{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s357224410", "group_id": "codeNet:p00001", "input_text": "import scala.io.StdIn._\n\nobject Main {\n def main(args: Array[String]): Unit = { \n val seq: Seq[Int] = (0 until 10).map(_ => readInt())\n val rev: Seq[Int] = seq.sorted.reverse\n for(i <- 0 until 3) println(rev(i))\n } \n}", "language": "Scala", "metadata": {"date": 1507292884, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00001.html", "problem_id": "p00001", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00001/input.txt", "sample_output_relpath": "derived/input_output/data/p00001/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00001/Scala/s357224410.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s357224410", "user_id": "u203887348"}, "prompt_components": {"gold_output": "3776\n2848\n2840\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main {\n def main(args: Array[String]): Unit = { \n val seq: Seq[Int] = (0 until 10).map(_ => readInt())\n val rev: Seq[Int] = seq.sorted.reverse\n for(i <- 0 until 3) println(rev(i))\n } \n}", "problem_context": "List of Top 3 Hills\n\nThere is a data which provides heights (in meter) of mountains. The data is only for ten mountains.\n\nWrite a program which prints heights of the top three mountains in descending order.\n\nInput\n\nHeight of mountain 1\nHeight of mountain 2\nHeight of mountain 3\n.\n.\nHeight of mountain 10\n\nConstraints\n\n0 ≤ height of mountain (integer) ≤ 10,000\n\nOutput\n\nHeight of the 1st mountain\nHeight of the 2nd mountain\nHeight of the 3rd mountain\n\nSample Input 1\n\n1819\n2003\n876\n2840\n1723\n1673\n3776\n2848\n1592\n922\n\nOutput for the Sample Input 1\n\n3776\n2848\n2840\n\nSample Input 2\n\n100\n200\n300\n400\n500\n600\n700\n800\n900\n900\n\nOutput for the Sample Input 2\n\n900\n900\n800", "sample_input": "1819\n2003\n876\n2840\n1723\n1673\n3776\n2848\n1592\n922\n"}, "reference_outputs": ["3776\n2848\n2840\n"], "source_document_id": "p00001", "source_text": "List of Top 3 Hills\n\nThere is a data which provides heights (in meter) of mountains. The data is only for ten mountains.\n\nWrite a program which prints heights of the top three mountains in descending order.\n\nInput\n\nHeight of mountain 1\nHeight of mountain 2\nHeight of mountain 3\n.\n.\nHeight of mountain 10\n\nConstraints\n\n0 ≤ height of mountain (integer) ≤ 10,000\n\nOutput\n\nHeight of the 1st mountain\nHeight of the 2nd mountain\nHeight of the 3rd mountain\n\nSample Input 1\n\n1819\n2003\n876\n2840\n1723\n1673\n3776\n2848\n1592\n922\n\nOutput for the Sample Input 1\n\n3776\n2848\n2840\n\nSample Input 2\n\n100\n200\n300\n400\n500\n600\n700\n800\n900\n900\n\nOutput for the Sample Input 2\n\n900\n900\n800", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 260, "memory_kb": 43940}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s771243672", "group_id": "codeNet:p00001", "input_text": "import scala.io.Source\n\nobject Main extends App {\n val input = Source.stdin.getLines\n input.toSeq.map(_.toInt).sorted.reverse.take(3).foreach(println)\n}\n\n", "language": "Scala", "metadata": {"date": 1515210035, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00001.html", "problem_id": "p00001", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00001/input.txt", "sample_output_relpath": "derived/input_output/data/p00001/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00001/Scala/s771243672.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s771243672", "user_id": "u809744987"}, "prompt_components": {"gold_output": "3776\n2848\n2840\n", "input_to_evaluate": "import scala.io.Source\n\nobject Main extends App {\n val input = Source.stdin.getLines\n input.toSeq.map(_.toInt).sorted.reverse.take(3).foreach(println)\n}\n\n", "problem_context": "List of Top 3 Hills\n\nThere is a data which provides heights (in meter) of mountains. The data is only for ten mountains.\n\nWrite a program which prints heights of the top three mountains in descending order.\n\nInput\n\nHeight of mountain 1\nHeight of mountain 2\nHeight of mountain 3\n.\n.\nHeight of mountain 10\n\nConstraints\n\n0 ≤ height of mountain (integer) ≤ 10,000\n\nOutput\n\nHeight of the 1st mountain\nHeight of the 2nd mountain\nHeight of the 3rd mountain\n\nSample Input 1\n\n1819\n2003\n876\n2840\n1723\n1673\n3776\n2848\n1592\n922\n\nOutput for the Sample Input 1\n\n3776\n2848\n2840\n\nSample Input 2\n\n100\n200\n300\n400\n500\n600\n700\n800\n900\n900\n\nOutput for the Sample Input 2\n\n900\n900\n800", "sample_input": "1819\n2003\n876\n2840\n1723\n1673\n3776\n2848\n1592\n922\n"}, "reference_outputs": ["3776\n2848\n2840\n"], "source_document_id": "p00001", "source_text": "List of Top 3 Hills\n\nThere is a data which provides heights (in meter) of mountains. The data is only for ten mountains.\n\nWrite a program which prints heights of the top three mountains in descending order.\n\nInput\n\nHeight of mountain 1\nHeight of mountain 2\nHeight of mountain 3\n.\n.\nHeight of mountain 10\n\nConstraints\n\n0 ≤ height of mountain (integer) ≤ 10,000\n\nOutput\n\nHeight of the 1st mountain\nHeight of the 2nd mountain\nHeight of the 3rd mountain\n\nSample Input 1\n\n1819\n2003\n876\n2840\n1723\n1673\n3776\n2848\n1592\n922\n\nOutput for the Sample Input 1\n\n3776\n2848\n2840\n\nSample Input 2\n\n100\n200\n300\n400\n500\n600\n700\n800\n900\n900\n\nOutput for the Sample Input 2\n\n900\n900\n800", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 260, "memory_kb": 44116}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s712655693", "group_id": "codeNet:p00002", "input_text": "import scala.io.Source.stdin\n\nobject Main {\n def main(args: Array[String]) = {\n stdin.getLines().map(_.split(\" \").map(_.toInt).reduce(_+_).toString.length).foreach(println)\n }\n}", "language": "Scala", "metadata": {"date": 1476112487, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00002.html", "problem_id": "p00002", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00002/input.txt", "sample_output_relpath": "derived/input_output/data/p00002/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00002/Scala/s712655693.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s712655693", "user_id": "u508732591"}, "prompt_components": {"gold_output": "2\n3\n4\n", "input_to_evaluate": "import scala.io.Source.stdin\n\nobject Main {\n def main(args: Array[String]) = {\n stdin.getLines().map(_.split(\" \").map(_.toInt).reduce(_+_).toString.length).foreach(println)\n }\n}", "problem_context": "Digit Number\n\nWrite a program which computes the digit number of sum of two integers a and b.\n\nInput\n\nThere are several test cases. Each test case consists of two non-negative integers a and b which are separeted by a space in a line. The input terminates with EOF.\n\nConstraints\n\n0 ≤ a, b ≤ 1,000,000\n\nThe number of datasets ≤ 200\n\nOutput\n\nPrint the number of digits of a + b for each data set.\n\nSample Input\n\n5 7\n1 99\n1000 999\n\nOutput for the Sample Input\n\n2\n3\n4", "sample_input": "5 7\n1 99\n1000 999\n"}, "reference_outputs": ["2\n3\n4\n"], "source_document_id": "p00002", "source_text": "Digit Number\n\nWrite a program which computes the digit number of sum of two integers a and b.\n\nInput\n\nThere are several test cases. Each test case consists of two non-negative integers a and b which are separeted by a space in a line. The input terminates with EOF.\n\nConstraints\n\n0 ≤ a, b ≤ 1,000,000\n\nThe number of datasets ≤ 200\n\nOutput\n\nPrint the number of digits of a + b for each data set.\n\nSample Input\n\n5 7\n1 99\n1000 999\n\nOutput for the Sample Input\n\n2\n3\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 44076}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s209964861", "group_id": "codeNet:p00003", "input_text": "object Main extends App{\n\n val n = io.StdIn.readInt()\n \n for (i <- 1 to n) {\n val sideAry = io.StdIn.readLine().split(' ').map { _.toInt }.sorted\n\n if (sideAry(2) * sideAry(2) == (sideAry(0) * sideAry(0) + sideAry(1) * sideAry(1)))\n println(\"YES\")\n else\n println(\"NO\")\n }\n}", "language": "Scala", "metadata": {"date": 1481113718, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00003.html", "problem_id": "p00003", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00003/input.txt", "sample_output_relpath": "derived/input_output/data/p00003/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00003/Scala/s209964861.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s209964861", "user_id": "u918841551"}, "prompt_components": {"gold_output": "YES\nNO\nNO\n", "input_to_evaluate": "object Main extends App{\n\n val n = io.StdIn.readInt()\n \n for (i <- 1 to n) {\n val sideAry = io.StdIn.readLine().split(' ').map { _.toInt }.sorted\n\n if (sideAry(2) * sideAry(2) == (sideAry(0) * sideAry(0) + sideAry(1) * sideAry(1)))\n println(\"YES\")\n else\n println(\"NO\")\n }\n}", "problem_context": "Is it a Right Triangle?\n\nWrite a program which judges wheather given length of three side form a right triangle. Print \"YES\" if the given sides (integers) form a right triangle, \"NO\" if not so.\n\nInput\n\nInput consists of several data sets. In the first line, the number of data set, N is given. Then, N lines follow, each line corresponds to a data set. A data set consists of three integers separated by a single space.\n\nConstraints\n\n1 ≤ length of the side ≤ 1,000\n\nN ≤ 1,000\n\nOutput\n\nFor each data set, print \"YES\" or \"NO\".\n\nSample Input\n\n3\n4 3 5\n4 3 6\n8 8 8\n\nOutput for the Sample Input\n\nYES\nNO\nNO", "sample_input": "3\n4 3 5\n4 3 6\n8 8 8\n"}, "reference_outputs": ["YES\nNO\nNO\n"], "source_document_id": "p00003", "source_text": "Is it a Right Triangle?\n\nWrite a program which judges wheather given length of three side form a right triangle. Print \"YES\" if the given sides (integers) form a right triangle, \"NO\" if not so.\n\nInput\n\nInput consists of several data sets. In the first line, the number of data set, N is given. Then, N lines follow, each line corresponds to a data set. A data set consists of three integers separated by a single space.\n\nConstraints\n\n1 ≤ length of the side ≤ 1,000\n\nN ≤ 1,000\n\nOutput\n\nFor each data set, print \"YES\" or \"NO\".\n\nSample Input\n\n3\n4 3 5\n4 3 6\n8 8 8\n\nOutput for the Sample Input\n\nYES\nNO\nNO", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 290, "memory_kb": 45200}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s945981136", "group_id": "codeNet:p00003", "input_text": "/**\n * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0003\n */\nobject Main {\n def main(args: Array[String]): Unit = {\n val N = io.StdIn.readInt()\n Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null).take(N)\n .map(_.split(\" +\").map(_.toInt) match { case Array(a, b, c) => (a, b, c) })\n .map { case (a, b, c) => isRightTriangle(a, b, c) }\n .map(if (_) \"Yes\" else \"No\")\n .foreach(println)\n }\n\n def isRightTriangle(x: Int, y: Int, z: Int): Boolean = {\n val (a, b, c) = Seq(x, y, z).sorted match {\n case Seq(_a, _b, _c) => (_a, _b, _c)\n }\n math.pow(a.toDouble, 2) + math.pow(b.toDouble, 2) == math.pow(c.toDouble, 2)\n }\n\n}", "language": "Scala", "metadata": {"date": 1497633564, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00003.html", "problem_id": "p00003", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00003/input.txt", "sample_output_relpath": "derived/input_output/data/p00003/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00003/Scala/s945981136.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s945981136", "user_id": "u757244973"}, "prompt_components": {"gold_output": "YES\nNO\nNO\n", "input_to_evaluate": "/**\n * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0003\n */\nobject Main {\n def main(args: Array[String]): Unit = {\n val N = io.StdIn.readInt()\n Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null).take(N)\n .map(_.split(\" +\").map(_.toInt) match { case Array(a, b, c) => (a, b, c) })\n .map { case (a, b, c) => isRightTriangle(a, b, c) }\n .map(if (_) \"Yes\" else \"No\")\n .foreach(println)\n }\n\n def isRightTriangle(x: Int, y: Int, z: Int): Boolean = {\n val (a, b, c) = Seq(x, y, z).sorted match {\n case Seq(_a, _b, _c) => (_a, _b, _c)\n }\n math.pow(a.toDouble, 2) + math.pow(b.toDouble, 2) == math.pow(c.toDouble, 2)\n }\n\n}", "problem_context": "Is it a Right Triangle?\n\nWrite a program which judges wheather given length of three side form a right triangle. Print \"YES\" if the given sides (integers) form a right triangle, \"NO\" if not so.\n\nInput\n\nInput consists of several data sets. In the first line, the number of data set, N is given. Then, N lines follow, each line corresponds to a data set. A data set consists of three integers separated by a single space.\n\nConstraints\n\n1 ≤ length of the side ≤ 1,000\n\nN ≤ 1,000\n\nOutput\n\nFor each data set, print \"YES\" or \"NO\".\n\nSample Input\n\n3\n4 3 5\n4 3 6\n8 8 8\n\nOutput for the Sample Input\n\nYES\nNO\nNO", "sample_input": "3\n4 3 5\n4 3 6\n8 8 8\n"}, "reference_outputs": ["YES\nNO\nNO\n"], "source_document_id": "p00003", "source_text": "Is it a Right Triangle?\n\nWrite a program which judges wheather given length of three side form a right triangle. Print \"YES\" if the given sides (integers) form a right triangle, \"NO\" if not so.\n\nInput\n\nInput consists of several data sets. In the first line, the number of data set, N is given. Then, N lines follow, each line corresponds to a data set. A data set consists of three integers separated by a single space.\n\nConstraints\n\n1 ≤ length of the side ≤ 1,000\n\nN ≤ 1,000\n\nOutput\n\nFor each data set, print \"YES\" or \"NO\".\n\nSample Input\n\n3\n4 3 5\n4 3 6\n8 8 8\n\nOutput for the Sample Input\n\nYES\nNO\nNO", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 684, "cpu_time_ms": 340, "memory_kb": 47368}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s076624977", "group_id": "codeNet:p00003", "input_text": "object Main extends App {\n (1 to readInt)\n .map(_ => readLine.split(\" \").map(_.toInt))\n .map(s => {\n val max = s.max\n if (s.filter(_ != max).map(_ ^ 2).sum == (max ^ 2)) \"YES\" else \"NO\"\n })\n .foreach(println)\n}\n\n", "language": "Scala", "metadata": {"date": 1528729928, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00003.html", "problem_id": "p00003", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00003/input.txt", "sample_output_relpath": "derived/input_output/data/p00003/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00003/Scala/s076624977.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s076624977", "user_id": "u927478431"}, "prompt_components": {"gold_output": "YES\nNO\nNO\n", "input_to_evaluate": "object Main extends App {\n (1 to readInt)\n .map(_ => readLine.split(\" \").map(_.toInt))\n .map(s => {\n val max = s.max\n if (s.filter(_ != max).map(_ ^ 2).sum == (max ^ 2)) \"YES\" else \"NO\"\n })\n .foreach(println)\n}\n\n", "problem_context": "Is it a Right Triangle?\n\nWrite a program which judges wheather given length of three side form a right triangle. Print \"YES\" if the given sides (integers) form a right triangle, \"NO\" if not so.\n\nInput\n\nInput consists of several data sets. In the first line, the number of data set, N is given. Then, N lines follow, each line corresponds to a data set. A data set consists of three integers separated by a single space.\n\nConstraints\n\n1 ≤ length of the side ≤ 1,000\n\nN ≤ 1,000\n\nOutput\n\nFor each data set, print \"YES\" or \"NO\".\n\nSample Input\n\n3\n4 3 5\n4 3 6\n8 8 8\n\nOutput for the Sample Input\n\nYES\nNO\nNO", "sample_input": "3\n4 3 5\n4 3 6\n8 8 8\n"}, "reference_outputs": ["YES\nNO\nNO\n"], "source_document_id": "p00003", "source_text": "Is it a Right Triangle?\n\nWrite a program which judges wheather given length of three side form a right triangle. Print \"YES\" if the given sides (integers) form a right triangle, \"NO\" if not so.\n\nInput\n\nInput consists of several data sets. In the first line, the number of data set, N is given. Then, N lines follow, each line corresponds to a data set. A data set consists of three integers separated by a single space.\n\nConstraints\n\n1 ≤ length of the side ≤ 1,000\n\nN ≤ 1,000\n\nOutput\n\nFor each data set, print \"YES\" or \"NO\".\n\nSample Input\n\n3\n4 3 5\n4 3 6\n8 8 8\n\nOutput for the Sample Input\n\nYES\nNO\nNO", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 300, "memory_kb": 46604}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s987516967", "group_id": "codeNet:p00003", "input_text": "object Main extends App {\n def square(a: Int) = a * a\n (1 to readInt)\n .map(_ => readLine.split(\" \").map(_.toInt).sorted.reverse)\n .map(s => if (s.tail.map(square).sum == square(s.head)) \"YES\" else \"NO\")\n .foreach(println)\n}\n", "language": "Scala", "metadata": {"date": 1528730558, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00003.html", "problem_id": "p00003", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00003/input.txt", "sample_output_relpath": "derived/input_output/data/p00003/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00003/Scala/s987516967.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s987516967", "user_id": "u927478431"}, "prompt_components": {"gold_output": "YES\nNO\nNO\n", "input_to_evaluate": "object Main extends App {\n def square(a: Int) = a * a\n (1 to readInt)\n .map(_ => readLine.split(\" \").map(_.toInt).sorted.reverse)\n .map(s => if (s.tail.map(square).sum == square(s.head)) \"YES\" else \"NO\")\n .foreach(println)\n}\n", "problem_context": "Is it a Right Triangle?\n\nWrite a program which judges wheather given length of three side form a right triangle. Print \"YES\" if the given sides (integers) form a right triangle, \"NO\" if not so.\n\nInput\n\nInput consists of several data sets. In the first line, the number of data set, N is given. Then, N lines follow, each line corresponds to a data set. A data set consists of three integers separated by a single space.\n\nConstraints\n\n1 ≤ length of the side ≤ 1,000\n\nN ≤ 1,000\n\nOutput\n\nFor each data set, print \"YES\" or \"NO\".\n\nSample Input\n\n3\n4 3 5\n4 3 6\n8 8 8\n\nOutput for the Sample Input\n\nYES\nNO\nNO", "sample_input": "3\n4 3 5\n4 3 6\n8 8 8\n"}, "reference_outputs": ["YES\nNO\nNO\n"], "source_document_id": "p00003", "source_text": "Is it a Right Triangle?\n\nWrite a program which judges wheather given length of three side form a right triangle. Print \"YES\" if the given sides (integers) form a right triangle, \"NO\" if not so.\n\nInput\n\nInput consists of several data sets. In the first line, the number of data set, N is given. Then, N lines follow, each line corresponds to a data set. A data set consists of three integers separated by a single space.\n\nConstraints\n\n1 ≤ length of the side ≤ 1,000\n\nN ≤ 1,000\n\nOutput\n\nFor each data set, print \"YES\" or \"NO\".\n\nSample Input\n\n3\n4 3 5\n4 3 6\n8 8 8\n\nOutput for the Sample Input\n\nYES\nNO\nNO", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 310, "memory_kb": 46364}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s196530100", "group_id": "codeNet:p00004", "input_text": "object Main {\n\tdef main(args:Array[String]) = {\n\t val sc = new java.util.Scanner(System.in)\n\t while(sc.hasNext){\n\t val a,b,c,d,e,f = sc.nextInt\n\t val y = (c*d-a*f)/(b*d-a*e)\n\t val x = (c-b*y)/a\n\t println(BigDecimal(x).setScale(3, BigDecimal.RoundingMode.HALF_UP)+\" \"+BigDecimal(y).setScale(3, BigDecimal.RoundingMode.HALF_UP))\n\t }\n\n }\n}", "language": "Scala", "metadata": {"date": 1446051523, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00004.html", "problem_id": "p00004", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00004/input.txt", "sample_output_relpath": "derived/input_output/data/p00004/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00004/Scala/s196530100.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s196530100", "user_id": "u271453140"}, "prompt_components": {"gold_output": "-1.000 2.000\n1.000 4.000\n", "input_to_evaluate": "object Main {\n\tdef main(args:Array[String]) = {\n\t val sc = new java.util.Scanner(System.in)\n\t while(sc.hasNext){\n\t val a,b,c,d,e,f = sc.nextInt\n\t val y = (c*d-a*f)/(b*d-a*e)\n\t val x = (c-b*y)/a\n\t println(BigDecimal(x).setScale(3, BigDecimal.RoundingMode.HALF_UP)+\" \"+BigDecimal(y).setScale(3, BigDecimal.RoundingMode.HALF_UP))\n\t }\n\n }\n}", "problem_context": "Simultaneous Equation\n\nWrite a program which solve a simultaneous equation:\n\nax + by = c\n\ndx + ey = f\n\nThe program should print x and y for given a, b, c, d, e and f (-1,000 ≤ a, b, c, d, e, f ≤ 1,000). You can suppose that given equation has a unique solution.\n\nInput\n\nThe input consists of several data sets, 1 line for each data set. In a data set, there will be a, b, c, d, e, f separated by a single space. The input terminates with EOF.\n\nOutput\n\nFor each data set, print x and y separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places.\n\nSample Input 1\n\n1 2 3 4 5 6\n2 -1 -2 -1 -1 -5\n\nOutput for the Sample Input 1\n\n-1.000 2.000\n1.000 4.000\n\nSample Input 2\n\n2 -1 -3 1 -1 -3\n2 -1 -3 -9 9 27\n\nOutput for the Sample Input 2\n\n0.000 3.000\n0.000 3.000", "sample_input": "1 2 3 4 5 6\n2 -1 -2 -1 -1 -5\n"}, "reference_outputs": ["-1.000 2.000\n1.000 4.000\n"], "source_document_id": "p00004", "source_text": "Simultaneous Equation\n\nWrite a program which solve a simultaneous equation:\n\nax + by = c\n\ndx + ey = f\n\nThe program should print x and y for given a, b, c, d, e and f (-1,000 ≤ a, b, c, d, e, f ≤ 1,000). You can suppose that given equation has a unique solution.\n\nInput\n\nThe input consists of several data sets, 1 line for each data set. In a data set, there will be a, b, c, d, e, f separated by a single space. The input terminates with EOF.\n\nOutput\n\nFor each data set, print x and y separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places.\n\nSample Input 1\n\n1 2 3 4 5 6\n2 -1 -2 -1 -1 -5\n\nOutput for the Sample Input 1\n\n-1.000 2.000\n1.000 4.000\n\nSample Input 2\n\n2 -1 -3 1 -1 -3\n2 -1 -3 -9 9 27\n\nOutput for the Sample Input 2\n\n0.000 3.000\n0.000 3.000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 368, "cpu_time_ms": 250, "memory_kb": 45080}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s726438184", "group_id": "codeNet:p00004", "input_text": "object Main extends App {\n\n def safeDivide(l: Double, r: Double) = if (l == 0.0) 0.0 else l / r\n def format(x: Double) = {\n val s = (x * 1000).round formatted \"%04d\"\n s.dropRight(3) + \".\" + s.takeRight(3)\n }\n\n val sc = new java.util.Scanner(Console.in)\n\n while (sc.hasNextLine()) {\n val line = sc.nextLine()\n val Array(a, b, c, d, e, f) = line.split(' ').map(_.toDouble)\n val x = safeDivide(c*e - b*f, a*e - b*d)\n val y = safeDivide(c - a*x, b)\n\n println(format(x) + \" \" + format(y))\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1523077555, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00004.html", "problem_id": "p00004", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00004/input.txt", "sample_output_relpath": "derived/input_output/data/p00004/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00004/Scala/s726438184.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s726438184", "user_id": "u816370254"}, "prompt_components": {"gold_output": "-1.000 2.000\n1.000 4.000\n", "input_to_evaluate": "object Main extends App {\n\n def safeDivide(l: Double, r: Double) = if (l == 0.0) 0.0 else l / r\n def format(x: Double) = {\n val s = (x * 1000).round formatted \"%04d\"\n s.dropRight(3) + \".\" + s.takeRight(3)\n }\n\n val sc = new java.util.Scanner(Console.in)\n\n while (sc.hasNextLine()) {\n val line = sc.nextLine()\n val Array(a, b, c, d, e, f) = line.split(' ').map(_.toDouble)\n val x = safeDivide(c*e - b*f, a*e - b*d)\n val y = safeDivide(c - a*x, b)\n\n println(format(x) + \" \" + format(y))\n }\n}\n\n", "problem_context": "Simultaneous Equation\n\nWrite a program which solve a simultaneous equation:\n\nax + by = c\n\ndx + ey = f\n\nThe program should print x and y for given a, b, c, d, e and f (-1,000 ≤ a, b, c, d, e, f ≤ 1,000). You can suppose that given equation has a unique solution.\n\nInput\n\nThe input consists of several data sets, 1 line for each data set. In a data set, there will be a, b, c, d, e, f separated by a single space. The input terminates with EOF.\n\nOutput\n\nFor each data set, print x and y separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places.\n\nSample Input 1\n\n1 2 3 4 5 6\n2 -1 -2 -1 -1 -5\n\nOutput for the Sample Input 1\n\n-1.000 2.000\n1.000 4.000\n\nSample Input 2\n\n2 -1 -3 1 -1 -3\n2 -1 -3 -9 9 27\n\nOutput for the Sample Input 2\n\n0.000 3.000\n0.000 3.000", "sample_input": "1 2 3 4 5 6\n2 -1 -2 -1 -1 -5\n"}, "reference_outputs": ["-1.000 2.000\n1.000 4.000\n"], "source_document_id": "p00004", "source_text": "Simultaneous Equation\n\nWrite a program which solve a simultaneous equation:\n\nax + by = c\n\ndx + ey = f\n\nThe program should print x and y for given a, b, c, d, e and f (-1,000 ≤ a, b, c, d, e, f ≤ 1,000). You can suppose that given equation has a unique solution.\n\nInput\n\nThe input consists of several data sets, 1 line for each data set. In a data set, there will be a, b, c, d, e, f separated by a single space. The input terminates with EOF.\n\nOutput\n\nFor each data set, print x and y separated by a single space. Print the solution to three places of decimals. Round off the solution to three decimal places.\n\nSample Input 1\n\n1 2 3 4 5 6\n2 -1 -2 -1 -1 -5\n\nOutput for the Sample Input 1\n\n-1.000 2.000\n1.000 4.000\n\nSample Input 2\n\n2 -1 -3 1 -1 -3\n2 -1 -3 -9 9 27\n\nOutput for the Sample Input 2\n\n0.000 3.000\n0.000 3.000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 517, "cpu_time_ms": 250, "memory_kb": 45376}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s789718586", "group_id": "codeNet:p00007", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n var num: BigInt = 100000\n for(i <- 0 until n) {\n num += num / 20\n if(num%10!=0) {\n num = num / 10\n num = num * 10 + 10\n }\n if(num%100!=0) {\n num = num / 100\n num = num * 100 + 100\n }\n if(num%1000!=1000) {\n num = num / 1000\n num = num * 1000 + 1000\n }\n }\n println(num-1000)\n}", "language": "Scala", "metadata": {"date": 1453297023, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00007.html", "problem_id": "p00007", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00007/input.txt", "sample_output_relpath": "derived/input_output/data/p00007/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00007/Scala/s789718586.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s789718586", "user_id": "u915343634"}, "prompt_components": {"gold_output": "130000\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n var num: BigInt = 100000\n for(i <- 0 until n) {\n num += num / 20\n if(num%10!=0) {\n num = num / 10\n num = num * 10 + 10\n }\n if(num%100!=0) {\n num = num / 100\n num = num * 100 + 100\n }\n if(num%1000!=1000) {\n num = num / 1000\n num = num * 1000 + 1000\n }\n }\n println(num-1000)\n}", "problem_context": "Debt Hell\n\nYour friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.\n\nWrite a program which computes the amount of the debt in n weeks.\n\nInput\n\nAn integer n (0 ≤ n ≤ 100) is given in a line.\n\nOutput\n\nPrint the amout of the debt in a line.\n\nSample Input\n\n5\n\nOutput for the Sample Input\n\n130000", "sample_input": "5\n"}, "reference_outputs": ["130000\n"], "source_document_id": "p00007", "source_text": "Debt Hell\n\nYour friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.\n\nWrite a program which computes the amount of the debt in n weeks.\n\nInput\n\nAn integer n (0 ≤ n ≤ 100) is given in a line.\n\nOutput\n\nPrint the amout of the debt in a line.\n\nSample Input\n\n5\n\nOutput for the Sample Input\n\n130000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 320, "memory_kb": 45456}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s141263337", "group_id": "codeNet:p00008", "input_text": "object Main {\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n while(sc.hasNext){\n\t val n = sc.nextInt\n\t val list = for(a <- 0 to 9; b <- 0 to 9; c <- 0 to 9; d <- 0 to 9 if a+b+c+d == n) yield 1\n\t println(list.size)\n \t}\n }\n}", "language": "Scala", "metadata": {"date": 1448095988, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00008.html", "problem_id": "p00008", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00008/input.txt", "sample_output_relpath": "derived/input_output/data/p00008/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00008/Scala/s141263337.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s141263337", "user_id": "u271453140"}, "prompt_components": {"gold_output": "4\n4\n", "input_to_evaluate": "object Main {\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n while(sc.hasNext){\n\t val n = sc.nextInt\n\t val list = for(a <- 0 to 9; b <- 0 to 9; c <- 0 to 9; d <- 0 to 9 if a+b+c+d == n) yield 1\n\t println(list.size)\n \t}\n }\n}", "problem_context": "Sum of 4 Integers\n\nWrite a program which reads an integer n and identifies the number of combinations of a, b, c and d (0 ≤ a, b, c, d ≤ 9) which meet the following equality:\n\na + b + c + d = n\n\nFor example, for n = 35, we have 4 different combinations of (a, b, c, d): (8, 9, 9, 9), (9, 8, 9, 9), (9, 9, 8, 9), and (9, 9, 9, 8).\n\nInput\n\nThe input consists of several datasets. Each dataset consists of n (1 ≤ n ≤ 50) in a line. The number of datasets is less than or equal to 50.\n\nOutput\n\nPrint the number of combination in a line.\n\nSample Input\n\n35\n1\n\nOutput for the Sample Input\n\n4\n4", "sample_input": "35\n1\n"}, "reference_outputs": ["4\n4\n"], "source_document_id": "p00008", "source_text": "Sum of 4 Integers\n\nWrite a program which reads an integer n and identifies the number of combinations of a, b, c and d (0 ≤ a, b, c, d ≤ 9) which meet the following equality:\n\na + b + c + d = n\n\nFor example, for n = 35, we have 4 different combinations of (a, b, c, d): (8, 9, 9, 9), (9, 8, 9, 9), (9, 9, 8, 9), and (9, 9, 9, 8).\n\nInput\n\nThe input consists of several datasets. Each dataset consists of n (1 ≤ n ≤ 50) in a line. The number of datasets is less than or equal to 50.\n\nOutput\n\nPrint the number of combination in a line.\n\nSample Input\n\n35\n1\n\nOutput for the Sample Input\n\n4\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 420, "memory_kb": 76892}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s493025542", "group_id": "codeNet:p00009", "input_text": "import scala.io.StdIn._\nimport scala.collection._\n\nobject Main {\n\n class Sieve(val n: Int){\n private[this] val top = (n - 3) / 2 + 1\n private[this] val sqrtLimit = (Math.sqrt(n).toInt - 3) / 2\n\n private[this] val cmpsts = new Array[Int]((top >>> 5) + 1)\n def isPrime(ci: Int): Boolean = (cmpsts(ci >>> 5) & (1 << (ci & 31))) == 0\n def notPrime(ci: Int): Unit = cmpsts(ci >>> 5) |= 1 << (ci & 31)\n\n def next(i: Int): Int = if((i > top) || isPrime(i)) 2 * i + 3 else next(i + 1)\n\n def exec: Iterator[Int] = {\n/*\n for{\n i <- 0 to sqrtLimit\n if isPrime(i)\n j <- Range(((2 * i + 3)*(2 * i + 3)-3)/2, top, (2 * i + 3))\n } notPrime(j)\n */\n /*\n (0 to sqrtLimit).map{ i =>\n val p = 2 * i + 3\n if(isPrime(i))Range((p*p-3)/2, top, p).map{notPrime}\n }\n */\n\n (0 to sqrtLimit).withFilter(isPrime).map { i =>\n Range(((2 * i + 3)*(2 * i + 3)-3)/2, top, (2 * i + 3)).map(notPrime)\n }\n\n\n if(n==2)Iterator.single(2)\n else Iterator.single(2) ++ Iterator.iterate(3)(p => next((p - 1) / 2)).takeWhile(_ <= n)\n }\n }\n\n def loop(s: String){\n if(s != null){\n val Array(n,_*) = s.split(\" \").map(_.toInt)\n if(n<2) println(0)\n else println(new Sieve(n).exec.size)\n loop(readLine)\n }\n }\n\n def main(args: Array[String]): Unit = loop(readLine)\n}", "language": "Scala", "metadata": {"date": 1435800536, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00009.html", "problem_id": "p00009", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00009/input.txt", "sample_output_relpath": "derived/input_output/data/p00009/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00009/Scala/s493025542.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s493025542", "user_id": "u047988051"}, "prompt_components": {"gold_output": "4\n2\n5\n", "input_to_evaluate": "import scala.io.StdIn._\nimport scala.collection._\n\nobject Main {\n\n class Sieve(val n: Int){\n private[this] val top = (n - 3) / 2 + 1\n private[this] val sqrtLimit = (Math.sqrt(n).toInt - 3) / 2\n\n private[this] val cmpsts = new Array[Int]((top >>> 5) + 1)\n def isPrime(ci: Int): Boolean = (cmpsts(ci >>> 5) & (1 << (ci & 31))) == 0\n def notPrime(ci: Int): Unit = cmpsts(ci >>> 5) |= 1 << (ci & 31)\n\n def next(i: Int): Int = if((i > top) || isPrime(i)) 2 * i + 3 else next(i + 1)\n\n def exec: Iterator[Int] = {\n/*\n for{\n i <- 0 to sqrtLimit\n if isPrime(i)\n j <- Range(((2 * i + 3)*(2 * i + 3)-3)/2, top, (2 * i + 3))\n } notPrime(j)\n */\n /*\n (0 to sqrtLimit).map{ i =>\n val p = 2 * i + 3\n if(isPrime(i))Range((p*p-3)/2, top, p).map{notPrime}\n }\n */\n\n (0 to sqrtLimit).withFilter(isPrime).map { i =>\n Range(((2 * i + 3)*(2 * i + 3)-3)/2, top, (2 * i + 3)).map(notPrime)\n }\n\n\n if(n==2)Iterator.single(2)\n else Iterator.single(2) ++ Iterator.iterate(3)(p => next((p - 1) / 2)).takeWhile(_ <= n)\n }\n }\n\n def loop(s: String){\n if(s != null){\n val Array(n,_*) = s.split(\" \").map(_.toInt)\n if(n<2) println(0)\n else println(new Sieve(n).exec.size)\n loop(readLine)\n }\n }\n\n def main(args: Array[String]): Unit = loop(readLine)\n}", "problem_context": "Prime Number\n\nWrite a program which reads an integer n and prints the number of prime numbers which are less than or equal to n. A 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\nInput\n\nInput consists of several datasets. Each dataset has an integer n (1 ≤ n ≤ 999,999) in a line.\n\nThe number of datasets is less than or equal to 30.\n\nOutput\n\nFor each dataset, prints the number of prime numbers.\n\nSample Input\n\n10\n3\n11\n\nOutput for the Sample Input\n\n4\n2\n5", "sample_input": "10\n3\n11\n"}, "reference_outputs": ["4\n2\n5\n"], "source_document_id": "p00009", "source_text": "Prime Number\n\nWrite a program which reads an integer n and prints the number of prime numbers which are less than or equal to n. A 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\nInput\n\nInput consists of several datasets. Each dataset has an integer n (1 ≤ n ≤ 999,999) in a line.\n\nThe number of datasets is less than or equal to 30.\n\nOutput\n\nFor each dataset, prints the number of prime numbers.\n\nSample Input\n\n10\n3\n11\n\nOutput for the Sample Input\n\n4\n2\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1371, "cpu_time_ms": 510, "memory_kb": 306332}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s595246279", "group_id": "codeNet:p00009", "input_text": "import scala.io.StdIn.readInt\n\nobject Main {\n def sieve(n:Int) = {\n val primes = Array.tabulate(n+1) { _ % 2 }\n primes(1) = 0\n primes(2) = 1\n\n for{\n i <- 3 to Math.sqrt(n).toInt by 2\n if primes(i) == 1\n }\n (i*i to n by i*2).foreach { primes(_) = 0 }\n\n primes\n }\n\n def main(args:Array[String]) = {\n val p = sieve(1000000)\n val n = readInt\n println(p.take(n+1).sum)\n }\n}", "language": "Scala", "metadata": {"date": 1483870198, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00009.html", "problem_id": "p00009", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00009/input.txt", "sample_output_relpath": "derived/input_output/data/p00009/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00009/Scala/s595246279.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s595246279", "user_id": "u508732591"}, "prompt_components": {"gold_output": "4\n2\n5\n", "input_to_evaluate": "import scala.io.StdIn.readInt\n\nobject Main {\n def sieve(n:Int) = {\n val primes = Array.tabulate(n+1) { _ % 2 }\n primes(1) = 0\n primes(2) = 1\n\n for{\n i <- 3 to Math.sqrt(n).toInt by 2\n if primes(i) == 1\n }\n (i*i to n by i*2).foreach { primes(_) = 0 }\n\n primes\n }\n\n def main(args:Array[String]) = {\n val p = sieve(1000000)\n val n = readInt\n println(p.take(n+1).sum)\n }\n}", "problem_context": "Prime Number\n\nWrite a program which reads an integer n and prints the number of prime numbers which are less than or equal to n. A 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\nInput\n\nInput consists of several datasets. Each dataset has an integer n (1 ≤ n ≤ 999,999) in a line.\n\nThe number of datasets is less than or equal to 30.\n\nOutput\n\nFor each dataset, prints the number of prime numbers.\n\nSample Input\n\n10\n3\n11\n\nOutput for the Sample Input\n\n4\n2\n5", "sample_input": "10\n3\n11\n"}, "reference_outputs": ["4\n2\n5\n"], "source_document_id": "p00009", "source_text": "Prime Number\n\nWrite a program which reads an integer n and prints the number of prime numbers which are less than or equal to n. A 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\nInput\n\nInput consists of several datasets. Each dataset has an integer n (1 ≤ n ≤ 999,999) in a line.\n\nThe number of datasets is less than or equal to 30.\n\nOutput\n\nFor each dataset, prints the number of prime numbers.\n\nSample Input\n\n10\n3\n11\n\nOutput for the Sample Input\n\n4\n2\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 270, "memory_kb": 63596}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s733560450", "group_id": "codeNet:p00009", "input_text": "import scala.io.Source.stdin\n \nobject Main {\n def sieve(n:Int) = {\n val primes = Array.tabulate(n+1) { _ % 2 }\n primes(1) = 0\n primes(2) = 1\n \n for( i <- 3 to Math.sqrt(n).toInt by 2 )\n {\n if(primes(i) == 1)\n (i*i to n by i*2).foreach { primes(_) = 0 }\n primes(i) = primes(i) + primes(i-1)\n primes(i+1) = primes(i)\n }\n \n for(i<-Math.sqrt(n).toInt+1 to n)\n primes(i) = primes(i)+primes(i-1)\n \n primes\n }\n \n def main(args:Array[String]) = {\n val p = sieve(1000000)\n for(i <- stdin.getLines) \n println(p(i.toInt))\n }\n}", "language": "Scala", "metadata": {"date": 1483872648, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00009.html", "problem_id": "p00009", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00009/input.txt", "sample_output_relpath": "derived/input_output/data/p00009/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00009/Scala/s733560450.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s733560450", "user_id": "u508732591"}, "prompt_components": {"gold_output": "4\n2\n5\n", "input_to_evaluate": "import scala.io.Source.stdin\n \nobject Main {\n def sieve(n:Int) = {\n val primes = Array.tabulate(n+1) { _ % 2 }\n primes(1) = 0\n primes(2) = 1\n \n for( i <- 3 to Math.sqrt(n).toInt by 2 )\n {\n if(primes(i) == 1)\n (i*i to n by i*2).foreach { primes(_) = 0 }\n primes(i) = primes(i) + primes(i-1)\n primes(i+1) = primes(i)\n }\n \n for(i<-Math.sqrt(n).toInt+1 to n)\n primes(i) = primes(i)+primes(i-1)\n \n primes\n }\n \n def main(args:Array[String]) = {\n val p = sieve(1000000)\n for(i <- stdin.getLines) \n println(p(i.toInt))\n }\n}", "problem_context": "Prime Number\n\nWrite a program which reads an integer n and prints the number of prime numbers which are less than or equal to n. A 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\nInput\n\nInput consists of several datasets. Each dataset has an integer n (1 ≤ n ≤ 999,999) in a line.\n\nThe number of datasets is less than or equal to 30.\n\nOutput\n\nFor each dataset, prints the number of prime numbers.\n\nSample Input\n\n10\n3\n11\n\nOutput for the Sample Input\n\n4\n2\n5", "sample_input": "10\n3\n11\n"}, "reference_outputs": ["4\n2\n5\n"], "source_document_id": "p00009", "source_text": "Prime Number\n\nWrite a program which reads an integer n and prints the number of prime numbers which are less than or equal to n. A 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\nInput\n\nInput consists of several datasets. Each dataset has an integer n (1 ≤ n ≤ 999,999) in a line.\n\nThe number of datasets is less than or equal to 30.\n\nOutput\n\nFor each dataset, prints the number of prime numbers.\n\nSample Input\n\n10\n3\n11\n\nOutput for the Sample Input\n\n4\n2\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 581, "cpu_time_ms": 260, "memory_kb": 63680}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s301339184", "group_id": "codeNet:p00009", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n io.Source.stdin.getLines foreach (n => println(pi(n.toInt)))\n }\n val primes: Vector[Int] = (2 #:: Stream.from(3).filter(n=> Primes.miller_rabin_test(n))).take(1000).toVector\n\n def pi(x: Int): Int = {\n if (x <= 1) 0\n else {\n val a = pi(Math.sqrt(x).toInt)\n phi(x, a) + a - 1\n }\n }\n\n def phi(x: Int, a:Int): Int = {\n val ps = primes take a\n (1 to x).count(i => ps.forall(p => i % p != 0))\n }\n object Primes {\n private def mod_exp(x: BigInt, n: Int, m: Int): BigInt = {\n def loop(x: BigInt, n: Int, acc: BigInt): BigInt = {\n if (n == 0) acc\n else loop (\n (x * x) % m,\n n >> 1,\n if ((n & 1) == 1) (acc * x) % m else acc\n )\n }\n loop(x,n,1)\n }\n private def div_pow_2(d: Int, s: Int = 0): (Int, Int) ={\n if ((d % 2) != 0) (d,s)\n else div_pow_2(d/2, s+1)\n }\n private def miller_rabin(n: Int, a: Int): Boolean = {\n val (d,s): (Int, Int) = div_pow_2(n-1)\n val a_exp_d: BigInt = mod_exp(a,d,n)\n def double(x: BigInt): BigInt = mod_exp(x,2,n)\n def loop(e: BigInt, i: Int): Boolean = {\n if (i == 0) false\n else if (e == n-1) true\n else loop(double(e), i-1)\n }\n a_exp_d == 1 || loop(a_exp_d, s)\n }\n def miller_rabin_test(n: Int, k: Int = 20): Boolean = {\n def loop(i: Int): Boolean = {\n if (i == 0) true\n else {\n val a = scala.util.Random.nextInt(n-1)+1\n if (miller_rabin(n,a)) loop(i-1)\n else false\n }\n }\n if (n < 2) false\n else loop(k)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1512537495, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00009.html", "problem_id": "p00009", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00009/input.txt", "sample_output_relpath": "derived/input_output/data/p00009/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00009/Scala/s301339184.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Memory Limit Exceeded", "submission_id": "s301339184", "user_id": "u995793569"}, "prompt_components": {"gold_output": "4\n2\n5\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n io.Source.stdin.getLines foreach (n => println(pi(n.toInt)))\n }\n val primes: Vector[Int] = (2 #:: Stream.from(3).filter(n=> Primes.miller_rabin_test(n))).take(1000).toVector\n\n def pi(x: Int): Int = {\n if (x <= 1) 0\n else {\n val a = pi(Math.sqrt(x).toInt)\n phi(x, a) + a - 1\n }\n }\n\n def phi(x: Int, a:Int): Int = {\n val ps = primes take a\n (1 to x).count(i => ps.forall(p => i % p != 0))\n }\n object Primes {\n private def mod_exp(x: BigInt, n: Int, m: Int): BigInt = {\n def loop(x: BigInt, n: Int, acc: BigInt): BigInt = {\n if (n == 0) acc\n else loop (\n (x * x) % m,\n n >> 1,\n if ((n & 1) == 1) (acc * x) % m else acc\n )\n }\n loop(x,n,1)\n }\n private def div_pow_2(d: Int, s: Int = 0): (Int, Int) ={\n if ((d % 2) != 0) (d,s)\n else div_pow_2(d/2, s+1)\n }\n private def miller_rabin(n: Int, a: Int): Boolean = {\n val (d,s): (Int, Int) = div_pow_2(n-1)\n val a_exp_d: BigInt = mod_exp(a,d,n)\n def double(x: BigInt): BigInt = mod_exp(x,2,n)\n def loop(e: BigInt, i: Int): Boolean = {\n if (i == 0) false\n else if (e == n-1) true\n else loop(double(e), i-1)\n }\n a_exp_d == 1 || loop(a_exp_d, s)\n }\n def miller_rabin_test(n: Int, k: Int = 20): Boolean = {\n def loop(i: Int): Boolean = {\n if (i == 0) true\n else {\n val a = scala.util.Random.nextInt(n-1)+1\n if (miller_rabin(n,a)) loop(i-1)\n else false\n }\n }\n if (n < 2) false\n else loop(k)\n }\n }\n}", "problem_context": "Prime Number\n\nWrite a program which reads an integer n and prints the number of prime numbers which are less than or equal to n. A 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\nInput\n\nInput consists of several datasets. Each dataset has an integer n (1 ≤ n ≤ 999,999) in a line.\n\nThe number of datasets is less than or equal to 30.\n\nOutput\n\nFor each dataset, prints the number of prime numbers.\n\nSample Input\n\n10\n3\n11\n\nOutput for the Sample Input\n\n4\n2\n5", "sample_input": "10\n3\n11\n"}, "reference_outputs": ["4\n2\n5\n"], "source_document_id": "p00009", "source_text": "Prime Number\n\nWrite a program which reads an integer n and prints the number of prime numbers which are less than or equal to n. A 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\nInput\n\nInput consists of several datasets. Each dataset has an integer n (1 ≤ n ≤ 999,999) in a line.\n\nThe number of datasets is less than or equal to 30.\n\nOutput\n\nFor each dataset, prints the number of prime numbers.\n\nSample Input\n\n10\n3\n11\n\nOutput for the Sample Input\n\n4\n2\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1642, "cpu_time_ms": 3580, "memory_kb": 575672}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s639043768", "group_id": "codeNet:p00010", "input_text": "import scala.io.StdIn.{readLine,readInt}\n\nobject Main {\n def main(args:Array[String]) = {\n val n = readInt\n for(i <- 0 until n) {\n val m = readLine.split(\" \").map(_.toDouble)\n val (x12,y12,x13,y13) = (m(0)-m(2),m(1)-m(3),m(0)-m(4),m(1)-m(5))\n val (xx1,yy1,xx2,yy2,xx3,yy3) = (m(0)*m(0),m(1)*m(1),m(2)*m(2),m(3)*m(3),m(4)*m(4),m(5)*m(5))\n val g = 2*(x12*y13 - y12*x13)\n val x = (y13*(xx1 - xx2 + yy1 - yy2) - y12*(xx1 - xx3 + yy1 - yy3))/g\n val y = (x12*(xx1 - xx3 + yy1 - yy3) - x13*(xx1 - xx2 + yy1 - yy2))/g\n\n printf(\"%.3f %.3f %.3f\\n\",x,y,Math.sqrt(x*x+y*y))\n\n }\n }\n}", "language": "Scala", "metadata": {"date": 1484029618, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00010.html", "problem_id": "p00010", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00010/input.txt", "sample_output_relpath": "derived/input_output/data/p00010/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00010/Scala/s639043768.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s639043768", "user_id": "u508732591"}, "prompt_components": {"gold_output": "1.000 1.000 1.414\n", "input_to_evaluate": "import scala.io.StdIn.{readLine,readInt}\n\nobject Main {\n def main(args:Array[String]) = {\n val n = readInt\n for(i <- 0 until n) {\n val m = readLine.split(\" \").map(_.toDouble)\n val (x12,y12,x13,y13) = (m(0)-m(2),m(1)-m(3),m(0)-m(4),m(1)-m(5))\n val (xx1,yy1,xx2,yy2,xx3,yy3) = (m(0)*m(0),m(1)*m(1),m(2)*m(2),m(3)*m(3),m(4)*m(4),m(5)*m(5))\n val g = 2*(x12*y13 - y12*x13)\n val x = (y13*(xx1 - xx2 + yy1 - yy2) - y12*(xx1 - xx3 + yy1 - yy3))/g\n val y = (x12*(xx1 - xx3 + yy1 - yy3) - x13*(xx1 - xx2 + yy1 - yy2))/g\n\n printf(\"%.3f %.3f %.3f\\n\",x,y,Math.sqrt(x*x+y*y))\n\n }\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nCircumscribed Circle of A Triangle.\n\nWrite a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface.\n\nInput\n\nInput consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:\n\n$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$\n\nin a line. All the input are real numbers.\n\nOutput\n\nFor each dataset, print $p_x$, $p_y$ and $r$ separated by a space in a line. Print the solution to three places of decimals. Round off the solution to three decimal places.\n\nConstraints\n\n$-100 \\leq x_1, y_1, x_2, y_2, x_3, y_3 \\leq 100$\n\n$ n \\leq 20$\n\nSample Input\n\n1\n0.0 0.0 2.0 0.0 2.0 2.0\n\nOutput for the Sample Input\n\n1.000 1.000 1.414", "sample_input": "1\n0.0 0.0 2.0 0.0 2.0 2.0\n"}, "reference_outputs": ["1.000 1.000 1.414\n"], "source_document_id": "p00010", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nCircumscribed Circle of A Triangle.\n\nWrite a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface.\n\nInput\n\nInput consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:\n\n$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$\n\nin a line. All the input are real numbers.\n\nOutput\n\nFor each dataset, print $p_x$, $p_y$ and $r$ separated by a space in a line. Print the solution to three places of decimals. Round off the solution to three decimal places.\n\nConstraints\n\n$-100 \\leq x_1, y_1, x_2, y_2, x_3, y_3 \\leq 100$\n\n$ n \\leq 20$\n\nSample Input\n\n1\n0.0 0.0 2.0 0.0 2.0 2.0\n\nOutput for the Sample Input\n\n1.000 1.000 1.414", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 675, "cpu_time_ms": 230, "memory_kb": 43980}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s483319122", "group_id": "codeNet:p00010", "input_text": "import scala.io.StdIn.{readLine,readInt}\nimport scala.math.BigDecimal\n\nobject Main {\n def round(x:Double) = BigDecimal(x).setScale(3,BigDecimal.RoundingMode.HALF_UP).toDouble\n\n def main(args:Array[String]) = {\n val n = readInt\n for(i <- 0 until n) {\n val m = readLine.split(\" \").map(_.toDouble)\n val (x12,y12,x13,y13) = (m(0)-m(2),m(1)-m(3),m(0)-m(4),m(1)-m(5))\n val (xx1,yy1,xx2,yy2,xx3,yy3) = (m(0)*m(0),m(1)*m(1),m(2)*m(2),m(3)*m(3),m(4)*m(4),m(5)*m(5))\n val g = 2*(x12*y13 - y12*x13)\n val x = (y13*(xx1 - xx2 + yy1 - yy2) - y12*(xx1 - xx3 + yy1 - yy3))/g\n val y = (x12*(xx1 - xx3 + yy1 - yy3) - x13*(xx1 - xx2 + yy1 - yy2))/g\n\n printf(\"%.3f %.3f %.3f\\n\",round(x),round(y),round(Math.sqrt(x*x+y*y)))\n }\n }\n}", "language": "Scala", "metadata": {"date": 1484030613, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00010.html", "problem_id": "p00010", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00010/input.txt", "sample_output_relpath": "derived/input_output/data/p00010/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00010/Scala/s483319122.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s483319122", "user_id": "u508732591"}, "prompt_components": {"gold_output": "1.000 1.000 1.414\n", "input_to_evaluate": "import scala.io.StdIn.{readLine,readInt}\nimport scala.math.BigDecimal\n\nobject Main {\n def round(x:Double) = BigDecimal(x).setScale(3,BigDecimal.RoundingMode.HALF_UP).toDouble\n\n def main(args:Array[String]) = {\n val n = readInt\n for(i <- 0 until n) {\n val m = readLine.split(\" \").map(_.toDouble)\n val (x12,y12,x13,y13) = (m(0)-m(2),m(1)-m(3),m(0)-m(4),m(1)-m(5))\n val (xx1,yy1,xx2,yy2,xx3,yy3) = (m(0)*m(0),m(1)*m(1),m(2)*m(2),m(3)*m(3),m(4)*m(4),m(5)*m(5))\n val g = 2*(x12*y13 - y12*x13)\n val x = (y13*(xx1 - xx2 + yy1 - yy2) - y12*(xx1 - xx3 + yy1 - yy3))/g\n val y = (x12*(xx1 - xx3 + yy1 - yy3) - x13*(xx1 - xx2 + yy1 - yy2))/g\n\n printf(\"%.3f %.3f %.3f\\n\",round(x),round(y),round(Math.sqrt(x*x+y*y)))\n }\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nCircumscribed Circle of A Triangle.\n\nWrite a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface.\n\nInput\n\nInput consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:\n\n$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$\n\nin a line. All the input are real numbers.\n\nOutput\n\nFor each dataset, print $p_x$, $p_y$ and $r$ separated by a space in a line. Print the solution to three places of decimals. Round off the solution to three decimal places.\n\nConstraints\n\n$-100 \\leq x_1, y_1, x_2, y_2, x_3, y_3 \\leq 100$\n\n$ n \\leq 20$\n\nSample Input\n\n1\n0.0 0.0 2.0 0.0 2.0 2.0\n\nOutput for the Sample Input\n\n1.000 1.000 1.414", "sample_input": "1\n0.0 0.0 2.0 0.0 2.0 2.0\n"}, "reference_outputs": ["1.000 1.000 1.414\n"], "source_document_id": "p00010", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nCircumscribed Circle of A Triangle.\n\nWrite a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface.\n\nInput\n\nInput consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:\n\n$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$\n\nin a line. All the input are real numbers.\n\nOutput\n\nFor each dataset, print $p_x$, $p_y$ and $r$ separated by a space in a line. Print the solution to three places of decimals. Round off the solution to three decimal places.\n\nConstraints\n\n$-100 \\leq x_1, y_1, x_2, y_2, x_3, y_3 \\leq 100$\n\n$ n \\leq 20$\n\nSample Input\n\n1\n0.0 0.0 2.0 0.0 2.0 2.0\n\nOutput for the Sample Input\n\n1.000 1.000 1.414", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 818, "cpu_time_ms": 240, "memory_kb": 44204}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s725617293", "group_id": "codeNet:p00010", "input_text": "import Math._\nobject Main extends App {\n val n = readLine().toInt\n\n for (i <- 0 until n) {\n val Seq(x1, y1, x2, y2, x3, y3) = readLine().split(' ').map(_.toDouble).toList\n val l1 = pow(x2 - x3, 2) + pow(y2 - y3, 2)\n val l2 = pow(x3 - x1, 2) + pow(y3 - y1, 2)\n val l3 = pow(x1 - x2, 2) + pow(y1 - y2, 2)\n\n val G1 = l1*(l2 + l3 - l1)\n val G2 = l2*(l3 + l1 - l2)\n val G3 = l3*(l1 + l2 - l3)\n\n val px = (G1 * x1 + G2 * x2 + G3 * x3) / (G1 + G2 + G3)\n val py = (G1 * y1 + G2 * y2 + G3 * y3) / (G1 + G2 + G3)\n\n val u1 = sqrt(l1)\n val u2 = sqrt(l2)\n val u3 = sqrt(l3)\n\n val r = (u1 * u2 * u3) / sqrt((u1 + u2 + u3) * (-u1 + u2 + u3) * (u1 - u2 + u3) * (u1 + u2 - u3))\n\n println(\"%.3f %.3f %.3f\".format(px, py, r))\n }\n}\n", "language": "Scala", "metadata": {"date": 1548504905, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00010.html", "problem_id": "p00010", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00010/input.txt", "sample_output_relpath": "derived/input_output/data/p00010/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00010/Scala/s725617293.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s725617293", "user_id": "u488896135"}, "prompt_components": {"gold_output": "1.000 1.000 1.414\n", "input_to_evaluate": "import Math._\nobject Main extends App {\n val n = readLine().toInt\n\n for (i <- 0 until n) {\n val Seq(x1, y1, x2, y2, x3, y3) = readLine().split(' ').map(_.toDouble).toList\n val l1 = pow(x2 - x3, 2) + pow(y2 - y3, 2)\n val l2 = pow(x3 - x1, 2) + pow(y3 - y1, 2)\n val l3 = pow(x1 - x2, 2) + pow(y1 - y2, 2)\n\n val G1 = l1*(l2 + l3 - l1)\n val G2 = l2*(l3 + l1 - l2)\n val G3 = l3*(l1 + l2 - l3)\n\n val px = (G1 * x1 + G2 * x2 + G3 * x3) / (G1 + G2 + G3)\n val py = (G1 * y1 + G2 * y2 + G3 * y3) / (G1 + G2 + G3)\n\n val u1 = sqrt(l1)\n val u2 = sqrt(l2)\n val u3 = sqrt(l3)\n\n val r = (u1 * u2 * u3) / sqrt((u1 + u2 + u3) * (-u1 + u2 + u3) * (u1 - u2 + u3) * (u1 + u2 - u3))\n\n println(\"%.3f %.3f %.3f\".format(px, py, r))\n }\n}\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nCircumscribed Circle of A Triangle.\n\nWrite a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface.\n\nInput\n\nInput consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:\n\n$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$\n\nin a line. All the input are real numbers.\n\nOutput\n\nFor each dataset, print $p_x$, $p_y$ and $r$ separated by a space in a line. Print the solution to three places of decimals. Round off the solution to three decimal places.\n\nConstraints\n\n$-100 \\leq x_1, y_1, x_2, y_2, x_3, y_3 \\leq 100$\n\n$ n \\leq 20$\n\nSample Input\n\n1\n0.0 0.0 2.0 0.0 2.0 2.0\n\nOutput for the Sample Input\n\n1.000 1.000 1.414", "sample_input": "1\n0.0 0.0 2.0 0.0 2.0 2.0\n"}, "reference_outputs": ["1.000 1.000 1.414\n"], "source_document_id": "p00010", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nCircumscribed Circle of A Triangle.\n\nWrite a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface.\n\nInput\n\nInput consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:\n\n$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$\n\nin a line. All the input are real numbers.\n\nOutput\n\nFor each dataset, print $p_x$, $p_y$ and $r$ separated by a space in a line. Print the solution to three places of decimals. Round off the solution to three decimal places.\n\nConstraints\n\n$-100 \\leq x_1, y_1, x_2, y_2, x_3, y_3 \\leq 100$\n\n$ n \\leq 20$\n\nSample Input\n\n1\n0.0 0.0 2.0 0.0 2.0 2.0\n\nOutput for the Sample Input\n\n1.000 1.000 1.414", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 757, "cpu_time_ms": 240, "memory_kb": 44396}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s160054587", "group_id": "codeNet:p00014", "input_text": "object Main extends App {\n import scala.io.Source.stdin\n\n val b = new StringBuilder\n\n for(d<-stdin.getLines.map(_.toInt)) {\n var i = 0\n var s = 0\n while(i*d < 600) {\n s += i*i\n i += 1\n }\n b.append(s*d*d*d+\"\\n\")\n }\n print(b.result)\n}", "language": "Scala", "metadata": {"date": 1484200858, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00014.html", "problem_id": "p00014", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00014/input.txt", "sample_output_relpath": "derived/input_output/data/p00014/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00014/Scala/s160054587.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s160054587", "user_id": "u508732591"}, "prompt_components": {"gold_output": "68440000\n70210000\n", "input_to_evaluate": "object Main extends App {\n import scala.io.Source.stdin\n\n val b = new StringBuilder\n\n for(d<-stdin.getLines.map(_.toInt)) {\n var i = 0\n var s = 0\n while(i*d < 600) {\n s += i*i\n i += 1\n }\n b.append(s*d*d*d+\"\\n\")\n }\n print(b.result)\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nIntegral\n\nWrite a program which computes the area of a shape represented by the following three lines:\n\n$y = x^2$\n\n$y = 0$\n\n$x = 600$\n\nIt is clear that the area is $72000000$, if you use an integral you learn in high school. On the other hand, we can obtain an approximative area of the shape by adding up areas of many rectangles in the shape as shown in the following figure:\n\n$f(x) = x^2$\n\nThe approximative area $s$ where the width of the rectangles is $d$ is:\n\narea of rectangle where its width is $d$ and height is $f(d)$ $+$\n\narea of rectangle where its width is $d$ and height is $f(2d)$ $+$\n\narea of rectangle where its width is $d$ and height is $f(3d)$ $+$\n\n...\n\narea of rectangle where its width is $d$ and height is $f(600 - d)$\n\nThe more we decrease $d$, the higer-precision value which is close to $72000000$ we could obtain. Your program should read the integer $d$ which is a divisor of $600$, and print the area $s$.\n\nInput\n\nThe input consists of several datasets. Each dataset consists of an integer $d$ in a line. The number of datasets is less than or equal to 20.\n\nOutput\n\nFor each dataset, print the area $s$ in a line.\n\nSample Input\n\n20\n10\n\nOutput for the Sample Input\n\n68440000\n70210000", "sample_input": "20\n10\n"}, "reference_outputs": ["68440000\n70210000\n"], "source_document_id": "p00014", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nIntegral\n\nWrite a program which computes the area of a shape represented by the following three lines:\n\n$y = x^2$\n\n$y = 0$\n\n$x = 600$\n\nIt is clear that the area is $72000000$, if you use an integral you learn in high school. On the other hand, we can obtain an approximative area of the shape by adding up areas of many rectangles in the shape as shown in the following figure:\n\n$f(x) = x^2$\n\nThe approximative area $s$ where the width of the rectangles is $d$ is:\n\narea of rectangle where its width is $d$ and height is $f(d)$ $+$\n\narea of rectangle where its width is $d$ and height is $f(2d)$ $+$\n\narea of rectangle where its width is $d$ and height is $f(3d)$ $+$\n\n...\n\narea of rectangle where its width is $d$ and height is $f(600 - d)$\n\nThe more we decrease $d$, the higer-precision value which is close to $72000000$ we could obtain. Your program should read the integer $d$ which is a divisor of $600$, and print the area $s$.\n\nInput\n\nThe input consists of several datasets. Each dataset consists of an integer $d$ in a line. The number of datasets is less than or equal to 20.\n\nOutput\n\nFor each dataset, print the area $s$ in a line.\n\nSample Input\n\n20\n10\n\nOutput for the Sample Input\n\n68440000\n70210000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 262, "cpu_time_ms": 230, "memory_kb": 43940}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s012615837", "group_id": "codeNet:p00014", "input_text": "object Main extends App {\n for(d<-scala.io.Source.stdin.getLines.map(_.toInt)) {\n var (i,s) = (0,0)\n while(i*d < 600) {\n s += i*i\n i += 1\n }\n println(s*d*d*d)\n }\n}", "language": "Scala", "metadata": {"date": 1484200971, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00014.html", "problem_id": "p00014", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00014/input.txt", "sample_output_relpath": "derived/input_output/data/p00014/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00014/Scala/s012615837.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s012615837", "user_id": "u508732591"}, "prompt_components": {"gold_output": "68440000\n70210000\n", "input_to_evaluate": "object Main extends App {\n for(d<-scala.io.Source.stdin.getLines.map(_.toInt)) {\n var (i,s) = (0,0)\n while(i*d < 600) {\n s += i*i\n i += 1\n }\n println(s*d*d*d)\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nIntegral\n\nWrite a program which computes the area of a shape represented by the following three lines:\n\n$y = x^2$\n\n$y = 0$\n\n$x = 600$\n\nIt is clear that the area is $72000000$, if you use an integral you learn in high school. On the other hand, we can obtain an approximative area of the shape by adding up areas of many rectangles in the shape as shown in the following figure:\n\n$f(x) = x^2$\n\nThe approximative area $s$ where the width of the rectangles is $d$ is:\n\narea of rectangle where its width is $d$ and height is $f(d)$ $+$\n\narea of rectangle where its width is $d$ and height is $f(2d)$ $+$\n\narea of rectangle where its width is $d$ and height is $f(3d)$ $+$\n\n...\n\narea of rectangle where its width is $d$ and height is $f(600 - d)$\n\nThe more we decrease $d$, the higer-precision value which is close to $72000000$ we could obtain. Your program should read the integer $d$ which is a divisor of $600$, and print the area $s$.\n\nInput\n\nThe input consists of several datasets. Each dataset consists of an integer $d$ in a line. The number of datasets is less than or equal to 20.\n\nOutput\n\nFor each dataset, print the area $s$ in a line.\n\nSample Input\n\n20\n10\n\nOutput for the Sample Input\n\n68440000\n70210000", "sample_input": "20\n10\n"}, "reference_outputs": ["68440000\n70210000\n"], "source_document_id": "p00014", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nIntegral\n\nWrite a program which computes the area of a shape represented by the following three lines:\n\n$y = x^2$\n\n$y = 0$\n\n$x = 600$\n\nIt is clear that the area is $72000000$, if you use an integral you learn in high school. On the other hand, we can obtain an approximative area of the shape by adding up areas of many rectangles in the shape as shown in the following figure:\n\n$f(x) = x^2$\n\nThe approximative area $s$ where the width of the rectangles is $d$ is:\n\narea of rectangle where its width is $d$ and height is $f(d)$ $+$\n\narea of rectangle where its width is $d$ and height is $f(2d)$ $+$\n\narea of rectangle where its width is $d$ and height is $f(3d)$ $+$\n\n...\n\narea of rectangle where its width is $d$ and height is $f(600 - d)$\n\nThe more we decrease $d$, the higer-precision value which is close to $72000000$ we could obtain. Your program should read the integer $d$ which is a divisor of $600$, and print the area $s$.\n\nInput\n\nThe input consists of several datasets. Each dataset consists of an integer $d$ in a line. The number of datasets is less than or equal to 20.\n\nOutput\n\nFor each dataset, print the area $s$ in a line.\n\nSample Input\n\n20\n10\n\nOutput for the Sample Input\n\n68440000\n70210000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43912}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s414513926", "group_id": "codeNet:p00016", "input_text": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n def read(e:Double,n:Double,angle:Double):(Double,Double) = {\n val l = readLine.split(\",\").map(_.toDouble);val x=l(0);val y=l(1)\n if(x==0 && y==0) (e,n)\n else read(e+x*Math.cos(Math.toRadians(angle)),n+x*Math.sin(Math.toRadians(angle)),angle-y)\n }\n val (e,n) = read(0,0,90)\n println(e.toInt)\n println(n.toInt)\n}", "language": "Scala", "metadata": {"date": 1484276807, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00016.html", "problem_id": "p00016", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00016/input.txt", "sample_output_relpath": "derived/input_output/data/p00016/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00016/Scala/s414513926.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s414513926", "user_id": "u508732591"}, "prompt_components": {"gold_output": "171\n-302\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n def read(e:Double,n:Double,angle:Double):(Double,Double) = {\n val l = readLine.split(\",\").map(_.toDouble);val x=l(0);val y=l(1)\n if(x==0 && y==0) (e,n)\n else read(e+x*Math.cos(Math.toRadians(angle)),n+x*Math.sin(Math.toRadians(angle)),angle-y)\n }\n val (e,n) = read(0,0,90)\n println(e.toInt)\n println(n.toInt)\n}", "problem_context": "Treasure Hunt\n\nWhen a boy was cleaning up after his grand father passing, he found an old paper:\n\nIn addition, other side of the paper says that \"go ahead a number of steps equivalent to the first integer, and turn clockwise by degrees equivalent to the second integer\".\n\nHis grand mother says that Sanbonmatsu was standing at the center of town. However, now buildings are crammed side by side and people can not walk along exactly what the paper says in. Your task is to write a program which hunts for the treature on the paper.\n\nFor simplicity, 1 step is equivalent to 1 meter. Input consists of several pairs of two integers d (the first integer) and t (the second integer) separated by a comma. Input ends with \"0, 0\". Your program should print the coordinate (x, y) of the end point. There is the treature where x meters to the east and y meters to the north from the center of town.\n\nYou can assume that d ≤ 100 and -180 ≤ t ≤ 180.\n\nInput\n\nA sequence of pairs of integers d and t which end with \"0,0\".\n\nOutput\n\nPrint the integer portion of x and y in a line respectively.\n\nSample Input\n\n56,65\n97,54\n64,-4\n55,76\n42,-27\n43,80\n87,-86\n55,-6\n89,34\n95,5\n0,0\n\nOutput for the Sample Input\n\n171\n-302", "sample_input": "56,65\n97,54\n64,-4\n55,76\n42,-27\n43,80\n87,-86\n55,-6\n89,34\n95,5\n0,0\n"}, "reference_outputs": ["171\n-302\n"], "source_document_id": "p00016", "source_text": "Treasure Hunt\n\nWhen a boy was cleaning up after his grand father passing, he found an old paper:\n\nIn addition, other side of the paper says that \"go ahead a number of steps equivalent to the first integer, and turn clockwise by degrees equivalent to the second integer\".\n\nHis grand mother says that Sanbonmatsu was standing at the center of town. However, now buildings are crammed side by side and people can not walk along exactly what the paper says in. Your task is to write a program which hunts for the treature on the paper.\n\nFor simplicity, 1 step is equivalent to 1 meter. Input consists of several pairs of two integers d (the first integer) and t (the second integer) separated by a comma. Input ends with \"0, 0\". Your program should print the coordinate (x, y) of the end point. There is the treature where x meters to the east and y meters to the north from the center of town.\n\nYou can assume that d ≤ 100 and -180 ≤ t ≤ 180.\n\nInput\n\nA sequence of pairs of integers d and t which end with \"0,0\".\n\nOutput\n\nPrint the integer portion of x and y in a line respectively.\n\nSample Input\n\n56,65\n97,54\n64,-4\n55,76\n42,-27\n43,80\n87,-86\n55,-6\n89,34\n95,5\n0,0\n\nOutput for the Sample Input\n\n171\n-302", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 383, "cpu_time_ms": 230, "memory_kb": 43732}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s210194128", "group_id": "codeNet:p00018", "input_text": "object Main extends App {\n val n = scala.io.StdIn.readLine.split(\" \").map(_.toInt).sorted.reverse\n println(n(0)+\" \"+n(1)+\" \"+n(2)+\" \"+n(3)+\" \"+n(4))\n}", "language": "Scala", "metadata": {"date": 1453298531, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00018.html", "problem_id": "p00018", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00018/input.txt", "sample_output_relpath": "derived/input_output/data/p00018/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00018/Scala/s210194128.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s210194128", "user_id": "u915343634"}, "prompt_components": {"gold_output": "9 7 6 5 3\n", "input_to_evaluate": "object Main extends App {\n val n = scala.io.StdIn.readLine.split(\" \").map(_.toInt).sorted.reverse\n println(n(0)+\" \"+n(1)+\" \"+n(2)+\" \"+n(3)+\" \"+n(4))\n}", "problem_context": "Sorting Five Numbers\n\nWrite a program which reads five numbers and sorts them in descending order.\n\nInput\n\nInput consists of five numbers a, b, c, d and e (-100000 ≤ a, b, c, d,e ≤ 100000). The five numbers are separeted by a space.\n\nOutput\n\nPrint the ordered numbers in a line. Adjacent numbers should be separated by a space.\n\nSample Input\n\n3 6 9 7 5\n\nOutput for the Sample Input\n\n9 7 6 5 3", "sample_input": "3 6 9 7 5\n"}, "reference_outputs": ["9 7 6 5 3\n"], "source_document_id": "p00018", "source_text": "Sorting Five Numbers\n\nWrite a program which reads five numbers and sorts them in descending order.\n\nInput\n\nInput consists of five numbers a, b, c, d and e (-100000 ≤ a, b, c, d,e ≤ 100000). The five numbers are separeted by a space.\n\nOutput\n\nPrint the ordered numbers in a line. Adjacent numbers should be separated by a space.\n\nSample Input\n\n3 6 9 7 5\n\nOutput for the Sample Input\n\n9 7 6 5 3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 260, "memory_kb": 43988}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s284847134", "group_id": "codeNet:p00018", "input_text": "object Main extends App {\n val n = scala.io.StdIn.readLine.split(\" \").map(_.toInt).sorted.reverse\n println(n(0)+\" \"+n(1)+\" \"+n(2)+\" \"+n(3)+\" \"+n(4))\n}", "language": "Scala", "metadata": {"date": 1453298560, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00018.html", "problem_id": "p00018", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00018/input.txt", "sample_output_relpath": "derived/input_output/data/p00018/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00018/Scala/s284847134.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s284847134", "user_id": "u915343634"}, "prompt_components": {"gold_output": "9 7 6 5 3\n", "input_to_evaluate": "object Main extends App {\n val n = scala.io.StdIn.readLine.split(\" \").map(_.toInt).sorted.reverse\n println(n(0)+\" \"+n(1)+\" \"+n(2)+\" \"+n(3)+\" \"+n(4))\n}", "problem_context": "Sorting Five Numbers\n\nWrite a program which reads five numbers and sorts them in descending order.\n\nInput\n\nInput consists of five numbers a, b, c, d and e (-100000 ≤ a, b, c, d,e ≤ 100000). The five numbers are separeted by a space.\n\nOutput\n\nPrint the ordered numbers in a line. Adjacent numbers should be separated by a space.\n\nSample Input\n\n3 6 9 7 5\n\nOutput for the Sample Input\n\n9 7 6 5 3", "sample_input": "3 6 9 7 5\n"}, "reference_outputs": ["9 7 6 5 3\n"], "source_document_id": "p00018", "source_text": "Sorting Five Numbers\n\nWrite a program which reads five numbers and sorts them in descending order.\n\nInput\n\nInput consists of five numbers a, b, c, d and e (-100000 ≤ a, b, c, d,e ≤ 100000). The five numbers are separeted by a space.\n\nOutput\n\nPrint the ordered numbers in a line. Adjacent numbers should be separated by a space.\n\nSample Input\n\n3 6 9 7 5\n\nOutput for the Sample Input\n\n9 7 6 5 3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 300, "memory_kb": 43944}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s628022211", "group_id": "codeNet:p00019", "input_text": "object Main extends App {\n def myFactorial(n: Int): Int = if (n == 0) 1 else n * myFactorial(n-1)\n\n println(myFactorial(io.Source.stdin.getLines.next.toInt))\n}", "language": "Scala", "metadata": {"date": 1513318288, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00019.html", "problem_id": "p00019", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00019/input.txt", "sample_output_relpath": "derived/input_output/data/p00019/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00019/Scala/s628022211.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s628022211", "user_id": "u387507798"}, "prompt_components": {"gold_output": "120\n", "input_to_evaluate": "object Main extends App {\n def myFactorial(n: Int): Int = if (n == 0) 1 else n * myFactorial(n-1)\n\n println(myFactorial(io.Source.stdin.getLines.next.toInt))\n}", "problem_context": "Factorial\n\nWrite a program which reads an integer n and prints the factorial of n. You can assume that n ≤ 20.\n\nInput\n\nAn integer n (1 ≤ n ≤ 20) in a line.\n\nOutput\n\nPrint the factorial of n in a line.\n\nSample Input\n\n5\n\nOutput for the Sample Input\n\n120", "sample_input": "5\n"}, "reference_outputs": ["120\n"], "source_document_id": "p00019", "source_text": "Factorial\n\nWrite a program which reads an integer n and prints the factorial of n. You can assume that n ≤ 20.\n\nInput\n\nAn integer n (1 ≤ n ≤ 20) in a line.\n\nOutput\n\nPrint the factorial of n in a line.\n\nSample Input\n\n5\n\nOutput for the Sample Input\n\n120", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 161, "cpu_time_ms": 230, "memory_kb": 43736}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s980441322", "group_id": "codeNet:p00020", "input_text": "object Main extends App {\n println(readLine.toUpperCase)\n}\n", "language": "Scala", "metadata": {"date": 1531671180, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00020.html", "problem_id": "p00020", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00020/input.txt", "sample_output_relpath": "derived/input_output/data/p00020/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00020/Scala/s980441322.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s980441322", "user_id": "u927478431"}, "prompt_components": {"gold_output": "THIS IS A PEN.\n", "input_to_evaluate": "object Main extends App {\n println(readLine.toUpperCase)\n}\n", "problem_context": "Capitalize\n\nWrite a program which replace all the lower-case letters of a given text with the corresponding captital letters.\n\nInput\n\nA text including lower-case letters, periods, and space is given in a line. The number of characters in the text is less than or equal to 200.\n\nOutput\n\nPrint the converted text.\n\nSample Input\n\nthis is a pen.\n\nOutput for the Sample Input\n\nTHIS IS A PEN.", "sample_input": "this is a pen.\n"}, "reference_outputs": ["THIS IS A PEN.\n"], "source_document_id": "p00020", "source_text": "Capitalize\n\nWrite a program which replace all the lower-case letters of a given text with the corresponding captital letters.\n\nInput\n\nA text including lower-case letters, periods, and space is given in a line. The number of characters in the text is less than or equal to 200.\n\nOutput\n\nPrint the converted text.\n\nSample Input\n\nthis is a pen.\n\nOutput for the Sample Input\n\nTHIS IS A PEN.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 60, "cpu_time_ms": 220, "memory_kb": 43684}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s107744360", "group_id": "codeNet:p00021", "input_text": "object Main extends App {\n val n = readInt()\n (1 to n).foreach { i =>\n val arr = readLine().split(\" \").map(_.toDouble).map(_ * 100000)\n val (x1, y1) = (arr(0), arr(1))\n val (x2, y2) = (arr(2), arr(3))\n val (x3, y3) = (arr(4), arr(5))\n val (x4, y4) = (arr(6), arr(7))\n val ab = (y2 - y1) / (x2 - x1)\n val cd = (y4 - y3) / (x4 - x3)\n if (ab == cd) println(\"YES\") else println(\"NO\")\n }\n}", "language": "Scala", "metadata": {"date": 1464697147, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00021.html", "problem_id": "p00021", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00021/input.txt", "sample_output_relpath": "derived/input_output/data/p00021/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00021/Scala/s107744360.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s107744360", "user_id": "u580616456"}, "prompt_components": {"gold_output": "YES\nNO\n", "input_to_evaluate": "object Main extends App {\n val n = readInt()\n (1 to n).foreach { i =>\n val arr = readLine().split(\" \").map(_.toDouble).map(_ * 100000)\n val (x1, y1) = (arr(0), arr(1))\n val (x2, y2) = (arr(2), arr(3))\n val (x3, y3) = (arr(4), arr(5))\n val (x4, y4) = (arr(6), arr(7))\n val ab = (y2 - y1) / (x2 - x1)\n val cd = (y4 - y3) / (x4 - x3)\n if (ab == cd) println(\"YES\") else println(\"NO\")\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nParallelism\n\nThere are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints \"YES\" and if not prints \"NO\".\n\nInput\n\nInput consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \\leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:\n\n$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$\n\nYou can assume that $-100 \\leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \\leq 100$.\nEach value is a real number with at most 5 digits after the decimal point.\n\nOutput\n\nFor each dataset, print \"YES\" or \"NO\" in a line.\n\nSample Input\n\n2\n0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0\n3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0\n\nOutput for the Sample Input\n\nYES\nNO", "sample_input": "2\n0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0\n3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0\n"}, "reference_outputs": ["YES\nNO\n"], "source_document_id": "p00021", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nParallelism\n\nThere are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints \"YES\" and if not prints \"NO\".\n\nInput\n\nInput consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \\leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers:\n\n$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$\n\nYou can assume that $-100 \\leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \\leq 100$.\nEach value is a real number with at most 5 digits after the decimal point.\n\nOutput\n\nFor each dataset, print \"YES\" or \"NO\" in a line.\n\nSample Input\n\n2\n0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0\n3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0\n\nOutput for the Sample Input\n\nYES\nNO", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 411, "cpu_time_ms": 290, "memory_kb": 44300}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s807160146", "group_id": "codeNet:p00022", "input_text": "object Main {\n def main(args: Array[String]) = {\n val in = io.Source.stdin.getLines.map(_.toInt)\n for (n <- in if n != 0) println(in.take(n).scanLeft(-100000)((a, b) => b max (a+b)).max)\n }\n}", "language": "Scala", "metadata": {"date": 1481349038, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00022.html", "problem_id": "p00022", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00022/input.txt", "sample_output_relpath": "derived/input_output/data/p00022/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00022/Scala/s807160146.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s807160146", "user_id": "u475394465"}, "prompt_components": {"gold_output": "19\n14\n1001\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]) = {\n val in = io.Source.stdin.getLines.map(_.toInt)\n for (n <- in if n != 0) println(in.take(n).scanLeft(-100000)((a, b) => b max (a+b)).max)\n }\n}", "problem_context": "Maximum Sum Sequence\n\nGiven a sequence of numbers a1, a2, a3, ..., an, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a contiquous subsequence.\n\nInput\n\nThe input consists of multiple datasets. Each data set consists of:\n\nn\na1\na2\n.\n.\nan\n\nYou can assume that 1 ≤ n ≤ 5000 and -100000 ≤ ai ≤ 100000.\n\nThe input end with a line consisting of a single 0.\n\nOutput\n\nFor each dataset, print the maximum sum in a line.\n\nSample Input\n\n7\n-5\n-1\n6\n4\n9\n-6\n-7\n13\n1\n2\n3\n2\n-2\n-1\n1\n2\n3\n2\n1\n-2\n1\n3\n1000\n-200\n201\n0\n\nOutput for the Sample Input\n\n19\n14\n1001", "sample_input": "7\n-5\n-1\n6\n4\n9\n-6\n-7\n13\n1\n2\n3\n2\n-2\n-1\n1\n2\n3\n2\n1\n-2\n1\n3\n1000\n-200\n201\n0\n"}, "reference_outputs": ["19\n14\n1001\n"], "source_document_id": "p00022", "source_text": "Maximum Sum Sequence\n\nGiven a sequence of numbers a1, a2, a3, ..., an, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a contiquous subsequence.\n\nInput\n\nThe input consists of multiple datasets. Each data set consists of:\n\nn\na1\na2\n.\n.\nan\n\nYou can assume that 1 ≤ n ≤ 5000 and -100000 ≤ ai ≤ 100000.\n\nThe input end with a line consisting of a single 0.\n\nOutput\n\nFor each dataset, print the maximum sum in a line.\n\nSample Input\n\n7\n-5\n-1\n6\n4\n9\n-6\n-7\n13\n1\n2\n3\n2\n-2\n-1\n1\n2\n3\n2\n1\n-2\n1\n3\n1000\n-200\n201\n0\n\nOutput for the Sample Input\n\n19\n14\n1001", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 44048}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s265925495", "group_id": "codeNet:p00022", "input_text": "import scala.io.StdIn._\n\nobject Main {\n def main(args: Array[String]): Unit = {\n while (true) {\n val n = readInt\n if (n == 0) return\n var sum = readInt\n var tmp = sum\n var max = tmp\n for (i <- 1 until n) {\n val x = readInt\n tmp = Math.max(x, tmp)\n sum += x\n if (sum < tmp) {\n sum = tmp\n }\n max = Math.max(max, sum)\n }\n println(max)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1507047011, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00022.html", "problem_id": "p00022", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00022/input.txt", "sample_output_relpath": "derived/input_output/data/p00022/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00022/Scala/s265925495.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s265925495", "user_id": "u809744987"}, "prompt_components": {"gold_output": "19\n14\n1001\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main {\n def main(args: Array[String]): Unit = {\n while (true) {\n val n = readInt\n if (n == 0) return\n var sum = readInt\n var tmp = sum\n var max = tmp\n for (i <- 1 until n) {\n val x = readInt\n tmp = Math.max(x, tmp)\n sum += x\n if (sum < tmp) {\n sum = tmp\n }\n max = Math.max(max, sum)\n }\n println(max)\n }\n }\n}", "problem_context": "Maximum Sum Sequence\n\nGiven a sequence of numbers a1, a2, a3, ..., an, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a contiquous subsequence.\n\nInput\n\nThe input consists of multiple datasets. Each data set consists of:\n\nn\na1\na2\n.\n.\nan\n\nYou can assume that 1 ≤ n ≤ 5000 and -100000 ≤ ai ≤ 100000.\n\nThe input end with a line consisting of a single 0.\n\nOutput\n\nFor each dataset, print the maximum sum in a line.\n\nSample Input\n\n7\n-5\n-1\n6\n4\n9\n-6\n-7\n13\n1\n2\n3\n2\n-2\n-1\n1\n2\n3\n2\n1\n-2\n1\n3\n1000\n-200\n201\n0\n\nOutput for the Sample Input\n\n19\n14\n1001", "sample_input": "7\n-5\n-1\n6\n4\n9\n-6\n-7\n13\n1\n2\n3\n2\n-2\n-1\n1\n2\n3\n2\n1\n-2\n1\n3\n1000\n-200\n201\n0\n"}, "reference_outputs": ["19\n14\n1001\n"], "source_document_id": "p00022", "source_text": "Maximum Sum Sequence\n\nGiven a sequence of numbers a1, a2, a3, ..., an, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a contiquous subsequence.\n\nInput\n\nThe input consists of multiple datasets. Each data set consists of:\n\nn\na1\na2\n.\n.\nan\n\nYou can assume that 1 ≤ n ≤ 5000 and -100000 ≤ ai ≤ 100000.\n\nThe input end with a line consisting of a single 0.\n\nOutput\n\nFor each dataset, print the maximum sum in a line.\n\nSample Input\n\n7\n-5\n-1\n6\n4\n9\n-6\n-7\n13\n1\n2\n3\n2\n-2\n-1\n1\n2\n3\n2\n1\n-2\n1\n3\n1000\n-200\n201\n0\n\nOutput for the Sample Input\n\n19\n14\n1001", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 280, "memory_kb": 44028}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s185106005", "group_id": "codeNet:p00022", "input_text": "import scala.io.StdIn._\n\nobject Main {\n def main(args: Array[String]): Unit = {\n while (true) {\n val n = readInt\n if (n == 0) return\n\n var list: Array[Long] = Array.empty\n for (i <- 0 until n) {\n list :+= readInt.toLong\n }\n println(execute(list))\n }\n\n //println(execute(Array(-5, -1, 6, 4, 9, -6)))\n }\n\n def execute(list: Array[Long]): Long = {\n\n var max = list(0)\n var tmp = max\n for (i <- 0 until list.length) {\n //val result = new Array[Long](list.length)\n //result(i) = list(i)\n tmp = list(i)\n max = Math.max(list(i), max)\n for (j <- i + 1 until list.length) {\n val x = list(j) + tmp\n max = Math.max(x, max)\n tmp = x\n }\n // result.foreach(x => print(x + \" \"))\n // println()\n }\n\n max\n }\n}", "language": "Scala", "metadata": {"date": 1507051764, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00022.html", "problem_id": "p00022", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00022/input.txt", "sample_output_relpath": "derived/input_output/data/p00022/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00022/Scala/s185106005.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s185106005", "user_id": "u809744987"}, "prompt_components": {"gold_output": "19\n14\n1001\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main {\n def main(args: Array[String]): Unit = {\n while (true) {\n val n = readInt\n if (n == 0) return\n\n var list: Array[Long] = Array.empty\n for (i <- 0 until n) {\n list :+= readInt.toLong\n }\n println(execute(list))\n }\n\n //println(execute(Array(-5, -1, 6, 4, 9, -6)))\n }\n\n def execute(list: Array[Long]): Long = {\n\n var max = list(0)\n var tmp = max\n for (i <- 0 until list.length) {\n //val result = new Array[Long](list.length)\n //result(i) = list(i)\n tmp = list(i)\n max = Math.max(list(i), max)\n for (j <- i + 1 until list.length) {\n val x = list(j) + tmp\n max = Math.max(x, max)\n tmp = x\n }\n // result.foreach(x => print(x + \" \"))\n // println()\n }\n\n max\n }\n}", "problem_context": "Maximum Sum Sequence\n\nGiven a sequence of numbers a1, a2, a3, ..., an, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a contiquous subsequence.\n\nInput\n\nThe input consists of multiple datasets. Each data set consists of:\n\nn\na1\na2\n.\n.\nan\n\nYou can assume that 1 ≤ n ≤ 5000 and -100000 ≤ ai ≤ 100000.\n\nThe input end with a line consisting of a single 0.\n\nOutput\n\nFor each dataset, print the maximum sum in a line.\n\nSample Input\n\n7\n-5\n-1\n6\n4\n9\n-6\n-7\n13\n1\n2\n3\n2\n-2\n-1\n1\n2\n3\n2\n1\n-2\n1\n3\n1000\n-200\n201\n0\n\nOutput for the Sample Input\n\n19\n14\n1001", "sample_input": "7\n-5\n-1\n6\n4\n9\n-6\n-7\n13\n1\n2\n3\n2\n-2\n-1\n1\n2\n3\n2\n1\n-2\n1\n3\n1000\n-200\n201\n0\n"}, "reference_outputs": ["19\n14\n1001\n"], "source_document_id": "p00022", "source_text": "Maximum Sum Sequence\n\nGiven a sequence of numbers a1, a2, a3, ..., an, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a contiquous subsequence.\n\nInput\n\nThe input consists of multiple datasets. Each data set consists of:\n\nn\na1\na2\n.\n.\nan\n\nYou can assume that 1 ≤ n ≤ 5000 and -100000 ≤ ai ≤ 100000.\n\nThe input end with a line consisting of a single 0.\n\nOutput\n\nFor each dataset, print the maximum sum in a line.\n\nSample Input\n\n7\n-5\n-1\n6\n4\n9\n-6\n-7\n13\n1\n2\n3\n2\n-2\n-1\n1\n2\n3\n2\n1\n-2\n1\n3\n1000\n-200\n201\n0\n\nOutput for the Sample Input\n\n19\n14\n1001", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 827, "cpu_time_ms": 290, "memory_kb": 84296}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s167318052", "group_id": "codeNet:p00033", "input_text": "object Main {\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n for(i <- 1 to n) {\n val list = List.fill(10)(sc.nextInt)\n println(solve(list))\n }\n }\n def solve(list: List[Int]): String = {\n var a = 0\n var b = 0\n var f = true\n for(i <- 0 to 9) {\n if(list(i) < a && list(i) < b) {\n f = false\n }\n else if(a < list(i) && list(i) < b) a = list(i)\n else if(list(i) < a && b < list(i)) b = list(i)\n else if (a < b) b = list(i)\n else a = list(i)\n }\n if(f) \"YES\"\n else \"NO\"\n }\n}", "language": "Scala", "metadata": {"date": 1459726356, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00033.html", "problem_id": "p00033", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00033/input.txt", "sample_output_relpath": "derived/input_output/data/p00033/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00033/Scala/s167318052.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s167318052", "user_id": "u811434779"}, "prompt_components": {"gold_output": "YES\nNO\n", "input_to_evaluate": "object Main {\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n for(i <- 1 to n) {\n val list = List.fill(10)(sc.nextInt)\n println(solve(list))\n }\n }\n def solve(list: List[Int]): String = {\n var a = 0\n var b = 0\n var f = true\n for(i <- 0 to 9) {\n if(list(i) < a && list(i) < b) {\n f = false\n }\n else if(a < list(i) && list(i) < b) a = list(i)\n else if(list(i) < a && b < list(i)) b = list(i)\n else if (a < b) b = list(i)\n else a = list(i)\n }\n if(f) \"YES\"\n else \"NO\"\n }\n}", "problem_context": "玉\n\n図のように二股に分かれている容器があります。1 から 10 までの番号が付けられた10 個の玉を容器の開口部 A から落とし、左の筒 B か右の筒 C に玉を入れます。板 D は支点 E を中心に左右に回転できるので、板 D を動かすことで筒 B と筒 C のどちらに入れるか決めることができます。\n\n開口部 A から落とす玉の並びを与えます。それらを順番に筒 B 又は筒 Cに入れていきます。このとき、筒 B と筒 C のおのおのが両方とも番号の小さい玉の上に大きい玉を並べられる場合は YES、並べられない場合は NO と出力するプログラムを作成してください。ただし、容器の中で玉の順序を入れ替えることはできないものとします。また、続けて同じ筒に入れることができるものとし、筒 B, C ともに 10 個の玉がすべて入るだけの余裕があるものとします。\n\nInput\n\n複数のデータセットが与えられます。1行目にデータセット数 N が与えられます。つづいて、N 行のデータセットが与えられます。各データセットに 10 個の番号が左から順番に空白区切りで与えられます。\n\nOutput\n\n各データセットに対して、YES または NO を1行に出力して下さい。\n\nSample Input\n\n2\n3 1 4 2 5 6 7 8 9 10\n10 9 8 7 6 5 4 3 2 1\n\nOutput for the Sample Input\n\nYES\nNO", "sample_input": "2\n3 1 4 2 5 6 7 8 9 10\n10 9 8 7 6 5 4 3 2 1\n"}, "reference_outputs": ["YES\nNO\n"], "source_document_id": "p00033", "source_text": "玉\n\n図のように二股に分かれている容器があります。1 から 10 までの番号が付けられた10 個の玉を容器の開口部 A から落とし、左の筒 B か右の筒 C に玉を入れます。板 D は支点 E を中心に左右に回転できるので、板 D を動かすことで筒 B と筒 C のどちらに入れるか決めることができます。\n\n開口部 A から落とす玉の並びを与えます。それらを順番に筒 B 又は筒 Cに入れていきます。このとき、筒 B と筒 C のおのおのが両方とも番号の小さい玉の上に大きい玉を並べられる場合は YES、並べられない場合は NO と出力するプログラムを作成してください。ただし、容器の中で玉の順序を入れ替えることはできないものとします。また、続けて同じ筒に入れることができるものとし、筒 B, C ともに 10 個の玉がすべて入るだけの余裕があるものとします。\n\nInput\n\n複数のデータセットが与えられます。1行目にデータセット数 N が与えられます。つづいて、N 行のデータセットが与えられます。各データセットに 10 個の番号が左から順番に空白区切りで与えられます。\n\nOutput\n\n各データセットに対して、YES または NO を1行に出力して下さい。\n\nSample Input\n\n2\n3 1 4 2 5 6 7 8 9 10\n10 9 8 7 6 5 4 3 2 1\n\nOutput for the Sample Input\n\nYES\nNO", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 260, "memory_kb": 44788}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s507935158", "group_id": "codeNet:p00038", "input_text": "import scala.io.Source.stdin\n\nobject Main {\n def hand(i:Int,j:Int,k:Int,l:Int,m:Int):String = {\n if( (j,k,l) == (i,i,i) || (k,l,m) == (j,j,j) ) \"four card\"\n else if( (j,l,m) == (i,k,k) || (j,k,m) == (i,i,l) ) \"full house\"\n else if( (j,k) == (i,i) || (k,l) == (j,j) || (l,m) == (k,k) ) \"three card\"\n else if( (j,l) == (i,k) || (j,m) == (i,l) || (k,m) == (j,l) ) \"two pair\"\n else if( i== j || j == k || k == l || l == m ) \"one pair\"\n else if( (i,j,k,l,m) == (i,i+1,i+2,i+3,i+4) || (i,j,k,l,m) == (1,10,11,12,13) ) \"straight\"\n else \"null\"\n }\n\n def main(args:Array[String]) = {\n stdin.getLines.foreach { s=>\n val l = s.split(\",\").map(_.toInt).sorted\n println(hand(l(0),l(1),l(2),l(3),l(4)))\n }\n }\n}", "language": "Scala", "metadata": {"date": 1485620914, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00038.html", "problem_id": "p00038", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00038/input.txt", "sample_output_relpath": "derived/input_output/data/p00038/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00038/Scala/s507935158.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s507935158", "user_id": "u508732591"}, "prompt_components": {"gold_output": "one pair\ntwo pair\nthree card\nfull house\nfour card\nstraight\nstraight\nnull\n", "input_to_evaluate": "import scala.io.Source.stdin\n\nobject Main {\n def hand(i:Int,j:Int,k:Int,l:Int,m:Int):String = {\n if( (j,k,l) == (i,i,i) || (k,l,m) == (j,j,j) ) \"four card\"\n else if( (j,l,m) == (i,k,k) || (j,k,m) == (i,i,l) ) \"full house\"\n else if( (j,k) == (i,i) || (k,l) == (j,j) || (l,m) == (k,k) ) \"three card\"\n else if( (j,l) == (i,k) || (j,m) == (i,l) || (k,m) == (j,l) ) \"two pair\"\n else if( i== j || j == k || k == l || l == m ) \"one pair\"\n else if( (i,j,k,l,m) == (i,i+1,i+2,i+3,i+4) || (i,j,k,l,m) == (1,10,11,12,13) ) \"straight\"\n else \"null\"\n }\n\n def main(args:Array[String]) = {\n stdin.getLines.foreach { s=>\n val l = s.split(\",\").map(_.toInt).sorted\n println(hand(l(0),l(1),l(2),l(3),l(4)))\n }\n }\n}", "problem_context": "ポーカー\n\nポーカーの手札データを読み込んで、それぞれについてその役を出力するプログラムを作成してください。ただし、この問題では、以下のルールに従います。\n\nポーカーはトランプ 5 枚で行う競技です。\n\n同じ数字のカードは 5 枚以上ありません。\n\nジョーカーは無いものとします。\n\n以下のポーカーの役だけを考えるものとします。(番号が大きいほど役が高くなります。)\n\n役なし(以下に挙げるどれにも当てはまらない)\n\nワンペア(2 枚の同じ数字のカードが1 組ある)\n\nツーペア(2 枚の同じ数字のカードが2 組ある)\n\nスリーカード(3 枚の同じ数字のカードが1 組ある)\n\nストレート(5 枚のカードの数字が連続している)\n\nただし、A を含むストレートの場合、A で終わる並びもストレートとします。つまり、A を含むストレート\nは、A 2 3 4 5  と 10 J Q K A  の2種類です。J Q K A 2 などのように、A をまたぐ並び\nはストレートではありません。(この場合、「役なし」になります)。\n\nフルハウス(3 枚の同じ数字のカードが1 組と、残りの2 枚が同じ数字のカード)\n\nフォーカード(4 枚の同じ数字のカードが1 組ある)\n\nInput\n\n入力は複数のデータセットからなります。各データセットは以下の形式で与えられます。\n\n手札1,手札2,手札3,手札4,手札5\n\n手札は、トランプのJ(ジャック) を11、Q(クイーン) を12、K(キング) を13、A(エース)を 1、その他はそれぞれの数字で表すこととします。\n\nデータセットの数は 50 を超えません。\n\nOutput\n\nデータセットごとに、手札によってできる最も高い役をひとつ出力してください。役の表記については出力例に従ってください。\n\nSample Input\n\n1,2,3,4,1\n2,3,2,3,12\n12,13,11,12,12\n7,6,7,6,7\n3,3,2,3,3\n6,7,8,9,10\n11,12,10,1,13\n11,12,13,1,2\n\nOutput for the Sample Input\n\none pair\ntwo pair\nthree card\nfull house\nfour card\nstraight\nstraight\nnull\n\n3 3 2 3 3 という手札であったときは、two pair ではなく four card です。", "sample_input": "1,2,3,4,1\n2,3,2,3,12\n12,13,11,12,12\n7,6,7,6,7\n3,3,2,3,3\n6,7,8,9,10\n11,12,10,1,13\n11,12,13,1,2\n"}, "reference_outputs": ["one pair\ntwo pair\nthree card\nfull house\nfour card\nstraight\nstraight\nnull\n"], "source_document_id": "p00038", "source_text": "ポーカー\n\nポーカーの手札データを読み込んで、それぞれについてその役を出力するプログラムを作成してください。ただし、この問題では、以下のルールに従います。\n\nポーカーはトランプ 5 枚で行う競技です。\n\n同じ数字のカードは 5 枚以上ありません。\n\nジョーカーは無いものとします。\n\n以下のポーカーの役だけを考えるものとします。(番号が大きいほど役が高くなります。)\n\n役なし(以下に挙げるどれにも当てはまらない)\n\nワンペア(2 枚の同じ数字のカードが1 組ある)\n\nツーペア(2 枚の同じ数字のカードが2 組ある)\n\nスリーカード(3 枚の同じ数字のカードが1 組ある)\n\nストレート(5 枚のカードの数字が連続している)\n\nただし、A を含むストレートの場合、A で終わる並びもストレートとします。つまり、A を含むストレート\nは、A 2 3 4 5  と 10 J Q K A  の2種類です。J Q K A 2 などのように、A をまたぐ並び\nはストレートではありません。(この場合、「役なし」になります)。\n\nフルハウス(3 枚の同じ数字のカードが1 組と、残りの2 枚が同じ数字のカード)\n\nフォーカード(4 枚の同じ数字のカードが1 組ある)\n\nInput\n\n入力は複数のデータセットからなります。各データセットは以下の形式で与えられます。\n\n手札1,手札2,手札3,手札4,手札5\n\n手札は、トランプのJ(ジャック) を11、Q(クイーン) を12、K(キング) を13、A(エース)を 1、その他はそれぞれの数字で表すこととします。\n\nデータセットの数は 50 を超えません。\n\nOutput\n\nデータセットごとに、手札によってできる最も高い役をひとつ出力してください。役の表記については出力例に従ってください。\n\nSample Input\n\n1,2,3,4,1\n2,3,2,3,12\n12,13,11,12,12\n7,6,7,6,7\n3,3,2,3,3\n6,7,8,9,10\n11,12,10,1,13\n11,12,13,1,2\n\nOutput for the Sample Input\n\none pair\ntwo pair\nthree card\nfull house\nfour card\nstraight\nstraight\nnull\n\n3 3 2 3 3 という手札であったときは、two pair ではなく four card です。", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 735, "cpu_time_ms": 240, "memory_kb": 43932}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s693360542", "group_id": "codeNet:p00040", "input_text": "import scala.io.StdIn.{readInt,readLine}\n\nobject Main {\n val alist = List(1,3,5,7,9,11,15,17,19,21,23,25)\n val blist = 0 to 25\n val invs = for{\n i<-alist\n j<-1 to 25 by 2\n if (i*j) % 26 == 1\n } yield (i,j)\n def encode(c:Int,a:Int,b:Int) = (((a*(c-97)+b) % 26)+97).toChar\n def decode(c:Int,a:Int,b:Int) = ((a*(c-97-b+26) % 26)+97).toChar\n\n def main(args:Array[String]) = {\n val n = readInt\n (0 until n).foreach { _ =>\n val l = readLine\n val (a,b) = {for(i<-alist;j<-blist) yield (i,j)}.find{ case (i,j) =>\n l.contains(\"that\".map{encode(_,i,j)}) || l.contains(\"this\".map{encode(_,i,j)})\n }.get\n println( l.map { c=> if(c>=97 && c<=122) decode(c,invs.find(s => s._1 == a).get._2,b) else c })\n }\n }\n}", "language": "Scala", "metadata": {"date": 1486210875, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00040.html", "problem_id": "p00040", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00040/input.txt", "sample_output_relpath": "derived/input_output/data/p00040/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00040/Scala/s693360542.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s693360542", "user_id": "u508732591"}, "prompt_components": {"gold_output": "i submit that there is another point of view\n", "input_to_evaluate": "import scala.io.StdIn.{readInt,readLine}\n\nobject Main {\n val alist = List(1,3,5,7,9,11,15,17,19,21,23,25)\n val blist = 0 to 25\n val invs = for{\n i<-alist\n j<-1 to 25 by 2\n if (i*j) % 26 == 1\n } yield (i,j)\n def encode(c:Int,a:Int,b:Int) = (((a*(c-97)+b) % 26)+97).toChar\n def decode(c:Int,a:Int,b:Int) = ((a*(c-97-b+26) % 26)+97).toChar\n\n def main(args:Array[String]) = {\n val n = readInt\n (0 until n).foreach { _ =>\n val l = readLine\n val (a,b) = {for(i<-alist;j<-blist) yield (i,j)}.find{ case (i,j) =>\n l.contains(\"that\".map{encode(_,i,j)}) || l.contains(\"this\".map{encode(_,i,j)})\n }.get\n println( l.map { c=> if(c>=97 && c<=122) decode(c,invs.find(s => s._1 == a).get._2,b) else c })\n }\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nアフィン暗号\n\n簡単な暗号法の一つに、アフィン暗号というものがあります。まず、アルファベット a〜z を a = 0, b = 1, c = 2,..., x = 23, y = 24, z = 25 と 0〜25 の数字に置き換えます。そして、以下の式で、原文のアルファベットを置換します。\n\n$F(\\gamma) = (\\alpha \\cdot \\gamma + \\beta)$ mod $26$\n\nただし、mod 26 は 26 で割った余りを表します。例えば、$\\alpha = 3, \\beta = 2$ のとき、アルファベットの 'a' (=0) は、$F(0) = (3 \\cdot 0 + 2)$ mod $26 = 2$ で 'c' に、アルファベットの 'n' (=13) は $F(13) = (3 \\cdot 13 + 2)$ mod $26 = 15$ で 'p' に置換されます。\nこのとき、$\\gamma$ に対する $F(\\gamma)$ が必ず 1 対 1 で対応付けられるように、$\\alpha$ と $\\beta$ は慎重に選ばれているものとします($\\alpha$ と 26 が互いに素であることが条件)。$\\alpha = 4, \\beta = 7$ のときのように、$F('a') = 7, F('n') = 7$ と、'a' も 'n' も同じ 'h' に置換されるようなことはありません。また、アルファベット以外の文字は置換されません。\n\n暗号化された文字列を元の文章に復号したものを出力するプログラムを作成してください。元の文章には、キーワードとして\n\nthat\nthis\n\nのいずれかが必ず含まれているものとします。\n\nInput\n\n複数のデータセットが与えられます。1行目にデータセット数 $n$ ($n \\leq 30$) が与えられます。続いて $n$ 行のデータが与えられます。各データセットに英小文字と空白からなる 256 文字以内の暗号化された文章が1行に与えられます。\n\nOutput\n\n各データセットに対して、復号した元の文章を1行に出力して下さい。\n\nSample Input\n\n1\ny eazqyp pnop pngtg ye obmpngt xmybp mr lygw\n\nOutput for the Sample Input\n\ni submit that there is another point of view", "sample_input": "1\ny eazqyp pnop pngtg ye obmpngt xmybp mr lygw\n"}, "reference_outputs": ["i submit that there is another point of view\n"], "source_document_id": "p00040", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nアフィン暗号\n\n簡単な暗号法の一つに、アフィン暗号というものがあります。まず、アルファベット a〜z を a = 0, b = 1, c = 2,..., x = 23, y = 24, z = 25 と 0〜25 の数字に置き換えます。そして、以下の式で、原文のアルファベットを置換します。\n\n$F(\\gamma) = (\\alpha \\cdot \\gamma + \\beta)$ mod $26$\n\nただし、mod 26 は 26 で割った余りを表します。例えば、$\\alpha = 3, \\beta = 2$ のとき、アルファベットの 'a' (=0) は、$F(0) = (3 \\cdot 0 + 2)$ mod $26 = 2$ で 'c' に、アルファベットの 'n' (=13) は $F(13) = (3 \\cdot 13 + 2)$ mod $26 = 15$ で 'p' に置換されます。\nこのとき、$\\gamma$ に対する $F(\\gamma)$ が必ず 1 対 1 で対応付けられるように、$\\alpha$ と $\\beta$ は慎重に選ばれているものとします($\\alpha$ と 26 が互いに素であることが条件)。$\\alpha = 4, \\beta = 7$ のときのように、$F('a') = 7, F('n') = 7$ と、'a' も 'n' も同じ 'h' に置換されるようなことはありません。また、アルファベット以外の文字は置換されません。\n\n暗号化された文字列を元の文章に復号したものを出力するプログラムを作成してください。元の文章には、キーワードとして\n\nthat\nthis\n\nのいずれかが必ず含まれているものとします。\n\nInput\n\n複数のデータセットが与えられます。1行目にデータセット数 $n$ ($n \\leq 30$) が与えられます。続いて $n$ 行のデータが与えられます。各データセットに英小文字と空白からなる 256 文字以内の暗号化された文章が1行に与えられます。\n\nOutput\n\n各データセットに対して、復号した元の文章を1行に出力して下さい。\n\nSample Input\n\n1\ny eazqyp pnop pngtg ye obmpngt xmybp mr lygw\n\nOutput for the Sample Input\n\ni submit that there is another point of view", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 753, "cpu_time_ms": 260, "memory_kb": 45316}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s591907236", "group_id": "codeNet:p00042", "input_text": "import scala.io.StdIn.{readLine,readInt}\n\nobject Main extends App {\n\n var index = 1\n Iterator.continually(readInt).takeWhile ( w => w != 0).foreach { w =>\n val n = readInt\n val wv = Array.ofDim[Int](n+1,2)\n val m = Array.ofDim[Int](n+1,w+1)\n var max = 0\n var maxw = 0\n\n for(i<-1 to n) wv(i) = readLine.split(\",\").map(_.toInt)\n for(i<-1 to n;j<-0 to w if j>= wv(i)(1)) {\n if(m(i-1)(j) < wv(i)(0) + m(i-1)(j-wv(i)(1))) {\n m(i)(j) = wv(i)(0) + m(i-1)(j-wv(i)(1))\n if(max < m(i)(j)) {\n maxw = j\n max = m(i)(j)\n }\n } else {\n m(i)(j) = m(i-1)(j)\n }\n }\n println(\"Case \"+index+\":\")\n println(m(n)(w))\n println(maxw)\n index += 1\n }\n}", "language": "Scala", "metadata": {"date": 1485919370, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00042.html", "problem_id": "p00042", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00042/input.txt", "sample_output_relpath": "derived/input_output/data/p00042/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00042/Scala/s591907236.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s591907236", "user_id": "u508732591"}, "prompt_components": {"gold_output": "Case 1:\n220\n49\nCase 2:\n220\n49\n", "input_to_evaluate": "import scala.io.StdIn.{readLine,readInt}\n\nobject Main extends App {\n\n var index = 1\n Iterator.continually(readInt).takeWhile ( w => w != 0).foreach { w =>\n val n = readInt\n val wv = Array.ofDim[Int](n+1,2)\n val m = Array.ofDim[Int](n+1,w+1)\n var max = 0\n var maxw = 0\n\n for(i<-1 to n) wv(i) = readLine.split(\",\").map(_.toInt)\n for(i<-1 to n;j<-0 to w if j>= wv(i)(1)) {\n if(m(i-1)(j) < wv(i)(0) + m(i-1)(j-wv(i)(1))) {\n m(i)(j) = wv(i)(0) + m(i-1)(j-wv(i)(1))\n if(max < m(i)(j)) {\n maxw = j\n max = m(i)(j)\n }\n } else {\n m(i)(j) = m(i-1)(j)\n }\n }\n println(\"Case \"+index+\":\")\n println(m(n)(w))\n println(maxw)\n index += 1\n }\n}", "problem_context": "泥棒\n\n宝物がたくさん収蔵されている博物館に、泥棒が大きな風呂敷を一つだけ持って忍び込みました。盗み出したいものはたくさんありますが、風呂敷が耐えられる重さが限られており、これを超えると風呂敷が破れてしまいます。そこで泥棒は、用意した風呂敷を破らず且つ最も価値が高くなるようなお宝の組み合わせを考えなくてはなりません。\n\n風呂敷が耐えられる重さ W、および博物館にある個々のお宝の価値と重さを読み込んで、重さの総和が W を超えない範囲で価値の総和が最大になるときの、お宝の価値総和と重さの総和を出力するプログラムを作成してください。ただし、価値の総和が最大になる組み合わせが複数あるときは、重さの総和が小さいものを出力することとします。\n\nInput\n\n複数のデータセットが与えられます。各データセットは以下のような形式で与えられます。\n\nW\nN\nv1,w1\nv2,w2\n:\nvN,wN\n\n1行目に風呂敷の耐えられる重さを表す整数 W (W ≤ 1,000)、2行目にお宝の数 N (1 ≤ N ≤ 1,000) が与えられます。続く N 行に i 番目のお宝の価値を表す整数 vi (0 ≤ vi ≤ 10,000) とその重さを表す整数 wi (0 ≤ wi ≤ W) の組がそれぞれ1行に与えられます。\n\nW が 0 のとき入力の最後とします。データセットの数は 50 を超えません。\n\nOutput\n\n各データセットに対して以下のように出力して下さい。\n\nCase データセットの番号:\n風呂敷に入れたお宝の価値総和\nそのときのお宝の重さの総和\n\nSample Input\n\n50\n5\n60,10\n100,20\n120,30\n210,45\n10,4\n50\n5\n60,10\n100,20\n120,30\n210,45\n10,4\n0\n\nOutput for the Sample Input\n\nCase 1:\n220\n49\nCase 2:\n220\n49", "sample_input": "50\n5\n60,10\n100,20\n120,30\n210,45\n10,4\n50\n5\n60,10\n100,20\n120,30\n210,45\n10,4\n0\n"}, "reference_outputs": ["Case 1:\n220\n49\nCase 2:\n220\n49\n"], "source_document_id": "p00042", "source_text": "泥棒\n\n宝物がたくさん収蔵されている博物館に、泥棒が大きな風呂敷を一つだけ持って忍び込みました。盗み出したいものはたくさんありますが、風呂敷が耐えられる重さが限られており、これを超えると風呂敷が破れてしまいます。そこで泥棒は、用意した風呂敷を破らず且つ最も価値が高くなるようなお宝の組み合わせを考えなくてはなりません。\n\n風呂敷が耐えられる重さ W、および博物館にある個々のお宝の価値と重さを読み込んで、重さの総和が W を超えない範囲で価値の総和が最大になるときの、お宝の価値総和と重さの総和を出力するプログラムを作成してください。ただし、価値の総和が最大になる組み合わせが複数あるときは、重さの総和が小さいものを出力することとします。\n\nInput\n\n複数のデータセットが与えられます。各データセットは以下のような形式で与えられます。\n\nW\nN\nv1,w1\nv2,w2\n:\nvN,wN\n\n1行目に風呂敷の耐えられる重さを表す整数 W (W ≤ 1,000)、2行目にお宝の数 N (1 ≤ N ≤ 1,000) が与えられます。続く N 行に i 番目のお宝の価値を表す整数 vi (0 ≤ vi ≤ 10,000) とその重さを表す整数 wi (0 ≤ wi ≤ W) の組がそれぞれ1行に与えられます。\n\nW が 0 のとき入力の最後とします。データセットの数は 50 を超えません。\n\nOutput\n\n各データセットに対して以下のように出力して下さい。\n\nCase データセットの番号:\n風呂敷に入れたお宝の価値総和\nそのときのお宝の重さの総和\n\nSample Input\n\n50\n5\n60,10\n100,20\n120,30\n210,45\n10,4\n50\n5\n60,10\n100,20\n120,30\n210,45\n10,4\n0\n\nOutput for the Sample Input\n\nCase 1:\n220\n49\nCase 2:\n220\n49", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 759, "cpu_time_ms": 310, "memory_kb": 64348}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s316925752", "group_id": "codeNet:p00043", "input_text": "import scala.io.StdIn.{readLine,readInt}\n\nobject Main extends App {\n val seq1 = for(i<-1 to 9) yield List(i,i,i)\n val seq2 = for(i<-1 to 7) yield List(i,i+1,i+2)\n\n def check(m:List[Int], count:Int,u:Int,v:Int):Boolean =\n if(m.length != count) false\n else if(count==2) {\n val List(x,y) = m\n if(x==y) true else false\n } else\n (u to 8).exists( i=> check(m diff seq1(i),count-3,i+1,v)) || (v to 6).exists(i=> check(m diff seq2(i),count-3,u,i))\n\n Iterator.continually(readLine).takeWhile ( _!=null ).foreach { line =>\n val l = line.map(_.asDigit).toList\n val m = (1 to 9).filter { i=> if(l.count( _==i ) >= 4) false else check(i::l,14,0,0) }\n if(m.length>0) println(m.mkString(\" \")) else println(0)\n }\n}", "language": "Scala", "metadata": {"date": 1486108048, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00043.html", "problem_id": "p00043", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00043/input.txt", "sample_output_relpath": "derived/input_output/data/p00043/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00043/Scala/s316925752.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s316925752", "user_id": "u508732591"}, "prompt_components": {"gold_output": "2 3 5 8\n3 4\n1 2 3 4 5 6 7 8 9\n7 8 9\n1 2 3 4 6 7 8\n0\n", "input_to_evaluate": "import scala.io.StdIn.{readLine,readInt}\n\nobject Main extends App {\n val seq1 = for(i<-1 to 9) yield List(i,i,i)\n val seq2 = for(i<-1 to 7) yield List(i,i+1,i+2)\n\n def check(m:List[Int], count:Int,u:Int,v:Int):Boolean =\n if(m.length != count) false\n else if(count==2) {\n val List(x,y) = m\n if(x==y) true else false\n } else\n (u to 8).exists( i=> check(m diff seq1(i),count-3,i+1,v)) || (v to 6).exists(i=> check(m diff seq2(i),count-3,u,i))\n\n Iterator.continually(readLine).takeWhile ( _!=null ).foreach { line =>\n val l = line.map(_.asDigit).toList\n val m = (1 to 9).filter { i=> if(l.count( _==i ) >= 4) false else check(i::l,14,0,0) }\n if(m.length>0) println(m.mkString(\" \")) else println(0)\n }\n}", "problem_context": "パズル\n\n1 〜 9 の数字を 14 個組み合わせて完成させるパズルがあります。与えられた 13 個の数字にもうひとつ数字を付け加えて完成させます。\n\nパズルの完成条件は\n\n同じ数字を2つ組み合わせたものが必ずひとつ必要です。\n\n残りの12 個の数字は、3個の数字の組み合わせ4つです。\n\n3個の数字の組み合わせ方は、同じ数字を3つ組み合わせたものか、または3つの連続する数字を組み合わせたものです。ただし、9 1 2 のような並びは連続する数字とは認められません。\n\n同じ数字は4 回まで使えます。\n\n13 個の数字からなる文字列を読み込んで、パズルを完成することができる数字を昇順に全て出力するプログラムを作成してください。なお、1〜9 のどの数字を付け加えてもパズルを完成させることができないときは 0 を出力してください。\n\n例えば与えられた文字列が 3456666777999 の場合\n\n「2」があれば、 234 567 666 77 999\n\n「3」があれば、 33 456 666 777 999\n\n「5」があれば、 345 567 666 77 999\n\n「8」があれば、 345 666 678 77 999\n\nというふうに、2 3 5 8 のいずれかの数字が付け加えられるとパズルは完成します。「6」でも整いますが、5 回目の使用になるので、この例では使えないことに注意してください。\n\nInput\n\n入力は複数のデータセットからなります。各データセットとして、13 個の数字が1行に与えられます。データセットの数は 50 を超えません。\n\nOutput\n\nデータセットごとに、パズルを完成させることができる数字を昇順に空白区切りで1行に出力します。\n\nSample Input\n\n3649596966777\n6358665788577\n9118992346175\n9643871425498\n7755542764533\n1133557799246\n\nOutput for the Sample Input\n\n2 3 5 8\n3 4\n1 2 3 4 5 6 7 8 9\n7 8 9\n1 2 3 4 6 7 8\n0", "sample_input": "3649596966777\n6358665788577\n9118992346175\n9643871425498\n7755542764533\n1133557799246\n"}, "reference_outputs": ["2 3 5 8\n3 4\n1 2 3 4 5 6 7 8 9\n7 8 9\n1 2 3 4 6 7 8\n0\n"], "source_document_id": "p00043", "source_text": "パズル\n\n1 〜 9 の数字を 14 個組み合わせて完成させるパズルがあります。与えられた 13 個の数字にもうひとつ数字を付け加えて完成させます。\n\nパズルの完成条件は\n\n同じ数字を2つ組み合わせたものが必ずひとつ必要です。\n\n残りの12 個の数字は、3個の数字の組み合わせ4つです。\n\n3個の数字の組み合わせ方は、同じ数字を3つ組み合わせたものか、または3つの連続する数字を組み合わせたものです。ただし、9 1 2 のような並びは連続する数字とは認められません。\n\n同じ数字は4 回まで使えます。\n\n13 個の数字からなる文字列を読み込んで、パズルを完成することができる数字を昇順に全て出力するプログラムを作成してください。なお、1〜9 のどの数字を付け加えてもパズルを完成させることができないときは 0 を出力してください。\n\n例えば与えられた文字列が 3456666777999 の場合\n\n「2」があれば、 234 567 666 77 999\n\n「3」があれば、 33 456 666 777 999\n\n「5」があれば、 345 567 666 77 999\n\n「8」があれば、 345 666 678 77 999\n\nというふうに、2 3 5 8 のいずれかの数字が付け加えられるとパズルは完成します。「6」でも整いますが、5 回目の使用になるので、この例では使えないことに注意してください。\n\nInput\n\n入力は複数のデータセットからなります。各データセットとして、13 個の数字が1行に与えられます。データセットの数は 50 を超えません。\n\nOutput\n\nデータセットごとに、パズルを完成させることができる数字を昇順に空白区切りで1行に出力します。\n\nSample Input\n\n3649596966777\n6358665788577\n9118992346175\n9643871425498\n7755542764533\n1133557799246\n\nOutput for the Sample Input\n\n2 3 5 8\n3 4\n1 2 3 4 5 6 7 8 9\n7 8 9\n1 2 3 4 6 7 8\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 390, "memory_kb": 66468}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s535958614", "group_id": "codeNet:p00046", "input_text": "object Main {\n def main(args: Array[String]) = {\n var min: Double = 1000000 + 1\n var max: Double = -1\n for (x <- io.Source.stdin.getLines()) {\n val y = x.toDouble\n if (y < min) min = y\n else if (y > max) max = y\n }\n println(max - min)\n }\n}", "language": "Scala", "metadata": {"date": 1506700029, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00046.html", "problem_id": "p00046", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00046/input.txt", "sample_output_relpath": "derived/input_output/data/p00046/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00046/Scala/s535958614.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s535958614", "user_id": "u809744987"}, "prompt_components": {"gold_output": "3130.8\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]) = {\n var min: Double = 1000000 + 1\n var max: Double = -1\n for (x <- io.Source.stdin.getLines()) {\n val y = x.toDouble\n if (y < min) min = y\n else if (y > max) max = y\n }\n println(max - min)\n }\n}", "problem_context": "標高差\n\n今まで登ったことのある山の標高を記録したデータがあります。このデータを読み込んで、一番高い山と一番低い山の標高差を出力するプログラムを作成してください。\n\nInput\n\n入力は以下の形式で与えられます。\n\n山の高さ\n...\n...\n\n山の高さが複数行に渡って与えられます。入力される値はすべて 0 以上 1,000,000 以下の実数です。入力される山の高さの数は 50 以下です。\n\nOutput\n\n一番高い山と一番低い山の標高差を実数で出力する。出力は0.01以下の誤差を含んでもよい。\n\nSample Input\n\n3776.0\n1819.0\n645.2\n2004.1\n1208.6\n\nOutput for the Sample Input\n\n3130.8", "sample_input": "3776.0\n1819.0\n645.2\n2004.1\n1208.6\n"}, "reference_outputs": ["3130.8\n"], "source_document_id": "p00046", "source_text": "標高差\n\n今まで登ったことのある山の標高を記録したデータがあります。このデータを読み込んで、一番高い山と一番低い山の標高差を出力するプログラムを作成してください。\n\nInput\n\n入力は以下の形式で与えられます。\n\n山の高さ\n...\n...\n\n山の高さが複数行に渡って与えられます。入力される値はすべて 0 以上 1,000,000 以下の実数です。入力される山の高さの数は 50 以下です。\n\nOutput\n\n一番高い山と一番低い山の標高差を実数で出力する。出力は0.01以下の誤差を含んでもよい。\n\nSample Input\n\n3776.0\n1819.0\n645.2\n2004.1\n1208.6\n\nOutput for the Sample Input\n\n3130.8", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 271, "cpu_time_ms": 260, "memory_kb": 43904}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s315173845", "group_id": "codeNet:p00053", "input_text": "import scala.io.StdIn.readInt\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n def sieve(n:Int) = {\n val list = Array.tabulate(n+1) { _ % 2 }\n val primes = new ArrayBuffer[Int]\n list(1) = 0\n list(2) = 2\n primes += 2\n\n for( i <- 3 to Math.sqrt(n).toInt by 2 )\n {\n if(list(i) == 1) {\n (i*i to n by i*2).foreach { list(_) = 0 }\n primes += primes(primes.length-1)+i\n }\n }\n for(i<-Math.sqrt(n).toInt+1 to n if list(i)==1)\n primes += primes(primes.length-1)+i\n primes.toArray\n }\n\n def main(args:Array[String]) = {\n val p = sieve(200000)\n var n = 0\n while( { n = readInt; n} != 0 ) println(p(n-1))\n }\n}", "language": "Scala", "metadata": {"date": 1486393485, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00053.html", "problem_id": "p00053", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00053/input.txt", "sample_output_relpath": "derived/input_output/data/p00053/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00053/Scala/s315173845.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s315173845", "user_id": "u508732591"}, "prompt_components": {"gold_output": "5\n100\n", "input_to_evaluate": "import scala.io.StdIn.readInt\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n def sieve(n:Int) = {\n val list = Array.tabulate(n+1) { _ % 2 }\n val primes = new ArrayBuffer[Int]\n list(1) = 0\n list(2) = 2\n primes += 2\n\n for( i <- 3 to Math.sqrt(n).toInt by 2 )\n {\n if(list(i) == 1) {\n (i*i to n by i*2).foreach { list(_) = 0 }\n primes += primes(primes.length-1)+i\n }\n }\n for(i<-Math.sqrt(n).toInt+1 to n if list(i)==1)\n primes += primes(primes.length-1)+i\n primes.toArray\n }\n\n def main(args:Array[String]) = {\n val p = sieve(200000)\n var n = 0\n while( { n = readInt; n} != 0 ) println(p(n-1))\n }\n}", "problem_context": "素数の和\n\np(i) を小さい方から i 番目の素数とします。例えば、7 は、2, 3, 5, 7 と小さい方から 4 番目の素数なので、p(4) = 7 です。\n\nn が与えられたとき、i = 1 から n までの p(i) の和 s\n\ns = p(1) + p(2) + .... + p(n)\n\nを出力するプログラムを作成してください。例えば、n = 9 のとき、s = 2 + 3 + 5 + 7 + 11 + 13 + 17 + 19 + 23 = 100 となります。\n\nInput\n\n複数のデータセットが与えられます。各データセットに整数 n (n ≤ 10000) が与えられます。n が 0 のとき入力の最後とします。データセットの数は 50 を超えません。\n\nOutput\n\n各データセットの n に対して、s を1行に出力して下さい。\n\nSample Input\n\n2\n9\n0\n\nOutput for the Sample Input\n\n5\n100", "sample_input": "2\n9\n0\n"}, "reference_outputs": ["5\n100\n"], "source_document_id": "p00053", "source_text": "素数の和\n\np(i) を小さい方から i 番目の素数とします。例えば、7 は、2, 3, 5, 7 と小さい方から 4 番目の素数なので、p(4) = 7 です。\n\nn が与えられたとき、i = 1 から n までの p(i) の和 s\n\ns = p(1) + p(2) + .... + p(n)\n\nを出力するプログラムを作成してください。例えば、n = 9 のとき、s = 2 + 3 + 5 + 7 + 11 + 13 + 17 + 19 + 23 = 100 となります。\n\nInput\n\n複数のデータセットが与えられます。各データセットに整数 n (n ≤ 10000) が与えられます。n が 0 のとき入力の最後とします。データセットの数は 50 を超えません。\n\nOutput\n\n各データセットの n に対して、s を1行に出力して下さい。\n\nSample Input\n\n2\n9\n0\n\nOutput for the Sample Input\n\n5\n100", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 300, "memory_kb": 53496}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s161869634", "group_id": "codeNet:p00054", "input_text": "object Main extends App {\n for (Array(a, b, n) <- io.Source.stdin.getLines.map(_.split(\" \").map(_.toInt))) {\n val x = (0 until n).foldLeft((a, 0))((p, _) => (p._1 % b * 10, p._2 + p._1 % b * 10 / b))\n println(x._2)\n }\n}", "language": "Scala", "metadata": {"date": 1496323813, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00054.html", "problem_id": "p00054", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00054/input.txt", "sample_output_relpath": "derived/input_output/data/p00054/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00054/Scala/s161869634.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s161869634", "user_id": "u475394465"}, "prompt_components": {"gold_output": "5\n24\n7\n6\n", "input_to_evaluate": "object Main extends App {\n for (Array(a, b, n) <- io.Source.stdin.getLines.map(_.split(\" \").map(_.toInt))) {\n val x = (0 until n).foldLeft((a, 0))((p, _) => (p._1 % b * 10, p._2 + p._1 % b * 10 / b))\n println(x._2)\n }\n}", "problem_context": "小数位の和\n\na, b, n は、いずれも正の整数であるとします。分数 a / b の小数第 i 位の数を f(i) とします (0 ≤ f(i) ≤ 9)。このとき、i = 1 から n までの f(i) の和を s とします。\n\ns = f(1) + f(2) + ... + f(n)\n\na, b, n を読み込んで、 s を出力して終了するプログラムを作成してください。\n\nInput\n\n入力は複数のデータセットからなります。各データセットとして、3 つの整数 a (1 ≤ a ≤ 1000), b (1 ≤ b ≤ 10000), n (1 ≤ n ≤ 100) が空白区切りで1行に与えられます。\n\nデータセットの数は 100 を超えません。\n\nOutput\n\nデータセットごとに、s を1行に出力します。\n\nSample Input\n\n1 2 3\n2 3 4\n5 4 3\n4 3 2\n\nOutput for the Sample Input\n\n5\n24\n7\n6", "sample_input": "1 2 3\n2 3 4\n5 4 3\n4 3 2\n"}, "reference_outputs": ["5\n24\n7\n6\n"], "source_document_id": "p00054", "source_text": "小数位の和\n\na, b, n は、いずれも正の整数であるとします。分数 a / b の小数第 i 位の数を f(i) とします (0 ≤ f(i) ≤ 9)。このとき、i = 1 から n までの f(i) の和を s とします。\n\ns = f(1) + f(2) + ... + f(n)\n\na, b, n を読み込んで、 s を出力して終了するプログラムを作成してください。\n\nInput\n\n入力は複数のデータセットからなります。各データセットとして、3 つの整数 a (1 ≤ a ≤ 1000), b (1 ≤ b ≤ 10000), n (1 ≤ n ≤ 100) が空白区切りで1行に与えられます。\n\nデータセットの数は 100 を超えません。\n\nOutput\n\nデータセットごとに、s を1行に出力します。\n\nSample Input\n\n1 2 3\n2 3 4\n5 4 3\n4 3 2\n\nOutput for the Sample Input\n\n5\n24\n7\n6", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 44112}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s104106406", "group_id": "codeNet:p00078", "input_text": "import scala.io.StdIn.readLine\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n def main(args:Array[String]) = {\n var n = 0\n val b = new ArrayBuffer[String]\n while({n=readLine.trim.toInt;n}!=0) {\n val a = Array.ofDim[Int](n,n)\n var (i,j,m) = (n/2+1,n/2,1)\n a(i)(j) = m\n m += 1\n i += 1\n j += 1\n while(m<=n*n) {\n if(j>=n) j=0 else if(j<0) j=n-1\n if(i>=n) i=0\n if(a(i)(j)!=0) {\n i += 1\n j -= 1\n } else {\n a(i)(j) = m\n m += 1\n i += 1\n j += 1\n }\n }\n b+=a.map(s=>s.map(\"%4d\".format(_)).mkString).mkString(\"\\n\")\n }\n println(b.mkString(\"\\n\"))\n }\n}", "language": "Scala", "metadata": {"date": 1488903234, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00078.html", "problem_id": "p00078", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00078/input.txt", "sample_output_relpath": "derived/input_output/data/p00078/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00078/Scala/s104106406.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s104106406", "user_id": "u508732591"}, "prompt_components": {"gold_output": " 4 9 2\n 3 5 7\n 8 1 6\n 11 24 7 20 3\n 4 12 25 8 16\n 17 5 13 21 9\n 10 18 1 14 22\n 23 6 19 2 15\n", "input_to_evaluate": "import scala.io.StdIn.readLine\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n def main(args:Array[String]) = {\n var n = 0\n val b = new ArrayBuffer[String]\n while({n=readLine.trim.toInt;n}!=0) {\n val a = Array.ofDim[Int](n,n)\n var (i,j,m) = (n/2+1,n/2,1)\n a(i)(j) = m\n m += 1\n i += 1\n j += 1\n while(m<=n*n) {\n if(j>=n) j=0 else if(j<0) j=n-1\n if(i>=n) i=0\n if(a(i)(j)!=0) {\n i += 1\n j -= 1\n } else {\n a(i)(j) = m\n m += 1\n i += 1\n j += 1\n }\n }\n b+=a.map(s=>s.map(\"%4d\".format(_)).mkString).mkString(\"\\n\")\n }\n println(b.mkString(\"\\n\"))\n }\n}", "problem_context": "魔方陣\n\nn × n の正方形のマス目の中に数字の1から n × n が一つずつ入っていて、縦のどの列のマス目の和も、横のどの列のマス目の和も対角線のマス目の和も等しいものを魔方陣といいます。\n\n一辺のマスの個数が奇数の魔方陣の作り方には以下の方法があります。\n\n中央のマス目のちょうど一つ下のマス目に1を入れる。\n\n次の数字を右斜め下のマス目に入れる。\nただし、数字を入れようとしたマス目が正方形からはみ出している場合、すでに数字が埋まっている場合は以下の方法に従って数字を入れるマス目を探す。\n\n右にはみ出した場合には、同じ行の左はしに、左にはみ出した場合には、同じ行の右はしに、下にはみ出した場合には、同じ列の一番上に数字を入れる。\n\n数字を入れようとしたマス目が埋まっているときには、その埋まっているマス目の左斜め下のマス目に入れる。\n\n全てのマス目が埋まるまで2を繰り返す。\n\nこの方法に従って、一辺のマス目の個数 n を入力として、その大きさの魔方陣を出力するプログラムを作成して下さい。ただし、n は 3 以上 15 以下の奇数とします。マス目に入る各数字は右詰 4 桁で出力してください。\n\n入力\n\n複数の入力が与えられます。各入力で n (正の整数)が1行に与えられます。入力は 0 で終了します。入力の数は 10 を超えません。\n\n出力\n\n各入力に対して n × n の魔方陣を出力して下さい。\n\nSample Input\n\n3\n5\n0\n\nOutput for the Sample Input\n\n4 9 2\n3 5 7\n8 1 6\n11 24 7 20 3\n4 12 25 8 16\n17 5 13 21 9\n10 18 1 14 22\n23 6 19 2 15", "sample_input": "3\n5\n0\n"}, "reference_outputs": [" 4 9 2\n 3 5 7\n 8 1 6\n 11 24 7 20 3\n 4 12 25 8 16\n 17 5 13 21 9\n 10 18 1 14 22\n 23 6 19 2 15\n"], "source_document_id": "p00078", "source_text": "魔方陣\n\nn × n の正方形のマス目の中に数字の1から n × n が一つずつ入っていて、縦のどの列のマス目の和も、横のどの列のマス目の和も対角線のマス目の和も等しいものを魔方陣といいます。\n\n一辺のマスの個数が奇数の魔方陣の作り方には以下の方法があります。\n\n中央のマス目のちょうど一つ下のマス目に1を入れる。\n\n次の数字を右斜め下のマス目に入れる。\nただし、数字を入れようとしたマス目が正方形からはみ出している場合、すでに数字が埋まっている場合は以下の方法に従って数字を入れるマス目を探す。\n\n右にはみ出した場合には、同じ行の左はしに、左にはみ出した場合には、同じ行の右はしに、下にはみ出した場合には、同じ列の一番上に数字を入れる。\n\n数字を入れようとしたマス目が埋まっているときには、その埋まっているマス目の左斜め下のマス目に入れる。\n\n全てのマス目が埋まるまで2を繰り返す。\n\nこの方法に従って、一辺のマス目の個数 n を入力として、その大きさの魔方陣を出力するプログラムを作成して下さい。ただし、n は 3 以上 15 以下の奇数とします。マス目に入る各数字は右詰 4 桁で出力してください。\n\n入力\n\n複数の入力が与えられます。各入力で n (正の整数)が1行に与えられます。入力は 0 で終了します。入力の数は 10 を超えません。\n\n出力\n\n各入力に対して n × n の魔方陣を出力して下さい。\n\nSample Input\n\n3\n5\n0\n\nOutput for the Sample Input\n\n4 9 2\n3 5 7\n8 1 6\n11 24 7 20 3\n4 12 25 8 16\n17 5 13 21 9\n10 18 1 14 22\n23 6 19 2 15", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 280, "memory_kb": 45772}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s774627755", "group_id": "codeNet:p00090", "input_text": "import java.util\n\nimport scala.collection.mutable\n\nobject Main extends App {\n type Radian = Double\n import scala.math.{sin, cos, sqrt, Pi, acos}\n import scala.io.StdIn.{readLine}\n import Main.Angle._\n loop(readLine().toInt)\n def loop(n:Int):Unit = {\n if (n == 0) return\n val circles = Array.tabulate(n) { _ ⇒\n val Array(x, y) = readLine().split(',').map(_.toDouble)\n Circle(Coordinate(x, y))\n }\n println(circles.map { circle ⇒\n val flag = Flag.Empty\n val stack = mutable.Stack[EndPoint]()\n var overlapped: Int = 0\n for (i ← 0 until circles.size) {\n if (circle == circles(i)) {\n overlapped += 1\n } else {\n circle.CrossPoint(circles(i)) match {\n case Some((begin, end)) ⇒\n stack.push(EndPoint(Begin, i, begin), EndPoint(End, i, end))\n case _ ⇒\n }\n }\n }\n var max = 0\n var current = overlapped\n stack.sorted.foreach {\n case EndPoint(Begin, id, _) ⇒\n flag.SetFlag(id)\n current += 1\n case EndPoint(_, id, _) if flag.IsSet(id) ⇒\n flag.UnsetFlag(id)\n if (max < current) max = current\n current -= 1\n case EndPoint(_, _, _) ⇒\n if (max < current) max = current\n max += 1\n }\n if (max < current) max = current\n max\n }.max)\n loop(readLine().toInt)\n }\n sealed trait EndType\n object Begin extends EndType{\n override def toString: String = \"Begin\"\n }\n object End extends EndType{\n override def toString: String = \"End\"\n }\n case class EndPoint(endType: EndType, id:Int, angle: Angle) extends Ordered[EndPoint] {\n override def compare(that: EndPoint): Int = if (angle == that.angle) (endType, that.endType) match{\n case (Begin, End) ⇒ -1\n case (End, Begin) ⇒ 1\n case _ ⇒ 0\n } else angle.compareTo(that.angle)\n }\n case class Coordinate(x:Double, y:Double){\n def +(other:Coordinate):Coordinate = Coordinate(x + other.x, y + other.y)\n def -(other:Coordinate):Coordinate = Coordinate(x - other.x, y - other.y)\n def Length:Double = sqrt(x * x + y * y)\n\n override def toString: String = s\"($x, $y)\"\n override def equals(obj: scala.Any): Boolean = {\n obj match{\n case Coordinate(a, b) ⇒ x == a && y == b\n case _ ⇒ false\n }\n }\n }\n implicit class ImplicitCoordinateManipulator(val coordinate: Coordinate){\n def Fmap(transformer:Double => Double):Coordinate = Coordinate(transformer(coordinate.x), transformer(coordinate.y))\n def *(other:Int):Coordinate = Coordinate(coordinate.x * other, coordinate.y * other)\n def /(other:Int):Coordinate = Coordinate(coordinate.x / other, coordinate.y / other)\n }\n class Angle private (val Sin:Double, val Cos:Double) extends Ordered[Angle]{\n def +(other:Angle):Angle = new Angle(Sin * other.Cos + Cos * other.Sin, Cos * other.Cos - Sin * other.Sin)\n def -(other:Angle):Angle = new Angle(Sin * other.Cos - Cos * other.Sin, Cos * other.Cos + Sin * other.Sin)\n private def ToRadian:Radian = if (Sin >= 0) acos(Cos) else 2 * Pi - acos(Cos)\n override def compare(that: Angle): Int = ToRadian.compareTo(that.ToRadian)\n\n override def toString: String = s\"${ToRadian * 180 / Pi}\"\n }\n object Angle{\n implicit class ImplicitCoordinateAngleConverter(val coordinate:Coordinate){\n def ToAngle:Angle = new Angle(coordinate.y / coordinate.Length, coordinate.x / coordinate.Length)\n }\n implicit class ImplicitAngleCoordinateConverter(val angle: Angle){\n def ToCoordinate:Coordinate = Coordinate(angle.Cos, angle.Sin)\n }\n implicit class ImplicitRadianToAngleConverter(val rad:Radian){\n def ToAngle:Angle = new Angle(sin(rad), cos(rad))\n }\n }\n case class Circle(center:Coordinate){\n def CrossPoint(other:Circle):Option[(Angle, Angle)] = {\n (center - other.center).Length match{\n case len if len > 2 => None\n case len =>\n val angle = (other.center - center).ToAngle\n val diff = acos(len / 2).ToAngle\n val posA = angle - diff\n val posB = angle + diff\n Some((posA, posB))\n }\n }\n }\n class Flag private (private var first:Int = 0, private var second:Int = 0, private var third:Int = 0, private var forth:Int = 0){\n def SetFlag(n:Int):Unit = {\n n match{\n case _ if n > 96 ⇒ forth |= 1 << (n - 96)\n case _ if n > 64 ⇒ third |= 1 << (n - 64)\n case _ if n > 32 ⇒ second |= 1 << (n - 32)\n case _ ⇒ first |= 1 << n\n }\n }\n def IsSet(n:Int):Boolean = {\n n match{\n case _ if n > 96 ⇒ (forth & (1 << (n - 96))) != 0\n case _ if n > 64 ⇒ (third & (1 << (n - 64))) != 0\n case _ if n > 32 ⇒ (second & (1 << (n - 32))) != 0\n case _ ⇒ (first & (1 << n)) != 0\n }\n }\n def UnsetFlag(n:Int):Unit = {\n n match{\n case _ if n > 96 ⇒ forth &= ~(1 << (n - 96))\n case _ if n > 64 ⇒ third &= ~(1 << (n - 64))\n case _ if n > 32 ⇒ second &= ~(1 << (n - 32))\n case _ ⇒ first &= ~(1 << n)\n }\n }\n }\n object Flag{\n def Empty= new Flag()\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1527313838, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00090.html", "problem_id": "p00090", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00090/input.txt", "sample_output_relpath": "derived/input_output/data/p00090/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00090/Scala/s774627755.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s774627755", "user_id": "u514597327"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util\n\nimport scala.collection.mutable\n\nobject Main extends App {\n type Radian = Double\n import scala.math.{sin, cos, sqrt, Pi, acos}\n import scala.io.StdIn.{readLine}\n import Main.Angle._\n loop(readLine().toInt)\n def loop(n:Int):Unit = {\n if (n == 0) return\n val circles = Array.tabulate(n) { _ ⇒\n val Array(x, y) = readLine().split(',').map(_.toDouble)\n Circle(Coordinate(x, y))\n }\n println(circles.map { circle ⇒\n val flag = Flag.Empty\n val stack = mutable.Stack[EndPoint]()\n var overlapped: Int = 0\n for (i ← 0 until circles.size) {\n if (circle == circles(i)) {\n overlapped += 1\n } else {\n circle.CrossPoint(circles(i)) match {\n case Some((begin, end)) ⇒\n stack.push(EndPoint(Begin, i, begin), EndPoint(End, i, end))\n case _ ⇒\n }\n }\n }\n var max = 0\n var current = overlapped\n stack.sorted.foreach {\n case EndPoint(Begin, id, _) ⇒\n flag.SetFlag(id)\n current += 1\n case EndPoint(_, id, _) if flag.IsSet(id) ⇒\n flag.UnsetFlag(id)\n if (max < current) max = current\n current -= 1\n case EndPoint(_, _, _) ⇒\n if (max < current) max = current\n max += 1\n }\n if (max < current) max = current\n max\n }.max)\n loop(readLine().toInt)\n }\n sealed trait EndType\n object Begin extends EndType{\n override def toString: String = \"Begin\"\n }\n object End extends EndType{\n override def toString: String = \"End\"\n }\n case class EndPoint(endType: EndType, id:Int, angle: Angle) extends Ordered[EndPoint] {\n override def compare(that: EndPoint): Int = if (angle == that.angle) (endType, that.endType) match{\n case (Begin, End) ⇒ -1\n case (End, Begin) ⇒ 1\n case _ ⇒ 0\n } else angle.compareTo(that.angle)\n }\n case class Coordinate(x:Double, y:Double){\n def +(other:Coordinate):Coordinate = Coordinate(x + other.x, y + other.y)\n def -(other:Coordinate):Coordinate = Coordinate(x - other.x, y - other.y)\n def Length:Double = sqrt(x * x + y * y)\n\n override def toString: String = s\"($x, $y)\"\n override def equals(obj: scala.Any): Boolean = {\n obj match{\n case Coordinate(a, b) ⇒ x == a && y == b\n case _ ⇒ false\n }\n }\n }\n implicit class ImplicitCoordinateManipulator(val coordinate: Coordinate){\n def Fmap(transformer:Double => Double):Coordinate = Coordinate(transformer(coordinate.x), transformer(coordinate.y))\n def *(other:Int):Coordinate = Coordinate(coordinate.x * other, coordinate.y * other)\n def /(other:Int):Coordinate = Coordinate(coordinate.x / other, coordinate.y / other)\n }\n class Angle private (val Sin:Double, val Cos:Double) extends Ordered[Angle]{\n def +(other:Angle):Angle = new Angle(Sin * other.Cos + Cos * other.Sin, Cos * other.Cos - Sin * other.Sin)\n def -(other:Angle):Angle = new Angle(Sin * other.Cos - Cos * other.Sin, Cos * other.Cos + Sin * other.Sin)\n private def ToRadian:Radian = if (Sin >= 0) acos(Cos) else 2 * Pi - acos(Cos)\n override def compare(that: Angle): Int = ToRadian.compareTo(that.ToRadian)\n\n override def toString: String = s\"${ToRadian * 180 / Pi}\"\n }\n object Angle{\n implicit class ImplicitCoordinateAngleConverter(val coordinate:Coordinate){\n def ToAngle:Angle = new Angle(coordinate.y / coordinate.Length, coordinate.x / coordinate.Length)\n }\n implicit class ImplicitAngleCoordinateConverter(val angle: Angle){\n def ToCoordinate:Coordinate = Coordinate(angle.Cos, angle.Sin)\n }\n implicit class ImplicitRadianToAngleConverter(val rad:Radian){\n def ToAngle:Angle = new Angle(sin(rad), cos(rad))\n }\n }\n case class Circle(center:Coordinate){\n def CrossPoint(other:Circle):Option[(Angle, Angle)] = {\n (center - other.center).Length match{\n case len if len > 2 => None\n case len =>\n val angle = (other.center - center).ToAngle\n val diff = acos(len / 2).ToAngle\n val posA = angle - diff\n val posB = angle + diff\n Some((posA, posB))\n }\n }\n }\n class Flag private (private var first:Int = 0, private var second:Int = 0, private var third:Int = 0, private var forth:Int = 0){\n def SetFlag(n:Int):Unit = {\n n match{\n case _ if n > 96 ⇒ forth |= 1 << (n - 96)\n case _ if n > 64 ⇒ third |= 1 << (n - 64)\n case _ if n > 32 ⇒ second |= 1 << (n - 32)\n case _ ⇒ first |= 1 << n\n }\n }\n def IsSet(n:Int):Boolean = {\n n match{\n case _ if n > 96 ⇒ (forth & (1 << (n - 96))) != 0\n case _ if n > 64 ⇒ (third & (1 << (n - 64))) != 0\n case _ if n > 32 ⇒ (second & (1 << (n - 32))) != 0\n case _ ⇒ (first & (1 << n)) != 0\n }\n }\n def UnsetFlag(n:Int):Unit = {\n n match{\n case _ if n > 96 ⇒ forth &= ~(1 << (n - 96))\n case _ if n > 64 ⇒ third &= ~(1 << (n - 64))\n case _ if n > 32 ⇒ second &= ~(1 << (n - 32))\n case _ ⇒ first &= ~(1 << n)\n }\n }\n }\n object Flag{\n def Empty= new Flag()\n }\n}\n\n", "problem_context": "シールの重なり\n\n1 辺の長さが 10 の正方形の折り紙に半径 1 の円形のシールを n 枚貼ります。シールは重ねて貼ることができます。シールを貼る位置の座標を読み込んで、折り紙上でもっとも多くシールが重なっている場所(シールが1枚だけでも\"重なっている\"とする)でのシールの枚数を出力するプログラムを作成してください。\n\n折り紙の左下を原点とした x, y 座標を与えます。この x, y を円の中心としてシールを貼ることとします。円の中心が折り紙の外に出ることはありません。また、同一座標に複数のシールが貼られることはありません。\n\nInput\n\n複数のデータセットが与えられます。各データセットは以下のような形式で与えられます。\n\nn\nx1,y1\nx2,y2\n:\nxn,yn\n\n1行目にシールの枚数 n (0 ≤ 100) が与えられます。続く n 行に、各シールの中心座標が与えられます。\nxi, yi は i 枚目のシールの中心の x 座標と y 座標を表します。各値は小数点以下最大 6 桁までの数字を含む実数で与えられます。\n\nn が 0 のとき、入力の最後とします。データセットの数は 50 を超えません。\n\nOutput\n\n各データセットに対し、折り紙上で最も多くシールが重なっている場所でのシールの枚数(整数)を出力して下さい。\n\nSample Input\n\n15\n3.14979,8.51743\n2.39506,3.84915\n2.68432,5.39095\n5.61904,9.16332\n7.85653,4.75593\n2.84021,5.41511\n1.79500,8.59211\n7.55389,8.17604\n4.70665,4.66125\n1.63470,4.42538\n7.34959,4.61981\n5.09003,8.11122\n5.24373,1.30066\n0.13517,1.83659\n7.57313,1.58150\n0\n\nOutput for the Sample Input\n\n4\n\nHint\n\n入力例のようにシールを貼った図です。円はシール、数字は入力例の行数を表しています。\n点(2.3,4.6)では、入力例の 2 行目、3 行目、6 行目、10 行目の 4 枚のシールが重なっています。\n\n6 と 9 のおのおのの中心の距離は 2.01293 なので、シールは重なっていません。1 と 12 のおのおのの中心の距離は 1.98231 なので、シールは重なっています。\n\n2つの円が接しているとき(おのおのの中心の距離が 2 のとき)は、重なっているものとします。", "sample_input": "15\n3.14979,8.51743\n2.39506,3.84915\n2.68432,5.39095\n5.61904,9.16332\n7.85653,4.75593\n2.84021,5.41511\n1.79500,8.59211\n7.55389,8.17604\n4.70665,4.66125\n1.63470,4.42538\n7.34959,4.61981\n5.09003,8.11122\n5.24373,1.30066\n0.13517,1.83659\n7.57313,1.58150\n0\n"}, "reference_outputs": ["4\n"], "source_document_id": "p00090", "source_text": "シールの重なり\n\n1 辺の長さが 10 の正方形の折り紙に半径 1 の円形のシールを n 枚貼ります。シールは重ねて貼ることができます。シールを貼る位置の座標を読み込んで、折り紙上でもっとも多くシールが重なっている場所(シールが1枚だけでも\"重なっている\"とする)でのシールの枚数を出力するプログラムを作成してください。\n\n折り紙の左下を原点とした x, y 座標を与えます。この x, y を円の中心としてシールを貼ることとします。円の中心が折り紙の外に出ることはありません。また、同一座標に複数のシールが貼られることはありません。\n\nInput\n\n複数のデータセットが与えられます。各データセットは以下のような形式で与えられます。\n\nn\nx1,y1\nx2,y2\n:\nxn,yn\n\n1行目にシールの枚数 n (0 ≤ 100) が与えられます。続く n 行に、各シールの中心座標が与えられます。\nxi, yi は i 枚目のシールの中心の x 座標と y 座標を表します。各値は小数点以下最大 6 桁までの数字を含む実数で与えられます。\n\nn が 0 のとき、入力の最後とします。データセットの数は 50 を超えません。\n\nOutput\n\n各データセットに対し、折り紙上で最も多くシールが重なっている場所でのシールの枚数(整数)を出力して下さい。\n\nSample Input\n\n15\n3.14979,8.51743\n2.39506,3.84915\n2.68432,5.39095\n5.61904,9.16332\n7.85653,4.75593\n2.84021,5.41511\n1.79500,8.59211\n7.55389,8.17604\n4.70665,4.66125\n1.63470,4.42538\n7.34959,4.61981\n5.09003,8.11122\n5.24373,1.30066\n0.13517,1.83659\n7.57313,1.58150\n0\n\nOutput for the Sample Input\n\n4\n\nHint\n\n入力例のようにシールを貼った図です。円はシール、数字は入力例の行数を表しています。\n点(2.3,4.6)では、入力例の 2 行目、3 行目、6 行目、10 行目の 4 枚のシールが重なっています。\n\n6 と 9 のおのおのの中心の距離は 2.01293 なので、シールは重なっていません。1 と 12 のおのおのの中心の距離は 1.98231 なので、シールは重なっています。\n\n2つの円が接しているとき(おのおのの中心の距離が 2 のとき)は、重なっているものとします。", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5159, "cpu_time_ms": 390, "memory_kb": 53352}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s151742459", "group_id": "codeNet:p00094", "input_text": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n val n = readLine.split(\" \").map(_.toDouble)\n println(n(0)*n(1)/3.305785)\n}", "language": "Scala", "metadata": {"date": 1486655219, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00094.html", "problem_id": "p00094", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00094/input.txt", "sample_output_relpath": "derived/input_output/data/p00094/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00094/Scala/s151742459.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s151742459", "user_id": "u508732591"}, "prompt_components": {"gold_output": "113.437508\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n val n = readLine.split(\" \").map(_.toDouble)\n println(n(0)*n(1)/3.305785)\n}", "problem_context": "坪面積の計算\n\n土地の面積を表現する「○○坪」という単位を聞いたことはないでしょうか? 古来、1人の武士が1日に食べるお米を作る面積を言いました。\n\na[m]× b[m]の土地があります。a と b を入力し、その土地の坪面積 S[坪]を出力するプログラムを作成してください。 1 坪 = 3.305785 [m2] とし、a と b は 100 以下の整数とします。\n\n入力\n\na b\n\n1つの空白で区切られた a と b が1行に与えられる。\n\n出力\n\n坪面積 S を1行に出力する。0.0001 以下の誤差が許される。\n\n入力例1\n\n15 25\n\n出力例1\n\n113.437508", "sample_input": "15 25\n"}, "reference_outputs": ["113.437508\n"], "source_document_id": "p00094", "source_text": "坪面積の計算\n\n土地の面積を表現する「○○坪」という単位を聞いたことはないでしょうか? 古来、1人の武士が1日に食べるお米を作る面積を言いました。\n\na[m]× b[m]の土地があります。a と b を入力し、その土地の坪面積 S[坪]を出力するプログラムを作成してください。 1 坪 = 3.305785 [m2] とし、a と b は 100 以下の整数とします。\n\n入力\n\na b\n\n1つの空白で区切られた a と b が1行に与えられる。\n\n出力\n\n坪面積 S を1行に出力する。0.0001 以下の誤差が許される。\n\n入力例1\n\n15 25\n\n出力例1\n\n113.437508", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 280, "memory_kb": 44004}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s321782446", "group_id": "codeNet:p00106", "input_text": "import scala.io.StdIn.readInt\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n def getPrice(total:Int,a:Int,b:Int,c:Int,d:Array[Array[Array[Int]]]):Int = {\n if(total==0) {\n d(a)(b)(c)=((a/5)*5*380*0.8+((a%5)*380)*1.0+(b/4)*4*550*0.85+(b%4)*550*1.0+(c/3)*3*850*0.88+(c%3)*850).toInt\n d(a)(b)(c)\n } else if(d(a)(b)(c)>0) d(a)(b)(c)\n else {\n var min = Int.MaxValue\n if(total==200 || total>=400) {\n val p = getPrice(total-200,a+1,b,c,d)\n if(p=500) {\n val q = getPrice(total-300,a,b+1,c,d)\n if(q=700) {\n val r = getPrice(total-500,a,b,c+1,d)\n if(r0) d(a)(b)(c)\n else {\n var min = Int.MaxValue\n if(total==200 || total>=400) {\n val p = getPrice(total-200,a+1,b,c,d)\n if(p=500) {\n val q = getPrice(total-300,a,b+1,c,d)\n if(q=700) {\n val r = getPrice(total-500,a,b,c+1,d)\n if(r\n val n = s.split(\"\\\\+\")\n val m = n(1).split(\"=\")\n val a = n(0);val b = m(0);val c = m(1)\n val range = if((a.length>1 && a(0)=='X') ||\n (b.length>1 && b(0)=='X') ||\n (c.length>1 && c(0)=='X')) '1' to '9' else '0' to '9'\n val result = range.find{ e =>\n BigInt(a.replace('X',e))+BigInt(b.replace('X',e)) == BigInt(c.replace('X',e))\n }.map(_.toString).getOrElse(\"NA\")\n println(result)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1493528976, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00110.html", "problem_id": "p00110", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00110/input.txt", "sample_output_relpath": "derived/input_output/data/p00110/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00110/Scala/s725099597.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s725099597", "user_id": "u508732591"}, "prompt_components": {"gold_output": "5\nNA\n1\n", "input_to_evaluate": "import scala.io.StdIn.{readInt,readLine}\n\nobject Main {\n\n def main(args:Array[String]) = {\n Iterator.continually(readLine).takeWhile(_!=null).foreach { s =>\n val n = s.split(\"\\\\+\")\n val m = n(1).split(\"=\")\n val a = n(0);val b = m(0);val c = m(1)\n val range = if((a.length>1 && a(0)=='X') ||\n (b.length>1 && b(0)=='X') ||\n (c.length>1 && c(0)=='X')) '1' to '9' else '0' to '9'\n val result = range.find{ e =>\n BigInt(a.replace('X',e))+BigInt(b.replace('X',e)) == BigInt(c.replace('X',e))\n }.map(_.toString).getOrElse(\"NA\")\n println(result)\n }\n }\n}", "problem_context": "覆面算\n\n数式の一部を隠してしまって、隠した数字を探す問題を覆面算といいます。今回は、数式の中のある数字のいくつかを X で隠してしまった式を扱います。以下の数式を入力して、結果を出力するプログラムを作成してください。\n\n数式\n\n「数字列 + 数字列 = 数字列」の形で、1 行の単純な足し算式です。\n\n「数字列」は、数字 0 から 9 と文字 X の並びです。\n\n2 桁以上の「数字列」の左端の数字は 0 ではないものとします。\n\nX は、数式全体の中で必ず 1 つ以上含まれます。\n\n結果\n\n覆面算の答えです。数式が成り立つ様な X の値で 0 ~ 9 のどれか 1 つです。2 つ以上の答えはないものとします。\n\n答えがない場合、結果は“NA”としてください。\n\nInput\n\n複数のデータセットが与えられます。各データセットとして、X を 1 つ以上含む足し算式(空白を含まない 126 文字以内の文字列) が1行に与えられます。データセットの数は 150 を超えません。\n\nOutput\n\n各データセットについて、覆面算の結果を1行に出力してください。数字 0 ~ 9 または NA を出力してください。\n\nSample Input\n\n123+4X6=X79\n12X+4X6=X79\nXX22+89=X2XX\n\nOutput for the Sample Input\n\n5\nNA\n1", "sample_input": "123+4X6=X79\n12X+4X6=X79\nXX22+89=X2XX\n"}, "reference_outputs": ["5\nNA\n1\n"], "source_document_id": "p00110", "source_text": "覆面算\n\n数式の一部を隠してしまって、隠した数字を探す問題を覆面算といいます。今回は、数式の中のある数字のいくつかを X で隠してしまった式を扱います。以下の数式を入力して、結果を出力するプログラムを作成してください。\n\n数式\n\n「数字列 + 数字列 = 数字列」の形で、1 行の単純な足し算式です。\n\n「数字列」は、数字 0 から 9 と文字 X の並びです。\n\n2 桁以上の「数字列」の左端の数字は 0 ではないものとします。\n\nX は、数式全体の中で必ず 1 つ以上含まれます。\n\n結果\n\n覆面算の答えです。数式が成り立つ様な X の値で 0 ~ 9 のどれか 1 つです。2 つ以上の答えはないものとします。\n\n答えがない場合、結果は“NA”としてください。\n\nInput\n\n複数のデータセットが与えられます。各データセットとして、X を 1 つ以上含む足し算式(空白を含まない 126 文字以内の文字列) が1行に与えられます。データセットの数は 150 を超えません。\n\nOutput\n\n各データセットについて、覆面算の結果を1行に出力してください。数字 0 ~ 9 または NA を出力してください。\n\nSample Input\n\n123+4X6=X79\n12X+4X6=X79\nXX22+89=X2XX\n\nOutput for the Sample Input\n\n5\nNA\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 635, "cpu_time_ms": 260, "memory_kb": 45040}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s385212956", "group_id": "codeNet:p00131", "input_text": "object Main {\n val fld = Array.ofDim[Int](10)\n val ans = Array.ofDim[Int](10)\n\n def beam(y: Int, x: Int) = {\n val dir = List((y, x), (y - 1, x), (y, x - 1), (y + 1, x), (y, x + 1)).filter(p => 0 <= p._1 && p._1 < 10 && 0 <= p._2 && p._2 < 10)\n for(p <- dir) {\n fld(p._1) ^= (1 << p._2)\n }\n }\n\n def init(orig: Array[Int]) = {\n for(y <- 0 to 9) {\n fld(y) = orig(y)\n ans(y) = 0\n }\n }\n\n def row_flip(y: Int, bits: Int) = {\n for(x <- 0 to 9) {\n if((bits & (1 << x)) != 0) {\n beam(y, x)\n ans(y) |= (1 << x)\n }\n }\n }\n\n def flip(y: Int, bits: Int) = {\n row_flip(0, bits)\n for(y <- 1 to 9) row_flip(y, fld(y - 1))\n }\n\n def solve(orig: Array[Int]) = {\n var i = 0\n var flag = true\n while(flag) {\n init(orig)\n flip(0, i)\n if(fld(9) == 0) {\n ans.foreach(bits => println(Integer.toBinaryString(bits).reverse.padTo(10, '0').split(\"\").mkString(\" \")))\n flag = false\n }\n else flag = false\n }\n }\n\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n sc.nextLine\n for(_ <- 1 to n) {\n val orig = (1 to 10).toArray.map(_ => Integer.parseInt(sc.nextLine.split(\" \").mkString(\"\").reverse, 2))\n solve(orig)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1459843978, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00131.html", "problem_id": "p00131", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00131/input.txt", "sample_output_relpath": "derived/input_output/data/p00131/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00131/Scala/s385212956.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s385212956", "user_id": "u811434779"}, "prompt_components": {"gold_output": "0 0 0 0 0 0 0 0 0 0\n0 1 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 1 1 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 1 0\n0 0 0 0 0 0 0 0 0 0\n", "input_to_evaluate": "object Main {\n val fld = Array.ofDim[Int](10)\n val ans = Array.ofDim[Int](10)\n\n def beam(y: Int, x: Int) = {\n val dir = List((y, x), (y - 1, x), (y, x - 1), (y + 1, x), (y, x + 1)).filter(p => 0 <= p._1 && p._1 < 10 && 0 <= p._2 && p._2 < 10)\n for(p <- dir) {\n fld(p._1) ^= (1 << p._2)\n }\n }\n\n def init(orig: Array[Int]) = {\n for(y <- 0 to 9) {\n fld(y) = orig(y)\n ans(y) = 0\n }\n }\n\n def row_flip(y: Int, bits: Int) = {\n for(x <- 0 to 9) {\n if((bits & (1 << x)) != 0) {\n beam(y, x)\n ans(y) |= (1 << x)\n }\n }\n }\n\n def flip(y: Int, bits: Int) = {\n row_flip(0, bits)\n for(y <- 1 to 9) row_flip(y, fld(y - 1))\n }\n\n def solve(orig: Array[Int]) = {\n var i = 0\n var flag = true\n while(flag) {\n init(orig)\n flip(0, i)\n if(fld(9) == 0) {\n ans.foreach(bits => println(Integer.toBinaryString(bits).reverse.padTo(10, '0').split(\"\").mkString(\" \")))\n flag = false\n }\n else flag = false\n }\n }\n\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n sc.nextLine\n for(_ <- 1 to n) {\n val orig = (1 to 10).toArray.map(_ => Integer.parseInt(sc.nextLine.split(\" \").mkString(\"\").reverse, 2))\n solve(orig)\n }\n }\n}", "problem_context": "博士の光電管\n\n博士 : ピーター君。やったよ。\n\nピーター : またですか。今度はどんなくだらない発明ですか。\n\n博士 : あの幻の素粒子アキシオンの検出器を発明したんじゃ。\n\nピーター : アキシオンといえば、欧州合同原子核研究機構 (CERN) をはじめとする研究者たちが血眼で追っかけているという、あれですよね。本当ですかぁ?\n\n博士 : 本当だってばよ。細かい説明は省くが、非常に強力な磁場を内蔵する特殊な光電管が光ることによって、通過するアキシオンを検出する。\n\nピーター : 他 に先んじて検出すれば、小柴先生のニュートリノ検出に匹敵するノーベル賞級の研究ですよ。\nこれで役立たずの研究ばかりしている「ダメ研究室」などという汚名も返上できますね。\n\n博士 : そうだとも。小柴先生の「スーパーカミオカンデ」にあやかって、この装置を、(悪口言ったら)「タダジャオカンデ」と命名した。\n\nピーター : ちょっと苦しいって言うか、卑屈って言うか・・・。\n\n博士 : それはいいとして、この装置ちょっとした癖があるんじゃよ。\nアキシオン粒子がある光電管を通過すると、感度の関係でその光電管と隣接する上下左右の光電管が反応する。\n\n図1\n\n図2\n\n★\n\n●\n\n●\n\n●\n\n●\n\n●\n\n●\n\n●\n\n★\n\n●\n\n●\n\n●\n\n●\n\n●\n\n●\n\n●\n\n●\n\n●\n\n●\n\n●\n\n●\n\n●\n\n★\n\n●\n\n●\n\n \n\n \n\n   →   \n\n \n\n \n\n○\n\n○\n\n●\n\n○\n\n●\n\n○\n\n●\n\n○\n\n○\n\n○\n\n●\n\n●\n\n●\n\n○\n\n●\n\n●\n\n●\n\n○\n\n●\n\n●\n\n●\n\n○\n\n○\n\n○\n\n●\n\n●\n\n○\n\n○\n\n●\n\n○\n\n○\n\n★\n\n★\n\n○\n\n☆\n\n●\n\n●\n\n○\n\n●\n\n●\n\n○\n\n●\n\n●\n\n○\n\n●\n\n●\n\n○\n\n○\n\n○\n\n●\n\n \n\n \n\n   →   \n\n \n\n \n\n●\n\n●\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ピーター : つまり、図1の左側★印の光電管を粒子が通過した場合、\n右側のように点灯すると言うことですね。\n(図は 5 × 5 の例。黒は消灯・白は点灯状態。以下同じ。)\n\n博士 : また反応とは、光電管の状態が反転する。つまり消えている光電管は光り、\n光っている光電管は消える。\n\nピーター : つまり、図2の左側の★印や☆印を粒子が通過した場合、右側のような状態になると。\n\n博士 : これを正方形になんと 100 個 (10 × 10) 配置して待ち受けるわけだ。\n\nピーター : これだけの大発明、ノーベル賞選考委員会も「ホッチャオカンデ」なんて。\n\n博士 : おぉピーター君、君も我が研究室の作風になじんできたようだね。いい感じだ。\nでは、早速実験を始めよう。まずはこの装置、現在ランダムに光電管が点いているので、\n実験が始められるように全部消えた状態にリセットしてくれたまえ。\nなあに、どの光電管にアキシオン粒子を当てれば全部消えるか考えればいいだけじゃよ。\n簡単だろう?\n\nピーター : 考えるのはいいんですが博士。当てるためには、\n幻のアキシオン粒子を発生させて打ち込める装置がないといけないんじゃないですか。\n\n博士 : ・・・。\n\n博士とピータ (同時に)コリャアカンデ!だははは・・・・。\nー:\n\nということで、本日も和気あいあいと暮れてゆく博士の研究室ですが、例によって話は全く進みそうもありません。しょうがないので、ピーター君に代わってプログラムを作成してあげてください。\nプログラムは次のようなものになります。\n\nA. 装置の光電管の状態を 10 × 10 の配列として入力します。0は消灯中、1は点灯中を表します。\n0 と 1 以外のデータは含まれません。\n\nB. 入力した装置の状態をすべて消灯にするために、アキシオン粒子を通過させる位置を計算して出力します。これは、入力と同じ 10 × 10の配列で光電管の位置を表します。「0 は通過させない」、「1 は通過させる」ことを表します。すべてを消灯する方法は必ず 1 通りだけ存在するものとします。\n\nInput\n\n複数のデータセットが与えられます。1行目にデータセットの数 n (n ≤ 20) が与えられます。各データセットは以下の形式で与えられます。\n\na1,1 a1,2 ... a1,10\na2,1 a2,2 ... a2,10\n:\na10,1 a10,2 ... a10,10\n\nai,j は装置の i 行目 j 列目の光電管の状態を示す整数 (0 または 1) を表します。\n\nOutput\n\n各データセットについて、粒子を通過させる位置を以下の形式で出力してください。\n\nb1,1 b1,2 ... b1,10\nb2,1 b2,2 ... b2,10\n:\nb10,1 b10,2 ... b10,10\n\nbi,j は装置の i 行目 j 列目の光電管に粒子を通過させるかいなかを示す整数 (0 または 1) を表します。\n\nSample Input\n\n1\n0 1 0 0 0 0 0 0 0 0\n1 1 1 0 0 0 0 0 0 0\n0 1 0 0 0 0 0 0 0 0\n0 0 0 0 1 1 0 0 0 0\n0 0 0 1 0 0 1 0 0 0\n0 0 0 0 1 1 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 1 0\n0 0 0 0 0 0 0 1 1 1\n0 0 0 0 0 0 0 0 1 0\n\nOutput for the Sample Input\n\n0 0 0 0 0 0 0 0 0 0\n0 1 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 1 1 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 1 0\n0 0 0 0 0 0 0 0 0 0", "sample_input": "1\n0 1 0 0 0 0 0 0 0 0\n1 1 1 0 0 0 0 0 0 0\n0 1 0 0 0 0 0 0 0 0\n0 0 0 0 1 1 0 0 0 0\n0 0 0 1 0 0 1 0 0 0\n0 0 0 0 1 1 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 1 0\n0 0 0 0 0 0 0 1 1 1\n0 0 0 0 0 0 0 0 1 0\n"}, "reference_outputs": ["0 0 0 0 0 0 0 0 0 0\n0 1 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 1 1 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 1 0\n0 0 0 0 0 0 0 0 0 0\n"], "source_document_id": "p00131", "source_text": "博士の光電管\n\n博士 : ピーター君。やったよ。\n\nピーター : またですか。今度はどんなくだらない発明ですか。\n\n博士 : あの幻の素粒子アキシオンの検出器を発明したんじゃ。\n\nピーター : アキシオンといえば、欧州合同原子核研究機構 (CERN) をはじめとする研究者たちが血眼で追っかけているという、あれですよね。本当ですかぁ?\n\n博士 : 本当だってばよ。細かい説明は省くが、非常に強力な磁場を内蔵する特殊な光電管が光ることによって、通過するアキシオンを検出する。\n\nピーター : 他 に先んじて検出すれば、小柴先生のニュートリノ検出に匹敵するノーベル賞級の研究ですよ。\nこれで役立たずの研究ばかりしている「ダメ研究室」などという汚名も返上できますね。\n\n博士 : そうだとも。小柴先生の「スーパーカミオカンデ」にあやかって、この装置を、(悪口言ったら)「タダジャオカンデ」と命名した。\n\nピーター : ちょっと苦しいって言うか、卑屈って言うか・・・。\n\n博士 : それはいいとして、この装置ちょっとした癖があるんじゃよ。\nアキシオン粒子がある光電管を通過すると、感度の関係でその光電管と隣接する上下左右の光電管が反応する。\n\n図1\n\n図2\n\n★\n\n●\n\n●\n\n●\n\n●\n\n●\n\n●\n\n●\n\n★\n\n●\n\n●\n\n●\n\n●\n\n●\n\n●\n\n●\n\n●\n\n●\n\n●\n\n●\n\n●\n\n●\n\n★\n\n●\n\n●\n\n \n\n \n\n   →   \n\n \n\n \n\n○\n\n○\n\n●\n\n○\n\n●\n\n○\n\n●\n\n○\n\n○\n\n○\n\n●\n\n●\n\n●\n\n○\n\n●\n\n●\n\n●\n\n○\n\n●\n\n●\n\n●\n\n○\n\n○\n\n○\n\n●\n\n●\n\n○\n\n○\n\n●\n\n○\n\n○\n\n★\n\n★\n\n○\n\n☆\n\n●\n\n●\n\n○\n\n●\n\n●\n\n○\n\n●\n\n●\n\n○\n\n●\n\n●\n\n○\n\n○\n\n○\n\n●\n\n \n\n \n\n   →   \n\n \n\n \n\n●\n\n●\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ピーター : つまり、図1の左側★印の光電管を粒子が通過した場合、\n右側のように点灯すると言うことですね。\n(図は 5 × 5 の例。黒は消灯・白は点灯状態。以下同じ。)\n\n博士 : また反応とは、光電管の状態が反転する。つまり消えている光電管は光り、\n光っている光電管は消える。\n\nピーター : つまり、図2の左側の★印や☆印を粒子が通過した場合、右側のような状態になると。\n\n博士 : これを正方形になんと 100 個 (10 × 10) 配置して待ち受けるわけだ。\n\nピーター : これだけの大発明、ノーベル賞選考委員会も「ホッチャオカンデ」なんて。\n\n博士 : おぉピーター君、君も我が研究室の作風になじんできたようだね。いい感じだ。\nでは、早速実験を始めよう。まずはこの装置、現在ランダムに光電管が点いているので、\n実験が始められるように全部消えた状態にリセットしてくれたまえ。\nなあに、どの光電管にアキシオン粒子を当てれば全部消えるか考えればいいだけじゃよ。\n簡単だろう?\n\nピーター : 考えるのはいいんですが博士。当てるためには、\n幻のアキシオン粒子を発生させて打ち込める装置がないといけないんじゃないですか。\n\n博士 : ・・・。\n\n博士とピータ (同時に)コリャアカンデ!だははは・・・・。\nー:\n\nということで、本日も和気あいあいと暮れてゆく博士の研究室ですが、例によって話は全く進みそうもありません。しょうがないので、ピーター君に代わってプログラムを作成してあげてください。\nプログラムは次のようなものになります。\n\nA. 装置の光電管の状態を 10 × 10 の配列として入力します。0は消灯中、1は点灯中を表します。\n0 と 1 以外のデータは含まれません。\n\nB. 入力した装置の状態をすべて消灯にするために、アキシオン粒子を通過させる位置を計算して出力します。これは、入力と同じ 10 × 10の配列で光電管の位置を表します。「0 は通過させない」、「1 は通過させる」ことを表します。すべてを消灯する方法は必ず 1 通りだけ存在するものとします。\n\nInput\n\n複数のデータセットが与えられます。1行目にデータセットの数 n (n ≤ 20) が与えられます。各データセットは以下の形式で与えられます。\n\na1,1 a1,2 ... a1,10\na2,1 a2,2 ... a2,10\n:\na10,1 a10,2 ... a10,10\n\nai,j は装置の i 行目 j 列目の光電管の状態を示す整数 (0 または 1) を表します。\n\nOutput\n\n各データセットについて、粒子を通過させる位置を以下の形式で出力してください。\n\nb1,1 b1,2 ... b1,10\nb2,1 b2,2 ... b2,10\n:\nb10,1 b10,2 ... b10,10\n\nbi,j は装置の i 行目 j 列目の光電管に粒子を通過させるかいなかを示す整数 (0 または 1) を表します。\n\nSample Input\n\n1\n0 1 0 0 0 0 0 0 0 0\n1 1 1 0 0 0 0 0 0 0\n0 1 0 0 0 0 0 0 0 0\n0 0 0 0 1 1 0 0 0 0\n0 0 0 1 0 0 1 0 0 0\n0 0 0 0 1 1 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 1 0\n0 0 0 0 0 0 0 1 1 1\n0 0 0 0 0 0 0 0 1 0\n\nOutput for the Sample Input\n\n0 0 0 0 0 0 0 0 0 0\n0 1 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 1 1 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 1 0\n0 0 0 0 0 0 0 0 0 0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1493, "cpu_time_ms": 260, "memory_kb": 46296}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s848723688", "group_id": "codeNet:p00138", "input_text": "import scala.io.StdIn.readLine\n\nobject Main {\n def getTop3() = {\n {\n for(i<-1 to 7) yield {\n val n = readLine.split(\" \")\n (n(0).toInt, n(1).toDouble)\n }\n }.toList.sortBy(_._2).take(3)\n }\n\n def main(args:Array[String]) = {\n val x1 = getTop3\n val x2 = getTop3\n val x3 = getTop3\n val r = List(x1(0),x1(1),x2(0),x2(1),x3(0),x3(1)) ++ List(x1(2),x2(2),x3(2)).sortBy(_._2).take(2)\n r.foreach(e =>println(e._1+\" \"+e._2))\n }\n}", "language": "Scala", "metadata": {"date": 1488111273, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00138.html", "problem_id": "p00138", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00138/input.txt", "sample_output_relpath": "derived/input_output/data/p00138/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00138/Scala/s848723688.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s848723688", "user_id": "u508732591"}, "prompt_components": {"gold_output": "5 22.88\n3 23.00\n13 21.99\n14 22.86\n24 21.89\n20 22.23\n17 22.51\n12 22.91\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main {\n def getTop3() = {\n {\n for(i<-1 to 7) yield {\n val n = readLine.split(\" \")\n (n(0).toInt, n(1).toDouble)\n }\n }.toList.sortBy(_._2).take(3)\n }\n\n def main(args:Array[String]) = {\n val x1 = getTop3\n val x2 = getTop3\n val x3 = getTop3\n val r = List(x1(0),x1(1),x2(0),x2(1),x3(0),x3(1)) ++ List(x1(2),x2(2),x3(2)).sortBy(_._2).take(2)\n r.foreach(e =>println(e._1+\" \"+e._2))\n }\n}", "problem_context": "陸上競技大会\n\n陸上競技大会 200M の準決勝 3 組のレースが行われました。それぞれの組に 8 名(計 24 名)の選手が出場します。各組上位 2 位までの選手と、各組の 3 位以下の全選手の中から上位 2 名の計 8 名が決勝に進出します。\n\n選手番号とタイムを入力とし、決勝進出者 8 名の番号とそのタイムを出力するプログラムを作成してください。\n\nInput\n\n入力は以下の形式で与えられます。\n\np1 t1\np2 t2\n:\np24 t24\n\n1 行目から 8 行目に1組目の選手番号 pi (整数、1 ≤ pi ≤ 10000) とタイム ti (1/100 まで計測した実数、1 ≤ ti ≤ 100)、9 行目から 16 行目に2組目の選手番号 pi とタイム ti、17 行目から 24 行目に3組目の選手番号 pi とタイム ti が与えられます。同じ選手番号の選手、同タイムの選手はいないものとします。\n\nOutput\n\n以下の順番で、決勝進出者の選手番号とタイムを空白区切りでそれぞれ1行に出力してください。\n\n1 組目の 1 位の選手\n\n1 組目の 2 位の選手\n\n2 組目の 1 位の選手\n\n2 組目の 2 位の選手\n\n3 組目の 1 位の選手\n\n3 組目の 2 位の選手\n\n各組で 3 位以下の選手の中でタイムが 1 位の選手\n\n各組で 3 位以下の選手の中でタイムが 2 位の選手\n\nSample Input\n\n18 25.46\n16 26.23\n3 23.00\n10 24.79\n5 22.88\n11 23.87\n19 23.90\n1 25.11\n23 23.88\n4 23.46\n7 24.12\n12 22.91\n13 21.99\n14 22.86\n21 23.12\n9 24.09\n17 22.51\n22 23.49\n6 23.02\n20 22.23\n24 21.89\n15 24.14\n8 23.77\n2 23.42\n\nOutput for the Sample Input\n\n5 22.88\n3 23.00\n13 21.99\n14 22.86\n24 21.89\n20 22.23\n17 22.51\n12 22.91", "sample_input": "18 25.46\n16 26.23\n3 23.00\n10 24.79\n5 22.88\n11 23.87\n19 23.90\n1 25.11\n23 23.88\n4 23.46\n7 24.12\n12 22.91\n13 21.99\n14 22.86\n21 23.12\n9 24.09\n17 22.51\n22 23.49\n6 23.02\n20 22.23\n24 21.89\n15 24.14\n8 23.77\n2 23.42\n"}, "reference_outputs": ["5 22.88\n3 23.00\n13 21.99\n14 22.86\n24 21.89\n20 22.23\n17 22.51\n12 22.91\n"], "source_document_id": "p00138", "source_text": "陸上競技大会\n\n陸上競技大会 200M の準決勝 3 組のレースが行われました。それぞれの組に 8 名(計 24 名)の選手が出場します。各組上位 2 位までの選手と、各組の 3 位以下の全選手の中から上位 2 名の計 8 名が決勝に進出します。\n\n選手番号とタイムを入力とし、決勝進出者 8 名の番号とそのタイムを出力するプログラムを作成してください。\n\nInput\n\n入力は以下の形式で与えられます。\n\np1 t1\np2 t2\n:\np24 t24\n\n1 行目から 8 行目に1組目の選手番号 pi (整数、1 ≤ pi ≤ 10000) とタイム ti (1/100 まで計測した実数、1 ≤ ti ≤ 100)、9 行目から 16 行目に2組目の選手番号 pi とタイム ti、17 行目から 24 行目に3組目の選手番号 pi とタイム ti が与えられます。同じ選手番号の選手、同タイムの選手はいないものとします。\n\nOutput\n\n以下の順番で、決勝進出者の選手番号とタイムを空白区切りでそれぞれ1行に出力してください。\n\n1 組目の 1 位の選手\n\n1 組目の 2 位の選手\n\n2 組目の 1 位の選手\n\n2 組目の 2 位の選手\n\n3 組目の 1 位の選手\n\n3 組目の 2 位の選手\n\n各組で 3 位以下の選手の中でタイムが 1 位の選手\n\n各組で 3 位以下の選手の中でタイムが 2 位の選手\n\nSample Input\n\n18 25.46\n16 26.23\n3 23.00\n10 24.79\n5 22.88\n11 23.87\n19 23.90\n1 25.11\n23 23.88\n4 23.46\n7 24.12\n12 22.91\n13 21.99\n14 22.86\n21 23.12\n9 24.09\n17 22.51\n22 23.49\n6 23.02\n20 22.23\n24 21.89\n15 24.14\n8 23.77\n2 23.42\n\nOutput for the Sample Input\n\n5 22.88\n3 23.00\n13 21.99\n14 22.86\n24 21.89\n20 22.23\n17 22.51\n12 22.91", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 467, "cpu_time_ms": 240, "memory_kb": 43688}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s912381960", "group_id": "codeNet:p00138", "input_text": "import scala.io.StdIn.readLine\n\nobject Main {\n def getTop3() = {\n {\n for(i<-1 to 8) yield {\n val n = readLine.split(\" \")\n (n(0).toInt, n(1).toDouble)\n }\n }.toList.sortBy(_._2)\n }\n\n def main(args:Array[String]) = {\n val x1 = getTop3\n val x2 = getTop3\n val x3 = getTop3\n val r = List(x1(0),x1(1),x2(0),x2(1),x3(0),x3(1))\n r.foreach {e => println(e._1+\" \"+\"%.2f\".format(e._2)) }\n val r2 = (x1.drop(2) ++ x2.drop(2) ++ x3.drop(2)).sortBy(_._2)\n println(r2(0)._1 + \" \" + \"%.2f\".format(r2(0)._2))\n println(r2(1)._1 + \" \" + \"%.2f\".format(r2(1)._2))\n }\n}", "language": "Scala", "metadata": {"date": 1488112613, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00138.html", "problem_id": "p00138", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00138/input.txt", "sample_output_relpath": "derived/input_output/data/p00138/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00138/Scala/s912381960.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s912381960", "user_id": "u508732591"}, "prompt_components": {"gold_output": "5 22.88\n3 23.00\n13 21.99\n14 22.86\n24 21.89\n20 22.23\n17 22.51\n12 22.91\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main {\n def getTop3() = {\n {\n for(i<-1 to 8) yield {\n val n = readLine.split(\" \")\n (n(0).toInt, n(1).toDouble)\n }\n }.toList.sortBy(_._2)\n }\n\n def main(args:Array[String]) = {\n val x1 = getTop3\n val x2 = getTop3\n val x3 = getTop3\n val r = List(x1(0),x1(1),x2(0),x2(1),x3(0),x3(1))\n r.foreach {e => println(e._1+\" \"+\"%.2f\".format(e._2)) }\n val r2 = (x1.drop(2) ++ x2.drop(2) ++ x3.drop(2)).sortBy(_._2)\n println(r2(0)._1 + \" \" + \"%.2f\".format(r2(0)._2))\n println(r2(1)._1 + \" \" + \"%.2f\".format(r2(1)._2))\n }\n}", "problem_context": "陸上競技大会\n\n陸上競技大会 200M の準決勝 3 組のレースが行われました。それぞれの組に 8 名(計 24 名)の選手が出場します。各組上位 2 位までの選手と、各組の 3 位以下の全選手の中から上位 2 名の計 8 名が決勝に進出します。\n\n選手番号とタイムを入力とし、決勝進出者 8 名の番号とそのタイムを出力するプログラムを作成してください。\n\nInput\n\n入力は以下の形式で与えられます。\n\np1 t1\np2 t2\n:\np24 t24\n\n1 行目から 8 行目に1組目の選手番号 pi (整数、1 ≤ pi ≤ 10000) とタイム ti (1/100 まで計測した実数、1 ≤ ti ≤ 100)、9 行目から 16 行目に2組目の選手番号 pi とタイム ti、17 行目から 24 行目に3組目の選手番号 pi とタイム ti が与えられます。同じ選手番号の選手、同タイムの選手はいないものとします。\n\nOutput\n\n以下の順番で、決勝進出者の選手番号とタイムを空白区切りでそれぞれ1行に出力してください。\n\n1 組目の 1 位の選手\n\n1 組目の 2 位の選手\n\n2 組目の 1 位の選手\n\n2 組目の 2 位の選手\n\n3 組目の 1 位の選手\n\n3 組目の 2 位の選手\n\n各組で 3 位以下の選手の中でタイムが 1 位の選手\n\n各組で 3 位以下の選手の中でタイムが 2 位の選手\n\nSample Input\n\n18 25.46\n16 26.23\n3 23.00\n10 24.79\n5 22.88\n11 23.87\n19 23.90\n1 25.11\n23 23.88\n4 23.46\n7 24.12\n12 22.91\n13 21.99\n14 22.86\n21 23.12\n9 24.09\n17 22.51\n22 23.49\n6 23.02\n20 22.23\n24 21.89\n15 24.14\n8 23.77\n2 23.42\n\nOutput for the Sample Input\n\n5 22.88\n3 23.00\n13 21.99\n14 22.86\n24 21.89\n20 22.23\n17 22.51\n12 22.91", "sample_input": "18 25.46\n16 26.23\n3 23.00\n10 24.79\n5 22.88\n11 23.87\n19 23.90\n1 25.11\n23 23.88\n4 23.46\n7 24.12\n12 22.91\n13 21.99\n14 22.86\n21 23.12\n9 24.09\n17 22.51\n22 23.49\n6 23.02\n20 22.23\n24 21.89\n15 24.14\n8 23.77\n2 23.42\n"}, "reference_outputs": ["5 22.88\n3 23.00\n13 21.99\n14 22.86\n24 21.89\n20 22.23\n17 22.51\n12 22.91\n"], "source_document_id": "p00138", "source_text": "陸上競技大会\n\n陸上競技大会 200M の準決勝 3 組のレースが行われました。それぞれの組に 8 名(計 24 名)の選手が出場します。各組上位 2 位までの選手と、各組の 3 位以下の全選手の中から上位 2 名の計 8 名が決勝に進出します。\n\n選手番号とタイムを入力とし、決勝進出者 8 名の番号とそのタイムを出力するプログラムを作成してください。\n\nInput\n\n入力は以下の形式で与えられます。\n\np1 t1\np2 t2\n:\np24 t24\n\n1 行目から 8 行目に1組目の選手番号 pi (整数、1 ≤ pi ≤ 10000) とタイム ti (1/100 まで計測した実数、1 ≤ ti ≤ 100)、9 行目から 16 行目に2組目の選手番号 pi とタイム ti、17 行目から 24 行目に3組目の選手番号 pi とタイム ti が与えられます。同じ選手番号の選手、同タイムの選手はいないものとします。\n\nOutput\n\n以下の順番で、決勝進出者の選手番号とタイムを空白区切りでそれぞれ1行に出力してください。\n\n1 組目の 1 位の選手\n\n1 組目の 2 位の選手\n\n2 組目の 1 位の選手\n\n2 組目の 2 位の選手\n\n3 組目の 1 位の選手\n\n3 組目の 2 位の選手\n\n各組で 3 位以下の選手の中でタイムが 1 位の選手\n\n各組で 3 位以下の選手の中でタイムが 2 位の選手\n\nSample Input\n\n18 25.46\n16 26.23\n3 23.00\n10 24.79\n5 22.88\n11 23.87\n19 23.90\n1 25.11\n23 23.88\n4 23.46\n7 24.12\n12 22.91\n13 21.99\n14 22.86\n21 23.12\n9 24.09\n17 22.51\n22 23.49\n6 23.02\n20 22.23\n24 21.89\n15 24.14\n8 23.77\n2 23.42\n\nOutput for the Sample Input\n\n5 22.88\n3 23.00\n13 21.99\n14 22.86\n24 21.89\n20 22.23\n17 22.51\n12 22.91", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 604, "cpu_time_ms": 230, "memory_kb": 44000}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s352547472", "group_id": "codeNet:p00148", "input_text": "import scala.io.Source.stdin\n\nobject Main extends App {\n stdin.getLines.foreach { s=>\n val n = (s.toInt-1) % 39 + 1\n printf(\"3C%02d\\n\",n)\n }\n}", "language": "Scala", "metadata": {"date": 1487599143, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00148.html", "problem_id": "p00148", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00148/input.txt", "sample_output_relpath": "derived/input_output/data/p00148/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00148/Scala/s352547472.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s352547472", "user_id": "u508732591"}, "prompt_components": {"gold_output": "3C11\n3C38\n3C39\n3C01\n", "input_to_evaluate": "import scala.io.Source.stdin\n\nobject Main extends App {\n stdin.getLines.foreach { s=>\n val n = (s.toInt-1) % 39 + 1\n printf(\"3C%02d\\n\",n)\n }\n}", "problem_context": "キャンディーとクラス旗\n\n3年C組では、平成19年11月10日の体育祭で使用する「クラス旗」を、将来のクラス会の時にも使うことにしました。そこで「クラス旗」を保管する生徒を決めるために、先生が先日差し入れてくれた大量のキャンディーを使って次のようなゲームを行うことにしました。\n\n各生徒は生徒番号の順に1個ずつキャンディーを取ります。\n\n一巡してもキャンディーが残っていたら、最初の生徒番号の人から順々にキャンディーを取り続けます。\n\n最後のキャンディーを取った人が「クラス旗」を保管する生徒になります。\n\n3年C組のクラスの人数は 39 人です。彼らの生徒番号は 3C01 から 3C39 です。例えば、キャンディーの数が 50 個の場合、クラス全員が1個目のキャンディーを取り終えると、キャンディーの残りは 11 個となります。それを再び生徒番号順に取ると、最後の 1 個は、3C11 の生徒が取ることとなります。すなわち 3C11 の生徒が「クラス旗」を保管する生徒となります。\n\nキャンディーの個数を入力とし、「クラス旗」を保管する生徒の生徒番号を出力するプログラムを作成してください。\n\nInput\n\n複数のテストケースが与えられます。各テストケースは以下の形式で与えられます。各テストケースとして、キャンディーの個数を表す整数 a (1 ≤ a ≤ 10000) が1行に与えられます。入力の最後(EOF)まで処理してください。\n\nデータセットの数は 20 を超えません。\n\nOutput\n\n各テストケースごとに、「クラス旗」を保管する生徒の生徒番号(半角英数字)を1行に出力してください。\n\nSample Input\n\n50\n5576\n5577\n5578\n\nOutput for the Sample Input\n\n3C11\n3C38\n3C39\n3C01", "sample_input": "50\n5576\n5577\n5578\n"}, "reference_outputs": ["3C11\n3C38\n3C39\n3C01\n"], "source_document_id": "p00148", "source_text": "キャンディーとクラス旗\n\n3年C組では、平成19年11月10日の体育祭で使用する「クラス旗」を、将来のクラス会の時にも使うことにしました。そこで「クラス旗」を保管する生徒を決めるために、先生が先日差し入れてくれた大量のキャンディーを使って次のようなゲームを行うことにしました。\n\n各生徒は生徒番号の順に1個ずつキャンディーを取ります。\n\n一巡してもキャンディーが残っていたら、最初の生徒番号の人から順々にキャンディーを取り続けます。\n\n最後のキャンディーを取った人が「クラス旗」を保管する生徒になります。\n\n3年C組のクラスの人数は 39 人です。彼らの生徒番号は 3C01 から 3C39 です。例えば、キャンディーの数が 50 個の場合、クラス全員が1個目のキャンディーを取り終えると、キャンディーの残りは 11 個となります。それを再び生徒番号順に取ると、最後の 1 個は、3C11 の生徒が取ることとなります。すなわち 3C11 の生徒が「クラス旗」を保管する生徒となります。\n\nキャンディーの個数を入力とし、「クラス旗」を保管する生徒の生徒番号を出力するプログラムを作成してください。\n\nInput\n\n複数のテストケースが与えられます。各テストケースは以下の形式で与えられます。各テストケースとして、キャンディーの個数を表す整数 a (1 ≤ a ≤ 10000) が1行に与えられます。入力の最後(EOF)まで処理してください。\n\nデータセットの数は 20 を超えません。\n\nOutput\n\n各テストケースごとに、「クラス旗」を保管する生徒の生徒番号(半角英数字)を1行に出力してください。\n\nSample Input\n\n50\n5576\n5577\n5578\n\nOutput for the Sample Input\n\n3C11\n3C38\n3C39\n3C01", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43928}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s182104669", "group_id": "codeNet:p00149", "input_text": "\nobject Main extends App {\n\n import scala.io.StdIn._\n\n val lines = io.Source.stdin.getLines().map{_.trim.split(' ').map(_.toDouble)}.toArray\n println(\n s\"${lines.count(_(0) >= 1.1)} ${lines.count(_(1) >= 1.1)}\"\n )\n println(\n s\"${lines.count(i ⇒ 1.1 > i(0) && i(0) >= 0.6)} ${lines.count(i ⇒ 1.1 > i(1) && i(1) >= 0.6)}\"\n )\n println(\n s\"${lines.count(i ⇒ 0.6 > i(0) && i(0) >= 0.2)} ${lines.count(i ⇒ 0.6 > i(1) && i(1) >= 0.2)}\"\n )\n println(\n s\"${lines.count(i ⇒ 0.2 > i(0))} ${lines.count(i ⇒ 0.2 > i(1))}\"\n )\n\n implicit class Extention[T](value :T){\n @inline\n def let[A](@inline func: T ⇒ A): A = func(value)\n }\n}\n", "language": "Scala", "metadata": {"date": 1547257259, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00149.html", "problem_id": "p00149", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00149/input.txt", "sample_output_relpath": "derived/input_output/data/p00149/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00149/Scala/s182104669.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s182104669", "user_id": "u514597327"}, "prompt_components": {"gold_output": "2 3\n2 1\n0 0\n0 0\n", "input_to_evaluate": "\nobject Main extends App {\n\n import scala.io.StdIn._\n\n val lines = io.Source.stdin.getLines().map{_.trim.split(' ').map(_.toDouble)}.toArray\n println(\n s\"${lines.count(_(0) >= 1.1)} ${lines.count(_(1) >= 1.1)}\"\n )\n println(\n s\"${lines.count(i ⇒ 1.1 > i(0) && i(0) >= 0.6)} ${lines.count(i ⇒ 1.1 > i(1) && i(1) >= 0.6)}\"\n )\n println(\n s\"${lines.count(i ⇒ 0.6 > i(0) && i(0) >= 0.2)} ${lines.count(i ⇒ 0.6 > i(1) && i(1) >= 0.2)}\"\n )\n println(\n s\"${lines.count(i ⇒ 0.2 > i(0))} ${lines.count(i ⇒ 0.2 > i(1))}\"\n )\n\n implicit class Extention[T](value :T){\n @inline\n def let[A](@inline func: T ⇒ A): A = func(value)\n }\n}\n", "problem_context": "視力検査\n\n視力検査の検査結果データを入力とし、下記の視力判定表に基づいて各判定に当てはまる人数を、左右の視力別に出力するプログラムを作成してください。\n\n判定\n\n視力\n\nA\n\n1.1 以上\n\nB\n\n0.6 以上 1.1 未満\n\nC\n\n0.2 以上 0.6 未満\n\nD\n\n0.2 未満\n\nInput\n\n入力は以下の形式で与えられます。\n\nl1 r1\nl2 r2\nl3 r3\n:\n:\n\ni 行目に i 人目の左の視力を表す実数 li と右の視力を表す実数 ri が空白区切りで与えられます。ただし、視力は 0.1 以上 2.0 以下で、 0.1 刻みで与えられます。\n\n入力の行数は 40 を超えません。\n\nOutput\n\n以下の形式で、判定表を出力してください。\n\n1行目 左の視力がAの人数 右の視力がAの人数(空白区切り)\n\n2行目 左の視力がBの人数 右の視力がBの人数(空白区切り)\n\n3行目 左の視力がCの人数 右の視力がCの人数(空白区切り)\n\n4行目 左の視力がDの人数 右の視力がDの人数(空白区切り)\n\nSample Input\n\n1.0 1.2\n0.8 1.5\n1.2 0.7\n2.0 2.0\n\nOutput for the Sample Input\n\n2 3\n2 1\n0 0\n0 0", "sample_input": "1.0 1.2\n0.8 1.5\n1.2 0.7\n2.0 2.0\n"}, "reference_outputs": ["2 3\n2 1\n0 0\n0 0\n"], "source_document_id": "p00149", "source_text": "視力検査\n\n視力検査の検査結果データを入力とし、下記の視力判定表に基づいて各判定に当てはまる人数を、左右の視力別に出力するプログラムを作成してください。\n\n判定\n\n視力\n\nA\n\n1.1 以上\n\nB\n\n0.6 以上 1.1 未満\n\nC\n\n0.2 以上 0.6 未満\n\nD\n\n0.2 未満\n\nInput\n\n入力は以下の形式で与えられます。\n\nl1 r1\nl2 r2\nl3 r3\n:\n:\n\ni 行目に i 人目の左の視力を表す実数 li と右の視力を表す実数 ri が空白区切りで与えられます。ただし、視力は 0.1 以上 2.0 以下で、 0.1 刻みで与えられます。\n\n入力の行数は 40 を超えません。\n\nOutput\n\n以下の形式で、判定表を出力してください。\n\n1行目 左の視力がAの人数 右の視力がAの人数(空白区切り)\n\n2行目 左の視力がBの人数 右の視力がBの人数(空白区切り)\n\n3行目 左の視力がCの人数 右の視力がCの人数(空白区切り)\n\n4行目 左の視力がDの人数 右の視力がDの人数(空白区切り)\n\nSample Input\n\n1.0 1.2\n0.8 1.5\n1.2 0.7\n2.0 2.0\n\nOutput for the Sample Input\n\n2 3\n2 1\n0 0\n0 0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43908}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s092498187", "group_id": "codeNet:p00160", "input_text": "import scala.io.StdIn.{readLine,readInt}\n\nobject Main {\n\n def getFee(x:Int,y:Int,h:Int,w:Int) = {\n val l = x+y+h\n if(l<=60 && w <= 2) 600\n else if(l<=80 && w<=5) 800\n else if(l<=100 && w<=10) 1000\n else if(l<=120 && w<=15) 1200\n else if(l<=140 && w<=20) 1400\n else if(l<=160 && w<=25) 1600\n else 0\n }\n\n def main(args:Array[String]) = {\n var n = 0\n while({n=readInt;n} != 0) {\n val sum = (1 to n).map { i =>\n val m = readLine.split(\" \").map(_.toInt)\n getFee(m(0),m(1),m(2),m(3))\n }.sum\n println(sum)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1488384003, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00160.html", "problem_id": "p00160", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00160/input.txt", "sample_output_relpath": "derived/input_output/data/p00160/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00160/Scala/s092498187.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s092498187", "user_id": "u508732591"}, "prompt_components": {"gold_output": "800\n3800\n", "input_to_evaluate": "import scala.io.StdIn.{readLine,readInt}\n\nobject Main {\n\n def getFee(x:Int,y:Int,h:Int,w:Int) = {\n val l = x+y+h\n if(l<=60 && w <= 2) 600\n else if(l<=80 && w<=5) 800\n else if(l<=100 && w<=10) 1000\n else if(l<=120 && w<=15) 1200\n else if(l<=140 && w<=20) 1400\n else if(l<=160 && w<=25) 1600\n else 0\n }\n\n def main(args:Array[String]) = {\n var n = 0\n while({n=readInt;n} != 0) {\n val sum = (1 to n).map { i =>\n val m = readLine.split(\" \").map(_.toInt)\n getFee(m(0),m(1),m(2),m(3))\n }.sum\n println(sum)\n }\n }\n}", "problem_context": "宅配料金\n\nある宅配業者の宅配料金は大きさと重量で下表のように料金が設定されています。\n\nA サイズ\n\nB サイズ\n\nC サイズ\n\nD サイズ\n\nE サイズ\n\nF サイズ\n\n大きさ\n\n60cm以内\n\n80cm以内\n\n100cm以内\n\n120cm以内\n\n140cm以内\n\n160cm以内\n\n重さ\n\n2kg以内\n\n5kg以内\n\n10kg以内\n\n15kg以内\n\n20kg以内\n\n25kg以内\n\n料金\n\n600円\n\n800円\n\n1000円\n\n1200円\n\n1400円\n\n1600円\n\n大きさは三辺(縦、横、高さ)の和です。例えば大きさが120cmで、重さが15kg以内の荷物はDサイズ(1,200円)となります。大きさが120cm以内でも、重さが15kgを超え、20kg以内ならばEサイズとなります。\n\n1日に持ち込まれた荷物の情報を入力とし、料金の総計を出力するプログラムを作成してください。なお、Fサイズを超えた荷物は対象外とし料金の総計には含みません。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。\n各データセットは以下の形式で与えられます。\n\nn\nx1 y1 h1 w1\nx2 y2 h2 w2\n:\nxn yn hn wn\n\n1行目に荷物の個数n (1 ≤ n ≤ 10000)、続くn 行に i 番目の荷物の縦の長さ xi、横の長さ yi、高さ hi、重さ wi (1 ≤ xi, yi, hi, wi ≤ 200) が空白区切りで1行に与えられます。\n\nデータセットの数は 20 を超えません。\n\nOutput\n\nデータセットごとに荷物の料金の総計を1行に出力します。\n\nSample Input\n\n2\n50 25 5 5\n80 60 10 30\n3\n10 15 25 24\n5 8 12 5\n30 30 30 18\n0\n\nOutput for the Sample Input\n\n800\n3800", "sample_input": "2\n50 25 5 5\n80 60 10 30\n3\n10 15 25 24\n5 8 12 5\n30 30 30 18\n0\n"}, "reference_outputs": ["800\n3800\n"], "source_document_id": "p00160", "source_text": "宅配料金\n\nある宅配業者の宅配料金は大きさと重量で下表のように料金が設定されています。\n\nA サイズ\n\nB サイズ\n\nC サイズ\n\nD サイズ\n\nE サイズ\n\nF サイズ\n\n大きさ\n\n60cm以内\n\n80cm以内\n\n100cm以内\n\n120cm以内\n\n140cm以内\n\n160cm以内\n\n重さ\n\n2kg以内\n\n5kg以内\n\n10kg以内\n\n15kg以内\n\n20kg以内\n\n25kg以内\n\n料金\n\n600円\n\n800円\n\n1000円\n\n1200円\n\n1400円\n\n1600円\n\n大きさは三辺(縦、横、高さ)の和です。例えば大きさが120cmで、重さが15kg以内の荷物はDサイズ(1,200円)となります。大きさが120cm以内でも、重さが15kgを超え、20kg以内ならばEサイズとなります。\n\n1日に持ち込まれた荷物の情報を入力とし、料金の総計を出力するプログラムを作成してください。なお、Fサイズを超えた荷物は対象外とし料金の総計には含みません。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。\n各データセットは以下の形式で与えられます。\n\nn\nx1 y1 h1 w1\nx2 y2 h2 w2\n:\nxn yn hn wn\n\n1行目に荷物の個数n (1 ≤ n ≤ 10000)、続くn 行に i 番目の荷物の縦の長さ xi、横の長さ yi、高さ hi、重さ wi (1 ≤ xi, yi, hi, wi ≤ 200) が空白区切りで1行に与えられます。\n\nデータセットの数は 20 を超えません。\n\nOutput\n\nデータセットごとに荷物の料金の総計を1行に出力します。\n\nSample Input\n\n2\n50 25 5 5\n80 60 10 30\n3\n10 15 25 24\n5 8 12 5\n30 30 30 18\n0\n\nOutput for the Sample Input\n\n800\n3800", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 572, "cpu_time_ms": 340, "memory_kb": 57036}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s792990637", "group_id": "codeNet:p00162", "input_text": "import scala.io.StdIn.readLine\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n def isHamming(num:Int):Boolean = {\n var n = num\n while(n%2==0) n = n/2\n while(n%3==0) n = n/3\n while(n%5==0) n = n/5\n\n if(n==1) true\n else false\n }\n\n def main(args:Array[String]) = {\n var s = \"0\"\n val b = new ArrayBuffer[String]\n while({s=readLine.trim;s}!=\"0\") {\n val n = s.split(\" \").map(_.toInt)\n b+=(n(0) to n(1)).count(i=>isHamming(i)).toString\n }\n println(b.mkString(\"\\n\"))\n }\n}", "language": "Scala", "metadata": {"date": 1488905666, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00162.html", "problem_id": "p00162", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00162/input.txt", "sample_output_relpath": "derived/input_output/data/p00162/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00162/Scala/s792990637.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s792990637", "user_id": "u508732591"}, "prompt_components": {"gold_output": "5\n17\n31\n", "input_to_evaluate": "import scala.io.StdIn.readLine\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n def isHamming(num:Int):Boolean = {\n var n = num\n while(n%2==0) n = n/2\n while(n%3==0) n = n/3\n while(n%5==0) n = n/5\n\n if(n==1) true\n else false\n }\n\n def main(args:Array[String]) = {\n var s = \"0\"\n val b = new ArrayBuffer[String]\n while({s=readLine.trim;s}!=\"0\") {\n val n = s.split(\" \").map(_.toInt)\n b+=(n(0) to n(1)).count(i=>isHamming(i)).toString\n }\n println(b.mkString(\"\\n\"))\n }\n}", "problem_context": "ハミング数\n\n1 に 2, 3, 5 を何回か (0 回以上) かけ算して得られる数をハミング数 (Hamming numbers) と呼びます。例えば、\n\n1\n\n1 × 2 × 2 = 4\n\n1 × 2 × 2 × 3 × 5 × 5 = 300\n\nなどはハミング数ですが、11, 13, 14 などはハミング数ではありません。\n\nハミング数はどれも 60 のべき乗を割り切る(例えば、54 は 603 = 21600 を割り切る) ので、時刻など 60 進法の計算には都合の良い数として昔から知られていました。また、楽器の調律に用いる音階の一つである純正律では、音の周波数の比が 24, 27, 30, 32, 36, 40, 45, 48 というハミング数からなる数列になります。\n\n整数 m、n を入力とし、m 以上 n 以下のハミング数の個数を出力するプログラムを作成してください。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。\n\n各データセットとして、2つの整数 m と n (1 ≤ m, n ≤ 1000000, m ≤ n) が空白区切りで1行に与えられます。\n\nデータセットの数は 20 を超えません。\n\nOutput\n\nデータセットごとに m 以上 n 以下のハミング数の個数を1行に出力します。\n\nSample Input\n\n3 8\n1 27\n1 86\n0\n\nOutput for the Sample Input\n\n5\n17\n31", "sample_input": "3 8\n1 27\n1 86\n0\n"}, "reference_outputs": ["5\n17\n31\n"], "source_document_id": "p00162", "source_text": "ハミング数\n\n1 に 2, 3, 5 を何回か (0 回以上) かけ算して得られる数をハミング数 (Hamming numbers) と呼びます。例えば、\n\n1\n\n1 × 2 × 2 = 4\n\n1 × 2 × 2 × 3 × 5 × 5 = 300\n\nなどはハミング数ですが、11, 13, 14 などはハミング数ではありません。\n\nハミング数はどれも 60 のべき乗を割り切る(例えば、54 は 603 = 21600 を割り切る) ので、時刻など 60 進法の計算には都合の良い数として昔から知られていました。また、楽器の調律に用いる音階の一つである純正律では、音の周波数の比が 24, 27, 30, 32, 36, 40, 45, 48 というハミング数からなる数列になります。\n\n整数 m、n を入力とし、m 以上 n 以下のハミング数の個数を出力するプログラムを作成してください。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。\n\n各データセットとして、2つの整数 m と n (1 ≤ m, n ≤ 1000000, m ≤ n) が空白区切りで1行に与えられます。\n\nデータセットの数は 20 を超えません。\n\nOutput\n\nデータセットごとに m 以上 n 以下のハミング数の個数を1行に出力します。\n\nSample Input\n\n3 8\n1 27\n1 86\n0\n\nOutput for the Sample Input\n\n5\n17\n31", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 522, "cpu_time_ms": 310, "memory_kb": 91496}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s247482352", "group_id": "codeNet:p00179", "input_text": "import scala.io.Source.stdin\nimport scala.collection.mutable.Queue\nimport scala.collection.mutable.{ Set => mSet }\n\nobject Main {\n val rgb = \"rgb\".toCharArray\n\n def main(argv: Array[String]): Unit = {\n stdin.getLines.foreach { l =>\n if (l == \"0\") sys.exit()\n\n val q = new Queue[(String, Int)]()\n q.enqueue((l, 0))\n val rgbSet = mSet(Array.fill(l.length)(\"r\").mkString,\n Array.fill(l.length)(\"g\").mkString,\n Array.fill(l.length)(\"b\").mkString)\n\n val done = mSet[String]()\n\n var continue = true\n\n if (rgbSet.contains(l)) {\n println(0)\n continue = false\n }\n while (continue && q.length > 0) {\n val (buf, time) = q.dequeue\n val pairs = (buf.drop(1) zip buf.take(buf.length-1)).map{ case (a, b) => Array(a, b) }.zipWithIndex\n\n pairs.foreach { case (arr, i) =>\n if (arr(0) != arr(1)) {\n val res = buf.take(i) + convert(arr).mkString + buf.drop(i + 2)\n // 終了判定\n if (rgbSet.contains(res) && continue) {\n println(time+1)\n continue = false\n }\n if (!done.contains(res)) {\n q.enqueue(res -> (time+1))\n done += res\n }\n }\n }\n\n if (continue && q.length == 0) {\n println(\"NA\")\n }\n }\n }\n }\n\n def convert(st: Array[Char]): Array[Char] = {\n val c = rgb.filterNot(c => st.contains(c))(0)\n Array(c, c)\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1521114823, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00179.html", "problem_id": "p00179", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00179/input.txt", "sample_output_relpath": "derived/input_output/data/p00179/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00179/Scala/s247482352.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s247482352", "user_id": "u921825999"}, "prompt_components": {"gold_output": "5\n7\n1\n6\nNA\n8\n0\n4\n", "input_to_evaluate": "import scala.io.Source.stdin\nimport scala.collection.mutable.Queue\nimport scala.collection.mutable.{ Set => mSet }\n\nobject Main {\n val rgb = \"rgb\".toCharArray\n\n def main(argv: Array[String]): Unit = {\n stdin.getLines.foreach { l =>\n if (l == \"0\") sys.exit()\n\n val q = new Queue[(String, Int)]()\n q.enqueue((l, 0))\n val rgbSet = mSet(Array.fill(l.length)(\"r\").mkString,\n Array.fill(l.length)(\"g\").mkString,\n Array.fill(l.length)(\"b\").mkString)\n\n val done = mSet[String]()\n\n var continue = true\n\n if (rgbSet.contains(l)) {\n println(0)\n continue = false\n }\n while (continue && q.length > 0) {\n val (buf, time) = q.dequeue\n val pairs = (buf.drop(1) zip buf.take(buf.length-1)).map{ case (a, b) => Array(a, b) }.zipWithIndex\n\n pairs.foreach { case (arr, i) =>\n if (arr(0) != arr(1)) {\n val res = buf.take(i) + convert(arr).mkString + buf.drop(i + 2)\n // 終了判定\n if (rgbSet.contains(res) && continue) {\n println(time+1)\n continue = false\n }\n if (!done.contains(res)) {\n q.enqueue(res -> (time+1))\n done += res\n }\n }\n }\n\n if (continue && q.length == 0) {\n println(\"NA\")\n }\n }\n }\n }\n\n def convert(st: Array[Char]): Array[Char] = {\n val c = rgb.filterNot(c => st.contains(c))(0)\n Array(c, c)\n }\n}\n\n", "problem_context": "ふしぎな虫\n\n会津生物学研究所のA博士は、とある南の島でふしぎな虫を発見しました。形は芋虫のように細長いのですが、ひとつの体節が玉のような形をしているので、糸でつないだビーズ玉のように見えます。ふしぎなのは体の色に様々なバリエーションがあることと、なかには時間がたつにつれて体の色が変っていく虫がいることでした。どの虫の体節の色も赤か緑か青のどれかに限られるようですが、1 秒ごとに体節の色が変わっていき、最後にはすべての体節が同じ色になって落ち着く場合もあれば、いつまで待ってもずっと色が変わりつづける場合もあるようでした。\n\n調べていくうちに、ふだんはすべての体節が同じ色をしているのですが、何かに驚いたりして興奮した後は体節の色が勝手に変わってしまうことがわかりました。一度体節の色が変わってしまうと、ふたたびすべての体節が同じ色になるまではずっと色が変わり続けることがわかりました。\n\nA博士はこの虫を何匹も捕まえて興奮させてみては、色が変わる様子を興味深く観察していましたが、やがて色が変化している最中の色の変わり方には次のような規則性があることに気がつきました。\n\n色が変わるのは、隣り合っている色違いの 2つの体節のペア 1組だけが変わり、他の体節の色は変わらない。ただし、そのようなペアが複数あるときに、どのペアの色が変わるかはあらかじめ予測できない。\n\nそのようなペアは、2つの体節の色のどちらでもない色に同時に変わる(たとえば、緑と赤の体節が隣り合っているときは、それらが同時に青に変わる)。\n\n虫の色の変化を、2秒後まですべて書いたものが上の図です。図の上段のような色をした虫がいるとします。このとき、隣り合った色違いの体節のペアは 3組あるので、1秒後には中段に並べて描いた 3通りの色のどれかに変わります。1秒後に中段左側の 2つのように変わったときには、2秒後にすべての体節が緑色になることができます(図の下段の左側から 2番目)。 それに対して、1秒後に中段の1番右のように変わったときには、2秒後にすべての体節が同じ色に変わることはありません。\n\n博士は、目の前にいる虫の体節がすべて同じ色になる可能性があるのか、あるとしたらそうなるのは最短で何秒後なのかを予測することにしました。\n\n目の前にいる虫の体節の色の並びを入力とし、その虫の体節がすべて同じ色になるのに要する最短の時間を秒単位で出力するプログラムを作成してください。ただし、同じ色になる可能性がないときは「NA(半角英大文字)」と出力してください。また、虫の体節の色の並びは2 以上 10 以下のr(赤)、g(緑)、b(青)からなる文字列で表されます。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されま\nす。各データセットとして、 虫の体節の情報を表す1つの文字列が1行に与えられます。\n\nデータセットの数は 100 を超えません。\n\nOutput\n\nデータセット毎に、すべての体節の色が同じになるまでに要する最小時間 (秒単位の整数) または NA を1行に出力します。\n\nSample Input\n\nrbgrg\nrbbgbbr\nbgr\nbgrbrgbr\nbggrgbgrr\ngbrggrbggr\nrrrrr\nbgbr\n0\n\nOutput for the Sample Input\n\n5\n7\n1\n6\nNA\n8\n0\n4", "sample_input": "rbgrg\nrbbgbbr\nbgr\nbgrbrgbr\nbggrgbgrr\ngbrggrbggr\nrrrrr\nbgbr\n0\n"}, "reference_outputs": ["5\n7\n1\n6\nNA\n8\n0\n4\n"], "source_document_id": "p00179", "source_text": "ふしぎな虫\n\n会津生物学研究所のA博士は、とある南の島でふしぎな虫を発見しました。形は芋虫のように細長いのですが、ひとつの体節が玉のような形をしているので、糸でつないだビーズ玉のように見えます。ふしぎなのは体の色に様々なバリエーションがあることと、なかには時間がたつにつれて体の色が変っていく虫がいることでした。どの虫の体節の色も赤か緑か青のどれかに限られるようですが、1 秒ごとに体節の色が変わっていき、最後にはすべての体節が同じ色になって落ち着く場合もあれば、いつまで待ってもずっと色が変わりつづける場合もあるようでした。\n\n調べていくうちに、ふだんはすべての体節が同じ色をしているのですが、何かに驚いたりして興奮した後は体節の色が勝手に変わってしまうことがわかりました。一度体節の色が変わってしまうと、ふたたびすべての体節が同じ色になるまではずっと色が変わり続けることがわかりました。\n\nA博士はこの虫を何匹も捕まえて興奮させてみては、色が変わる様子を興味深く観察していましたが、やがて色が変化している最中の色の変わり方には次のような規則性があることに気がつきました。\n\n色が変わるのは、隣り合っている色違いの 2つの体節のペア 1組だけが変わり、他の体節の色は変わらない。ただし、そのようなペアが複数あるときに、どのペアの色が変わるかはあらかじめ予測できない。\n\nそのようなペアは、2つの体節の色のどちらでもない色に同時に変わる(たとえば、緑と赤の体節が隣り合っているときは、それらが同時に青に変わる)。\n\n虫の色の変化を、2秒後まですべて書いたものが上の図です。図の上段のような色をした虫がいるとします。このとき、隣り合った色違いの体節のペアは 3組あるので、1秒後には中段に並べて描いた 3通りの色のどれかに変わります。1秒後に中段左側の 2つのように変わったときには、2秒後にすべての体節が緑色になることができます(図の下段の左側から 2番目)。 それに対して、1秒後に中段の1番右のように変わったときには、2秒後にすべての体節が同じ色に変わることはありません。\n\n博士は、目の前にいる虫の体節がすべて同じ色になる可能性があるのか、あるとしたらそうなるのは最短で何秒後なのかを予測することにしました。\n\n目の前にいる虫の体節の色の並びを入力とし、その虫の体節がすべて同じ色になるのに要する最短の時間を秒単位で出力するプログラムを作成してください。ただし、同じ色になる可能性がないときは「NA(半角英大文字)」と出力してください。また、虫の体節の色の並びは2 以上 10 以下のr(赤)、g(緑)、b(青)からなる文字列で表されます。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されま\nす。各データセットとして、 虫の体節の情報を表す1つの文字列が1行に与えられます。\n\nデータセットの数は 100 を超えません。\n\nOutput\n\nデータセット毎に、すべての体節の色が同じになるまでに要する最小時間 (秒単位の整数) または NA を1行に出力します。\n\nSample Input\n\nrbgrg\nrbbgbbr\nbgr\nbgrbrgbr\nbggrgbgrr\ngbrggrbggr\nrrrrr\nbgbr\n0\n\nOutput for the Sample Input\n\n5\n7\n1\n6\nNA\n8\n0\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1477, "cpu_time_ms": 1540, "memory_kb": 457308}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s133370416", "group_id": "codeNet:p00217", "input_text": "import scala.math._\nimport scala.collection.mutable.ListBuffer\n\nobject Main {\n val sc = new java.util.Scanner(System.in)\n def main(args: Array[String]) {\n while(true) {\n val n = sc.nextInt()\n if(n == 0) return\n\n val l = new Array[(Int,Int)](n)\n for(i <- 0 until n) {\n val p, d1, d2 = sc.nextInt()\n l(i) = (d1+d2, p)\n }\n val ans = l.sorted.last\n println(ans._2.toString + \" \" + ans._1.toString)\n }\n\n }\n}", "language": "Scala", "metadata": {"date": 1455210837, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00217.html", "problem_id": "p00217", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00217/input.txt", "sample_output_relpath": "derived/input_output/data/p00217/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00217/Scala/s133370416.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Memory Limit Exceeded", "submission_id": "s133370416", "user_id": "u158037864"}, "prompt_components": {"gold_output": "5000 5633\n345 7396\n", "input_to_evaluate": "import scala.math._\nimport scala.collection.mutable.ListBuffer\n\nobject Main {\n val sc = new java.util.Scanner(System.in)\n def main(args: Array[String]) {\n while(true) {\n val n = sc.nextInt()\n if(n == 0) return\n\n val l = new Array[(Int,Int)](n)\n for(i <- 0 until n) {\n val p, d1, d2 = sc.nextInt()\n l(i) = (d1+d2, p)\n }\n val ans = l.sorted.last\n println(ans._2.toString + \" \" + ans._1.toString)\n }\n\n }\n}", "problem_context": "ウォーキング\n\n会津リバーサイドホスピタルでは、リハビリと健康増進のため、入院患者が一日二回のウォーキングを行っています。元気に退院するために、ウォーキングで体力を回復しようと頑張る人が日に日に増えきたことから、院長が「一日で一番長い距離を歩いた人にプレゼントをあげよう!」という企画を立ち上げました。\n\n患者の数 n (1 ≤ n ≤ 10000)、それぞれの患者の番号 pi (1 ≤ pi ≤ 10000)、一回目に歩いた距離 d1i、二回目に歩いた距離 d2i (0 ≤ d1i, d2i ≤ 5000) を入力とし、歩いた距離の合計が最も長い患者の番号とその距離を出力するプログラムを作成してください。ただし、一日に歩いた距離が同じ患者はいないものとします。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。\n各データセットは以下の形式で与えられます。\n\nn\np1 d11 d21\np2 d12 d22\n:\npn d1n d2n\n\n入力はすべて整数で与えられます。データセットの数は50 を超えません。\n\nOutput\n\n入力データセットごとに、最も長い合計距離を歩いた患者の番号とその歩いた距離を1行に出力します。\n\nSample Input\n\n5\n263 2345 2504\n1 3210 1985\n5000 1501 4132\n10000 503 3107\n51 1758 2690\n3\n345 5000 2396\n7 3910 1590\n6789 2525 3616\n0\n\nOutput for the Sample Input\n\n5000 5633\n345 7396", "sample_input": "5\n263 2345 2504\n1 3210 1985\n5000 1501 4132\n10000 503 3107\n51 1758 2690\n3\n345 5000 2396\n7 3910 1590\n6789 2525 3616\n0\n"}, "reference_outputs": ["5000 5633\n345 7396\n"], "source_document_id": "p00217", "source_text": "ウォーキング\n\n会津リバーサイドホスピタルでは、リハビリと健康増進のため、入院患者が一日二回のウォーキングを行っています。元気に退院するために、ウォーキングで体力を回復しようと頑張る人が日に日に増えきたことから、院長が「一日で一番長い距離を歩いた人にプレゼントをあげよう!」という企画を立ち上げました。\n\n患者の数 n (1 ≤ n ≤ 10000)、それぞれの患者の番号 pi (1 ≤ pi ≤ 10000)、一回目に歩いた距離 d1i、二回目に歩いた距離 d2i (0 ≤ d1i, d2i ≤ 5000) を入力とし、歩いた距離の合計が最も長い患者の番号とその距離を出力するプログラムを作成してください。ただし、一日に歩いた距離が同じ患者はいないものとします。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。\n各データセットは以下の形式で与えられます。\n\nn\np1 d11 d21\np2 d12 d22\n:\npn d1n d2n\n\n入力はすべて整数で与えられます。データセットの数は50 を超えません。\n\nOutput\n\n入力データセットごとに、最も長い合計距離を歩いた患者の番号とその歩いた距離を1行に出力します。\n\nSample Input\n\n5\n263 2345 2504\n1 3210 1985\n5000 1501 4132\n10000 503 3107\n51 1758 2690\n3\n345 5000 2396\n7 3910 1590\n6789 2525 3616\n0\n\nOutput for the Sample Input\n\n5000 5633\n345 7396", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1060, "memory_kb": 445340}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s921957866", "group_id": "codeNet:p00217", "input_text": "import java.util.Scanner\n\nimport scala.collection.Searching._\nimport scala.annotation.tailrec\nimport scala.collection.immutable.{NumericRange, Queue}\nimport scala.collection.mutable\nimport scala.io.StdIn.readLine\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(new Node(None, 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n @tailrec\n private def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) => root(p)\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val N = sc.nextInt\n if (N != 0) {\n val ans = Array.fill(N)((sc.nextInt, sc.nextInt + sc.nextInt)).maxBy(a => a._2)\n println(ans._1 + \" \" + ans._2)\n solve(sc)\n }\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n", "language": "Scala", "metadata": {"date": 1521676779, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00217.html", "problem_id": "p00217", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00217/input.txt", "sample_output_relpath": "derived/input_output/data/p00217/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00217/Scala/s921957866.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s921957866", "user_id": "u018134297"}, "prompt_components": {"gold_output": "5000 5633\n345 7396\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.collection.Searching._\nimport scala.annotation.tailrec\nimport scala.collection.immutable.{NumericRange, Queue}\nimport scala.collection.mutable\nimport scala.io.StdIn.readLine\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(new Node(None, 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n @tailrec\n private def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) => root(p)\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val N = sc.nextInt\n if (N != 0) {\n val ans = Array.fill(N)((sc.nextInt, sc.nextInt + sc.nextInt)).maxBy(a => a._2)\n println(ans._1 + \" \" + ans._2)\n solve(sc)\n }\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n", "problem_context": "ウォーキング\n\n会津リバーサイドホスピタルでは、リハビリと健康増進のため、入院患者が一日二回のウォーキングを行っています。元気に退院するために、ウォーキングで体力を回復しようと頑張る人が日に日に増えきたことから、院長が「一日で一番長い距離を歩いた人にプレゼントをあげよう!」という企画を立ち上げました。\n\n患者の数 n (1 ≤ n ≤ 10000)、それぞれの患者の番号 pi (1 ≤ pi ≤ 10000)、一回目に歩いた距離 d1i、二回目に歩いた距離 d2i (0 ≤ d1i, d2i ≤ 5000) を入力とし、歩いた距離の合計が最も長い患者の番号とその距離を出力するプログラムを作成してください。ただし、一日に歩いた距離が同じ患者はいないものとします。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。\n各データセットは以下の形式で与えられます。\n\nn\np1 d11 d21\np2 d12 d22\n:\npn d1n d2n\n\n入力はすべて整数で与えられます。データセットの数は50 を超えません。\n\nOutput\n\n入力データセットごとに、最も長い合計距離を歩いた患者の番号とその歩いた距離を1行に出力します。\n\nSample Input\n\n5\n263 2345 2504\n1 3210 1985\n5000 1501 4132\n10000 503 3107\n51 1758 2690\n3\n345 5000 2396\n7 3910 1590\n6789 2525 3616\n0\n\nOutput for the Sample Input\n\n5000 5633\n345 7396", "sample_input": "5\n263 2345 2504\n1 3210 1985\n5000 1501 4132\n10000 503 3107\n51 1758 2690\n3\n345 5000 2396\n7 3910 1590\n6789 2525 3616\n0\n"}, "reference_outputs": ["5000 5633\n345 7396\n"], "source_document_id": "p00217", "source_text": "ウォーキング\n\n会津リバーサイドホスピタルでは、リハビリと健康増進のため、入院患者が一日二回のウォーキングを行っています。元気に退院するために、ウォーキングで体力を回復しようと頑張る人が日に日に増えきたことから、院長が「一日で一番長い距離を歩いた人にプレゼントをあげよう!」という企画を立ち上げました。\n\n患者の数 n (1 ≤ n ≤ 10000)、それぞれの患者の番号 pi (1 ≤ pi ≤ 10000)、一回目に歩いた距離 d1i、二回目に歩いた距離 d2i (0 ≤ d1i, d2i ≤ 5000) を入力とし、歩いた距離の合計が最も長い患者の番号とその距離を出力するプログラムを作成してください。ただし、一日に歩いた距離が同じ患者はいないものとします。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。\n各データセットは以下の形式で与えられます。\n\nn\np1 d11 d21\np2 d12 d22\n:\npn d1n d2n\n\n入力はすべて整数で与えられます。データセットの数は50 を超えません。\n\nOutput\n\n入力データセットごとに、最も長い合計距離を歩いた患者の番号とその歩いた距離を1行に出力します。\n\nSample Input\n\n5\n263 2345 2504\n1 3210 1985\n5000 1501 4132\n10000 503 3107\n51 1758 2690\n3\n345 5000 2396\n7 3910 1590\n6789 2525 3616\n0\n\nOutput for the Sample Input\n\n5000 5633\n345 7396", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1489, "cpu_time_ms": 830, "memory_kb": 440820}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s981404589", "group_id": "codeNet:p00219", "input_text": "import java.util.Scanner\n\nimport scala.collection.Searching._\nimport scala.annotation.tailrec\nimport scala.collection.immutable.{NumericRange, Queue}\nimport scala.collection.mutable\nimport scala.io.StdIn.readLine\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(new Node(None, 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n @tailrec\n private def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) => root(p)\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val N = sc.nextInt\n if (N != 0) {\n val A = Array.fill(N)(sc.nextInt).groupBy(x => x).map(x => (x._1, \"*\" * x._2.length))\n for (i <- Range(0, 10)) {\n println(A.getOrElse(i, \"-\"))\n }\n solve(sc)\n }\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n", "language": "Scala", "metadata": {"date": 1521805007, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00219.html", "problem_id": "p00219", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00219/input.txt", "sample_output_relpath": "derived/input_output/data/p00219/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00219/Scala/s981404589.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s981404589", "user_id": "u018134297"}, "prompt_components": {"gold_output": "*\n*\n***\n*\n*\n-\n*\n**\n***\n**\n-\n*\n-\n-\n-\n*\n-\n-\n-\n*\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.collection.Searching._\nimport scala.annotation.tailrec\nimport scala.collection.immutable.{NumericRange, Queue}\nimport scala.collection.mutable\nimport scala.io.StdIn.readLine\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(new Node(None, 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n @tailrec\n private def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) => root(p)\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val N = sc.nextInt\n if (N != 0) {\n val A = Array.fill(N)(sc.nextInt).groupBy(x => x).map(x => (x._1, \"*\" * x._2.length))\n for (i <- Range(0, 10)) {\n println(A.getOrElse(i, \"-\"))\n }\n solve(sc)\n }\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n", "problem_context": "ヒストグラム\n\nテンアイスクリームという名前のアイスクリーム屋さんがあります。このお店では常に 10 種類のアイスクリームが店頭に並ぶようにしています。お店の店長は商品開発の参考にするために、アイスクリームの売れ具合を表すグラフを毎日作成しています。\n\nそんな店長のために、あなたは各アイスクリームの販売数をグラフで表示するプログラムを作成することになりました。\n\n一日に販売されるアイスクリームの総数と売れたアイスクリームの番号を入力とし、アイスクリームの種類ごとに販売した数だけ * (半角アスタリスク) を出力するプログラムを作成してください。ただし、アイスクリームの種類を 0 から 9 までの整数で表わします。また、販売個数がゼロのアイスクリームは、- (半角ハイフン) をひとつ出力します。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。\n各データセットは以下の形式で与えられます。\n\nn\nc1\nc2\n:\ncn\n\n1 行目に一日に販売されるアイスクリームの総数 n (1 ≤ n ≤ 10000) が与えられます。続く n 行に第 i のアイスクリームの種類 ci (0 ≤ ci≤ 9) が与えられます。\n\nデータセットの数は 20 を超えません。\n\nOutput\n\n入力データセットごとに、各アイスクリームの種類の番号順に販売数を出力します。\n\nSample Input\n\n15\n2\n6\n7\n0\n1\n9\n8\n7\n3\n8\n9\n4\n8\n2\n2\n3\n9\n1\n5\n0\n\nOutput for the Sample Input\n\n*\n*\n***\n*\n*\n-\n*\n**\n***\n**\n-\n*\n-\n-\n-\n*\n-\n-\n-\n*", "sample_input": "15\n2\n6\n7\n0\n1\n9\n8\n7\n3\n8\n9\n4\n8\n2\n2\n3\n9\n1\n5\n0\n"}, "reference_outputs": ["*\n*\n***\n*\n*\n-\n*\n**\n***\n**\n-\n*\n-\n-\n-\n*\n-\n-\n-\n*\n"], "source_document_id": "p00219", "source_text": "ヒストグラム\n\nテンアイスクリームという名前のアイスクリーム屋さんがあります。このお店では常に 10 種類のアイスクリームが店頭に並ぶようにしています。お店の店長は商品開発の参考にするために、アイスクリームの売れ具合を表すグラフを毎日作成しています。\n\nそんな店長のために、あなたは各アイスクリームの販売数をグラフで表示するプログラムを作成することになりました。\n\n一日に販売されるアイスクリームの総数と売れたアイスクリームの番号を入力とし、アイスクリームの種類ごとに販売した数だけ * (半角アスタリスク) を出力するプログラムを作成してください。ただし、アイスクリームの種類を 0 から 9 までの整数で表わします。また、販売個数がゼロのアイスクリームは、- (半角ハイフン) をひとつ出力します。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。\n各データセットは以下の形式で与えられます。\n\nn\nc1\nc2\n:\ncn\n\n1 行目に一日に販売されるアイスクリームの総数 n (1 ≤ n ≤ 10000) が与えられます。続く n 行に第 i のアイスクリームの種類 ci (0 ≤ ci≤ 9) が与えられます。\n\nデータセットの数は 20 を超えません。\n\nOutput\n\n入力データセットごとに、各アイスクリームの種類の番号順に販売数を出力します。\n\nSample Input\n\n15\n2\n6\n7\n0\n1\n9\n8\n7\n3\n8\n9\n4\n8\n2\n2\n3\n9\n1\n5\n0\n\nOutput for the Sample Input\n\n*\n*\n***\n*\n*\n-\n*\n**\n***\n**\n-\n*\n-\n-\n-\n*\n-\n-\n-\n*", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1535, "cpu_time_ms": 490, "memory_kb": 80244}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s663074415", "group_id": "codeNet:p00242", "input_text": "object Main extends App {\n\n import scala.io.StdIn._\n\n solve\n def solve:Unit = {\n val n = readLine.trim.toInt\n if (n == 0) return\n val words = Array.tabulate(n) { _ ⇒ readLine.trim.split(' ') }.flatten.groupBy(s ⇒ s).mapValues(_.length).toArray\n val k = readLine.head\n val filtered = words.filter(_._1.head == k)\n if (filtered.isEmpty) {\n println(\"NA\")\n }else{\n val w = filtered.sortWith((a, b) ⇒ if (a._2 == b._2) a._1 < b._1 else a._2 > b._2).map(_._1)\n if (w.length > 5) println(w.take(5).mkString(\" \"))\n else println(w.mkString(\" \"))\n }\n solve\n }\n implicit class Extension[T](val value :T) extends AnyVal {\n @inline\n def let[A](@inline func: T ⇒ A): A = func(value)\n @inline\n def also(@inline func: T ⇒ Unit): T = {func(value); value}\n }\n}\n", "language": "Scala", "metadata": {"date": 1547795920, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00242.html", "problem_id": "p00242", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00242/input.txt", "sample_output_relpath": "derived/input_output/data/p00242/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00242/Scala/s663074415.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s663074415", "user_id": "u514597327"}, "prompt_components": {"gold_output": "bananas because ben best\naizu and as\nabout alex android answer apps\nNA\n", "input_to_evaluate": "object Main extends App {\n\n import scala.io.StdIn._\n\n solve\n def solve:Unit = {\n val n = readLine.trim.toInt\n if (n == 0) return\n val words = Array.tabulate(n) { _ ⇒ readLine.trim.split(' ') }.flatten.groupBy(s ⇒ s).mapValues(_.length).toArray\n val k = readLine.head\n val filtered = words.filter(_._1.head == k)\n if (filtered.isEmpty) {\n println(\"NA\")\n }else{\n val w = filtered.sortWith((a, b) ⇒ if (a._2 == b._2) a._1 < b._1 else a._2 > b._2).map(_._1)\n if (w.length > 5) println(w.take(5).mkString(\" \"))\n else println(w.mkString(\" \"))\n }\n solve\n }\n implicit class Extension[T](val value :T) extends AnyVal {\n @inline\n def let[A](@inline func: T ⇒ A): A = func(value)\n @inline\n def also(@inline func: T ⇒ Unit): T = {func(value); value}\n }\n}\n", "problem_context": "入力候補\n\n携帯電話には、メールなどの文章を効率良く入力するために入力候補を表示する機能が搭載されています。これは、使われる頻度が高い単語を記録しておき、入力された文字を頭文字に持つ単語を入力候補として提示するものです。例えば、普段”computer”という単語を多く入力しているなら、”c”と入力するだけで候補として”computer”が提示されます。このような機能の基本部分を作成してみましょう。\n\n文章、文字を入力とし、その文字を頭文字に持つ単語を出現数の順に出力するプログラムを作成してください。ただし、出現数が同じ単語が複数ある場合は、辞書式順序で出力します。出力する単語は最大5つまでとします。該当する単語が存在しない場合は”NA”と出力してください。\n\n入力\n\n複数のデータセットが与えられます。入力の終わりはゼロひとつで表されます。各データセットは以下の形式で与えられます。\n\nn\nline1\nline2\n:\nlinen\nk\n\n1行目に文章の行数 n (1 ≤ n ≤ 10) が与えられます。続く n 行に文章が与えられます。文章は半角英小文字と半角空白からなり、1行の文字数は1文字以上1024文字以下とします。空白によって区切られる単語は1文字以上20文字以下です。\n\n続く行に頭文字 k が半角英字で与えられます。\n\nデータセットの数は 100 を超えません。\n\n出力\n\nデータセットごとに、指定された文字を頭文字にもつ単語または”NA” を出力します。\n\n入力例\n\n1\nben likes bananas the best among many fruits because bananas are sweet and cheap\nb\n1\nwinners get to visit aizu and the university of aizu and make many friends as well\na\n3\nask alex about\nthe answer for the\nassignment on android apps\na\n2\nprogramming is both\na sport and an intellectual puzzle\nc\n0\n\n出力例\n\nbananas because ben best\naizu and as\nabout alex android answer apps\nNA", "sample_input": "1\nben likes bananas the best among many fruits because bananas are sweet and cheap\nb\n1\nwinners get to visit aizu and the university of aizu and make many friends as well\na\n3\nask alex about\nthe answer for the\nassignment on android apps\na\n2\nprogramming is both\na sport and an intellectual puzzle\nc\n0\n"}, "reference_outputs": ["bananas because ben best\naizu and as\nabout alex android answer apps\nNA\n"], "source_document_id": "p00242", "source_text": "入力候補\n\n携帯電話には、メールなどの文章を効率良く入力するために入力候補を表示する機能が搭載されています。これは、使われる頻度が高い単語を記録しておき、入力された文字を頭文字に持つ単語を入力候補として提示するものです。例えば、普段”computer”という単語を多く入力しているなら、”c”と入力するだけで候補として”computer”が提示されます。このような機能の基本部分を作成してみましょう。\n\n文章、文字を入力とし、その文字を頭文字に持つ単語を出現数の順に出力するプログラムを作成してください。ただし、出現数が同じ単語が複数ある場合は、辞書式順序で出力します。出力する単語は最大5つまでとします。該当する単語が存在しない場合は”NA”と出力してください。\n\n入力\n\n複数のデータセットが与えられます。入力の終わりはゼロひとつで表されます。各データセットは以下の形式で与えられます。\n\nn\nline1\nline2\n:\nlinen\nk\n\n1行目に文章の行数 n (1 ≤ n ≤ 10) が与えられます。続く n 行に文章が与えられます。文章は半角英小文字と半角空白からなり、1行の文字数は1文字以上1024文字以下とします。空白によって区切られる単語は1文字以上20文字以下です。\n\n続く行に頭文字 k が半角英字で与えられます。\n\nデータセットの数は 100 を超えません。\n\n出力\n\nデータセットごとに、指定された文字を頭文字にもつ単語または”NA” を出力します。\n\n入力例\n\n1\nben likes bananas the best among many fruits because bananas are sweet and cheap\nb\n1\nwinners get to visit aizu and the university of aizu and make many friends as well\na\n3\nask alex about\nthe answer for the\nassignment on android apps\na\n2\nprogramming is both\na sport and an intellectual puzzle\nc\n0\n\n出力例\n\nbananas because ben best\naizu and as\nabout alex android answer apps\nNA", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 818, "cpu_time_ms": 370, "memory_kb": 54268}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s363687570", "group_id": "codeNet:p00254", "input_text": "import scala.io.StdIn.readLine\n\nobject Main {\n def main(args:Array[String]):Unit = {\n println {\n Iterator.continually(readLine).takeWhile(_.toInt!=0).map { s=>\n var n = s\n var cnt = 0\n if(n.sortWith(_>_).toInt - n.sorted.toInt == 0) \"NA\"\n else {\n while(n!=\"6174\") {\n n = \"%04d\".format((n.sortWith(_>_).toInt - n.sorted.toInt))\n cnt += 1\n }\n cnt\n }\n }.mkString(\"\\n\")\n }\n }\n}", "language": "Scala", "metadata": {"date": 1487989551, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00254.html", "problem_id": "p00254", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00254/input.txt", "sample_output_relpath": "derived/input_output/data/p00254/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00254/Scala/s363687570.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s363687570", "user_id": "u508732591"}, "prompt_components": {"gold_output": "0\n3\nNA\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main {\n def main(args:Array[String]):Unit = {\n println {\n Iterator.continually(readLine).takeWhile(_.toInt!=0).map { s=>\n var n = s\n var cnt = 0\n if(n.sortWith(_>_).toInt - n.sorted.toInt == 0) \"NA\"\n else {\n while(n!=\"6174\") {\n n = \"%04d\".format((n.sortWith(_>_).toInt - n.sorted.toInt))\n cnt += 1\n }\n cnt\n }\n }.mkString(\"\\n\")\n }\n }\n}", "problem_context": "すべての数は6174に通ず\n\n0 から 9 の数字からなる四桁の数 N に対して以下の操作を行う。\n\nN の桁それぞれの数値を大きい順に並べた結果得た数を L とする\n\nN の桁それぞれの数値を小さい順に並べた結果得た数を S とする\n\n差 L-S を新しい N とする(1回分の操作終了)\n\n新しい N に対して 1. から繰り返す\n\nこのとき、全桁が同じ数字(0000, 1111など)である場合を除き、あらゆる四桁の数はいつかは 6174になることが知られている。例えば N = 2012の場合\n\n       1回目 (N = 2012): L = 2210, S = 0122, L-S = 2088\n\n       2回目 (N = 2088): L = 8820, S = 0288, L-S = 8532\n\n       3回目 (N = 8532): L = 8532, S = 2358, L-S = 6174\n\nとなり、3 回の操作で 6174 に到達する。\n\n0 から 9 の数字からなる四桁の数が与えられたとき、何回の操作で 6174 に到達するか計算するプログラムを作成して下さい。\n\n入力\n\n入力は複数のデータセットからなる。入力の終わりは 0000 が1つの行で示される。各データセットは以下の形式で与えられる。\n\nN\n\nデータセットは1行であり、N (1 ≤ N ≤ 9999) は四桁の数を示す。N < 1000 の場合は上の桁は 0 で埋められている。\n\nデータセットの数は 10000 を超えない。\n\n出力\n\n各データセットごとに何回の操作で 6174 に到達したかを1行に出力する。ただし全桁が同じ数字である数が入力として与えられた場合は NA と出力する。\n\n入力例\n\n6174\n2012\n3333\n0000\n\n出力例\n\n0\n3\nNA", "sample_input": "6174\n2012\n3333\n0000\n"}, "reference_outputs": ["0\n3\nNA\n"], "source_document_id": "p00254", "source_text": "すべての数は6174に通ず\n\n0 から 9 の数字からなる四桁の数 N に対して以下の操作を行う。\n\nN の桁それぞれの数値を大きい順に並べた結果得た数を L とする\n\nN の桁それぞれの数値を小さい順に並べた結果得た数を S とする\n\n差 L-S を新しい N とする(1回分の操作終了)\n\n新しい N に対して 1. から繰り返す\n\nこのとき、全桁が同じ数字(0000, 1111など)である場合を除き、あらゆる四桁の数はいつかは 6174になることが知られている。例えば N = 2012の場合\n\n       1回目 (N = 2012): L = 2210, S = 0122, L-S = 2088\n\n       2回目 (N = 2088): L = 8820, S = 0288, L-S = 8532\n\n       3回目 (N = 8532): L = 8532, S = 2358, L-S = 6174\n\nとなり、3 回の操作で 6174 に到達する。\n\n0 から 9 の数字からなる四桁の数が与えられたとき、何回の操作で 6174 に到達するか計算するプログラムを作成して下さい。\n\n入力\n\n入力は複数のデータセットからなる。入力の終わりは 0000 が1つの行で示される。各データセットは以下の形式で与えられる。\n\nN\n\nデータセットは1行であり、N (1 ≤ N ≤ 9999) は四桁の数を示す。N < 1000 の場合は上の桁は 0 で埋められている。\n\nデータセットの数は 10000 を超えない。\n\n出力\n\n各データセットごとに何回の操作で 6174 に到達したかを1行に出力する。ただし全桁が同じ数字である数が入力として与えられた場合は NA と出力する。\n\n入力例\n\n6174\n2012\n3333\n0000\n\n出力例\n\n0\n3\nNA", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 475, "cpu_time_ms": 850, "memory_kb": 164268}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s664041879", "group_id": "codeNet:p00271", "input_text": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n for(i<-1 to 7) {\n val n = readLine.split(\" \").map(_.toInt)\n println(n(0)-n(1))\n }\n}", "language": "Scala", "metadata": {"date": 1487865802, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00271.html", "problem_id": "p00271", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00271/input.txt", "sample_output_relpath": "derived/input_output/data/p00271/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00271/Scala/s664041879.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s664041879", "user_id": "u508732591"}, "prompt_components": {"gold_output": "11\n19\n1\n5\n1\n13\n20\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n for(i<-1 to 7) {\n val n = readLine.split(\" \").map(_.toInt)\n println(n(0)-n(1))\n }\n}", "problem_context": "気温の差\n\n選手の皆さん、パソコン甲子園にようこそ。イベントに参加するには体調管理が大切です。気温が大きく変動する季節の変わり目には体に負担がかかり、風邪をひきやすいと言われています。一番気を付けなければいけない日は、最高気温と最低気温の差が最も大きい日です。1日の最高気温と最低気温が7日分与えられたとき、それぞれの日について最高気温から最低気温を引いた値を出力するプログラムを作成してください。\n\n入力\n\n入力データは以下の形式で与えられる。\n\na1 b1\na2 b2\n:\na7 b7\n\n入力は7行からなり、i行目にはi日目の最高気温 ai(-40 ≤ ai ≤ 40)と最低気温 bi(-40 ≤ bi ≤ 40)を表す整数が与えられる。すべての日において、最高気温 ai は必ず最低気温 bi 以上となっている。\n\n出力\n\n7日分の気温の差を7行に出力する。\n\n入力例\n\n30 19\n39 20\n19 18\n25 20\n22 21\n23 10\n10 -10\n\n出力例\n\n11\n19\n1\n5\n1\n13\n20", "sample_input": "30 19\n39 20\n19 18\n25 20\n22 21\n23 10\n10 -10\n"}, "reference_outputs": ["11\n19\n1\n5\n1\n13\n20\n"], "source_document_id": "p00271", "source_text": "気温の差\n\n選手の皆さん、パソコン甲子園にようこそ。イベントに参加するには体調管理が大切です。気温が大きく変動する季節の変わり目には体に負担がかかり、風邪をひきやすいと言われています。一番気を付けなければいけない日は、最高気温と最低気温の差が最も大きい日です。1日の最高気温と最低気温が7日分与えられたとき、それぞれの日について最高気温から最低気温を引いた値を出力するプログラムを作成してください。\n\n入力\n\n入力データは以下の形式で与えられる。\n\na1 b1\na2 b2\n:\na7 b7\n\n入力は7行からなり、i行目にはi日目の最高気温 ai(-40 ≤ ai ≤ 40)と最低気温 bi(-40 ≤ bi ≤ 40)を表す整数が与えられる。すべての日において、最高気温 ai は必ず最低気温 bi 以上となっている。\n\n出力\n\n7日分の気温の差を7行に出力する。\n\n入力例\n\n30 19\n39 20\n19 18\n25 20\n22 21\n23 10\n10 -10\n\n出力例\n\n11\n19\n1\n5\n1\n13\n20", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43968}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s344110024", "group_id": "codeNet:p00274", "input_text": "import java.util.Scanner\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n var N = sc.nextInt\n while (N != 0) {\n if (N != 0) {\n var z = false\n for (_ <- 0 until N) {\n if (sc.nextInt == 0) (z = true)\n }\n println(if (z) (\"NA\") else (N + 1))\n }\n N = sc.nextInt\n System.gc\n }\n }\n\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n\n solve(sc)\n }\n}", "language": "Scala", "metadata": {"date": 1507812145, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00274.html", "problem_id": "p00274", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00274/input.txt", "sample_output_relpath": "derived/input_output/data/p00274/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00274/Scala/s344110024.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s344110024", "user_id": "u018134297"}, "prompt_components": {"gold_output": "3\nNA\n2\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n var N = sc.nextInt\n while (N != 0) {\n if (N != 0) {\n var z = false\n for (_ <- 0 until N) {\n if (sc.nextInt == 0) (z = true)\n }\n println(if (z) (\"NA\") else (N + 1))\n }\n N = sc.nextInt\n System.gc\n }\n }\n\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n\n solve(sc)\n }\n}", "problem_context": "おそろいの景品\n\nジョウ君とヤエさんは仲の良いカップルです。ジョウ君はカプセル玩具自販機(ガチャポン)の景品を集めており、二人で出かけたときも、ガチャポンを見つけると何度かやってみるほどの熱の入りようです。ヤエさんは楽しそうなジョウ君をそばで見ているだけでしたが、ジョウ君の今度の誕生日プレゼントにガチャポンの景品をひとつあげることにしました。ヤエさんはガチャポン自体にはあまり興味がわきませんでしたが、できればジョウ君とおそろいの景品が欲しいと思っています。\n\nヤエさんがやってみようと思うガチャポンは、1回のチャレンジで景品がひとつ出ます。品切れのものも含め景品が何種類あるのかと、それぞれの景品がいくつ残っているのかはわかります。しかし、1回のチャレンジでどの景品が出るかはわかりません。そこで、景品が出る順番にかかわらず、ヤエさんが同じ景品を必ず2つ得るために最低限必要なチャレンジの回数を出力するプログラムを作成してください。\n\n入力\n\n入力は複数のデータセットからなる。入力の終わりはゼロ1つの行で示される。各データセットは以下の形式で与えられる。\n\nN\nk1 k2 ... kN\n\n各データセットは2行であり、1行目に景品が何種類あるかを表す整数N(1 ≤ N ≤ 10000)が与えられる。続く1行に各景品がいくつ残っているのかを表す整数ki(0 ≤ ki ≤ 10000)が与えられる。\n\nデータセットの数は100を超えない。\n\n出力\n\nデータセットごとに、同じ景品を必ず2つ得るために最低限必要なチャレンジの回数を出力する。ただし、不可能な場合はNAと出力する。\n\n入力例\n\n2\n3 2\n3\n0 1 1\n1\n1000\n0\n\n出力例\n\n3\nNA\n2\n\n1つ目のデータセットでは、運良く1種類目か2種類目の景品が連続で出て2回で済む可能性はあるが、同じ種類の景品を必ず2つ得るためには3回チャレンジする必要がある。\n\n2つ目のデータセットでは、2つ以上残っている景品がもともと無いので不可能である。\n\n3つ目のデータセットでは、景品は1種類だけなので2回のチャレンジでその景品が必ず2つ得られる。", "sample_input": "2\n3 2\n3\n0 1 1\n1\n1000\n0\n"}, "reference_outputs": ["3\nNA\n2\n"], "source_document_id": "p00274", "source_text": "おそろいの景品\n\nジョウ君とヤエさんは仲の良いカップルです。ジョウ君はカプセル玩具自販機(ガチャポン)の景品を集めており、二人で出かけたときも、ガチャポンを見つけると何度かやってみるほどの熱の入りようです。ヤエさんは楽しそうなジョウ君をそばで見ているだけでしたが、ジョウ君の今度の誕生日プレゼントにガチャポンの景品をひとつあげることにしました。ヤエさんはガチャポン自体にはあまり興味がわきませんでしたが、できればジョウ君とおそろいの景品が欲しいと思っています。\n\nヤエさんがやってみようと思うガチャポンは、1回のチャレンジで景品がひとつ出ます。品切れのものも含め景品が何種類あるのかと、それぞれの景品がいくつ残っているのかはわかります。しかし、1回のチャレンジでどの景品が出るかはわかりません。そこで、景品が出る順番にかかわらず、ヤエさんが同じ景品を必ず2つ得るために最低限必要なチャレンジの回数を出力するプログラムを作成してください。\n\n入力\n\n入力は複数のデータセットからなる。入力の終わりはゼロ1つの行で示される。各データセットは以下の形式で与えられる。\n\nN\nk1 k2 ... kN\n\n各データセットは2行であり、1行目に景品が何種類あるかを表す整数N(1 ≤ N ≤ 10000)が与えられる。続く1行に各景品がいくつ残っているのかを表す整数ki(0 ≤ ki ≤ 10000)が与えられる。\n\nデータセットの数は100を超えない。\n\n出力\n\nデータセットごとに、同じ景品を必ず2つ得るために最低限必要なチャレンジの回数を出力する。ただし、不可能な場合はNAと出力する。\n\n入力例\n\n2\n3 2\n3\n0 1 1\n1\n1000\n0\n\n出力例\n\n3\nNA\n2\n\n1つ目のデータセットでは、運良く1種類目か2種類目の景品が連続で出て2回で済む可能性はあるが、同じ種類の景品を必ず2つ得るためには3回チャレンジする必要がある。\n\n2つ目のデータセットでは、2つ以上残っている景品がもともと無いので不可能である。\n\n3つ目のデータセットでは、景品は1種類だけなので2回のチャレンジでその景品が必ず2つ得られる。", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2770, "memory_kb": 61252}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s478060051", "group_id": "codeNet:p00293", "input_text": "import java.util.Scanner\n\nobject Main {\n def solve(sc: => Scanner): Unit =\n println((List.fill[Int](sc.nextInt)(sc.nextInt * 60 + sc.nextInt) ::: List.fill[Int](sc.nextInt)(sc.nextInt * 60 + sc.nextInt))\n .toSeq.toList\n .sortBy(A => A)\n .map(A => ((A / 60): Int) + \":%02d\".format(A % 60))\n .mkString(\" \"))\n\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n\n solve(sc)\n }\n}", "language": "Scala", "metadata": {"date": 1507630337, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00293.html", "problem_id": "p00293", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00293/input.txt", "sample_output_relpath": "derived/input_output/data/p00293/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00293/Scala/s478060051.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s478060051", "user_id": "u018134297"}, "prompt_components": {"gold_output": "8:27 9:08 15:59\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def solve(sc: => Scanner): Unit =\n println((List.fill[Int](sc.nextInt)(sc.nextInt * 60 + sc.nextInt) ::: List.fill[Int](sc.nextInt)(sc.nextInt * 60 + sc.nextInt))\n .toSeq.toList\n .sortBy(A => A)\n .map(A => ((A / 60): Int) + \":%02d\".format(A % 60))\n .mkString(\" \"))\n\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n\n solve(sc)\n }\n}", "problem_context": "路線バスの時刻表\n\nバスマニアの健次郎君は、A市内のバスをよく利用しています。ある日ふと、健次郎君の家の前のバス停から出発するすべてのバスを写真に収めることを思い立ちました。このバス停には飯盛山行きと鶴ケ城行きの2つのバス路線が通ります。各路線の時刻表は手に入れましたが、1つの時刻表としてまとめた方がバス停で写真が撮りやすくなります。\n\n健次郎君を助けるために、2つの路線の時刻表を、0時0分を基準として出発時刻が早い順に1つの時刻表としてまとめるプログラムを作成してください。\n\n入力\n\n入力は以下の形式で与えられる。\n\nN h1 m1 h2 m2 ... hN mN\nM k1 g1 k2 g2 ... kM gM\n\n1行目に、飯盛山行きのバスの数を表す整数 N (1 ≤ N ≤ 100) と、それに続いて飯盛山行きのバス出発時刻が早い順に与えられる。出発時刻は整数 hi (0 ≤ hi ≤ 23) と mi (0 ≤ mi ≤ 59) からなり、hi 時 mi 分に i 番目のバスが出発することを表す。2行目に、鶴ケ城行きのバスの数を表す整数 M (1 ≤ M ≤ 100) と、それに続いて鶴ケ城行きのバス出発時刻が早い順に与えられる。出発時刻は整数 ki (0 ≤ ki ≤ 23) と gi (0 ≤ gi ≤ 59) からなり、ki 時 gi 分に i 番目のバスが出発することを表す。同じ路線には、同じ時刻に出発するバスはないものとする。\n\n出力\n\n2つの路線の時刻表を、0時0分を基準として出発時刻が早い順に1つにまとめた時刻表を1行に出力する。ただし、同じ時刻に複数のバスが出発するときは1つだけを出力する。出発時刻の時と分を : で区切る。分が1桁のときは左に0をひとつ加えて2桁で出力する。時刻と時刻の間は空白1 つで区切る。\n\n入出力例\n\n入力例1\n\n2 9 8 15 59\n1 8 27\n\n出力例1\n\n8:27 9:08 15:59\n\n入力例2\n\n2 0 0 21 0\n3 7 30 21 0 23 7\n\n出力例2\n\n0:00 7:30 21:00 23:07", "sample_input": "2 9 8 15 59\n1 8 27\n"}, "reference_outputs": ["8:27 9:08 15:59\n"], "source_document_id": "p00293", "source_text": "路線バスの時刻表\n\nバスマニアの健次郎君は、A市内のバスをよく利用しています。ある日ふと、健次郎君の家の前のバス停から出発するすべてのバスを写真に収めることを思い立ちました。このバス停には飯盛山行きと鶴ケ城行きの2つのバス路線が通ります。各路線の時刻表は手に入れましたが、1つの時刻表としてまとめた方がバス停で写真が撮りやすくなります。\n\n健次郎君を助けるために、2つの路線の時刻表を、0時0分を基準として出発時刻が早い順に1つの時刻表としてまとめるプログラムを作成してください。\n\n入力\n\n入力は以下の形式で与えられる。\n\nN h1 m1 h2 m2 ... hN mN\nM k1 g1 k2 g2 ... kM gM\n\n1行目に、飯盛山行きのバスの数を表す整数 N (1 ≤ N ≤ 100) と、それに続いて飯盛山行きのバス出発時刻が早い順に与えられる。出発時刻は整数 hi (0 ≤ hi ≤ 23) と mi (0 ≤ mi ≤ 59) からなり、hi 時 mi 分に i 番目のバスが出発することを表す。2行目に、鶴ケ城行きのバスの数を表す整数 M (1 ≤ M ≤ 100) と、それに続いて鶴ケ城行きのバス出発時刻が早い順に与えられる。出発時刻は整数 ki (0 ≤ ki ≤ 23) と gi (0 ≤ gi ≤ 59) からなり、ki 時 gi 分に i 番目のバスが出発することを表す。同じ路線には、同じ時刻に出発するバスはないものとする。\n\n出力\n\n2つの路線の時刻表を、0時0分を基準として出発時刻が早い順に1つにまとめた時刻表を1行に出力する。ただし、同じ時刻に複数のバスが出発するときは1つだけを出力する。出発時刻の時と分を : で区切る。分が1桁のときは左に0をひとつ加えて2桁で出力する。時刻と時刻の間は空白1 つで区切る。\n\n入出力例\n\n入力例1\n\n2 9 8 15 59\n1 8 27\n\n出力例1\n\n8:27 9:08 15:59\n\n入力例2\n\n2 0 0 21 0\n3 7 30 21 0 23 7\n\n出力例2\n\n0:00 7:30 21:00 23:07", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 250, "memory_kb": 44888}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s971461354", "group_id": "codeNet:p00364", "input_text": "import java.util.Scanner\n\nimport scala.collection.Searching._\nimport scala.annotation.tailrec\nimport scala.collection.immutable.{NumericRange, Queue}\nimport scala.collection.mutable\nimport scala.io.StdIn.readLine\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(new Node(None, 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) => root(p)\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val N, T = sc.nextInt\n println(\"%.20f\".format(Array.fill(N)(sc.nextDouble, sc.nextDouble).map(x => T * x._2 / x._1).max))\n\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n", "language": "Scala", "metadata": {"date": 1522255080, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00364.html", "problem_id": "p00364", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00364/input.txt", "sample_output_relpath": "derived/input_output/data/p00364/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00364/Scala/s971461354.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s971461354", "user_id": "u018134297"}, "prompt_components": {"gold_output": "6.666667\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.collection.Searching._\nimport scala.annotation.tailrec\nimport scala.collection.immutable.{NumericRange, Queue}\nimport scala.collection.mutable\nimport scala.io.StdIn.readLine\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(new Node(None, 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) => root(p)\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val N, T = sc.nextInt\n println(\"%.20f\".format(Array.fill(N)(sc.nextDouble, sc.nextDouble).map(x => T * x._2 / x._1).max))\n\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n", "problem_context": "Bange Hills Tower\n\nA project is underway to build a new viewing tower in Bange town called “Bange Hills Tower” whose selling point will be the gorgeous view of the entire main keep of Wakamatsu Castle from top to bottom. Therefore, the view line from the top of the tower must reach the bottom of the keep without being hindered by any of the buildings in the town.\n\nWrite a program to calculate the minimum tower height required to view the keep in its entirety based on the following information: the planned location of the tower and the heights and locations of existing buildings. Assume all the buildings, including the keep, are vertical lines without horizontal stretch. “view of the entire keep” means that the view line from the tower top can cover the keep from the bottom to the top without intersecting (contacts at the top are exempted) any of the other vertical lines (i.e., buildings).\n\nInput\n\nThe input is given in the following format.\n\nN t\nx_1 h_1\nx_2 h_2\n:\nx_N h_N\n\nThe first line provides the number of existing buildings N (1≤N≤1000) and the planned location of the tower t (2≤t≤105) in integers. Each of the subsequent N lines provides the information of the i-th building: location x_i (1 ≤ x_i < t) and height from the ground h_i (1 ≤ h_i ≤ 100). All position information is one-dimensional along the ground line whose origin coincides with the Keep location. No more than one building is located in the same location (i.e. if i ≠ j, then x_i ≠ x_j).\n\nOutput\n\nOutput the required height as a real number. No limits on the number of decimal places as long as the error does not exceed ± 10-3.\n\nSample Input 1\n\n3 10\n6 4\n4 2\n3 2\n\nSample Output 1\n\n6.666667", "sample_input": "3 10\n6 4\n4 2\n3 2\n"}, "reference_outputs": ["6.666667\n"], "source_document_id": "p00364", "source_text": "Bange Hills Tower\n\nA project is underway to build a new viewing tower in Bange town called “Bange Hills Tower” whose selling point will be the gorgeous view of the entire main keep of Wakamatsu Castle from top to bottom. Therefore, the view line from the top of the tower must reach the bottom of the keep without being hindered by any of the buildings in the town.\n\nWrite a program to calculate the minimum tower height required to view the keep in its entirety based on the following information: the planned location of the tower and the heights and locations of existing buildings. Assume all the buildings, including the keep, are vertical lines without horizontal stretch. “view of the entire keep” means that the view line from the tower top can cover the keep from the bottom to the top without intersecting (contacts at the top are exempted) any of the other vertical lines (i.e., buildings).\n\nInput\n\nThe input is given in the following format.\n\nN t\nx_1 h_1\nx_2 h_2\n:\nx_N h_N\n\nThe first line provides the number of existing buildings N (1≤N≤1000) and the planned location of the tower t (2≤t≤105) in integers. Each of the subsequent N lines provides the information of the i-th building: location x_i (1 ≤ x_i < t) and height from the ground h_i (1 ≤ h_i ≤ 100). All position information is one-dimensional along the ground line whose origin coincides with the Keep location. No more than one building is located in the same location (i.e. if i ≠ j, then x_i ≠ x_j).\n\nOutput\n\nOutput the required height as a real number. No limits on the number of decimal places as long as the error does not exceed ± 10-3.\n\nSample Input 1\n\n3 10\n6 4\n4 2\n3 2\n\nSample Output 1\n\n6.666667", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1414, "cpu_time_ms": 430, "memory_kb": 60268}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s715937962", "group_id": "codeNet:p00423", "input_text": "object Main extends App {\n val in = io.Source.stdin.getLines.map(_.split(\" \").map(_.toInt))\n for (Array(n) <- in if n != 0) {\n var x, y = 0\n for (Array(a, b) <- in.take(n)) {\n if(a > b) x += a+b\n else if(a < b) y += a+b\n else {x += a; y+= b}\n }\n println(x + \" \" + y)\n }\n}", "language": "Scala", "metadata": {"date": 1486468134, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00423.html", "problem_id": "p00423", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00423/input.txt", "sample_output_relpath": "derived/input_output/data/p00423/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00423/Scala/s715937962.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s715937962", "user_id": "u475394465"}, "prompt_components": {"gold_output": "19 8\n20 0\n15 14\n", "input_to_evaluate": "object Main extends App {\n val in = io.Source.stdin.getLines.map(_.split(\" \").map(_.toInt))\n for (Array(n) <- in if n != 0) {\n var x, y = 0\n for (Array(a, b) <- in.take(n)) {\n if(a > b) x += a+b\n else if(a < b) y += a+b\n else {x += a; y+= b}\n }\n println(x + \" \" + y)\n }\n}", "problem_context": "A と B の 2 人のプレーヤーが, 0 から 9 までの数字が書かれたカードを使ってゲームを行う.最初に, 2 人は与えられた n 枚ずつのカードを,裏向きにして横一列に並べる.その後, 2 人は各自の左から 1 枚ずつカードを表向きにしていき,書かれた数字が大きい方のカードの持ち主が,その 2 枚のカードを取る.このとき,その 2 枚のカードに書かれた数字の合計が,カードを取ったプレーヤーの得点となるものとする.ただし,開いた 2 枚のカードに同じ数字が書かれているときには,引き分けとし,各プレーヤーが自分のカードを 1 枚ずつ取るものとする.\n\n例えば, A,B の持ち札が,以下の入力例 1 から 3 のように並べられている場合を考えよう.ただし,入力ファイルは n + 1 行からなり, 1 行目には各プレーヤのカード枚数 n が書かれており, i + 1 行目(i = 1,2,... ,n)には A の左から i 枚目のカードの数字と B の左から i 枚目の カードの数字が,空白を区切り文字としてこの順で書かれている.すなわち,入力ファイルの 2 行目以降は,左側の列が A のカードの並びを,右側の列が B のカードの並びを,それぞれ表している.このとき,ゲーム終了後の A と B の得点は,それぞれ,対応する出力例に示したものとなる.\n\n 入力ファイルに対応するゲームが終了したときの A の得点と B の得点を,この順に空白を区切り文字として 1 行に出力するプログラムを作成しなさい.ただし, n ≤ 10000 とする.\n\n入力例1\n\n入力例2\n\n入力例3\n\n3\n\n3\n\n3\n\n9 1\n\n9 1\n\n9 1\n\n5 4\n\n5 4\n\n5 5\n\n0 8\n\n1 0\n\n1 8\n\n \n\n出力例1\n\n出力例2\n\n出力例3\n\n19 8\n\n20 0\n\n15 14\n\n入力\n\n入力は複数のデータセットからなる.n が 0 のとき入力が終了する.データセットの数は 5 を超えない.\n\n出力\n\nデータセットごとに、A の得点と B の得点を1行に出力する.\n\n入力例\n\n3\n9 1\n5 4\n0 8\n3\n9 1\n5 4\n1 0\n3\n9 1\n5 5\n1 8\n0\n\n出力例\n\n19 8\n20 0\n15 14\n\n各データセットの出力の後(Bの得点の後)に改行を入れること。\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "3\n9 1\n5 4\n0 8\n3\n9 1\n5 4\n1 0\n3\n9 1\n5 5\n1 8\n0\n"}, "reference_outputs": ["19 8\n20 0\n15 14\n"], "source_document_id": "p00423", "source_text": "A と B の 2 人のプレーヤーが, 0 から 9 までの数字が書かれたカードを使ってゲームを行う.最初に, 2 人は与えられた n 枚ずつのカードを,裏向きにして横一列に並べる.その後, 2 人は各自の左から 1 枚ずつカードを表向きにしていき,書かれた数字が大きい方のカードの持ち主が,その 2 枚のカードを取る.このとき,その 2 枚のカードに書かれた数字の合計が,カードを取ったプレーヤーの得点となるものとする.ただし,開いた 2 枚のカードに同じ数字が書かれているときには,引き分けとし,各プレーヤーが自分のカードを 1 枚ずつ取るものとする.\n\n例えば, A,B の持ち札が,以下の入力例 1 から 3 のように並べられている場合を考えよう.ただし,入力ファイルは n + 1 行からなり, 1 行目には各プレーヤのカード枚数 n が書かれており, i + 1 行目(i = 1,2,... ,n)には A の左から i 枚目のカードの数字と B の左から i 枚目の カードの数字が,空白を区切り文字としてこの順で書かれている.すなわち,入力ファイルの 2 行目以降は,左側の列が A のカードの並びを,右側の列が B のカードの並びを,それぞれ表している.このとき,ゲーム終了後の A と B の得点は,それぞれ,対応する出力例に示したものとなる.\n\n 入力ファイルに対応するゲームが終了したときの A の得点と B の得点を,この順に空白を区切り文字として 1 行に出力するプログラムを作成しなさい.ただし, n ≤ 10000 とする.\n\n入力例1\n\n入力例2\n\n入力例3\n\n3\n\n3\n\n3\n\n9 1\n\n9 1\n\n9 1\n\n5 4\n\n5 4\n\n5 5\n\n0 8\n\n1 0\n\n1 8\n\n \n\n出力例1\n\n出力例2\n\n出力例3\n\n19 8\n\n20 0\n\n15 14\n\n入力\n\n入力は複数のデータセットからなる.n が 0 のとき入力が終了する.データセットの数は 5 を超えない.\n\n出力\n\nデータセットごとに、A の得点と B の得点を1行に出力する.\n\n入力例\n\n3\n9 1\n5 4\n0 8\n3\n9 1\n5 4\n1 0\n3\n9 1\n5 5\n1 8\n0\n\n出力例\n\n19 8\n20 0\n15 14\n\n各データセットの出力の後(Bの得点の後)に改行を入れること。\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 410, "memory_kb": 70552}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s867677694", "group_id": "codeNet:p00428", "input_text": "object Main extends App {\n val src = io.Source.stdin.getLines.map(_.split(\" \").map(_.toInt).toList)\n\n for (List(rows, elems) <- src if rows != 0)\n println(src.take(rows).toList\n .transpose.map(_.sum).zip(Stream from 1)\n .sortWith((tup1, tup2) => tup1._1 > tup2._1)\n .map{ case (num, idx) => idx }.mkString(\" \"))\n}\n\n", "language": "Scala", "metadata": {"date": 1515645626, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00428.html", "problem_id": "p00428", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00428/input.txt", "sample_output_relpath": "derived/input_output/data/p00428/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00428/Scala/s867677694.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s867677694", "user_id": "u387507798"}, "prompt_components": {"gold_output": "1 3 2 5 4 6\n1 3 2 5 4 6\n", "input_to_evaluate": "object Main extends App {\n val src = io.Source.stdin.getLines.map(_.split(\" \").map(_.toInt).toList)\n\n for (List(rows, elems) <- src if rows != 0)\n println(src.take(rows).toList\n .transpose.map(_.sum).zip(Stream from 1)\n .sortWith((tup1, tup2) => tup1._1 > tup2._1)\n .map{ case (num, idx) => idx }.mkString(\" \"))\n}\n\n", "problem_context": "ある学校で修学旅行へ行く計画がある.そのためにアンケート調査を行った.\n生徒は 1 から n までの生徒番号を持ち,旅行候補の場所を 1 から m までの番号で表し,行きたい場所に ○,行きたくない場所に×の印をつけて提出している.\n\nこのとき, 行きたい場所の人数が多い順に,場所の番号を出力するプログラムを作成せよ.人数が同じときは,場所の番号順とする.\n\n入力データ の 1 行目は生徒の人数 n と旅行候補の場所の数 m が空白で区切られ, i + 1 行に生徒 i のアンケート結果を ○ は 1 で×は 0 で表し,空白で区切られた m 個の数字が並んでいる.1 ≤ n ≤ 1000, 1 ≤ m ≤ 100 とする.\n\n入力例1\n\n4 6\n\n1 0 1 0 1 1\n\n1 1 0 1 0 0\n\n1 1 1 0 0 0\n\n1 0 1 0 1 0\n\n \n\n出力例1\n\n1 3 2 5 4 6\n\n入力\n\n入力は複数のデータセットからなる.n, m がともに 0 のとき入力が終了する.データセットの数は 5 を超えない.\n\n出力\n\nデータセットごとに、場所の番号 を1行に出力する.\n\n入力例\n\n4 6\n1 0 1 0 1 1\n1 1 0 1 0 0\n1 1 1 0 0 0\n1 0 1 0 1 0\n4 6\n1 0 1 0 1 1\n1 1 0 1 0 0\n1 1 1 0 0 0\n1 0 1 0 1 0\n0 0\n\n出力例\n\n1 3 2 5 4 6\n1 3 2 5 4 6\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "4 6\n1 0 1 0 1 1\n1 1 0 1 0 0\n1 1 1 0 0 0\n1 0 1 0 1 0\n4 6\n1 0 1 0 1 1\n1 1 0 1 0 0\n1 1 1 0 0 0\n1 0 1 0 1 0\n0 0\n"}, "reference_outputs": ["1 3 2 5 4 6\n1 3 2 5 4 6\n"], "source_document_id": "p00428", "source_text": "ある学校で修学旅行へ行く計画がある.そのためにアンケート調査を行った.\n生徒は 1 から n までの生徒番号を持ち,旅行候補の場所を 1 から m までの番号で表し,行きたい場所に ○,行きたくない場所に×の印をつけて提出している.\n\nこのとき, 行きたい場所の人数が多い順に,場所の番号を出力するプログラムを作成せよ.人数が同じときは,場所の番号順とする.\n\n入力データ の 1 行目は生徒の人数 n と旅行候補の場所の数 m が空白で区切られ, i + 1 行に生徒 i のアンケート結果を ○ は 1 で×は 0 で表し,空白で区切られた m 個の数字が並んでいる.1 ≤ n ≤ 1000, 1 ≤ m ≤ 100 とする.\n\n入力例1\n\n4 6\n\n1 0 1 0 1 1\n\n1 1 0 1 0 0\n\n1 1 1 0 0 0\n\n1 0 1 0 1 0\n\n \n\n出力例1\n\n1 3 2 5 4 6\n\n入力\n\n入力は複数のデータセットからなる.n, m がともに 0 のとき入力が終了する.データセットの数は 5 を超えない.\n\n出力\n\nデータセットごとに、場所の番号 を1行に出力する.\n\n入力例\n\n4 6\n1 0 1 0 1 1\n1 1 0 1 0 0\n1 1 1 0 0 0\n1 0 1 0 1 0\n4 6\n1 0 1 0 1 1\n1 1 0 1 0 0\n1 1 1 0 0 0\n1 0 1 0 1 0\n0 0\n\n出力例\n\n1 3 2 5 4 6\n1 3 2 5 4 6\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 335, "cpu_time_ms": 500, "memory_kb": 73872}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s312341358", "group_id": "codeNet:p00429", "input_text": "import scala.io.StdIn.{readInt,readLine}\n\nobject Main extends App {\n def genStr(s:String) = {\n var i = 0\n var result = \"\"\n\n while(i\n var s = readLine\n (0 until n).foreach { _ => s = genStr(s) }\n println(s)\n }\n}", "language": "Scala", "metadata": {"date": 1487688922, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00429.html", "problem_id": "p00429", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00429/input.txt", "sample_output_relpath": "derived/input_output/data/p00429/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00429/Scala/s312341358.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Memory Limit Exceeded", "submission_id": "s312341358", "user_id": "u508732591"}, "prompt_components": {"gold_output": "13112221\n13112221\n", "input_to_evaluate": "import scala.io.StdIn.{readInt,readLine}\n\nobject Main extends App {\n def genStr(s:String) = {\n var i = 0\n var result = \"\"\n\n while(i\n var s = readLine\n (0 until n).foreach { _ => s = genStr(s) }\n println(s)\n }\n}", "problem_context": "0 から 9 までの数字だけで構成された文字列が与えられたとき,その文字列から次の規則に従って新しい文字列を作る操作を考える.与えられた文字列を左端から1文字ずつ順に読んで行き,同じ数字 a が r 個続いていた場合,個数 r と数字a を空白で区切らずにこの順で書き出す.与えられた文字列の右端まで読み,最後の書き出しが終わったところまでを途中何回書き出しがあったとしても全部まとめて操作1回とカウントする.2回目以降の操作は前回の操作により書き出された文字列を与えられた文字列として同様の操作を実施する.例えば “122244” という文字列が与えられた場合には左端から順に1個の1, 3個の2,2個の4なのでこの操作1回で得られる文字列は “113224” であり,“44444444444” (11 個の4)の場合には得られる文字列は “114” となる.\n\n100 文字以下の与えられた文字列に上の操作を n 回実施した文字列を出力するプログラムを作成せよ.ただし, n ≤ 20 とする.\n\n入力データ は 2 行からなり,1 行目に操作回数 n, 2 行目に最初の文字列が書かれている.\n\n入力例\n\n5\n\n11\n\n \n\n出力例\n\n13112221\n\n入力\n\n入力は複数のデータセットからなる.n が 0 のとき入力が終了する.データセットの数は 5 を超えない.\n\n出力\n\nデータセットごとに、指定された回数の操作を施した文字列 を1行に出力する.\n\n入力例\n\n5\n11\n5\n11\n0\n\n出力例\n\n13112221\n13112221\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "5\n11\n5\n11\n0\n"}, "reference_outputs": ["13112221\n13112221\n"], "source_document_id": "p00429", "source_text": "0 から 9 までの数字だけで構成された文字列が与えられたとき,その文字列から次の規則に従って新しい文字列を作る操作を考える.与えられた文字列を左端から1文字ずつ順に読んで行き,同じ数字 a が r 個続いていた場合,個数 r と数字a を空白で区切らずにこの順で書き出す.与えられた文字列の右端まで読み,最後の書き出しが終わったところまでを途中何回書き出しがあったとしても全部まとめて操作1回とカウントする.2回目以降の操作は前回の操作により書き出された文字列を与えられた文字列として同様の操作を実施する.例えば “122244” という文字列が与えられた場合には左端から順に1個の1, 3個の2,2個の4なのでこの操作1回で得られる文字列は “113224” であり,“44444444444” (11 個の4)の場合には得られる文字列は “114” となる.\n\n100 文字以下の与えられた文字列に上の操作を n 回実施した文字列を出力するプログラムを作成せよ.ただし, n ≤ 20 とする.\n\n入力データ は 2 行からなり,1 行目に操作回数 n, 2 行目に最初の文字列が書かれている.\n\n入力例\n\n5\n\n11\n\n \n\n出力例\n\n13112221\n\n入力\n\n入力は複数のデータセットからなる.n が 0 のとき入力が終了する.データセットの数は 5 を超えない.\n\n出力\n\nデータセットごとに、指定された回数の操作を施した文字列 を1行に出力する.\n\n入力例\n\n5\n11\n5\n11\n0\n\n出力例\n\n13112221\n13112221\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 479, "cpu_time_ms": 1500, "memory_kb": 568520}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s189871030", "group_id": "codeNet:p00448", "input_text": "import java.util.Scanner\n\nobject Main {\n def check(input: Array[Array[Int]]): Int = {\n Array.tabulate(input(0).length)(\n j => math.max(\n Array.tabulate(input.length)(i=>input(i)(j)).filter(k => 0 == k).length,\n Array.tabulate(input.length)(i=>input(i)(j)).filter(k => 1 == k).length\n )\n ).sum\n }\n\n def rev(num: Int, input: Array[Array[Int]]): Array[Array[Int]] = {\n Array.tabulate(input.length)(i => if ((num >> i) % 2 == 1) (Array.tabulate(input(i).length)(j => 1 - input(i)(j))) else (input(i)))\n }\n\n def make(input: Array[Array[Int]]): Int = {\n Array.tabulate(1 << input.length)(i => check(rev(i, input))).max\n }\n\n def solve(sc: Scanner): Unit = {\n val R: Int = sc.nextInt\n val C: Int = sc.nextInt\n if (R != 0 && C != 0) {\n println(make(Array.fill(R)(Array.fill(C)(sc.nextInt))))\n\n solve(sc)\n }\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}", "language": "Scala", "metadata": {"date": 1500711873, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00448.html", "problem_id": "p00448", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00448/input.txt", "sample_output_relpath": "derived/input_output/data/p00448/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00448/Scala/s189871030.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Memory Limit Exceeded", "submission_id": "s189871030", "user_id": "u018134297"}, "prompt_components": {"gold_output": "9\n15\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def check(input: Array[Array[Int]]): Int = {\n Array.tabulate(input(0).length)(\n j => math.max(\n Array.tabulate(input.length)(i=>input(i)(j)).filter(k => 0 == k).length,\n Array.tabulate(input.length)(i=>input(i)(j)).filter(k => 1 == k).length\n )\n ).sum\n }\n\n def rev(num: Int, input: Array[Array[Int]]): Array[Array[Int]] = {\n Array.tabulate(input.length)(i => if ((num >> i) % 2 == 1) (Array.tabulate(input(i).length)(j => 1 - input(i)(j))) else (input(i)))\n }\n\n def make(input: Array[Array[Int]]): Int = {\n Array.tabulate(1 << input.length)(i => check(rev(i, input))).max\n }\n\n def solve(sc: Scanner): Unit = {\n val R: Int = sc.nextInt\n val C: Int = sc.nextInt\n if (R != 0 && C != 0) {\n println(make(Array.fill(R)(Array.fill(C)(sc.nextInt))))\n\n solve(sc)\n }\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}", "problem_context": "おせんべい\n\n問題\n\nIOI製菓では,創業以来の伝統の製法で煎餅(せんべい)を焼いている.この伝統の製法は,炭火で一定時間表側を焼き,表側が焼けると裏返して,炭火で一定時間裏側を焼くというものである.この伝統を守りつつ,煎餅を機械で焼いている.この機械は縦 R (1 ≤ R ≤ 10) 行, 横 C (1 ≤ C ≤ 10000) 列の長方形状に煎餅を並べて焼く.通常は自動運転で,表側が焼けたら一斉に煎餅を裏返し裏側を焼く.\n\nある日,煎餅を焼いていると,煎餅を裏返す直前に地震が起こり何枚かの煎餅が裏返ってしまった.幸いなことに炭火の状態は適切なままであったが,これ以上表側を焼くと創業以来の伝統で定められている焼き時間を超えてしまい,煎餅の表側が焼けすぎて商品として出荷できなくなる.そこで,急いで機械をマニュアル操作に変更し,まだ裏返っていない煎餅だけを裏返そうとした.この機械は,横の行を何行か同時に裏返したり縦の列を何列か同時に裏返したりすることはできるが,残念なことに,煎餅を1枚ごと裏返すことはできない.\n\n裏返すのに時間がかかると,地震で裏返らなかった煎餅の表側が焼けすぎて商品として出荷できなくなるので,横の何行かを同時に1回裏返し,引き続き,縦の何列かを同時に1回裏返して,表側を焼きすぎずに両面を焼くことのできる煎餅,つまり,「出荷できる煎餅」の枚数をなるべく多くすることにした.横の行を1行も裏返さない,あるいは,縦の列を1列も裏返さない場合も考えることにする.出荷できる煎餅の枚数の最大値を出力するプログラムを書きなさい.\n\n地震の直後に,煎餅が次の図のような状態になったとする.黒い丸が表側が焼ける状態を,白い丸が裏側が焼ける状態を表している.\n\n1行目を裏返すと次の図のような状態になる.\n\nさらに, 1列目と5列目を裏返すと次の図のような状態になる.この状態では,出荷できる煎餅は9枚である.\n\nヒント\n\nR の上限 10 は C の上限 10000 に比べて小さいことに注意せよ.\n\n入力\n\n入力は複数のデータセットからなる.各データセットは以下の形式で与えられる.\n\n入力の1行目には2つの整数 R, C (1 ≤ R ≤ 10, 1 ≤ C ≤ 10 000) が空白を区切りとして書かれている.続く R 行は地震直後の煎餅の状態を表す. (i+1) 行目 (1 ≤ i ≤ R) には, C 個の整数 ai,1, ai,2, ……, ai,C が空白を区切りとして書かれており, ai,j は i 行 j 列 の煎餅の状態を表している. ai,j が 1 なら表側が焼けることを, 0 なら裏側が焼けることを表す.\n\nC, R がともに 0 のとき入力の終了を示す. データセットの数は 5 を超えない.\n\n出力\n\nデータセットごとに,出荷できる煎餅の最大枚数を1行に出力する.\n\n入出力例\n\n入力例\n\n2 5\n0 1 0 1 0\n1 0 0 0 1\n3 6\n1 0 0 0 1 0\n1 1 1 0 1 0\n1 0 1 1 0 1\n0 0\n\n出力例\n\n9\n15\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "2 5\n0 1 0 1 0\n1 0 0 0 1\n3 6\n1 0 0 0 1 0\n1 1 1 0 1 0\n1 0 1 1 0 1\n0 0\n"}, "reference_outputs": ["9\n15\n"], "source_document_id": "p00448", "source_text": "おせんべい\n\n問題\n\nIOI製菓では,創業以来の伝統の製法で煎餅(せんべい)を焼いている.この伝統の製法は,炭火で一定時間表側を焼き,表側が焼けると裏返して,炭火で一定時間裏側を焼くというものである.この伝統を守りつつ,煎餅を機械で焼いている.この機械は縦 R (1 ≤ R ≤ 10) 行, 横 C (1 ≤ C ≤ 10000) 列の長方形状に煎餅を並べて焼く.通常は自動運転で,表側が焼けたら一斉に煎餅を裏返し裏側を焼く.\n\nある日,煎餅を焼いていると,煎餅を裏返す直前に地震が起こり何枚かの煎餅が裏返ってしまった.幸いなことに炭火の状態は適切なままであったが,これ以上表側を焼くと創業以来の伝統で定められている焼き時間を超えてしまい,煎餅の表側が焼けすぎて商品として出荷できなくなる.そこで,急いで機械をマニュアル操作に変更し,まだ裏返っていない煎餅だけを裏返そうとした.この機械は,横の行を何行か同時に裏返したり縦の列を何列か同時に裏返したりすることはできるが,残念なことに,煎餅を1枚ごと裏返すことはできない.\n\n裏返すのに時間がかかると,地震で裏返らなかった煎餅の表側が焼けすぎて商品として出荷できなくなるので,横の何行かを同時に1回裏返し,引き続き,縦の何列かを同時に1回裏返して,表側を焼きすぎずに両面を焼くことのできる煎餅,つまり,「出荷できる煎餅」の枚数をなるべく多くすることにした.横の行を1行も裏返さない,あるいは,縦の列を1列も裏返さない場合も考えることにする.出荷できる煎餅の枚数の最大値を出力するプログラムを書きなさい.\n\n地震の直後に,煎餅が次の図のような状態になったとする.黒い丸が表側が焼ける状態を,白い丸が裏側が焼ける状態を表している.\n\n1行目を裏返すと次の図のような状態になる.\n\nさらに, 1列目と5列目を裏返すと次の図のような状態になる.この状態では,出荷できる煎餅は9枚である.\n\nヒント\n\nR の上限 10 は C の上限 10000 に比べて小さいことに注意せよ.\n\n入力\n\n入力は複数のデータセットからなる.各データセットは以下の形式で与えられる.\n\n入力の1行目には2つの整数 R, C (1 ≤ R ≤ 10, 1 ≤ C ≤ 10 000) が空白を区切りとして書かれている.続く R 行は地震直後の煎餅の状態を表す. (i+1) 行目 (1 ≤ i ≤ R) には, C 個の整数 ai,1, ai,2, ……, ai,C が空白を区切りとして書かれており, ai,j は i 行 j 列 の煎餅の状態を表している. ai,j が 1 なら表側が焼けることを, 0 なら裏側が焼けることを表す.\n\nC, R がともに 0 のとき入力の終了を示す. データセットの数は 5 を超えない.\n\n出力\n\nデータセットごとに,出荷できる煎餅の最大枚数を1行に出力する.\n\n入出力例\n\n入力例\n\n2 5\n0 1 0 1 0\n1 0 0 0 1\n3 6\n1 0 0 0 1 0\n1 1 1 0 1 0\n1 0 1 1 0 1\n0 0\n\n出力例\n\n9\n15\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 974, "cpu_time_ms": 8130, "memory_kb": 583156}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s648910176", "group_id": "codeNet:p00497", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val firstLine = scala.io.StdIn.readLine().split(\" \");\n val n = firstLine(0).toInt\n val m = firstLine(1).toInt\n\n val checked = new Array[Byte](n * (n + 1) / 2)\n val one = 1.byteValue()\n \n System.gc();\n\n var count = 0\n for (mcount <- 1 to m) {\n val line = scala.io.StdIn.readLine\n val lineArray = line.split(\" \");\n val a = lineArray(0).toInt\n val b = lineArray(1).toInt\n val x = lineArray(2).toInt\n\n var i = a * (a - 1) / 2 + b - 1\n for (p <- a to a + x) {\n for (q <- b to b + p - a) {\n if (checked(i) != one) {\n checked(i) = one\n count += 1;\n }\n\n i += 1\n }\n i += a - 1\n }\n }\n\n println(count)\n }\n}", "language": "Scala", "metadata": {"date": 1447317747, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00497.html", "problem_id": "p00497", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00497/input.txt", "sample_output_relpath": "derived/input_output/data/p00497/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00497/Scala/s648910176.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s648910176", "user_id": "u586872224"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val firstLine = scala.io.StdIn.readLine().split(\" \");\n val n = firstLine(0).toInt\n val m = firstLine(1).toInt\n\n val checked = new Array[Byte](n * (n + 1) / 2)\n val one = 1.byteValue()\n \n System.gc();\n\n var count = 0\n for (mcount <- 1 to m) {\n val line = scala.io.StdIn.readLine\n val lineArray = line.split(\" \");\n val a = lineArray(0).toInt\n val b = lineArray(1).toInt\n val x = lineArray(2).toInt\n\n var i = a * (a - 1) / 2 + b - 1\n for (p <- a to a + x) {\n for (q <- b to b + p - a) {\n if (checked(i) != one) {\n checked(i) = one\n count += 1;\n }\n\n i += 1\n }\n i += a - 1\n }\n }\n\n println(count)\n }\n}", "problem_context": "釘(Nails)\n\nJOI くんは板に釘を刺して遊んでいる.下図のように,JOI くんは一辺N 本の正三角形の形に釘を並べて刺した.上からa 行目(1 ≤ a ≤ N) にはa 本の釘が並んでいる.そのうち左からb 本目(1 ≤ b ≤ a) の釘を(a, b) で表す.\n\n図1: 釘の並び方(N = 5 の場合)\n\n釘を頂点とする正三角形が,「各辺が全体の正三角形の辺のいずれかと平行で,全体の正三角形と同じ向き」であるとき,この正三角形を「よい正三角形」と呼ぶ.すなわち,「よい正三角形」とは,3 本の釘(a, b), (a + x, b), (a + x, b + x) を頂点とする正三角形のことである(ただしa, b, x は1 ≤ a < N, 1 ≤ b ≤ a, 1 ≤ x ≤ N - a) をみたす).\n\nJOI くんは,輪ゴムを使って,「よい正三角形」の周りを囲うことにした.\n\n図2: 輪ゴムによる「よい正三角形」の囲い方の例\n\n課題\n\n正三角形の一辺に並んでいる釘の本数N と,JOI くんが持っている輪ゴムの数M と,M 本の輪ゴムによる「よい正三角形」の囲い方が与えられたとき,1 本以上の輪ゴムで囲われた釘の本数を求めるプログラムを作成せよ.\n\n制限\n\n2 ≤ N ≤ 5000     一辺に並んでいる釘の本数\n\n1 ≤ M ≤ 500000 (= 5 × 105)     輪ゴムの数\n\n入力\n\n標準入力から以下のデータを読み込め.\n\n1 行目には整数N, M が空白を区切りとして書かれている.N は正三角形の一辺に並んでいる釘の本数を,M はJOI くんの持っている輪ゴムの数をそれぞれ表す.\n\n続くM 行は輪ゴムによる「よい正三角形」の囲い方の情報を表す.i + 1 行目(1 ≤ i ≤ M) には整数Ai, Bi, Xi (1 ≤ Ai < N, 1 ≤ Bi ≤ Ai, 1 ≤ Xi ≤ N - Ai) が空白を区切りとして書かれている.これは,i本目の輪ゴムは3 本の釘(Ai, Bi), (Ai + Xi, Bi), (Ai + Xi, Bi + Xi) を頂点とする「よい正三角形」を囲っていることを表す.\n\n出力\n\n標準出力に,1 本以上の輪ゴムに囲われている釘の本数を1 行で出力せよ.\n\n採点基準\n\n採点用データのうち,配点の30% 分については,M ≤ 10000 を満たす.\n\n入出力例\n\n入力例 1\n\n5 2\n2 2 1\n2 1 3\n\n出力例 1\n\n12\n\nこの例は図2 のような「よい正三角形」の囲い方に対応している.この例において,(1, 1), (4, 4), (5, 5) 以外の12 本の釘が1 本以上の輪ゴムで囲われている.\n\n問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "5 2\n2 2 1\n2 1 3\n"}, "reference_outputs": ["12\n"], "source_document_id": "p00497", "source_text": "釘(Nails)\n\nJOI くんは板に釘を刺して遊んでいる.下図のように,JOI くんは一辺N 本の正三角形の形に釘を並べて刺した.上からa 行目(1 ≤ a ≤ N) にはa 本の釘が並んでいる.そのうち左からb 本目(1 ≤ b ≤ a) の釘を(a, b) で表す.\n\n図1: 釘の並び方(N = 5 の場合)\n\n釘を頂点とする正三角形が,「各辺が全体の正三角形の辺のいずれかと平行で,全体の正三角形と同じ向き」であるとき,この正三角形を「よい正三角形」と呼ぶ.すなわち,「よい正三角形」とは,3 本の釘(a, b), (a + x, b), (a + x, b + x) を頂点とする正三角形のことである(ただしa, b, x は1 ≤ a < N, 1 ≤ b ≤ a, 1 ≤ x ≤ N - a) をみたす).\n\nJOI くんは,輪ゴムを使って,「よい正三角形」の周りを囲うことにした.\n\n図2: 輪ゴムによる「よい正三角形」の囲い方の例\n\n課題\n\n正三角形の一辺に並んでいる釘の本数N と,JOI くんが持っている輪ゴムの数M と,M 本の輪ゴムによる「よい正三角形」の囲い方が与えられたとき,1 本以上の輪ゴムで囲われた釘の本数を求めるプログラムを作成せよ.\n\n制限\n\n2 ≤ N ≤ 5000     一辺に並んでいる釘の本数\n\n1 ≤ M ≤ 500000 (= 5 × 105)     輪ゴムの数\n\n入力\n\n標準入力から以下のデータを読み込め.\n\n1 行目には整数N, M が空白を区切りとして書かれている.N は正三角形の一辺に並んでいる釘の本数を,M はJOI くんの持っている輪ゴムの数をそれぞれ表す.\n\n続くM 行は輪ゴムによる「よい正三角形」の囲い方の情報を表す.i + 1 行目(1 ≤ i ≤ M) には整数Ai, Bi, Xi (1 ≤ Ai < N, 1 ≤ Bi ≤ Ai, 1 ≤ Xi ≤ N - Ai) が空白を区切りとして書かれている.これは,i本目の輪ゴムは3 本の釘(Ai, Bi), (Ai + Xi, Bi), (Ai + Xi, Bi + Xi) を頂点とする「よい正三角形」を囲っていることを表す.\n\n出力\n\n標準出力に,1 本以上の輪ゴムに囲われている釘の本数を1 行で出力せよ.\n\n採点基準\n\n採点用データのうち,配点の30% 分については,M ≤ 10000 を満たす.\n\n入出力例\n\n入力例 1\n\n5 2\n2 2 1\n2 1 3\n\n出力例 1\n\n12\n\nこの例は図2 のような「よい正三角形」の囲い方に対応している.この例において,(1, 1), (4, 4), (5, 5) 以外の12 本の釘が1 本以上の輪ゴムで囲われている.\n\n問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 8990, "memory_kb": 90964}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s707491099", "group_id": "codeNet:p00497", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val firstLine = scala.io.StdIn.readLine().split(\" \");\n val n = firstLine(0).toInt\n val m = firstLine(1).toInt\n\n val checked = new Array[Byte](n * (n + 1) / 2)\n val one = 1.byteValue()\n\n System.gc();\n var a = 0;\n var b = 0;\n var x = 0;\n\n var count = 0\n for (mcount <- 1 to m) {\n val line = scala.io.StdIn.readLine\n val lineArray = line.split(\" \");\n a = lineArray(0).toInt\n b = lineArray(1).toInt\n x = lineArray(2).toInt\n\n var i = a * (a - 1) / 2 + b - 1\n for (p <- a to a + x) {\n for (q <- b to b + p - a) {\n if (checked(i) != one) {\n checked(i) = one\n count += 1;\n }\n\n i += 1\n }\n i += a - 1\n }\n System.gc();\n }\n\n println(count)\n }\n}", "language": "Scala", "metadata": {"date": 1447329319, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00497.html", "problem_id": "p00497", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00497/input.txt", "sample_output_relpath": "derived/input_output/data/p00497/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00497/Scala/s707491099.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s707491099", "user_id": "u586872224"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val firstLine = scala.io.StdIn.readLine().split(\" \");\n val n = firstLine(0).toInt\n val m = firstLine(1).toInt\n\n val checked = new Array[Byte](n * (n + 1) / 2)\n val one = 1.byteValue()\n\n System.gc();\n var a = 0;\n var b = 0;\n var x = 0;\n\n var count = 0\n for (mcount <- 1 to m) {\n val line = scala.io.StdIn.readLine\n val lineArray = line.split(\" \");\n a = lineArray(0).toInt\n b = lineArray(1).toInt\n x = lineArray(2).toInt\n\n var i = a * (a - 1) / 2 + b - 1\n for (p <- a to a + x) {\n for (q <- b to b + p - a) {\n if (checked(i) != one) {\n checked(i) = one\n count += 1;\n }\n\n i += 1\n }\n i += a - 1\n }\n System.gc();\n }\n\n println(count)\n }\n}", "problem_context": "釘(Nails)\n\nJOI くんは板に釘を刺して遊んでいる.下図のように,JOI くんは一辺N 本の正三角形の形に釘を並べて刺した.上からa 行目(1 ≤ a ≤ N) にはa 本の釘が並んでいる.そのうち左からb 本目(1 ≤ b ≤ a) の釘を(a, b) で表す.\n\n図1: 釘の並び方(N = 5 の場合)\n\n釘を頂点とする正三角形が,「各辺が全体の正三角形の辺のいずれかと平行で,全体の正三角形と同じ向き」であるとき,この正三角形を「よい正三角形」と呼ぶ.すなわち,「よい正三角形」とは,3 本の釘(a, b), (a + x, b), (a + x, b + x) を頂点とする正三角形のことである(ただしa, b, x は1 ≤ a < N, 1 ≤ b ≤ a, 1 ≤ x ≤ N - a) をみたす).\n\nJOI くんは,輪ゴムを使って,「よい正三角形」の周りを囲うことにした.\n\n図2: 輪ゴムによる「よい正三角形」の囲い方の例\n\n課題\n\n正三角形の一辺に並んでいる釘の本数N と,JOI くんが持っている輪ゴムの数M と,M 本の輪ゴムによる「よい正三角形」の囲い方が与えられたとき,1 本以上の輪ゴムで囲われた釘の本数を求めるプログラムを作成せよ.\n\n制限\n\n2 ≤ N ≤ 5000     一辺に並んでいる釘の本数\n\n1 ≤ M ≤ 500000 (= 5 × 105)     輪ゴムの数\n\n入力\n\n標準入力から以下のデータを読み込め.\n\n1 行目には整数N, M が空白を区切りとして書かれている.N は正三角形の一辺に並んでいる釘の本数を,M はJOI くんの持っている輪ゴムの数をそれぞれ表す.\n\n続くM 行は輪ゴムによる「よい正三角形」の囲い方の情報を表す.i + 1 行目(1 ≤ i ≤ M) には整数Ai, Bi, Xi (1 ≤ Ai < N, 1 ≤ Bi ≤ Ai, 1 ≤ Xi ≤ N - Ai) が空白を区切りとして書かれている.これは,i本目の輪ゴムは3 本の釘(Ai, Bi), (Ai + Xi, Bi), (Ai + Xi, Bi + Xi) を頂点とする「よい正三角形」を囲っていることを表す.\n\n出力\n\n標準出力に,1 本以上の輪ゴムに囲われている釘の本数を1 行で出力せよ.\n\n採点基準\n\n採点用データのうち,配点の30% 分については,M ≤ 10000 を満たす.\n\n入出力例\n\n入力例 1\n\n5 2\n2 2 1\n2 1 3\n\n出力例 1\n\n12\n\nこの例は図2 のような「よい正三角形」の囲い方に対応している.この例において,(1, 1), (4, 4), (5, 5) 以外の12 本の釘が1 本以上の輪ゴムで囲われている.\n\n問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "5 2\n2 2 1\n2 1 3\n"}, "reference_outputs": ["12\n"], "source_document_id": "p00497", "source_text": "釘(Nails)\n\nJOI くんは板に釘を刺して遊んでいる.下図のように,JOI くんは一辺N 本の正三角形の形に釘を並べて刺した.上からa 行目(1 ≤ a ≤ N) にはa 本の釘が並んでいる.そのうち左からb 本目(1 ≤ b ≤ a) の釘を(a, b) で表す.\n\n図1: 釘の並び方(N = 5 の場合)\n\n釘を頂点とする正三角形が,「各辺が全体の正三角形の辺のいずれかと平行で,全体の正三角形と同じ向き」であるとき,この正三角形を「よい正三角形」と呼ぶ.すなわち,「よい正三角形」とは,3 本の釘(a, b), (a + x, b), (a + x, b + x) を頂点とする正三角形のことである(ただしa, b, x は1 ≤ a < N, 1 ≤ b ≤ a, 1 ≤ x ≤ N - a) をみたす).\n\nJOI くんは,輪ゴムを使って,「よい正三角形」の周りを囲うことにした.\n\n図2: 輪ゴムによる「よい正三角形」の囲い方の例\n\n課題\n\n正三角形の一辺に並んでいる釘の本数N と,JOI くんが持っている輪ゴムの数M と,M 本の輪ゴムによる「よい正三角形」の囲い方が与えられたとき,1 本以上の輪ゴムで囲われた釘の本数を求めるプログラムを作成せよ.\n\n制限\n\n2 ≤ N ≤ 5000     一辺に並んでいる釘の本数\n\n1 ≤ M ≤ 500000 (= 5 × 105)     輪ゴムの数\n\n入力\n\n標準入力から以下のデータを読み込め.\n\n1 行目には整数N, M が空白を区切りとして書かれている.N は正三角形の一辺に並んでいる釘の本数を,M はJOI くんの持っている輪ゴムの数をそれぞれ表す.\n\n続くM 行は輪ゴムによる「よい正三角形」の囲い方の情報を表す.i + 1 行目(1 ≤ i ≤ M) には整数Ai, Bi, Xi (1 ≤ Ai < N, 1 ≤ Bi ≤ Ai, 1 ≤ Xi ≤ N - Ai) が空白を区切りとして書かれている.これは,i本目の輪ゴムは3 本の釘(Ai, Bi), (Ai + Xi, Bi), (Ai + Xi, Bi + Xi) を頂点とする「よい正三角形」を囲っていることを表す.\n\n出力\n\n標準出力に,1 本以上の輪ゴムに囲われている釘の本数を1 行で出力せよ.\n\n採点基準\n\n採点用データのうち,配点の30% 分については,M ≤ 10000 を満たす.\n\n入出力例\n\n入力例 1\n\n5 2\n2 2 1\n2 1 3\n\n出力例 1\n\n12\n\nこの例は図2 のような「よい正三角形」の囲い方に対応している.この例において,(1, 1), (4, 4), (5, 5) 以外の12 本の釘が1 本以上の輪ゴムで囲われている.\n\n問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 844, "cpu_time_ms": 490, "memory_kb": 46508}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s529707521", "group_id": "codeNet:p00500", "input_text": "object Main extends App {\n import scala.io.StdIn._\n println(\n (0 until readLine.trim.toInt).map(_ ⇒ readLine.trim.split(' ').map(_.toInt)).let{a ⇒ a.indices.map(i ⇒ (0 until 3).filter(j ⇒ a.map(_(j)).count(_ == a(i)(j)) == 1).map(j ⇒ a(i)(j)).sum).mkString(\"\\n\")}\n )\n implicit class ScopeFunc[T](val value: T){\n def let[A](func: T ⇒ A): A = func(value)\n def also(func: T ⇒ Unit): T = {\n func(value)\n value\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1539651116, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00500.html", "problem_id": "p00500", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00500/input.txt", "sample_output_relpath": "derived/input_output/data/p00500/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00500/Scala/s529707521.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s529707521", "user_id": "u514597327"}, "prompt_components": {"gold_output": "0\n92\n215\n198\n89\n", "input_to_evaluate": "object Main extends App {\n import scala.io.StdIn._\n println(\n (0 until readLine.trim.toInt).map(_ ⇒ readLine.trim.split(' ').map(_.toInt)).let{a ⇒ a.indices.map(i ⇒ (0 until 3).filter(j ⇒ a.map(_(j)).count(_ == a(i)(j)) == 1).map(j ⇒ a(i)(j)).sum).mkString(\"\\n\")}\n )\n implicit class ScopeFunc[T](val value: T){\n def let[A](func: T ⇒ A): A = func(value)\n def also(func: T ⇒ Unit): T = {\n func(value)\n value\n }\n }\n}\n", "problem_context": "数当てゲーム (Unique number)\n\n問題\n\nJOI 君は友達とゲームをすることにした.このゲームには N 人のプレイヤーが参加する.1 回のゲームのルールは次のようなものである:\n\nそれぞれのプレイヤーは 1 以上 100 以下の好きな整数をカードに書いて提出する.各プレイヤーは,自分と同じ数を書いた人が他にいなかった場合,自分の書いた数と同じ得点を得る.自分と同じ数を書いた人が他にいた場合は得点を得られない.\n\nJOI 君たちはこのゲームを 3 回行った.各プレイヤーが 3 回のゲームにおいて書いた数が与えられたとき,各プレイヤーが 3 回のゲームで得た合計得点を求めるプログラムを作成せよ.\n\n入力\n\n入力は 1 + N 行からなる.\n\n1 行目には整数 N (2 ≦ N ≦ 200) が書かれており,プレイヤーの人数を表す.\n\n続く N 行のうちの i 行目 (1 ≦ i ≦ N) には 3 つの 1 以上 100 以下の整数が空白を区切りとして書かれており,それぞれ i 人目のプレイヤーが 1 回目,2 回目,3 回目のゲームで書いた数を表す.\n\n出力\n\n出力は N 行からなる.\n\ni 行目 (1 ≦ i ≦ N) には i 人目のプレイヤーが 3 回のゲームで得た合計得点を表す整数を出力せよ.\n\n入出力例\n\n入力例 1\n\n5\n100 99 98\n100 97 92\n63 89 63\n99 99 99\n89 97 98\n\n出力例 1\n\n0\n92\n215\n198\n89\n\n入力例 1 では,各プレイヤーが 3 回のゲームで得た得点の詳細は次のようになる:\n\nプレイヤー 1: 0 + 0 + 0 = 0\n\nプレイヤー 2: 0 + 0 + 92 = 92\n\nプレイヤー 3: 63 + 89 + 63 = 215\n\nプレイヤー 4: 99 + 0 + 99 = 198\n\nプレイヤー 5: 89 + 0 + 0 = 89\n\n入力例 2\n\n3\n89 92 77\n89 92 63\n89 63 77\n\n出力例 2\n\n0\n63\n63\n\n問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "5\n100 99 98\n100 97 92\n63 89 63\n99 99 99\n89 97 98\n"}, "reference_outputs": ["0\n92\n215\n198\n89\n"], "source_document_id": "p00500", "source_text": "数当てゲーム (Unique number)\n\n問題\n\nJOI 君は友達とゲームをすることにした.このゲームには N 人のプレイヤーが参加する.1 回のゲームのルールは次のようなものである:\n\nそれぞれのプレイヤーは 1 以上 100 以下の好きな整数をカードに書いて提出する.各プレイヤーは,自分と同じ数を書いた人が他にいなかった場合,自分の書いた数と同じ得点を得る.自分と同じ数を書いた人が他にいた場合は得点を得られない.\n\nJOI 君たちはこのゲームを 3 回行った.各プレイヤーが 3 回のゲームにおいて書いた数が与えられたとき,各プレイヤーが 3 回のゲームで得た合計得点を求めるプログラムを作成せよ.\n\n入力\n\n入力は 1 + N 行からなる.\n\n1 行目には整数 N (2 ≦ N ≦ 200) が書かれており,プレイヤーの人数を表す.\n\n続く N 行のうちの i 行目 (1 ≦ i ≦ N) には 3 つの 1 以上 100 以下の整数が空白を区切りとして書かれており,それぞれ i 人目のプレイヤーが 1 回目,2 回目,3 回目のゲームで書いた数を表す.\n\n出力\n\n出力は N 行からなる.\n\ni 行目 (1 ≦ i ≦ N) には i 人目のプレイヤーが 3 回のゲームで得た合計得点を表す整数を出力せよ.\n\n入出力例\n\n入力例 1\n\n5\n100 99 98\n100 97 92\n63 89 63\n99 99 99\n89 97 98\n\n出力例 1\n\n0\n92\n215\n198\n89\n\n入力例 1 では,各プレイヤーが 3 回のゲームで得た得点の詳細は次のようになる:\n\nプレイヤー 1: 0 + 0 + 0 = 0\n\nプレイヤー 2: 0 + 0 + 92 = 92\n\nプレイヤー 3: 63 + 89 + 63 = 215\n\nプレイヤー 4: 99 + 0 + 99 = 198\n\nプレイヤー 5: 89 + 0 + 0 = 89\n\n入力例 2\n\n3\n89 92 77\n89 92 63\n89 63 77\n\n出力例 2\n\n0\n63\n63\n\n問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 300, "memory_kb": 46372}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s462599978", "group_id": "codeNet:p00506", "input_text": "import scala.io.StdIn.{readInt,readLine}\n\nobject Main {\n def euclid(m:Int,n:Int):Int = if(n==0) m else euclid(n,m%n)\n\n def main(args:Array[String]) = {\n val n = readInt\n val nums = readLine.split(\" \").map(_.toInt)\n var gcm = nums(0)\n for(i <- 1 until n) {\n gcm = euclid(gcm,nums(i))\n }\n for(i<-1 to gcm if gcm%i==0)\n println(i)\n }\n}", "language": "Scala", "metadata": {"date": 1487773919, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00506.html", "problem_id": "p00506", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00506/input.txt", "sample_output_relpath": "derived/input_output/data/p00506/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00506/Scala/s462599978.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s462599978", "user_id": "u508732591"}, "prompt_components": {"gold_output": "1\n5\n25\n", "input_to_evaluate": "import scala.io.StdIn.{readInt,readLine}\n\nobject Main {\n def euclid(m:Int,n:Int):Int = if(n==0) m else euclid(n,m%n)\n\n def main(args:Array[String]) = {\n val n = readInt\n val nums = readLine.split(\" \").map(_.toInt)\n var gcm = nums(0)\n for(i <- 1 until n) {\n gcm = euclid(gcm,nums(i))\n }\n for(i<-1 to gcm if gcm%i==0)\n println(i)\n }\n}", "problem_context": "問題 2\n\n 入力ファイルの1行目に正整数 n が書いてあり,\n2行目には半角空白文字1つを区切りとして,\nn 個の正整数が書いてある.\nn は 2 または 3 であり,\n2行目に書かれているどの整数も値は 108 以下である.\nこれら2個または3個の数の公約数をすべて求め,\n小さい方から順に1行に1個ずつ出力せよ.\n自明な公約数(「1」)も出力すること.\n\n \n出力ファイルにおいては,\n出力の最後行にも改行コードを入れること.\n\n入出力例\n\n入力例1\n\n2\n75 125\n\n出力例1\n\n1\n5\n25\n\n入力例2\n\n3\n110 22 88\n\n出力例2\n\n1\n2\n11\n22\n\n入力例3\n\n3\n66 11 3\n\n出力例3\n\n1\n\n問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "2\n75 125\n"}, "reference_outputs": ["1\n5\n25\n"], "source_document_id": "p00506", "source_text": "問題 2\n\n 入力ファイルの1行目に正整数 n が書いてあり,\n2行目には半角空白文字1つを区切りとして,\nn 個の正整数が書いてある.\nn は 2 または 3 であり,\n2行目に書かれているどの整数も値は 108 以下である.\nこれら2個または3個の数の公約数をすべて求め,\n小さい方から順に1行に1個ずつ出力せよ.\n自明な公約数(「1」)も出力すること.\n\n \n出力ファイルにおいては,\n出力の最後行にも改行コードを入れること.\n\n入出力例\n\n入力例1\n\n2\n75 125\n\n出力例1\n\n1\n5\n25\n\n入力例2\n\n3\n110 22 88\n\n出力例2\n\n1\n2\n11\n22\n\n入力例3\n\n3\n66 11 3\n\n出力例3\n\n1\n\n問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 250, "memory_kb": 45120}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s579456632", "group_id": "codeNet:p00511", "input_text": "import scala.io.StdIn.{readInt,readLine}\n\nobject Main {\n def calc(n:Int):Int = {\n val op = readLine\n op match {\n case \"+\" => calc(n+readInt)\n case \"-\" => calc(n-readInt)\n case \"*\" => calc(n*readInt)\n case \"/\" => calc(n/readInt)\n case _ => n\n }\n }\n\n def main(args:Array[String]) = println(calc(readInt))\n}", "language": "Scala", "metadata": {"date": 1487777430, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00511.html", "problem_id": "p00511", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00511/input.txt", "sample_output_relpath": "derived/input_output/data/p00511/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00511/Scala/s579456632.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s579456632", "user_id": "u508732591"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.io.StdIn.{readInt,readLine}\n\nobject Main {\n def calc(n:Int):Int = {\n val op = readLine\n op match {\n case \"+\" => calc(n+readInt)\n case \"-\" => calc(n-readInt)\n case \"*\" => calc(n*readInt)\n case \"/\" => calc(n/readInt)\n case _ => n\n }\n }\n\n def main(args:Array[String]) = println(calc(readInt))\n}", "problem_context": "問題 2\n\n 加減乗除の計算をする電卓プログラムを作りなさい.\n\n 入力データの各行には数と記号 +, -, *, /, = のどれか1つが交互に書いてある.\n1行目は数である.\n演算 +, -, *, / の優先順位(乗除算 *, / を加減算 +, - よりも先に計算すること)は考えず,入力の順序で計算し,= の行になったら,計算結果を出力する.\n入力データの数値は108以下の正の整数とする.\n計算中および計算結果は,0または負の数になることもあるが\n-108〜108 の範囲は超えない.\n割り算は切り捨てとする.\nしたがって,100/3*3= は 99 になる.\n\n 出力ファイルにおいては,\n出力の最後の行にも改行コードを入れること.\n\n入出力例\n\n入力例1\n\n1\n+\n1\n=\n\n出力例1\n\n2\n\n入力例2\n\n10\n-\n21\n*\n5\n=\n\n出力例2\n\n-55\n\n入力例3\n\n100\n/\n3\n*\n3\n=\n\n出力例3\n\n99\n\n問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "1\n+\n1\n=\n"}, "reference_outputs": ["2\n"], "source_document_id": "p00511", "source_text": "問題 2\n\n 加減乗除の計算をする電卓プログラムを作りなさい.\n\n 入力データの各行には数と記号 +, -, *, /, = のどれか1つが交互に書いてある.\n1行目は数である.\n演算 +, -, *, / の優先順位(乗除算 *, / を加減算 +, - よりも先に計算すること)は考えず,入力の順序で計算し,= の行になったら,計算結果を出力する.\n入力データの数値は108以下の正の整数とする.\n計算中および計算結果は,0または負の数になることもあるが\n-108〜108 の範囲は超えない.\n割り算は切り捨てとする.\nしたがって,100/3*3= は 99 になる.\n\n 出力ファイルにおいては,\n出力の最後の行にも改行コードを入れること.\n\n入出力例\n\n入力例1\n\n1\n+\n1\n=\n\n出力例1\n\n2\n\n入力例2\n\n10\n-\n21\n*\n5\n=\n\n出力例2\n\n-55\n\n入力例3\n\n100\n/\n3\n*\n3\n=\n\n出力例3\n\n99\n\n問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 270, "memory_kb": 43516}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s441347987", "group_id": "codeNet:p00595", "input_text": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n while (sc.hasNext) {\n println(gcd(sc.nextLong(), sc.nextLong()))\n }\n }\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def calc(A: Array[Long]): Array[String] = {\n if (A.length == 0) Array.fill(0)(\"\")\n else {\n val last = A.zipWithIndex.map(x => (x._1 - x._2, x._1)).takeWhile(x => x._1 == A.head).last._2\n if (last == A.head) \"%d\".format(A.head) +: calc(A.zipWithIndex.map(x => (x._1 - x._2, x._1)).dropWhile(x => x._1 == A.head).map(x => x._2))\n else \"%d-%d\".format(A.head, last) +: calc(A.zipWithIndex.map(x => (x._1 - x._2, x._1)).dropWhile(x => x._1 == A.head).map(x => x._2))\n }\n }\n\n var memo: Map[(Long, Long), Long] = Map[(Long, Long), Long]()\n\n def recursive(xyz: Array[(Long, Long, Long)], M: Long): Long = {\n if (xyz.isEmpty) M else {\n val head = xyz.head\n if (head._1 == 0) {\n if (head._2 == M)\n recursive(xyz.tail, head._3)\n else if (head._3 == M)\n recursive(xyz.tail, head._2)\n else\n recursive(xyz.tail, M)\n } else {\n if (head._2 == M)\n recursive(xyz.tail, head._3)\n else\n recursive(xyz.tail, M)\n }\n }\n }\n\n def recursive2(X: Set[Long], Y: Stream[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n\n def check(s: String): Boolean = {\n s.isEmpty ||\n s.startsWith(\"dream\") && check(s.drop(5)) ||\n s.startsWith(\"dreamer\") && check(s.drop(7)) ||\n s.startsWith(\"erase\") && check(s.drop(5)) ||\n s.startsWith(\"eraser\") && check(s.drop(6))\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def primeFactors(i: Long): List[Long] = primeFactors_(i, 1).sorted\n\n\n def primeFactors_(i: Long, j: Long): List[Long] = {\n if (j * j > i) List.empty else if (i % j == 0) primeFactors_(i, j + 1) ++ List[Long](j, i / j) else primeFactors_(i, j + 1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1563803858, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00595.html", "problem_id": "p00595", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00595/input.txt", "sample_output_relpath": "derived/input_output/data/p00595/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00595/Scala/s441347987.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s441347987", "user_id": "u018134297"}, "prompt_components": {"gold_output": "19\n12\n", "input_to_evaluate": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n while (sc.hasNext) {\n println(gcd(sc.nextLong(), sc.nextLong()))\n }\n }\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def calc(A: Array[Long]): Array[String] = {\n if (A.length == 0) Array.fill(0)(\"\")\n else {\n val last = A.zipWithIndex.map(x => (x._1 - x._2, x._1)).takeWhile(x => x._1 == A.head).last._2\n if (last == A.head) \"%d\".format(A.head) +: calc(A.zipWithIndex.map(x => (x._1 - x._2, x._1)).dropWhile(x => x._1 == A.head).map(x => x._2))\n else \"%d-%d\".format(A.head, last) +: calc(A.zipWithIndex.map(x => (x._1 - x._2, x._1)).dropWhile(x => x._1 == A.head).map(x => x._2))\n }\n }\n\n var memo: Map[(Long, Long), Long] = Map[(Long, Long), Long]()\n\n def recursive(xyz: Array[(Long, Long, Long)], M: Long): Long = {\n if (xyz.isEmpty) M else {\n val head = xyz.head\n if (head._1 == 0) {\n if (head._2 == M)\n recursive(xyz.tail, head._3)\n else if (head._3 == M)\n recursive(xyz.tail, head._2)\n else\n recursive(xyz.tail, M)\n } else {\n if (head._2 == M)\n recursive(xyz.tail, head._3)\n else\n recursive(xyz.tail, M)\n }\n }\n }\n\n def recursive2(X: Set[Long], Y: Stream[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n\n def check(s: String): Boolean = {\n s.isEmpty ||\n s.startsWith(\"dream\") && check(s.drop(5)) ||\n s.startsWith(\"dreamer\") && check(s.drop(7)) ||\n s.startsWith(\"erase\") && check(s.drop(5)) ||\n s.startsWith(\"eraser\") && check(s.drop(6))\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def primeFactors(i: Long): List[Long] = primeFactors_(i, 1).sorted\n\n\n def primeFactors_(i: Long, j: Long): List[Long] = {\n if (j * j > i) List.empty else if (i % j == 0) primeFactors_(i, j + 1) ++ List[Long](j, i / j) else primeFactors_(i, j + 1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n}\n\n", "problem_context": "Problem A: Greatest Common Divisor\n\nPlease find the greatest common divisor of two natural numbers. A clue is: The Euclid's algorithm is a way to resolve this task.\n\nInput\n\nThe input file consists of several lines with pairs of two natural numbers in each line. The numbers do not exceed 100000.\n\nThe number of pairs (datasets) is less than 50.\n\nOutput\n\nYour program has to print the greatest common divisor for each pair of input numbers. Print each result on a new line.\n\nSample Input\n\n57 38\n60 84\n\nOutput for the Sample Input\n\n19\n12", "sample_input": "57 38\n60 84\n"}, "reference_outputs": ["19\n12\n"], "source_document_id": "p00595", "source_text": "Problem A: Greatest Common Divisor\n\nPlease find the greatest common divisor of two natural numbers. A clue is: The Euclid's algorithm is a way to resolve this task.\n\nInput\n\nThe input file consists of several lines with pairs of two natural numbers in each line. The numbers do not exceed 100000.\n\nThe number of pairs (datasets) is less than 50.\n\nOutput\n\nYour program has to print the greatest common divisor for each pair of input numbers. Print each result on a new line.\n\nSample Input\n\n57 38\n60 84\n\nOutput for the Sample Input\n\n19\n12", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 7237, "cpu_time_ms": 230, "memory_kb": 43976}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s306984677", "group_id": "codeNet:p00684", "input_text": "import scala.annotation.tailrec\nobject Main extends App {\n\n import scala.io.StdIn._\n\n solve\n def solve: Unit = {\n val expression = readLine\n if (expression == null) return\n Expression.calculate(expression) match {\n case Some(c) ⇒ println(c)\n case None ⇒ println(\"overflow\")\n }\n solve\n }\n\n case class Real(value: Int) {\n def +(that: Real): Real = Real(value + that.value)\n def -(that: Real): Real = Real(value - that.value)\n def *(that: Real): Real = Real(value * that.value)\n def *(that: Image): Image = Image(value * that.value)\n override def toString: String = if (value == 0) \"\" else s\"$value\"\n }\n case class Image(value: Int) {\n def +(that: Image): Image = Image(value + that.value)\n def -(that: Image): Image = Image(value - that.value)\n def *(that: Image): Real = Real(-value * that.value)\n def *(that: Real): Image = Image(value * that.value)\n override def toString: String = if (value == 0) \"\" else if (value > 0) s\"${value}i\" else s\"${value}i\"\n }\n case class ComplexType(real: Real = Real(0), image: Image = Image(0)) {\n def +(that: ComplexType): ComplexType = ComplexType(real + that.real, image + that.image)\n def -(that: ComplexType): ComplexType = ComplexType(real - that.real, image - that.image)\n def *(that: ComplexType): ComplexType = ComplexType(real * that.real + image * that.image, real * that.image + image * that.real)\n def isOverflow: Boolean = math.abs(real.value) > 10000 || math.abs(image.value) > 10000\n def overflowChecked: Option[ComplexType] = if (isOverflow) None else Some(this)\n override def toString(): String = {\n if (real.value == 0 && image.value != 0){\n image.toString\n }else if (real.value == 0){\n \"0\"\n }else if (image.value == 0){\n real.toString\n }else if (image.value > 0){\n s\"$real+$image\"\n }else {\n s\"$real$image\"\n }\n }\n }\n object Expression{\n def calculate(expression: String): Option[ComplexType] = {\n expression.toList match {\n case f Expression Nil ⇒ f\n case _ ⇒ ???\n }\n }\n def unapply(arg: List[Char]): Option[(Option[ComplexType], List[Char])] = {\n arg match {\n case left Term rest ⇒ Some(parseAll(rest, left))\n case _ ⇒ None\n }\n }\n @tailrec\n private def parseAll(arg: List[Char], left: Option[ComplexType]): (Option[ComplexType], List[Char]) = {\n arg match {\n case '+'::(right Term t) ⇒ parseAll(t, left.flatMap(l ⇒ right.map(r ⇒ l + r)).filterNot(_.isOverflow))\n case '-'::(right Term t) ⇒ parseAll(t, left.flatMap(l ⇒ right.map(r ⇒ l - r)).filterNot(_.isOverflow))\n case _ ⇒ (left, arg)\n }\n }\n }\n\n object Term {\n def unapply(arg: List[Char]): Option[(Option[ComplexType], List[Char])] = {\n arg match {\n case f Factor rest ⇒ Some(parseAll(rest, f))\n case _ ⇒ None\n }\n }\n @tailrec\n private def parseAll(arg: List[Char], left: Option[ComplexType]): (Option[ComplexType], List[Char]) = {\n arg match {\n case '*'::(right Factor t) ⇒ parseAll(t, left.flatMap(l ⇒ right.map(r ⇒ l * r)).filterNot(_.isOverflow))\n case _ ⇒ (left, arg)\n }\n }\n }\n object Factor {\n def unapply(arg: List[Char]): Option[(Option[ComplexType], List[Char])] = {\n arg match {\n case '('::(f Expression ')'::t) ⇒ Some(f, t)\n case r Number t ⇒ Some(r.flatMap(real ⇒ ComplexType(real = real).overflowChecked), t)\n case i Image t ⇒ Some(ComplexType(image = i).overflowChecked, t)\n }\n }\n }\n object Image{\n def unapply(arg: List[Char]): Option[(Image, List[Char])] = {\n arg match {\n case 'i'::t ⇒ Some(Image(1), t)\n case _ ⇒ None\n }\n }\n }\n object Number{\n def unapply(arg: List[Char]): Option[(Option[Real], List[Char])] = {\n arg.span(_.isDigit) match {\n case (Nil, _) ⇒ None\n case (number, t) ⇒ Some(number.foldLeft(Some(0):Option[Int]){(o, r) ⇒ o.map(l ⇒ l * 10 + r.asDigit).filterNot(i ⇒ math.abs(i) > 10000)}.map(i ⇒ Real(i)), t)\n }\n }\n }\n implicit class Extension[T](val value :T) extends AnyVal {\n @inline\n def let[A](@inline func: T ⇒ A): A = func(value)\n @inline\n def also(@inline func: T ⇒ Unit): T = {func(value); value}\n }\n}\n", "language": "Scala", "metadata": {"date": 1547613202, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00684.html", "problem_id": "p00684", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00684/input.txt", "sample_output_relpath": "derived/input_output/data/p00684/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00684/Scala/s306984677.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s306984677", "user_id": "u514597327"}, "prompt_components": {"gold_output": "11\n-37+16i\n9998+2010i\noverflow\n", "input_to_evaluate": "import scala.annotation.tailrec\nobject Main extends App {\n\n import scala.io.StdIn._\n\n solve\n def solve: Unit = {\n val expression = readLine\n if (expression == null) return\n Expression.calculate(expression) match {\n case Some(c) ⇒ println(c)\n case None ⇒ println(\"overflow\")\n }\n solve\n }\n\n case class Real(value: Int) {\n def +(that: Real): Real = Real(value + that.value)\n def -(that: Real): Real = Real(value - that.value)\n def *(that: Real): Real = Real(value * that.value)\n def *(that: Image): Image = Image(value * that.value)\n override def toString: String = if (value == 0) \"\" else s\"$value\"\n }\n case class Image(value: Int) {\n def +(that: Image): Image = Image(value + that.value)\n def -(that: Image): Image = Image(value - that.value)\n def *(that: Image): Real = Real(-value * that.value)\n def *(that: Real): Image = Image(value * that.value)\n override def toString: String = if (value == 0) \"\" else if (value > 0) s\"${value}i\" else s\"${value}i\"\n }\n case class ComplexType(real: Real = Real(0), image: Image = Image(0)) {\n def +(that: ComplexType): ComplexType = ComplexType(real + that.real, image + that.image)\n def -(that: ComplexType): ComplexType = ComplexType(real - that.real, image - that.image)\n def *(that: ComplexType): ComplexType = ComplexType(real * that.real + image * that.image, real * that.image + image * that.real)\n def isOverflow: Boolean = math.abs(real.value) > 10000 || math.abs(image.value) > 10000\n def overflowChecked: Option[ComplexType] = if (isOverflow) None else Some(this)\n override def toString(): String = {\n if (real.value == 0 && image.value != 0){\n image.toString\n }else if (real.value == 0){\n \"0\"\n }else if (image.value == 0){\n real.toString\n }else if (image.value > 0){\n s\"$real+$image\"\n }else {\n s\"$real$image\"\n }\n }\n }\n object Expression{\n def calculate(expression: String): Option[ComplexType] = {\n expression.toList match {\n case f Expression Nil ⇒ f\n case _ ⇒ ???\n }\n }\n def unapply(arg: List[Char]): Option[(Option[ComplexType], List[Char])] = {\n arg match {\n case left Term rest ⇒ Some(parseAll(rest, left))\n case _ ⇒ None\n }\n }\n @tailrec\n private def parseAll(arg: List[Char], left: Option[ComplexType]): (Option[ComplexType], List[Char]) = {\n arg match {\n case '+'::(right Term t) ⇒ parseAll(t, left.flatMap(l ⇒ right.map(r ⇒ l + r)).filterNot(_.isOverflow))\n case '-'::(right Term t) ⇒ parseAll(t, left.flatMap(l ⇒ right.map(r ⇒ l - r)).filterNot(_.isOverflow))\n case _ ⇒ (left, arg)\n }\n }\n }\n\n object Term {\n def unapply(arg: List[Char]): Option[(Option[ComplexType], List[Char])] = {\n arg match {\n case f Factor rest ⇒ Some(parseAll(rest, f))\n case _ ⇒ None\n }\n }\n @tailrec\n private def parseAll(arg: List[Char], left: Option[ComplexType]): (Option[ComplexType], List[Char]) = {\n arg match {\n case '*'::(right Factor t) ⇒ parseAll(t, left.flatMap(l ⇒ right.map(r ⇒ l * r)).filterNot(_.isOverflow))\n case _ ⇒ (left, arg)\n }\n }\n }\n object Factor {\n def unapply(arg: List[Char]): Option[(Option[ComplexType], List[Char])] = {\n arg match {\n case '('::(f Expression ')'::t) ⇒ Some(f, t)\n case r Number t ⇒ Some(r.flatMap(real ⇒ ComplexType(real = real).overflowChecked), t)\n case i Image t ⇒ Some(ComplexType(image = i).overflowChecked, t)\n }\n }\n }\n object Image{\n def unapply(arg: List[Char]): Option[(Image, List[Char])] = {\n arg match {\n case 'i'::t ⇒ Some(Image(1), t)\n case _ ⇒ None\n }\n }\n }\n object Number{\n def unapply(arg: List[Char]): Option[(Option[Real], List[Char])] = {\n arg.span(_.isDigit) match {\n case (Nil, _) ⇒ None\n case (number, t) ⇒ Some(number.foldLeft(Some(0):Option[Int]){(o, r) ⇒ o.map(l ⇒ l * 10 + r.asDigit).filterNot(i ⇒ math.abs(i) > 10000)}.map(i ⇒ Real(i)), t)\n }\n }\n }\n implicit class Extension[T](val value :T) extends AnyVal {\n @inline\n def let[A](@inline func: T ⇒ A): A = func(value)\n @inline\n def also(@inline func: T ⇒ Unit): T = {func(value); value}\n }\n}\n", "problem_context": "Calculation of Expressions\n\nWrite a program to calculate values of arithmetic expressions which may\ninvolve complex numbers. Details of the expressions are described below.\n\nIn this problem, basic elements of expressions are\nnon-negative integer numbers and\nthe special symbol \"i\". Integer numbers are sequences\nof digits of arbitrary length and are in decimal notation. \"i\" denotes the\nunit imaginary number i, i.e. i 2 = -1.\n\nOperators appearing in expressions are + (addition), -\n(subtraction), and * (multiplication). Division is excluded from\nthe repertoire of the operators. All three operators are only used as binary\noperators. Unary plus and minus operators (e.g., -100) are also\nexcluded from the repertoire. Note that the multiplication symbol *\nmay not be omitted in any case. For example, the expression 1+3i\nin mathematics should be written as 1+3*i.\n\nUsual formation rules of arithmetic expressions apply. Namely, (1) The\noperator * binds its operands stronger than the operators +\nand -. (2) The operators + and - have the same\nstrength in operand binding. (3) Two operators of the same strength bind\nfrom left to right. (4) Parentheses are used to designate specific order\nof binding.\n\nThe consequence of these rules can easily be understood from the following\nexamples.\n\n(1) 3+4*5 is 3+(4*5), not (3+4)*5\n\n(2) 5-6+7 is (5-6)+7, not 5-(6+7)\n\n(3) 1+2+3 is (1+2)+3, not 1+(2+3)\n\nYour program should successively read expressions, calculate them and\nprint their results. Overflow should be detected.\n\nWhenever an abnormal value is yielded as a result of applying an operator\nappearing in the given expression,\nyour program should report that the calculation failed due to overflow.\nBy \"an abnormal value\", we mean a value\nwhose real part or imaginary part is\ngreater than 10000 or less than -10000. Here are examples:\n\n10000+1+(0-10)\n\noverflow, not 9991\n\n(10*i+100)*(101+20*i)\n\n9900+3010i , not overflow\n\n4000000-4000000\n\noverflow, not 0\n\nNote that the law of associativity does not necessarily hold in this\nproblem. For example, in the first example,\noverflow is detected by interpreting\nthe expression as (10000+1)+(0-10) following the binding rules,\nwhereas overflow could not be detected\nif you interpreted it as 10000+(1+(0-10)).\nMoreover, overflow detection should take place for resulting value of each\noperation.\n\nIn the second example, a value which exceeds 10000 appears\nin the calculation process of one multiplication\nif you use the mathematical rule\n\n(a+b i)(c+d i)=(ac-bd)+(ad+bc)i\n.\n\nBut the yielded result 9900+3010i does not contain any number\nwhich exceeds 10000 and, therefore, overflow should not be reported.\n\nInput\n\nA sequence of lines each of which contains an expression is given as\ninput. Each line consists of less than 100 characters and does not contain\nany blank spaces. You may assume that all expressions given in the sequence\nare syntactically correct.\n\nOutput\n\nYour program should produce output for each expression line by line.\nIf overflow is detected, output should be\na character string \"overflow\".\nOtherwise, output should be the resulting value of calculation\nin the following fashion.\n\n0 , if the result is 0+0i.\n\n-123 , if the result is -123+0i.\n\n45i , if the result is 0+45i.\n\n3+1i , if the result is 3+i.\n\n123-45i , if the result is 123-45i.\n\nOutput should not contain any blanks, surplus 0,\n+, or -.\n\nSample Input\n\n(1-10*i)+00007+(3+10*i)\n3+4*i*(4+10*i)\n(102+10*i)*(99+10*i)\n2*i+3+9999*i+4\n\nOutput for the Sample Input\n\n11\n-37+16i\n9998+2010i\noverflow", "sample_input": "(1-10*i)+00007+(3+10*i)\n3+4*i*(4+10*i)\n(102+10*i)*(99+10*i)\n2*i+3+9999*i+4\n"}, "reference_outputs": ["11\n-37+16i\n9998+2010i\noverflow\n"], "source_document_id": "p00684", "source_text": "Calculation of Expressions\n\nWrite a program to calculate values of arithmetic expressions which may\ninvolve complex numbers. Details of the expressions are described below.\n\nIn this problem, basic elements of expressions are\nnon-negative integer numbers and\nthe special symbol \"i\". Integer numbers are sequences\nof digits of arbitrary length and are in decimal notation. \"i\" denotes the\nunit imaginary number i, i.e. i 2 = -1.\n\nOperators appearing in expressions are + (addition), -\n(subtraction), and * (multiplication). Division is excluded from\nthe repertoire of the operators. All three operators are only used as binary\noperators. Unary plus and minus operators (e.g., -100) are also\nexcluded from the repertoire. Note that the multiplication symbol *\nmay not be omitted in any case. For example, the expression 1+3i\nin mathematics should be written as 1+3*i.\n\nUsual formation rules of arithmetic expressions apply. Namely, (1) The\noperator * binds its operands stronger than the operators +\nand -. (2) The operators + and - have the same\nstrength in operand binding. (3) Two operators of the same strength bind\nfrom left to right. (4) Parentheses are used to designate specific order\nof binding.\n\nThe consequence of these rules can easily be understood from the following\nexamples.\n\n(1) 3+4*5 is 3+(4*5), not (3+4)*5\n\n(2) 5-6+7 is (5-6)+7, not 5-(6+7)\n\n(3) 1+2+3 is (1+2)+3, not 1+(2+3)\n\nYour program should successively read expressions, calculate them and\nprint their results. Overflow should be detected.\n\nWhenever an abnormal value is yielded as a result of applying an operator\nappearing in the given expression,\nyour program should report that the calculation failed due to overflow.\nBy \"an abnormal value\", we mean a value\nwhose real part or imaginary part is\ngreater than 10000 or less than -10000. Here are examples:\n\n10000+1+(0-10)\n\noverflow, not 9991\n\n(10*i+100)*(101+20*i)\n\n9900+3010i , not overflow\n\n4000000-4000000\n\noverflow, not 0\n\nNote that the law of associativity does not necessarily hold in this\nproblem. For example, in the first example,\noverflow is detected by interpreting\nthe expression as (10000+1)+(0-10) following the binding rules,\nwhereas overflow could not be detected\nif you interpreted it as 10000+(1+(0-10)).\nMoreover, overflow detection should take place for resulting value of each\noperation.\n\nIn the second example, a value which exceeds 10000 appears\nin the calculation process of one multiplication\nif you use the mathematical rule\n\n(a+b i)(c+d i)=(ac-bd)+(ad+bc)i\n.\n\nBut the yielded result 9900+3010i does not contain any number\nwhich exceeds 10000 and, therefore, overflow should not be reported.\n\nInput\n\nA sequence of lines each of which contains an expression is given as\ninput. Each line consists of less than 100 characters and does not contain\nany blank spaces. You may assume that all expressions given in the sequence\nare syntactically correct.\n\nOutput\n\nYour program should produce output for each expression line by line.\nIf overflow is detected, output should be\na character string \"overflow\".\nOtherwise, output should be the resulting value of calculation\nin the following fashion.\n\n0 , if the result is 0+0i.\n\n-123 , if the result is -123+0i.\n\n45i , if the result is 0+45i.\n\n3+1i , if the result is 3+i.\n\n123-45i , if the result is 123-45i.\n\nOutput should not contain any blanks, surplus 0,\n+, or -.\n\nSample Input\n\n(1-10*i)+00007+(3+10*i)\n3+4*i*(4+10*i)\n(102+10*i)*(99+10*i)\n2*i+3+9999*i+4\n\nOutput for the Sample Input\n\n11\n-37+16i\n9998+2010i\noverflow", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4348, "cpu_time_ms": 330, "memory_kb": 55560}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s633672087", "group_id": "codeNet:p00710", "input_text": "object Main{\n def cut(cards: Array[Int],p:Int,c:Int): Array[Int] = {\n cards.slice(p-1,p-1+c) ++ cards.take(p-1) ++ cards.drop(p+c-1)\n }\n def main(args: Array[String]){\n var nr = readLine.split(\" \").map( n => n.toInt )\n var n = nr(0)\n var r = nr(1)\n while(n>0&&r>0){\n var cards = new Array[Int](n)\n for(i <- 0 until n) cards(i) = n-i\n for(i <- 0 until r){\n val pc = readLine.split(\" \").map( n => n.toInt )\n val p = pc(0)\n val c = pc(1)\n cards = cut(cards,p,c)\n }\n println( cards.head )\n nr = readLine.split(\" \").map( n => n.toInt )\n n = nr(0)\n r = nr(1)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1475454554, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00710.html", "problem_id": "p00710", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00710/input.txt", "sample_output_relpath": "derived/input_output/data/p00710/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00710/Scala/s633672087.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s633672087", "user_id": "u802625365"}, "prompt_components": {"gold_output": "4\n4\n", "input_to_evaluate": "object Main{\n def cut(cards: Array[Int],p:Int,c:Int): Array[Int] = {\n cards.slice(p-1,p-1+c) ++ cards.take(p-1) ++ cards.drop(p+c-1)\n }\n def main(args: Array[String]){\n var nr = readLine.split(\" \").map( n => n.toInt )\n var n = nr(0)\n var r = nr(1)\n while(n>0&&r>0){\n var cards = new Array[Int](n)\n for(i <- 0 until n) cards(i) = n-i\n for(i <- 0 until r){\n val pc = readLine.split(\" \").map( n => n.toInt )\n val p = pc(0)\n val c = pc(1)\n cards = cut(cards,p,c)\n }\n println( cards.head )\n nr = readLine.split(\" \").map( n => n.toInt )\n n = nr(0)\n r = nr(1)\n }\n }\n}", "problem_context": "Problem A: Hanafuda Shuffle\n\nThere are a number of ways to shuffle a deck of cards. Hanafuda\nshuffling for Japanese card game 'Hanafuda' is one such example.\nThe following is how to perform Hanafuda shuffling.\n\nThere is a deck of n cards. Starting from the p-th card\nfrom the top of the deck, c cards are pulled out\nand put on the top of the deck, as shown in Figure 1.\nThis operation, called a cutting operation, is repeated.\n\nWrite a program that simulates Hanafuda shuffling and answers which\ncard will be finally placed on the top of the deck.\n\nFigure 1: Cutting operation\n\nInput\n\nThe input consists of multiple data sets.\nEach data set starts with a line containing two positive integers n\n(1 <= n <= 50) and r (1 <= r <= 50); n and\nr are the number of cards in the deck and the number of cutting\noperations, respectively.\n\nThere are r more lines in the data set, each of which\nrepresents a cutting operation. These cutting operations\nare performed in the listed order.\nEach line contains two positive integers p and c\n(p + c <= n + 1).\nStarting from the p-th card from the top of the deck, c\ncards should be pulled out and put on the top.\n\nThe end of the input is indicated by a line which contains two zeros.\n\nEach input line contains exactly two integers separated by a space\ncharacter.\nThere are no other characters in the line.\n\nOutput\n\nFor each data set in the input, your program\nshould write the number of the top card after the shuffle.\nAssume that at the beginning the cards\nare numbered from 1 to n, from the bottom to the top.\nEach number should be written in a separate line\nwithout any superfluous characters such as leading or following spaces.\n\nSample Input\n\n5 2\n3 1\n3 1\n10 3\n1 10\n10 1\n8 3\n0 0\n\nOutput for the Sample Input\n\n4\n4", "sample_input": "5 2\n3 1\n3 1\n10 3\n1 10\n10 1\n8 3\n0 0\n"}, "reference_outputs": ["4\n4\n"], "source_document_id": "p00710", "source_text": "Problem A: Hanafuda Shuffle\n\nThere are a number of ways to shuffle a deck of cards. Hanafuda\nshuffling for Japanese card game 'Hanafuda' is one such example.\nThe following is how to perform Hanafuda shuffling.\n\nThere is a deck of n cards. Starting from the p-th card\nfrom the top of the deck, c cards are pulled out\nand put on the top of the deck, as shown in Figure 1.\nThis operation, called a cutting operation, is repeated.\n\nWrite a program that simulates Hanafuda shuffling and answers which\ncard will be finally placed on the top of the deck.\n\nFigure 1: Cutting operation\n\nInput\n\nThe input consists of multiple data sets.\nEach data set starts with a line containing two positive integers n\n(1 <= n <= 50) and r (1 <= r <= 50); n and\nr are the number of cards in the deck and the number of cutting\noperations, respectively.\n\nThere are r more lines in the data set, each of which\nrepresents a cutting operation. These cutting operations\nare performed in the listed order.\nEach line contains two positive integers p and c\n(p + c <= n + 1).\nStarting from the p-th card from the top of the deck, c\ncards should be pulled out and put on the top.\n\nThe end of the input is indicated by a line which contains two zeros.\n\nEach input line contains exactly two integers separated by a space\ncharacter.\nThere are no other characters in the line.\n\nOutput\n\nFor each data set in the input, your program\nshould write the number of the top card after the shuffle.\nAssume that at the beginning the cards\nare numbered from 1 to n, from the bottom to the top.\nEach number should be written in a separate line\nwithout any superfluous characters such as leading or following spaces.\n\nSample Input\n\n5 2\n3 1\n3 1\n10 3\n1 10\n10 1\n8 3\n0 0\n\nOutput for the Sample Input\n\n4\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 650, "cpu_time_ms": 320, "memory_kb": 50052}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s826360968", "group_id": "codeNet:p00710", "input_text": "object Main extends App {\n val in = io.Source.stdin.getLines.map(_.split(\" \").map(_.toInt))\n for (Array(n, r) <- in if n > 0 && r > 0) {\n val m = in.take(r).foldRight(0)((r, i) =>\n if (i >= r(0) - 1 + r(1)) i\n else if (i >= r(1)) i - r(1)\n else i + r(0) - 1 \n )\n println(n - m)\n }\n}", "language": "Scala", "metadata": {"date": 1497867078, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00710.html", "problem_id": "p00710", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00710/input.txt", "sample_output_relpath": "derived/input_output/data/p00710/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00710/Scala/s826360968.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s826360968", "user_id": "u475394465"}, "prompt_components": {"gold_output": "4\n4\n", "input_to_evaluate": "object Main extends App {\n val in = io.Source.stdin.getLines.map(_.split(\" \").map(_.toInt))\n for (Array(n, r) <- in if n > 0 && r > 0) {\n val m = in.take(r).foldRight(0)((r, i) =>\n if (i >= r(0) - 1 + r(1)) i\n else if (i >= r(1)) i - r(1)\n else i + r(0) - 1 \n )\n println(n - m)\n }\n}", "problem_context": "Problem A: Hanafuda Shuffle\n\nThere are a number of ways to shuffle a deck of cards. Hanafuda\nshuffling for Japanese card game 'Hanafuda' is one such example.\nThe following is how to perform Hanafuda shuffling.\n\nThere is a deck of n cards. Starting from the p-th card\nfrom the top of the deck, c cards are pulled out\nand put on the top of the deck, as shown in Figure 1.\nThis operation, called a cutting operation, is repeated.\n\nWrite a program that simulates Hanafuda shuffling and answers which\ncard will be finally placed on the top of the deck.\n\nFigure 1: Cutting operation\n\nInput\n\nThe input consists of multiple data sets.\nEach data set starts with a line containing two positive integers n\n(1 <= n <= 50) and r (1 <= r <= 50); n and\nr are the number of cards in the deck and the number of cutting\noperations, respectively.\n\nThere are r more lines in the data set, each of which\nrepresents a cutting operation. These cutting operations\nare performed in the listed order.\nEach line contains two positive integers p and c\n(p + c <= n + 1).\nStarting from the p-th card from the top of the deck, c\ncards should be pulled out and put on the top.\n\nThe end of the input is indicated by a line which contains two zeros.\n\nEach input line contains exactly two integers separated by a space\ncharacter.\nThere are no other characters in the line.\n\nOutput\n\nFor each data set in the input, your program\nshould write the number of the top card after the shuffle.\nAssume that at the beginning the cards\nare numbered from 1 to n, from the bottom to the top.\nEach number should be written in a separate line\nwithout any superfluous characters such as leading or following spaces.\n\nSample Input\n\n5 2\n3 1\n3 1\n10 3\n1 10\n10 1\n8 3\n0 0\n\nOutput for the Sample Input\n\n4\n4", "sample_input": "5 2\n3 1\n3 1\n10 3\n1 10\n10 1\n8 3\n0 0\n"}, "reference_outputs": ["4\n4\n"], "source_document_id": "p00710", "source_text": "Problem A: Hanafuda Shuffle\n\nThere are a number of ways to shuffle a deck of cards. Hanafuda\nshuffling for Japanese card game 'Hanafuda' is one such example.\nThe following is how to perform Hanafuda shuffling.\n\nThere is a deck of n cards. Starting from the p-th card\nfrom the top of the deck, c cards are pulled out\nand put on the top of the deck, as shown in Figure 1.\nThis operation, called a cutting operation, is repeated.\n\nWrite a program that simulates Hanafuda shuffling and answers which\ncard will be finally placed on the top of the deck.\n\nFigure 1: Cutting operation\n\nInput\n\nThe input consists of multiple data sets.\nEach data set starts with a line containing two positive integers n\n(1 <= n <= 50) and r (1 <= r <= 50); n and\nr are the number of cards in the deck and the number of cutting\noperations, respectively.\n\nThere are r more lines in the data set, each of which\nrepresents a cutting operation. These cutting operations\nare performed in the listed order.\nEach line contains two positive integers p and c\n(p + c <= n + 1).\nStarting from the p-th card from the top of the deck, c\ncards should be pulled out and put on the top.\n\nThe end of the input is indicated by a line which contains two zeros.\n\nEach input line contains exactly two integers separated by a space\ncharacter.\nThere are no other characters in the line.\n\nOutput\n\nFor each data set in the input, your program\nshould write the number of the top card after the shuffle.\nAssume that at the beginning the cards\nare numbered from 1 to n, from the bottom to the top.\nEach number should be written in a separate line\nwithout any superfluous characters such as leading or following spaces.\n\nSample Input\n\n5 2\n3 1\n3 1\n10 3\n1 10\n10 1\n8 3\n0 0\n\nOutput for the Sample Input\n\n4\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 310, "memory_kb": 48676}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s393444165", "group_id": "codeNet:p00729", "input_text": "import scala.collection.mutable._\nimport io.StdIn.readInt\nimport io.StdIn.readLine\n\nobject Main extends App {\n val out = new java.io.PrintWriter(System.out)\n\n def calculate(q:Array[Int],d:Array[Array[Int]]):Int = {\n val ts = q(0)\n val te = q(1)\n val st = q(2)\n\n val a = d.filter(_(2) == st)\n val map = new HashMap[Int,Array[Int]]\n val log = ListBuffer.empty[Tuple2[Int,Int]]\n a.foreach(l => {\n if(l(3) == 1) map.put(l(1),l)\n else {\n val e = map.remove(l(1)).get\n log += {( e(0), l(0) )}\n }\n })\n // println(log.mkString)\n\n val time = Array.ofDim[Int](721)\n log.par.foreach(t => {\n val s = math.max(ts, t._1) -540\n val e = math.min(te, t._2) -540\n (s until e).foreach(time(_) = 1)\n })\n time.sum\n }\n\n def solve(s:String):Unit = {\n val Array(n, m) = s.split(\" \").map(_.toInt)\n val r = readInt\n val d = Iterator.continually(readLine)\n .take(r)\n .map(_.split(\" \").map(_.toInt))\n .toArray\n val q = readInt\n Iterator.continually(readLine)\n .take(q)\n .map(_.split(\" \").map(_.toInt))\n .foreach(qd => out.println(calculate(qd,d)))\n }\n\n Iterator.continually(readLine)\n .takeWhile(_ != \"0 0\")\n .foreach(solve(_))\n \n out.flush\n}\n", "language": "Scala", "metadata": {"date": 1545379694, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00729.html", "problem_id": "p00729", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00729/input.txt", "sample_output_relpath": "derived/input_output/data/p00729/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00729/Scala/s393444165.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s393444165", "user_id": "u768801062"}, "prompt_components": {"gold_output": "55\n70\n30\n0\n0\n50\n10\n50\n0\n", "input_to_evaluate": "import scala.collection.mutable._\nimport io.StdIn.readInt\nimport io.StdIn.readLine\n\nobject Main extends App {\n val out = new java.io.PrintWriter(System.out)\n\n def calculate(q:Array[Int],d:Array[Array[Int]]):Int = {\n val ts = q(0)\n val te = q(1)\n val st = q(2)\n\n val a = d.filter(_(2) == st)\n val map = new HashMap[Int,Array[Int]]\n val log = ListBuffer.empty[Tuple2[Int,Int]]\n a.foreach(l => {\n if(l(3) == 1) map.put(l(1),l)\n else {\n val e = map.remove(l(1)).get\n log += {( e(0), l(0) )}\n }\n })\n // println(log.mkString)\n\n val time = Array.ofDim[Int](721)\n log.par.foreach(t => {\n val s = math.max(ts, t._1) -540\n val e = math.min(te, t._2) -540\n (s until e).foreach(time(_) = 1)\n })\n time.sum\n }\n\n def solve(s:String):Unit = {\n val Array(n, m) = s.split(\" \").map(_.toInt)\n val r = readInt\n val d = Iterator.continually(readLine)\n .take(r)\n .map(_.split(\" \").map(_.toInt))\n .toArray\n val q = readInt\n Iterator.continually(readLine)\n .take(q)\n .map(_.split(\" \").map(_.toInt))\n .foreach(qd => out.println(calculate(qd,d)))\n }\n\n Iterator.continually(readLine)\n .takeWhile(_ != \"0 0\")\n .foreach(solve(_))\n \n out.flush\n}\n", "problem_context": "Problem B: Analyzing Login/Logout Records\n\nYou have a computer literacy course in your university. In the computer\nsystem, the login/logout records of all PCs in a day are stored in a\nfile. Although students may use two or more PCs at a time, no one can\nlog in to a PC which has been logged in by someone who has not\nlogged out of that PC yet.\n\nYou are asked to write a program that calculates the total time of a\nstudent that he/she used at least one PC in a given time period\n(probably in a laboratory class) based on the records in the file.\n\nThe following are example login/logout records.\n\nThe student 1 logged in to the PC 1 at 12:55\n\nThe student 2 logged in to the PC 4 at 13:00\n\nThe student 1 logged in to the PC 2 at 13:10\n\nThe student 1 logged out of the PC 2 at 13:20\n\nThe student 1 logged in to the PC 3 at 13:30\n\nThe student 1 logged out of the PC 1 at 13:40\n\nThe student 1 logged out of the PC 3 at 13:45\n\nThe student 1 logged in to the PC 1 at 14:20\n\nThe student 2 logged out of the PC 4 at 14:30\n\nThe student 1 logged out of the PC 1 at 14:40\n\nFor a query such as \"Give usage of the student 1 between 13:00 and\n14:30\", your program should answer \"55 minutes\", that is, the sum of\n45 minutes from 13:00 to 13:45 and 10 minutes from 14:20 to 14:30, as\ndepicted in the following figure.\n\nInput\n\nThe input is a sequence of a number of datasets.\nThe end of the input is indicated by a line containing two zeros\nseparated by a space.\nThe number of datasets never exceeds 10.\n\nEach dataset is formatted as follows.\n\nN M \n\nr \n\nrecord1\n\n...\n\nrecordr \n\nq \n\nquery1\n\n...\n\nqueryq \n\nThe numbers N  and M  in the first line are the numbers of\nPCs and the students, respectively. r  is the number of\nrecords. q  is the number of queries. These four are integers\nsatisfying the following.\n\n1 ≤ N  ≤ 1000, 1 ≤ M  ≤ 10000, 2 ≤ r  ≤ 1000, 1 ≤ q  ≤ 50\n\nEach record consists of four integers, delimited by a space, as follows.\n\nt  n  m  s \n\ns  is 0 or 1.\nIf s  is 1, this line means that the student m  logged in\nto the PC n  at time t . If s  is 0, it means that\nthe student m  logged out of the PC n  at time t .\nThe time is expressed as elapsed minutes from 0:00 of the day.\nt , n  and m  satisfy the following.\n\n540 ≤ t  ≤ 1260,\n1 ≤ n  ≤ N , 1 ≤ m  ≤ M \n\nYou may assume the following about the records.\n\nRecords are stored in ascending order of time t. \n\nNo two records for the same PC has the same time t. \n\nNo PCs are being logged in before the time of the first record\nnor after that of the last record in the file.\n\nLogin and logout records for one PC appear alternatingly, and each of the login-logout record pairs is for the same student.\n\nEach query consists of three integers delimited by a space, as follows.\n\nts  te  m \n\nIt represents \"Usage of the student m  between\nts  and te \".\nts , te  and m \nsatisfy the following.\n\n540 ≤ ts  < te  ≤ 1260,\n1 ≤ m  ≤ M \n\nOutput\n\nFor each query, print a line having a decimal integer indicating the\ntime of usage in minutes. Output lines should not have any character\nother than this number.\n\nSample Input\n\n4 2\n10\n775 1 1 1\n780 4 2 1\n790 2 1 1\n800 2 1 0\n810 3 1 1\n820 1 1 0\n825 3 1 0\n860 1 1 1\n870 4 2 0\n880 1 1 0\n1\n780 870 1\n13 15\n12\n540 12 13 1\n600 12 13 0\n650 13 15 1\n660 12 15 1\n665 11 13 1\n670 13 15 0\n675 11 13 0\n680 12 15 0\n1000 11 14 1\n1060 12 14 1\n1060 11 14 0\n1080 12 14 0\n3\n540 700 13\n600 1000 15\n1000 1200 11\n1 1\n2\n600 1 1 1\n700 1 1 0\n5\n540 600 1\n550 650 1\n610 620 1\n650 750 1\n700 800 1\n0 0\n\nOutput for the Sample Input\n\n55\n70\n30\n0\n0\n50\n10\n50\n0", "sample_input": "4 2\n10\n775 1 1 1\n780 4 2 1\n790 2 1 1\n800 2 1 0\n810 3 1 1\n820 1 1 0\n825 3 1 0\n860 1 1 1\n870 4 2 0\n880 1 1 0\n1\n780 870 1\n13 15\n12\n540 12 13 1\n600 12 13 0\n650 13 15 1\n660 12 15 1\n665 11 13 1\n670 13 15 0\n675 11 13 0\n680 12 15 0\n1000 11 14 1\n1060 12 14 1\n1060 11 14 0\n1080 12 14 0\n3\n540 700 13\n600 1000 15\n1000 1200 11\n1 1\n2\n600 1 1 1\n700 1 1 0\n5\n540 600 1\n550 650 1\n610 620 1\n650 750 1\n700 800 1\n0 0\n"}, "reference_outputs": ["55\n70\n30\n0\n0\n50\n10\n50\n0\n"], "source_document_id": "p00729", "source_text": "Problem B: Analyzing Login/Logout Records\n\nYou have a computer literacy course in your university. In the computer\nsystem, the login/logout records of all PCs in a day are stored in a\nfile. Although students may use two or more PCs at a time, no one can\nlog in to a PC which has been logged in by someone who has not\nlogged out of that PC yet.\n\nYou are asked to write a program that calculates the total time of a\nstudent that he/she used at least one PC in a given time period\n(probably in a laboratory class) based on the records in the file.\n\nThe following are example login/logout records.\n\nThe student 1 logged in to the PC 1 at 12:55\n\nThe student 2 logged in to the PC 4 at 13:00\n\nThe student 1 logged in to the PC 2 at 13:10\n\nThe student 1 logged out of the PC 2 at 13:20\n\nThe student 1 logged in to the PC 3 at 13:30\n\nThe student 1 logged out of the PC 1 at 13:40\n\nThe student 1 logged out of the PC 3 at 13:45\n\nThe student 1 logged in to the PC 1 at 14:20\n\nThe student 2 logged out of the PC 4 at 14:30\n\nThe student 1 logged out of the PC 1 at 14:40\n\nFor a query such as \"Give usage of the student 1 between 13:00 and\n14:30\", your program should answer \"55 minutes\", that is, the sum of\n45 minutes from 13:00 to 13:45 and 10 minutes from 14:20 to 14:30, as\ndepicted in the following figure.\n\nInput\n\nThe input is a sequence of a number of datasets.\nThe end of the input is indicated by a line containing two zeros\nseparated by a space.\nThe number of datasets never exceeds 10.\n\nEach dataset is formatted as follows.\n\nN M \n\nr \n\nrecord1\n\n...\n\nrecordr \n\nq \n\nquery1\n\n...\n\nqueryq \n\nThe numbers N  and M  in the first line are the numbers of\nPCs and the students, respectively. r  is the number of\nrecords. q  is the number of queries. These four are integers\nsatisfying the following.\n\n1 ≤ N  ≤ 1000, 1 ≤ M  ≤ 10000, 2 ≤ r  ≤ 1000, 1 ≤ q  ≤ 50\n\nEach record consists of four integers, delimited by a space, as follows.\n\nt  n  m  s \n\ns  is 0 or 1.\nIf s  is 1, this line means that the student m  logged in\nto the PC n  at time t . If s  is 0, it means that\nthe student m  logged out of the PC n  at time t .\nThe time is expressed as elapsed minutes from 0:00 of the day.\nt , n  and m  satisfy the following.\n\n540 ≤ t  ≤ 1260,\n1 ≤ n  ≤ N , 1 ≤ m  ≤ M \n\nYou may assume the following about the records.\n\nRecords are stored in ascending order of time t. \n\nNo two records for the same PC has the same time t. \n\nNo PCs are being logged in before the time of the first record\nnor after that of the last record in the file.\n\nLogin and logout records for one PC appear alternatingly, and each of the login-logout record pairs is for the same student.\n\nEach query consists of three integers delimited by a space, as follows.\n\nts  te  m \n\nIt represents \"Usage of the student m  between\nts  and te \".\nts , te  and m \nsatisfy the following.\n\n540 ≤ ts  < te  ≤ 1260,\n1 ≤ m  ≤ M \n\nOutput\n\nFor each query, print a line having a decimal integer indicating the\ntime of usage in minutes. Output lines should not have any character\nother than this number.\n\nSample Input\n\n4 2\n10\n775 1 1 1\n780 4 2 1\n790 2 1 1\n800 2 1 0\n810 3 1 1\n820 1 1 0\n825 3 1 0\n860 1 1 1\n870 4 2 0\n880 1 1 0\n1\n780 870 1\n13 15\n12\n540 12 13 1\n600 12 13 0\n650 13 15 1\n660 12 15 1\n665 11 13 1\n670 13 15 0\n675 11 13 0\n680 12 15 0\n1000 11 14 1\n1060 12 14 1\n1060 11 14 0\n1080 12 14 0\n3\n540 700 13\n600 1000 15\n1000 1200 11\n1 1\n2\n600 1 1 1\n700 1 1 0\n5\n540 600 1\n550 650 1\n610 620 1\n650 750 1\n700 800 1\n0 0\n\nOutput for the Sample Input\n\n55\n70\n30\n0\n0\n50\n10\n50\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1259, "cpu_time_ms": 700, "memory_kb": 65712}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s355862101", "group_id": "codeNet:p00837", "input_text": "import java.util.Scanner\n\nimport scala.collection.Searching._\nimport scala.annotation.tailrec\nimport scala.collection.immutable.Queue\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(new Node(None, 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n @tailrec\n private def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) => root(p)\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n var M, C, N = sc.nextInt\n var i = 0\n var f = true\n while (M != 0 && C != 0 && N != 0) {\n val A = Array.fill(N)(Array.fill(sc.nextInt)(sc.nextInt))\n var B = List.fill(0)(0)\n for (j <- 0 until 100) {\n for (i <- 0 until N) {\n if (j < A(i).size) {\n B = B :+ A(i)(j)\n }\n }\n }\n\n System.gc()\n\n val que = Array.fill[Queue[Int]](M)(Queue[Int]())\n var ans = 0\n for (x <- B) {\n var findpoint = M\n i = 0\n f = true\n while (i < M && f) {\n val findindex = que(i).indexOf(x)\n if (findindex != -1) {\n que(i) = que(i).take(findindex - 1) ++ que(i).drop(findindex + 1)\n //println(findindex)\n //println(que(i).take(findindex - 1))\n // println(que(i).drop(findindex + 1))\n findpoint = i\n f = false\n }\n i += 1\n }\n ans += findpoint + 1\n var returnpoint = M\n i = 0\n while (i < M) {\n if (que(i).size < C) {\n returnpoint = math.min(returnpoint, i)\n }\n i += 1\n }\n ans += returnpoint + 1\n //println(\"--\", ans)\n if (returnpoint == 0) {\n que(0) ++= List(x)\n } else {\n var returnpoint2 = M\n i = 0\n f = true\n while (i < M && f) {\n if (que(i).size + (if (returnpoint == i) (1) else (0)) + 1 <= C) {\n returnpoint2 = math.min(returnpoint2, i)\n f = false\n }\n i += 1\n }\n if (returnpoint != 0) {\n ans += 1 + returnpoint2 + 1\n //println(\"--\",ans)\n val first = que(0).head\n que(0) = que(0).drop(1)\n if (returnpoint2 != M) {\n que(returnpoint2) ++= List(first)\n }\n }\n que(0) ++= List(x)\n ans += 1 + returnpoint + 1\n //println(\"--\",ans,returnpoint)\n }\n //println(que.mkString(\" \"))\n //println(ans)\n }\n println(ans)\n M = sc.nextInt\n C = sc.nextInt\n N = sc.nextInt\n System.gc()\n }\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n\n solve(sc)\n }\n\n}", "language": "Scala", "metadata": {"date": 1510138393, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00837.html", "problem_id": "p00837", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00837/input.txt", "sample_output_relpath": "derived/input_output/data/p00837/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00837/Scala/s355862101.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Memory Limit Exceeded", "submission_id": "s355862101", "user_id": "u018134297"}, "prompt_components": {"gold_output": "4\n16\n28\n68\n58\n98\n23\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.collection.Searching._\nimport scala.annotation.tailrec\nimport scala.collection.immutable.Queue\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(new Node(None, 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n @tailrec\n private def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) => root(p)\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n var M, C, N = sc.nextInt\n var i = 0\n var f = true\n while (M != 0 && C != 0 && N != 0) {\n val A = Array.fill(N)(Array.fill(sc.nextInt)(sc.nextInt))\n var B = List.fill(0)(0)\n for (j <- 0 until 100) {\n for (i <- 0 until N) {\n if (j < A(i).size) {\n B = B :+ A(i)(j)\n }\n }\n }\n\n System.gc()\n\n val que = Array.fill[Queue[Int]](M)(Queue[Int]())\n var ans = 0\n for (x <- B) {\n var findpoint = M\n i = 0\n f = true\n while (i < M && f) {\n val findindex = que(i).indexOf(x)\n if (findindex != -1) {\n que(i) = que(i).take(findindex - 1) ++ que(i).drop(findindex + 1)\n //println(findindex)\n //println(que(i).take(findindex - 1))\n // println(que(i).drop(findindex + 1))\n findpoint = i\n f = false\n }\n i += 1\n }\n ans += findpoint + 1\n var returnpoint = M\n i = 0\n while (i < M) {\n if (que(i).size < C) {\n returnpoint = math.min(returnpoint, i)\n }\n i += 1\n }\n ans += returnpoint + 1\n //println(\"--\", ans)\n if (returnpoint == 0) {\n que(0) ++= List(x)\n } else {\n var returnpoint2 = M\n i = 0\n f = true\n while (i < M && f) {\n if (que(i).size + (if (returnpoint == i) (1) else (0)) + 1 <= C) {\n returnpoint2 = math.min(returnpoint2, i)\n f = false\n }\n i += 1\n }\n if (returnpoint != 0) {\n ans += 1 + returnpoint2 + 1\n //println(\"--\",ans)\n val first = que(0).head\n que(0) = que(0).drop(1)\n if (returnpoint2 != M) {\n que(returnpoint2) ++= List(first)\n }\n }\n que(0) ++= List(x)\n ans += 1 + returnpoint + 1\n //println(\"--\",ans,returnpoint)\n }\n //println(que.mkString(\" \"))\n //println(ans)\n }\n println(ans)\n M = sc.nextInt\n C = sc.nextInt\n N = sc.nextInt\n System.gc()\n }\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n\n solve(sc)\n }\n\n}", "problem_context": "Problem B: Book Replacement\n\nThe deadline of Prof. Hachioji’s assignment is tomorrow. To complete the task, students have\nto copy pages of many reference books in the library.\n\nAll the reference books are in a storeroom and only the librarian is allowed to enter it. To obtain\na copy of a reference book’s page, a student should ask the librarian to make it. The librarian\nbrings books out of the storeroom and makes page copies according to the requests. The overall\nsituation is shown in Figure 1.\n\nStudents queue up in front of the counter. Only a single book can be requested at a time. If a\nstudent has more requests, the student goes to the end of the queue after the request has been\nserved.\n\nIn the storeroom, there are m desks D1, ... , Dm, and a shelf. They are placed in a line in this\norder, from the door to the back of the room. Up to c books can be put on each of the desks. If\na student requests a book, the librarian enters the storeroom and looks for it on D1, ... , Dm in\nthis order, and then on the shelf. After finding the book, the librarian takes it and gives a copy\nof a page to the student.\n\nThen the librarian returns to the storeroom with the requested book, to put it on D1 according to the following procedure.\n\nIf D1 is not full (in other words, the number of books on D1 < c), the librarian puts the requested book there.\n\nIf D1 is full, the librarian\n\ntemporarily puts the requested book on the non-full desk closest to the entrance or,\nin case all the desks are full, on the shelf,\n\nfinds the book on D1 that has not been requested for the longest time (i.e. the least recently used book) and takes it,\n\nputs it on the non-full desk (except D1 ) closest to the entrance or, in case all the desks except D1 are full, on the shelf,\n\ntakes the requested book from the temporary place,\n\nand finally puts it on D1 .\n\nYour task is to write a program which simulates the behaviors of the students and the librarian,\nand evaluates the total cost of the overall process. Costs are associated with accessing a desk\nor the shelf, that is, putting/taking a book on/from it in the description above. The cost of an\naccess is i for desk Di and m + 1 for the shelf. That is, an access to D1, ... , Dm , and the shelf\ncosts 1, ... , m, and m + 1, respectively. Costs of other actions are ignored.\n\nInitially, no books are put on desks. No new students appear after opening the library.\n\nInput\n\nThe input consists of multiple datasets. The end of the input is indicated by a line containing\nthree zeros separated by a space. It is not a dataset.\n\nThe format of each dataset is as follows.\n\nm c n\nk1\nb11 . . . b1k1\n.\n.\n.\nkn\nbn1 . . . bnkn\n\nHere, all data items are positive integers. m is the number of desks not exceeding 10. c is the number of books allowed to put on a desk, which does not exceed 30. n is the number of\nstudents not exceeding 100. ki is the number of books requested by the i-th student, which does\nnot exceed 50. bij is the ID number of the book requested by the i-th student on the j-th turn.\nNo two books have the same ID number. Note that a student may request the same book more\nthan once. bij is less than 100.\n\nHere we show you an example of cost calculation for the following dataset.\n\n3 1 2\n3\n60 61 62\n2\n70 60\n\nIn this dataset, there are 3 desks (D1, D2, D3 ). At most 1 book can be put on each desk. The\nnumber of students is 2. The first student requests 3 books of which IDs are 60, 61, and 62,\nrespectively, and the second student 2 books of which IDs are 70 and 60, respectively.\n\nThe calculation of the cost for this dataset is done as follows. First, for the first request of the\nfirst student, the librarian takes the book 60 from the shelf and puts it on D1 and the first\nstudent goes to the end of the queue, costing 5. Next, for the first request of the second student,\nthe librarian takes the book 70 from the shelf, puts it on D2, moves the book 60 from D1 to D3 ,\nand finally moves the book 70 from D2 to D1 , costing 13. Similarly, the cost for the books 61,\n60, and 62, are calculated as 14, 12, 14, respectively. Therefore, the total cost is 58.\n\nOutput\n\nFor each dataset, output the total cost of processing all the requests, in a separate line.\n\nSample Input\n\n2 1 1\n1\n50\n2 1 2\n1\n50\n1\n60\n2 1 2\n2\n60 61\n1\n70\n4 2 3\n3\n60 61 62\n1\n70\n2\n80 81\n3 1 2\n3\n60 61 62\n2\n70 60\n1 2 5\n2\n87 95\n3\n96 71 35\n2\n68 2\n3\n3 18 93\n2\n57 2\n2 2 1\n5\n1 2 1 3 1\n0 0 0\n\nOutput for the Sample Input\n\n4\n16\n28\n68\n58\n98\n23", "sample_input": "2 1 1\n1\n50\n2 1 2\n1\n50\n1\n60\n2 1 2\n2\n60 61\n1\n70\n4 2 3\n3\n60 61 62\n1\n70\n2\n80 81\n3 1 2\n3\n60 61 62\n2\n70 60\n1 2 5\n2\n87 95\n3\n96 71 35\n2\n68 2\n3\n3 18 93\n2\n57 2\n2 2 1\n5\n1 2 1 3 1\n0 0 0\n"}, "reference_outputs": ["4\n16\n28\n68\n58\n98\n23\n"], "source_document_id": "p00837", "source_text": "Problem B: Book Replacement\n\nThe deadline of Prof. Hachioji’s assignment is tomorrow. To complete the task, students have\nto copy pages of many reference books in the library.\n\nAll the reference books are in a storeroom and only the librarian is allowed to enter it. To obtain\na copy of a reference book’s page, a student should ask the librarian to make it. The librarian\nbrings books out of the storeroom and makes page copies according to the requests. The overall\nsituation is shown in Figure 1.\n\nStudents queue up in front of the counter. Only a single book can be requested at a time. If a\nstudent has more requests, the student goes to the end of the queue after the request has been\nserved.\n\nIn the storeroom, there are m desks D1, ... , Dm, and a shelf. They are placed in a line in this\norder, from the door to the back of the room. Up to c books can be put on each of the desks. If\na student requests a book, the librarian enters the storeroom and looks for it on D1, ... , Dm in\nthis order, and then on the shelf. After finding the book, the librarian takes it and gives a copy\nof a page to the student.\n\nThen the librarian returns to the storeroom with the requested book, to put it on D1 according to the following procedure.\n\nIf D1 is not full (in other words, the number of books on D1 < c), the librarian puts the requested book there.\n\nIf D1 is full, the librarian\n\ntemporarily puts the requested book on the non-full desk closest to the entrance or,\nin case all the desks are full, on the shelf,\n\nfinds the book on D1 that has not been requested for the longest time (i.e. the least recently used book) and takes it,\n\nputs it on the non-full desk (except D1 ) closest to the entrance or, in case all the desks except D1 are full, on the shelf,\n\ntakes the requested book from the temporary place,\n\nand finally puts it on D1 .\n\nYour task is to write a program which simulates the behaviors of the students and the librarian,\nand evaluates the total cost of the overall process. Costs are associated with accessing a desk\nor the shelf, that is, putting/taking a book on/from it in the description above. The cost of an\naccess is i for desk Di and m + 1 for the shelf. That is, an access to D1, ... , Dm , and the shelf\ncosts 1, ... , m, and m + 1, respectively. Costs of other actions are ignored.\n\nInitially, no books are put on desks. No new students appear after opening the library.\n\nInput\n\nThe input consists of multiple datasets. The end of the input is indicated by a line containing\nthree zeros separated by a space. It is not a dataset.\n\nThe format of each dataset is as follows.\n\nm c n\nk1\nb11 . . . b1k1\n.\n.\n.\nkn\nbn1 . . . bnkn\n\nHere, all data items are positive integers. m is the number of desks not exceeding 10. c is the number of books allowed to put on a desk, which does not exceed 30. n is the number of\nstudents not exceeding 100. ki is the number of books requested by the i-th student, which does\nnot exceed 50. bij is the ID number of the book requested by the i-th student on the j-th turn.\nNo two books have the same ID number. Note that a student may request the same book more\nthan once. bij is less than 100.\n\nHere we show you an example of cost calculation for the following dataset.\n\n3 1 2\n3\n60 61 62\n2\n70 60\n\nIn this dataset, there are 3 desks (D1, D2, D3 ). At most 1 book can be put on each desk. The\nnumber of students is 2. The first student requests 3 books of which IDs are 60, 61, and 62,\nrespectively, and the second student 2 books of which IDs are 70 and 60, respectively.\n\nThe calculation of the cost for this dataset is done as follows. First, for the first request of the\nfirst student, the librarian takes the book 60 from the shelf and puts it on D1 and the first\nstudent goes to the end of the queue, costing 5. Next, for the first request of the second student,\nthe librarian takes the book 70 from the shelf, puts it on D2, moves the book 60 from D1 to D3 ,\nand finally moves the book 70 from D2 to D1 , costing 13. Similarly, the cost for the books 61,\n60, and 62, are calculated as 14, 12, 14, respectively. Therefore, the total cost is 58.\n\nOutput\n\nFor each dataset, output the total cost of processing all the requests, in a separate line.\n\nSample Input\n\n2 1 1\n1\n50\n2 1 2\n1\n50\n1\n60\n2 1 2\n2\n60 61\n1\n70\n4 2 3\n3\n60 61 62\n1\n70\n2\n80 81\n3 1 2\n3\n60 61 62\n2\n70 60\n1 2 5\n2\n87 95\n3\n96 71 35\n2\n68 2\n3\n3 18 93\n2\n57 2\n2 2 1\n5\n1 2 1 3 1\n0 0 0\n\nOutput for the Sample Input\n\n4\n16\n28\n68\n58\n98\n23", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3272, "cpu_time_ms": 3510, "memory_kb": 365428}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s785708014", "group_id": "codeNet:p00898", "input_text": "import scala.annotation.tailrec\n\nobject Main extends App {\n\n override def main(args: Array[String]): Unit = {\n val answerMap = Solver.solveAll\n import scala.io.{StdIn => in}\n Iterator.continually(in.readLine()).takeWhile(str => !(str startsWith \"0 0 0\")).map(_.split(\" \")).map(arr => new Solver(arr(0).toInt, arr(1).toInt, arr(2).toInt))\n .map(solver => solver.solve(answerMap)).foreach(println)\n }\n\n}\n\n\nsealed trait Coordination {\n val x: Int\n val y: Int\n}\n\nobject Coordination {\n def apply(x: Int, y: Int): Coordination =\n if (((x + y) & 1) == 1) OddCoordination(x, y)\n else EvenCoordination(x, y)\n\n}\n\ncase class OddCoordination(x: Int, y: Int) extends Coordination {}\n\ncase class EvenCoordination(x: Int, y: Int) extends Coordination {}\n\ncase class Face(bottom: Int, southOrNorth: Int)\n\nsealed trait CoordinationAndFace {\n val coordination: Coordination\n val face: Face\n\n def next: Seq[CoordinationAndFace]\n\n val toKeySring: String = List(coordination.x, coordination.y, face.bottom, face.southOrNorth).mkString(\",\")\n}\n\nobject CoordinationAndFace {\n def apply(coordination: Coordination, face: Face): CoordinationAndFace = {\n coordination match {\n case e: EvenCoordination => EvenCoordinationAndFace(e, face)\n case o: OddCoordination => OddCoordinationAndFace(o, face)\n }\n }\n}\n\ncase class EvenCoordinationAndFace(coordination: EvenCoordination, face: Face) extends CoordinationAndFace {\n override def next = Seq(toNorth, toSouthEast, toSouthWest)\n\n val now = IcosahedronFaces(face.bottom)(face.southOrNorth)\n\n def toNorth: CoordinationAndFace = {\n val newCoordination = Coordination(coordination.x, coordination.y + 1)\n val nextFace = IcosahedronFaces(now.top)(now.n)\n val newFace = Face(nextFace.n, nextFace.top)\n CoordinationAndFace(newCoordination, newFace)\n }\n\n def toSouthWest: CoordinationAndFace = {\n val newCoordination = Coordination(coordination.x - 1, coordination.y)\n val nextFace = IcosahedronFaces(now.right)(now.n)\n val newFace = Face(nextFace.n, nextFace.left)\n CoordinationAndFace(newCoordination, newFace)\n }\n\n def toSouthEast: CoordinationAndFace = {\n val newCoordination = Coordination(coordination.x + 1, coordination.y)\n val nextFace = IcosahedronFaces(now.left)(now.n)\n val newFace = Face(nextFace.n, nextFace.right)\n CoordinationAndFace(newCoordination, newFace)\n }\n}\n\ncase class OddCoordinationAndFace(coordination: OddCoordination, face: Face) extends CoordinationAndFace {\n override def next = Seq(toSouth, toNorthEast, toNorthWest)\n\n val now = IcosahedronFaces(face.bottom)(face.southOrNorth)\n\n def toSouth: CoordinationAndFace = {\n val newCoordination = Coordination(coordination.x, coordination.y - 1)\n val nextFace = IcosahedronFaces(now.top)(now.n)\n val newFace = Face(nextFace.n, nextFace.top)\n CoordinationAndFace(newCoordination, newFace)\n }\n\n def toNorthWest: CoordinationAndFace = {\n val newCoordination = Coordination(coordination.x - 1, coordination.y)\n val nextFace = IcosahedronFaces(now.left)(now.n)\n val newFace = Face(nextFace.n, nextFace.right)\n CoordinationAndFace(newCoordination, newFace)\n }\n\n def toNorthEast: CoordinationAndFace = {\n val newCoordination = Coordination(coordination.x + 1, coordination.y)\n val nextFace = IcosahedronFaces(now.right)(now.n)\n val newFace = Face(nextFace.n, nextFace.left)\n CoordinationAndFace(newCoordination, newFace)\n }\n\n}\n\nsealed case class IcosahedronFace(n: Int, top: Int, left: Int, right: Int) {\n def apply(asTop: Int): IcosahedronFace = {\n asTop match {\n case `top` => this\n case `left` => IcosahedronFace(n, left, right, top)\n case `right` => IcosahedronFace(n, right, top, left)\n }\n }\n}\n\nobject IcosahedronFaces {\n private val list = List(\n IcosahedronFace(0, 5, 1, 4),\n IcosahedronFace(1, 6, 2, 0),\n IcosahedronFace(2, 7, 3, 1),\n IcosahedronFace(3, 8, 4, 2),\n IcosahedronFace(4, 9, 0, 3),\n IcosahedronFace(5, 0, 10, 11),\n IcosahedronFace(6, 1, 11, 12),\n IcosahedronFace(7, 2, 12, 13),\n IcosahedronFace(8, 3, 13, 14),\n IcosahedronFace(9, 4, 14, 10),\n IcosahedronFace(10, 15, 5, 9),\n IcosahedronFace(11, 16, 6, 5),\n IcosahedronFace(12, 17, 7, 6),\n IcosahedronFace(13, 18, 8, 7),\n IcosahedronFace(14, 19, 9, 8),\n IcosahedronFace(15, 10, 19, 16),\n IcosahedronFace(16, 11, 15, 17),\n IcosahedronFace(17, 12, 16, 18),\n IcosahedronFace(18, 13, 17, 19),\n IcosahedronFace(19, 14, 18, 15)\n )\n\n def apply(n: Int): IcosahedronFace = n match {\n case n: Int if ((0 to 19).contains(n)) => list(n)\n }\n}\n\n\nclass Solver(x: Int, y: Int, n: Int) {\n\n import Solver._\n\n def solve(answerMap: Array[Int]): Int = {\n if (-100 > x || -100 > y || x >= 100 || y >= 100) {\n val coordination = Coordination(x, y)\n val missing = coordination match {\n case e: EvenCoordination => 100\n case o: OddCoordination => 99\n }\n return missing\n }\n\n val coordination = Coordination(x, y)\n val missing = coordination match {\n case e: EvenCoordination => 100\n case o: OddCoordination => 99\n }\n\n val iface = IcosahedronFaces(n)\n\n val keys = List(\n CoordinationAndFace(coordination, Face(n, iface.top)),\n CoordinationAndFace(coordination, Face(n, iface.left)),\n CoordinationAndFace(coordination, Face(n, iface.right))\n )\n\n keys.map(cf => answerMap(coordinationAndFaceToInt(cf))).map(v => if (v == 0) missing else v).min\n }\n\n}\n\nobject Solver {\n\n def solveAll: Array[Int] = {\n val init: CoordinationAndFace = CoordinationAndFace(Coordination(0, 0), Face(0, 5))\n\n import scala.collection.mutable.{Queue => MQueue}\n\n def solveInner(map: Array[Int], queue: MQueue[(Int, Int)]): Boolean = {\n val head = queue.dequeue()\n if (head._2 < 98) {\n val candidate = intToCoordinationAndFace(head._1).next\n val nextCost = head._2 + 1\n candidate.filter(cf => map(coordinationAndFaceToInt(cf)) == 0).foreach {\n next =>\n map(coordinationAndFaceToInt(next)) = nextCost\n queue.enqueue((coordinationAndFaceToInt( next), nextCost))\n }\n true\n }\n else false\n }\n\n val map = Array.ofDim[Int](xWidth * xPosition)\n val queue = MQueue(coordinationAndFaceToInt(init) -> 0)\n while(solveInner(map, queue)){}\n map\n }\n\n val xOffset = 100\n val yOffset = 100\n val xWidth = 200\n val yWidth = 200\n val bottomWidth = 20\n val southOrNorthWidth = 20\n\n val southOrNorthPosition = 1\n val bottom = southOrNorthWidth * southOrNorthPosition\n val yPosition = bottomWidth * bottom\n val xPosition = yWidth * yPosition\n\n def toInt(x: Int, y: Int, buttom: Int, southOrNorth: Int): Int = {\n (x + xOffset) * xPosition + (y + yOffset) * yPosition + (buttom) * bottom + (southOrNorth) * southOrNorthPosition\n }\n\n def fromInt(int: Int): (Int, Int, Int, Int) = {\n ((int / xPosition) - xOffset, (int / yPosition) % yWidth - yOffset, (int / bottom) % bottomWidth, (int / southOrNorthPosition) % southOrNorthWidth)\n }\n\n def coordinationAndFaceToInt(coordinationAndFace: CoordinationAndFace): Int = {\n val x = coordinationAndFace.coordination.x\n val y = coordinationAndFace.coordination.y\n val bottom = coordinationAndFace.face.bottom\n val southOrNorth = coordinationAndFace.face.southOrNorth\n toInt(x, y, bottom, southOrNorth)\n }\n\n def intToCoordinationAndFace(int: Int): CoordinationAndFace = {\n val (x, y, bottom, southOrNorth) = fromInt(int)\n CoordinationAndFace(Coordination(x, y), Face(bottom, southOrNorth))\n }\n\n}", "language": "Scala", "metadata": {"date": 1491264153, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00898.html", "problem_id": "p00898", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00898/input.txt", "sample_output_relpath": "derived/input_output/data/p00898/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00898/Scala/s785708014.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Memory Limit Exceeded", "submission_id": "s785708014", "user_id": "u825684692"}, "prompt_components": {"gold_output": "6\n10\n9\n30\n47\n100\n", "input_to_evaluate": "import scala.annotation.tailrec\n\nobject Main extends App {\n\n override def main(args: Array[String]): Unit = {\n val answerMap = Solver.solveAll\n import scala.io.{StdIn => in}\n Iterator.continually(in.readLine()).takeWhile(str => !(str startsWith \"0 0 0\")).map(_.split(\" \")).map(arr => new Solver(arr(0).toInt, arr(1).toInt, arr(2).toInt))\n .map(solver => solver.solve(answerMap)).foreach(println)\n }\n\n}\n\n\nsealed trait Coordination {\n val x: Int\n val y: Int\n}\n\nobject Coordination {\n def apply(x: Int, y: Int): Coordination =\n if (((x + y) & 1) == 1) OddCoordination(x, y)\n else EvenCoordination(x, y)\n\n}\n\ncase class OddCoordination(x: Int, y: Int) extends Coordination {}\n\ncase class EvenCoordination(x: Int, y: Int) extends Coordination {}\n\ncase class Face(bottom: Int, southOrNorth: Int)\n\nsealed trait CoordinationAndFace {\n val coordination: Coordination\n val face: Face\n\n def next: Seq[CoordinationAndFace]\n\n val toKeySring: String = List(coordination.x, coordination.y, face.bottom, face.southOrNorth).mkString(\",\")\n}\n\nobject CoordinationAndFace {\n def apply(coordination: Coordination, face: Face): CoordinationAndFace = {\n coordination match {\n case e: EvenCoordination => EvenCoordinationAndFace(e, face)\n case o: OddCoordination => OddCoordinationAndFace(o, face)\n }\n }\n}\n\ncase class EvenCoordinationAndFace(coordination: EvenCoordination, face: Face) extends CoordinationAndFace {\n override def next = Seq(toNorth, toSouthEast, toSouthWest)\n\n val now = IcosahedronFaces(face.bottom)(face.southOrNorth)\n\n def toNorth: CoordinationAndFace = {\n val newCoordination = Coordination(coordination.x, coordination.y + 1)\n val nextFace = IcosahedronFaces(now.top)(now.n)\n val newFace = Face(nextFace.n, nextFace.top)\n CoordinationAndFace(newCoordination, newFace)\n }\n\n def toSouthWest: CoordinationAndFace = {\n val newCoordination = Coordination(coordination.x - 1, coordination.y)\n val nextFace = IcosahedronFaces(now.right)(now.n)\n val newFace = Face(nextFace.n, nextFace.left)\n CoordinationAndFace(newCoordination, newFace)\n }\n\n def toSouthEast: CoordinationAndFace = {\n val newCoordination = Coordination(coordination.x + 1, coordination.y)\n val nextFace = IcosahedronFaces(now.left)(now.n)\n val newFace = Face(nextFace.n, nextFace.right)\n CoordinationAndFace(newCoordination, newFace)\n }\n}\n\ncase class OddCoordinationAndFace(coordination: OddCoordination, face: Face) extends CoordinationAndFace {\n override def next = Seq(toSouth, toNorthEast, toNorthWest)\n\n val now = IcosahedronFaces(face.bottom)(face.southOrNorth)\n\n def toSouth: CoordinationAndFace = {\n val newCoordination = Coordination(coordination.x, coordination.y - 1)\n val nextFace = IcosahedronFaces(now.top)(now.n)\n val newFace = Face(nextFace.n, nextFace.top)\n CoordinationAndFace(newCoordination, newFace)\n }\n\n def toNorthWest: CoordinationAndFace = {\n val newCoordination = Coordination(coordination.x - 1, coordination.y)\n val nextFace = IcosahedronFaces(now.left)(now.n)\n val newFace = Face(nextFace.n, nextFace.right)\n CoordinationAndFace(newCoordination, newFace)\n }\n\n def toNorthEast: CoordinationAndFace = {\n val newCoordination = Coordination(coordination.x + 1, coordination.y)\n val nextFace = IcosahedronFaces(now.right)(now.n)\n val newFace = Face(nextFace.n, nextFace.left)\n CoordinationAndFace(newCoordination, newFace)\n }\n\n}\n\nsealed case class IcosahedronFace(n: Int, top: Int, left: Int, right: Int) {\n def apply(asTop: Int): IcosahedronFace = {\n asTop match {\n case `top` => this\n case `left` => IcosahedronFace(n, left, right, top)\n case `right` => IcosahedronFace(n, right, top, left)\n }\n }\n}\n\nobject IcosahedronFaces {\n private val list = List(\n IcosahedronFace(0, 5, 1, 4),\n IcosahedronFace(1, 6, 2, 0),\n IcosahedronFace(2, 7, 3, 1),\n IcosahedronFace(3, 8, 4, 2),\n IcosahedronFace(4, 9, 0, 3),\n IcosahedronFace(5, 0, 10, 11),\n IcosahedronFace(6, 1, 11, 12),\n IcosahedronFace(7, 2, 12, 13),\n IcosahedronFace(8, 3, 13, 14),\n IcosahedronFace(9, 4, 14, 10),\n IcosahedronFace(10, 15, 5, 9),\n IcosahedronFace(11, 16, 6, 5),\n IcosahedronFace(12, 17, 7, 6),\n IcosahedronFace(13, 18, 8, 7),\n IcosahedronFace(14, 19, 9, 8),\n IcosahedronFace(15, 10, 19, 16),\n IcosahedronFace(16, 11, 15, 17),\n IcosahedronFace(17, 12, 16, 18),\n IcosahedronFace(18, 13, 17, 19),\n IcosahedronFace(19, 14, 18, 15)\n )\n\n def apply(n: Int): IcosahedronFace = n match {\n case n: Int if ((0 to 19).contains(n)) => list(n)\n }\n}\n\n\nclass Solver(x: Int, y: Int, n: Int) {\n\n import Solver._\n\n def solve(answerMap: Array[Int]): Int = {\n if (-100 > x || -100 > y || x >= 100 || y >= 100) {\n val coordination = Coordination(x, y)\n val missing = coordination match {\n case e: EvenCoordination => 100\n case o: OddCoordination => 99\n }\n return missing\n }\n\n val coordination = Coordination(x, y)\n val missing = coordination match {\n case e: EvenCoordination => 100\n case o: OddCoordination => 99\n }\n\n val iface = IcosahedronFaces(n)\n\n val keys = List(\n CoordinationAndFace(coordination, Face(n, iface.top)),\n CoordinationAndFace(coordination, Face(n, iface.left)),\n CoordinationAndFace(coordination, Face(n, iface.right))\n )\n\n keys.map(cf => answerMap(coordinationAndFaceToInt(cf))).map(v => if (v == 0) missing else v).min\n }\n\n}\n\nobject Solver {\n\n def solveAll: Array[Int] = {\n val init: CoordinationAndFace = CoordinationAndFace(Coordination(0, 0), Face(0, 5))\n\n import scala.collection.mutable.{Queue => MQueue}\n\n def solveInner(map: Array[Int], queue: MQueue[(Int, Int)]): Boolean = {\n val head = queue.dequeue()\n if (head._2 < 98) {\n val candidate = intToCoordinationAndFace(head._1).next\n val nextCost = head._2 + 1\n candidate.filter(cf => map(coordinationAndFaceToInt(cf)) == 0).foreach {\n next =>\n map(coordinationAndFaceToInt(next)) = nextCost\n queue.enqueue((coordinationAndFaceToInt( next), nextCost))\n }\n true\n }\n else false\n }\n\n val map = Array.ofDim[Int](xWidth * xPosition)\n val queue = MQueue(coordinationAndFaceToInt(init) -> 0)\n while(solveInner(map, queue)){}\n map\n }\n\n val xOffset = 100\n val yOffset = 100\n val xWidth = 200\n val yWidth = 200\n val bottomWidth = 20\n val southOrNorthWidth = 20\n\n val southOrNorthPosition = 1\n val bottom = southOrNorthWidth * southOrNorthPosition\n val yPosition = bottomWidth * bottom\n val xPosition = yWidth * yPosition\n\n def toInt(x: Int, y: Int, buttom: Int, southOrNorth: Int): Int = {\n (x + xOffset) * xPosition + (y + yOffset) * yPosition + (buttom) * bottom + (southOrNorth) * southOrNorthPosition\n }\n\n def fromInt(int: Int): (Int, Int, Int, Int) = {\n ((int / xPosition) - xOffset, (int / yPosition) % yWidth - yOffset, (int / bottom) % bottomWidth, (int / southOrNorthPosition) % southOrNorthWidth)\n }\n\n def coordinationAndFaceToInt(coordinationAndFace: CoordinationAndFace): Int = {\n val x = coordinationAndFace.coordination.x\n val y = coordinationAndFace.coordination.y\n val bottom = coordinationAndFace.face.bottom\n val southOrNorth = coordinationAndFace.face.southOrNorth\n toInt(x, y, bottom, southOrNorth)\n }\n\n def intToCoordinationAndFace(int: Int): CoordinationAndFace = {\n val (x, y, bottom, southOrNorth) = fromInt(int)\n CoordinationAndFace(Coordination(x, y), Face(bottom, southOrNorth))\n }\n\n}", "problem_context": "Problem E: Driving an Icosahedral Rover\n\nAfter decades of fruitless efforts, one of the expedition teams of ITO (Intersolar Tourism Organization) finally found a planet that would surely provide one of the best tourist attractions\nwithin a ten light-year radius from our solar system. The most attractive feature of the planet,\nbesides its comfortable gravity and calm weather, is the area called Mare Triangularis. Despite\nthe name, the area is not covered with water but is a great plane. Its unique feature is that it is\ndivided into equilateral triangular sections of the same size, called trigons. The trigons provide\na unique impressive landscape, a must for tourism. It is no wonder the board of ITO decided\nto invest a vast amount on the planet.\n\nDespite the expected secrecy of the staff, the Society of Astrogeology caught this information\nin no time, as always. They immediately sent their president's letter to the Institute of Science\nand Education of the Commonwealth Galactica claiming that authoritative academic inspections\nwere to be completed before any commercial exploitation might damage the nature.\n\nFortunately, astrogeologists do not plan to practice all the possible inspections on all of the\ntrigons; there are far too many of them. Inspections are planned only on some characteristic\ntrigons and, for each of them, in one of twenty different scientific aspects.\n\nTo accelerate building this new tourist resort, ITO's construction machinery team has already succeeded in putting their brand-new\ninvention in practical use. It is a rover vehicle of the shape of an icosahedron, a regular polyhedron with twenty faces of equilateral triangles.\nThe machine is customized\nso that each of the twenty faces exactly fits each of the trigons.\nControlling the high-tech gyromotor installed inside its body, the rover can roll onto one of the three trigons neighboring the one its bottom is\non.\n\nFigure E.1: The Rover on Mare Triangularis\n\nEach of the twenty faces has its own function. The set of equipments installed on the bottom\nface touching the ground can be applied to the trigon it is on. Of course, the rover was meant to accelerate construction of the luxury hotels to host rich interstellar travelers, but, changing\nthe installed equipment sets, it can also be used to accelerate academic inspections.\n\nYou are the driver of this rover and are asked to move the vehicle onto the trigon specified by\nthe leader of the scientific commission with the smallest possible steps. What makes your task\nmore difficult is that the designated face installed with the appropriate set of equipments has to\nbe the bottom. The direction of the rover does not matter.\n\nFigure E.2:The Coordinate System\n\nFigure E.3: Face Numbering\n\nThe trigons of Mare Triangularis are given two-dimensional coordinates as shown in Figure E.2.\nLike maps used for the Earth, the x axis is from the west to the east, and the y axis is from the\nsouth to the north. Note that all the trigons with its coordinates (x , y) has neighboring trigons\nwith coordinates (x - 1 , y) and (x + 1 , y). In addition to these, when x + y is even, it has a\nneighbor (x , y + 1); otherwise, that is, when x + y is odd, it has a neighbor (x , y - 1).\n\nFigure E.3 shows a development of the skin of the rover. The top face of the development\nmakes the exterior. That is, if the numbers on faces of the development were actually marked\non the faces of the rover, they should been readable from its outside. These numbers are used\nto identify the faces.\n\nWhen you start the rover, it is on the trigon (0,0) and the face 0 is touching the ground. The\nrover is placed so that rolling towards north onto the trigon (0,1) makes the face numbered 5\nto be at the bottom.\n\nAs your first step, you can choose one of the three adjacent trigons, namely those with coordinates (-1,0), (1,0),\nand (0,1), to visit. The bottom will be the face numbered 4, 1, and 5,\nrespectively. If you choose to go to (1,0) in the first rolling step, the second step can bring\nthe rover to either of (0,0), (2,0), or (1,-1). The bottom face will be either of 0, 6, or 2,\ncorrespondingly. The rover may visit any of the trigons twice or more, including the start and the goal trigons, when appropriate.\n\nThe theoretical design section of ITO showed that the rover can reach any goal trigon on the\nspecified bottom face within a finite number of steps.\n\nInput\n\nThe input consists of a number of datasets. The number of datasets does not exceed 50.\n\nEach of the datasets has three integers x, y, and n in one line, separated by a space. Here, (x,y)\nspecifies the coordinates of the trigon to which you have to move the rover, and n specifies the\nface that should be at the bottom.\n\nThe end of the input is indicated by a line containing three zeros.\n\nOutput\n\nThe output for each dataset should be a line containing a single integer that gives the minimum\nnumber of steps required to set the rover on the specified trigon with the specified face touching\nthe ground. No other characters should appear in the output.\n\nYou can assume that the maximum number of required steps does not exceed 100. Mare Triangularis\nis broad enough so that any of its edges cannot be reached within that number of\nsteps.\n\nSample Input\n\n0 0 1\n3 5 2\n-4 1 3\n13 -13 2\n-32 15 9\n-50 50 0\n0 0 0\n\nOutput for the Sample Input\n\n6\n10\n9\n30\n47\n100", "sample_input": "0 0 1\n3 5 2\n-4 1 3\n13 -13 2\n-32 15 9\n-50 50 0\n0 0 0\n"}, "reference_outputs": ["6\n10\n9\n30\n47\n100\n"], "source_document_id": "p00898", "source_text": "Problem E: Driving an Icosahedral Rover\n\nAfter decades of fruitless efforts, one of the expedition teams of ITO (Intersolar Tourism Organization) finally found a planet that would surely provide one of the best tourist attractions\nwithin a ten light-year radius from our solar system. The most attractive feature of the planet,\nbesides its comfortable gravity and calm weather, is the area called Mare Triangularis. Despite\nthe name, the area is not covered with water but is a great plane. Its unique feature is that it is\ndivided into equilateral triangular sections of the same size, called trigons. The trigons provide\na unique impressive landscape, a must for tourism. It is no wonder the board of ITO decided\nto invest a vast amount on the planet.\n\nDespite the expected secrecy of the staff, the Society of Astrogeology caught this information\nin no time, as always. They immediately sent their president's letter to the Institute of Science\nand Education of the Commonwealth Galactica claiming that authoritative academic inspections\nwere to be completed before any commercial exploitation might damage the nature.\n\nFortunately, astrogeologists do not plan to practice all the possible inspections on all of the\ntrigons; there are far too many of them. Inspections are planned only on some characteristic\ntrigons and, for each of them, in one of twenty different scientific aspects.\n\nTo accelerate building this new tourist resort, ITO's construction machinery team has already succeeded in putting their brand-new\ninvention in practical use. It is a rover vehicle of the shape of an icosahedron, a regular polyhedron with twenty faces of equilateral triangles.\nThe machine is customized\nso that each of the twenty faces exactly fits each of the trigons.\nControlling the high-tech gyromotor installed inside its body, the rover can roll onto one of the three trigons neighboring the one its bottom is\non.\n\nFigure E.1: The Rover on Mare Triangularis\n\nEach of the twenty faces has its own function. The set of equipments installed on the bottom\nface touching the ground can be applied to the trigon it is on. Of course, the rover was meant to accelerate construction of the luxury hotels to host rich interstellar travelers, but, changing\nthe installed equipment sets, it can also be used to accelerate academic inspections.\n\nYou are the driver of this rover and are asked to move the vehicle onto the trigon specified by\nthe leader of the scientific commission with the smallest possible steps. What makes your task\nmore difficult is that the designated face installed with the appropriate set of equipments has to\nbe the bottom. The direction of the rover does not matter.\n\nFigure E.2:The Coordinate System\n\nFigure E.3: Face Numbering\n\nThe trigons of Mare Triangularis are given two-dimensional coordinates as shown in Figure E.2.\nLike maps used for the Earth, the x axis is from the west to the east, and the y axis is from the\nsouth to the north. Note that all the trigons with its coordinates (x , y) has neighboring trigons\nwith coordinates (x - 1 , y) and (x + 1 , y). In addition to these, when x + y is even, it has a\nneighbor (x , y + 1); otherwise, that is, when x + y is odd, it has a neighbor (x , y - 1).\n\nFigure E.3 shows a development of the skin of the rover. The top face of the development\nmakes the exterior. That is, if the numbers on faces of the development were actually marked\non the faces of the rover, they should been readable from its outside. These numbers are used\nto identify the faces.\n\nWhen you start the rover, it is on the trigon (0,0) and the face 0 is touching the ground. The\nrover is placed so that rolling towards north onto the trigon (0,1) makes the face numbered 5\nto be at the bottom.\n\nAs your first step, you can choose one of the three adjacent trigons, namely those with coordinates (-1,0), (1,0),\nand (0,1), to visit. The bottom will be the face numbered 4, 1, and 5,\nrespectively. If you choose to go to (1,0) in the first rolling step, the second step can bring\nthe rover to either of (0,0), (2,0), or (1,-1). The bottom face will be either of 0, 6, or 2,\ncorrespondingly. The rover may visit any of the trigons twice or more, including the start and the goal trigons, when appropriate.\n\nThe theoretical design section of ITO showed that the rover can reach any goal trigon on the\nspecified bottom face within a finite number of steps.\n\nInput\n\nThe input consists of a number of datasets. The number of datasets does not exceed 50.\n\nEach of the datasets has three integers x, y, and n in one line, separated by a space. Here, (x,y)\nspecifies the coordinates of the trigon to which you have to move the rover, and n specifies the\nface that should be at the bottom.\n\nThe end of the input is indicated by a line containing three zeros.\n\nOutput\n\nThe output for each dataset should be a line containing a single integer that gives the minimum\nnumber of steps required to set the rover on the specified trigon with the specified face touching\nthe ground. No other characters should appear in the output.\n\nYou can assume that the maximum number of required steps does not exceed 100. Mare Triangularis\nis broad enough so that any of its edges cannot be reached within that number of\nsteps.\n\nSample Input\n\n0 0 1\n3 5 2\n-4 1 3\n13 -13 2\n-32 15 9\n-50 50 0\n0 0 0\n\nOutput for the Sample Input\n\n6\n10\n9\n30\n47\n100", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 7575, "cpu_time_ms": 3890, "memory_kb": 660772}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s327943581", "group_id": "codeNet:p01066", "input_text": "object Main extends App {\n\n import scala.io.StdIn._\n import scala.math._\n val n = readLine.trim.toInt\n val planets = Array.tabulate(n){_ ⇒\n val Array(x, y) = readLine.trim.split(' ').map(_.toInt.toRational)\n Coordinate(x, y)\n }\n println(\n planets.tail.permutations.map{p ⇒ minLine(p.toList, planets.head)}.min\n )\n def minLine(planets: List[Coordinate], start: Coordinate): Int = {\n def sub(planets: List[Coordinate], current: Coordinate, lines: List[Line]): Int = {\n planets match {\n case Nil ⇒ lines.length\n case h::t ⇒\n val line = verticalHalf(current, h)\n if (lines.contains(line)) sub(t, h, lines)\n else sub(t, h, line::lines)\n }\n }\n sub(planets, start, Nil)\n }\n\n def verticalHalf(a: Coordinate, b: Coordinate): Line = {\n val mid = a + b match {case Coordinate(x, y) ⇒ Coordinate(x / 2.toRational, y / 2.toRational)}\n val diff = a - b match {case Coordinate(x, y) ⇒ Coordinate(-y, x)}\n new Line(mid, mid + diff)\n }\n class Line(private val from: Coordinate, private val to: Coordinate){\n override def toString: String = s\"Line($from, $to)\"\n private def dx: Rational = (to - from).x\n private def dy: Rational = (to - from).y\n def isOnLine(point: Coordinate): Boolean = {\n point - from match {\n case Coordinate(x, y) ⇒\n val ddx = dx\n val ddy = dy\n ddx * y == ddy * x\n }\n }\n override def equals(obj: Any): Boolean = {\n obj match {\n case line: Line ⇒ isOnLine(line.from) && isOnLine(line.to)\n case _ ⇒ super.equals(obj)\n }\n }\n }\n object Rational{\n def apply(numerator: Long, denominator: Long): Rational = {\n val g = gcd(math.abs(numerator), math.abs(denominator))\n val signum = numerator.signum * denominator.signum\n new Rational(signum * math.abs(numerator / g), math.abs(denominator / g))\n }\n private def gcd(a: Long, b: Long): Long = {\n b match {\n case 0l ⇒ a\n case _ ⇒ gcd(b, a % b)\n }\n }\n }\n implicit class ToRational(val value: Int){\n def toRational: Rational = Rational(value, 1)\n }\n class Rational private (private val numerator: Long, private val denominator: Long) extends Ordered[Rational] {\n def +(that: Rational): Rational = Rational(numerator * that.denominator + denominator * that.numerator, denominator * that.denominator)\n def -(that: Rational): Rational = Rational(numerator * that.denominator - denominator * that.numerator, denominator * that.denominator)\n def *(that: Rational): Rational = Rational(numerator * that.numerator, denominator * that.denominator)\n def /(that: Rational): Rational = Rational(numerator * that.denominator, denominator * that.numerator)\n def unary_-(): Rational = Rational(-numerator, denominator)\n override def compare(that: Rational): Int = (this - that).numerator.compare(0)\n\n override def equals(obj: Any): Boolean = {\n obj match {\n case r: Rational ⇒ this.compare(r) == 0\n case _ ⇒ super.equals(obj)\n }\n }\n override def toString: String = s\"$numerator / $denominator\"\n }\n case class Coordinate(x: Rational, y: Rational){\n def -(that: Coordinate): Coordinate = Coordinate(x - that.x, y - that.y)\n def +(that: Coordinate): Coordinate = Coordinate(x + that.x, y + that.y)\n }\n implicit class Extension[T](val value :T){\n def also(func: T ⇒ Unit): T = {\n func(value)\n value\n }\n def let[R](func: T ⇒ R): R = func(value)\n }\n}\n", "language": "Scala", "metadata": {"date": 1546404969, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01066.html", "problem_id": "p01066", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01066/input.txt", "sample_output_relpath": "derived/input_output/data/p01066/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01066/Scala/s327943581.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s327943581", "user_id": "u514597327"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n\n import scala.io.StdIn._\n import scala.math._\n val n = readLine.trim.toInt\n val planets = Array.tabulate(n){_ ⇒\n val Array(x, y) = readLine.trim.split(' ').map(_.toInt.toRational)\n Coordinate(x, y)\n }\n println(\n planets.tail.permutations.map{p ⇒ minLine(p.toList, planets.head)}.min\n )\n def minLine(planets: List[Coordinate], start: Coordinate): Int = {\n def sub(planets: List[Coordinate], current: Coordinate, lines: List[Line]): Int = {\n planets match {\n case Nil ⇒ lines.length\n case h::t ⇒\n val line = verticalHalf(current, h)\n if (lines.contains(line)) sub(t, h, lines)\n else sub(t, h, line::lines)\n }\n }\n sub(planets, start, Nil)\n }\n\n def verticalHalf(a: Coordinate, b: Coordinate): Line = {\n val mid = a + b match {case Coordinate(x, y) ⇒ Coordinate(x / 2.toRational, y / 2.toRational)}\n val diff = a - b match {case Coordinate(x, y) ⇒ Coordinate(-y, x)}\n new Line(mid, mid + diff)\n }\n class Line(private val from: Coordinate, private val to: Coordinate){\n override def toString: String = s\"Line($from, $to)\"\n private def dx: Rational = (to - from).x\n private def dy: Rational = (to - from).y\n def isOnLine(point: Coordinate): Boolean = {\n point - from match {\n case Coordinate(x, y) ⇒\n val ddx = dx\n val ddy = dy\n ddx * y == ddy * x\n }\n }\n override def equals(obj: Any): Boolean = {\n obj match {\n case line: Line ⇒ isOnLine(line.from) && isOnLine(line.to)\n case _ ⇒ super.equals(obj)\n }\n }\n }\n object Rational{\n def apply(numerator: Long, denominator: Long): Rational = {\n val g = gcd(math.abs(numerator), math.abs(denominator))\n val signum = numerator.signum * denominator.signum\n new Rational(signum * math.abs(numerator / g), math.abs(denominator / g))\n }\n private def gcd(a: Long, b: Long): Long = {\n b match {\n case 0l ⇒ a\n case _ ⇒ gcd(b, a % b)\n }\n }\n }\n implicit class ToRational(val value: Int){\n def toRational: Rational = Rational(value, 1)\n }\n class Rational private (private val numerator: Long, private val denominator: Long) extends Ordered[Rational] {\n def +(that: Rational): Rational = Rational(numerator * that.denominator + denominator * that.numerator, denominator * that.denominator)\n def -(that: Rational): Rational = Rational(numerator * that.denominator - denominator * that.numerator, denominator * that.denominator)\n def *(that: Rational): Rational = Rational(numerator * that.numerator, denominator * that.denominator)\n def /(that: Rational): Rational = Rational(numerator * that.denominator, denominator * that.numerator)\n def unary_-(): Rational = Rational(-numerator, denominator)\n override def compare(that: Rational): Int = (this - that).numerator.compare(0)\n\n override def equals(obj: Any): Boolean = {\n obj match {\n case r: Rational ⇒ this.compare(r) == 0\n case _ ⇒ super.equals(obj)\n }\n }\n override def toString: String = s\"$numerator / $denominator\"\n }\n case class Coordinate(x: Rational, y: Rational){\n def -(that: Coordinate): Coordinate = Coordinate(x - that.x, y - that.y)\n def +(that: Coordinate): Coordinate = Coordinate(x + that.x, y + that.y)\n }\n implicit class Extension[T](val value :T){\n def also(func: T ⇒ Unit): T = {\n func(value)\n value\n }\n def let[R](func: T ⇒ R): R = func(value)\n }\n}\n", "problem_context": "Reflection Warp Machine\n\nProblem\n\nとある宇宙では、2次元の格子点上にn個の星が存在し、宇宙人達はReflection Warp Machineを使い、星間を移動している。\n\nこの装置は、任意の位置、角度で直線を引くことができる。\n\nこの直線を対称軸として、現在いる座標から線対称の座標に移動することができる。\n\nただし、星が存在しない座標に移動することはできない。\n\n一度引いた直線は何度でも利用できる。\n\n現在、(x0,y0)の星にいるある宇宙人はすべての星を訪れたいと考えている。\n\n星は好きな順番に訪れることができる。\n\nすべての星を訪れるのに最小で何本の直線を引く必要があるか求めよ。\n\nInput\n\nn\nx0 y0\n...\nxn−1 yn−1\n\n入力は全て整数で与えられる。\n\n1行目にnが与えられる。\n\n2行目以降n行にi番目の星の座標(xi,yi)が空白区切りで与えられる。\n\nConstraints\n\n2 ≤ n ≤ 8\n\n−100 ≤ xi,yi ≤ 100\n\n(xi,yi) ≠ (xj,yj) (i ≠ j)\n\nOutput\n\nすべての星を訪れるために必要な最小の直線の数を1行に出力せよ。\n\nSample Input 1\n\n3\n0 0\n0 1\n1 0\n\nSample Output 1\n\n2\n\nSample Input 2\n\n4\n0 0\n0 1\n0 2\n0 3\n\nSample Output 2\n\n2", "sample_input": "3\n0 0\n0 1\n1 0\n"}, "reference_outputs": ["2\n"], "source_document_id": "p01066", "source_text": "Reflection Warp Machine\n\nProblem\n\nとある宇宙では、2次元の格子点上にn個の星が存在し、宇宙人達はReflection Warp Machineを使い、星間を移動している。\n\nこの装置は、任意の位置、角度で直線を引くことができる。\n\nこの直線を対称軸として、現在いる座標から線対称の座標に移動することができる。\n\nただし、星が存在しない座標に移動することはできない。\n\n一度引いた直線は何度でも利用できる。\n\n現在、(x0,y0)の星にいるある宇宙人はすべての星を訪れたいと考えている。\n\n星は好きな順番に訪れることができる。\n\nすべての星を訪れるのに最小で何本の直線を引く必要があるか求めよ。\n\nInput\n\nn\nx0 y0\n...\nxn−1 yn−1\n\n入力は全て整数で与えられる。\n\n1行目にnが与えられる。\n\n2行目以降n行にi番目の星の座標(xi,yi)が空白区切りで与えられる。\n\nConstraints\n\n2 ≤ n ≤ 8\n\n−100 ≤ xi,yi ≤ 100\n\n(xi,yi) ≠ (xj,yj) (i ≠ j)\n\nOutput\n\nすべての星を訪れるために必要な最小の直線の数を1行に出力せよ。\n\nSample Input 1\n\n3\n0 0\n0 1\n1 0\n\nSample Output 1\n\n2\n\nSample Input 2\n\n4\n0 0\n0 1\n0 2\n0 3\n\nSample Output 2\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3523, "cpu_time_ms": 730, "memory_kb": 109692}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s912601281", "group_id": "codeNet:p01072", "input_text": "import java.util.Scanner\n\nobject Main {\n\n val scan = new Scanner(System.in)\n\n def main(args: Array[String]): Unit = {\n val W = scan.nextInt()\n val H = scan.nextInt()\n val T = scan.nextInt()\n val p = scan.nextInt()\n val g = Array.ofDim[Int](H, W)\n for (i <- 0 until p) {\n val x = scan.nextInt()\n val y = scan.nextInt()\n val t = scan.nextInt()\n g(y)(x) += 1\n }\n var sum = 0\n for (i <- 0 until H; j <- 0 until W) {\n val s = scan.nextInt()\n sum += s * g(i)(j)\n }\n println(s\"${sum}\")\n }\n\n}", "language": "Scala", "metadata": {"date": 1474181450, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01072.html", "problem_id": "p01072", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01072/input.txt", "sample_output_relpath": "derived/input_output/data/p01072/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01072/Scala/s912601281.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s912601281", "user_id": "u967850487"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n\n val scan = new Scanner(System.in)\n\n def main(args: Array[String]): Unit = {\n val W = scan.nextInt()\n val H = scan.nextInt()\n val T = scan.nextInt()\n val p = scan.nextInt()\n val g = Array.ofDim[Int](H, W)\n for (i <- 0 until p) {\n val x = scan.nextInt()\n val y = scan.nextInt()\n val t = scan.nextInt()\n g(y)(x) += 1\n }\n var sum = 0\n for (i <- 0 until H; j <- 0 until W) {\n val s = scan.nextInt()\n sum += s * g(i)(j)\n }\n println(s\"${sum}\")\n }\n\n}", "problem_context": "Problem A: Plants\n\nProblem\n\nがっちょ君は横W個×縦H個のマスで区切られた畑を所有している。x列目y行目のマスをマス (x, y) と呼ぶことにする。いくつかのマスの土地には高さ0cmの植物が1本だけ植えてあり、その他のマスの土地には何も植えられていない。\n\nがっちょ君はある時刻に畑に肥料をまく。肥料がまかれたマスに植物が植えられているとき、その植物の高さが1cm伸びる。植物が植えられていないときは、何もおこらない。植物が伸びるのにかかる時間はとても短いので無視できる。がっちょ君は同じ時刻に複数のマスに肥料をまくことができる。ただし、同じ時刻に同じマスに2度以上肥料をまくことはない。\n\nがっちょ君が肥料をまいた記録が与えられたとき、時刻T時点での畑の植物の高さの和を計算せよ。\n\nInput\n\n入力は以下の形式で与えられる。\n\nW H T\np\nx0 y0 t0\nx1 y1 t1\n...\nxp−1 yp−1 tp−1\ns0,0 s1,0 … sW−1,0\ns0,1 s1,1 … sW−1,1\n...\ns0,H−1 s1,H−1 … sW−1,H−1\n\n1行目に畑の横幅W、畑の縦幅H、時刻Tが与えられる。がっちょ君は時刻Tまでに肥料をまきおえる。\n\n2行目にがっちょ君が肥料をまいた回数pが与えられる。\n\n3行目から2+p行目までに与えられる3つの整数は、がっちょ君が時刻tiにマス(xi, yi)に肥料をまいたことを表す。\n\n3+p行目から2+p+H行目までは、最初の畑のそれぞれのマスに植物が植えられているかどうかを表すW×H個の整数が与えられる。sj,kが1のときマス(j, k)に高さ0cmの植物が1本だけ植えられていることを表し、sj,kが0のときマス(j, k)に植物は1本も植えられていないことを表す。\n\nConstraints\n\n1 ≤ W, H, T ≤ 50\n\n0 ≤ p ≤ min(W×H×T, 50)\n\n0 ≤ xi < W\n\n0 ≤ yi < H\n\n0 ≤ ti < T\n\nsj,k = 0または1\n\nOutput\n\n時刻Tでの畑の植物の高さの和を1行に出力せよ。\n\nSample Input 1\n\n3 3 3\n5\n2 0 0\n0 1 0\n1 1 1\n1 2 1\n2 2 0\n0 0 0\n0 1 0\n0 0 0\n\nSample Output 1\n\n1\n\nSample Input 2\n\n2 3 4\n2\n0 0 0\n1 1 3\n1 0\n0 0\n0 0\n\nSample Output 2\n\n1\n\nSample Input 3\n\n3 8 6\n6\n0 4 3\n2 5 3\n0 2 3\n2 2 5\n1 1 3\n2 2 1\n1 1 1\n1 1 1\n1 1 1\n1 0 1\n0 1 1\n1 1 0\n1 0 1\n0 1 0\n\nSample Output 3\n\n4\n\nSample Input 4\n\n8 3 3\n7\n0 1 1\n5 1 0\n4 0 2\n3 2 0\n3 1 1\n3 0 1\n5 1 1\n1 0 1 1 0 0 1 0\n0 0 1 1 0 1 0 1\n0 1 0 0 0 1 0 1\n\nSample Output 4\n\n4", "sample_input": "3 3 3\n5\n2 0 0\n0 1 0\n1 1 1\n1 2 1\n2 2 0\n0 0 0\n0 1 0\n0 0 0\n"}, "reference_outputs": ["1\n"], "source_document_id": "p01072", "source_text": "Problem A: Plants\n\nProblem\n\nがっちょ君は横W個×縦H個のマスで区切られた畑を所有している。x列目y行目のマスをマス (x, y) と呼ぶことにする。いくつかのマスの土地には高さ0cmの植物が1本だけ植えてあり、その他のマスの土地には何も植えられていない。\n\nがっちょ君はある時刻に畑に肥料をまく。肥料がまかれたマスに植物が植えられているとき、その植物の高さが1cm伸びる。植物が植えられていないときは、何もおこらない。植物が伸びるのにかかる時間はとても短いので無視できる。がっちょ君は同じ時刻に複数のマスに肥料をまくことができる。ただし、同じ時刻に同じマスに2度以上肥料をまくことはない。\n\nがっちょ君が肥料をまいた記録が与えられたとき、時刻T時点での畑の植物の高さの和を計算せよ。\n\nInput\n\n入力は以下の形式で与えられる。\n\nW H T\np\nx0 y0 t0\nx1 y1 t1\n...\nxp−1 yp−1 tp−1\ns0,0 s1,0 … sW−1,0\ns0,1 s1,1 … sW−1,1\n...\ns0,H−1 s1,H−1 … sW−1,H−1\n\n1行目に畑の横幅W、畑の縦幅H、時刻Tが与えられる。がっちょ君は時刻Tまでに肥料をまきおえる。\n\n2行目にがっちょ君が肥料をまいた回数pが与えられる。\n\n3行目から2+p行目までに与えられる3つの整数は、がっちょ君が時刻tiにマス(xi, yi)に肥料をまいたことを表す。\n\n3+p行目から2+p+H行目までは、最初の畑のそれぞれのマスに植物が植えられているかどうかを表すW×H個の整数が与えられる。sj,kが1のときマス(j, k)に高さ0cmの植物が1本だけ植えられていることを表し、sj,kが0のときマス(j, k)に植物は1本も植えられていないことを表す。\n\nConstraints\n\n1 ≤ W, H, T ≤ 50\n\n0 ≤ p ≤ min(W×H×T, 50)\n\n0 ≤ xi < W\n\n0 ≤ yi < H\n\n0 ≤ ti < T\n\nsj,k = 0または1\n\nOutput\n\n時刻Tでの畑の植物の高さの和を1行に出力せよ。\n\nSample Input 1\n\n3 3 3\n5\n2 0 0\n0 1 0\n1 1 1\n1 2 1\n2 2 0\n0 0 0\n0 1 0\n0 0 0\n\nSample Output 1\n\n1\n\nSample Input 2\n\n2 3 4\n2\n0 0 0\n1 1 3\n1 0\n0 0\n0 0\n\nSample Output 2\n\n1\n\nSample Input 3\n\n3 8 6\n6\n0 4 3\n2 5 3\n0 2 3\n2 2 5\n1 1 3\n2 2 1\n1 1 1\n1 1 1\n1 1 1\n1 0 1\n0 1 1\n1 1 0\n1 0 1\n0 1 0\n\nSample Output 3\n\n4\n\nSample Input 4\n\n8 3 3\n7\n0 1 1\n5 1 0\n4 0 2\n3 2 0\n3 1 1\n3 0 1\n5 1 1\n1 0 1 1 0 0 1 0\n0 0 1 1 0 1 0 1\n0 1 0 0 0 1 0 1\n\nSample Output 4\n\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 290, "memory_kb": 49924}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s842807101", "group_id": "codeNet:p01093", "input_text": "import scala.util.control.Breaks\n\nobject Main extends App{\n def main(N:Int,s:List[Int]) {\n var res=1000000000\n for(i<-0 until N-1) {\n res=List(res,s(i+1)-s(i)).min\n }\n println(res)\n }\n val sc = new java.util.Scanner(System.in)\n val b=new Breaks\n\n b.breakable {\n while (true) {\n val N = sc.nextInt\n if (N == 0) b.break\n val s = List.fill(N)(sc.nextInt)\n main(N, s.sorted)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1486177597, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01093.html", "problem_id": "p01093", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01093/input.txt", "sample_output_relpath": "derived/input_output/data/p01093/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01093/Scala/s842807101.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s842807101", "user_id": "u363039534"}, "prompt_components": {"gold_output": "0\n1\n5\n", "input_to_evaluate": "import scala.util.control.Breaks\n\nobject Main extends App{\n def main(N:Int,s:List[Int]) {\n var res=1000000000\n for(i<-0 until N-1) {\n res=List(res,s(i+1)-s(i)).min\n }\n println(res)\n }\n val sc = new java.util.Scanner(System.in)\n val b=new Breaks\n\n b.breakable {\n while (true) {\n val N = sc.nextInt\n if (N == 0) b.break\n val s = List.fill(N)(sc.nextInt)\n main(N, s.sorted)\n }\n }\n}", "problem_context": "Selection of Participants of an Experiment\n\nDr. Tsukuba has devised a new method of programming training.\nIn order to evaluate the effectiveness of this method,\nhe plans to carry out a control experiment.\nHaving two students as the participants of the experiment,\none of them will be trained under the conventional method\nand the other under his new method.\nComparing the final scores of these two,\nhe will be able to judge the effectiveness of his method.\n\nIt is important to select two students having the closest possible scores,\nfor making the comparison fair.\nHe has a list of the scores of all students\nwho can participate in the experiment.\nYou are asked to write a program which selects two of them\nhaving the smallest difference in their scores.\n\nInput\n\nThe input consists of multiple datasets, each in the following format.\n\nn\n\na1 a2 … an\n\nA dataset consists of two lines.\nThe number of students n is given in the first line.\nn is an integer satisfying 2 ≤ n ≤ 1000.\nThe second line gives scores of n students.\nai (1 ≤ i ≤ n) is the score of the i-th student, which is a non-negative integer not greater than 1,000,000.\n\nThe end of the input is indicated by a line containing a zero.\nThe sum of n's of all the datasets does not exceed 50,000.\n\nOutput\n\nFor each dataset, select two students with the smallest difference in their scores,\nand output in a line (the absolute value of) the difference.\n\nSample Input\n\n5\n10 10 10 10 10\n5\n1 5 8 9 11\n7\n11 34 83 47 59 29 70\n0\n\nOutput for the Sample Input\n\n0\n1\n5", "sample_input": "5\n10 10 10 10 10\n5\n1 5 8 9 11\n7\n11 34 83 47 59 29 70\n0\n"}, "reference_outputs": ["0\n1\n5\n"], "source_document_id": "p01093", "source_text": "Selection of Participants of an Experiment\n\nDr. Tsukuba has devised a new method of programming training.\nIn order to evaluate the effectiveness of this method,\nhe plans to carry out a control experiment.\nHaving two students as the participants of the experiment,\none of them will be trained under the conventional method\nand the other under his new method.\nComparing the final scores of these two,\nhe will be able to judge the effectiveness of his method.\n\nIt is important to select two students having the closest possible scores,\nfor making the comparison fair.\nHe has a list of the scores of all students\nwho can participate in the experiment.\nYou are asked to write a program which selects two of them\nhaving the smallest difference in their scores.\n\nInput\n\nThe input consists of multiple datasets, each in the following format.\n\nn\n\na1 a2 … an\n\nA dataset consists of two lines.\nThe number of students n is given in the first line.\nn is an integer satisfying 2 ≤ n ≤ 1000.\nThe second line gives scores of n students.\nai (1 ≤ i ≤ n) is the score of the i-th student, which is a non-negative integer not greater than 1,000,000.\n\nThe end of the input is indicated by a line containing a zero.\nThe sum of n's of all the datasets does not exceed 50,000.\n\nOutput\n\nFor each dataset, select two students with the smallest difference in their scores,\nand output in a line (the absolute value of) the difference.\n\nSample Input\n\n5\n10 10 10 10 10\n5\n1 5 8 9 11\n7\n11 34 83 47 59 29 70\n0\n\nOutput for the Sample Input\n\n0\n1\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 490, "memory_kb": 69264}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s379001717", "group_id": "codeNet:p01093", "input_text": "object Main extends App {\n\t// your code goes here\n\timport scala.io.StdIn.readLine\n\twhile(true) {\n\t\tval n = readLine().toInt\n\t\tif (n == 0) System.exit(0)\n\t\tval list = readLine().split(\" \").map(_.toInt)\n\t\tprintln(list.sorted.sliding(2).map{case Array(_1, _2) => _2 - _1}.min)\n\t}\n}\n\n", "language": "Scala", "metadata": {"date": 1538102906, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01093.html", "problem_id": "p01093", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01093/input.txt", "sample_output_relpath": "derived/input_output/data/p01093/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01093/Scala/s379001717.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s379001717", "user_id": "u010611609"}, "prompt_components": {"gold_output": "0\n1\n5\n", "input_to_evaluate": "object Main extends App {\n\t// your code goes here\n\timport scala.io.StdIn.readLine\n\twhile(true) {\n\t\tval n = readLine().toInt\n\t\tif (n == 0) System.exit(0)\n\t\tval list = readLine().split(\" \").map(_.toInt)\n\t\tprintln(list.sorted.sliding(2).map{case Array(_1, _2) => _2 - _1}.min)\n\t}\n}\n\n", "problem_context": "Selection of Participants of an Experiment\n\nDr. Tsukuba has devised a new method of programming training.\nIn order to evaluate the effectiveness of this method,\nhe plans to carry out a control experiment.\nHaving two students as the participants of the experiment,\none of them will be trained under the conventional method\nand the other under his new method.\nComparing the final scores of these two,\nhe will be able to judge the effectiveness of his method.\n\nIt is important to select two students having the closest possible scores,\nfor making the comparison fair.\nHe has a list of the scores of all students\nwho can participate in the experiment.\nYou are asked to write a program which selects two of them\nhaving the smallest difference in their scores.\n\nInput\n\nThe input consists of multiple datasets, each in the following format.\n\nn\n\na1 a2 … an\n\nA dataset consists of two lines.\nThe number of students n is given in the first line.\nn is an integer satisfying 2 ≤ n ≤ 1000.\nThe second line gives scores of n students.\nai (1 ≤ i ≤ n) is the score of the i-th student, which is a non-negative integer not greater than 1,000,000.\n\nThe end of the input is indicated by a line containing a zero.\nThe sum of n's of all the datasets does not exceed 50,000.\n\nOutput\n\nFor each dataset, select two students with the smallest difference in their scores,\nand output in a line (the absolute value of) the difference.\n\nSample Input\n\n5\n10 10 10 10 10\n5\n1 5 8 9 11\n7\n11 34 83 47 59 29 70\n0\n\nOutput for the Sample Input\n\n0\n1\n5", "sample_input": "5\n10 10 10 10 10\n5\n1 5 8 9 11\n7\n11 34 83 47 59 29 70\n0\n"}, "reference_outputs": ["0\n1\n5\n"], "source_document_id": "p01093", "source_text": "Selection of Participants of an Experiment\n\nDr. Tsukuba has devised a new method of programming training.\nIn order to evaluate the effectiveness of this method,\nhe plans to carry out a control experiment.\nHaving two students as the participants of the experiment,\none of them will be trained under the conventional method\nand the other under his new method.\nComparing the final scores of these two,\nhe will be able to judge the effectiveness of his method.\n\nIt is important to select two students having the closest possible scores,\nfor making the comparison fair.\nHe has a list of the scores of all students\nwho can participate in the experiment.\nYou are asked to write a program which selects two of them\nhaving the smallest difference in their scores.\n\nInput\n\nThe input consists of multiple datasets, each in the following format.\n\nn\n\na1 a2 … an\n\nA dataset consists of two lines.\nThe number of students n is given in the first line.\nn is an integer satisfying 2 ≤ n ≤ 1000.\nThe second line gives scores of n students.\nai (1 ≤ i ≤ n) is the score of the i-th student, which is a non-negative integer not greater than 1,000,000.\n\nThe end of the input is indicated by a line containing a zero.\nThe sum of n's of all the datasets does not exceed 50,000.\n\nOutput\n\nFor each dataset, select two students with the smallest difference in their scores,\nand output in a line (the absolute value of) the difference.\n\nSample Input\n\n5\n10 10 10 10 10\n5\n1 5 8 9 11\n7\n11 34 83 47 59 29 70\n0\n\nOutput for the Sample Input\n\n0\n1\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 280, "cpu_time_ms": 500, "memory_kb": 79256}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s780176449", "group_id": "codeNet:p01101", "input_text": "import scala.io.StdIn\nimport java.util.Arrays\n\nobject Main {\n def main(args: Array[String]): Unit = {\n while(true) {\n val n :: m :: _res = StdIn.readLine().split(\" \").map(_.toInt).toList\n if(n == 0) { return; }\n val prices = StdIn.readLine().split(\" \").map(_.toInt).toSeq\n\n\n println(solve(m, prices).map(_.toString).getOrElse(\"NONE\"))\n }\n }\n\n def solve(max: Int, prices: Seq[Int]): Option[Int] = {\n val ps = prices.toArray\n Arrays.sort(ps)\n\n var current: Int = 0\n\n for {\n (p, i) <- ps.zipWithIndex\n (q, j) <- ps.zipWithIndex\n if i < j\n } {\n val add = p + q\n if(add <= max) {\n if(current < add) {\n current = add\n }\n }\n }\n\n if(current == 0) {\n None\n } else {\n Some(current)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1511944264, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01101.html", "problem_id": "p01101", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01101/input.txt", "sample_output_relpath": "derived/input_output/data/p01101/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01101/Scala/s780176449.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s780176449", "user_id": "u346810041"}, "prompt_components": {"gold_output": "40\n10\n99\nNONE\n20\n", "input_to_evaluate": "import scala.io.StdIn\nimport java.util.Arrays\n\nobject Main {\n def main(args: Array[String]): Unit = {\n while(true) {\n val n :: m :: _res = StdIn.readLine().split(\" \").map(_.toInt).toList\n if(n == 0) { return; }\n val prices = StdIn.readLine().split(\" \").map(_.toInt).toSeq\n\n\n println(solve(m, prices).map(_.toString).getOrElse(\"NONE\"))\n }\n }\n\n def solve(max: Int, prices: Seq[Int]): Option[Int] = {\n val ps = prices.toArray\n Arrays.sort(ps)\n\n var current: Int = 0\n\n for {\n (p, i) <- ps.zipWithIndex\n (q, j) <- ps.zipWithIndex\n if i < j\n } {\n val add = p + q\n if(add <= max) {\n if(current < add) {\n current = add\n }\n }\n }\n\n if(current == 0) {\n None\n } else {\n Some(current)\n }\n }\n}", "problem_context": "Taro's Shopping\n\nMammy decided to give Taro his first shopping experience.\nMammy tells him to choose any two items he wants from those\nlisted in the shopping catalogue,\nbut Taro cannot decide which two, as all the items look attractive.\nThus he plans to buy the pair of two items with\nthe highest price sum, not exceeding the amount Mammy allows.\nAs getting two of the same item is boring, he wants two different items.\n\nYou are asked to help Taro select the two items.\nThe price list for all of the items is given.\nAmong pairs of two items in the list,\nfind the pair with the highest price sum\nnot exceeding the allowed amount,\nand report the sum.\nTaro is buying two items, not one, nor three, nor more.\nNote that, two or more items in the list may be priced equally.\n\nInput\n\nThe input consists of multiple datasets, each in the following format.\n\nn m\na1 a2 ... an\n\nA dataset consists of two lines.\nIn the first line, the number of items n and the maximum\npayment allowed m are given.\nn is an integer satisfying 2 ≤ n ≤ 1000.\nm is an integer satisfying 2 ≤ m ≤ 2,000,000.\nIn the second line, prices of n items are given.\nai (1 ≤ i ≤ n) is the price\nof the i-th item.\nThis value is an integer greater than or equal to 1 and\nless than or equal to 1,000,000.\n\nThe end of the input is indicated by a line containing two zeros.\nThe sum of n's of all the datasets does not exceed 50,000.\n\nOutput\n\nFor each dataset, find the pair with the highest price sum\nnot exceeding the allowed amount m\nand output the sum in a line.\nIf the price sum of every pair of items exceeds m,\noutput NONE instead.\n\nSample Input\n\n3 45\n10 20 30\n6 10\n1 2 5 8 9 11\n7 100\n11 34 83 47 59 29 70\n4 100\n80 70 60 50\n4 20\n10 5 10 16\n0 0\n\nOutput for the Sample Input\n\n40\n10\n99\nNONE\n20", "sample_input": "3 45\n10 20 30\n6 10\n1 2 5 8 9 11\n7 100\n11 34 83 47 59 29 70\n4 100\n80 70 60 50\n4 20\n10 5 10 16\n0 0\n"}, "reference_outputs": ["40\n10\n99\nNONE\n20\n"], "source_document_id": "p01101", "source_text": "Taro's Shopping\n\nMammy decided to give Taro his first shopping experience.\nMammy tells him to choose any two items he wants from those\nlisted in the shopping catalogue,\nbut Taro cannot decide which two, as all the items look attractive.\nThus he plans to buy the pair of two items with\nthe highest price sum, not exceeding the amount Mammy allows.\nAs getting two of the same item is boring, he wants two different items.\n\nYou are asked to help Taro select the two items.\nThe price list for all of the items is given.\nAmong pairs of two items in the list,\nfind the pair with the highest price sum\nnot exceeding the allowed amount,\nand report the sum.\nTaro is buying two items, not one, nor three, nor more.\nNote that, two or more items in the list may be priced equally.\n\nInput\n\nThe input consists of multiple datasets, each in the following format.\n\nn m\na1 a2 ... an\n\nA dataset consists of two lines.\nIn the first line, the number of items n and the maximum\npayment allowed m are given.\nn is an integer satisfying 2 ≤ n ≤ 1000.\nm is an integer satisfying 2 ≤ m ≤ 2,000,000.\nIn the second line, prices of n items are given.\nai (1 ≤ i ≤ n) is the price\nof the i-th item.\nThis value is an integer greater than or equal to 1 and\nless than or equal to 1,000,000.\n\nThe end of the input is indicated by a line containing two zeros.\nThe sum of n's of all the datasets does not exceed 50,000.\n\nOutput\n\nFor each dataset, find the pair with the highest price sum\nnot exceeding the allowed amount m\nand output the sum in a line.\nIf the price sum of every pair of items exceeds m,\noutput NONE instead.\n\nSample Input\n\n3 45\n10 20 30\n6 10\n1 2 5 8 9 11\n7 100\n11 34 83 47 59 29 70\n4 100\n80 70 60 50\n4 20\n10 5 10 16\n0 0\n\nOutput for the Sample Input\n\n40\n10\n99\nNONE\n20", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 799, "cpu_time_ms": 700, "memory_kb": 441208}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s903143652", "group_id": "codeNet:p01156", "input_text": "object Main extends App {\n val hands = List(\"Rock\", \"Fire\", \"Scissors\", \"Snake\", \"Human\", \"Tree\", \"Wolf\", \"Sponge\", \"Paper\", \"Air\", \"Water\", \"Dragon\", \"Devil\", \"Lightning\", \"Gun\") \n val h = (hands ::: hands).sliding(8).take(15).map(l => (l.head, l.tail)).toMap\n val in = io.Source.stdin.getLines\n for (n <- in if n != \"0\") {\n val x = in.take(n.toInt).toList\n x.foldLeft(x)((a, b) => a.filterNot(h(b).contains _)) match {\n case _ if n == \"1\" => println(\"Draw\")\n case x :: Nil => println(x)\n case _ => println(\"Draw\")\n }\n }\n}", "language": "Scala", "metadata": {"date": 1489757380, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01156.html", "problem_id": "p01156", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01156/input.txt", "sample_output_relpath": "derived/input_output/data/p01156/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01156/Scala/s903143652.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s903143652", "user_id": "u475394465"}, "prompt_components": {"gold_output": "Sponge\nDraw\n", "input_to_evaluate": "object Main extends App {\n val hands = List(\"Rock\", \"Fire\", \"Scissors\", \"Snake\", \"Human\", \"Tree\", \"Wolf\", \"Sponge\", \"Paper\", \"Air\", \"Water\", \"Dragon\", \"Devil\", \"Lightning\", \"Gun\") \n val h = (hands ::: hands).sliding(8).take(15).map(l => (l.head, l.tail)).toMap\n val in = io.Source.stdin.getLines\n for (n <- in if n != \"0\") {\n val x = in.take(n.toInt).toList\n x.foldLeft(x)((a, b) => a.filterNot(h(b).contains _)) match {\n case _ if n == \"1\" => println(\"Draw\")\n case x :: Nil => println(x)\n case _ => println(\"Draw\")\n }\n }\n}", "problem_context": "Problem B: Hyper Rock-Scissors-Paper\n\nRock-Scissors-Paper is a game played with hands and often used for random choice of a person for some\npurpose. Today, we have got an extended version, namely, Hyper Rock-Scissors-Paper (or Hyper RSP\nfor short).\n\nIn a game of Hyper RSP, the players simultaneously presents their hands forming any one of the following\n15 gestures: Rock, Fire, Scissors, Snake, Human, Tree, Wolf, Sponge, Paper, Air, Water, Dragon, Devil,\nLightning, and Gun.\n\nFigure 1: Hyper Rock-Scissors-Paper\n\nThe arrows in the figure above show the defeating relation. For example, Rock defeats Fire, Scissors,\nSnake, Human, Tree, Wolf, and Sponge. Fire defeats Scissors, Snake, Human, Tree, Wolf, Sponge, and\nPaper. Generally speaking, each hand defeats other seven hands located after in anti-clockwise order in\nthe figure. A player is said to win the game if the player’s hand defeats at least one of the other hands,\nand is not defeated by any of the other hands.\n\nYour task is to determine the winning hand, given multiple hands presented by the players.\n\nInput\n\nThe input consists of a series of data sets. The first line of each data set is the number N of the players\n(N < 1000). The next N lines are the hands presented by the players.\n\nThe end of the input is indicated by a line containing single zero.\n\nOutput\n\nFor each data set, output the winning hand in a single line. When there are no winners in the game,\noutput “Draw” (without quotes).\n\nSample Input\n\n8\nLightning\nGun\nPaper\nSponge\nWater\nDragon\nDevil\nAir\n3\nRock\nScissors\nPaper\n0\n\nOutput for the Sample Input\n\nSponge\nDraw", "sample_input": "8\nLightning\nGun\nPaper\nSponge\nWater\nDragon\nDevil\nAir\n3\nRock\nScissors\nPaper\n0\n"}, "reference_outputs": ["Sponge\nDraw\n"], "source_document_id": "p01156", "source_text": "Problem B: Hyper Rock-Scissors-Paper\n\nRock-Scissors-Paper is a game played with hands and often used for random choice of a person for some\npurpose. Today, we have got an extended version, namely, Hyper Rock-Scissors-Paper (or Hyper RSP\nfor short).\n\nIn a game of Hyper RSP, the players simultaneously presents their hands forming any one of the following\n15 gestures: Rock, Fire, Scissors, Snake, Human, Tree, Wolf, Sponge, Paper, Air, Water, Dragon, Devil,\nLightning, and Gun.\n\nFigure 1: Hyper Rock-Scissors-Paper\n\nThe arrows in the figure above show the defeating relation. For example, Rock defeats Fire, Scissors,\nSnake, Human, Tree, Wolf, and Sponge. Fire defeats Scissors, Snake, Human, Tree, Wolf, Sponge, and\nPaper. Generally speaking, each hand defeats other seven hands located after in anti-clockwise order in\nthe figure. A player is said to win the game if the player’s hand defeats at least one of the other hands,\nand is not defeated by any of the other hands.\n\nYour task is to determine the winning hand, given multiple hands presented by the players.\n\nInput\n\nThe input consists of a series of data sets. The first line of each data set is the number N of the players\n(N < 1000). The next N lines are the hands presented by the players.\n\nThe end of the input is indicated by a line containing single zero.\n\nOutput\n\nFor each data set, output the winning hand in a single line. When there are no winners in the game,\noutput “Draw” (without quotes).\n\nSample Input\n\n8\nLightning\nGun\nPaper\nSponge\nWater\nDragon\nDevil\nAir\n3\nRock\nScissors\nPaper\n0\n\nOutput for the Sample Input\n\nSponge\nDraw", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 592, "cpu_time_ms": 480, "memory_kb": 107296}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s382390817", "group_id": "codeNet:p01193", "input_text": "import scala.io.StdIn\n\nobject Main {\n def printResult(R1: BigInt) {\n if(R1 < 0 || R1 >= 10000){\n println(\"E\")\n }\n else{\n println(R1)\n }\n }\n def read(){\n StdIn.readLine() match {\n case line: String => {\n val digit = \"\"\"(\\d+)\"\"\".r\n var R1 = BigInt(0)\n var R2 = BigInt(0)\n var R3 = \"+\"\n val tokens = line.split(\"\").toArray\n for(i <- 0 to tokens.length - 1){\n val x = tokens(i).toString\n x match {\n case digit(x) => {\n R2 = BigInt(\"10\") * R2 + BigInt(x)\n }\n case \"+\" => {\n R1 = R1 + R2\n R2 = 0\n R3 = x\n }\n case \"-\" => {\n R1 = R1 - R2\n R2 = 0\n R3 = x\n }\n case \"*\" => {\n R1 = R1 * R2\n R2 = 0\n R3 = x\n }\n case \"=\" => {\n R3 match {\n case \"+\" => {\n R1 = R1 + R2\n R2 = 0\n printResult(R1)\n }\n case \"-\" => {\n R1 = R1 - R2\n R2 = 0\n printResult(R1)\n }\n case \"*\" => {\n R1 = R1 * R2\n R2 = 0\n printResult(R1)\n }\n case _ => {\n sys.exit()\n }\n }\n }\n case _ => {\n sys.exit()\n }\n }\n }\n }\n case _ => {\n return\n }\n }\n read()\n }\n def main(args: Array[String]){\n read()\n }\n}", "language": "Scala", "metadata": {"date": 1448186809, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01193.html", "problem_id": "p01193", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01193/input.txt", "sample_output_relpath": "derived/input_output/data/p01193/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01193/Scala/s382390817.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s382390817", "user_id": "u274875240"}, "prompt_components": {"gold_output": "55\n125\n720\nE\nE\nE\nE\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main {\n def printResult(R1: BigInt) {\n if(R1 < 0 || R1 >= 10000){\n println(\"E\")\n }\n else{\n println(R1)\n }\n }\n def read(){\n StdIn.readLine() match {\n case line: String => {\n val digit = \"\"\"(\\d+)\"\"\".r\n var R1 = BigInt(0)\n var R2 = BigInt(0)\n var R3 = \"+\"\n val tokens = line.split(\"\").toArray\n for(i <- 0 to tokens.length - 1){\n val x = tokens(i).toString\n x match {\n case digit(x) => {\n R2 = BigInt(\"10\") * R2 + BigInt(x)\n }\n case \"+\" => {\n R1 = R1 + R2\n R2 = 0\n R3 = x\n }\n case \"-\" => {\n R1 = R1 - R2\n R2 = 0\n R3 = x\n }\n case \"*\" => {\n R1 = R1 * R2\n R2 = 0\n R3 = x\n }\n case \"=\" => {\n R3 match {\n case \"+\" => {\n R1 = R1 + R2\n R2 = 0\n printResult(R1)\n }\n case \"-\" => {\n R1 = R1 - R2\n R2 = 0\n printResult(R1)\n }\n case \"*\" => {\n R1 = R1 * R2\n R2 = 0\n printResult(R1)\n }\n case _ => {\n sys.exit()\n }\n }\n }\n case _ => {\n sys.exit()\n }\n }\n }\n }\n case _ => {\n return\n }\n }\n read()\n }\n def main(args: Array[String]){\n read()\n }\n}", "problem_context": "First Experience\n\nAfter spending long long time, you had gotten tired of computer programming. Instead you were inter-\nested in electronic construction. As your first work, you built a simple calculator. It can handle positive\nintegers of up to four decimal digits, and perform addition, subtraction and multiplication of numbers.\nYou didn’t implement division just because it was so complicated. Although the calculator almost worked\nwell, you noticed that it displays unexpected results in several cases. So, you decided to try its simulation\nby a computer program in order to figure out the cause of unexpected behaviors.\n\nThe specification of the calculator you built is as follows. There are three registers on the calculator. The\nregister R1 stores the value of the operation result of the latest operation; the register R2 stores the new\ninput value; and the register R3 stores the input operator. At the beginning, both R1 and R2 hold zero,\nand R3 holds a null operator. The calculator has keys for decimal digits from ‘0’ to ‘9’ and operators\n‘+’, ‘-’, ‘×’ and ‘=’. The four operators indicate addition, subtraction, multiplication and conclusion,\nrespectively. When a digit key is pressed, R2 is multiplied by ten, and then added by the pressed digit\n(as a number). When ‘+’, ‘-’ or ‘×’ is pressed, the calculator first applies the binary operator held in R3\nto the values in R1 and R2 and updates R1 with the result of the operation. Suppose R1 has 10, R2 has\n3, and R3 has ‘-’ (subtraction operator), R1 is updated with 7 ( = 10 - 3). If R3 holds a null operator,\nthe result will be equal to the value of R2. After R1 is updated, R2 is cleared to zero and R3 is set to the\noperator which the user entered. ‘=’ indicates termination of a computation. So, when ‘=’ is pressed,\nthe calculator applies the operator held in R3 in the same manner as the other operators, and displays the\nfinal result to the user. After the final result is displayed, R3 is reinitialized with a null operator.\n\nThe calculator cannot handle numbers with five or more decimal digits. Because of that, if the intermediate computation produces a value less than 0 (i.e., a negative number) or greater than 9999, the calculator\ndisplays “E” that stands for error, and ignores the rest of the user input until ‘=’ is pressed.\n\nYour task is to write a program to simulate the simple calculator.\n\nInput\n\nThe input consists of multiple test cases.\n\nEach line of the input specifies one test case, indicating the order of key strokes which a user entered.\nThe input consists only decimal digits (from ‘0’ to ‘9’) and valid operators ‘+’, ‘-’, ‘*’ and ‘=’ where ‘*’\nstands for ‘×’.\n\nYou may assume that ‘=’ occurs only at the end of each line, and no case contains more than 80 key\nstrokes.\n\nThe end of input is indicated by EOF.\n\nOutput\n\nFor each test case, output one line which contains the result of simulation.\n\nSample Input\n\n1+2+3+4+5+6+7+8+9+10=\n1000-500-250-125=\n1*2*3*4*5*6=\n5000*5000=\n10-100=\n100*100=\n10000=\n\nOutput for the Sample Input\n\n55\n125\n720\nE\nE\nE\nE", "sample_input": "1+2+3+4+5+6+7+8+9+10=\n1000-500-250-125=\n1*2*3*4*5*6=\n5000*5000=\n10-100=\n100*100=\n10000=\n"}, "reference_outputs": ["55\n125\n720\nE\nE\nE\nE\n"], "source_document_id": "p01193", "source_text": "First Experience\n\nAfter spending long long time, you had gotten tired of computer programming. Instead you were inter-\nested in electronic construction. As your first work, you built a simple calculator. It can handle positive\nintegers of up to four decimal digits, and perform addition, subtraction and multiplication of numbers.\nYou didn’t implement division just because it was so complicated. Although the calculator almost worked\nwell, you noticed that it displays unexpected results in several cases. So, you decided to try its simulation\nby a computer program in order to figure out the cause of unexpected behaviors.\n\nThe specification of the calculator you built is as follows. There are three registers on the calculator. The\nregister R1 stores the value of the operation result of the latest operation; the register R2 stores the new\ninput value; and the register R3 stores the input operator. At the beginning, both R1 and R2 hold zero,\nand R3 holds a null operator. The calculator has keys for decimal digits from ‘0’ to ‘9’ and operators\n‘+’, ‘-’, ‘×’ and ‘=’. The four operators indicate addition, subtraction, multiplication and conclusion,\nrespectively. When a digit key is pressed, R2 is multiplied by ten, and then added by the pressed digit\n(as a number). When ‘+’, ‘-’ or ‘×’ is pressed, the calculator first applies the binary operator held in R3\nto the values in R1 and R2 and updates R1 with the result of the operation. Suppose R1 has 10, R2 has\n3, and R3 has ‘-’ (subtraction operator), R1 is updated with 7 ( = 10 - 3). If R3 holds a null operator,\nthe result will be equal to the value of R2. After R1 is updated, R2 is cleared to zero and R3 is set to the\noperator which the user entered. ‘=’ indicates termination of a computation. So, when ‘=’ is pressed,\nthe calculator applies the operator held in R3 in the same manner as the other operators, and displays the\nfinal result to the user. After the final result is displayed, R3 is reinitialized with a null operator.\n\nThe calculator cannot handle numbers with five or more decimal digits. Because of that, if the intermediate computation produces a value less than 0 (i.e., a negative number) or greater than 9999, the calculator\ndisplays “E” that stands for error, and ignores the rest of the user input until ‘=’ is pressed.\n\nYour task is to write a program to simulate the simple calculator.\n\nInput\n\nThe input consists of multiple test cases.\n\nEach line of the input specifies one test case, indicating the order of key strokes which a user entered.\nThe input consists only decimal digits (from ‘0’ to ‘9’) and valid operators ‘+’, ‘-’, ‘*’ and ‘=’ where ‘*’\nstands for ‘×’.\n\nYou may assume that ‘=’ occurs only at the end of each line, and no case contains more than 80 key\nstrokes.\n\nThe end of input is indicated by EOF.\n\nOutput\n\nFor each test case, output one line which contains the result of simulation.\n\nSample Input\n\n1+2+3+4+5+6+7+8+9+10=\n1000-500-250-125=\n1*2*3*4*5*6=\n5000*5000=\n10-100=\n100*100=\n10000=\n\nOutput for the Sample Input\n\n55\n125\n720\nE\nE\nE\nE", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1682, "cpu_time_ms": 550, "memory_kb": 81936}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s117889929", "group_id": "codeNet:p01661", "input_text": "\nobject Main extends App {\n\n import scala.io.StdIn._\n import scala.math._\n\n val Array(n, s) = readLine.trim.split(' ').map(_.toInt)\n val planets = Array.tabulate(n){i ⇒\n val Array(l, r) = readLine.trim.split(' ').map(_.toInt)\n Time(l, r)\n }\n val distance = Array.tabulate(n){_ ⇒ readLine.trim.split(' ').map(_.toInt)}\n for (i ← planets.indices){\n if (planets(i).from < distance(s - 1)(i))\n planets(i) = planets(i).copy(from = distance(s - 1)(i))\n }\n val maxTime = Array.tabulate(n){_ ⇒ 0L}\n for ((p, i) ← planets.zipWithIndex.sortBy(_._1.to)){\n if (p.to >= p.to) {\n if (maxTime(i) < p.to - p.from)\n maxTime(i) = p.to - p.from\n for ((q, j) ← planets.zipWithIndex if i != j) {\n if (q.to + distance(j)(i) <= p.from) {\n if (maxTime(i) < maxTime(j) + p.to - p.from)maxTime(i) = maxTime(j) + p.to - p.from\n } else if (q.to + distance(j)(i) <= p.to) {\n if (maxTime(i) < maxTime(j) + p.to - q.to - distance(j)(i)) maxTime(i) = maxTime(j) + p.to - q.to - distance(j)(i)\n }\n }\n }\n }\n println(\n maxTime.max\n )\n case class Planet(id: Int, time: Time)\n case class Time(from: Int, to: Int)\n}\n", "language": "Scala", "metadata": {"date": 1545380406, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01661.html", "problem_id": "p01661", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01661/input.txt", "sample_output_relpath": "derived/input_output/data/p01661/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01661/Scala/s117889929.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s117889929", "user_id": "u514597327"}, "prompt_components": {"gold_output": "150\n", "input_to_evaluate": "\nobject Main extends App {\n\n import scala.io.StdIn._\n import scala.math._\n\n val Array(n, s) = readLine.trim.split(' ').map(_.toInt)\n val planets = Array.tabulate(n){i ⇒\n val Array(l, r) = readLine.trim.split(' ').map(_.toInt)\n Time(l, r)\n }\n val distance = Array.tabulate(n){_ ⇒ readLine.trim.split(' ').map(_.toInt)}\n for (i ← planets.indices){\n if (planets(i).from < distance(s - 1)(i))\n planets(i) = planets(i).copy(from = distance(s - 1)(i))\n }\n val maxTime = Array.tabulate(n){_ ⇒ 0L}\n for ((p, i) ← planets.zipWithIndex.sortBy(_._1.to)){\n if (p.to >= p.to) {\n if (maxTime(i) < p.to - p.from)\n maxTime(i) = p.to - p.from\n for ((q, j) ← planets.zipWithIndex if i != j) {\n if (q.to + distance(j)(i) <= p.from) {\n if (maxTime(i) < maxTime(j) + p.to - p.from)maxTime(i) = maxTime(j) + p.to - p.from\n } else if (q.to + distance(j)(i) <= p.to) {\n if (maxTime(i) < maxTime(j) + p.to - q.to - distance(j)(i)) maxTime(i) = maxTime(j) + p.to - q.to - distance(j)(i)\n }\n }\n }\n }\n println(\n maxTime.max\n )\n case class Planet(id: Int, time: Time)\n case class Time(from: Int, to: Int)\n}\n", "problem_context": "F - 7歳教\n\n7歳の誕生日に\"彼\"は父から告げられた.\n\n「お前が7歳になったということは,私はもう引退だ.今日からお前が7歳教の長だ.\n\n7歳教の戒律により,7歳教の長が7歳の間だけ布教活動を行うことが認められている.\n\nこの宇宙船を使って,よりたくさんの人々に7歳教の素晴らしさを広めてきなさい.」\n\n7歳教をよりたくさんの人に広めるために\"彼\"は,自分の周りの星についての情報を集めた.\n\n\"彼\"の星の周りには,n 個の惑星があり,惑星は 1, ... , n で番号付けされていることがわかった.\n\n惑星i から 惑星jの間を移動するには,w_i_j (年)の時間がかかることもわかった.\n\nそして,それぞれの星で彼が7歳でいられる時間,つまり布教活動できる時間が異なることがわかった.\n\nそれぞれの惑星上では,宇宙暦l_i年1月1日00:00:00以降r_i年1月1日00:00:00より前までの時間帯であれば7歳でいられる.\n\nたとえ一度ある星で7歳以外の年齢になっても,その星で後から7歳になった場合や,別の星で7歳になれば布教活動を再開することができる.\n\nしかしどの星でどれくらい,そしてどの順序で布教活動を行えばより多くの人に7歳教を伝えることができるのか,\n\n\"彼\"にはわからなかった.そこで\"彼\"はプログラミングが得意なあなたに助けを求めることにした.\n\n現在は宇宙暦0年1月1日00:00:00であり,\"彼\"は惑星 s にいる.\n惑星間を最適に移動・滞在した場合に布教活動が行える最長の年数,\n\nつまり\"彼\"が7歳でかつ惑星で過ごす最長の年数Tを求めてあげよう.\nただし,年数Tには移動時間は含まれない.\n\n入力形式\n\n入力は以下の形式で与えられる.\n\nn s\nl_1 r_1\n...\nl_{n} r_{n}\nw_{1,1} w_{1,2} ... w_{1,n}\n...\nw_{n,1} w_{n,2} ... w_{n,n}\n\nn は惑星の個数である.s は主人公が最初にいる惑星をあらわす.\n\nl_i と r_i はそれぞれ,惑星i での7歳でいられる時間帯の下限と上限をあらわす.\n\nw_i_j は,惑星iから惑星jを移動するのにかかる時間をあらわす.\n\n入力はすべて整数である.\n\n出力形式\n\n答えTを出力せよ.\n\n制約\n\n1 ≤ n ≤ 500\n\n1 ≤ s ≤ n\n\n0 ≤ l_i < r_i ≤ 10^8\n\n0 ≤ w_{ij} ≤ 10^8 (i ≠j)\n\nw_{ij} = 0 (i = j)\n\n入出力例\n\n入力例 1\n\n2 1\n0 100\n150 250\n0 100\n100 0\n\n出力例 1\n\n150\n\n入力例 2\n\n5 1\n7 44\n10 49\n38 48\n11 23\n11 30\n0 1 7 2 7\n10 0 3 8 10\n4 8 0 2 5\n3 2 1 0 4\n8 4 3 3 0\n\n出力例 2\n\n41", "sample_input": "2 1\n0 100\n150 250\n0 100\n100 0\n"}, "reference_outputs": ["150\n"], "source_document_id": "p01661", "source_text": "F - 7歳教\n\n7歳の誕生日に\"彼\"は父から告げられた.\n\n「お前が7歳になったということは,私はもう引退だ.今日からお前が7歳教の長だ.\n\n7歳教の戒律により,7歳教の長が7歳の間だけ布教活動を行うことが認められている.\n\nこの宇宙船を使って,よりたくさんの人々に7歳教の素晴らしさを広めてきなさい.」\n\n7歳教をよりたくさんの人に広めるために\"彼\"は,自分の周りの星についての情報を集めた.\n\n\"彼\"の星の周りには,n 個の惑星があり,惑星は 1, ... , n で番号付けされていることがわかった.\n\n惑星i から 惑星jの間を移動するには,w_i_j (年)の時間がかかることもわかった.\n\nそして,それぞれの星で彼が7歳でいられる時間,つまり布教活動できる時間が異なることがわかった.\n\nそれぞれの惑星上では,宇宙暦l_i年1月1日00:00:00以降r_i年1月1日00:00:00より前までの時間帯であれば7歳でいられる.\n\nたとえ一度ある星で7歳以外の年齢になっても,その星で後から7歳になった場合や,別の星で7歳になれば布教活動を再開することができる.\n\nしかしどの星でどれくらい,そしてどの順序で布教活動を行えばより多くの人に7歳教を伝えることができるのか,\n\n\"彼\"にはわからなかった.そこで\"彼\"はプログラミングが得意なあなたに助けを求めることにした.\n\n現在は宇宙暦0年1月1日00:00:00であり,\"彼\"は惑星 s にいる.\n惑星間を最適に移動・滞在した場合に布教活動が行える最長の年数,\n\nつまり\"彼\"が7歳でかつ惑星で過ごす最長の年数Tを求めてあげよう.\nただし,年数Tには移動時間は含まれない.\n\n入力形式\n\n入力は以下の形式で与えられる.\n\nn s\nl_1 r_1\n...\nl_{n} r_{n}\nw_{1,1} w_{1,2} ... w_{1,n}\n...\nw_{n,1} w_{n,2} ... w_{n,n}\n\nn は惑星の個数である.s は主人公が最初にいる惑星をあらわす.\n\nl_i と r_i はそれぞれ,惑星i での7歳でいられる時間帯の下限と上限をあらわす.\n\nw_i_j は,惑星iから惑星jを移動するのにかかる時間をあらわす.\n\n入力はすべて整数である.\n\n出力形式\n\n答えTを出力せよ.\n\n制約\n\n1 ≤ n ≤ 500\n\n1 ≤ s ≤ n\n\n0 ≤ l_i < r_i ≤ 10^8\n\n0 ≤ w_{ij} ≤ 10^8 (i ≠j)\n\nw_{ij} = 0 (i = j)\n\n入出力例\n\n入力例 1\n\n2 1\n0 100\n150 250\n0 100\n100 0\n\n出力例 1\n\n150\n\n入力例 2\n\n5 1\n7 44\n10 49\n38 48\n11 23\n11 30\n0 1 7 2 7\n10 0 3 8 10\n4 8 0 2 5\n3 2 1 0 4\n8 4 3 3 0\n\n出力例 2\n\n41", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 510, "memory_kb": 79784}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s850470060", "group_id": "codeNet:p01858", "input_text": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val N = sc.nextInt()\n println(\n Array.fill(N)(sc.next()).zip(Array.fill(N)(sc.next()))\n .foldLeft(((0, 0), None: Option[Boolean]))((prev, now) =>\n prev match {\n case (_, Some(_)) => prev\n case (prevV, None) =>\n now match {\n case (\"tameru\", \"tameru\") => ((Math.min(5, prevV._1 + 1), Math.min(5, prevV._2 + 1)), prev._2)\n case (\"tameru\", \"mamoru\") => ((Math.min(5, prevV._1 + 1), prevV._2), prev._2)\n case (\"mamoru\", \"tameru\") => ((prevV._1, Math.min(5, prevV._2 + 1)), prev._2)\n case (\"mamoru\", \"mamoru\") => prev\n case (\"kougekida\", \"mamoru\") =>\n if (prevV._1 == 0) (prevV, Some(false))\n else if (prevV._1 == 5) (prevV, Some(true))\n else ((0, prevV._2), None)\n case (\"mamoru\", \"kougekida\") =>\n if (prevV._2 == 0) (prevV, Some(true))\n else if (prevV._2 == 5) (prevV, Some(false))\n else ((prevV._1, 0), None)\n case (\"kougekida\", \"tameru\") =>\n if (prevV._1 == 0) (prevV, Some(false))\n else (prevV, Some(true))\n case (\"tameru\", \"kougekida\") =>\n if (prevV._2 == 0) (prevV, Some(true))\n else (prevV, Some(false))\n case (\"kougekida\", \"kougekida\") =>\n if (prevV._1 == prevV._2) ((0, 0), None)\n else if (prevV._1 == 0) (prevV, Some(false))\n else if (prevV._2 == 0) (prevV, Some(true))\n else if (prevV._1 > prevV._2) ((prevV, Some(true)))\n else (prevV, Some(false))\n }\n }\n )\n ._2 match {\n case Some(true) => \"Isono-kun\"\n case Some(false) => \"Nakajima-kun\"\n case None => \"Hikiwake-kun\"\n })\n }\n\n def recursive(now: Long, minV: Long): Set[Long] = {\n if (Math.sqrt(now) < minV) Set(now) else {\n if (now % minV == 0) recursive(now / minV, minV + 1) + minV else recursive(now, minV + 1)\n }\n }\n\n def time(s: String): Int =\n s.substring(0, 2).toInt * 60 + s.substring(3, 5).toInt\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def calc(A: Array[Long]): Array[String] = {\n if (A.length == 0) Array.fill(0)(\"\")\n else {\n val last = A.zipWithIndex.map(x => (x._1 - x._2, x._1)).takeWhile(x => x._1 == A.head).last._2\n if (last == A.head) \"%d\".format(A.head) +: calc(A.zipWithIndex.map(x => (x._1 - x._2, x._1)).dropWhile(x => x._1 == A.head).map(x => x._2))\n else \"%d-%d\".format(A.head, last) +: calc(A.zipWithIndex.map(x => (x._1 - x._2, x._1)).dropWhile(x => x._1 == A.head).map(x => x._2))\n }\n }\n\n var memo: Map[(Long, Long), Long] = Map[(Long, Long), Long]()\n\n\n @scala.annotation.tailrec\n def recursive2(X: Set[Long], Y: Stream[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n\n def check(i: Int, X: String): Long = {\n if (X == \"\") 0 else check(i, X.tail) * i + X.head.toString.toLong\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n @scala.annotation.tailrec\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def primeFactors(i: Long): List[Long] = primeFactors_(i, 1).sorted\n\n\n def primeFactors_(i: Long, j: Long): List[Long] = {\n if (j * j > i) List.empty else if (i % j == 0) primeFactors_(i, j + 1) ++ List[Long](j, i / j) else primeFactors_(i, j + 1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n @scala.annotation.tailrec\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n @scala.annotation.tailrec\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1574173117, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01858.html", "problem_id": "p01858", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01858/input.txt", "sample_output_relpath": "derived/input_output/data/p01858/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01858/Scala/s850470060.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s850470060", "user_id": "u018134297"}, "prompt_components": {"gold_output": "Nakajima-kun\n", "input_to_evaluate": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val N = sc.nextInt()\n println(\n Array.fill(N)(sc.next()).zip(Array.fill(N)(sc.next()))\n .foldLeft(((0, 0), None: Option[Boolean]))((prev, now) =>\n prev match {\n case (_, Some(_)) => prev\n case (prevV, None) =>\n now match {\n case (\"tameru\", \"tameru\") => ((Math.min(5, prevV._1 + 1), Math.min(5, prevV._2 + 1)), prev._2)\n case (\"tameru\", \"mamoru\") => ((Math.min(5, prevV._1 + 1), prevV._2), prev._2)\n case (\"mamoru\", \"tameru\") => ((prevV._1, Math.min(5, prevV._2 + 1)), prev._2)\n case (\"mamoru\", \"mamoru\") => prev\n case (\"kougekida\", \"mamoru\") =>\n if (prevV._1 == 0) (prevV, Some(false))\n else if (prevV._1 == 5) (prevV, Some(true))\n else ((0, prevV._2), None)\n case (\"mamoru\", \"kougekida\") =>\n if (prevV._2 == 0) (prevV, Some(true))\n else if (prevV._2 == 5) (prevV, Some(false))\n else ((prevV._1, 0), None)\n case (\"kougekida\", \"tameru\") =>\n if (prevV._1 == 0) (prevV, Some(false))\n else (prevV, Some(true))\n case (\"tameru\", \"kougekida\") =>\n if (prevV._2 == 0) (prevV, Some(true))\n else (prevV, Some(false))\n case (\"kougekida\", \"kougekida\") =>\n if (prevV._1 == prevV._2) ((0, 0), None)\n else if (prevV._1 == 0) (prevV, Some(false))\n else if (prevV._2 == 0) (prevV, Some(true))\n else if (prevV._1 > prevV._2) ((prevV, Some(true)))\n else (prevV, Some(false))\n }\n }\n )\n ._2 match {\n case Some(true) => \"Isono-kun\"\n case Some(false) => \"Nakajima-kun\"\n case None => \"Hikiwake-kun\"\n })\n }\n\n def recursive(now: Long, minV: Long): Set[Long] = {\n if (Math.sqrt(now) < minV) Set(now) else {\n if (now % minV == 0) recursive(now / minV, minV + 1) + minV else recursive(now, minV + 1)\n }\n }\n\n def time(s: String): Int =\n s.substring(0, 2).toInt * 60 + s.substring(3, 5).toInt\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def calc(A: Array[Long]): Array[String] = {\n if (A.length == 0) Array.fill(0)(\"\")\n else {\n val last = A.zipWithIndex.map(x => (x._1 - x._2, x._1)).takeWhile(x => x._1 == A.head).last._2\n if (last == A.head) \"%d\".format(A.head) +: calc(A.zipWithIndex.map(x => (x._1 - x._2, x._1)).dropWhile(x => x._1 == A.head).map(x => x._2))\n else \"%d-%d\".format(A.head, last) +: calc(A.zipWithIndex.map(x => (x._1 - x._2, x._1)).dropWhile(x => x._1 == A.head).map(x => x._2))\n }\n }\n\n var memo: Map[(Long, Long), Long] = Map[(Long, Long), Long]()\n\n\n @scala.annotation.tailrec\n def recursive2(X: Set[Long], Y: Stream[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n\n def check(i: Int, X: String): Long = {\n if (X == \"\") 0 else check(i, X.tail) * i + X.head.toString.toLong\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n @scala.annotation.tailrec\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def primeFactors(i: Long): List[Long] = primeFactors_(i, 1).sorted\n\n\n def primeFactors_(i: Long, j: Long): List[Long] = {\n if (j * j > i) List.empty else if (i % j == 0) primeFactors_(i, j + 1) ++ List[Long](j, i / j) else primeFactors_(i, j + 1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n @scala.annotation.tailrec\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n @scala.annotation.tailrec\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n}\n\n", "problem_context": "A: 磯野、あれやろうぜ! - Sendame -\n\n物語\n\n中島「磯野〜,あれやろうぜ!」\n\n磯野「あれって何だよ,中島」\n\n中島「ほら,あれだよ,あれ.なぜか文字で表さなきゃならないから,説明しづらいな〜」\n\n磯野「いや,図や写真も入れられるみたいだぞ?」\n\n中島「本当だ!」\n\n磯野「で,何をやるんだ?」\n\n中島「ほら,リズムに乗って,手を2回叩いた後に,防御,溜め,攻撃のポーズを取るやつ」\n\n磯野「う〜ん,イマイチわからないな…」\n\n中島「2回手を叩いた後に,例えば防御だったら」\n\n中島「で,溜めだったら」\n\n中島「攻撃だったら」\n\n中島「ってやるやつ,知ってるだろ?」\n\n磯野「ああ!写真が入ると劇的に分かりやすくなるな!」\n\n中島「これぞ文明の進歩だな!」\n\n(それから悠久の時が経った)\n\n花沢「い゛そ゛の゛く゛〜゛ん゛な゛か゛じ゛ま゛く゛〜゛ん゛」\n\n二人「(パチパチ…パチパチ…パチパチ…)」\n\n花沢「アンタたち,まさか寝ながらあれやってるの…!?」\n\n花沢「今勝負ついたじゃない…磯野くん,今あなた勝ったわよ?」\n\n磯野「……花沢さん来てたんだ…中島もう一度やるぞ…zzz」\n\n中島「(こくり)」\n\n二人「(パチパチ…パチパチ…)」\n\n花沢「もう…ここに,あれの勝敗判定ロボット置いておくから…」\n\nそうして花沢さんは去って行った.\n\nということがあるかもしれないので,あれの勝敗判定プログラムを書いてください.\n\n問題\n\n「あれ」は2人で行うゲームである.リズムに合わせて2人が同時に,防御,溜め,攻撃のいずれかのポーズを取ることを繰り返す.ここで,2人がポーズを取るタイミングのことを「回」と表記する.このゲームでは,ある回で勝敗がつき,かつ,それまでの回で勝敗がついていないとき,その勝敗がゲームの勝敗となる.\n\n2人はそれぞれ「攻撃力」というパラメータを持ち,ゲーム開始時,攻撃力は 0 である.\n\n攻撃のポーズを取った場合,その時点での攻撃力に応じて,次のようになる.\n\n攻撃力が 0 のときに攻撃のポーズを取ると,反則負けとなる.ただし,相手も攻撃力が 0 で攻撃のポーズをした場合,その回では勝敗がつかない.\n\n自分の攻撃力が 1 以上のときに攻撃のポーズをとると,相手に攻撃を加える.また,その回で相手も攻撃のポーズを取った場合,攻撃力のより高いプレイヤーが勝利する.ただし,両プレイヤーが同じ攻撃力で攻撃のポーズを取った場合には,その回では勝敗がつかない.\n\nまた,攻撃のポーズを取った回の終了時に,自分の攻撃力が 0 になる.\n\n溜めのポーズを取ると,そのプレイヤーの攻撃力が 1 だけ上昇する.ただし,攻撃力が 5 である場合,そのプレイヤーが溜めのポーズを取っても,攻撃力は 5 のままである.溜めのポーズを取った回で,相手が攻撃を加えた場合,相手が勝利する.なお,溜めのポーズを取った回で,相手が攻撃以外のポーズをとった場合,勝敗がつかない.\n\n防御のポーズを取った回に,相手が攻撃力 5 の攻撃を加えた場合,相手が勝利する.一方,防御のポーズを取った回に,相手が攻撃力 4 以下の攻撃を加えた場合や,溜めまたは防御のポーズを取った場合,その回では勝敗がつかない.なお,防御のポーズを取っても,そのプレイヤーの攻撃力に変化はない.\n\n両プレイヤーのポーズが順に与えられるので,勝敗を出力せよ.なお,両プレイヤーは勝敗が決定した後もポーズをとり続けることがあるが,勝敗が決定した後のポーズは無視するものとする.\n\n入力形式\n\n入力は以下の形式で与えられる.\n\nK\nI_1\n...\nI_K\nN_1\n...\nN_K\n\n入力の1行目には,1個の整数 K ( 1 ≤ K ≤ 100) が与えられる.\n2行目からの K 行には,磯野が取ったポーズ I_i (1 ≤ i ≤ K) が順に与えられる.\nその直後の K 行には,中島が取ったポーズ N_i (1 ≤ i ≤ K) が順に与えられる.\nI_i および N_i は “mamoru”, “tameru”, “kougekida” のいずれかである.これらの文字列は順に,防御,溜め,攻撃のポーズを表す.\n\n出力形式\n\n磯野が勝利した場合には “Isono-kun” ,中島が勝利した場合には “Nakajima-kun” , K 回で勝敗がつかない場合には, “Hikiwake-kun” と1行で出力せよ.\n\n入力例1\n\n3\ntameru\ntameru\ntameru\ntameru\nkougekida\ntameru\n\n出力例1\n\nNakajima-kun\n\n2 回目で,磯野が溜めのポーズをしているのに対し,中島は攻撃力 1 の攻撃をしているので,中島の勝利です.\n\n入力例2\n\n3\nmamoru\nmamoru\nmamoru\ntameru\ntameru\ntameru\n\n出力例2\n\nHikiwake-kun\n\nどちらも攻撃をしなかったので,勝敗がつきませんでした.\n\n入力例3\n\n5\ntameru\ntameru\nmamoru\nmamoru\nkougekida\ntameru\ntameru\nkougekida\ntameru\nkougekida\n\n出力例3\n\nIsono-kun\n\n1 回目から 4 回目まででは勝敗がつきません. 5 回目で,両プレイヤーが攻撃のポーズをしていますが,磯野の攻撃力が 2 なのに対し,中島の攻撃力が 1 なので,磯野の勝利です.\n\n入力例4\n\n3\nkougekida\nkougekida\ntameru\nkougekida\nmamoru\nkougekida\n\n出力例4\n\nNakajima-kun\n\n1 回目では,両プレイヤーが攻撃力 0 で攻撃のポーズを取っているので,勝敗がつきません. 2 回目では,磯野のみが攻撃力 0 で攻撃のポーズをとっているので,中島の勝利です.\n\n入力例5\n\n8\ntameru\nmamoru\ntameru\ntameru\ntameru\ntameru\ntameru\nkougekida\ntameru\nkougekida\nmamoru\nmamoru\nmamoru\nmamoru\nmamoru\nmamoru\n\n出力例5\n\nIsono-kun\n\n2 回目では,中島が攻撃力 1 で攻撃のポーズを取っていますが,磯野が防御のポーズを取っているので,勝敗がつきません. 7 回目では,磯野が攻撃力 5 で溜めのポーズを取っているので,磯野の攻撃力は 5 のままです. 8 回目では,磯野が攻撃力 5 で攻撃のポーズをとり,中島が防御のポーズを取っているので,磯野が勝利します.", "sample_input": "3\ntameru\ntameru\ntameru\ntameru\nkougekida\ntameru\n"}, "reference_outputs": ["Nakajima-kun\n"], "source_document_id": "p01858", "source_text": "A: 磯野、あれやろうぜ! - Sendame -\n\n物語\n\n中島「磯野〜,あれやろうぜ!」\n\n磯野「あれって何だよ,中島」\n\n中島「ほら,あれだよ,あれ.なぜか文字で表さなきゃならないから,説明しづらいな〜」\n\n磯野「いや,図や写真も入れられるみたいだぞ?」\n\n中島「本当だ!」\n\n磯野「で,何をやるんだ?」\n\n中島「ほら,リズムに乗って,手を2回叩いた後に,防御,溜め,攻撃のポーズを取るやつ」\n\n磯野「う〜ん,イマイチわからないな…」\n\n中島「2回手を叩いた後に,例えば防御だったら」\n\n中島「で,溜めだったら」\n\n中島「攻撃だったら」\n\n中島「ってやるやつ,知ってるだろ?」\n\n磯野「ああ!写真が入ると劇的に分かりやすくなるな!」\n\n中島「これぞ文明の進歩だな!」\n\n(それから悠久の時が経った)\n\n花沢「い゛そ゛の゛く゛〜゛ん゛な゛か゛じ゛ま゛く゛〜゛ん゛」\n\n二人「(パチパチ…パチパチ…パチパチ…)」\n\n花沢「アンタたち,まさか寝ながらあれやってるの…!?」\n\n花沢「今勝負ついたじゃない…磯野くん,今あなた勝ったわよ?」\n\n磯野「……花沢さん来てたんだ…中島もう一度やるぞ…zzz」\n\n中島「(こくり)」\n\n二人「(パチパチ…パチパチ…)」\n\n花沢「もう…ここに,あれの勝敗判定ロボット置いておくから…」\n\nそうして花沢さんは去って行った.\n\nということがあるかもしれないので,あれの勝敗判定プログラムを書いてください.\n\n問題\n\n「あれ」は2人で行うゲームである.リズムに合わせて2人が同時に,防御,溜め,攻撃のいずれかのポーズを取ることを繰り返す.ここで,2人がポーズを取るタイミングのことを「回」と表記する.このゲームでは,ある回で勝敗がつき,かつ,それまでの回で勝敗がついていないとき,その勝敗がゲームの勝敗となる.\n\n2人はそれぞれ「攻撃力」というパラメータを持ち,ゲーム開始時,攻撃力は 0 である.\n\n攻撃のポーズを取った場合,その時点での攻撃力に応じて,次のようになる.\n\n攻撃力が 0 のときに攻撃のポーズを取ると,反則負けとなる.ただし,相手も攻撃力が 0 で攻撃のポーズをした場合,その回では勝敗がつかない.\n\n自分の攻撃力が 1 以上のときに攻撃のポーズをとると,相手に攻撃を加える.また,その回で相手も攻撃のポーズを取った場合,攻撃力のより高いプレイヤーが勝利する.ただし,両プレイヤーが同じ攻撃力で攻撃のポーズを取った場合には,その回では勝敗がつかない.\n\nまた,攻撃のポーズを取った回の終了時に,自分の攻撃力が 0 になる.\n\n溜めのポーズを取ると,そのプレイヤーの攻撃力が 1 だけ上昇する.ただし,攻撃力が 5 である場合,そのプレイヤーが溜めのポーズを取っても,攻撃力は 5 のままである.溜めのポーズを取った回で,相手が攻撃を加えた場合,相手が勝利する.なお,溜めのポーズを取った回で,相手が攻撃以外のポーズをとった場合,勝敗がつかない.\n\n防御のポーズを取った回に,相手が攻撃力 5 の攻撃を加えた場合,相手が勝利する.一方,防御のポーズを取った回に,相手が攻撃力 4 以下の攻撃を加えた場合や,溜めまたは防御のポーズを取った場合,その回では勝敗がつかない.なお,防御のポーズを取っても,そのプレイヤーの攻撃力に変化はない.\n\n両プレイヤーのポーズが順に与えられるので,勝敗を出力せよ.なお,両プレイヤーは勝敗が決定した後もポーズをとり続けることがあるが,勝敗が決定した後のポーズは無視するものとする.\n\n入力形式\n\n入力は以下の形式で与えられる.\n\nK\nI_1\n...\nI_K\nN_1\n...\nN_K\n\n入力の1行目には,1個の整数 K ( 1 ≤ K ≤ 100) が与えられる.\n2行目からの K 行には,磯野が取ったポーズ I_i (1 ≤ i ≤ K) が順に与えられる.\nその直後の K 行には,中島が取ったポーズ N_i (1 ≤ i ≤ K) が順に与えられる.\nI_i および N_i は “mamoru”, “tameru”, “kougekida” のいずれかである.これらの文字列は順に,防御,溜め,攻撃のポーズを表す.\n\n出力形式\n\n磯野が勝利した場合には “Isono-kun” ,中島が勝利した場合には “Nakajima-kun” , K 回で勝敗がつかない場合には, “Hikiwake-kun” と1行で出力せよ.\n\n入力例1\n\n3\ntameru\ntameru\ntameru\ntameru\nkougekida\ntameru\n\n出力例1\n\nNakajima-kun\n\n2 回目で,磯野が溜めのポーズをしているのに対し,中島は攻撃力 1 の攻撃をしているので,中島の勝利です.\n\n入力例2\n\n3\nmamoru\nmamoru\nmamoru\ntameru\ntameru\ntameru\n\n出力例2\n\nHikiwake-kun\n\nどちらも攻撃をしなかったので,勝敗がつきませんでした.\n\n入力例3\n\n5\ntameru\ntameru\nmamoru\nmamoru\nkougekida\ntameru\ntameru\nkougekida\ntameru\nkougekida\n\n出力例3\n\nIsono-kun\n\n1 回目から 4 回目まででは勝敗がつきません. 5 回目で,両プレイヤーが攻撃のポーズをしていますが,磯野の攻撃力が 2 なのに対し,中島の攻撃力が 1 なので,磯野の勝利です.\n\n入力例4\n\n3\nkougekida\nkougekida\ntameru\nkougekida\nmamoru\nkougekida\n\n出力例4\n\nNakajima-kun\n\n1 回目では,両プレイヤーが攻撃力 0 で攻撃のポーズを取っているので,勝敗がつきません. 2 回目では,磯野のみが攻撃力 0 で攻撃のポーズをとっているので,中島の勝利です.\n\n入力例5\n\n8\ntameru\nmamoru\ntameru\ntameru\ntameru\ntameru\ntameru\nkougekida\ntameru\nkougekida\nmamoru\nmamoru\nmamoru\nmamoru\nmamoru\nmamoru\n\n出力例5\n\nIsono-kun\n\n2 回目では,中島が攻撃力 1 で攻撃のポーズを取っていますが,磯野が防御のポーズを取っているので,勝敗がつきません. 7 回目では,磯野が攻撃力 5 で溜めのポーズを取っているので,磯野の攻撃力は 5 のままです. 8 回目では,磯野が攻撃力 5 で攻撃のポーズをとり,中島が防御のポーズを取っているので,磯野が勝利します.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 8847, "cpu_time_ms": 330, "memory_kb": 44520}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s586058418", "group_id": "codeNet:p01900", "input_text": "import scala.collection.mutable.Queue\nimport io.StdIn\n\nobject Main extends App {\n val n = StdIn.readInt\n val seq = StdIn.readLine.split(\" \").map(_.toInt % 3)\n val a = for(i <- 0 until 3) yield seq.count(_ == i)\n\n def bfs(first:Tuple5[Int,Int,Int,Int,Int]):Int = {\n\n val que = new Queue[Tuple5[Int,Int,Int,Int,Int]]\n que += first\n var cur = (0,0,0,0,0)\n\n var isCnt = true\n while(isCnt || !que.isEmpty) {\n cur = que.dequeue\n\n if(cur._2 == 0 || (cur._3 == 0 && cur._4 == 0 && cur._5 == 0)) isCnt = false\n else {\n cur match {\n case (acc, 1, c0, c1, c2) if c0 != 0 => que += {(acc+1, 1, c0-1, c1, c2)}\n case (acc, 2, c0, c1, c2) if c0 != 0 => que += {(acc+1, 2, c0-1, c1, c2)}\n case (acc, 1, c0, c1, c2) if c1 != 0 => que += {(acc+1, 2, 0, c1-1, c2)}\n case (acc, 2, c0, c1, c2) if c2 != 0 => que += {(acc+1, 1, 0, c1, c2-1)}\n case (acc, 2, c0, c1, c2) if c1 != 0 => que += {(acc+1, 0, 0, c1-1, 0)}\n case (acc, 1, c0, c1, c2) if c2 != 0 => que += {(acc+1, 0, 0, 0, c2-1)}\n }\n }\n }\n cur._1\n }\n\n val res1 = bfs(0,1,a(0),a(1)-1,a(2)) + 1\n val res2 = bfs(0,2,a(0),a(1),a(2)-1) + 1\n val ans = if(a.drop(1).sum == 0) 1 else math.max(res1,res2)\n println(ans)\n}\n", "language": "Scala", "metadata": {"date": 1545800964, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01900.html", "problem_id": "p01900", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01900/input.txt", "sample_output_relpath": "derived/input_output/data/p01900/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01900/Scala/s586058418.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s586058418", "user_id": "u768801062"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import scala.collection.mutable.Queue\nimport io.StdIn\n\nobject Main extends App {\n val n = StdIn.readInt\n val seq = StdIn.readLine.split(\" \").map(_.toInt % 3)\n val a = for(i <- 0 until 3) yield seq.count(_ == i)\n\n def bfs(first:Tuple5[Int,Int,Int,Int,Int]):Int = {\n\n val que = new Queue[Tuple5[Int,Int,Int,Int,Int]]\n que += first\n var cur = (0,0,0,0,0)\n\n var isCnt = true\n while(isCnt || !que.isEmpty) {\n cur = que.dequeue\n\n if(cur._2 == 0 || (cur._3 == 0 && cur._4 == 0 && cur._5 == 0)) isCnt = false\n else {\n cur match {\n case (acc, 1, c0, c1, c2) if c0 != 0 => que += {(acc+1, 1, c0-1, c1, c2)}\n case (acc, 2, c0, c1, c2) if c0 != 0 => que += {(acc+1, 2, c0-1, c1, c2)}\n case (acc, 1, c0, c1, c2) if c1 != 0 => que += {(acc+1, 2, 0, c1-1, c2)}\n case (acc, 2, c0, c1, c2) if c2 != 0 => que += {(acc+1, 1, 0, c1, c2-1)}\n case (acc, 2, c0, c1, c2) if c1 != 0 => que += {(acc+1, 0, 0, c1-1, 0)}\n case (acc, 1, c0, c1, c2) if c2 != 0 => que += {(acc+1, 0, 0, 0, c2-1)}\n }\n }\n }\n cur._1\n }\n\n val res1 = bfs(0,1,a(0),a(1)-1,a(2)) + 1\n val res2 = bfs(0,2,a(0),a(1),a(2)-1) + 1\n val ans = if(a.drop(1).sum == 0) 1 else math.max(res1,res2)\n println(ans)\n}\n", "problem_context": "C : Mod!Mod!\n\n物語\n\nじゃん!探してますよ目撃証言!\n会津に怪盗が現れた!みんなのウマウマ棒が盗まれた!犯人は誰だ!?\n解きあかせ!Mod!Mod!\n\n問題文\n\n\"アイズ\"...それは選ばれし者の心に膨らむ奇跡のつぼみ...。特殊能力\"アイズ\"を使えばどんなものだって盗むことができる。\n\n会津一の大怪盗、あいずまるは世界を謎で満たすためにn人の探偵から「ウマウマ棒」を盗むことにした。ウマウマ棒とはあいずまるが大好きなただのお菓子であり、n人の探偵はそれぞれ数本のウマウマ棒を持っている。また、あいずまるは強欲なためそれぞれの探偵からウマウマ棒を盗むとき、その探偵が所持する全てのウマウマ棒を盗む。\n\nウマウマ棒の3本同時食いにハマっているあいずまるは、3本以上のウマウマ棒が手元にあるとき、誘惑に負けて手持ちのウマウマ棒が3本未満になるまで、3本ずつウマウマ棒を食べてしまう。しかし、あいずまるは手元にウマウマ棒がないとショックでアイズを失ってしまい、それ以上ウマウマ棒を盗むことができなくなってしまう。つまり、ウマウマ棒を盗むためには手持ちのウマウマ棒の本数を1本以上にしておく必要があり、0本になるとそれ以上ウマウマ棒を盗むことができなくなる。\n\n少しでも多くの探偵からウマウマ棒を盗みたいあいずまるは、どの探偵から順にウマウマ棒を盗むかによって何人の探偵からウマウマ棒を盗めるのかが変わることに気づいた。しかし、あいずまるには難しいことは分からない。「ハテー?」あいずまるの優秀な部下であるあなたは、あいずまるの代わりに最大で何人の探偵からウマウマ棒を盗むことができるのかを求めるプログラムを書いてあげることにした。\n\n探偵の人数nと、n人の探偵からそれぞれ何本のウマウマ棒を盗むのかが与えられるので、最適な順番で探偵からウマウマ棒を盗んだとき、最大で何人の探偵からウマウマ棒を盗むことができるかを出力するプログラムを作成せよ。ただし、はじめの手持ちのウマウマ棒の本数は0であるが、最初に限り手持ちが0本でもウマウマ棒を盗むことができるとする。\n\n入力形式\n\n入力は2行からなり、以下の形式で与えられる。\n\nn\na_1 a_2 … a_n\n\n1行目には、ウマウマ棒を盗む探偵の数である整数nが与えられる。\n2行目には、各探偵から盗むウマウマ棒の本数n個が空白区切りで与えられる。\n\n制約\n\n1 ≤ n ≤ 500{,}000\n\n1 ≤ a_i ≤ 9 (1 ≤ i ≤ n)\n\n出力形式\n\n最適な順番で探偵からウマウマ棒を盗んだとき、最大で何人の探偵からウマウマ棒を盗むことができるか一行に出力せよ。\n\n入力例1\n\n6\n2 5 2 5 2 1\n\n出力例1\n\n5\n\n2 5 1 2 5の順で盗むと5人から盗むことができる。どのような順序で盗んでも6人から盗むことはできない。\n\n入力例2\n\n3\n3 6 9\n\n出力例2\n\n1\n\nどの1人から盗んでも手持ちのウマウマ棒の本数は0になってしまい、アイズを失ってしまう。\n\n入力例3\n\n6\n1 2 3 4 5 6\n\n出力例3\n\n6", "sample_input": "6\n2 5 2 5 2 1\n"}, "reference_outputs": ["5\n"], "source_document_id": "p01900", "source_text": "C : Mod!Mod!\n\n物語\n\nじゃん!探してますよ目撃証言!\n会津に怪盗が現れた!みんなのウマウマ棒が盗まれた!犯人は誰だ!?\n解きあかせ!Mod!Mod!\n\n問題文\n\n\"アイズ\"...それは選ばれし者の心に膨らむ奇跡のつぼみ...。特殊能力\"アイズ\"を使えばどんなものだって盗むことができる。\n\n会津一の大怪盗、あいずまるは世界を謎で満たすためにn人の探偵から「ウマウマ棒」を盗むことにした。ウマウマ棒とはあいずまるが大好きなただのお菓子であり、n人の探偵はそれぞれ数本のウマウマ棒を持っている。また、あいずまるは強欲なためそれぞれの探偵からウマウマ棒を盗むとき、その探偵が所持する全てのウマウマ棒を盗む。\n\nウマウマ棒の3本同時食いにハマっているあいずまるは、3本以上のウマウマ棒が手元にあるとき、誘惑に負けて手持ちのウマウマ棒が3本未満になるまで、3本ずつウマウマ棒を食べてしまう。しかし、あいずまるは手元にウマウマ棒がないとショックでアイズを失ってしまい、それ以上ウマウマ棒を盗むことができなくなってしまう。つまり、ウマウマ棒を盗むためには手持ちのウマウマ棒の本数を1本以上にしておく必要があり、0本になるとそれ以上ウマウマ棒を盗むことができなくなる。\n\n少しでも多くの探偵からウマウマ棒を盗みたいあいずまるは、どの探偵から順にウマウマ棒を盗むかによって何人の探偵からウマウマ棒を盗めるのかが変わることに気づいた。しかし、あいずまるには難しいことは分からない。「ハテー?」あいずまるの優秀な部下であるあなたは、あいずまるの代わりに最大で何人の探偵からウマウマ棒を盗むことができるのかを求めるプログラムを書いてあげることにした。\n\n探偵の人数nと、n人の探偵からそれぞれ何本のウマウマ棒を盗むのかが与えられるので、最適な順番で探偵からウマウマ棒を盗んだとき、最大で何人の探偵からウマウマ棒を盗むことができるかを出力するプログラムを作成せよ。ただし、はじめの手持ちのウマウマ棒の本数は0であるが、最初に限り手持ちが0本でもウマウマ棒を盗むことができるとする。\n\n入力形式\n\n入力は2行からなり、以下の形式で与えられる。\n\nn\na_1 a_2 … a_n\n\n1行目には、ウマウマ棒を盗む探偵の数である整数nが与えられる。\n2行目には、各探偵から盗むウマウマ棒の本数n個が空白区切りで与えられる。\n\n制約\n\n1 ≤ n ≤ 500{,}000\n\n1 ≤ a_i ≤ 9 (1 ≤ i ≤ n)\n\n出力形式\n\n最適な順番で探偵からウマウマ棒を盗んだとき、最大で何人の探偵からウマウマ棒を盗むことができるか一行に出力せよ。\n\n入力例1\n\n6\n2 5 2 5 2 1\n\n出力例1\n\n5\n\n2 5 1 2 5の順で盗むと5人から盗むことができる。どのような順序で盗んでも6人から盗むことはできない。\n\n入力例2\n\n3\n3 6 9\n\n出力例2\n\n1\n\nどの1人から盗んでも手持ちのウマウマ棒の本数は0になってしまい、アイズを失ってしまう。\n\n入力例3\n\n6\n1 2 3 4 5 6\n\n出力例3\n\n6", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1266, "cpu_time_ms": 230, "memory_kb": 44188}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s899931128", "group_id": "codeNet:p01933", "input_text": "import java.util.Scanner\n\nobject Main {\n def solve(sc: => Scanner): Long = {\n val N, K = sc.nextInt\n val A = Array.fill(N)(sc.nextInt - 1)\n val Ans = A.map(X => X == -1)\n val leaf = Array.fill(N)(true)\n for (i <- 0 until N) {\n if (A(i) != -1) (leaf(A(i)) = false)\n }\n var i = 0\n while (i < N) {\n if (leaf(i)) {\n var now = i\n var idx = 0\n while (idx < K && A(now) != -1) {\n Ans(now) = true\n if (A(now) != -1) (now = A(now))\n idx += 1\n }\n }\n i += 1\n }\n Ans.filter(x => x).length\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n\n println(solve(sc))\n }\n}", "language": "Scala", "metadata": {"date": 1508319501, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01933.html", "problem_id": "p01933", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01933/input.txt", "sample_output_relpath": "derived/input_output/data/p01933/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01933/Scala/s899931128.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s899931128", "user_id": "u018134297"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def solve(sc: => Scanner): Long = {\n val N, K = sc.nextInt\n val A = Array.fill(N)(sc.nextInt - 1)\n val Ans = A.map(X => X == -1)\n val leaf = Array.fill(N)(true)\n for (i <- 0 until N) {\n if (A(i) != -1) (leaf(A(i)) = false)\n }\n var i = 0\n while (i < N) {\n if (leaf(i)) {\n var now = i\n var idx = 0\n while (idx < K && A(now) != -1) {\n Ans(now) = true\n if (A(now) != -1) (now = A(now))\n idx += 1\n }\n }\n i += 1\n }\n Ans.filter(x => x).length\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n\n println(solve(sc))\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: {inlineMath: [['$','$'], ['\\\\(','\\\\)']]} });\n\nC: ツイート数\n\n問題\n\nAORイカちゃんが利用するSNSであるイカったーでは、投稿のことをツイートと呼ぶ。\n\nそして、イカったーでは、ツイートへの返信が多くなると視認性が悪くなることが懸念されるため、あるツイートが次の規則のいずれかを満たすときに画面にそのツイートを表示する仕様になっている。\n\n規則1. どのツイートへも返信していない\n\n規則2. どのツイートからも返信されていない\n\n規則3. 規則2が適用されたツイートから返信先を順に辿ったとき、 $K$ 回未満で辿り着ける\n\nなお、同じツイートは重複して表示されることはない。\n\nいま、 $N$ 個のツイートがあり、 $A_i$ が $0$ のとき $i$ 番目のツイートは返信でないツイートで、 $A_i$ が $0$ でないとき $i$ 番目のツイートは $A_i$ 番目のツイートへの返信のツイートである。\n\n画面に表示されるツイート数を答えよ。\n\n制約\n\n$1 \\le N \\le 10^5$\n\n$1 \\le K \\le 10^5$\n\n$0 \\le A_i \\lt i (i = 1, 2, \\dots, N)$\n\nツイートは時系列順に与えられる。\n\n入力は全て整数で与えられる。\n\n入力形式\n\n入力は以下の形式で与えられる。\n\n$N \\ K$\n$A_1$\n$A_2$\n$\\vdots$\n$A_N$\n\n出力\n\n画面に表示されるツイート数を出力せよ。また、末尾に改行も出力せよ。\n\nサンプル\n\nサンプル入力 1\n\n6 3\n0\n0\n2\n3\n4\n5\n\nサンプル出力 1\n\n5\n\nこの時、表示されるツイートは、図の青いツイートである。 よって、この例の解は $5$ である。\n\nサンプル入力 2\n\n12 2\n0\n1\n0\n3\n4\n3\n6\n7\n0\n9\n10\n11\n\nサンプル出力 2\n\n10\n\nサンプル入力 3\n\n5 10\n0\n0\n0\n0\n0\n\nサンプル出力 3\n\n5", "sample_input": "6 3\n0\n0\n2\n3\n4\n5\n"}, "reference_outputs": ["5\n"], "source_document_id": "p01933", "source_text": "MathJax.Hub.Config({ tex2jax: {inlineMath: [['$','$'], ['\\\\(','\\\\)']]} });\n\nC: ツイート数\n\n問題\n\nAORイカちゃんが利用するSNSであるイカったーでは、投稿のことをツイートと呼ぶ。\n\nそして、イカったーでは、ツイートへの返信が多くなると視認性が悪くなることが懸念されるため、あるツイートが次の規則のいずれかを満たすときに画面にそのツイートを表示する仕様になっている。\n\n規則1. どのツイートへも返信していない\n\n規則2. どのツイートからも返信されていない\n\n規則3. 規則2が適用されたツイートから返信先を順に辿ったとき、 $K$ 回未満で辿り着ける\n\nなお、同じツイートは重複して表示されることはない。\n\nいま、 $N$ 個のツイートがあり、 $A_i$ が $0$ のとき $i$ 番目のツイートは返信でないツイートで、 $A_i$ が $0$ でないとき $i$ 番目のツイートは $A_i$ 番目のツイートへの返信のツイートである。\n\n画面に表示されるツイート数を答えよ。\n\n制約\n\n$1 \\le N \\le 10^5$\n\n$1 \\le K \\le 10^5$\n\n$0 \\le A_i \\lt i (i = 1, 2, \\dots, N)$\n\nツイートは時系列順に与えられる。\n\n入力は全て整数で与えられる。\n\n入力形式\n\n入力は以下の形式で与えられる。\n\n$N \\ K$\n$A_1$\n$A_2$\n$\\vdots$\n$A_N$\n\n出力\n\n画面に表示されるツイート数を出力せよ。また、末尾に改行も出力せよ。\n\nサンプル\n\nサンプル入力 1\n\n6 3\n0\n0\n2\n3\n4\n5\n\nサンプル出力 1\n\n5\n\nこの時、表示されるツイートは、図の青いツイートである。 よって、この例の解は $5$ である。\n\nサンプル入力 2\n\n12 2\n0\n1\n0\n3\n4\n3\n6\n7\n0\n9\n10\n11\n\nサンプル出力 2\n\n10\n\nサンプル入力 3\n\n5 10\n0\n0\n0\n0\n0\n\nサンプル出力 3\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 4430, "memory_kb": 130748}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s963767771", "group_id": "codeNet:p01980", "input_text": "\nobject Main extends App {\n\n import scala.io.StdIn._\n import scala.math._\n\n\n val Array(n, m, q) = readLine.trim.split(' ').map(_.toInt)\n val floors = SegTree(1, n)\n for (_ ← 0 until m) {\n val Array(d, a, b) = readLine.trim.split(' ').map(_.toInt)\n floors.setUpperLimit(a, b - 1, d)\n }\n for (_ ← 0 until q){\n val Array(e, s, t) = readLine.trim.split(' ').map(_.toInt)\n val day = floors.maxBetween(s, t - 1)\n println(\n if (day < e) \"Yes\"\n else \"No\"\n )\n }\n object SegTree{\n def apply(from: Int, to: Int, default: Int = Int.MaxValue): SegTree = {\n if (from == to) new Leaf(default, from)\n else new Node(from, to, SegTree(from, (from + to) / 2, default), SegTree((from + to) / 2 + 1, to, default))\n }\n }\n sealed trait SegTree{\n def maxBetween(from: Int, to: Int): Int\n def setUpperLimit(from: Int, to: Int, limit: Int): Unit\n def upper: Int\n }\n class Node(private val mFrom: Int, private val mTo: Int, private val mLeft: SegTree, private val mRight: SegTree) extends SegTree {\n override def upper: Int = mUpper\n private var mUpper = math.max(mLeft.upper, mRight.upper)\n\n override def setUpperLimit(from: Int, to: Int, limit: Int): Unit = {\n if (mUpper > limit) {\n if (from <= mFrom && mTo <= to) {\n mUpper = limit\n } else if (from <= mTo && mFrom <= to) {\n mLeft.setUpperLimit(mFrom, mTo, mUpper)\n mLeft.setUpperLimit(from, to, limit)\n mRight.setUpperLimit(mFrom, mTo, mUpper)\n mRight.setUpperLimit(from, to, limit)\n mUpper = math.max(mLeft.upper, mRight.upper)\n }\n }\n }\n override def maxBetween(from: Int, to: Int): Int = {\n if (to < mFrom || mTo < from) Int.MinValue\n else if (from <= mFrom && mTo <= to) mUpper\n else {\n mLeft.setUpperLimit(mFrom, mTo, mUpper)\n mRight.setUpperLimit(mFrom, mTo, mUpper)\n math.max(mLeft.maxBetween(from, to), mRight.maxBetween(from, to))\n }\n }\n }\n class Leaf(private var mValue: Int, private val mPosition: Int) extends SegTree {\n override def maxBetween(from: Int, to: Int): Int = {\n if ((from to to).contains(mPosition)) mValue\n else Int.MinValue\n }\n\n override def setUpperLimit(from: Int, to: Int, limit: Int): Unit = {\n if ((from to to).contains(mPosition) && limit < mValue) mValue = limit\n }\n\n override def upper: Int = mValue\n }\n implicit class Extension[T](val value :T){\n def also(func: T ⇒ Unit): T = {\n func(value)\n value\n }\n def let[R](func: T ⇒ R): R = func(value)\n }\n}\n", "language": "Scala", "metadata": {"date": 1545574805, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01980.html", "problem_id": "p01980", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01980/input.txt", "sample_output_relpath": "derived/input_output/data/p01980/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01980/Scala/s963767771.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s963767771", "user_id": "u514597327"}, "prompt_components": {"gold_output": "No\nYes\n", "input_to_evaluate": "\nobject Main extends App {\n\n import scala.io.StdIn._\n import scala.math._\n\n\n val Array(n, m, q) = readLine.trim.split(' ').map(_.toInt)\n val floors = SegTree(1, n)\n for (_ ← 0 until m) {\n val Array(d, a, b) = readLine.trim.split(' ').map(_.toInt)\n floors.setUpperLimit(a, b - 1, d)\n }\n for (_ ← 0 until q){\n val Array(e, s, t) = readLine.trim.split(' ').map(_.toInt)\n val day = floors.maxBetween(s, t - 1)\n println(\n if (day < e) \"Yes\"\n else \"No\"\n )\n }\n object SegTree{\n def apply(from: Int, to: Int, default: Int = Int.MaxValue): SegTree = {\n if (from == to) new Leaf(default, from)\n else new Node(from, to, SegTree(from, (from + to) / 2, default), SegTree((from + to) / 2 + 1, to, default))\n }\n }\n sealed trait SegTree{\n def maxBetween(from: Int, to: Int): Int\n def setUpperLimit(from: Int, to: Int, limit: Int): Unit\n def upper: Int\n }\n class Node(private val mFrom: Int, private val mTo: Int, private val mLeft: SegTree, private val mRight: SegTree) extends SegTree {\n override def upper: Int = mUpper\n private var mUpper = math.max(mLeft.upper, mRight.upper)\n\n override def setUpperLimit(from: Int, to: Int, limit: Int): Unit = {\n if (mUpper > limit) {\n if (from <= mFrom && mTo <= to) {\n mUpper = limit\n } else if (from <= mTo && mFrom <= to) {\n mLeft.setUpperLimit(mFrom, mTo, mUpper)\n mLeft.setUpperLimit(from, to, limit)\n mRight.setUpperLimit(mFrom, mTo, mUpper)\n mRight.setUpperLimit(from, to, limit)\n mUpper = math.max(mLeft.upper, mRight.upper)\n }\n }\n }\n override def maxBetween(from: Int, to: Int): Int = {\n if (to < mFrom || mTo < from) Int.MinValue\n else if (from <= mFrom && mTo <= to) mUpper\n else {\n mLeft.setUpperLimit(mFrom, mTo, mUpper)\n mRight.setUpperLimit(mFrom, mTo, mUpper)\n math.max(mLeft.maxBetween(from, to), mRight.maxBetween(from, to))\n }\n }\n }\n class Leaf(private var mValue: Int, private val mPosition: Int) extends SegTree {\n override def maxBetween(from: Int, to: Int): Int = {\n if ((from to to).contains(mPosition)) mValue\n else Int.MinValue\n }\n\n override def setUpperLimit(from: Int, to: Int, limit: Int): Unit = {\n if ((from to to).contains(mPosition) && limit < mValue) mValue = limit\n }\n\n override def upper: Int = mValue\n }\n implicit class Extension[T](val value :T){\n def also(func: T ⇒ Unit): T = {\n func(value)\n value\n }\n def let[R](func: T ⇒ R): R = func(value)\n }\n}\n", "problem_context": "G: エレベータ\n\n問題\n\n株式会社AORは $N$ 階建てのビルである。地下階は存在しない。\n\nAORイカちゃんはイカであるため、階段を下りることは可能だが、上ることは不可能である。\n\n上の階に登れないと不便なため、$M$ 個のエレベータをビルに設置することにした。\n\nエレベータを設置するには時間がかかり、$i$ 番目のエレベータは $D_i$ 日後の夜に設置が完了し、 $A_i$ 階以上 $B_i$ 階以下の全ての階を移動可能にする。\n\nあなたはAORイカちゃんに $Q$ 個の質問をされた。$i$ 番目の質問は「 $E_i$ 日後の昼に、$S_i$ 階から $T_i$ 階に移動可能か?」という質問である。\n\n移動に使える手段は階段とエレベータのみである。また移動にかかる時間は無視できるものとする。\n\n制約\n\n$2 \\le N \\le 10^5$\n\n$1 \\le M \\le 10^5$\n\n$1 \\le Q \\le 10^5$\n\n$1 \\le D_i , E_i \\le 10^9$\n\n$1 \\le A_i < B_i \\le N$\n\n$1 \\le S_i , T_i \\le N$\n\n入力は全て整数\n\n入力\n\n$N \\ M\\ Q$\n\n$D_1 \\ A_1 \\ B_1$\n\n$\\vdots$\n\n$D_M \\ A_M \\ B_M$\n\n$E_1 \\ S_1 \\ T_1$\n\n$\\vdots$\n\n$E_Q \\ S_Q \\ T_Q$\n\n出力\n\n各質問ごとに一行で Yes または No を出力せよ。ただし質問された順に答えること。また末尾に改行を出力せよ。\n\nサンプル\n\nサンプル入力 1\n\n5 1 2\n3 1 5\n3 1 5\n4 1 5\n\nサンプル出力 1\n\nNo\nYes\n\nエレベータが設置されるのは三日目の夜であるため、三日目の昼に移動することはできない。\n\nサンプル入力 2\n\n8 6 5\n30 6 7\n21 3 8\n5 2 4\n10 1 2\n2 7 8\n15 5 7\n16 5 8\n11 1 3\n22 3 7\n30 6 7\n15 5 8\n\nサンプル出力 2\n\nYes\nYes\nYes\nYes\nNo", "sample_input": "5 1 2\n3 1 5\n3 1 5\n4 1 5\n"}, "reference_outputs": ["No\nYes\n"], "source_document_id": "p01980", "source_text": "G: エレベータ\n\n問題\n\n株式会社AORは $N$ 階建てのビルである。地下階は存在しない。\n\nAORイカちゃんはイカであるため、階段を下りることは可能だが、上ることは不可能である。\n\n上の階に登れないと不便なため、$M$ 個のエレベータをビルに設置することにした。\n\nエレベータを設置するには時間がかかり、$i$ 番目のエレベータは $D_i$ 日後の夜に設置が完了し、 $A_i$ 階以上 $B_i$ 階以下の全ての階を移動可能にする。\n\nあなたはAORイカちゃんに $Q$ 個の質問をされた。$i$ 番目の質問は「 $E_i$ 日後の昼に、$S_i$ 階から $T_i$ 階に移動可能か?」という質問である。\n\n移動に使える手段は階段とエレベータのみである。また移動にかかる時間は無視できるものとする。\n\n制約\n\n$2 \\le N \\le 10^5$\n\n$1 \\le M \\le 10^5$\n\n$1 \\le Q \\le 10^5$\n\n$1 \\le D_i , E_i \\le 10^9$\n\n$1 \\le A_i < B_i \\le N$\n\n$1 \\le S_i , T_i \\le N$\n\n入力は全て整数\n\n入力\n\n$N \\ M\\ Q$\n\n$D_1 \\ A_1 \\ B_1$\n\n$\\vdots$\n\n$D_M \\ A_M \\ B_M$\n\n$E_1 \\ S_1 \\ T_1$\n\n$\\vdots$\n\n$E_Q \\ S_Q \\ T_Q$\n\n出力\n\n各質問ごとに一行で Yes または No を出力せよ。ただし質問された順に答えること。また末尾に改行を出力せよ。\n\nサンプル\n\nサンプル入力 1\n\n5 1 2\n3 1 5\n3 1 5\n4 1 5\n\nサンプル出力 1\n\nNo\nYes\n\nエレベータが設置されるのは三日目の夜であるため、三日目の昼に移動することはできない。\n\nサンプル入力 2\n\n8 6 5\n30 6 7\n21 3 8\n5 2 4\n10 1 2\n2 7 8\n15 5 7\n16 5 8\n11 1 3\n22 3 7\n30 6 7\n15 5 8\n\nサンプル出力 2\n\nYes\nYes\nYes\nYes\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2584, "cpu_time_ms": 1940, "memory_kb": 289152}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s625656061", "group_id": "codeNet:p02016", "input_text": "object Main extends App {\n import scala.io.StdIn._\n\n println(\n if (readLine.trim == \"ani\") \"square1001\" else \"e869120\"\n )\n implicit class Scope[T](val value: T) extends AnyVal {\n @inline\n def let[A](func: T ⇒ A): A = func(value)\n }\n}\n", "language": "Scala", "metadata": {"date": 1551800728, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02016.html", "problem_id": "p02016", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02016/input.txt", "sample_output_relpath": "derived/input_output/data/p02016/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02016/Scala/s625656061.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s625656061", "user_id": "u514597327"}, "prompt_components": {"gold_output": "square1001\n", "input_to_evaluate": "object Main extends App {\n import scala.io.StdIn._\n\n println(\n if (readLine.trim == \"ani\") \"square1001\" else \"e869120\"\n )\n implicit class Scope[T](val value: T) extends AnyVal {\n @inline\n def let[A](func: T ⇒ A): A = func(value)\n }\n}\n", "problem_context": "B: 双子 (Twins)\n\nとある双子は、自分たちのどちらが兄でどちらが弟かがあまり知られていないことに腹を立てた。\n\n\"ani\" と入力されたら \"square1001\"、\"otouto\" と入力されたら \"e869120\" と出力するプログラムを作りなさい。\n\n入力\n\n入力として \"ani\" または \"otouto\" という文字列のどちらかが与えられます。\n\n出力\n\n\"e869120\" または \"square1001\" を、問題文の通りに出力してください。最後の改行を忘れないようにしましょう。\n\n入力例1\n\nani\n\n出力例1\n\nsquare1001\n\n入力例2\n\notouto\n\n出力例2\n\ne869120", "sample_input": "ani\n"}, "reference_outputs": ["square1001\n"], "source_document_id": "p02016", "source_text": "B: 双子 (Twins)\n\nとある双子は、自分たちのどちらが兄でどちらが弟かがあまり知られていないことに腹を立てた。\n\n\"ani\" と入力されたら \"square1001\"、\"otouto\" と入力されたら \"e869120\" と出力するプログラムを作りなさい。\n\n入力\n\n入力として \"ani\" または \"otouto\" という文字列のどちらかが与えられます。\n\n出力\n\n\"e869120\" または \"square1001\" を、問題文の通りに出力してください。最後の改行を忘れないようにしましょう。\n\n入力例1\n\nani\n\n出力例1\n\nsquare1001\n\n入力例2\n\notouto\n\n出力例2\n\ne869120", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 250, "cpu_time_ms": 220, "memory_kb": 43620}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s309882428", "group_id": "codeNet:p02019", "input_text": "object Main extends App {\n import scala.io.StdIn._\n\n val Array(n, a, b, c) = readLine.trim.split(' ').map(_.toInt)\n println(\n n - a - b + c\n )\n implicit class Scope[T](val value: T) extends AnyVal {\n @inline\n def let[A](func: T ⇒ A): A = func(value)\n }\n}\n", "language": "Scala", "metadata": {"date": 1551800518, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02019.html", "problem_id": "p02019", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02019/input.txt", "sample_output_relpath": "derived/input_output/data/p02019/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02019/Scala/s309882428.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s309882428", "user_id": "u514597327"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n import scala.io.StdIn._\n\n val Array(n, a, b, c) = readLine.trim.split(' ').map(_.toInt)\n println(\n n - a - b + c\n )\n implicit class Scope[T](val value: T) extends AnyVal {\n @inline\n def let[A](func: T ⇒ A): A = func(value)\n }\n}\n", "problem_context": "E-修行\n\nねねさんはプログラミングの修行のため、$N$ 個の整数 $V_1, V_2, V_3, \\cdots, V_N$ について調べるプログラムを作っている。\n\n指導役のうみこさんに言われて、ねねさんは 2, 3, 6 の倍数の個数を調べるプログラムを書いた。\n\n2 の倍数は $A$ 個、3 の倍数は $B$ 個、6 の倍数は $C$ 個だった。\n\nうみこさんは、次は「2 の倍数でも 3 の倍数でもない数」の個数を調べるようにと言った。\n\nしかし、ねねさんは疲れたので、答えだけを求めてごまかすことにした。\n\n$N, A, B, C$ の値だけをもとに、「2 の倍数でも 3 の倍数でもない数」の個数が分かります。これを求めるプログラムを作ってください。\n\n入力\n\n$N, A, B, C$ が空白区切りで与えられる。\n\n出力\n\nデータの中にある「2 の倍数でも 3の倍数でもない数」の個数を出力せよ。ただし、最後には改行を入れること。\n\n制約\n\n$N$ は $1$ 以上 $100$ 以下の整数\n\n$A, B, C$ は $0$ 以上 $N$ 以下の整数\n\n$A$ が $N$ より大きいなどという、矛盾するデータは与えられない\n\n入力例1\n\n6 3 2 1\n\n出力例1\n\n2\n\n例えばデータが $2, 3, 4, 5, 6, 7$ のときは、$5$ と $7$ のふたつが「2 の倍数でも 3 の倍数でもない数」です。\n\n入力例2\n\n10 9 9 9\n\n出力例2\n\n1", "sample_input": "6 3 2 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02019", "source_text": "E-修行\n\nねねさんはプログラミングの修行のため、$N$ 個の整数 $V_1, V_2, V_3, \\cdots, V_N$ について調べるプログラムを作っている。\n\n指導役のうみこさんに言われて、ねねさんは 2, 3, 6 の倍数の個数を調べるプログラムを書いた。\n\n2 の倍数は $A$ 個、3 の倍数は $B$ 個、6 の倍数は $C$ 個だった。\n\nうみこさんは、次は「2 の倍数でも 3 の倍数でもない数」の個数を調べるようにと言った。\n\nしかし、ねねさんは疲れたので、答えだけを求めてごまかすことにした。\n\n$N, A, B, C$ の値だけをもとに、「2 の倍数でも 3 の倍数でもない数」の個数が分かります。これを求めるプログラムを作ってください。\n\n入力\n\n$N, A, B, C$ が空白区切りで与えられる。\n\n出力\n\nデータの中にある「2 の倍数でも 3の倍数でもない数」の個数を出力せよ。ただし、最後には改行を入れること。\n\n制約\n\n$N$ は $1$ 以上 $100$ 以下の整数\n\n$A, B, C$ は $0$ 以上 $N$ 以下の整数\n\n$A$ が $N$ より大きいなどという、矛盾するデータは与えられない\n\n入力例1\n\n6 3 2 1\n\n出力例1\n\n2\n\n例えばデータが $2, 3, 4, 5, 6, 7$ のときは、$5$ と $7$ のふたつが「2 の倍数でも 3 の倍数でもない数」です。\n\n入力例2\n\n10 9 9 9\n\n出力例2\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 44044}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s624021399", "group_id": "codeNet:p02028", "input_text": "import java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n \nimport scala.collection.immutable._\nimport scala.io.Codec\nimport scala.collection.Searching._\n \n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n \nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n \n def this(reader: Reader) = this(new BufferedReader(reader))\n \n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n \n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n \n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n \n def this(str: String) = this(new StringReader(str))\n \n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n \n private[this] var current = iterator\n \n def hasNext: Boolean = current.hasNext\n \n @inline def next(): String = current.next()\n \n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n \n def lineNumber: Int = reader.getLineNumber\n \n def nextString(): String = next()\n \n def nextBoolean(): Boolean = next().toBoolean\n \n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n \n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n \n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n \n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n \n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n \n def nextFloat(): Float = next().toFloat\n \n def nextDouble(): Double = next().toDouble\n \n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n \n override def close(): Unit = reader.close()\n}\n \nobject Main {\n \n def solve(sc: => Scanner): Unit = {\n val N, M = sc.nextInt()\n val A = Array.fill(N)(sc.nextLong()).sorted\n val sumOfA = A.scanLeft(0L)((a, b) => a + b)\n \n println(Array.fill(M)(sc.nextLong()).map(b => b).sum)\n \n }\n \n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n", "language": "Scala", "metadata": {"date": 1546514688, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02028.html", "problem_id": "p02028", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02028/input.txt", "sample_output_relpath": "derived/input_output/data/p02028/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02028/Scala/s624021399.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s624021399", "user_id": "u018134297"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n \nimport scala.collection.immutable._\nimport scala.io.Codec\nimport scala.collection.Searching._\n \n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n \nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n \n def this(reader: Reader) = this(new BufferedReader(reader))\n \n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n \n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n \n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n \n def this(str: String) = this(new StringReader(str))\n \n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n \n private[this] var current = iterator\n \n def hasNext: Boolean = current.hasNext\n \n @inline def next(): String = current.next()\n \n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n \n def lineNumber: Int = reader.getLineNumber\n \n def nextString(): String = next()\n \n def nextBoolean(): Boolean = next().toBoolean\n \n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n \n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n \n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n \n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n \n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n \n def nextFloat(): Float = next().toFloat\n \n def nextDouble(): Double = next().toDouble\n \n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n \n override def close(): Unit = reader.close()\n}\n \nobject Main {\n \n def solve(sc: => Scanner): Unit = {\n val N, M = sc.nextInt()\n val A = Array.fill(N)(sc.nextLong()).sorted\n val sumOfA = A.scanLeft(0L)((a, b) => a + b)\n \n println(Array.fill(M)(sc.nextLong()).map(b => b).sum)\n \n }\n \n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n", "problem_context": "N: 通販 (Mail Order)\n\n胡桃沢さんは、魔界通販で積み木のおもちゃを買った。\n\n積み木は一辺の長さが1の立方体の形をしており、縦に $H$ 個、横に $W$ 個に分割されたマス目の上に積まれている。\n\n真横から見ると、左から順に、$A_1, A_2, A_3, \\dots, A_H$ 個のブロックが積まれて見えた。\n\n正面から見ると、左から順に、$B_1, B_2, B_3, \\dots, B_W$ 個のブロックが積まれて見えた。\n\n胡桃沢さんは偉大なので、これらの情報だけからブロックの総数を当てようと考えた。\n\n小さい数を答えて間違えると格好悪いので、考えられる最大の個数を答えたい。\n\n入力\n\n1 行目には整数 $H, W$ が空白区切りで与えられる。\n\n2 行目には、真横から見たときの図を表す $H$ 個の整数 $A_1, A_2, A_3, \\dots, A_H$ が空白区切りで与えられる。\n\n3 行目には、正面から見たときの図を表す $W$ 個の整数 $B_1, B_2, B_3, \\dots, B_W$ が空白区切りで与えられる。\n\n出力\n\nこれらの情報から考えられるブロックの個数の最大値を出力しなさい。\n\n制約\n\n$H, W$ は $1$ 以上 $100 \\ 000$ 以下の整数\n\n$A_1, A_2, A_3, \\dots, A_H$ は $1$ 以上 $100 \\ 000 \\ 000$ 以下の整数\n\n$B_1, B_2, B_3, \\dots, B_W$ は $1$ 以上 $100 \\ 000 \\ 000$ 以下の整数\n\nすべての入力に対して、条件を満たすブロックの積み方があることが保証される\n\n入力例1\n\n2 2\n1 5\n1 5\n\n出力例1\n\n8\n\n縦方向に $X$ 番目、横方向に $Y$ 番目のマスを $(X, Y)$ で表すことにします。\n\nマス $(2, 2)$ に5個、マス $(1, 1)$、$(1, 2)$、$(2, 1)$ に $1$ 個ずつ積まれていると合計 $8$ 個のブロックが積まれることになります。\n\n$9$ 個以上積まれている可能性は無いので、答えは $8$ です。\n\n入力例2\n\n3 3\n2 4 5\n3 1 5\n\n出力例2\n\n22", "sample_input": "2 2\n1 5\n1 5\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02028", "source_text": "N: 通販 (Mail Order)\n\n胡桃沢さんは、魔界通販で積み木のおもちゃを買った。\n\n積み木は一辺の長さが1の立方体の形をしており、縦に $H$ 個、横に $W$ 個に分割されたマス目の上に積まれている。\n\n真横から見ると、左から順に、$A_1, A_2, A_3, \\dots, A_H$ 個のブロックが積まれて見えた。\n\n正面から見ると、左から順に、$B_1, B_2, B_3, \\dots, B_W$ 個のブロックが積まれて見えた。\n\n胡桃沢さんは偉大なので、これらの情報だけからブロックの総数を当てようと考えた。\n\n小さい数を答えて間違えると格好悪いので、考えられる最大の個数を答えたい。\n\n入力\n\n1 行目には整数 $H, W$ が空白区切りで与えられる。\n\n2 行目には、真横から見たときの図を表す $H$ 個の整数 $A_1, A_2, A_3, \\dots, A_H$ が空白区切りで与えられる。\n\n3 行目には、正面から見たときの図を表す $W$ 個の整数 $B_1, B_2, B_3, \\dots, B_W$ が空白区切りで与えられる。\n\n出力\n\nこれらの情報から考えられるブロックの個数の最大値を出力しなさい。\n\n制約\n\n$H, W$ は $1$ 以上 $100 \\ 000$ 以下の整数\n\n$A_1, A_2, A_3, \\dots, A_H$ は $1$ 以上 $100 \\ 000 \\ 000$ 以下の整数\n\n$B_1, B_2, B_3, \\dots, B_W$ は $1$ 以上 $100 \\ 000 \\ 000$ 以下の整数\n\nすべての入力に対して、条件を満たすブロックの積み方があることが保証される\n\n入力例1\n\n2 2\n1 5\n1 5\n\n出力例1\n\n8\n\n縦方向に $X$ 番目、横方向に $Y$ 番目のマスを $(X, Y)$ で表すことにします。\n\nマス $(2, 2)$ に5個、マス $(1, 1)$、$(1, 2)$、$(2, 1)$ に $1$ 個ずつ積まれていると合計 $8$ 個のブロックが積まれることになります。\n\n$9$ 個以上積まれている可能性は無いので、答えは $8$ です。\n\n入力例2\n\n3 3\n2 4 5\n3 1 5\n\n出力例2\n\n22", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2703, "cpu_time_ms": 700, "memory_kb": 102288}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s233620442", "group_id": "codeNet:p02098", "input_text": "import java.util.Scanner\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val A, B = sc.nextDouble\n val N = (A - B) / -2 + 360 + A\n println(N % 180)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n\n solve(sc)\n }\n}", "language": "Scala", "metadata": {"date": 1508251058, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02098.html", "problem_id": "p02098", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02098/input.txt", "sample_output_relpath": "derived/input_output/data/p02098/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02098/Scala/s233620442.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s233620442", "user_id": "u018134297"}, "prompt_components": {"gold_output": "15.0\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val A, B = sc.nextDouble\n val N = (A - B) / -2 + 360 + A\n println(N % 180)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n\n solve(sc)\n }\n}", "problem_context": "Problem A: The Mean of Angles\n\nProblem\n\n与えられた2つの角度θ1,θ2 のちょうど間の角度を求めよ。ここで、ちょうど間の角度を、下図のように「θ1 + t = θ2 − t を満たすtのうち絶対値が最も小さいものをt’としたときのθ1 + t’」と定義する。\n\nInput\n\n入力は以下の形式で与えられる。\n\nθ1\nθ2\n\nConstraints\n\n入力は以下の条件を満たす。\n\n角度は度数法(degree)で表される\n\n0 ≤ θ1, θ2 < 360\n\nθ1, θ2は整数\n\n|θ1 − θ2| ≠ 180\n\n解答が[0,0.0001]または[359.999, 360)になるような入力は与えられない\n\nOutput\n\nθ1,θ2のちょうど間の角度を度数法で[0,360)の範囲で1行に出力せよ。ただし0.0001を超える誤差を含んではならない。\n\nSample Input 1\n\n10\n20\n\nSample Output 1\n\n15.0\n\nSample Input 2\n\n20\n350\n\nSample Output 2\n\n5.0", "sample_input": "10\n20\n"}, "reference_outputs": ["15.0\n"], "source_document_id": "p02098", "source_text": "Problem A: The Mean of Angles\n\nProblem\n\n与えられた2つの角度θ1,θ2 のちょうど間の角度を求めよ。ここで、ちょうど間の角度を、下図のように「θ1 + t = θ2 − t を満たすtのうち絶対値が最も小さいものをt’としたときのθ1 + t’」と定義する。\n\nInput\n\n入力は以下の形式で与えられる。\n\nθ1\nθ2\n\nConstraints\n\n入力は以下の条件を満たす。\n\n角度は度数法(degree)で表される\n\n0 ≤ θ1, θ2 < 360\n\nθ1, θ2は整数\n\n|θ1 − θ2| ≠ 180\n\n解答が[0,0.0001]または[359.999, 360)になるような入力は与えられない\n\nOutput\n\nθ1,θ2のちょうど間の角度を度数法で[0,360)の範囲で1行に出力せよ。ただし0.0001を超える誤差を含んではならない。\n\nSample Input 1\n\n10\n20\n\nSample Output 1\n\n15.0\n\nSample Input 2\n\n20\n350\n\nSample Output 2\n\n5.0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 260, "memory_kb": 45616}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s188880240", "group_id": "codeNet:p02098", "input_text": "import java.util.Scanner\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val A, B = sc.nextDouble\n val N = (math.max(A, B) - math.min(A, B)) / 2 + math.min(A, B)\n println(if (A - N < 90) (N) else {\n if (N + 180 >= 180) (N - 180) else (N + 180)\n })\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n\n solve(sc)\n }\n}", "language": "Scala", "metadata": {"date": 1508251364, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02098.html", "problem_id": "p02098", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02098/input.txt", "sample_output_relpath": "derived/input_output/data/p02098/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02098/Scala/s188880240.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s188880240", "user_id": "u018134297"}, "prompt_components": {"gold_output": "15.0\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val A, B = sc.nextDouble\n val N = (math.max(A, B) - math.min(A, B)) / 2 + math.min(A, B)\n println(if (A - N < 90) (N) else {\n if (N + 180 >= 180) (N - 180) else (N + 180)\n })\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n\n solve(sc)\n }\n}", "problem_context": "Problem A: The Mean of Angles\n\nProblem\n\n与えられた2つの角度θ1,θ2 のちょうど間の角度を求めよ。ここで、ちょうど間の角度を、下図のように「θ1 + t = θ2 − t を満たすtのうち絶対値が最も小さいものをt’としたときのθ1 + t’」と定義する。\n\nInput\n\n入力は以下の形式で与えられる。\n\nθ1\nθ2\n\nConstraints\n\n入力は以下の条件を満たす。\n\n角度は度数法(degree)で表される\n\n0 ≤ θ1, θ2 < 360\n\nθ1, θ2は整数\n\n|θ1 − θ2| ≠ 180\n\n解答が[0,0.0001]または[359.999, 360)になるような入力は与えられない\n\nOutput\n\nθ1,θ2のちょうど間の角度を度数法で[0,360)の範囲で1行に出力せよ。ただし0.0001を超える誤差を含んではならない。\n\nSample Input 1\n\n10\n20\n\nSample Output 1\n\n15.0\n\nSample Input 2\n\n20\n350\n\nSample Output 2\n\n5.0", "sample_input": "10\n20\n"}, "reference_outputs": ["15.0\n"], "source_document_id": "p02098", "source_text": "Problem A: The Mean of Angles\n\nProblem\n\n与えられた2つの角度θ1,θ2 のちょうど間の角度を求めよ。ここで、ちょうど間の角度を、下図のように「θ1 + t = θ2 − t を満たすtのうち絶対値が最も小さいものをt’としたときのθ1 + t’」と定義する。\n\nInput\n\n入力は以下の形式で与えられる。\n\nθ1\nθ2\n\nConstraints\n\n入力は以下の条件を満たす。\n\n角度は度数法(degree)で表される\n\n0 ≤ θ1, θ2 < 360\n\nθ1, θ2は整数\n\n|θ1 − θ2| ≠ 180\n\n解答が[0,0.0001]または[359.999, 360)になるような入力は与えられない\n\nOutput\n\nθ1,θ2のちょうど間の角度を度数法で[0,360)の範囲で1行に出力せよ。ただし0.0001を超える誤差を含んではならない。\n\nSample Input 1\n\n10\n20\n\nSample Output 1\n\n15.0\n\nSample Input 2\n\n20\n350\n\nSample Output 2\n\n5.0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 383, "cpu_time_ms": 250, "memory_kb": 45688}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s784618667", "group_id": "codeNet:p02098", "input_text": "import java.util.Scanner\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val A, B = sc.nextDouble\n val N: Double = (math.max(A, B) - math.min(A, B)) / 2 + math.min(A, B)\n println(if (A - N < 90) (N) else {\n if (N + 180 >= 360) (N - 180) else (N + 180)\n })\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n\n solve(sc)\n }\n}", "language": "Scala", "metadata": {"date": 1508251430, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02098.html", "problem_id": "p02098", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02098/input.txt", "sample_output_relpath": "derived/input_output/data/p02098/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02098/Scala/s784618667.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s784618667", "user_id": "u018134297"}, "prompt_components": {"gold_output": "15.0\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val A, B = sc.nextDouble\n val N: Double = (math.max(A, B) - math.min(A, B)) / 2 + math.min(A, B)\n println(if (A - N < 90) (N) else {\n if (N + 180 >= 360) (N - 180) else (N + 180)\n })\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n\n solve(sc)\n }\n}", "problem_context": "Problem A: The Mean of Angles\n\nProblem\n\n与えられた2つの角度θ1,θ2 のちょうど間の角度を求めよ。ここで、ちょうど間の角度を、下図のように「θ1 + t = θ2 − t を満たすtのうち絶対値が最も小さいものをt’としたときのθ1 + t’」と定義する。\n\nInput\n\n入力は以下の形式で与えられる。\n\nθ1\nθ2\n\nConstraints\n\n入力は以下の条件を満たす。\n\n角度は度数法(degree)で表される\n\n0 ≤ θ1, θ2 < 360\n\nθ1, θ2は整数\n\n|θ1 − θ2| ≠ 180\n\n解答が[0,0.0001]または[359.999, 360)になるような入力は与えられない\n\nOutput\n\nθ1,θ2のちょうど間の角度を度数法で[0,360)の範囲で1行に出力せよ。ただし0.0001を超える誤差を含んではならない。\n\nSample Input 1\n\n10\n20\n\nSample Output 1\n\n15.0\n\nSample Input 2\n\n20\n350\n\nSample Output 2\n\n5.0", "sample_input": "10\n20\n"}, "reference_outputs": ["15.0\n"], "source_document_id": "p02098", "source_text": "Problem A: The Mean of Angles\n\nProblem\n\n与えられた2つの角度θ1,θ2 のちょうど間の角度を求めよ。ここで、ちょうど間の角度を、下図のように「θ1 + t = θ2 − t を満たすtのうち絶対値が最も小さいものをt’としたときのθ1 + t’」と定義する。\n\nInput\n\n入力は以下の形式で与えられる。\n\nθ1\nθ2\n\nConstraints\n\n入力は以下の条件を満たす。\n\n角度は度数法(degree)で表される\n\n0 ≤ θ1, θ2 < 360\n\nθ1, θ2は整数\n\n|θ1 − θ2| ≠ 180\n\n解答が[0,0.0001]または[359.999, 360)になるような入力は与えられない\n\nOutput\n\nθ1,θ2のちょうど間の角度を度数法で[0,360)の範囲で1行に出力せよ。ただし0.0001を超える誤差を含んではならない。\n\nSample Input 1\n\n10\n20\n\nSample Output 1\n\n15.0\n\nSample Input 2\n\n20\n350\n\nSample Output 2\n\n5.0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 300, "memory_kb": 45656}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s062247440", "group_id": "codeNet:p02118", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val in = new Scanner(System.in)\n val N = in.nextInt()\n val L = in.nextInt()\n val K = in.nextLong()\n val ad: Array[(Long, Long)] = (for (_ <- 0 until N) yield {\n val a: Long = in.nextInt()\n val d: Long = in.nextInt()\n (a, d)\n }).toArray\n\n val sum = ad.map {\n case (a, d) => (a + (a + (L - 1) * d)) * L / 2\n }\n\n // imos[i+1] = sum(0...i)\n val imos = new Array[Long](N + 1)\n for (i <- 0 until N) {\n imos(i + 1) = imos(i) + sum(i)\n }\n\n\n def calc(a0: Long, da: Long, b0: Long, db: Long, p: Int): Long = {\n def value(x: Int): Long = (b0 - a0) * x + x * (x - 1) * (db - da) / 2\n\n val left = 0\n val right = value(p)\n if (db - da >= 0) {\n math.max(left, right)\n } else {\n val y = b0 - a0\n val z = db - da\n var t = (z - 2 * y).toDouble / 2 / z\n t = math.max(t, 0)\n t = math.min(t, p)\n math.max(value(math.ceil(t).toInt), value(math.floor(t).toInt))\n }\n }\n\n\n if (K == N * L) {\n println(imos(N))\n } else {\n val ans = (for {\n head <- 0 until N\n if head + K / L < N\n } yield {\n val a0 = ad(head)._1\n val da = ad(head)._2\n\n val idx = (head + K / L).toInt\n val rest = (K % L).toInt\n val p = L - rest\n\n val b0 = ad(idx)._1 + rest * ad(idx)._2\n val db = ad(idx)._2\n\n val sum1 = imos(idx) - imos(head) + (ad(idx)._1 + ad(idx)._1 + (rest - 1) * db) * rest / 2\n val sum2 = calc(a0, da, b0, db, p) + sum1\n\n if (idx + 1 < N && rest >= 2) {\n val sum3 = sum1 + (b0 + b0 + (p - 1) * db) * p / 2 - (a0 + a0 + (p - 1) * da) * p / 2\n\n val c0 = ad(idx + 1)._1\n val dc = ad(idx + 1)._2\n\n val ax = a0 + p * da\n\n val sum4 = calc(ax, da, c0, dc, rest) + sum3\n\n math.max(sum2, sum4)\n } else {\n sum2\n }\n }).max\n println(ans)\n }\n}", "language": "Scala", "metadata": {"date": 1505800934, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02118.html", "problem_id": "p02118", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02118/input.txt", "sample_output_relpath": "derived/input_output/data/p02118/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02118/Scala/s062247440.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s062247440", "user_id": "u807237426"}, "prompt_components": {"gold_output": "25\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n val in = new Scanner(System.in)\n val N = in.nextInt()\n val L = in.nextInt()\n val K = in.nextLong()\n val ad: Array[(Long, Long)] = (for (_ <- 0 until N) yield {\n val a: Long = in.nextInt()\n val d: Long = in.nextInt()\n (a, d)\n }).toArray\n\n val sum = ad.map {\n case (a, d) => (a + (a + (L - 1) * d)) * L / 2\n }\n\n // imos[i+1] = sum(0...i)\n val imos = new Array[Long](N + 1)\n for (i <- 0 until N) {\n imos(i + 1) = imos(i) + sum(i)\n }\n\n\n def calc(a0: Long, da: Long, b0: Long, db: Long, p: Int): Long = {\n def value(x: Int): Long = (b0 - a0) * x + x * (x - 1) * (db - da) / 2\n\n val left = 0\n val right = value(p)\n if (db - da >= 0) {\n math.max(left, right)\n } else {\n val y = b0 - a0\n val z = db - da\n var t = (z - 2 * y).toDouble / 2 / z\n t = math.max(t, 0)\n t = math.min(t, p)\n math.max(value(math.ceil(t).toInt), value(math.floor(t).toInt))\n }\n }\n\n\n if (K == N * L) {\n println(imos(N))\n } else {\n val ans = (for {\n head <- 0 until N\n if head + K / L < N\n } yield {\n val a0 = ad(head)._1\n val da = ad(head)._2\n\n val idx = (head + K / L).toInt\n val rest = (K % L).toInt\n val p = L - rest\n\n val b0 = ad(idx)._1 + rest * ad(idx)._2\n val db = ad(idx)._2\n\n val sum1 = imos(idx) - imos(head) + (ad(idx)._1 + ad(idx)._1 + (rest - 1) * db) * rest / 2\n val sum2 = calc(a0, da, b0, db, p) + sum1\n\n if (idx + 1 < N && rest >= 2) {\n val sum3 = sum1 + (b0 + b0 + (p - 1) * db) * p / 2 - (a0 + a0 + (p - 1) * da) * p / 2\n\n val c0 = ad(idx + 1)._1\n val dc = ad(idx + 1)._2\n\n val ax = a0 + p * da\n\n val sum4 = calc(ax, da, c0, dc, rest) + sum3\n\n math.max(sum2, sum4)\n } else {\n sum2\n }\n }).max\n println(ans)\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nProblem H: Sequence\n\nProblem\n\n項数$L$の等差数列が$N$個ある。$i$番目の等差数列の初項は$a_i$で公差は$d_i$である。1番目の数列から順番に1番目の数列, 2番目の数列, ..., $N$番目の数列と並べ、そうしてできた数列を$A$とする。その後、$A$から長さ$K$の任意の区間を選んで、新たに数列$B$を作るとき、数列$B$の和を最大化せよ。\n\nInput\n\n入力は以下の形式で与えられる。\n\n$N$ $L$ $K$\n\n$a_1$ $d_1$\n\n$a_2$ $d_2$\n\n...\n\n$a_N$ $d_N$\n\n1行目に3つの整数$N$, $L$, $K$が空白区切りで与えられる。\n\n続く$N$行に、$i$個目の等差数列の情報$a_i$, $d_i$が空白区切りで与えられる。\n\nConstraints\n\n入力は以下の条件を満たす。\n\n$1 \\leq N \\leq 10^5$\n\n$1 \\leq L \\leq 10^5$\n\n$1 \\leq K \\leq N\\times L$\n\n$0 \\leq a_i \\leq 10^5$\n\n$1 \\leq d_i \\leq 10^3$\n\n入力はすべて整数\n\nOutput\n\n数列$B$の和の最大値を1行に出力する。\n\nSample Input 1\n\n3 3 5\n0 3\n2 2\n4 1\n\nSample Output 1\n\n25\n\n数列$A$は$0,3,6,2,4,6,4,5,6$となる。この数列の第5項から第9項までを数列$B$とすれば、数列$B$の和は25となり、これが最大である。\n\nSample Input 2\n\n3 3 5\n0 10\n8 1\n11 1\n\nSample Output 2\n\n58", "sample_input": "3 3 5\n0 3\n2 2\n4 1\n"}, "reference_outputs": ["25\n"], "source_document_id": "p02118", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nProblem H: Sequence\n\nProblem\n\n項数$L$の等差数列が$N$個ある。$i$番目の等差数列の初項は$a_i$で公差は$d_i$である。1番目の数列から順番に1番目の数列, 2番目の数列, ..., $N$番目の数列と並べ、そうしてできた数列を$A$とする。その後、$A$から長さ$K$の任意の区間を選んで、新たに数列$B$を作るとき、数列$B$の和を最大化せよ。\n\nInput\n\n入力は以下の形式で与えられる。\n\n$N$ $L$ $K$\n\n$a_1$ $d_1$\n\n$a_2$ $d_2$\n\n...\n\n$a_N$ $d_N$\n\n1行目に3つの整数$N$, $L$, $K$が空白区切りで与えられる。\n\n続く$N$行に、$i$個目の等差数列の情報$a_i$, $d_i$が空白区切りで与えられる。\n\nConstraints\n\n入力は以下の条件を満たす。\n\n$1 \\leq N \\leq 10^5$\n\n$1 \\leq L \\leq 10^5$\n\n$1 \\leq K \\leq N\\times L$\n\n$0 \\leq a_i \\leq 10^5$\n\n$1 \\leq d_i \\leq 10^3$\n\n入力はすべて整数\n\nOutput\n\n数列$B$の和の最大値を1行に出力する。\n\nSample Input 1\n\n3 3 5\n0 3\n2 2\n4 1\n\nSample Output 1\n\n25\n\n数列$A$は$0,3,6,2,4,6,4,5,6$となる。この数列の第5項から第9項までを数列$B$とすれば、数列$B$の和は25となり、これが最大である。\n\nSample Input 2\n\n3 3 5\n0 10\n8 1\n11 1\n\nSample Output 2\n\n58", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1865, "cpu_time_ms": 790, "memory_kb": 200332}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s841318556", "group_id": "codeNet:p02176", "input_text": "object Main extends App {\n import scala.io.StdIn._\n val n = readInt()\n val crypt = readLine.trim\n val coordinate = crypt.foldLeft(Coordinate(0, 0)){\n case (pos, c) if 'A' to 'M' contains c ⇒ pos.copy(y = pos.y - 1)\n case (pos, c) if 'N' to 'Z' contains c ⇒ pos.copy(y = pos.y + 1)\n case (pos, c) if 'a' to 'm' contains c ⇒ pos.copy(x = pos.x + 1)\n case (pos, c) if 'n' to 'z' contains c ⇒ pos.copy(x = pos.x - 1)\n case _ ⇒ ???\n }\n println(math.abs(coordinate.x) + math.abs(coordinate.y))\n println(encrypt(coordinate))\n\n case class Coordinate(x: Int, y: Int) {\n def +(that: Coordinate): Coordinate = Coordinate(x + that.x, y + that.y)\n }\n def encrypt(coordinate: Coordinate): String = {\n coordinate match {\n case Coordinate(x, y) if x >= 0 && y >= 0 ⇒ \"N\" * y + \"a\" * x\n case Coordinate(x, y) if x >= 0 ⇒ \"A\" * -y + \"a\" * x\n case Coordinate(x, y) if x < 0 && y < 0 ⇒ \"A\" * -y + \"n\" * -x\n case Coordinate(x, y) ⇒ \"N\" * y + \"n\" * -x\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1568851508, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02176.html", "problem_id": "p02176", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02176/input.txt", "sample_output_relpath": "derived/input_output/data/p02176/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02176/Scala/s841318556.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s841318556", "user_id": "u514597327"}, "prompt_components": {"gold_output": "1\nA\n", "input_to_evaluate": "object Main extends App {\n import scala.io.StdIn._\n val n = readInt()\n val crypt = readLine.trim\n val coordinate = crypt.foldLeft(Coordinate(0, 0)){\n case (pos, c) if 'A' to 'M' contains c ⇒ pos.copy(y = pos.y - 1)\n case (pos, c) if 'N' to 'Z' contains c ⇒ pos.copy(y = pos.y + 1)\n case (pos, c) if 'a' to 'm' contains c ⇒ pos.copy(x = pos.x + 1)\n case (pos, c) if 'n' to 'z' contains c ⇒ pos.copy(x = pos.x - 1)\n case _ ⇒ ???\n }\n println(math.abs(coordinate.x) + math.abs(coordinate.y))\n println(encrypt(coordinate))\n\n case class Coordinate(x: Int, y: Int) {\n def +(that: Coordinate): Coordinate = Coordinate(x + that.x, y + that.y)\n }\n def encrypt(coordinate: Coordinate): String = {\n coordinate match {\n case Coordinate(x, y) if x >= 0 && y >= 0 ⇒ \"N\" * y + \"a\" * x\n case Coordinate(x, y) if x >= 0 ⇒ \"A\" * -y + \"a\" * x\n case Coordinate(x, y) if x < 0 && y < 0 ⇒ \"A\" * -y + \"n\" * -x\n case Coordinate(x, y) ⇒ \"N\" * y + \"n\" * -x\n }\n }\n}\n", "problem_context": "B: Shortest Crypt\n\n問題\n\nxryuseixくんの学校では暗号が流行している. 格子状の街に住んでいるxryuseixくんは集合場所を決める新しい暗号を考えた.\n\n暗号文は $N$ 文字の文字列 $S$ からなり, $S_i$ の文字によって現在地からの移動方向を決める. 移動方向に関しては以下の通りである.\n\nA ~ M : 北に1マス進む.\n\nN ~ Z : 南に1マス進む.\n\na ~ m : 東に1マス進む.\n\nn ~ z : 西に1マス進む.\n\nさて,ここでxryuseixくんは, yryuseiyちゃんにデートの集合場所を暗号文で教えようと思ったのだが, 暗号文が冗長なことに気づいた.\n\n例えば,「ANA」という暗号文があったとしよう. これは北に $1$ マス進み, 南へ $1$ マス進んだのち北へ $1$ マス進む.\nこれは北に $1$ マス進む暗号文と等価なので,「ANA」=「A」と, 簡潔にできる. xryuseixくんはyryuseiyちゃんに遠回りをさせないよう,暗号文を簡潔にしようと思った.\n\nそこであなたはxryuseixくんに変わって, 暗号文を簡潔にするプログラムを書くことになった.\nなお, 「暗号文を簡潔にする」とは,「元の暗号文と同じ目的地へ行く最も短い暗号文を作る」ということである.\n\n制約\n\n$N$ は整数であり, $S_i$ は大文字または小文字のアルファベットである.\n\n$1 \\leq N \\leq 10^{5}$\n\n入力形式\n\n入力は以下の形式で与えられる.\n\n$N$\n\n$S$\n\n出力\n\n$1$ 行目に簡潔にした後の暗号文の長さ, $2$ 行目にその暗号文を出力せよ.\n答えとしてありうる暗号文が複数存在する場合, どれを出力してもよい.\nまた各行の末尾に改行を出力せよ.\n\nサンプル\n\nサンプル入力 1\n\n5\nANazA\n\nサンプル出力 1\n\n1\nA\n\nサンプル入力 2\n\n7\nACMICPC\n\nサンプル出力 2\n\n5\nHIJKL\n\nサンプル入力 3\n\n4\nAIZU\n\nサンプル出力 3\n\n0\n\n簡潔にした暗号文(空の文字列)のあとに改行が必要なことに注意.", "sample_input": "5\nANazA\n"}, "reference_outputs": ["1\nA\n"], "source_document_id": "p02176", "source_text": "B: Shortest Crypt\n\n問題\n\nxryuseixくんの学校では暗号が流行している. 格子状の街に住んでいるxryuseixくんは集合場所を決める新しい暗号を考えた.\n\n暗号文は $N$ 文字の文字列 $S$ からなり, $S_i$ の文字によって現在地からの移動方向を決める. 移動方向に関しては以下の通りである.\n\nA ~ M : 北に1マス進む.\n\nN ~ Z : 南に1マス進む.\n\na ~ m : 東に1マス進む.\n\nn ~ z : 西に1マス進む.\n\nさて,ここでxryuseixくんは, yryuseiyちゃんにデートの集合場所を暗号文で教えようと思ったのだが, 暗号文が冗長なことに気づいた.\n\n例えば,「ANA」という暗号文があったとしよう. これは北に $1$ マス進み, 南へ $1$ マス進んだのち北へ $1$ マス進む.\nこれは北に $1$ マス進む暗号文と等価なので,「ANA」=「A」と, 簡潔にできる. xryuseixくんはyryuseiyちゃんに遠回りをさせないよう,暗号文を簡潔にしようと思った.\n\nそこであなたはxryuseixくんに変わって, 暗号文を簡潔にするプログラムを書くことになった.\nなお, 「暗号文を簡潔にする」とは,「元の暗号文と同じ目的地へ行く最も短い暗号文を作る」ということである.\n\n制約\n\n$N$ は整数であり, $S_i$ は大文字または小文字のアルファベットである.\n\n$1 \\leq N \\leq 10^{5}$\n\n入力形式\n\n入力は以下の形式で与えられる.\n\n$N$\n\n$S$\n\n出力\n\n$1$ 行目に簡潔にした後の暗号文の長さ, $2$ 行目にその暗号文を出力せよ.\n答えとしてありうる暗号文が複数存在する場合, どれを出力してもよい.\nまた各行の末尾に改行を出力せよ.\n\nサンプル\n\nサンプル入力 1\n\n5\nANazA\n\nサンプル出力 1\n\n1\nA\n\nサンプル入力 2\n\n7\nACMICPC\n\nサンプル出力 2\n\n5\nHIJKL\n\nサンプル入力 3\n\n4\nAIZU\n\nサンプル出力 3\n\n0\n\n簡潔にした暗号文(空の文字列)のあとに改行が必要なことに注意.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1011, "cpu_time_ms": 460, "memory_kb": 92340}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s364959991", "group_id": "codeNet:p02235", "input_text": "import scala.io.StdIn.{readInt,readLine}\n \nobject Main {\n def max(x:Int,y:Int) = if(x>y) x else y\n def main(args:Array[String]) = {\n val n = readInt\n\n for(i<-0 until n) {\n val s1 = readLine.trim\n val s2 = readLine.trim\n val maxN = s1.length\n val maxM = s2.length\n\n val a = Array.ofDim[Int](maxN,maxM)\n for(i<-0 until maxN) if(s1(i)==s2(0)) a(i)(0) = 1\n for(j<-0 until maxM) if(s1(0)==s2(j)) a(0)(j) = 1\n for(i<-1 until maxN) {\n for(j<-1 until maxM) {\n if(s1(i)==s2(j)) {\n a(i)(j) = a(i-1)(j-1)+1\n } else {\n a(i)(j) = max(a(i-1)(j), a(i)(j-1))\n }\n }\n }\n println(a(maxN-1)(maxM-1))\n }\n }\n}", "language": "Scala", "metadata": {"date": 1495376595, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02235.html", "problem_id": "p02235", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02235/input.txt", "sample_output_relpath": "derived/input_output/data/p02235/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02235/Scala/s364959991.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s364959991", "user_id": "u508732591"}, "prompt_components": {"gold_output": "4\n3\n2\n", "input_to_evaluate": "import scala.io.StdIn.{readInt,readLine}\n \nobject Main {\n def max(x:Int,y:Int) = if(x>y) x else y\n def main(args:Array[String]) = {\n val n = readInt\n\n for(i<-0 until n) {\n val s1 = readLine.trim\n val s2 = readLine.trim\n val maxN = s1.length\n val maxM = s2.length\n\n val a = Array.ofDim[Int](maxN,maxM)\n for(i<-0 until maxN) if(s1(i)==s2(0)) a(i)(0) = 1\n for(j<-0 until maxM) if(s1(0)==s2(j)) a(0)(j) = 1\n for(i<-1 until maxN) {\n for(j<-1 until maxM) {\n if(s1(i)==s2(j)) {\n a(i)(j) = a(i-1)(j-1)+1\n } else {\n a(i)(j) = max(a(i-1)(j), a(i)(j-1))\n }\n }\n }\n println(a(maxN-1)(maxM-1))\n }\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nLongest Common Subsequence\n\nFor given two sequences $X$ and $Y$, a sequence $Z$ is a common subsequence of $X$ and $Y$ if $Z$ is a subsequence of both $X$ and $Y$. For example, if $X = \\{a,b,c,b,d,a,b\\}$ and $Y = \\{b,d,c,a,b,a\\}$, the sequence $\\{b,c,a\\}$ is a common subsequence of both $X$ and $Y$. On the other hand, the sequence $\\{b,c,a\\}$ is not a longest common subsequence (LCS) of $X$ and $Y$, since it has length 3 and the sequence $\\{b,c,b,a\\}$, which is also common to both $X$ and $Y$, has length 4. The sequence $\\{b,c,b,a\\}$ is an LCS of $X$ and $Y$, since there is no common subsequence of length 5 or greater.\n\nWrite a program which finds the length of LCS of given two sequences $X$ and $Y$. The sequence consists of alphabetical characters.\n\nInput\n\nThe input consists of multiple datasets. In the first line, an integer $q$ which is the number of datasets is given. In the following $2 \\times q$ lines, each dataset which consists of the two sequences $X$ and $Y$ are given.\n\nOutput\n\nFor each dataset, print the length of LCS of $X$ and $Y$ in a line.\n\nConstraints\n\n$1 \\leq q \\leq 150$\n\n$1 \\leq$ length of $X$ and $Y$ $\\leq 1,000$\n\n$q \\leq 20$ if the dataset includes a sequence whose length is more than 100\n\nSample Input 1\n\n3\nabcbdab\nbdcaba\nabc\nabc\nabc\nbc\n\nSample Output 1\n\n4\n3\n2\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "3\nabcbdab\nbdcaba\nabc\nabc\nabc\nbc\n"}, "reference_outputs": ["4\n3\n2\n"], "source_document_id": "p02235", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nLongest Common Subsequence\n\nFor given two sequences $X$ and $Y$, a sequence $Z$ is a common subsequence of $X$ and $Y$ if $Z$ is a subsequence of both $X$ and $Y$. For example, if $X = \\{a,b,c,b,d,a,b\\}$ and $Y = \\{b,d,c,a,b,a\\}$, the sequence $\\{b,c,a\\}$ is a common subsequence of both $X$ and $Y$. On the other hand, the sequence $\\{b,c,a\\}$ is not a longest common subsequence (LCS) of $X$ and $Y$, since it has length 3 and the sequence $\\{b,c,b,a\\}$, which is also common to both $X$ and $Y$, has length 4. The sequence $\\{b,c,b,a\\}$ is an LCS of $X$ and $Y$, since there is no common subsequence of length 5 or greater.\n\nWrite a program which finds the length of LCS of given two sequences $X$ and $Y$. The sequence consists of alphabetical characters.\n\nInput\n\nThe input consists of multiple datasets. In the first line, an integer $q$ which is the number of datasets is given. In the following $2 \\times q$ lines, each dataset which consists of the two sequences $X$ and $Y$ are given.\n\nOutput\n\nFor each dataset, print the length of LCS of $X$ and $Y$ in a line.\n\nConstraints\n\n$1 \\leq q \\leq 150$\n\n$1 \\leq$ length of $X$ and $Y$ $\\leq 1,000$\n\n$q \\leq 20$ if the dataset includes a sequence whose length is more than 100\n\nSample Input 1\n\n3\nabcbdab\nbdcaba\nabc\nabc\nabc\nbc\n\nSample Output 1\n\n4\n3\n2\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 400, "memory_kb": 124824}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s495846542", "group_id": "codeNet:p02238", "input_text": "import scala.io.StdIn.{readInt, readLine};\nobject Main {\n def main(args: Array[String]): Unit = {\n val n = readInt;\n val ig = new IntGraph(n);\n (1 to n).foreach { i =>\n readLine.split(\" \").drop(2).map(_.toInt).foreach { j => ig.add(i, j)}\n }\n ig.dSearch.zipWithIndex.drop(1).foreach { e => println(\"%d %d %d\".format(e._2, e._1(0), e._1(1)))}\n }\n}\nclass IntGraph(n: Int) {\n val size: Int = n + 1;\n val matrix: Array[Array[Int]] = Array.ofDim[Int](size, size);\n def add(src: Int, dst: Int): Unit = matrix(src)(dst) = 1;\n \n def dSearch(): Array[Array[Int]] = {\n val status = Array.ofDim[Int](size, 2);\n def _dSearch(curr: Int, time: Int): Int = {\n status(curr)(0) = time;\n val newTime = 1 + (1 until size).foldLeft(time) { (t, i) =>\n if (matrix(curr)(i) == 1 && status(i)(0) == 0) _dSearch(i, t + 1) else t;\n }\n status(curr)(1) = newTime;\n newTime;\n }\n (1 until size).foreach { i =>\n if (status(i)(0) == 0) {\n _dSearch(i, 1);\n }\n }\n status;\n }\n}\n", "language": "Scala", "metadata": {"date": 1523460137, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02238.html", "problem_id": "p02238", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02238/input.txt", "sample_output_relpath": "derived/input_output/data/p02238/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02238/Scala/s495846542.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s495846542", "user_id": "u909989059"}, "prompt_components": {"gold_output": "1 1 8\n2 2 7\n3 4 5\n4 3 6\n", "input_to_evaluate": "import scala.io.StdIn.{readInt, readLine};\nobject Main {\n def main(args: Array[String]): Unit = {\n val n = readInt;\n val ig = new IntGraph(n);\n (1 to n).foreach { i =>\n readLine.split(\" \").drop(2).map(_.toInt).foreach { j => ig.add(i, j)}\n }\n ig.dSearch.zipWithIndex.drop(1).foreach { e => println(\"%d %d %d\".format(e._2, e._1(0), e._1(1)))}\n }\n}\nclass IntGraph(n: Int) {\n val size: Int = n + 1;\n val matrix: Array[Array[Int]] = Array.ofDim[Int](size, size);\n def add(src: Int, dst: Int): Unit = matrix(src)(dst) = 1;\n \n def dSearch(): Array[Array[Int]] = {\n val status = Array.ofDim[Int](size, 2);\n def _dSearch(curr: Int, time: Int): Int = {\n status(curr)(0) = time;\n val newTime = 1 + (1 until size).foldLeft(time) { (t, i) =>\n if (matrix(curr)(i) == 1 && status(i)(0) == 0) _dSearch(i, t + 1) else t;\n }\n status(curr)(1) = newTime;\n newTime;\n }\n (1 until size).foreach { i =>\n if (status(i)(0) == 0) {\n _dSearch(i, 1);\n }\n }\n status;\n }\n}\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nDepth First Search\n\nDepth-first search (DFS) follows the strategy to search ”deeper” in the graph whenever possible. In DFS, edges are recursively explored out of the most recently discovered vertex $v$ that still has unexplored edges leaving it. When all of $v$'s edges have been explored, the search ”backtracks” to explore edges leaving the vertex from which $v$ was discovered.\n\nThis process continues until all the vertices that are reachable from the original source vertex have been discovered. If any undiscovered vertices remain, then one of them is selected as a new source and the search is repeated from that source.\n\nDFS timestamps each vertex as follows:\n\n$d[v]$ records when $v$ is first discovered.\n\n$f[v]$ records when the search finishes examining $v$’s adjacency list.\n\nWrite a program which reads a directed graph $G = (V, E)$ and demonstrates DFS on the graph based on the following rules:\n\n$G$ is given in an adjacency-list. Vertices are identified by IDs $1, 2,... n$ respectively.\n\nIDs in the adjacency list are arranged in ascending order.\n\nThe program should report the discover time and the finish time for each vertex.\n\nWhen there are several candidates to visit during DFS, the algorithm should select the vertex with the smallest ID.\n\nThe timestamp starts with 1.\n\nInput\n\nIn the first line, an integer $n$ denoting the number of vertices of $G$ is given. In the next $n$ lines, adjacency lists of $u$ are given in the following format:\n\n$u$ $k$ $v_1$ $v_2$ ... $v_k$\n\n$u$ is ID of the vertex and $k$ denotes its degree. $v_i$ are IDs of vertices adjacent to $u$.\n\nOutput\n\nFor each vertex, print $id$, $d$ and $f$ separated by a space character in a line. $id$ is ID of the vertex, $d$ and $f$ is the discover time and the finish time respectively. Print in order of vertex IDs.\n\nConstraints\n\n$1 \\leq n \\leq 100$\n\nSample Input 1\n\n4\n1 1 2\n2 1 4\n3 0\n4 1 3\n\nSample Output 1\n\n1 1 8\n2 2 7\n3 4 5\n4 3 6\n\nSample Input 2\n\n6\n1 2 2 3\n2 2 3 4\n3 1 5\n4 1 6\n5 1 6\n6 0\n\nSample Output 2\n\n1 1 12\n2 2 11\n3 3 8\n4 9 10\n5 4 7\n6 5 6\n\nThis is example for Sample Input 2 (discover/finish)\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "4\n1 1 2\n2 1 4\n3 0\n4 1 3\n"}, "reference_outputs": ["1 1 8\n2 2 7\n3 4 5\n4 3 6\n"], "source_document_id": "p02238", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nDepth First Search\n\nDepth-first search (DFS) follows the strategy to search ”deeper” in the graph whenever possible. In DFS, edges are recursively explored out of the most recently discovered vertex $v$ that still has unexplored edges leaving it. When all of $v$'s edges have been explored, the search ”backtracks” to explore edges leaving the vertex from which $v$ was discovered.\n\nThis process continues until all the vertices that are reachable from the original source vertex have been discovered. If any undiscovered vertices remain, then one of them is selected as a new source and the search is repeated from that source.\n\nDFS timestamps each vertex as follows:\n\n$d[v]$ records when $v$ is first discovered.\n\n$f[v]$ records when the search finishes examining $v$’s adjacency list.\n\nWrite a program which reads a directed graph $G = (V, E)$ and demonstrates DFS on the graph based on the following rules:\n\n$G$ is given in an adjacency-list. Vertices are identified by IDs $1, 2,... n$ respectively.\n\nIDs in the adjacency list are arranged in ascending order.\n\nThe program should report the discover time and the finish time for each vertex.\n\nWhen there are several candidates to visit during DFS, the algorithm should select the vertex with the smallest ID.\n\nThe timestamp starts with 1.\n\nInput\n\nIn the first line, an integer $n$ denoting the number of vertices of $G$ is given. In the next $n$ lines, adjacency lists of $u$ are given in the following format:\n\n$u$ $k$ $v_1$ $v_2$ ... $v_k$\n\n$u$ is ID of the vertex and $k$ denotes its degree. $v_i$ are IDs of vertices adjacent to $u$.\n\nOutput\n\nFor each vertex, print $id$, $d$ and $f$ separated by a space character in a line. $id$ is ID of the vertex, $d$ and $f$ is the discover time and the finish time respectively. Print in order of vertex IDs.\n\nConstraints\n\n$1 \\leq n \\leq 100$\n\nSample Input 1\n\n4\n1 1 2\n2 1 4\n3 0\n4 1 3\n\nSample Output 1\n\n1 1 8\n2 2 7\n3 4 5\n4 3 6\n\nSample Input 2\n\n6\n1 2 2 3\n2 2 3 4\n3 1 5\n4 1 6\n5 1 6\n6 0\n\nSample Output 2\n\n1 1 12\n2 2 11\n3 3 8\n4 9 10\n5 4 7\n6 5 6\n\nThis is example for Sample Input 2 (discover/finish)\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1162, "cpu_time_ms": 270, "memory_kb": 44180}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s253775336", "group_id": "codeNet:p02239", "input_text": "object Main extends App {\n val n = io.StdIn.readInt()\n val adjacents = Array.fill[Array[Int]](n)(Array())\n for (_ <- 0 until n) {\n val data = io.StdIn.readLine().split(\" \").map(_.toInt)\n val id = data(0)-1\n adjacents(id) = data.drop(2).map(_-1)\n }\n val depth = Array.fill[Int](n)(-1)\n def search(x: Int) = {\n val queue = collection.mutable.Queue.empty[Int]\n depth(x) = 0\n queue.enqueue(x)\n loop()\n def loop(): Unit =\n if (queue.isEmpty) ()\n else {\n val i = queue.dequeue()\n for (a <- adjacents(i))\n if (depth(a) < 0) {\n depth(a) = depth(i)+1\n queue.enqueue(a)\n }\n loop()\n }\n }\n search(0)\n for (i <- 0 until n) println(s\"${i+1} ${depth(i)}\")\n}\n", "language": "Scala", "metadata": {"date": 1536903720, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02239.html", "problem_id": "p02239", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02239/input.txt", "sample_output_relpath": "derived/input_output/data/p02239/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02239/Scala/s253775336.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s253775336", "user_id": "u995793569"}, "prompt_components": {"gold_output": "1 0\n2 1\n3 2\n4 1\n", "input_to_evaluate": "object Main extends App {\n val n = io.StdIn.readInt()\n val adjacents = Array.fill[Array[Int]](n)(Array())\n for (_ <- 0 until n) {\n val data = io.StdIn.readLine().split(\" \").map(_.toInt)\n val id = data(0)-1\n adjacents(id) = data.drop(2).map(_-1)\n }\n val depth = Array.fill[Int](n)(-1)\n def search(x: Int) = {\n val queue = collection.mutable.Queue.empty[Int]\n depth(x) = 0\n queue.enqueue(x)\n loop()\n def loop(): Unit =\n if (queue.isEmpty) ()\n else {\n val i = queue.dequeue()\n for (a <- adjacents(i))\n if (depth(a) < 0) {\n depth(a) = depth(i)+1\n queue.enqueue(a)\n }\n loop()\n }\n }\n search(0)\n for (i <- 0 until n) println(s\"${i+1} ${depth(i)}\")\n}\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nBreadth First Search\n\nWrite a program which reads an directed graph $G = (V, E)$, and finds the shortest distance from vertex $1$ to each vertex (the number of edges in the shortest path). Vertices are identified by IDs $1, 2, ... n$.\n\nInput\n\nIn the first line, an integer $n$ denoting the number of vertices, is given. In the next $n$ lines, adjacent lists of vertex $u$ are given in the following format:\n\n$u$ $k$ $v_1$ $v_2$ ... $v_k$\n\n$u$ is ID of the vertex and $k$ denotes its degree.$v_i$ are IDs of vertices adjacent to $u$.\n\nConstraints\n\n$1 \\leq n \\leq 100$\n\nOutput\n\nFor each vertex $u$, print $id$ and $d$ in a line. $id$ is ID of vertex $u$ and $d$ is the distance from vertex $1$ to vertex $u$. If there are no path from vertex $1$ to vertex $u$, print -1 as the shortest distance. Print in order of IDs.\n\nSample Input 1\n\n4\n1 2 2 4\n2 1 4\n3 0\n4 1 3\n\nSample Output 1\n\n1 0\n2 1\n3 2\n4 1\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "4\n1 2 2 4\n2 1 4\n3 0\n4 1 3\n"}, "reference_outputs": ["1 0\n2 1\n3 2\n4 1\n"], "source_document_id": "p02239", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nBreadth First Search\n\nWrite a program which reads an directed graph $G = (V, E)$, and finds the shortest distance from vertex $1$ to each vertex (the number of edges in the shortest path). Vertices are identified by IDs $1, 2, ... n$.\n\nInput\n\nIn the first line, an integer $n$ denoting the number of vertices, is given. In the next $n$ lines, adjacent lists of vertex $u$ are given in the following format:\n\n$u$ $k$ $v_1$ $v_2$ ... $v_k$\n\n$u$ is ID of the vertex and $k$ denotes its degree.$v_i$ are IDs of vertices adjacent to $u$.\n\nConstraints\n\n$1 \\leq n \\leq 100$\n\nOutput\n\nFor each vertex $u$, print $id$ and $d$ in a line. $id$ is ID of vertex $u$ and $d$ is the distance from vertex $1$ to vertex $u$. If there are no path from vertex $1$ to vertex $u$, print -1 as the shortest distance. Print in order of IDs.\n\nSample Input 1\n\n4\n1 2 2 4\n2 1 4\n3 0\n4 1 3\n\nSample Output 1\n\n1 0\n2 1\n3 2\n4 1\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 44388}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s830453333", "group_id": "codeNet:p02241", "input_text": "import scala.collection.mutable.ArrayBuffer\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n\n class UnionSet(par: Array[Int]) {\n def root(x: Int): Int =\n if (par(x) == x) x\n else {\n par(x) = root(par(x))\n par(x)\n }\n def unite(x: Int, y: Int): Unit = {\n val rx = root(x)\n val ry = root(y)\n if (rx != ry)\n par(rx) = ry\n }\n def same(x: Int, y: Int): Boolean =\n root(x) == root(y)\n }\n object UnionSet {\n def apply(n: Int): UnionSet =\n new UnionSet(Array.range(0, n))\n }\n\n val sc = new java.util.Scanner(System.in)\n\n val N = sc.nextInt()\n val W = Array.fill(N, N)(sc.nextInt())\n\n val _E = new ArrayBuffer[(Int, Int)]() // (辺(u,v), 重みw)\n (0 until N) foreach { i =>\n (0 until N) foreach { j =>\n if (W(i)(j) >= 0) {\n _E.append((i, j))\n }\n }\n }\n val E: List[(Int, Int)] = _E.sortBy(e => W(e._1)(e._2)).toList // 辺(軽い順)\n\n // 最初, 全ての頂点は別の木として初期化する\n val unionset = UnionSet(N)\n var count = 0\n // 軽い辺から見ていき\n E foreach { e =>\n val (u, v) = e\n // u, v が別の木ならば, これは軽い辺なので安全に追加できる.\n if (!unionset.same(u, v)) {\n unionset.unite(u, v)\n count += W(u)(v)\n }\n }\n\n // 入力が連結グラフであることから,最終的に出来上がった木は1本となり, これが最小全域木である\n // 加えた辺の重さの合計が最小全域木の重さの合計\n println(count)\n }\n\n}\n\n", "language": "Scala", "metadata": {"date": 1559107807, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02241.html", "problem_id": "p02241", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02241/input.txt", "sample_output_relpath": "derived/input_output/data/p02241/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02241/Scala/s830453333.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s830453333", "user_id": "u389570999"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import scala.collection.mutable.ArrayBuffer\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n\n class UnionSet(par: Array[Int]) {\n def root(x: Int): Int =\n if (par(x) == x) x\n else {\n par(x) = root(par(x))\n par(x)\n }\n def unite(x: Int, y: Int): Unit = {\n val rx = root(x)\n val ry = root(y)\n if (rx != ry)\n par(rx) = ry\n }\n def same(x: Int, y: Int): Boolean =\n root(x) == root(y)\n }\n object UnionSet {\n def apply(n: Int): UnionSet =\n new UnionSet(Array.range(0, n))\n }\n\n val sc = new java.util.Scanner(System.in)\n\n val N = sc.nextInt()\n val W = Array.fill(N, N)(sc.nextInt())\n\n val _E = new ArrayBuffer[(Int, Int)]() // (辺(u,v), 重みw)\n (0 until N) foreach { i =>\n (0 until N) foreach { j =>\n if (W(i)(j) >= 0) {\n _E.append((i, j))\n }\n }\n }\n val E: List[(Int, Int)] = _E.sortBy(e => W(e._1)(e._2)).toList // 辺(軽い順)\n\n // 最初, 全ての頂点は別の木として初期化する\n val unionset = UnionSet(N)\n var count = 0\n // 軽い辺から見ていき\n E foreach { e =>\n val (u, v) = e\n // u, v が別の木ならば, これは軽い辺なので安全に追加できる.\n if (!unionset.same(u, v)) {\n unionset.unite(u, v)\n count += W(u)(v)\n }\n }\n\n // 入力が連結グラフであることから,最終的に出来上がった木は1本となり, これが最小全域木である\n // 加えた辺の重さの合計が最小全域木の重さの合計\n println(count)\n }\n\n}\n\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMinimum Spanning Tree\n\nFor a given weighted graph $G = (V, E)$, find the minimum spanning tree (MST) of $G$ and print total weight of edges belong to the MST.\n\nInput\n\nIn the first line, an integer $n$ denoting the number of vertices in $G$ is given. In the following $n$ lines, a $n \\times n$ adjacency matrix $A$ which represents $G$ is given.\n$a_{ij}$ denotes the weight of edge connecting vertex $i$ and vertex $j$. If there is no edge between $i$ and $j$, $a_{ij}$ is given by -1.\n\nOutput\n\nPrint the total weight of the minimum spanning tree of $G$.\n\nConstraints\n\n$1 \\leq n \\leq 100$\n\n$0 \\leq a_{ij} \\leq 2,000$ (if $a_{ij} \\neq -1$)\n\n$a_{ij} = a_{ji}$\n\n$G$ is a connected graph\n\nSample Input 1\n\n5\n-1 2 3 1 -1\n2 -1 -1 4 -1\n3 -1 -1 1 1\n1 4 1 -1 3\n-1 -1 1 3 -1\n\nSample Output 1\n\n5\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "5\n -1 2 3 1 -1\n 2 -1 -1 4 -1\n 3 -1 -1 1 1\n 1 4 1 -1 3\n -1 -1 1 3 -1\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02241", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMinimum Spanning Tree\n\nFor a given weighted graph $G = (V, E)$, find the minimum spanning tree (MST) of $G$ and print total weight of edges belong to the MST.\n\nInput\n\nIn the first line, an integer $n$ denoting the number of vertices in $G$ is given. In the following $n$ lines, a $n \\times n$ adjacency matrix $A$ which represents $G$ is given.\n$a_{ij}$ denotes the weight of edge connecting vertex $i$ and vertex $j$. If there is no edge between $i$ and $j$, $a_{ij}$ is given by -1.\n\nOutput\n\nPrint the total weight of the minimum spanning tree of $G$.\n\nConstraints\n\n$1 \\leq n \\leq 100$\n\n$0 \\leq a_{ij} \\leq 2,000$ (if $a_{ij} \\neq -1$)\n\n$a_{ij} = a_{ji}$\n\n$G$ is a connected graph\n\nSample Input 1\n\n5\n-1 2 3 1 -1\n2 -1 -1 4 -1\n3 -1 -1 1 1\n1 4 1 -1 3\n-1 -1 1 3 -1\n\nSample Output 1\n\n5\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1634, "cpu_time_ms": 430, "memory_kb": 63236}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s476303700", "group_id": "codeNet:p02241", "input_text": "import scala.io.StdIn.{readInt, readLine};\nimport scala.annotation.tailrec;\nobject Main {\n def main(args: Array[String]): Unit = {\n val size = readInt;\n val m = new Array[Array[Int]](size);\n (0 until size).foreach { i => m(i) = readLine.trim.split(\" \").map( a => if (a.toInt == -1) Int.MaxValue else a.toInt)}\n val g = new Graph(size, m);\n val (parent, distance) = g.prim;\n println(distance.sum)\n }\n}\ncase class Graph(size: Int, matrix: Array[Array[Int]]) {\n val INFINITY = Int.MaxValue\n def prim(): (Array[Int], Array[Int]) = {\n // WHITE : 未訪問, GRAY: MST候補ノード, BLACK: MST追加済みノード\n val WHITE = 0; val GRAY = 1; val BLACK = 2;\n val color = new Array[Int](size); // 訪問状態リスト(WHITE, GRAY, BLACK)\n val distance = new Array[Int](size).map( e => INFINITY); // 重みリスト\n val parents = new Array[Int](size); // 親ノードリスト\n @tailrec\n def _prim(curr: Int): Unit = {\n // MSTに属する頂点の集合から最も近いノードの index を取得する\n val idx = (0 until size).foldLeft(-1) { (minidx, i) =>\n if (color(i) != BLACK) {\n // curr の子ノードをMST候補ノードに追加\n if (matrix(curr)(i) != -1) {\n color(i) = GRAY;\n }\n if (color(i) == GRAY) {\n // すでに登録されている重みよりも curr からの重みのほうが小さい場合は\n // 親ノードと重みを更新する\n if (matrix(curr)(i) < distance(i)) {\n distance(i) = matrix(curr)(i);\n parents(i) = curr;\n }\n if (minidx == -1 || distance(i) < distance(minidx)) i else minidx;\n } else { // color(i) == WHITE\n // 現時点のMSTに隣接していないノードは評価しない\n minidx;\n }\n } else { // color(i) == BLACK \n // すでにMSTに追加されているノードは評価しない\n minidx;\n }\n }\n if (idx != -1){\n // MSTから最も距離の近いノードを追加\n color(idx) = BLACK;\n _prim(idx);\n }\n }\n distance(0) = 0;\n parents(0) = -1;\n color(0) = BLACK;\n _prim(0);\n (parents, distance);\n }\n}\n", "language": "Scala", "metadata": {"date": 1523083931, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02241.html", "problem_id": "p02241", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02241/input.txt", "sample_output_relpath": "derived/input_output/data/p02241/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02241/Scala/s476303700.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s476303700", "user_id": "u909989059"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import scala.io.StdIn.{readInt, readLine};\nimport scala.annotation.tailrec;\nobject Main {\n def main(args: Array[String]): Unit = {\n val size = readInt;\n val m = new Array[Array[Int]](size);\n (0 until size).foreach { i => m(i) = readLine.trim.split(\" \").map( a => if (a.toInt == -1) Int.MaxValue else a.toInt)}\n val g = new Graph(size, m);\n val (parent, distance) = g.prim;\n println(distance.sum)\n }\n}\ncase class Graph(size: Int, matrix: Array[Array[Int]]) {\n val INFINITY = Int.MaxValue\n def prim(): (Array[Int], Array[Int]) = {\n // WHITE : 未訪問, GRAY: MST候補ノード, BLACK: MST追加済みノード\n val WHITE = 0; val GRAY = 1; val BLACK = 2;\n val color = new Array[Int](size); // 訪問状態リスト(WHITE, GRAY, BLACK)\n val distance = new Array[Int](size).map( e => INFINITY); // 重みリスト\n val parents = new Array[Int](size); // 親ノードリスト\n @tailrec\n def _prim(curr: Int): Unit = {\n // MSTに属する頂点の集合から最も近いノードの index を取得する\n val idx = (0 until size).foldLeft(-1) { (minidx, i) =>\n if (color(i) != BLACK) {\n // curr の子ノードをMST候補ノードに追加\n if (matrix(curr)(i) != -1) {\n color(i) = GRAY;\n }\n if (color(i) == GRAY) {\n // すでに登録されている重みよりも curr からの重みのほうが小さい場合は\n // 親ノードと重みを更新する\n if (matrix(curr)(i) < distance(i)) {\n distance(i) = matrix(curr)(i);\n parents(i) = curr;\n }\n if (minidx == -1 || distance(i) < distance(minidx)) i else minidx;\n } else { // color(i) == WHITE\n // 現時点のMSTに隣接していないノードは評価しない\n minidx;\n }\n } else { // color(i) == BLACK \n // すでにMSTに追加されているノードは評価しない\n minidx;\n }\n }\n if (idx != -1){\n // MSTから最も距離の近いノードを追加\n color(idx) = BLACK;\n _prim(idx);\n }\n }\n distance(0) = 0;\n parents(0) = -1;\n color(0) = BLACK;\n _prim(0);\n (parents, distance);\n }\n}\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMinimum Spanning Tree\n\nFor a given weighted graph $G = (V, E)$, find the minimum spanning tree (MST) of $G$ and print total weight of edges belong to the MST.\n\nInput\n\nIn the first line, an integer $n$ denoting the number of vertices in $G$ is given. In the following $n$ lines, a $n \\times n$ adjacency matrix $A$ which represents $G$ is given.\n$a_{ij}$ denotes the weight of edge connecting vertex $i$ and vertex $j$. If there is no edge between $i$ and $j$, $a_{ij}$ is given by -1.\n\nOutput\n\nPrint the total weight of the minimum spanning tree of $G$.\n\nConstraints\n\n$1 \\leq n \\leq 100$\n\n$0 \\leq a_{ij} \\leq 2,000$ (if $a_{ij} \\neq -1$)\n\n$a_{ij} = a_{ji}$\n\n$G$ is a connected graph\n\nSample Input 1\n\n5\n-1 2 3 1 -1\n2 -1 -1 4 -1\n3 -1 -1 1 1\n1 4 1 -1 3\n-1 -1 1 3 -1\n\nSample Output 1\n\n5\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "5\n -1 2 3 1 -1\n 2 -1 -1 4 -1\n 3 -1 -1 1 1\n 1 4 1 -1 3\n -1 -1 1 3 -1\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02241", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMinimum Spanning Tree\n\nFor a given weighted graph $G = (V, E)$, find the minimum spanning tree (MST) of $G$ and print total weight of edges belong to the MST.\n\nInput\n\nIn the first line, an integer $n$ denoting the number of vertices in $G$ is given. In the following $n$ lines, a $n \\times n$ adjacency matrix $A$ which represents $G$ is given.\n$a_{ij}$ denotes the weight of edge connecting vertex $i$ and vertex $j$. If there is no edge between $i$ and $j$, $a_{ij}$ is given by -1.\n\nOutput\n\nPrint the total weight of the minimum spanning tree of $G$.\n\nConstraints\n\n$1 \\leq n \\leq 100$\n\n$0 \\leq a_{ij} \\leq 2,000$ (if $a_{ij} \\neq -1$)\n\n$a_{ij} = a_{ji}$\n\n$G$ is a connected graph\n\nSample Input 1\n\n5\n-1 2 3 1 -1\n2 -1 -1 4 -1\n3 -1 -1 1 1\n1 4 1 -1 3\n-1 -1 1 3 -1\n\nSample Output 1\n\n5\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2637, "cpu_time_ms": 280, "memory_kb": 48972}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s538529532", "group_id": "codeNet:p02242", "input_text": "object Main {\n def main(args: Array[String]) = {\n val inf = Int.MaxValue-100000\n val in = io.Source.stdin.getLines\n val v = in.next.toInt\n val g = Array.fill(v)(inf)\n val e = in.flatMap(x => {val y = x.split(\" \").map(_.toInt); y.drop(2).grouped(2).map(y(0) +: _)})\n g(0) = 0\n var flag = true\n while(flag) {\n flag = false\n for (b <- e) if (g(b(0)) + b(2) < g(b(1))) {g(b(1)) = g(b(0)) + b(2); flag = true}\n }\n g.zipWithIndex.foreach(p => println(p._2 + \" \" + p._1))\n }\n}", "language": "Scala", "metadata": {"date": 1485178090, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02242.html", "problem_id": "p02242", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02242/input.txt", "sample_output_relpath": "derived/input_output/data/p02242/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02242/Scala/s538529532.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s538529532", "user_id": "u475394465"}, "prompt_components": {"gold_output": "0 0\n1 2\n2 2\n3 1\n4 3\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]) = {\n val inf = Int.MaxValue-100000\n val in = io.Source.stdin.getLines\n val v = in.next.toInt\n val g = Array.fill(v)(inf)\n val e = in.flatMap(x => {val y = x.split(\" \").map(_.toInt); y.drop(2).grouped(2).map(y(0) +: _)})\n g(0) = 0\n var flag = true\n while(flag) {\n flag = false\n for (b <- e) if (g(b(0)) + b(2) < g(b(1))) {g(b(1)) = g(b(0)) + b(2); flag = true}\n }\n g.zipWithIndex.foreach(p => println(p._2 + \" \" + p._1))\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nSingle Source Shortest Path\n\nFor a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$.\n\nInput\n\nIn the first line, an integer $n$ denoting the number of vertices in $G$ is given. In the following $n$ lines, adjacency lists for each vertex $u$ are respectively given in the following format:\n\n$u$ $k$ $v_1$ $c_1$ $v_2$ $c_2$ ... $v_k$ $c_k$\n\nVertices in $G$ are named with IDs $0, 1, ..., n-1$. $u$ is ID of the target vertex and $k$ denotes its degree. $v_i (i = 1, 2, ... k)$ denote IDs of vertices adjacent to $u$ and $c_i$ denotes the weight of a directed edge connecting $u$ and $v_i$ (from $u$ to $v_i$).\n\nOutput\n\nFor each vertex, print its ID and the distance separated by a space character in a line respectively. Print in order of vertex IDs.\n\nConstraints\n\n$1 \\leq n \\leq 100$\n\n$0 \\leq c_i \\leq 100,000$\n\n$|E| \\leq 10,000$\n\nAll vertices are reachable from vertex $0$\n\nSample Input 1\n\n5\n0 3 2 3 3 1 1 2\n1 2 0 2 3 4\n2 3 0 3 3 1 4 1\n3 4 2 1 0 1 1 4 4 3\n4 2 2 1 3 3\n\nSample Output 1\n\n0 0\n1 2\n2 2\n3 1\n4 3\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "5\n0 3 2 3 3 1 1 2\n1 2 0 2 3 4\n2 3 0 3 3 1 4 1\n3 4 2 1 0 1 1 4 4 3\n4 2 2 1 3 3\n"}, "reference_outputs": ["0 0\n1 2\n2 2\n3 1\n4 3\n"], "source_document_id": "p02242", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nSingle Source Shortest Path\n\nFor a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$.\n\nInput\n\nIn the first line, an integer $n$ denoting the number of vertices in $G$ is given. In the following $n$ lines, adjacency lists for each vertex $u$ are respectively given in the following format:\n\n$u$ $k$ $v_1$ $c_1$ $v_2$ $c_2$ ... $v_k$ $c_k$\n\nVertices in $G$ are named with IDs $0, 1, ..., n-1$. $u$ is ID of the target vertex and $k$ denotes its degree. $v_i (i = 1, 2, ... k)$ denote IDs of vertices adjacent to $u$ and $c_i$ denotes the weight of a directed edge connecting $u$ and $v_i$ (from $u$ to $v_i$).\n\nOutput\n\nFor each vertex, print its ID and the distance separated by a space character in a line respectively. Print in order of vertex IDs.\n\nConstraints\n\n$1 \\leq n \\leq 100$\n\n$0 \\leq c_i \\leq 100,000$\n\n$|E| \\leq 10,000$\n\nAll vertices are reachable from vertex $0$\n\nSample Input 1\n\n5\n0 3 2 3 3 1 1 2\n1 2 0 2 3 4\n2 3 0 3 3 1 4 1\n3 4 2 1 0 1 1 4 4 3\n4 2 2 1 3 3\n\nSample Output 1\n\n0 0\n1 2\n2 2\n3 1\n4 3\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 567, "cpu_time_ms": 230, "memory_kb": 43732}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s856689570", "group_id": "codeNet:p02247", "input_text": "import scala.io.StdIn.readLine\n\nobject Main {\n def main(args:Array[String]) = {\n val s1 = readLine\n val s2 = readLine\n for(i<-0 to s1.length-s2.length)\n if(s1(i)==s2(0))\n if(s1.slice(i,i+s2.length)==s2)\n println(i)\n }\n}", "language": "Scala", "metadata": {"date": 1491045194, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02247.html", "problem_id": "p02247", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02247/input.txt", "sample_output_relpath": "derived/input_output/data/p02247/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02247/Scala/s856689570.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s856689570", "user_id": "u508732591"}, "prompt_components": {"gold_output": "0\n3\n4\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main {\n def main(args:Array[String]) = {\n val s1 = readLine\n val s2 = readLine\n for(i<-0 to s1.length-s2.length)\n if(s1(i)==s2(0))\n if(s1.slice(i,i+s2.length)==s2)\n println(i)\n }\n}", "problem_context": "Naive String Search\n\nFind places where a string P is found within a text T.\n\nPrint all indices of T where P found. The indices of T start with 0.\n\nInput\n\nIn the first line, a text T is given. In the second line, a string P is given.\n\noutput\n\nPrint an index of T where P found in a line. Print the indices in ascending order.\n\nConstraints\n\n1 ≤ length of T ≤ 1000\n\n1 ≤ length of P ≤ 1000\n\nThe input consists of alphabetical characters and digits\n\nSample Input 1\n\naabaaa\naa\n\nSample Output 1\n\n0\n3\n4\n\nSample Input 2\n\nxyzz\nyz\n\nSample Output 2\n\n1\n\nSample Input 3\n\nabc\nxyz\n\nSample Output3\n\nThe ouput should be empty.", "sample_input": "aabaaa\naa\n"}, "reference_outputs": ["0\n3\n4\n"], "source_document_id": "p02247", "source_text": "Naive String Search\n\nFind places where a string P is found within a text T.\n\nPrint all indices of T where P found. The indices of T start with 0.\n\nInput\n\nIn the first line, a text T is given. In the second line, a string P is given.\n\noutput\n\nPrint an index of T where P found in a line. Print the indices in ascending order.\n\nConstraints\n\n1 ≤ length of T ≤ 1000\n\n1 ≤ length of P ≤ 1000\n\nThe input consists of alphabetical characters and digits\n\nSample Input 1\n\naabaaa\naa\n\nSample Output 1\n\n0\n3\n4\n\nSample Input 2\n\nxyzz\nyz\n\nSample Output 2\n\n1\n\nSample Input 3\n\nabc\nxyz\n\nSample Output3\n\nThe ouput should be empty.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 251, "cpu_time_ms": 250, "memory_kb": 43920}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s693641269", "group_id": "codeNet:p02256", "input_text": "import scala.io.StdIn\n\nobject Main{\n def main(args: Array[String]) = {\n def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)\n val (a :: b :: _) = StdIn.readLine().split(\" \").map(_.toInt).toList\n println(gcd(a, b))\n }\n}", "language": "Scala", "metadata": {"date": 1461858783, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02256.html", "problem_id": "p02256", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02256/input.txt", "sample_output_relpath": "derived/input_output/data/p02256/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02256/Scala/s693641269.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s693641269", "user_id": "u389172382"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main{\n def main(args: Array[String]) = {\n def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)\n val (a :: b :: _) = StdIn.readLine().split(\" \").map(_.toInt).toList\n println(gcd(a, b))\n }\n}", "problem_context": "Greatest Common Divisor\n\nWrite a program which finds the greatest common divisor of two natural numbers a and b\n\nInput\n\na and b are given in a line sparated by a single space.\n\nOutput\n\nOutput the greatest common divisor of a and b.\n\nConstrants\n\n1 ≤ a, b ≤ 109\n\nHint\n\nYou can use the following observation:\n\nFor integers x and y, if x ≥ y, then gcd(x, y) = gcd(y, x%y)\n\nSample Input 1\n\n54 20\n\nSample Output 1\n\n2\n\nSample Input 2\n\n147 105\n\nSample Output 2\n\n21", "sample_input": "54 20\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02256", "source_text": "Greatest Common Divisor\n\nWrite a program which finds the greatest common divisor of two natural numbers a and b\n\nInput\n\na and b are given in a line sparated by a single space.\n\nOutput\n\nOutput the greatest common divisor of a and b.\n\nConstrants\n\n1 ≤ a, b ≤ 109\n\nHint\n\nYou can use the following observation:\n\nFor integers x and y, if x ≥ y, then gcd(x, y) = gcd(y, x%y)\n\nSample Input 1\n\n54 20\n\nSample Output 1\n\n2\n\nSample Input 2\n\n147 105\n\nSample Output 2\n\n21", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 270, "memory_kb": 43552}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s170282440", "group_id": "codeNet:p02256", "input_text": "object Main {\n def gcd(a: Int, b: Int): Int = {\n if (b == 0) {\n a\n } else {\n gcd(b, a % b)\n }\n }\n\n def main(args: Array[String]): Unit = {\n val Array(a, b) = io.StdIn.readLine().split(\" \").map(_.toInt)\n println(gcd(a, b))\n }\n}\n", "language": "Scala", "metadata": {"date": 1528691834, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02256.html", "problem_id": "p02256", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02256/input.txt", "sample_output_relpath": "derived/input_output/data/p02256/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02256/Scala/s170282440.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s170282440", "user_id": "u958669959"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main {\n def gcd(a: Int, b: Int): Int = {\n if (b == 0) {\n a\n } else {\n gcd(b, a % b)\n }\n }\n\n def main(args: Array[String]): Unit = {\n val Array(a, b) = io.StdIn.readLine().split(\" \").map(_.toInt)\n println(gcd(a, b))\n }\n}\n", "problem_context": "Greatest Common Divisor\n\nWrite a program which finds the greatest common divisor of two natural numbers a and b\n\nInput\n\na and b are given in a line sparated by a single space.\n\nOutput\n\nOutput the greatest common divisor of a and b.\n\nConstrants\n\n1 ≤ a, b ≤ 109\n\nHint\n\nYou can use the following observation:\n\nFor integers x and y, if x ≥ y, then gcd(x, y) = gcd(y, x%y)\n\nSample Input 1\n\n54 20\n\nSample Output 1\n\n2\n\nSample Input 2\n\n147 105\n\nSample Output 2\n\n21", "sample_input": "54 20\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02256", "source_text": "Greatest Common Divisor\n\nWrite a program which finds the greatest common divisor of two natural numbers a and b\n\nInput\n\na and b are given in a line sparated by a single space.\n\nOutput\n\nOutput the greatest common divisor of a and b.\n\nConstrants\n\n1 ≤ a, b ≤ 109\n\nHint\n\nYou can use the following observation:\n\nFor integers x and y, if x ≥ y, then gcd(x, y) = gcd(y, x%y)\n\nSample Input 1\n\n54 20\n\nSample Output 1\n\n2\n\nSample Input 2\n\n147 105\n\nSample Output 2\n\n21", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43960}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s446975479", "group_id": "codeNet:p02256", "input_text": "import scala.io.StdIn\n\nobject Main{\n def main(args: Array[String]){\n var a = StdIn.readLine().split(\" \").map(_.toInt)\n \n println(yukuriddo(a(0), a(1)))\n }\n \n def yukuriddo(a: Int, b: Int): Int = {\n \n if(b != 0){\n yukuriddo(b, a % b)\n }else{\n a\n }\n \n \n }\n}\n", "language": "Scala", "metadata": {"date": 1571028164, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02256.html", "problem_id": "p02256", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02256/input.txt", "sample_output_relpath": "derived/input_output/data/p02256/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02256/Scala/s446975479.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s446975479", "user_id": "u687450887"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main{\n def main(args: Array[String]){\n var a = StdIn.readLine().split(\" \").map(_.toInt)\n \n println(yukuriddo(a(0), a(1)))\n }\n \n def yukuriddo(a: Int, b: Int): Int = {\n \n if(b != 0){\n yukuriddo(b, a % b)\n }else{\n a\n }\n \n \n }\n}\n", "problem_context": "Greatest Common Divisor\n\nWrite a program which finds the greatest common divisor of two natural numbers a and b\n\nInput\n\na and b are given in a line sparated by a single space.\n\nOutput\n\nOutput the greatest common divisor of a and b.\n\nConstrants\n\n1 ≤ a, b ≤ 109\n\nHint\n\nYou can use the following observation:\n\nFor integers x and y, if x ≥ y, then gcd(x, y) = gcd(y, x%y)\n\nSample Input 1\n\n54 20\n\nSample Output 1\n\n2\n\nSample Input 2\n\n147 105\n\nSample Output 2\n\n21", "sample_input": "54 20\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02256", "source_text": "Greatest Common Divisor\n\nWrite a program which finds the greatest common divisor of two natural numbers a and b\n\nInput\n\na and b are given in a line sparated by a single space.\n\nOutput\n\nOutput the greatest common divisor of a and b.\n\nConstrants\n\n1 ≤ a, b ≤ 109\n\nHint\n\nYou can use the following observation:\n\nFor integers x and y, if x ≥ y, then gcd(x, y) = gcd(y, x%y)\n\nSample Input 1\n\n54 20\n\nSample Output 1\n\n2\n\nSample Input 2\n\n147 105\n\nSample Output 2\n\n21", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 300, "memory_kb": 43580}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s459253323", "group_id": "codeNet:p02256", "input_text": "import scala.io.StdIn.readLine;\nobject Main {\n def main(args: Array[String]): Unit = {\n val Array(x, y) = readLine.split(\" \").map(_.toInt);\n println(gcd(x, y));\n }\n def gcd(x: Int, y: Int): Int = {\n if (x < y) {\n gcd(y, x);\n } else if (x % y == 0) {\n y;\n } else {\n gcd(y, x % y);\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1547046330, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02256.html", "problem_id": "p02256", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02256/input.txt", "sample_output_relpath": "derived/input_output/data/p02256/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02256/Scala/s459253323.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s459253323", "user_id": "u909989059"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.io.StdIn.readLine;\nobject Main {\n def main(args: Array[String]): Unit = {\n val Array(x, y) = readLine.split(\" \").map(_.toInt);\n println(gcd(x, y));\n }\n def gcd(x: Int, y: Int): Int = {\n if (x < y) {\n gcd(y, x);\n } else if (x % y == 0) {\n y;\n } else {\n gcd(y, x % y);\n }\n }\n}\n", "problem_context": "Greatest Common Divisor\n\nWrite a program which finds the greatest common divisor of two natural numbers a and b\n\nInput\n\na and b are given in a line sparated by a single space.\n\nOutput\n\nOutput the greatest common divisor of a and b.\n\nConstrants\n\n1 ≤ a, b ≤ 109\n\nHint\n\nYou can use the following observation:\n\nFor integers x and y, if x ≥ y, then gcd(x, y) = gcd(y, x%y)\n\nSample Input 1\n\n54 20\n\nSample Output 1\n\n2\n\nSample Input 2\n\n147 105\n\nSample Output 2\n\n21", "sample_input": "54 20\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02256", "source_text": "Greatest Common Divisor\n\nWrite a program which finds the greatest common divisor of two natural numbers a and b\n\nInput\n\na and b are given in a line sparated by a single space.\n\nOutput\n\nOutput the greatest common divisor of a and b.\n\nConstrants\n\n1 ≤ a, b ≤ 109\n\nHint\n\nYou can use the following observation:\n\nFor integers x and y, if x ≥ y, then gcd(x, y) = gcd(y, x%y)\n\nSample Input 1\n\n54 20\n\nSample Output 1\n\n2\n\nSample Input 2\n\n147 105\n\nSample Output 2\n\n21", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43872}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s850604752", "group_id": "codeNet:p02257", "input_text": "object Main{\n def main(args: Array[String]){\n val in = new java.util.Scanner(System.in)\n val a = in.nextInt\n var count = 0\n\n var arr = new Array[Int](a)\n for(i <- 0 to a-1){\n arr(i) = in.nextInt\n }\n\n for(i <- 0 to a-2){\n var minpos = i;\n var minval = arr(i);\n\n for(j <- i+1 to a-1){\n if(arr(j) < minval){\n minpos = j;\n minval = arr(j)\n }\n }\n\n if(minpos != i){\n var tmp = arr(minpos)\n arr(minpos) = arr(i)\n arr(i) = tmp\n count = count + 1\n }\n }\n\n println(arr.mkString(\" \"))\n println(count)\n }\n}", "language": "Scala", "metadata": {"date": 1435071686, "filename_ext": "scala", "original_language": "Scala", "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/Scala/s850604752.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s850604752", "user_id": "u085441951"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main{\n def main(args: Array[String]){\n val in = new java.util.Scanner(System.in)\n val a = in.nextInt\n var count = 0\n\n var arr = new Array[Int](a)\n for(i <- 0 to a-1){\n arr(i) = in.nextInt\n }\n\n for(i <- 0 to a-2){\n var minpos = i;\n var minval = arr(i);\n\n for(j <- i+1 to a-1){\n if(arr(j) < minval){\n minpos = j;\n minval = arr(j)\n }\n }\n\n if(minpos != i){\n var tmp = arr(minpos)\n arr(minpos) = arr(i)\n arr(i) = tmp\n count = count + 1\n }\n }\n\n println(arr.mkString(\" \"))\n println(count)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 620, "cpu_time_ms": 240, "memory_kb": 41984}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s139310258", "group_id": "codeNet:p02257", "input_text": "object Main {\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val ls = List.fill(n)(sc.nextInt)\n println(ls.filter(i => is_prime(i)).size)\n }\n def is_prime2(n: Int): Boolean = {\n if (n == 2) return true\n //val count = (2 to n).filter(i => i * i <= n).filter(j => n % j == 0).size //memory limit exceeded\n val count_seq = for (i <- 2 to n if i * i <= n; if n % i == 0) yield i //memory limit exceeded\n val count = count_seq.size\n if (count == 0) true else false \n }\n def is_prime(n: Int): Boolean = {\n if (n == 2)\n return true\n var i = 2\n while (i * i <= n){\n if (n%i == 0){\n return false\n }\n i += 1\n }\n return true\n }\n}", "language": "Scala", "metadata": {"date": 1441630755, "filename_ext": "scala", "original_language": "Scala", "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/Scala/s139310258.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s139310258", "user_id": "u879226672"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main {\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val ls = List.fill(n)(sc.nextInt)\n println(ls.filter(i => is_prime(i)).size)\n }\n def is_prime2(n: Int): Boolean = {\n if (n == 2) return true\n //val count = (2 to n).filter(i => i * i <= n).filter(j => n % j == 0).size //memory limit exceeded\n val count_seq = for (i <- 2 to n if i * i <= n; if n % i == 0) yield i //memory limit exceeded\n val count = count_seq.size\n if (count == 0) true else false \n }\n def is_prime(n: Int): Boolean = {\n if (n == 2)\n return true\n var i = 2\n while (i * i <= n){\n if (n%i == 0){\n return false\n }\n i += 1\n }\n return true\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 440, "memory_kb": 59608}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s192633363", "group_id": "codeNet:p02257", "input_text": "object Main {\n def is_prime(n: Int): Boolean = {\n if (n == 2)\n return true\n var i = 2\n while (i * i <= n){\n if (n%i == 0){\n return false\n }\n i += 1\n }\n return true\n }\n def main(args:Array[String]) = {\n //val primes = for (i <- 2 to 999999 if is_prime(i)) yield i\n val primes = (2 to 999999).par.filter(i => is_prime(i))\n val sc = new java.util.Scanner(System.in)\n while (sc.hasNext){\n val n = sc.nextInt\n println(primes.count(i => i <= n))\n }\n }\n}", "language": "Scala", "metadata": {"date": 1442017160, "filename_ext": "scala", "original_language": "Scala", "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/Scala/s192633363.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s192633363", "user_id": "u879226672"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main {\n def is_prime(n: Int): Boolean = {\n if (n == 2)\n return true\n var i = 2\n while (i * i <= n){\n if (n%i == 0){\n return false\n }\n i += 1\n }\n return true\n }\n def main(args:Array[String]) = {\n //val primes = for (i <- 2 to 999999 if is_prime(i)) yield i\n val primes = (2 to 999999).par.filter(i => is_prime(i))\n val sc = new java.util.Scanner(System.in)\n while (sc.hasNext){\n val n = sc.nextInt\n println(primes.count(i => i <= 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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 518, "cpu_time_ms": 1030, "memory_kb": 67904}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s565513021", "group_id": "codeNet:p02257", "input_text": "import scala.io.Source\n\nobject Main{\n def main(args: Array[String]){\n val lines = for{\n in <- Source.stdin.getLines\n }yield if(isPrime(in.toInt)) in else -1\n\n println(lines.toList.tail.filter(_ != -1).length)\n }\n\n def isPrime(n: Int): Boolean = (2 to Math.sqrt(n).toInt).forall(n % _ != 0)\n}", "language": "Scala", "metadata": {"date": 1461646032, "filename_ext": "scala", "original_language": "Scala", "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/Scala/s565513021.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s565513021", "user_id": "u085441951"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.io.Source\n\nobject Main{\n def main(args: Array[String]){\n val lines = for{\n in <- Source.stdin.getLines\n }yield if(isPrime(in.toInt)) in else -1\n\n println(lines.toList.tail.filter(_ != -1).length)\n }\n\n def isPrime(n: Int): Boolean = (2 to Math.sqrt(n).toInt).forall(n % _ != 0)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 308, "cpu_time_ms": 370, "memory_kb": 103440}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s397336554", "group_id": "codeNet:p02257", "input_text": "import scala.io.StdIn.readInt\n \nobject Main {\n val r = Array(2,3,5,7)\n \n def twoPow(d:Int,s:Int):(Int,Int) = {\n if(d%2 == 1) (d,s)\n else twoPow(d>>1,s+1)\n }\n \n def maybePrime(i:Int,d:Int,s:Int, n:Int):Boolean = {\n if(i>3) true\n else {\n val a = r(i)\n val x = BigInt(a).modPow(d,n).toLong\n \n if(x==1 || x==n-1) maybePrime(i+1,d,s,n)\n else repeat(s-1,x*x%n, i, d, s, n)\n }\n }\n \n def repeat(j:Int, x:Long, i:Int, d:Int, s:Int, n:Int):Boolean = {\n if(j==0) false\n else if(x==1) false\n else if(x==n-1) maybePrime(i+1,d,s,n)\n else repeat(j-1,x*x%n,i,d,s,n)\n }\n \n def isPrime(n:Int):Boolean = {\n if(n<2000) (2 to Math.sqrt(n).toInt).forall(n%_ != 0)\n else if(n%2==0) false\n else {\n val (d,s) = twoPow(n-1,0)\n maybePrime(0,d,s,n)\n }\n }\n \n def main(args:Array[String]) = {\n val n = readInt\n println((0 until n).count{ _=> isPrime(readInt) })\n }\n}", "language": "Scala", "metadata": {"date": 1483622347, "filename_ext": "scala", "original_language": "Scala", "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/Scala/s397336554.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s397336554", "user_id": "u508732591"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.io.StdIn.readInt\n \nobject Main {\n val r = Array(2,3,5,7)\n \n def twoPow(d:Int,s:Int):(Int,Int) = {\n if(d%2 == 1) (d,s)\n else twoPow(d>>1,s+1)\n }\n \n def maybePrime(i:Int,d:Int,s:Int, n:Int):Boolean = {\n if(i>3) true\n else {\n val a = r(i)\n val x = BigInt(a).modPow(d,n).toLong\n \n if(x==1 || x==n-1) maybePrime(i+1,d,s,n)\n else repeat(s-1,x*x%n, i, d, s, n)\n }\n }\n \n def repeat(j:Int, x:Long, i:Int, d:Int, s:Int, n:Int):Boolean = {\n if(j==0) false\n else if(x==1) false\n else if(x==n-1) maybePrime(i+1,d,s,n)\n else repeat(j-1,x*x%n,i,d,s,n)\n }\n \n def isPrime(n:Int):Boolean = {\n if(n<2000) (2 to Math.sqrt(n).toInt).forall(n%_ != 0)\n else if(n%2==0) false\n else {\n val (d,s) = twoPow(n-1,0)\n maybePrime(0,d,s,n)\n }\n }\n \n def main(args:Array[String]) = {\n val n = readInt\n println((0 until n).count{ _=> isPrime(readInt) })\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 929, "cpu_time_ms": 360, "memory_kb": 61996}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s005008059", "group_id": "codeNet:p02257", "input_text": "object Main{\n def main(args:Array[String]) = {\n val lines = for{\n in <-scala.io.Source.stdin.getLines()\n }yield if(isPrime(in.toInt)) in else -1\n\n println(lines.filter(_ != -1).length)\n }\n def isPrime(n : Int) : Boolean = (2 to Math.sqrt(n).toInt).forall(n % _ != 0)\n}", "language": "Scala", "metadata": {"date": 1493478408, "filename_ext": "scala", "original_language": "Scala", "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/Scala/s005008059.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s005008059", "user_id": "u808689778"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main{\n def main(args:Array[String]) = {\n val lines = for{\n in <-scala.io.Source.stdin.getLines()\n }yield if(isPrime(in.toInt)) in else -1\n\n println(lines.filter(_ != -1).length)\n }\n def isPrime(n : Int) : Boolean = (2 to Math.sqrt(n).toInt).forall(n % _ != 0)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 360, "memory_kb": 101412}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s126706861", "group_id": "codeNet:p02257", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val scanner = new java.util.Scanner(System.in)\n\n var a = 0\n for(_ <- 1 to scanner.nextInt) {\n val x = scanner.nextDouble\n if((2 to math.sqrt(x).toInt).find(x % _ == 0).isEmpty) a = a + 1\n }\n println(a)\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1523864526, "filename_ext": "scala", "original_language": "Scala", "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/Scala/s126706861.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s126706861", "user_id": "u250696856"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val scanner = new java.util.Scanner(System.in)\n\n var a = 0\n for(_ <- 1 to scanner.nextInt) {\n val x = scanner.nextDouble\n if((2 to math.sqrt(x).toInt).find(x % _ == 0).isEmpty) a = a + 1\n }\n println(a)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 950, "memory_kb": 155836}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s301006951", "group_id": "codeNet:p02257", "input_text": "import scala.io.StdIn\nimport scala.math.sqrt\n\nobject Main{\n def main(args: Array[String]){\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt // 最初の数字を読み取る\n val list = List.fill(n)(sc.nextInt) // nextIntがn回呼ばれる\n var count = 0;\n for(j <- list)if(isPrime(j)) count = count + 1\n \n \n println(count)\n }\n \n def isPrime(x: Int): Boolean = {\n if(x == 2){\n return true\n }\n \n if(x < 2 || x % 2 == 0){\n return false\n }\n \n var i = 3;\n while(i <= sqrt(x)){\n if(x % i == 0){\n return false\n }\n i += 2\n }\n return true\n }\n}\n", "language": "Scala", "metadata": {"date": 1571034412, "filename_ext": "scala", "original_language": "Scala", "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/Scala/s301006951.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s301006951", "user_id": "u687450887"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.io.StdIn\nimport scala.math.sqrt\n\nobject Main{\n def main(args: Array[String]){\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt // 最初の数字を読み取る\n val list = List.fill(n)(sc.nextInt) // nextIntがn回呼ばれる\n var count = 0;\n for(j <- list)if(isPrime(j)) count = count + 1\n \n \n println(count)\n }\n \n def isPrime(x: Int): Boolean = {\n if(x == 2){\n return true\n }\n \n if(x < 2 || x % 2 == 0){\n return false\n }\n \n var i = 3;\n while(i <= sqrt(x)){\n if(x % i == 0){\n return false\n }\n i += 2\n }\n return true\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 766, "cpu_time_ms": 510, "memory_kb": 60144}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s050555512", "group_id": "codeNet:p02258", "input_text": "import java.util.Scanner\nimport scala.annotation.tailrec\n\nobject Main{\n def main(args: Array[String]){\n val sc = new Scanner(System.in)\n val n = sc.nextInt\n val list = List.fill(n)(sc.nextInt)\n\n println(rec(list, Int.MinValue, Int.MaxValue))\n }\n\n @tailrec\n def rec(list: List[Int], preMax: Int, preMin: Int): Int ={\n if(list.length == 1) preMax\n else{\n val min = Math.min(preMin, list.init.min)\n rec(list.init, Math.max(list.last - min, preMax), min)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1461765298, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02258.html", "problem_id": "p02258", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02258/input.txt", "sample_output_relpath": "derived/input_output/data/p02258/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02258/Scala/s050555512.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s050555512", "user_id": "u085441951"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Scanner\nimport scala.annotation.tailrec\n\nobject Main{\n def main(args: Array[String]){\n val sc = new Scanner(System.in)\n val n = sc.nextInt\n val list = List.fill(n)(sc.nextInt)\n\n println(rec(list, Int.MinValue, Int.MaxValue))\n }\n\n @tailrec\n def rec(list: List[Int], preMax: Int, preMin: Int): Int ={\n if(list.length == 1) preMax\n else{\n val min = Math.min(preMin, list.init.min)\n rec(list.init, Math.max(list.last - min, preMax), min)\n }\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMaximum Profit\n\nYou can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.\n\nWrite a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .\n\nInput\n\nThe first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.\n\nOutput\n\nPrint the maximum value in a line.\n\nConstraints\n\n$2 \\leq n \\leq 200,000$\n\n$1 \\leq R_t \\leq 10^9$\n\nSample Input 1\n\n6\n5\n3\n1\n3\n4\n3\n\nSample Output 1\n\n3\n\nSample Input 2\n\n3\n4\n3\n2\n\nSample Output 2\n\n-1", "sample_input": "6\n5\n3\n1\n3\n4\n3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02258", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMaximum Profit\n\nYou can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.\n\nWrite a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .\n\nInput\n\nThe first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.\n\nOutput\n\nPrint the maximum value in a line.\n\nConstraints\n\n$2 \\leq n \\leq 200,000$\n\n$1 \\leq R_t \\leq 10^9$\n\nSample Input 1\n\n6\n5\n3\n1\n3\n4\n3\n\nSample Output 1\n\n3\n\nSample Input 2\n\n3\n4\n3\n2\n\nSample Output 2\n\n-1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 260, "memory_kb": 44716}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s115650958", "group_id": "codeNet:p02258", "input_text": "import scala.io.StdIn.readInt\nimport scala.io.Source.stdin\n\nobject Main {\n def main(args: Array[String]) = {\n val list = stdin.getLines().map { _.toInt }\n val n = list.next()\n val r0 = list.next()\n val r1 = list.next()\n var max = r1 - r0\n var min = if(r0 > r1) r1 else r0\n for( m <- list ) {\n if( max < m - min) {\n max = m - min\n if( min > m )\n min = m\n }\n else if( min > m ) {\n min = m\n }\n }\n println(max)\n }\n}", "language": "Scala", "metadata": {"date": 1467286771, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02258.html", "problem_id": "p02258", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02258/input.txt", "sample_output_relpath": "derived/input_output/data/p02258/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02258/Scala/s115650958.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s115650958", "user_id": "u935184340"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.io.StdIn.readInt\nimport scala.io.Source.stdin\n\nobject Main {\n def main(args: Array[String]) = {\n val list = stdin.getLines().map { _.toInt }\n val n = list.next()\n val r0 = list.next()\n val r1 = list.next()\n var max = r1 - r0\n var min = if(r0 > r1) r1 else r0\n for( m <- list ) {\n if( max < m - min) {\n max = m - min\n if( min > m )\n min = m\n }\n else if( min > m ) {\n min = m\n }\n }\n println(max)\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMaximum Profit\n\nYou can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.\n\nWrite a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .\n\nInput\n\nThe first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.\n\nOutput\n\nPrint the maximum value in a line.\n\nConstraints\n\n$2 \\leq n \\leq 200,000$\n\n$1 \\leq R_t \\leq 10^9$\n\nSample Input 1\n\n6\n5\n3\n1\n3\n4\n3\n\nSample Output 1\n\n3\n\nSample Input 2\n\n3\n4\n3\n2\n\nSample Output 2\n\n-1", "sample_input": "6\n5\n3\n1\n3\n4\n3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02258", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMaximum Profit\n\nYou can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.\n\nWrite a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .\n\nInput\n\nThe first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.\n\nOutput\n\nPrint the maximum value in a line.\n\nConstraints\n\n$2 \\leq n \\leq 200,000$\n\n$1 \\leq R_t \\leq 10^9$\n\nSample Input 1\n\n6\n5\n3\n1\n3\n4\n3\n\nSample Output 1\n\n3\n\nSample Input 2\n\n3\n4\n3\n2\n\nSample Output 2\n\n-1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 350, "memory_kb": 64720}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s683607084", "group_id": "codeNet:p02258", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val inputString = \"6\\n2\\n3\\n1\\n3\\n4\\n3\"\n// val inputString = io.StdIn.readLine()\n val intArray = inputString.split(\"\\n\").map(_.toInt)\n val sz = intArray(0)\n var ret = Int.MinValue\n for(i <- 1 to sz) {\n for(j <- i+1 to sz) {\n val t = intArray(j) - intArray(i)\n if(t>ret) ret = t\n }\n }\n println(ret)\n }\n}", "language": "Scala", "metadata": {"date": 1497405448, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02258.html", "problem_id": "p02258", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02258/input.txt", "sample_output_relpath": "derived/input_output/data/p02258/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02258/Scala/s683607084.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s683607084", "user_id": "u256600337"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val inputString = \"6\\n2\\n3\\n1\\n3\\n4\\n3\"\n// val inputString = io.StdIn.readLine()\n val intArray = inputString.split(\"\\n\").map(_.toInt)\n val sz = intArray(0)\n var ret = Int.MinValue\n for(i <- 1 to sz) {\n for(j <- i+1 to sz) {\n val t = intArray(j) - intArray(i)\n if(t>ret) ret = t\n }\n }\n println(ret)\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMaximum Profit\n\nYou can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.\n\nWrite a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .\n\nInput\n\nThe first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.\n\nOutput\n\nPrint the maximum value in a line.\n\nConstraints\n\n$2 \\leq n \\leq 200,000$\n\n$1 \\leq R_t \\leq 10^9$\n\nSample Input 1\n\n6\n5\n3\n1\n3\n4\n3\n\nSample Output 1\n\n3\n\nSample Input 2\n\n3\n4\n3\n2\n\nSample Output 2\n\n-1", "sample_input": "6\n5\n3\n1\n3\n4\n3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02258", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMaximum Profit\n\nYou can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.\n\nWrite a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .\n\nInput\n\nThe first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.\n\nOutput\n\nPrint the maximum value in a line.\n\nConstraints\n\n$2 \\leq n \\leq 200,000$\n\n$1 \\leq R_t \\leq 10^9$\n\nSample Input 1\n\n6\n5\n3\n1\n3\n4\n3\n\nSample Output 1\n\n3\n\nSample Input 2\n\n3\n4\n3\n2\n\nSample Output 2\n\n-1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 408, "cpu_time_ms": 220, "memory_kb": 43668}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s130672218", "group_id": "codeNet:p02258", "input_text": "import scala.io.StdIn\nobject Main extends App {\n\n val n = StdIn.readLine().trim.toInt\n\n var minv = StdIn.readLine().trim.toInt\n var maxv = (scala.math.pow(10, 9) * -1 ).toInt\n (1 until n).foreach{ j =>\n val temp = StdIn.readLine().trim.toInt\n maxv = if(maxv < temp - minv) temp - minv else maxv\n minv = if(temp < minv) temp else minv\n }\n\n println(maxv)\n \n}\n\n", "language": "Scala", "metadata": {"date": 1521815650, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02258.html", "problem_id": "p02258", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02258/input.txt", "sample_output_relpath": "derived/input_output/data/p02258/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02258/Scala/s130672218.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s130672218", "user_id": "u342234782"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.io.StdIn\nobject Main extends App {\n\n val n = StdIn.readLine().trim.toInt\n\n var minv = StdIn.readLine().trim.toInt\n var maxv = (scala.math.pow(10, 9) * -1 ).toInt\n (1 until n).foreach{ j =>\n val temp = StdIn.readLine().trim.toInt\n maxv = if(maxv < temp - minv) temp - minv else maxv\n minv = if(temp < minv) temp else minv\n }\n\n println(maxv)\n \n}\n\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMaximum Profit\n\nYou can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.\n\nWrite a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .\n\nInput\n\nThe first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.\n\nOutput\n\nPrint the maximum value in a line.\n\nConstraints\n\n$2 \\leq n \\leq 200,000$\n\n$1 \\leq R_t \\leq 10^9$\n\nSample Input 1\n\n6\n5\n3\n1\n3\n4\n3\n\nSample Output 1\n\n3\n\nSample Input 2\n\n3\n4\n3\n2\n\nSample Output 2\n\n-1", "sample_input": "6\n5\n3\n1\n3\n4\n3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02258", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMaximum Profit\n\nYou can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.\n\nWrite a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .\n\nInput\n\nThe first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.\n\nOutput\n\nPrint the maximum value in a line.\n\nConstraints\n\n$2 \\leq n \\leq 200,000$\n\n$1 \\leq R_t \\leq 10^9$\n\nSample Input 1\n\n6\n5\n3\n1\n3\n4\n3\n\nSample Output 1\n\n3\n\nSample Input 2\n\n3\n4\n3\n2\n\nSample Output 2\n\n-1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 370, "memory_kb": 63420}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s459481188", "group_id": "codeNet:p02258", "input_text": "import scala.io.Source\n\nobject Main {\n// def calcMaxProfit(numbers: Seq[Int]): Int = {\n// val maxProfit: Int = (1 to numbers.size-1)\n// .toStream\n// .map{i =>\n// val a = numbers(i-1)\n// val bs = numbers.toStream.drop(i)\n// bs.max - a\n// }\n// .max\n// maxProfit\n// }\n\n def calcMaxProfit(numbers: Seq[Int]): Int = {\n var min = numbers(0)\n var maxProfit = numbers(1) - min\n for(i <- 1 until numbers.size) {\n maxProfit = math.max(maxProfit, numbers(i) - min)\n min = math.min(min, numbers(i))\n }\n maxProfit\n }\n\n\n def main(args: Array[String]): Unit = {\n // Get interator of stdin\n val stdinIterator = Source.stdin.getLines()\n\n // Skip the first line\n stdinIterator.next()\n\n // Get input\n val numbers: Seq[Int] = stdinIterator.toSeq.map(_.toInt).toArray\n\n // Calc max profit\n val maxProfit = calcMaxProfit(numbers)\n\n // Print max profit\n println(maxProfit)\n }\n}\n", "language": "Scala", "metadata": {"date": 1528694847, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02258.html", "problem_id": "p02258", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02258/input.txt", "sample_output_relpath": "derived/input_output/data/p02258/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02258/Scala/s459481188.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s459481188", "user_id": "u958669959"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.io.Source\n\nobject Main {\n// def calcMaxProfit(numbers: Seq[Int]): Int = {\n// val maxProfit: Int = (1 to numbers.size-1)\n// .toStream\n// .map{i =>\n// val a = numbers(i-1)\n// val bs = numbers.toStream.drop(i)\n// bs.max - a\n// }\n// .max\n// maxProfit\n// }\n\n def calcMaxProfit(numbers: Seq[Int]): Int = {\n var min = numbers(0)\n var maxProfit = numbers(1) - min\n for(i <- 1 until numbers.size) {\n maxProfit = math.max(maxProfit, numbers(i) - min)\n min = math.min(min, numbers(i))\n }\n maxProfit\n }\n\n\n def main(args: Array[String]): Unit = {\n // Get interator of stdin\n val stdinIterator = Source.stdin.getLines()\n\n // Skip the first line\n stdinIterator.next()\n\n // Get input\n val numbers: Seq[Int] = stdinIterator.toSeq.map(_.toInt).toArray\n\n // Calc max profit\n val maxProfit = calcMaxProfit(numbers)\n\n // Print max profit\n println(maxProfit)\n }\n}\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMaximum Profit\n\nYou can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.\n\nWrite a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .\n\nInput\n\nThe first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.\n\nOutput\n\nPrint the maximum value in a line.\n\nConstraints\n\n$2 \\leq n \\leq 200,000$\n\n$1 \\leq R_t \\leq 10^9$\n\nSample Input 1\n\n6\n5\n3\n1\n3\n4\n3\n\nSample Output 1\n\n3\n\nSample Input 2\n\n3\n4\n3\n2\n\nSample Output 2\n\n-1", "sample_input": "6\n5\n3\n1\n3\n4\n3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02258", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMaximum Profit\n\nYou can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.\n\nWrite a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .\n\nInput\n\nThe first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.\n\nOutput\n\nPrint the maximum value in a line.\n\nConstraints\n\n$2 \\leq n \\leq 200,000$\n\n$1 \\leq R_t \\leq 10^9$\n\nSample Input 1\n\n6\n5\n3\n1\n3\n4\n3\n\nSample Output 1\n\n3\n\nSample Input 2\n\n3\n4\n3\n2\n\nSample Output 2\n\n-1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 976, "cpu_time_ms": 720, "memory_kb": 120776}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s445698311", "group_id": "codeNet:p02258", "input_text": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val n = sc.nextInt()\n val r = Array.fill(n)(sc.nextInt())\n\n var minv = r(0)\n var maxv = r(1) - r(0)\n\n (1 until n).foreach { j =>\n maxv = Math.max(maxv, r(j) - minv)\n minv = Math.min(minv, r(j))\n }\n\n println(maxv)\n }\n\n}\n\n", "language": "Scala", "metadata": {"date": 1590654200, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02258.html", "problem_id": "p02258", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02258/input.txt", "sample_output_relpath": "derived/input_output/data/p02258/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02258/Scala/s445698311.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s445698311", "user_id": "u829797112"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val n = sc.nextInt()\n val r = Array.fill(n)(sc.nextInt())\n\n var minv = r(0)\n var maxv = r(1) - r(0)\n\n (1 until n).foreach { j =>\n maxv = Math.max(maxv, r(j) - minv)\n minv = Math.min(minv, r(j))\n }\n\n println(maxv)\n }\n\n}\n\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMaximum Profit\n\nYou can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.\n\nWrite a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .\n\nInput\n\nThe first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.\n\nOutput\n\nPrint the maximum value in a line.\n\nConstraints\n\n$2 \\leq n \\leq 200,000$\n\n$1 \\leq R_t \\leq 10^9$\n\nSample Input 1\n\n6\n5\n3\n1\n3\n4\n3\n\nSample Output 1\n\n3\n\nSample Input 2\n\n3\n4\n3\n2\n\nSample Output 2\n\n-1", "sample_input": "6\n5\n3\n1\n3\n4\n3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02258", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMaximum Profit\n\nYou can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.\n\nWrite a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .\n\nInput\n\nThe first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t = 0, 1, 2, ... n-1$) are given in order.\n\nOutput\n\nPrint the maximum value in a line.\n\nConstraints\n\n$2 \\leq n \\leq 200,000$\n\n$1 \\leq R_t \\leq 10^9$\n\nSample Input 1\n\n6\n5\n3\n1\n3\n4\n3\n\nSample Output 1\n\n3\n\nSample Input 2\n\n3\n4\n3\n2\n\nSample Output 2\n\n-1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 770, "memory_kb": 204532}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s137635809", "group_id": "codeNet:p02259", "input_text": "import scala.io.StdIn\n\nobject Main {\n\n def bubbleSort(A: Array[Int]){\n def swap(i: Int, j: Int) {\n val t = A(i); A(i) = A(j); A(j) = t\n ()\n }\n\n var count = 0\n for(i <- 0 to A.length - 1){\n for(j <- A.length - 1 to i + 1 by -1){\n if(A(j) < A(j-1)){\n swap(j,j-1)\n count += 1\n }\n }\n }\n\n println(A.mkString(\" \"))\n println(count)\n }\n\n def main(args: Array[String]){\n val N = StdIn.readInt()\n val input = StdIn.readLine().split(\" \").map(_.toInt)\n bubbleSort(input)\n }\n}", "language": "Scala", "metadata": {"date": 1445075926, "filename_ext": "scala", "original_language": "Scala", "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/Scala/s137635809.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s137635809", "user_id": "u274875240"}, "prompt_components": {"gold_output": "1 2 3 4 5\n8\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main {\n\n def bubbleSort(A: Array[Int]){\n def swap(i: Int, j: Int) {\n val t = A(i); A(i) = A(j); A(j) = t\n ()\n }\n\n var count = 0\n for(i <- 0 to A.length - 1){\n for(j <- A.length - 1 to i + 1 by -1){\n if(A(j) < A(j-1)){\n swap(j,j-1)\n count += 1\n }\n }\n }\n\n println(A.mkString(\" \"))\n println(count)\n }\n\n def main(args: Array[String]){\n val N = StdIn.readInt()\n val input = StdIn.readLine().split(\" \").map(_.toInt)\n bubbleSort(input)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 549, "cpu_time_ms": 280, "memory_kb": 43932}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s165700611", "group_id": "codeNet:p02259", "input_text": "import scala.io.StdIn\n\nobject Main{\n def main(args: Array[String]){\n StdIn.readLine()\n val line = StdIn.readLine().split(\" \").toList.map(_.toInt)\n\n bSort(List(), line, 0)\n }\n\n def bSort(sorted: List[Int], unsorted: List[Int], n: Int){\n if(unsorted.length == 0) println(n)\n else bSort(sorted :+ unsorted.min, unsorted.filterNot(_ == unsorted.min), n+1)\n }\n}", "language": "Scala", "metadata": {"date": 1461773208, "filename_ext": "scala", "original_language": "Scala", "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/Scala/s165700611.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s165700611", "user_id": "u085441951"}, "prompt_components": {"gold_output": "1 2 3 4 5\n8\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main{\n def main(args: Array[String]){\n StdIn.readLine()\n val line = StdIn.readLine().split(\" \").toList.map(_.toInt)\n\n bSort(List(), line, 0)\n }\n\n def bSort(sorted: List[Int], unsorted: List[Int], n: Int){\n if(unsorted.length == 0) println(n)\n else bSort(sorted :+ unsorted.min, unsorted.filterNot(_ == unsorted.min), n+1)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 210, "memory_kb": 43092}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s069603759", "group_id": "codeNet:p02260", "input_text": "import scala.io.StdIn\nimport scala.annotation.tailrec\nimport scala.collection.mutable.ListBuffer\n\nobject Main{\n def main(args: Array[String]){\n StdIn.readLine()\n val line = StdIn.readLine().split(\" \").toList.map(_.toInt)\n\n println(line.sorted.mkString(\" \"))\n println(sSort(List(), line, 0))\n }\n\n @tailrec\n def sSort(sorted: List[Int], unsorted: List[Int], n: Int): Int={\n if(unsorted.length == 0) n\n else if(unsorted.sorted == unsorted) n\n else {\n val pos = unsorted.indexWhere(_ == unsorted.min)\n val swapped = unsorted.updated(0, unsorted(pos)).updated(pos, unsorted(0))\n\n sSort(sorted :+ unsorted.min, deleteOne(swapped, 0), n+1)\n }\n }\n\n def deleteOne(list: List[Int], index: Int): List[Int] = {\n val buf = ListBuffer(list: _*)\n buf.remove(index)\n buf.toList\n }\n}", "language": "Scala", "metadata": {"date": 1461948945, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02260.html", "problem_id": "p02260", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02260/input.txt", "sample_output_relpath": "derived/input_output/data/p02260/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02260/Scala/s069603759.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s069603759", "user_id": "u085441951"}, "prompt_components": {"gold_output": "1 2 3 4 5 6\n4\n", "input_to_evaluate": "import scala.io.StdIn\nimport scala.annotation.tailrec\nimport scala.collection.mutable.ListBuffer\n\nobject Main{\n def main(args: Array[String]){\n StdIn.readLine()\n val line = StdIn.readLine().split(\" \").toList.map(_.toInt)\n\n println(line.sorted.mkString(\" \"))\n println(sSort(List(), line, 0))\n }\n\n @tailrec\n def sSort(sorted: List[Int], unsorted: List[Int], n: Int): Int={\n if(unsorted.length == 0) n\n else if(unsorted.sorted == unsorted) n\n else {\n val pos = unsorted.indexWhere(_ == unsorted.min)\n val swapped = unsorted.updated(0, unsorted(pos)).updated(pos, unsorted(0))\n\n sSort(sorted :+ unsorted.min, deleteOne(swapped, 0), n+1)\n }\n }\n\n def deleteOne(list: List[Int], index: Int): List[Int] = {\n val buf = ListBuffer(list: _*)\n buf.remove(index)\n buf.toList\n }\n}", "problem_context": "Selection Sort\n\nWrite a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\nSelectionSort(A)\n1 for i = 0 to A.length-1\n2 mini = i\n3 for j = i to A.length-1\n4 if A[j] < A[mini]\n5 mini = j\n6 swap A[i] and A[mini]\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 6 of the pseudocode in the case where i ≠ mini.\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 space 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\n6\n5 6 4 2 1 3\n\nSample Output 1\n\n1 2 3 4 5 6\n4\n\nSample Input 2\n\n6\n5 2 4 6 1 3\n\nSample Output 2\n\n1 2 3 4 5 6\n3", "sample_input": "6\n5 6 4 2 1 3\n"}, "reference_outputs": ["1 2 3 4 5 6\n4\n"], "source_document_id": "p02260", "source_text": "Selection Sort\n\nWrite a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\nSelectionSort(A)\n1 for i = 0 to A.length-1\n2 mini = i\n3 for j = i to A.length-1\n4 if A[j] < A[mini]\n5 mini = j\n6 swap A[i] and A[mini]\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 6 of the pseudocode in the case where i ≠ mini.\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 space 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\n6\n5 6 4 2 1 3\n\nSample Output 1\n\n1 2 3 4 5 6\n4\n\nSample Input 2\n\n6\n5 2 4 6 1 3\n\nSample Output 2\n\n1 2 3 4 5 6\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 270, "memory_kb": 43900}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s076841881", "group_id": "codeNet:p02260", "input_text": "import scala.io.StdIn\nimport scala.annotation.tailrec\nimport scala.collection.mutable.ListBuffer\n\nobject Main{\n def main(args: Array[String]){\n StdIn.readLine()\n val line = StdIn.readLine().split(\" \").toList.map(_.toInt)\n\n println(line.sorted.mkString(\" \"))\n println(sSort(List(), line, 0))\n }\n\n @tailrec\n def sSort(sorted: List[Int], unsorted: List[Int], n: Int): Int={\n if(unsorted.length == 0) n\n else if(unsorted.sorted == unsorted) n\n else {\n val pos = unsorted.indexWhere(_ == unsorted.min)\n val swapped = unsorted.updated(0, unsorted(pos)).updated(pos, unsorted.head)\n\n if(pos == 0) sSort(sorted :+ unsorted.min, unsorted.updated(0, unsorted(pos)).updated(pos, unsorted.head).tail, n)\n else sSort(sorted :+ unsorted.min, unsorted.updated(0, unsorted(pos)).updated(pos, unsorted.head).tail, n+1)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1461952886, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02260.html", "problem_id": "p02260", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02260/input.txt", "sample_output_relpath": "derived/input_output/data/p02260/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02260/Scala/s076841881.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s076841881", "user_id": "u085441951"}, "prompt_components": {"gold_output": "1 2 3 4 5 6\n4\n", "input_to_evaluate": "import scala.io.StdIn\nimport scala.annotation.tailrec\nimport scala.collection.mutable.ListBuffer\n\nobject Main{\n def main(args: Array[String]){\n StdIn.readLine()\n val line = StdIn.readLine().split(\" \").toList.map(_.toInt)\n\n println(line.sorted.mkString(\" \"))\n println(sSort(List(), line, 0))\n }\n\n @tailrec\n def sSort(sorted: List[Int], unsorted: List[Int], n: Int): Int={\n if(unsorted.length == 0) n\n else if(unsorted.sorted == unsorted) n\n else {\n val pos = unsorted.indexWhere(_ == unsorted.min)\n val swapped = unsorted.updated(0, unsorted(pos)).updated(pos, unsorted.head)\n\n if(pos == 0) sSort(sorted :+ unsorted.min, unsorted.updated(0, unsorted(pos)).updated(pos, unsorted.head).tail, n)\n else sSort(sorted :+ unsorted.min, unsorted.updated(0, unsorted(pos)).updated(pos, unsorted.head).tail, n+1)\n }\n }\n}", "problem_context": "Selection Sort\n\nWrite a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\nSelectionSort(A)\n1 for i = 0 to A.length-1\n2 mini = i\n3 for j = i to A.length-1\n4 if A[j] < A[mini]\n5 mini = j\n6 swap A[i] and A[mini]\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 6 of the pseudocode in the case where i ≠ mini.\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 space 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\n6\n5 6 4 2 1 3\n\nSample Output 1\n\n1 2 3 4 5 6\n4\n\nSample Input 2\n\n6\n5 2 4 6 1 3\n\nSample Output 2\n\n1 2 3 4 5 6\n3", "sample_input": "6\n5 6 4 2 1 3\n"}, "reference_outputs": ["1 2 3 4 5 6\n4\n"], "source_document_id": "p02260", "source_text": "Selection Sort\n\nWrite a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\nSelectionSort(A)\n1 for i = 0 to A.length-1\n2 mini = i\n3 for j = i to A.length-1\n4 if A[j] < A[mini]\n5 mini = j\n6 swap A[i] and A[mini]\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 6 of the pseudocode in the case where i ≠ mini.\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 space 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\n6\n5 6 4 2 1 3\n\nSample Output 1\n\n1 2 3 4 5 6\n4\n\nSample Input 2\n\n6\n5 2 4 6 1 3\n\nSample Output 2\n\n1 2 3 4 5 6\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 310, "memory_kb": 45816}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s673618514", "group_id": "codeNet:p02260", "input_text": "object Main{\n def main(args: Array[String]){\n val in = new java.util.Scanner(System.in)\n val a = in.nextInt\n var count = 0;\n \n var arr = new Array[Int](a)\n for(i <- 0 to a-1){\n arr(i) = in.nextInt\n }\n \n for(i <- 0 to a-2){\n var minpos = i;\n var minval = arr(i);\n \n for(j <- i+1 to a-1){\n if(arr(j) < minval){\n minpos = j;\n minval = arr(j)\n }\n }\n \n if(minpos != i){\n var tmp = arr(minpos)\n arr(minpos) = arr(i)\n arr(i) = tmp\n count = count + 1\n }\n }\n \n println(arr.mkString(\" \"))\n println(count)\n }\n}", "language": "Scala", "metadata": {"date": 1465185614, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02260.html", "problem_id": "p02260", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02260/input.txt", "sample_output_relpath": "derived/input_output/data/p02260/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02260/Scala/s673618514.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s673618514", "user_id": "u778333573"}, "prompt_components": {"gold_output": "1 2 3 4 5 6\n4\n", "input_to_evaluate": "object Main{\n def main(args: Array[String]){\n val in = new java.util.Scanner(System.in)\n val a = in.nextInt\n var count = 0;\n \n var arr = new Array[Int](a)\n for(i <- 0 to a-1){\n arr(i) = in.nextInt\n }\n \n for(i <- 0 to a-2){\n var minpos = i;\n var minval = arr(i);\n \n for(j <- i+1 to a-1){\n if(arr(j) < minval){\n minpos = j;\n minval = arr(j)\n }\n }\n \n if(minpos != i){\n var tmp = arr(minpos)\n arr(minpos) = arr(i)\n arr(i) = tmp\n count = count + 1\n }\n }\n \n println(arr.mkString(\" \"))\n println(count)\n }\n}", "problem_context": "Selection Sort\n\nWrite a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\nSelectionSort(A)\n1 for i = 0 to A.length-1\n2 mini = i\n3 for j = i to A.length-1\n4 if A[j] < A[mini]\n5 mini = j\n6 swap A[i] and A[mini]\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 6 of the pseudocode in the case where i ≠ mini.\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 space 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\n6\n5 6 4 2 1 3\n\nSample Output 1\n\n1 2 3 4 5 6\n4\n\nSample Input 2\n\n6\n5 2 4 6 1 3\n\nSample Output 2\n\n1 2 3 4 5 6\n3", "sample_input": "6\n5 6 4 2 1 3\n"}, "reference_outputs": ["1 2 3 4 5 6\n4\n"], "source_document_id": "p02260", "source_text": "Selection Sort\n\nWrite a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\nSelectionSort(A)\n1 for i = 0 to A.length-1\n2 mini = i\n3 for j = i to A.length-1\n4 if A[j] < A[mini]\n5 mini = j\n6 swap A[i] and A[mini]\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 6 of the pseudocode in the case where i ≠ mini.\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 space 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\n6\n5 6 4 2 1 3\n\nSample Output 1\n\n1 2 3 4 5 6\n4\n\nSample Input 2\n\n6\n5 2 4 6 1 3\n\nSample Output 2\n\n1 2 3 4 5 6\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 626, "cpu_time_ms": 300, "memory_kb": 45188}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s454577112", "group_id": "codeNet:p02260", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val n = io.StdIn.readInt()\n val a = io.StdIn.readLine().split(\" \").map(_.toInt)\n val count = selectionSort(a, n)\n println(a.mkString(\" \"))\n println(count)\n }\n\n def selectionSort(a: Array[Int], n: Int): Int = {\n (0 until n).count { i =>\n val minIdx = (i until n).foldLeft(i) { case (z, j) =>\n if (a(j) < a(z)) j\n else z\n }\n if (i != minIdx) {\n val v = a(i)\n a(i) = a(minIdx)\n a(minIdx) = v\n true\n } else {\n false\n }\n }\n }\n}", "language": "Scala", "metadata": {"date": 1491385422, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02260.html", "problem_id": "p02260", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02260/input.txt", "sample_output_relpath": "derived/input_output/data/p02260/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02260/Scala/s454577112.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s454577112", "user_id": "u959441351"}, "prompt_components": {"gold_output": "1 2 3 4 5 6\n4\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val n = io.StdIn.readInt()\n val a = io.StdIn.readLine().split(\" \").map(_.toInt)\n val count = selectionSort(a, n)\n println(a.mkString(\" \"))\n println(count)\n }\n\n def selectionSort(a: Array[Int], n: Int): Int = {\n (0 until n).count { i =>\n val minIdx = (i until n).foldLeft(i) { case (z, j) =>\n if (a(j) < a(z)) j\n else z\n }\n if (i != minIdx) {\n val v = a(i)\n a(i) = a(minIdx)\n a(minIdx) = v\n true\n } else {\n false\n }\n }\n }\n}", "problem_context": "Selection Sort\n\nWrite a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\nSelectionSort(A)\n1 for i = 0 to A.length-1\n2 mini = i\n3 for j = i to A.length-1\n4 if A[j] < A[mini]\n5 mini = j\n6 swap A[i] and A[mini]\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 6 of the pseudocode in the case where i ≠ mini.\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 space 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\n6\n5 6 4 2 1 3\n\nSample Output 1\n\n1 2 3 4 5 6\n4\n\nSample Input 2\n\n6\n5 2 4 6 1 3\n\nSample Output 2\n\n1 2 3 4 5 6\n3", "sample_input": "6\n5 6 4 2 1 3\n"}, "reference_outputs": ["1 2 3 4 5 6\n4\n"], "source_document_id": "p02260", "source_text": "Selection Sort\n\nWrite a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\nSelectionSort(A)\n1 for i = 0 to A.length-1\n2 mini = i\n3 for j = i to A.length-1\n4 if A[j] < A[mini]\n5 mini = j\n6 swap A[i] and A[mini]\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 6 of the pseudocode in the case where i ≠ mini.\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 space 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\n6\n5 6 4 2 1 3\n\nSample Output 1\n\n1 2 3 4 5 6\n4\n\nSample Input 2\n\n6\n5 2 4 6 1 3\n\nSample Output 2\n\n1 2 3 4 5 6\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 44100}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s024898685", "group_id": "codeNet:p02260", "input_text": "import scala.io.StdIn\n\nobject Main {\n def main(args: Array[String]) = {\n val n = StdIn.readInt\n val array = StdIn.readLine.split(\" \").map(_.toInt)\n val t = selectionSort(n, array)\n println(t._1.mkString(\" \"))\n println(t._2)\n }\n\n def selectionSort(n: Int, array: Array[Int]) = {\n var count = 0\n for (i <- 0 to n - 1) {\n var min = i\n for (k <- i to n - 1) {\n if (array(min) > array(k)) {\n min = k\n }\n }\n if (array(min) != array(i)) {\n val tmp = array(i)\n array(i) = array(min)\n array(min) = tmp\n count = count + 1\n }\n }\n (array, count)\n }\n}\n", "language": "Scala", "metadata": {"date": 1571047592, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02260.html", "problem_id": "p02260", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02260/input.txt", "sample_output_relpath": "derived/input_output/data/p02260/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02260/Scala/s024898685.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s024898685", "user_id": "u687450887"}, "prompt_components": {"gold_output": "1 2 3 4 5 6\n4\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main {\n def main(args: Array[String]) = {\n val n = StdIn.readInt\n val array = StdIn.readLine.split(\" \").map(_.toInt)\n val t = selectionSort(n, array)\n println(t._1.mkString(\" \"))\n println(t._2)\n }\n\n def selectionSort(n: Int, array: Array[Int]) = {\n var count = 0\n for (i <- 0 to n - 1) {\n var min = i\n for (k <- i to n - 1) {\n if (array(min) > array(k)) {\n min = k\n }\n }\n if (array(min) != array(i)) {\n val tmp = array(i)\n array(i) = array(min)\n array(min) = tmp\n count = count + 1\n }\n }\n (array, count)\n }\n}\n", "problem_context": "Selection Sort\n\nWrite a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\nSelectionSort(A)\n1 for i = 0 to A.length-1\n2 mini = i\n3 for j = i to A.length-1\n4 if A[j] < A[mini]\n5 mini = j\n6 swap A[i] and A[mini]\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 6 of the pseudocode in the case where i ≠ mini.\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 space 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\n6\n5 6 4 2 1 3\n\nSample Output 1\n\n1 2 3 4 5 6\n4\n\nSample Input 2\n\n6\n5 2 4 6 1 3\n\nSample Output 2\n\n1 2 3 4 5 6\n3", "sample_input": "6\n5 6 4 2 1 3\n"}, "reference_outputs": ["1 2 3 4 5 6\n4\n"], "source_document_id": "p02260", "source_text": "Selection Sort\n\nWrite a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\nSelectionSort(A)\n1 for i = 0 to A.length-1\n2 mini = i\n3 for j = i to A.length-1\n4 if A[j] < A[mini]\n5 mini = j\n6 swap A[i] and A[mini]\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 6 of the pseudocode in the case where i ≠ mini.\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 space 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\n6\n5 6 4 2 1 3\n\nSample Output 1\n\n1 2 3 4 5 6\n4\n\nSample Input 2\n\n6\n5 2 4 6 1 3\n\nSample Output 2\n\n1 2 3 4 5 6\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 646, "cpu_time_ms": 300, "memory_kb": 44024}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s429989515", "group_id": "codeNet:p02261", "input_text": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]) {\n val sc = new Scanner(System.in)\n val N = sc.nextInt()\n val arr: Array[String] = Array.fill(N)(sc.next())\n val arrBubble: Array[String] = arr.clone()\n val arrSelect: Array[String] = arr.clone()\n\n println(bubbleSort(arrBubble))\n checkStable(arr, arrBubble)\n println(selectionSort(arrSelect))\n checkStable(arr, arrSelect)\n }\n\n def bubbleSort(arr: Array[String]): String = {\n for(i <- 0 until arr.length) {\n for(j <- arr.length-1 until i by -1) {\n if(arr(j).last.toInt < arr(j-1).last.toInt) {\n val t = arr(j); arr(j) = arr(j-1); arr(j-1) = t // swap\n }\n }\n }\n return arr.mkString(\" \")\n }\n\n def selectionSort(arr: Array[String]): String = {\n for((x, i) <- arr.zipWithIndex) {\n var minj = i\n for(j <- i until arr.length) {\n if(arr(minj).last.toInt > arr(j).last.toInt) minj = j\n }\n val t = arr(i); arr(i) = arr(minj); arr(minj) = t\n }\n return arr.mkString(\" \")\n }\n\n def checkStable(arrOrigin: Array[String], arrSorted: Array[String]): Unit = {\n for((a, i) <- arrOrigin.zipWithIndex) {\n for((b, j) <- arrOrigin.zipWithIndex if i != j && a.last.toInt == b.last.toInt) {\n for((c, k) <- arrSorted.zipWithIndex if a == c) {\n for((d, l) <- arrSorted.zipWithIndex if b == d) {\n if((i - j) * (k - l) < 0) {\n println(\"Not stable\")\n return\n }\n }\n }\n }\n }\n println(\"Stable\")\n }\n}", "language": "Scala", "metadata": {"date": 1460626046, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02261.html", "problem_id": "p02261", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02261/input.txt", "sample_output_relpath": "derived/input_output/data/p02261/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02261/Scala/s429989515.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s429989515", "user_id": "u763534154"}, "prompt_components": {"gold_output": "D2 C3 H4 S4 C9\nStable\nD2 C3 S4 H4 C9\nNot stable\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]) {\n val sc = new Scanner(System.in)\n val N = sc.nextInt()\n val arr: Array[String] = Array.fill(N)(sc.next())\n val arrBubble: Array[String] = arr.clone()\n val arrSelect: Array[String] = arr.clone()\n\n println(bubbleSort(arrBubble))\n checkStable(arr, arrBubble)\n println(selectionSort(arrSelect))\n checkStable(arr, arrSelect)\n }\n\n def bubbleSort(arr: Array[String]): String = {\n for(i <- 0 until arr.length) {\n for(j <- arr.length-1 until i by -1) {\n if(arr(j).last.toInt < arr(j-1).last.toInt) {\n val t = arr(j); arr(j) = arr(j-1); arr(j-1) = t // swap\n }\n }\n }\n return arr.mkString(\" \")\n }\n\n def selectionSort(arr: Array[String]): String = {\n for((x, i) <- arr.zipWithIndex) {\n var minj = i\n for(j <- i until arr.length) {\n if(arr(minj).last.toInt > arr(j).last.toInt) minj = j\n }\n val t = arr(i); arr(i) = arr(minj); arr(minj) = t\n }\n return arr.mkString(\" \")\n }\n\n def checkStable(arrOrigin: Array[String], arrSorted: Array[String]): Unit = {\n for((a, i) <- arrOrigin.zipWithIndex) {\n for((b, j) <- arrOrigin.zipWithIndex if i != j && a.last.toInt == b.last.toInt) {\n for((c, k) <- arrSorted.zipWithIndex if a == c) {\n for((d, l) <- arrSorted.zipWithIndex if b == d) {\n if((i - j) * (k - l) < 0) {\n println(\"Not stable\")\n return\n }\n }\n }\n }\n }\n println(\"Stable\")\n }\n}", "problem_context": "Stable Sort\n\nLet's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1.\n\nYour task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode:\n\nBubbleSort(C)\n1 for i = 0 to C.length-1\n2 for j = C.length-1 downto i+1\n3 if C[j].value < C[j-1].value\n4 swap C[j] and C[j-1]\n\nSelectionSort(C)\n1 for i = 0 to C.length-1\n2 mini = i\n3 for j = i to C.length-1\n4 if C[j].value < C[mini].value\n5 mini = j\n6 swap C[i] and C[mini]\n\nNote that, indices for array elements are based on 0-origin.\n\nFor each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).\n\nInput\n\nThe first line contains an integer N, the number of cards.\n\nN cards are given in the following line. Each card is represented by two characters. Two consecutive cards are separated by a space character.\n\nOutput\n\nIn the first line, print the arranged cards provided by the Bubble Sort algorithm. Two consecutive cards should be separated by a space character.\n\nIn the second line, print the stability (\"Stable\" or \"Not stable\") of this output.\n\nIn the third line, print the arranged cards provided by the Selection Sort algorithm. Two consecutive cards should be separated by a space character.\n\nIn the fourth line, print the stability (\"Stable\" or \"Not stable\") of this output.\n\nConstraints\n\n1 ≤ N ≤ 36\n\nSample Input 1\n\n5\nH4 C9 S4 D2 C3\n\nSample Output 1\n\nD2 C3 H4 S4 C9\nStable\nD2 C3 S4 H4 C9\nNot stable\n\nSample Input 2\n\n2\nS1 H1\n\nSample Output 2\n\nS1 H1\nStable\nS1 H1\nStable", "sample_input": "5\nH4 C9 S4 D2 C3\n"}, "reference_outputs": ["D2 C3 H4 S4 C9\nStable\nD2 C3 S4 H4 C9\nNot stable\n"], "source_document_id": "p02261", "source_text": "Stable Sort\n\nLet's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1.\n\nYour task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode:\n\nBubbleSort(C)\n1 for i = 0 to C.length-1\n2 for j = C.length-1 downto i+1\n3 if C[j].value < C[j-1].value\n4 swap C[j] and C[j-1]\n\nSelectionSort(C)\n1 for i = 0 to C.length-1\n2 mini = i\n3 for j = i to C.length-1\n4 if C[j].value < C[mini].value\n5 mini = j\n6 swap C[i] and C[mini]\n\nNote that, indices for array elements are based on 0-origin.\n\nFor each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).\n\nInput\n\nThe first line contains an integer N, the number of cards.\n\nN cards are given in the following line. Each card is represented by two characters. Two consecutive cards are separated by a space character.\n\nOutput\n\nIn the first line, print the arranged cards provided by the Bubble Sort algorithm. Two consecutive cards should be separated by a space character.\n\nIn the second line, print the stability (\"Stable\" or \"Not stable\") of this output.\n\nIn the third line, print the arranged cards provided by the Selection Sort algorithm. Two consecutive cards should be separated by a space character.\n\nIn the fourth line, print the stability (\"Stable\" or \"Not stable\") of this output.\n\nConstraints\n\n1 ≤ N ≤ 36\n\nSample Input 1\n\n5\nH4 C9 S4 D2 C3\n\nSample Output 1\n\nD2 C3 H4 S4 C9\nStable\nD2 C3 S4 H4 C9\nNot stable\n\nSample Input 2\n\n2\nS1 H1\n\nSample Output 2\n\nS1 H1\nStable\nS1 H1\nStable", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1550, "cpu_time_ms": 290, "memory_kb": 45940}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s044572499", "group_id": "codeNet:p02261", "input_text": "import scala.io.StdIn\nobject Main extends App {\n\n val rn = StdIn.readLine().trim.toInt\n case class Card(suit: Char, num: Int){\n override def toString: String = s\"$suit$num\"\n }\n val ra = StdIn.readLine().trim.split(' ').map{ p =>\n Card(p.charAt(0), p.charAt(1).toString.toInt)\n }\n val ra1 = ra.clone()\n val ra2 = ra.clone()\n \n def isStable(a: Array[Card], after: Array[Card], n: Int): Boolean = {\n (0 until n).foreach{ i =>\n if(a(i).suit != after(i).suit) return false\n }\n true\n }\n \n def bubbleSort(a: Array[Card], n: Int): Array[Card] = {\n (0 until n).foreach{ i =>\n // println(s\"bubble($i):\" + a.toList)\n (n-1 until i by -1).foreach{ j =>\n if(a(j).num < a(j-1).num){\n val temp = a(j)\n a(j) = a(j-1)\n a(j-1) = temp\n }\n }\n }\n a\n }\n\n def selectionSort(a: Array[Card], n: Int): Array[Card] = {\n (0 until n).foreach{ i =>\n // println(s\"selection($i):\" + a.toList)\n\n var minj = i\n (i until n).foreach{ j =>\n minj = if(a(j).num < a(minj).num) j else minj\n }\n val temp = a(minj)\n a(minj) = a(i)\n a(i) = temp\n }\n a\n }\n \n val rbubble = bubbleSort(ra1, rn)\n val rselection = selectionSort(ra2, rn)\n\n //println(\"ra:\" + ra.toList.mkString(\" \"))\n println(rbubble.toList.mkString(\" \"))\n println(\"Stable\")\n\n println(rselection.toList.mkString(\" \"))\n println(if(isStable(rbubble, rselection, rn)) \"Stable\" else \"Not stable\")\n\n}\n\n", "language": "Scala", "metadata": {"date": 1521937655, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02261.html", "problem_id": "p02261", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02261/input.txt", "sample_output_relpath": "derived/input_output/data/p02261/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02261/Scala/s044572499.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s044572499", "user_id": "u342234782"}, "prompt_components": {"gold_output": "D2 C3 H4 S4 C9\nStable\nD2 C3 S4 H4 C9\nNot stable\n", "input_to_evaluate": "import scala.io.StdIn\nobject Main extends App {\n\n val rn = StdIn.readLine().trim.toInt\n case class Card(suit: Char, num: Int){\n override def toString: String = s\"$suit$num\"\n }\n val ra = StdIn.readLine().trim.split(' ').map{ p =>\n Card(p.charAt(0), p.charAt(1).toString.toInt)\n }\n val ra1 = ra.clone()\n val ra2 = ra.clone()\n \n def isStable(a: Array[Card], after: Array[Card], n: Int): Boolean = {\n (0 until n).foreach{ i =>\n if(a(i).suit != after(i).suit) return false\n }\n true\n }\n \n def bubbleSort(a: Array[Card], n: Int): Array[Card] = {\n (0 until n).foreach{ i =>\n // println(s\"bubble($i):\" + a.toList)\n (n-1 until i by -1).foreach{ j =>\n if(a(j).num < a(j-1).num){\n val temp = a(j)\n a(j) = a(j-1)\n a(j-1) = temp\n }\n }\n }\n a\n }\n\n def selectionSort(a: Array[Card], n: Int): Array[Card] = {\n (0 until n).foreach{ i =>\n // println(s\"selection($i):\" + a.toList)\n\n var minj = i\n (i until n).foreach{ j =>\n minj = if(a(j).num < a(minj).num) j else minj\n }\n val temp = a(minj)\n a(minj) = a(i)\n a(i) = temp\n }\n a\n }\n \n val rbubble = bubbleSort(ra1, rn)\n val rselection = selectionSort(ra2, rn)\n\n //println(\"ra:\" + ra.toList.mkString(\" \"))\n println(rbubble.toList.mkString(\" \"))\n println(\"Stable\")\n\n println(rselection.toList.mkString(\" \"))\n println(if(isStable(rbubble, rselection, rn)) \"Stable\" else \"Not stable\")\n\n}\n\n", "problem_context": "Stable Sort\n\nLet's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1.\n\nYour task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode:\n\nBubbleSort(C)\n1 for i = 0 to C.length-1\n2 for j = C.length-1 downto i+1\n3 if C[j].value < C[j-1].value\n4 swap C[j] and C[j-1]\n\nSelectionSort(C)\n1 for i = 0 to C.length-1\n2 mini = i\n3 for j = i to C.length-1\n4 if C[j].value < C[mini].value\n5 mini = j\n6 swap C[i] and C[mini]\n\nNote that, indices for array elements are based on 0-origin.\n\nFor each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).\n\nInput\n\nThe first line contains an integer N, the number of cards.\n\nN cards are given in the following line. Each card is represented by two characters. Two consecutive cards are separated by a space character.\n\nOutput\n\nIn the first line, print the arranged cards provided by the Bubble Sort algorithm. Two consecutive cards should be separated by a space character.\n\nIn the second line, print the stability (\"Stable\" or \"Not stable\") of this output.\n\nIn the third line, print the arranged cards provided by the Selection Sort algorithm. Two consecutive cards should be separated by a space character.\n\nIn the fourth line, print the stability (\"Stable\" or \"Not stable\") of this output.\n\nConstraints\n\n1 ≤ N ≤ 36\n\nSample Input 1\n\n5\nH4 C9 S4 D2 C3\n\nSample Output 1\n\nD2 C3 H4 S4 C9\nStable\nD2 C3 S4 H4 C9\nNot stable\n\nSample Input 2\n\n2\nS1 H1\n\nSample Output 2\n\nS1 H1\nStable\nS1 H1\nStable", "sample_input": "5\nH4 C9 S4 D2 C3\n"}, "reference_outputs": ["D2 C3 H4 S4 C9\nStable\nD2 C3 S4 H4 C9\nNot stable\n"], "source_document_id": "p02261", "source_text": "Stable Sort\n\nLet's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1.\n\nYour task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode:\n\nBubbleSort(C)\n1 for i = 0 to C.length-1\n2 for j = C.length-1 downto i+1\n3 if C[j].value < C[j-1].value\n4 swap C[j] and C[j-1]\n\nSelectionSort(C)\n1 for i = 0 to C.length-1\n2 mini = i\n3 for j = i to C.length-1\n4 if C[j].value < C[mini].value\n5 mini = j\n6 swap C[i] and C[mini]\n\nNote that, indices for array elements are based on 0-origin.\n\nFor each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).\n\nInput\n\nThe first line contains an integer N, the number of cards.\n\nN cards are given in the following line. Each card is represented by two characters. Two consecutive cards are separated by a space character.\n\nOutput\n\nIn the first line, print the arranged cards provided by the Bubble Sort algorithm. Two consecutive cards should be separated by a space character.\n\nIn the second line, print the stability (\"Stable\" or \"Not stable\") of this output.\n\nIn the third line, print the arranged cards provided by the Selection Sort algorithm. Two consecutive cards should be separated by a space character.\n\nIn the fourth line, print the stability (\"Stable\" or \"Not stable\") of this output.\n\nConstraints\n\n1 ≤ N ≤ 36\n\nSample Input 1\n\n5\nH4 C9 S4 D2 C3\n\nSample Output 1\n\nD2 C3 H4 S4 C9\nStable\nD2 C3 S4 H4 C9\nNot stable\n\nSample Input 2\n\n2\nS1 H1\n\nSample Output 2\n\nS1 H1\nStable\nS1 H1\nStable", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 44060}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s884788888", "group_id": "codeNet:p02261", "input_text": "import scala.io.StdIn._\n\nobject Main extends App {\n\n def isLeftSmall(c1: String, c2: String): Boolean = {\n if (c1.takeRight(1).toInt < c2.takeRight(1).toInt) true else false\n }\n \n def bubbleSort(c: Array[String], n: Int) {\n for(i <- (0 to n - 1)) {\n for (j <- (n - 1 until i by -1)) {\n if (isLeftSmall(c(j), c(j - 1))) {\n val tmp_v = c(j)\n c(j) = c(j - 1)\n c(j - 1) = tmp_v\n }\n }\n }\n println(c.mkString(\" \"))\n println(\"Stable\")\n }\n\n def selectionSort(c: Array[String], n: Int) {\n for (i <- (0 to n - 1)) {\n var min_j = i\n for (j <- (i to n - 1)) {\n if (isLeftSmall(c(j), c(min_j))) {\n min_j = j\n }\n }\n val tmp_v = c(i)\n c(i) = c(min_j)\n c(min_j) = tmp_v\n }\n println(c.mkString(\" \"))\n }\n \n val n = readLine.toInt\n val c = readLine.split(\" \").toArray\n val c1 = c.clone\n val c2 = c.clone\n bubbleSort(c1, n)\n selectionSort(c2, n)\n if (c1 sameElements c2) println(\"Stable\") else println(\"Not stable\")\n}\n", "language": "Scala", "metadata": {"date": 1554179313, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02261.html", "problem_id": "p02261", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02261/input.txt", "sample_output_relpath": "derived/input_output/data/p02261/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02261/Scala/s884788888.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s884788888", "user_id": "u071810536"}, "prompt_components": {"gold_output": "D2 C3 H4 S4 C9\nStable\nD2 C3 S4 H4 C9\nNot stable\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main extends App {\n\n def isLeftSmall(c1: String, c2: String): Boolean = {\n if (c1.takeRight(1).toInt < c2.takeRight(1).toInt) true else false\n }\n \n def bubbleSort(c: Array[String], n: Int) {\n for(i <- (0 to n - 1)) {\n for (j <- (n - 1 until i by -1)) {\n if (isLeftSmall(c(j), c(j - 1))) {\n val tmp_v = c(j)\n c(j) = c(j - 1)\n c(j - 1) = tmp_v\n }\n }\n }\n println(c.mkString(\" \"))\n println(\"Stable\")\n }\n\n def selectionSort(c: Array[String], n: Int) {\n for (i <- (0 to n - 1)) {\n var min_j = i\n for (j <- (i to n - 1)) {\n if (isLeftSmall(c(j), c(min_j))) {\n min_j = j\n }\n }\n val tmp_v = c(i)\n c(i) = c(min_j)\n c(min_j) = tmp_v\n }\n println(c.mkString(\" \"))\n }\n \n val n = readLine.toInt\n val c = readLine.split(\" \").toArray\n val c1 = c.clone\n val c2 = c.clone\n bubbleSort(c1, n)\n selectionSort(c2, n)\n if (c1 sameElements c2) println(\"Stable\") else println(\"Not stable\")\n}\n", "problem_context": "Stable Sort\n\nLet's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1.\n\nYour task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode:\n\nBubbleSort(C)\n1 for i = 0 to C.length-1\n2 for j = C.length-1 downto i+1\n3 if C[j].value < C[j-1].value\n4 swap C[j] and C[j-1]\n\nSelectionSort(C)\n1 for i = 0 to C.length-1\n2 mini = i\n3 for j = i to C.length-1\n4 if C[j].value < C[mini].value\n5 mini = j\n6 swap C[i] and C[mini]\n\nNote that, indices for array elements are based on 0-origin.\n\nFor each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).\n\nInput\n\nThe first line contains an integer N, the number of cards.\n\nN cards are given in the following line. Each card is represented by two characters. Two consecutive cards are separated by a space character.\n\nOutput\n\nIn the first line, print the arranged cards provided by the Bubble Sort algorithm. Two consecutive cards should be separated by a space character.\n\nIn the second line, print the stability (\"Stable\" or \"Not stable\") of this output.\n\nIn the third line, print the arranged cards provided by the Selection Sort algorithm. Two consecutive cards should be separated by a space character.\n\nIn the fourth line, print the stability (\"Stable\" or \"Not stable\") of this output.\n\nConstraints\n\n1 ≤ N ≤ 36\n\nSample Input 1\n\n5\nH4 C9 S4 D2 C3\n\nSample Output 1\n\nD2 C3 H4 S4 C9\nStable\nD2 C3 S4 H4 C9\nNot stable\n\nSample Input 2\n\n2\nS1 H1\n\nSample Output 2\n\nS1 H1\nStable\nS1 H1\nStable", "sample_input": "5\nH4 C9 S4 D2 C3\n"}, "reference_outputs": ["D2 C3 H4 S4 C9\nStable\nD2 C3 S4 H4 C9\nNot stable\n"], "source_document_id": "p02261", "source_text": "Stable Sort\n\nLet's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1.\n\nYour task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode:\n\nBubbleSort(C)\n1 for i = 0 to C.length-1\n2 for j = C.length-1 downto i+1\n3 if C[j].value < C[j-1].value\n4 swap C[j] and C[j-1]\n\nSelectionSort(C)\n1 for i = 0 to C.length-1\n2 mini = i\n3 for j = i to C.length-1\n4 if C[j].value < C[mini].value\n5 mini = j\n6 swap C[i] and C[mini]\n\nNote that, indices for array elements are based on 0-origin.\n\nFor each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).\n\nInput\n\nThe first line contains an integer N, the number of cards.\n\nN cards are given in the following line. Each card is represented by two characters. Two consecutive cards are separated by a space character.\n\nOutput\n\nIn the first line, print the arranged cards provided by the Bubble Sort algorithm. Two consecutive cards should be separated by a space character.\n\nIn the second line, print the stability (\"Stable\" or \"Not stable\") of this output.\n\nIn the third line, print the arranged cards provided by the Selection Sort algorithm. Two consecutive cards should be separated by a space character.\n\nIn the fourth line, print the stability (\"Stable\" or \"Not stable\") of this output.\n\nConstraints\n\n1 ≤ N ≤ 36\n\nSample Input 1\n\n5\nH4 C9 S4 D2 C3\n\nSample Output 1\n\nD2 C3 H4 S4 C9\nStable\nD2 C3 S4 H4 C9\nNot stable\n\nSample Input 2\n\n2\nS1 H1\n\nSample Output 2\n\nS1 H1\nStable\nS1 H1\nStable", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 44196}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s040679252", "group_id": "codeNet:p02264", "input_text": "import collection.mutable.Queue\nimport java.util._\n \nobject Main {\n val sc = new Scanner(System.in)\n val map = new HashMap[String,Int]\n val q = Queue[String]()\n val n = sc.nextInt\n val proces = sc.nextInt\n \n \n \n \n def main(args: Array[String]): Unit = {\n for( i <- 0 until n){\n var temp = sc.next\n q.enqueue(temp)\n map.put(temp, sc.nextInt)\n }\n new Solve().main\n }\n \n \n \n \n class Solve{\n def main{\n var count = 0\n while(!q.isEmpty){\n var temp = q.dequeue() \n \n if(map.get(temp) - proces > 0){\n map.put(temp ,map.get(temp) - proces)\n q.enqueue(temp)\n count += proces\n }else {\n count += map.get(temp)\n println(temp + \" \" + count)\n }\n \n }\n }\n }\n}", "language": "Scala", "metadata": {"date": 1465483554, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02264.html", "problem_id": "p02264", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02264/input.txt", "sample_output_relpath": "derived/input_output/data/p02264/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02264/Scala/s040679252.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s040679252", "user_id": "u778333573"}, "prompt_components": {"gold_output": "p2 180\np5 400\np1 450\np3 550\np4 800\n", "input_to_evaluate": "import collection.mutable.Queue\nimport java.util._\n \nobject Main {\n val sc = new Scanner(System.in)\n val map = new HashMap[String,Int]\n val q = Queue[String]()\n val n = sc.nextInt\n val proces = sc.nextInt\n \n \n \n \n def main(args: Array[String]): Unit = {\n for( i <- 0 until n){\n var temp = sc.next\n q.enqueue(temp)\n map.put(temp, sc.nextInt)\n }\n new Solve().main\n }\n \n \n \n \n class Solve{\n def main{\n var count = 0\n while(!q.isEmpty){\n var temp = q.dequeue() \n \n if(map.get(temp) - proces > 0){\n map.put(temp ,map.get(temp) - proces)\n q.enqueue(temp)\n count += proces\n }else {\n count += map.get(temp)\n println(temp + \" \" + count)\n }\n \n }\n }\n }\n}", "problem_context": "There are n processes in a queue. Each process has namei and timei. The round-robin scheduling handles the processes in order. A round-robin scheduler gives each process a quantum (a time slot) and interrupts the process if it is not completed by then. The process is resumed and moved to the end of the queue, then the scheduler handles the next process in the queue.\n\nFor example, we have the following queue with the quantum of 100ms.\n\nA(150) - B(80) - C(200) - D(200)\n\nFirst, process A is handled for 100ms, then the process is moved to the end of the queue with the remaining time (50ms).\n\nB(80) - C(200) - D(200) - A(50)\n\nNext, process B is handled for 80ms. The process is completed with the time stamp of 180ms and removed from the queue.\n\nC(200) - D(200) - A(50)\n\nYour task is to write a program which simulates the round-robin scheduling.\n\nInput\n\nn q\n\nname1 time1\n\nname2 time2\n\n...\n\nnamen timen\n\nIn the first line the number of processes n and the quantum q are given separated by a single space.\n\nIn the following n lines, names and times for the n processes are given. namei and timei are separated by a single space.\n\nOutput\n\nFor each process, prints its name and the time the process finished in order.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n1 ≤ q ≤ 1000\n\n1 ≤ timei ≤ 50000\n\n1 ≤ length of namei ≤ 10\n\n1 ≤ Sum of timei ≤ 1000000\n\nSample Input 1\n\n5 100\np1 150\np2 80\np3 200\np4 350\np5 20\n\nSample Output 1\n\np2 180\np5 400\np1 450\np3 550\np4 800\n\nNotes\n\nTemplate in C", "sample_input": "5 100\np1 150\np2 80\np3 200\np4 350\np5 20\n"}, "reference_outputs": ["p2 180\np5 400\np1 450\np3 550\np4 800\n"], "source_document_id": "p02264", "source_text": "There are n processes in a queue. Each process has namei and timei. The round-robin scheduling handles the processes in order. A round-robin scheduler gives each process a quantum (a time slot) and interrupts the process if it is not completed by then. The process is resumed and moved to the end of the queue, then the scheduler handles the next process in the queue.\n\nFor example, we have the following queue with the quantum of 100ms.\n\nA(150) - B(80) - C(200) - D(200)\n\nFirst, process A is handled for 100ms, then the process is moved to the end of the queue with the remaining time (50ms).\n\nB(80) - C(200) - D(200) - A(50)\n\nNext, process B is handled for 80ms. The process is completed with the time stamp of 180ms and removed from the queue.\n\nC(200) - D(200) - A(50)\n\nYour task is to write a program which simulates the round-robin scheduling.\n\nInput\n\nn q\n\nname1 time1\n\nname2 time2\n\n...\n\nnamen timen\n\nIn the first line the number of processes n and the quantum q are given separated by a single space.\n\nIn the following n lines, names and times for the n processes are given. namei and timei are separated by a single space.\n\nOutput\n\nFor each process, prints its name and the time the process finished in order.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n1 ≤ q ≤ 1000\n\n1 ≤ timei ≤ 50000\n\n1 ≤ length of namei ≤ 10\n\n1 ≤ Sum of timei ≤ 1000000\n\nSample Input 1\n\n5 100\np1 150\np2 80\np3 200\np4 350\np5 20\n\nSample Output 1\n\np2 180\np5 400\np1 450\np3 550\np4 800\n\nNotes\n\nTemplate in C", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 827, "cpu_time_ms": 1070, "memory_kb": 142844}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s652297561", "group_id": "codeNet:p02264", "input_text": "import scala.io.StdIn.readLine\nimport scala.collection.immutable.Queue\n\nobject Main {\n\n def loop(n:Int,q:Queue[(String,Int)]):Queue[(String,Int)] = {\n if(n==0) q\n else {\n val m = readLine.split(\" \")\n loop(n-1,q.enqueue((m(0),m(1).toInt)))\n }\n }\n\n def rrobin(q:Queue[(String,Int)],total:Int,str:String,qt:Int):String = {\n if(q.isEmpty) str\n else {\n val ((p,t),r) = q.dequeue\n val (newQ,newT,s):(Queue[(String,Int)],Int,String) = if(t>qt) (r.enqueue((p,t-qt)),qt,\"\") else (r,t,p + \" \" + (t+total) + \"\\n\")\n rrobin(newQ,total+newT,str+s,qt)\n }\n }\n\n def main(args:Array[String]) = {\n val l = readLine.split(\" \").map(_.toInt)\n val q = loop(l(0),Queue[(String,Int)]())\n\n print(rrobin(q,0,\"\",l(1)))\n }\n}", "language": "Scala", "metadata": {"date": 1484104511, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02264.html", "problem_id": "p02264", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02264/input.txt", "sample_output_relpath": "derived/input_output/data/p02264/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02264/Scala/s652297561.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Memory Limit Exceeded", "submission_id": "s652297561", "user_id": "u508732591"}, "prompt_components": {"gold_output": "p2 180\np5 400\np1 450\np3 550\np4 800\n", "input_to_evaluate": "import scala.io.StdIn.readLine\nimport scala.collection.immutable.Queue\n\nobject Main {\n\n def loop(n:Int,q:Queue[(String,Int)]):Queue[(String,Int)] = {\n if(n==0) q\n else {\n val m = readLine.split(\" \")\n loop(n-1,q.enqueue((m(0),m(1).toInt)))\n }\n }\n\n def rrobin(q:Queue[(String,Int)],total:Int,str:String,qt:Int):String = {\n if(q.isEmpty) str\n else {\n val ((p,t),r) = q.dequeue\n val (newQ,newT,s):(Queue[(String,Int)],Int,String) = if(t>qt) (r.enqueue((p,t-qt)),qt,\"\") else (r,t,p + \" \" + (t+total) + \"\\n\")\n rrobin(newQ,total+newT,str+s,qt)\n }\n }\n\n def main(args:Array[String]) = {\n val l = readLine.split(\" \").map(_.toInt)\n val q = loop(l(0),Queue[(String,Int)]())\n\n print(rrobin(q,0,\"\",l(1)))\n }\n}", "problem_context": "There are n processes in a queue. Each process has namei and timei. The round-robin scheduling handles the processes in order. A round-robin scheduler gives each process a quantum (a time slot) and interrupts the process if it is not completed by then. The process is resumed and moved to the end of the queue, then the scheduler handles the next process in the queue.\n\nFor example, we have the following queue with the quantum of 100ms.\n\nA(150) - B(80) - C(200) - D(200)\n\nFirst, process A is handled for 100ms, then the process is moved to the end of the queue with the remaining time (50ms).\n\nB(80) - C(200) - D(200) - A(50)\n\nNext, process B is handled for 80ms. The process is completed with the time stamp of 180ms and removed from the queue.\n\nC(200) - D(200) - A(50)\n\nYour task is to write a program which simulates the round-robin scheduling.\n\nInput\n\nn q\n\nname1 time1\n\nname2 time2\n\n...\n\nnamen timen\n\nIn the first line the number of processes n and the quantum q are given separated by a single space.\n\nIn the following n lines, names and times for the n processes are given. namei and timei are separated by a single space.\n\nOutput\n\nFor each process, prints its name and the time the process finished in order.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n1 ≤ q ≤ 1000\n\n1 ≤ timei ≤ 50000\n\n1 ≤ length of namei ≤ 10\n\n1 ≤ Sum of timei ≤ 1000000\n\nSample Input 1\n\n5 100\np1 150\np2 80\np3 200\np4 350\np5 20\n\nSample Output 1\n\np2 180\np5 400\np1 450\np3 550\np4 800\n\nNotes\n\nTemplate in C", "sample_input": "5 100\np1 150\np2 80\np3 200\np4 350\np5 20\n"}, "reference_outputs": ["p2 180\np5 400\np1 450\np3 550\np4 800\n"], "source_document_id": "p02264", "source_text": "There are n processes in a queue. Each process has namei and timei. The round-robin scheduling handles the processes in order. A round-robin scheduler gives each process a quantum (a time slot) and interrupts the process if it is not completed by then. The process is resumed and moved to the end of the queue, then the scheduler handles the next process in the queue.\n\nFor example, we have the following queue with the quantum of 100ms.\n\nA(150) - B(80) - C(200) - D(200)\n\nFirst, process A is handled for 100ms, then the process is moved to the end of the queue with the remaining time (50ms).\n\nB(80) - C(200) - D(200) - A(50)\n\nNext, process B is handled for 80ms. The process is completed with the time stamp of 180ms and removed from the queue.\n\nC(200) - D(200) - A(50)\n\nYour task is to write a program which simulates the round-robin scheduling.\n\nInput\n\nn q\n\nname1 time1\n\nname2 time2\n\n...\n\nnamen timen\n\nIn the first line the number of processes n and the quantum q are given separated by a single space.\n\nIn the following n lines, names and times for the n processes are given. namei and timei are separated by a single space.\n\nOutput\n\nFor each process, prints its name and the time the process finished in order.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n1 ≤ q ≤ 1000\n\n1 ≤ timei ≤ 50000\n\n1 ≤ length of namei ≤ 10\n\n1 ≤ Sum of timei ≤ 1000000\n\nSample Input 1\n\n5 100\np1 150\np2 80\np3 200\np4 350\np5 20\n\nSample Output 1\n\np2 180\np5 400\np1 450\np3 550\np4 800\n\nNotes\n\nTemplate in C", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 490, "memory_kb": 437036}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s450659271", "group_id": "codeNet:p02265", "input_text": "import scala.io.StdIn.{readInt, readLine};\nobject Main {\n def main(args: Array[String]): Unit = {\n val n = readInt;\n val list = new DoublyLinkedList[Long]();\n for (i <- (0 until n)) {\n readLine.split(\" \") match {\n case Array(\"insert\", value) => list.insert(value.toLong);\n case Array(\"delete\", value) => list.delete(value.toLong);\n case Array(\"deleteFirst\") => list.deleteFirst;\n case Array(\"deleteLast\") => list.deleteLast;\n case _ => ();\n }\n }\n println(list);\n }\n}\nclass DoublyLinkedList[A]() {\n trait Node {var prev: Node; var next: Node;}\n case class Head(var prev: Node, var next: Node) extends Node;\n case class Elem(key: A, var prev: Node, var next: Node) extends Node;\n var length = 0;\n private val head = Head(null, null);\n def isEmpty: Boolean = length == 0;\n override def toString: String = {\n def go(node: Node, ret: List[A]): List[A] = {\n node match {\n case e: Elem => go(e.prev, e.key :: ret);\n case _ => ret;\n }\n }\n if (isEmpty) \"\" else go(head.prev, Nil).mkString(\" \");\n }\n def insert(key: A): Unit = {\n if (isEmpty) {\n val e = Elem(key, head, head);\n head.next = e;\n head.prev = e;\n } else {\n val e = Elem(key, head, head.next);\n head.next.prev = e;\n head.next = e;\n }\n length += 1;\n }\n def delete(key: A): Unit = {\n def go(node: Node): Elem = {\n node match {\n case e: Elem => if (e.key == key) e else go(e.next);\n case _ => null;\n }\n }\n if (!isEmpty) {\n if (length == 1) {\n deleteFirst;\n } else {\n go(head.next) match {\n case null => ();\n case e => {\n val n = e.next;\n val p = e.prev;\n n.prev = p;\n p.next = n;\n length -= 1;\n }\n }\n }\n }\n }\n \n def deleteFirst: Unit = {\n if (!isEmpty) {\n if (length == 1) {\n head.next = null;\n head.prev = null;\n } else {\n val newFirst = head.next.next;\n newFirst.prev = head;\n head.next = newFirst;\n }\n length -= 1;\n }\n }\n def deleteLast: Unit = {\n if (!isEmpty) {\n if (length == 1) {\n head.next = null;\n head.prev = null;\n } else {\n val newLast = head.prev.prev;\n newLast.next = head;\n head.prev = newLast;\n }\n length -= 1;\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1524733580, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02265.html", "problem_id": "p02265", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02265/input.txt", "sample_output_relpath": "derived/input_output/data/p02265/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02265/Scala/s450659271.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s450659271", "user_id": "u909989059"}, "prompt_components": {"gold_output": "6 1 2\n", "input_to_evaluate": "import scala.io.StdIn.{readInt, readLine};\nobject Main {\n def main(args: Array[String]): Unit = {\n val n = readInt;\n val list = new DoublyLinkedList[Long]();\n for (i <- (0 until n)) {\n readLine.split(\" \") match {\n case Array(\"insert\", value) => list.insert(value.toLong);\n case Array(\"delete\", value) => list.delete(value.toLong);\n case Array(\"deleteFirst\") => list.deleteFirst;\n case Array(\"deleteLast\") => list.deleteLast;\n case _ => ();\n }\n }\n println(list);\n }\n}\nclass DoublyLinkedList[A]() {\n trait Node {var prev: Node; var next: Node;}\n case class Head(var prev: Node, var next: Node) extends Node;\n case class Elem(key: A, var prev: Node, var next: Node) extends Node;\n var length = 0;\n private val head = Head(null, null);\n def isEmpty: Boolean = length == 0;\n override def toString: String = {\n def go(node: Node, ret: List[A]): List[A] = {\n node match {\n case e: Elem => go(e.prev, e.key :: ret);\n case _ => ret;\n }\n }\n if (isEmpty) \"\" else go(head.prev, Nil).mkString(\" \");\n }\n def insert(key: A): Unit = {\n if (isEmpty) {\n val e = Elem(key, head, head);\n head.next = e;\n head.prev = e;\n } else {\n val e = Elem(key, head, head.next);\n head.next.prev = e;\n head.next = e;\n }\n length += 1;\n }\n def delete(key: A): Unit = {\n def go(node: Node): Elem = {\n node match {\n case e: Elem => if (e.key == key) e else go(e.next);\n case _ => null;\n }\n }\n if (!isEmpty) {\n if (length == 1) {\n deleteFirst;\n } else {\n go(head.next) match {\n case null => ();\n case e => {\n val n = e.next;\n val p = e.prev;\n n.prev = p;\n p.next = n;\n length -= 1;\n }\n }\n }\n }\n }\n \n def deleteFirst: Unit = {\n if (!isEmpty) {\n if (length == 1) {\n head.next = null;\n head.prev = null;\n } else {\n val newFirst = head.next.next;\n newFirst.prev = head;\n head.next = newFirst;\n }\n length -= 1;\n }\n }\n def deleteLast: Unit = {\n if (!isEmpty) {\n if (length == 1) {\n head.next = null;\n head.prev = null;\n } else {\n val newLast = head.prev.prev;\n newLast.next = head;\n head.prev = newLast;\n }\n length -= 1;\n }\n }\n}\n", "problem_context": "Doubly Linked List\n\nYour task is to implement a double linked list.\n\nWrite a program which performs the following operations:\n\ninsert x: insert an element with key x into the front of the list.\n\ndelete x: delete the first element which has the key of x from the list. If there is not such element, you need not do anything.\n\ndeleteFirst: delete the first element from the list.\n\ndeleteLast: delete the last element from the list.\n\nInput\n\nThe input is given in the following format:\n\nn\n\ncommand1\n\ncommand2\n\n...\n\ncommandn\n\nIn the first line, the number of operations n is given. In the following n lines, the above mentioned operations are given in the following format:\n\ninsert x\n\ndelete x\n\ndeleteFirst\n\ndeleteLast\n\nOutput\n\nPrint all the element (key) in the list after the given operations. Two consequtive keys should be separated by a single space.\n\nConstraints\n\nThe number of operations ≤ 2,000,000\n\nThe number of delete operations ≤ 20\n\n0 ≤ value of a key ≤ 109\n\nThe number of elements in the list does not exceed 106\n\nFor a delete, deleteFirst or deleteLast operation, there is at least one element in the list.\n\nSample Input 1\n\n7\ninsert 5\ninsert 2\ninsert 3\ninsert 1\ndelete 3\ninsert 6\ndelete 5\n\nSample Output 1\n\n6 1 2\n\nSample Input 2\n\n9\ninsert 5\ninsert 2\ninsert 3\ninsert 1\ndelete 3\ninsert 6\ndelete 5\ndeleteFirst\ndeleteLast\n\nSample Output 2\n\n1", "sample_input": "7\ninsert 5\ninsert 2\ninsert 3\ninsert 1\ndelete 3\ninsert 6\ndelete 5\n"}, "reference_outputs": ["6 1 2\n"], "source_document_id": "p02265", "source_text": "Doubly Linked List\n\nYour task is to implement a double linked list.\n\nWrite a program which performs the following operations:\n\ninsert x: insert an element with key x into the front of the list.\n\ndelete x: delete the first element which has the key of x from the list. If there is not such element, you need not do anything.\n\ndeleteFirst: delete the first element from the list.\n\ndeleteLast: delete the last element from the list.\n\nInput\n\nThe input is given in the following format:\n\nn\n\ncommand1\n\ncommand2\n\n...\n\ncommandn\n\nIn the first line, the number of operations n is given. In the following n lines, the above mentioned operations are given in the following format:\n\ninsert x\n\ndelete x\n\ndeleteFirst\n\ndeleteLast\n\nOutput\n\nPrint all the element (key) in the list after the given operations. Two consequtive keys should be separated by a single space.\n\nConstraints\n\nThe number of operations ≤ 2,000,000\n\nThe number of delete operations ≤ 20\n\n0 ≤ value of a key ≤ 109\n\nThe number of elements in the list does not exceed 106\n\nFor a delete, deleteFirst or deleteLast operation, there is at least one element in the list.\n\nSample Input 1\n\n7\ninsert 5\ninsert 2\ninsert 3\ninsert 1\ndelete 3\ninsert 6\ndelete 5\n\nSample Output 1\n\n6 1 2\n\nSample Input 2\n\n9\ninsert 5\ninsert 2\ninsert 3\ninsert 1\ndelete 3\ninsert 6\ndelete 5\ndeleteFirst\ndeleteLast\n\nSample Output 2\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2936, "cpu_time_ms": 3980, "memory_kb": 538600}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s871149133", "group_id": "codeNet:p02268", "input_text": "object Main{\n def main(args:Array[String]) : Unit = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val list = List.fill(n)(sc.nextInt)\n val q = sc.nextInt\n val queries = List.fill(q)(sc.nextInt)\n val contained = queries.filter(binarySearch(list, _))\n println(contained.size)\n }\n def binarySearch(list: List[Int], n: Int) : Boolean = {\n val l = list.size\n if (l==0) false\n else if (list(l/2) > n ) binarySearch(list.slice(0, l/2), n)\n else if (list(l/2) == n) true\n else binarySearch(list.slice((l/2) + 1, list.size), n)\n }\n}", "language": "Scala", "metadata": {"date": 1439639055, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02268.html", "problem_id": "p02268", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02268/input.txt", "sample_output_relpath": "derived/input_output/data/p02268/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02268/Scala/s871149133.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s871149133", "user_id": "u879226672"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main{\n def main(args:Array[String]) : Unit = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val list = List.fill(n)(sc.nextInt)\n val q = sc.nextInt\n val queries = List.fill(q)(sc.nextInt)\n val contained = queries.filter(binarySearch(list, _))\n println(contained.size)\n }\n def binarySearch(list: List[Int], n: Int) : Boolean = {\n val l = list.size\n if (l==0) false\n else if (list(l/2) > n ) binarySearch(list.slice(0, l/2), n)\n else if (list(l/2) == n) true\n else binarySearch(list.slice((l/2) + 1, list.size), n)\n }\n}", "problem_context": "Search II\n\nYou are given a sequence of n integers S and a sequence of different q integers T. Write a program which outputs C, the number of integers in T which are also in the set S.\n\nInput\n\nIn the first line n is given. In the second line, n integers are given. In the third line q is given. Then, in the fourth line, q integers are given.\n\nOutput\n\nPrint C in a line.\n\nConstraints\n\nElements in S is sorted in ascending order\n\nn ≤ 100000\n\nq ≤ 50000\n\n0 ≤ an element in S ≤ 109\n\n0 ≤ an element in T ≤ 109\n\nSample Input 1\n\n5\n1 2 3 4 5\n3\n3 4 1\n\nSample Output 1\n\n3\n\nSample Input 2\n\n3\n1 2 3\n1\n5\n\nSample Output 2\n\n0\n\nSample Input 3\n\n5\n1 1 2 2 3\n2\n1 2\n\nSample Output 3\n\n2\n\nNotes", "sample_input": "5\n1 2 3 4 5\n3\n3 4 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02268", "source_text": "Search II\n\nYou are given a sequence of n integers S and a sequence of different q integers T. Write a program which outputs C, the number of integers in T which are also in the set S.\n\nInput\n\nIn the first line n is given. In the second line, n integers are given. In the third line q is given. Then, in the fourth line, q integers are given.\n\nOutput\n\nPrint C in a line.\n\nConstraints\n\nElements in S is sorted in ascending order\n\nn ≤ 100000\n\nq ≤ 50000\n\n0 ≤ an element in S ≤ 109\n\n0 ≤ an element in T ≤ 109\n\nSample Input 1\n\n5\n1 2 3 4 5\n3\n3 4 1\n\nSample Output 1\n\n3\n\nSample Input 2\n\n3\n1 2 3\n1\n5\n\nSample Output 2\n\n0\n\nSample Input 3\n\n5\n1 1 2 2 3\n2\n1 2\n\nSample Output 3\n\n2\n\nNotes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 810, "memory_kb": 290476}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s722316648", "group_id": "codeNet:p02268", "input_text": "import scala.io.StdIn.{readInt,readLine}\n\nobject Main {\n def scan(a:Array[Int],value:Int,l:Int,r:Int):Boolean = {\n val mid = (l+r)/2\n if(a(mid) == value) true\n else if(l>=r) false\n else {\n val (new_l,new_r) = if(a(mid) search(s,i)))\n }\n}", "language": "Scala", "metadata": {"date": 1489237586, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02268.html", "problem_id": "p02268", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02268/input.txt", "sample_output_relpath": "derived/input_output/data/p02268/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02268/Scala/s722316648.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s722316648", "user_id": "u508732591"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.io.StdIn.{readInt,readLine}\n\nobject Main {\n def scan(a:Array[Int],value:Int,l:Int,r:Int):Boolean = {\n val mid = (l+r)/2\n if(a(mid) == value) true\n else if(l>=r) false\n else {\n val (new_l,new_r) = if(a(mid) search(s,i)))\n }\n}", "problem_context": "Search II\n\nYou are given a sequence of n integers S and a sequence of different q integers T. Write a program which outputs C, the number of integers in T which are also in the set S.\n\nInput\n\nIn the first line n is given. In the second line, n integers are given. In the third line q is given. Then, in the fourth line, q integers are given.\n\nOutput\n\nPrint C in a line.\n\nConstraints\n\nElements in S is sorted in ascending order\n\nn ≤ 100000\n\nq ≤ 50000\n\n0 ≤ an element in S ≤ 109\n\n0 ≤ an element in T ≤ 109\n\nSample Input 1\n\n5\n1 2 3 4 5\n3\n3 4 1\n\nSample Output 1\n\n3\n\nSample Input 2\n\n3\n1 2 3\n1\n5\n\nSample Output 2\n\n0\n\nSample Input 3\n\n5\n1 1 2 2 3\n2\n1 2\n\nSample Output 3\n\n2\n\nNotes", "sample_input": "5\n1 2 3 4 5\n3\n3 4 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02268", "source_text": "Search II\n\nYou are given a sequence of n integers S and a sequence of different q integers T. Write a program which outputs C, the number of integers in T which are also in the set S.\n\nInput\n\nIn the first line n is given. In the second line, n integers are given. In the third line q is given. Then, in the fourth line, q integers are given.\n\nOutput\n\nPrint C in a line.\n\nConstraints\n\nElements in S is sorted in ascending order\n\nn ≤ 100000\n\nq ≤ 50000\n\n0 ≤ an element in S ≤ 109\n\n0 ≤ an element in T ≤ 109\n\nSample Input 1\n\n5\n1 2 3 4 5\n3\n3 4 1\n\nSample Output 1\n\n3\n\nSample Input 2\n\n3\n1 2 3\n1\n5\n\nSample Output 2\n\n0\n\nSample Input 3\n\n5\n1 1 2 2 3\n2\n1 2\n\nSample Output 3\n\n2\n\nNotes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 440, "memory_kb": 94612}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s481787778", "group_id": "codeNet:p02268", "input_text": "object Main extends App {\n val in = io.Source.stdin.getLines.map(_.split(\" \").map(_.toInt).toList).toList\n val src = in.filter(in.indexOf(_) % 2 != 0)\n\n def binarySearch(li: List[Int], n: Int): Option[Int] = li match {\n case h :: Nil => if (h == n) Some(n) else None\n case _ => {\n val midIndex = li.length / 2\n val midValue = li(midIndex)\n if (n < midValue) binarySearch(li.take(midIndex), n)\n else if (n > midValue) binarySearch(li.drop(midIndex), n)\n else Some(n)\n }\n }\n\n println((for (i <- src(1)) yield { binarySearch(src(0), i )}).filter(_ != None).length)\n}\n\n", "language": "Scala", "metadata": {"date": 1515378364, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02268.html", "problem_id": "p02268", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02268/input.txt", "sample_output_relpath": "derived/input_output/data/p02268/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02268/Scala/s481787778.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s481787778", "user_id": "u387507798"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main extends App {\n val in = io.Source.stdin.getLines.map(_.split(\" \").map(_.toInt).toList).toList\n val src = in.filter(in.indexOf(_) % 2 != 0)\n\n def binarySearch(li: List[Int], n: Int): Option[Int] = li match {\n case h :: Nil => if (h == n) Some(n) else None\n case _ => {\n val midIndex = li.length / 2\n val midValue = li(midIndex)\n if (n < midValue) binarySearch(li.take(midIndex), n)\n else if (n > midValue) binarySearch(li.drop(midIndex), n)\n else Some(n)\n }\n }\n\n println((for (i <- src(1)) yield { binarySearch(src(0), i )}).filter(_ != None).length)\n}\n\n", "problem_context": "Search II\n\nYou are given a sequence of n integers S and a sequence of different q integers T. Write a program which outputs C, the number of integers in T which are also in the set S.\n\nInput\n\nIn the first line n is given. In the second line, n integers are given. In the third line q is given. Then, in the fourth line, q integers are given.\n\nOutput\n\nPrint C in a line.\n\nConstraints\n\nElements in S is sorted in ascending order\n\nn ≤ 100000\n\nq ≤ 50000\n\n0 ≤ an element in S ≤ 109\n\n0 ≤ an element in T ≤ 109\n\nSample Input 1\n\n5\n1 2 3 4 5\n3\n3 4 1\n\nSample Output 1\n\n3\n\nSample Input 2\n\n3\n1 2 3\n1\n5\n\nSample Output 2\n\n0\n\nSample Input 3\n\n5\n1 1 2 2 3\n2\n1 2\n\nSample Output 3\n\n2\n\nNotes", "sample_input": "5\n1 2 3 4 5\n3\n3 4 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02268", "source_text": "Search II\n\nYou are given a sequence of n integers S and a sequence of different q integers T. Write a program which outputs C, the number of integers in T which are also in the set S.\n\nInput\n\nIn the first line n is given. In the second line, n integers are given. In the third line q is given. Then, in the fourth line, q integers are given.\n\nOutput\n\nPrint C in a line.\n\nConstraints\n\nElements in S is sorted in ascending order\n\nn ≤ 100000\n\nq ≤ 50000\n\n0 ≤ an element in S ≤ 109\n\n0 ≤ an element in T ≤ 109\n\nSample Input 1\n\n5\n1 2 3 4 5\n3\n3 4 1\n\nSample Output 1\n\n3\n\nSample Input 2\n\n3\n1 2 3\n1\n5\n\nSample Output 2\n\n0\n\nSample Input 3\n\n5\n1 1 2 2 3\n2\n1 2\n\nSample Output 3\n\n2\n\nNotes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 604, "cpu_time_ms": 410, "memory_kb": 163600}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s399525529", "group_id": "codeNet:p02270", "input_text": "import scala.io.StdIn.{readInt,readLine}\nobject Main {\n def main(args: Array[String]): Unit = {\n val input = readLine.split(\" \").map(_.toInt) \n val luggages = (1 to input(0)).foldLeft(Nil: List[Int]) { (list, v) => readInt :: list}\n println(allocation(input(1), luggages.reverse))\n }\n def allocation(k: Int, wList: List[Int]): Int = {\n // 最大積載量 = capacity の場合にトラックに荷物が乗り切るかどうか\n def inCapacity(luggages: List[Int], truck: Int, capacity: Int, curr: Int): Boolean = luggages match {\n case Nil => true\n case x :: xs => {\n val tmpCurr = curr + x\n if (tmpCurr > capacity) {\n if (truck == 1) false\n else inCapacity(xs, truck - 1, capacity, x)\n } else {\n inCapacity(xs, truck, capacity, curr + x)\n }\n }\n }\n // 最小の最大積載量を2分木探索で探索\n def binSearch(pc: Array[Int], leftPtr: Int, rightPtr: Int, currMin: Int): Int = (leftPtr + rightPtr) / 2 match {\n case center if leftPtr == rightPtr => if (center < currMin && inCapacity(wList, k, pc(center), 0)) pc(center) else currMin\n case center => inCapacity(wList, k, pc(center), 0) match {\n case true => binSearch(pc, leftPtr, center, pc(center))\n case false => binSearch(pc, center + 1, rightPtr, currMin)\n }\n }\n\n val maxCapa = wList.sum\n val possibleCapa = (1 to maxCapa).toArray\n binSearch(possibleCapa, 0, possibleCapa.length - 1, maxCapa)\n }\n}\n", "language": "Scala", "metadata": {"date": 1516011676, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02270.html", "problem_id": "p02270", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02270/input.txt", "sample_output_relpath": "derived/input_output/data/p02270/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02270/Scala/s399525529.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s399525529", "user_id": "u909989059"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import scala.io.StdIn.{readInt,readLine}\nobject Main {\n def main(args: Array[String]): Unit = {\n val input = readLine.split(\" \").map(_.toInt) \n val luggages = (1 to input(0)).foldLeft(Nil: List[Int]) { (list, v) => readInt :: list}\n println(allocation(input(1), luggages.reverse))\n }\n def allocation(k: Int, wList: List[Int]): Int = {\n // 最大積載量 = capacity の場合にトラックに荷物が乗り切るかどうか\n def inCapacity(luggages: List[Int], truck: Int, capacity: Int, curr: Int): Boolean = luggages match {\n case Nil => true\n case x :: xs => {\n val tmpCurr = curr + x\n if (tmpCurr > capacity) {\n if (truck == 1) false\n else inCapacity(xs, truck - 1, capacity, x)\n } else {\n inCapacity(xs, truck, capacity, curr + x)\n }\n }\n }\n // 最小の最大積載量を2分木探索で探索\n def binSearch(pc: Array[Int], leftPtr: Int, rightPtr: Int, currMin: Int): Int = (leftPtr + rightPtr) / 2 match {\n case center if leftPtr == rightPtr => if (center < currMin && inCapacity(wList, k, pc(center), 0)) pc(center) else currMin\n case center => inCapacity(wList, k, pc(center), 0) match {\n case true => binSearch(pc, leftPtr, center, pc(center))\n case false => binSearch(pc, center + 1, rightPtr, currMin)\n }\n }\n\n val maxCapa = wList.sum\n val possibleCapa = (1 to maxCapa).toArray\n binSearch(possibleCapa, 0, possibleCapa.length - 1, maxCapa)\n }\n}\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nYou are given $n$ packages of $w_i$ kg from a belt conveyor in order ($i = 0, 1, ... n-1$). You should load all packages onto $k$ trucks which have the common maximum load $P$. Each truck can load consecutive packages (more than or equals to zero) from the belt conveyor unless the total weights of the packages in the sequence does not exceed the maximum load $P$.\n\nWrite a program which reads $n$, $k$ and $w_i$, and reports the minimum value of the maximum load $P$ to load all packages from the belt conveyor.\n\nInput\n\nIn the first line, two integers $n$ and $k$ are given separated by a space character. In the following $n$ lines, $w_i$ are given respectively.\n\nOutput\n\nPrint the minimum value of $P$ in a line.\n\nConstraints\n\n$1 \\leq n \\leq 100,000$\n\n$1 \\leq k \\leq 100,000$\n\n$1 \\leq w_i \\leq 10,000$\n\nSample Input 1\n\n5 3\n8\n1\n7\n3\n9\n\nSample Output 1\n\n10\n\nIf the first truck loads two packages of $\\{8, 1\\}$, the second truck loads two packages of $\\{7, 3\\}$ and the third truck loads a package of $\\{9\\}$, then the minimum value of the maximum load $P$ shall be 10.\n\nSample Input 2\n\n4 2\n1\n2\n2\n6\n\nSample Output 2\n\n6\n\nIf the first truck loads three packages of $\\{1, 2, 2\\}$ and the second truck loads a package of $\\{6\\}$, then the minimum value of the maximum load $P$ shall be 6.", "sample_input": "5 3\n8\n1\n7\n3\n9\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02270", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nYou are given $n$ packages of $w_i$ kg from a belt conveyor in order ($i = 0, 1, ... n-1$). You should load all packages onto $k$ trucks which have the common maximum load $P$. Each truck can load consecutive packages (more than or equals to zero) from the belt conveyor unless the total weights of the packages in the sequence does not exceed the maximum load $P$.\n\nWrite a program which reads $n$, $k$ and $w_i$, and reports the minimum value of the maximum load $P$ to load all packages from the belt conveyor.\n\nInput\n\nIn the first line, two integers $n$ and $k$ are given separated by a space character. In the following $n$ lines, $w_i$ are given respectively.\n\nOutput\n\nPrint the minimum value of $P$ in a line.\n\nConstraints\n\n$1 \\leq n \\leq 100,000$\n\n$1 \\leq k \\leq 100,000$\n\n$1 \\leq w_i \\leq 10,000$\n\nSample Input 1\n\n5 3\n8\n1\n7\n3\n9\n\nSample Output 1\n\n10\n\nIf the first truck loads two packages of $\\{8, 1\\}$, the second truck loads two packages of $\\{7, 3\\}$ and the third truck loads a package of $\\{9\\}$, then the minimum value of the maximum load $P$ shall be 10.\n\nSample Input 2\n\n4 2\n1\n2\n2\n6\n\nSample Output 2\n\n6\n\nIf the first truck loads three packages of $\\{1, 2, 2\\}$ and the second truck loads a package of $\\{6\\}$, then the minimum value of the maximum load $P$ shall be 6.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1668, "cpu_time_ms": 240, "memory_kb": 43768}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s982204630", "group_id": "codeNet:p02271", "input_text": "import scala.collection.mutable\nimport scala.io.StdIn.{readInt, readLine}\n\nobject Main extends App {\n\n val n = readInt()\n val xs = readLine().split(\" \").map { _.toInt }\n readLine()\n val ys = readLine().split(\" \").map { _.toInt }\n\n val zs = mutable.Set.empty[Int]\n for {\n i <- 1 to n\n cs <- xs.combinations(i).map { _.sum }\n } {\n zs += cs\n }\n\n for {\n y <- ys\n ans = if (zs.contains(y)) \"yes\" else \"no\"\n } {\n println(ans)\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1590206544, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02271.html", "problem_id": "p02271", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02271/input.txt", "sample_output_relpath": "derived/input_output/data/p02271/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02271/Scala/s982204630.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s982204630", "user_id": "u912124184"}, "prompt_components": {"gold_output": "no\nno\nyes\nyes\nyes\nyes\nno\nno\n", "input_to_evaluate": "import scala.collection.mutable\nimport scala.io.StdIn.{readInt, readLine}\n\nobject Main extends App {\n\n val n = readInt()\n val xs = readLine().split(\" \").map { _.toInt }\n readLine()\n val ys = readLine().split(\" \").map { _.toInt }\n\n val zs = mutable.Set.empty[Int]\n for {\n i <- 1 to n\n cs <- xs.combinations(i).map { _.sum }\n } {\n zs += cs\n }\n\n for {\n y <- ys\n ans = if (zs.contains(y)) \"yes\" else \"no\"\n } {\n println(ans)\n }\n}\n\n", "problem_context": "Exhaustive Search\n\nWrite a program which reads a sequence A of n elements and an integer M, and outputs \"yes\" if you can make M by adding elements in A, otherwise \"no\". You can use an element only once.\n\nYou are given the sequence A and q questions where each question contains Mi.\n\nInput\n\nIn the first line n is given. In the second line, n integers are given. In the third line q is given. Then, in the fourth line, q integers (Mi) are given.\n\nOutput\n\nFor each question Mi, print yes or no.\n\nConstraints\n\nn ≤ 20\n\nq ≤ 200\n\n1 ≤ elements in A ≤ 2000\n\n1 ≤ Mi ≤ 2000\n\nSample Input 1\n\n5\n1 5 7 10 21\n8\n2 4 17 8 22 21 100 35\n\nSample Output 1\n\nno\nno\nyes\nyes\nyes\nyes\nno\nno\n\nNotes\n\nYou can solve this problem by a Burte Force approach. Suppose solve(p, t) is a function which checkes whether you can make t by selecting elements after p-th element (inclusive). Then you can recursively call the following functions:\n\nsolve(0, M)\n\nsolve(1, M-{sum created from elements before 1st element})\n\nsolve(2, M-{sum created from elements before 2nd element})\n\n...\n\nThe recursive function has two choices: you selected p-th element and not. So, you can check solve(p+1, t-A[p]) and solve(p+1, t) in solve(p, t) to check the all combinations.\n\nFor example, the following figure shows that 8 can be made by A[0] + A[2].", "sample_input": "5\n1 5 7 10 21\n8\n2 4 17 8 22 21 100 35\n"}, "reference_outputs": ["no\nno\nyes\nyes\nyes\nyes\nno\nno\n"], "source_document_id": "p02271", "source_text": "Exhaustive Search\n\nWrite a program which reads a sequence A of n elements and an integer M, and outputs \"yes\" if you can make M by adding elements in A, otherwise \"no\". You can use an element only once.\n\nYou are given the sequence A and q questions where each question contains Mi.\n\nInput\n\nIn the first line n is given. In the second line, n integers are given. In the third line q is given. Then, in the fourth line, q integers (Mi) are given.\n\nOutput\n\nFor each question Mi, print yes or no.\n\nConstraints\n\nn ≤ 20\n\nq ≤ 200\n\n1 ≤ elements in A ≤ 2000\n\n1 ≤ Mi ≤ 2000\n\nSample Input 1\n\n5\n1 5 7 10 21\n8\n2 4 17 8 22 21 100 35\n\nSample Output 1\n\nno\nno\nyes\nyes\nyes\nyes\nno\nno\n\nNotes\n\nYou can solve this problem by a Burte Force approach. Suppose solve(p, t) is a function which checkes whether you can make t by selecting elements after p-th element (inclusive). Then you can recursively call the following functions:\n\nsolve(0, M)\n\nsolve(1, M-{sum created from elements before 1st element})\n\nsolve(2, M-{sum created from elements before 2nd element})\n\n...\n\nThe recursive function has two choices: you selected p-th element and not. So, you can check solve(p+1, t-A[p]) and solve(p+1, t) in solve(p, t) to check the all combinations.\n\nFor example, the following figure shows that 8 can be made by A[0] + A[2].", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 790, "memory_kb": 219100}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s276286726", "group_id": "codeNet:p02272", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val (n, s) = (io.StdIn.readLine().toInt, io.StdIn.readLine().split(' ').map(_.toInt).toList)\n\n var cnt = 0\n /*\n def merge(left: List[Int], right: List[Int]): List[Int] = (left, right) match {\n case (x :: xs, y :: ys) if x <= y => x :: merge(xs, right)\n case (x :: xs, y :: ys) if x > y => y :: merge(left, ys)\n case (Nil, ys) => right\n case (xs, Nil) => left\n }\n */\n def merge(left: List[Int], right: List[Int]): List[Int] = (left ::: right).sorted\n def mergeSort(list: List[Int]): List[Int] = list match {\n case x :: Nil => list\n case _ =>\n val (l1, l2) = list.splitAt(list.size / 2)\n cnt += l1.size + l2.size\n merge(mergeSort(l1), mergeSort(l2))\n }\n println(mergeSort(s).mkString(\" \"))\n println(cnt)\n }\n}", "language": "Scala", "metadata": {"date": 1465140893, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02272.html", "problem_id": "p02272", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02272/input.txt", "sample_output_relpath": "derived/input_output/data/p02272/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02272/Scala/s276286726.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Memory Limit Exceeded", "submission_id": "s276286726", "user_id": "u027872723"}, "prompt_components": {"gold_output": "1 2 3 4 5 6 7 8 9 10\n34\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val (n, s) = (io.StdIn.readLine().toInt, io.StdIn.readLine().split(' ').map(_.toInt).toList)\n\n var cnt = 0\n /*\n def merge(left: List[Int], right: List[Int]): List[Int] = (left, right) match {\n case (x :: xs, y :: ys) if x <= y => x :: merge(xs, right)\n case (x :: xs, y :: ys) if x > y => y :: merge(left, ys)\n case (Nil, ys) => right\n case (xs, Nil) => left\n }\n */\n def merge(left: List[Int], right: List[Int]): List[Int] = (left ::: right).sorted\n def mergeSort(list: List[Int]): List[Int] = list match {\n case x :: Nil => list\n case _ =>\n val (l1, l2) = list.splitAt(list.size / 2)\n cnt += l1.size + l2.size\n merge(mergeSort(l1), mergeSort(l2))\n }\n println(mergeSort(s).mkString(\" \"))\n println(cnt)\n }\n}", "problem_context": "Merge Sort\n\nWrite a program of a Merge Sort algorithm implemented by the following pseudocode. You should also report the number of comparisons in the Merge function.\n\nMerge(A, left, mid, right)\nn1 = mid - left;\nn2 = right - mid;\ncreate array L[0...n1], R[0...n2]\nfor i = 0 to n1-1\ndo L[i] = A[left + i]\nfor i = 0 to n2-1\ndo R[i] = A[mid + i]\nL[n1] = SENTINEL\nR[n2] = SENTINEL\ni = 0;\nj = 0;\nfor k = left to right-1\nif L[i] <= R[j]\nthen A[k] = L[i]\ni = i + 1\nelse A[k] = R[j]\nj = j + 1\n\nMerge-Sort(A, left, right){\nif left+1 < right\nthen mid = (left + right)/2;\ncall Merge-Sort(A, left, mid)\ncall Merge-Sort(A, mid, right)\ncall Merge(A, left, mid, right)\n\nInput\n\nIn the first line n is given. In the second line, n integers are given.\n\nOutput\n\nIn the first line, print the sequence S. Two consequtive elements should be separated by a space character.\n\nIn the second line, print the number of comparisons.\n\nConstraints\n\nn ≤ 500000\n\n0 ≤ an element in S ≤ 109\n\nSample Input 1\n\n10\n8 5 9 2 6 3 7 1 10 4\n\nSample Output 1\n\n1 2 3 4 5 6 7 8 9 10\n34\n\nNotes", "sample_input": "10\n8 5 9 2 6 3 7 1 10 4\n"}, "reference_outputs": ["1 2 3 4 5 6 7 8 9 10\n34\n"], "source_document_id": "p02272", "source_text": "Merge Sort\n\nWrite a program of a Merge Sort algorithm implemented by the following pseudocode. You should also report the number of comparisons in the Merge function.\n\nMerge(A, left, mid, right)\nn1 = mid - left;\nn2 = right - mid;\ncreate array L[0...n1], R[0...n2]\nfor i = 0 to n1-1\ndo L[i] = A[left + i]\nfor i = 0 to n2-1\ndo R[i] = A[mid + i]\nL[n1] = SENTINEL\nR[n2] = SENTINEL\ni = 0;\nj = 0;\nfor k = left to right-1\nif L[i] <= R[j]\nthen A[k] = L[i]\ni = i + 1\nelse A[k] = R[j]\nj = j + 1\n\nMerge-Sort(A, left, right){\nif left+1 < right\nthen mid = (left + right)/2;\ncall Merge-Sort(A, left, mid)\ncall Merge-Sort(A, mid, right)\ncall Merge(A, left, mid, right)\n\nInput\n\nIn the first line n is given. In the second line, n integers are given.\n\nOutput\n\nIn the first line, print the sequence S. Two consequtive elements should be separated by a space character.\n\nIn the second line, print the number of comparisons.\n\nConstraints\n\nn ≤ 500000\n\n0 ≤ an element in S ≤ 109\n\nSample Input 1\n\n10\n8 5 9 2 6 3 7 1 10 4\n\nSample Output 1\n\n1 2 3 4 5 6 7 8 9 10\n34\n\nNotes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1090, "memory_kb": 337156}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s403328497", "group_id": "codeNet:p02272", "input_text": "import scala.io.StdIn.{readLine,readInt}\nimport scala.collection.mutable.ListBuffer\nimport scala.language.postfixOps\n\nobject Main {\n var cnt = 0\n\n def merge(a:Array[Int],left:Int,mid:Int,right:Int) = { val n1 = mid-left\n val n2 = right-mid\n val l = a.slice(left,left+n1) :+ Int.MaxValue\n val r = a.slice(mid,mid+n2) :+ Int.MaxValue\n var i=0\n var j=0\n for(k<-left until right) {\n if(l(i)<=r(j)){\n a(k) = l(i)\n i += 1\n } else {\n a(k)=r(j)\n j += 1\n }\n cnt += 1\n }\n }\n\n def sort(n:Int):Iterator[(Int,Int)] = {\n var l2 = Iterator((0,n/2),(n/2,n))\n var n2 = n/2\n while(n2>1) {\n l2 = for(i<-l2;j<-List((i._1,(i._2+i._1)/2),((i._2+i._1)/2,i._2)) iterator) yield j\n n2 = n2/2\n }\n l2\n }\n\n def mergeSort(l:List[(Int,Int)],a:Array[Int]):Unit = {\n if(l.length==1) return\n else {\n var i = 0\n var left = 0\n var right = 0\n val b = new ListBuffer[(Int,Int)]\n for(e<-l) {\n val mid = (e._2+e._1)/2\n if(e._2-e._1>1)\n merge(a,e._1,mid,e._2)\n if(i==1) {\n right = e._2\n b += ((left,right))\n i = 0\n } else {\n left = e._1\n i+=1\n }\n }\n mergeSort(b.toList,a)\n }\n }\n\n def main(args:Array[String]) = {\n val n = readInt\n val a = readLine.split(\" \").map(_.toInt)\n val r = sort(n)\n mergeSort(r.toList,a)\n merge(a,0,n/2,n)\n println(a.mkString(\" \"))\n println(cnt)\n }\n}", "language": "Scala", "metadata": {"date": 1490280899, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02272.html", "problem_id": "p02272", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02272/input.txt", "sample_output_relpath": "derived/input_output/data/p02272/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02272/Scala/s403328497.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Memory Limit Exceeded", "submission_id": "s403328497", "user_id": "u508732591"}, "prompt_components": {"gold_output": "1 2 3 4 5 6 7 8 9 10\n34\n", "input_to_evaluate": "import scala.io.StdIn.{readLine,readInt}\nimport scala.collection.mutable.ListBuffer\nimport scala.language.postfixOps\n\nobject Main {\n var cnt = 0\n\n def merge(a:Array[Int],left:Int,mid:Int,right:Int) = { val n1 = mid-left\n val n2 = right-mid\n val l = a.slice(left,left+n1) :+ Int.MaxValue\n val r = a.slice(mid,mid+n2) :+ Int.MaxValue\n var i=0\n var j=0\n for(k<-left until right) {\n if(l(i)<=r(j)){\n a(k) = l(i)\n i += 1\n } else {\n a(k)=r(j)\n j += 1\n }\n cnt += 1\n }\n }\n\n def sort(n:Int):Iterator[(Int,Int)] = {\n var l2 = Iterator((0,n/2),(n/2,n))\n var n2 = n/2\n while(n2>1) {\n l2 = for(i<-l2;j<-List((i._1,(i._2+i._1)/2),((i._2+i._1)/2,i._2)) iterator) yield j\n n2 = n2/2\n }\n l2\n }\n\n def mergeSort(l:List[(Int,Int)],a:Array[Int]):Unit = {\n if(l.length==1) return\n else {\n var i = 0\n var left = 0\n var right = 0\n val b = new ListBuffer[(Int,Int)]\n for(e<-l) {\n val mid = (e._2+e._1)/2\n if(e._2-e._1>1)\n merge(a,e._1,mid,e._2)\n if(i==1) {\n right = e._2\n b += ((left,right))\n i = 0\n } else {\n left = e._1\n i+=1\n }\n }\n mergeSort(b.toList,a)\n }\n }\n\n def main(args:Array[String]) = {\n val n = readInt\n val a = readLine.split(\" \").map(_.toInt)\n val r = sort(n)\n mergeSort(r.toList,a)\n merge(a,0,n/2,n)\n println(a.mkString(\" \"))\n println(cnt)\n }\n}", "problem_context": "Merge Sort\n\nWrite a program of a Merge Sort algorithm implemented by the following pseudocode. You should also report the number of comparisons in the Merge function.\n\nMerge(A, left, mid, right)\nn1 = mid - left;\nn2 = right - mid;\ncreate array L[0...n1], R[0...n2]\nfor i = 0 to n1-1\ndo L[i] = A[left + i]\nfor i = 0 to n2-1\ndo R[i] = A[mid + i]\nL[n1] = SENTINEL\nR[n2] = SENTINEL\ni = 0;\nj = 0;\nfor k = left to right-1\nif L[i] <= R[j]\nthen A[k] = L[i]\ni = i + 1\nelse A[k] = R[j]\nj = j + 1\n\nMerge-Sort(A, left, right){\nif left+1 < right\nthen mid = (left + right)/2;\ncall Merge-Sort(A, left, mid)\ncall Merge-Sort(A, mid, right)\ncall Merge(A, left, mid, right)\n\nInput\n\nIn the first line n is given. In the second line, n integers are given.\n\nOutput\n\nIn the first line, print the sequence S. Two consequtive elements should be separated by a space character.\n\nIn the second line, print the number of comparisons.\n\nConstraints\n\nn ≤ 500000\n\n0 ≤ an element in S ≤ 109\n\nSample Input 1\n\n10\n8 5 9 2 6 3 7 1 10 4\n\nSample Output 1\n\n1 2 3 4 5 6 7 8 9 10\n34\n\nNotes", "sample_input": "10\n8 5 9 2 6 3 7 1 10 4\n"}, "reference_outputs": ["1 2 3 4 5 6 7 8 9 10\n34\n"], "source_document_id": "p02272", "source_text": "Merge Sort\n\nWrite a program of a Merge Sort algorithm implemented by the following pseudocode. You should also report the number of comparisons in the Merge function.\n\nMerge(A, left, mid, right)\nn1 = mid - left;\nn2 = right - mid;\ncreate array L[0...n1], R[0...n2]\nfor i = 0 to n1-1\ndo L[i] = A[left + i]\nfor i = 0 to n2-1\ndo R[i] = A[mid + i]\nL[n1] = SENTINEL\nR[n2] = SENTINEL\ni = 0;\nj = 0;\nfor k = left to right-1\nif L[i] <= R[j]\nthen A[k] = L[i]\ni = i + 1\nelse A[k] = R[j]\nj = j + 1\n\nMerge-Sort(A, left, right){\nif left+1 < right\nthen mid = (left + right)/2;\ncall Merge-Sort(A, left, mid)\ncall Merge-Sort(A, mid, right)\ncall Merge(A, left, mid, right)\n\nInput\n\nIn the first line n is given. In the second line, n integers are given.\n\nOutput\n\nIn the first line, print the sequence S. Two consequtive elements should be separated by a space character.\n\nIn the second line, print the number of comparisons.\n\nConstraints\n\nn ≤ 500000\n\n0 ≤ an element in S ≤ 109\n\nSample Input 1\n\n10\n8 5 9 2 6 3 7 1 10 4\n\nSample Output 1\n\n1 2 3 4 5 6 7 8 9 10\n34\n\nNotes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1514, "cpu_time_ms": 1200, "memory_kb": 456932}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s194901804", "group_id": "codeNet:p02272", "input_text": "import scala.io.StdIn.{readLine,readInt}\nimport scala.collection.mutable.ListBuffer\nimport scala.language.postfixOps\n\nobject Main {\n var cnt = 0\n val l = new Array[Int](260000)\n val r = new Array[Int](260000)\n val b = new ListBuffer[(Int,Int)]\n\n def merge(a:Array[Int],left:Int,mid:Int,right:Int) = { val n1 = mid-left\n val n2 = right-mid\n Array.copy(a,left,l,0,n1)\n l(n1) = Int.MaxValue\n Array.copy(a,mid,r,0,n2)\n r(n2) = Int.MaxValue\n var i=0\n var j=0\n for(k<-left until right) {\n if(l(i)<=r(j)){\n a(k) = l(i)\n i += 1\n } else {\n a(k)=r(j)\n j += 1\n }\n cnt += 1\n }\n }\n\n def sort(n:Int):Iterator[(Int,Int)] = {\n var l2 = Iterator((0,n/2),(n/2,n))\n var n2 = n/2\n while(n2>1) {\n l2 = for(i<-l2;j<-List((i._1,(i._2+i._1)/2),((i._2+i._1)/2,i._2)) iterator) yield j\n n2 = n2/2\n }\n l2\n }\n\n def mergeSort(l:List[(Int,Int)],a:Array[Int]):Unit = {\n if(l.length==1) return\n else {\n var i = 0\n var left = 0\n var right = 0\n b.clear()\n for(e<-l) {\n val mid = (e._2+e._1)/2\n if(e._2-e._1>1)\n merge(a,e._1,mid,e._2)\n if(i==1) {\n right = e._2\n b += ((left,right))\n i = 0\n } else {\n left = e._1\n i+=1\n }\n }\n mergeSort(b.toList,a)\n }\n }\n\n def main(args:Array[String]) = {\n val n = readInt\n val a = readLine.split(\" \").map(_.toInt)\n val r = sort(n)\n mergeSort(r.toList,a)\n merge(a,0,n/2,n)\n println(a.mkString(\" \"))\n println(cnt)\n }\n}", "language": "Scala", "metadata": {"date": 1490285536, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02272.html", "problem_id": "p02272", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02272/input.txt", "sample_output_relpath": "derived/input_output/data/p02272/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02272/Scala/s194901804.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Memory Limit Exceeded", "submission_id": "s194901804", "user_id": "u508732591"}, "prompt_components": {"gold_output": "1 2 3 4 5 6 7 8 9 10\n34\n", "input_to_evaluate": "import scala.io.StdIn.{readLine,readInt}\nimport scala.collection.mutable.ListBuffer\nimport scala.language.postfixOps\n\nobject Main {\n var cnt = 0\n val l = new Array[Int](260000)\n val r = new Array[Int](260000)\n val b = new ListBuffer[(Int,Int)]\n\n def merge(a:Array[Int],left:Int,mid:Int,right:Int) = { val n1 = mid-left\n val n2 = right-mid\n Array.copy(a,left,l,0,n1)\n l(n1) = Int.MaxValue\n Array.copy(a,mid,r,0,n2)\n r(n2) = Int.MaxValue\n var i=0\n var j=0\n for(k<-left until right) {\n if(l(i)<=r(j)){\n a(k) = l(i)\n i += 1\n } else {\n a(k)=r(j)\n j += 1\n }\n cnt += 1\n }\n }\n\n def sort(n:Int):Iterator[(Int,Int)] = {\n var l2 = Iterator((0,n/2),(n/2,n))\n var n2 = n/2\n while(n2>1) {\n l2 = for(i<-l2;j<-List((i._1,(i._2+i._1)/2),((i._2+i._1)/2,i._2)) iterator) yield j\n n2 = n2/2\n }\n l2\n }\n\n def mergeSort(l:List[(Int,Int)],a:Array[Int]):Unit = {\n if(l.length==1) return\n else {\n var i = 0\n var left = 0\n var right = 0\n b.clear()\n for(e<-l) {\n val mid = (e._2+e._1)/2\n if(e._2-e._1>1)\n merge(a,e._1,mid,e._2)\n if(i==1) {\n right = e._2\n b += ((left,right))\n i = 0\n } else {\n left = e._1\n i+=1\n }\n }\n mergeSort(b.toList,a)\n }\n }\n\n def main(args:Array[String]) = {\n val n = readInt\n val a = readLine.split(\" \").map(_.toInt)\n val r = sort(n)\n mergeSort(r.toList,a)\n merge(a,0,n/2,n)\n println(a.mkString(\" \"))\n println(cnt)\n }\n}", "problem_context": "Merge Sort\n\nWrite a program of a Merge Sort algorithm implemented by the following pseudocode. You should also report the number of comparisons in the Merge function.\n\nMerge(A, left, mid, right)\nn1 = mid - left;\nn2 = right - mid;\ncreate array L[0...n1], R[0...n2]\nfor i = 0 to n1-1\ndo L[i] = A[left + i]\nfor i = 0 to n2-1\ndo R[i] = A[mid + i]\nL[n1] = SENTINEL\nR[n2] = SENTINEL\ni = 0;\nj = 0;\nfor k = left to right-1\nif L[i] <= R[j]\nthen A[k] = L[i]\ni = i + 1\nelse A[k] = R[j]\nj = j + 1\n\nMerge-Sort(A, left, right){\nif left+1 < right\nthen mid = (left + right)/2;\ncall Merge-Sort(A, left, mid)\ncall Merge-Sort(A, mid, right)\ncall Merge(A, left, mid, right)\n\nInput\n\nIn the first line n is given. In the second line, n integers are given.\n\nOutput\n\nIn the first line, print the sequence S. Two consequtive elements should be separated by a space character.\n\nIn the second line, print the number of comparisons.\n\nConstraints\n\nn ≤ 500000\n\n0 ≤ an element in S ≤ 109\n\nSample Input 1\n\n10\n8 5 9 2 6 3 7 1 10 4\n\nSample Output 1\n\n1 2 3 4 5 6 7 8 9 10\n34\n\nNotes", "sample_input": "10\n8 5 9 2 6 3 7 1 10 4\n"}, "reference_outputs": ["1 2 3 4 5 6 7 8 9 10\n34\n"], "source_document_id": "p02272", "source_text": "Merge Sort\n\nWrite a program of a Merge Sort algorithm implemented by the following pseudocode. You should also report the number of comparisons in the Merge function.\n\nMerge(A, left, mid, right)\nn1 = mid - left;\nn2 = right - mid;\ncreate array L[0...n1], R[0...n2]\nfor i = 0 to n1-1\ndo L[i] = A[left + i]\nfor i = 0 to n2-1\ndo R[i] = A[mid + i]\nL[n1] = SENTINEL\nR[n2] = SENTINEL\ni = 0;\nj = 0;\nfor k = left to right-1\nif L[i] <= R[j]\nthen A[k] = L[i]\ni = i + 1\nelse A[k] = R[j]\nj = j + 1\n\nMerge-Sort(A, left, right){\nif left+1 < right\nthen mid = (left + right)/2;\ncall Merge-Sort(A, left, mid)\ncall Merge-Sort(A, mid, right)\ncall Merge(A, left, mid, right)\n\nInput\n\nIn the first line n is given. In the second line, n integers are given.\n\nOutput\n\nIn the first line, print the sequence S. Two consequtive elements should be separated by a space character.\n\nIn the second line, print the number of comparisons.\n\nConstraints\n\nn ≤ 500000\n\n0 ≤ an element in S ≤ 109\n\nSample Input 1\n\n10\n8 5 9 2 6 3 7 1 10 4\n\nSample Output 1\n\n1 2 3 4 5 6 7 8 9 10\n34\n\nNotes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1603, "cpu_time_ms": 950, "memory_kb": 342108}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s680091065", "group_id": "codeNet:p02274", "input_text": "object Main {\n var res = 0\n def msort(arr: Array[Int]): Array[Int] = {\n if (arr.size > 1) {\n val a = msort(arr.take(arr.size/2))\n val b = msort(arr.drop(arr.size/2))\n var i, j, k = 0\n var f = true\n while (f) {\n if (i == a.size && j == b.size) f = false\n else if (j == b.size) {arr(k) = a(i); i += 1; k += 1}\n else if (i == a.size) {arr(k) = b(j); j += 1; k += 1}\n else if (a(i) < b(j)) {arr(k) = a(i); i += 1; k += 1}\n else {arr(k) = b(j); j += 1; k += 1; res += (a.size-i)}\n }\n }\n arr\n }\n def main(args: Array[String]) = {\n val in = io.Source.stdin.getLines.map(_.split(\" \").map(_.toInt))\n in.next\n msort(in.next)\n println(res)\n }\n}", "language": "Scala", "metadata": {"date": 1496058668, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02274.html", "problem_id": "p02274", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02274/input.txt", "sample_output_relpath": "derived/input_output/data/p02274/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02274/Scala/s680091065.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s680091065", "user_id": "u475394465"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "object Main {\n var res = 0\n def msort(arr: Array[Int]): Array[Int] = {\n if (arr.size > 1) {\n val a = msort(arr.take(arr.size/2))\n val b = msort(arr.drop(arr.size/2))\n var i, j, k = 0\n var f = true\n while (f) {\n if (i == a.size && j == b.size) f = false\n else if (j == b.size) {arr(k) = a(i); i += 1; k += 1}\n else if (i == a.size) {arr(k) = b(j); j += 1; k += 1}\n else if (a(i) < b(j)) {arr(k) = a(i); i += 1; k += 1}\n else {arr(k) = b(j); j += 1; k += 1; res += (a.size-i)}\n }\n }\n arr\n }\n def main(args: Array[String]) = {\n val in = io.Source.stdin.getLines.map(_.split(\" \").map(_.toInt))\n in.next\n msort(in.next)\n println(res)\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nThe Number of Inversions\n\nFor a given sequence $A = \\{a_0, a_1, ... a_{n-1}\\}$, the number of pairs $(i, j)$ where $a_i > a_j$ and $i < j$, is called the number of inversions. The number of inversions is equal to the number of swaps of Bubble Sort defined in the following program:\n\nbubbleSort(A)\ncnt = 0 // the number of inversions\nfor i = 0 to A.length-1\nfor j = A.length-1 downto i+1\nif A[j] < A[j-1]\nswap(A[j], A[j-1])\ncnt++\n\nreturn cnt\n\nFor the given sequence $A$, print the number of inversions of $A$. Note that you should not use the above program, which brings Time Limit Exceeded.\n\nInput\n\nIn the first line, an integer $n$, the number of elements in $A$, is given. In the second line, the elements $a_i$ ($i = 0, 1, .. n-1$) are given separated by space characters.\n\noutput\n\nPrint the number of inversions in a line.\n\nConstraints\n\n$ 1 \\leq n \\leq 200,000$\n\n$ 0 \\leq a_i \\leq 10^9$\n\n$a_i$ are all different\n\nSample Input 1\n\n5\n3 5 2 1 4\n\nSample Output 1\n\n6\n\nSample Input 2\n\n3\n3 1 2\n\nSample Output 2\n\n2", "sample_input": "5\n3 5 2 1 4\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02274", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nThe Number of Inversions\n\nFor a given sequence $A = \\{a_0, a_1, ... a_{n-1}\\}$, the number of pairs $(i, j)$ where $a_i > a_j$ and $i < j$, is called the number of inversions. The number of inversions is equal to the number of swaps of Bubble Sort defined in the following program:\n\nbubbleSort(A)\ncnt = 0 // the number of inversions\nfor i = 0 to A.length-1\nfor j = A.length-1 downto i+1\nif A[j] < A[j-1]\nswap(A[j], A[j-1])\ncnt++\n\nreturn cnt\n\nFor the given sequence $A$, print the number of inversions of $A$. Note that you should not use the above program, which brings Time Limit Exceeded.\n\nInput\n\nIn the first line, an integer $n$, the number of elements in $A$, is given. In the second line, the elements $a_i$ ($i = 0, 1, .. n-1$) are given separated by space characters.\n\noutput\n\nPrint the number of inversions in a line.\n\nConstraints\n\n$ 1 \\leq n \\leq 200,000$\n\n$ 0 \\leq a_i \\leq 10^9$\n\n$a_i$ are all different\n\nSample Input 1\n\n5\n3 5 2 1 4\n\nSample Output 1\n\n6\n\nSample Input 2\n\n3\n3 1 2\n\nSample Output 2\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 838, "cpu_time_ms": 630, "memory_kb": 203580}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s183834513", "group_id": "codeNet:p02274", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n\n\n val rn = StdIn.readLine().trim.toInt\n val ina = StdIn.readLine().trim.split(' ').map(_.toInt)\n \n final val infity = Int.MaxValue\n def mergeSort(): Long = {\n @inline def copyToArray(start: Int, end: Int): Array[Int] = {\n val alsize = end - start + 1\n val temp = new Array[Int](alsize)\n Array.copy(ina, start, temp, 0, alsize - 1)\n temp(alsize-1) = infity\n temp\n }\n\n def merge(left: Int, mid: Int, right: Int): Long ={\n val al = copyToArray(left, mid)\n val ar = copyToArray(mid, right)\n var i = 0\n var j = 0\n var cnt = 0L\n //println(\"left:\" + al.toList)\n //println(\"right:\" + ar.toList)\n (left until right).foreach{ k =>\n if(al(i) <= ar(j)){\n ina(k) = al(i)\n i += 1\n } else {\n ina(k) = ar(j)\n j += 1\n cnt += mid - left - i\n }\n }\n //println(\"all:\" + ar2.toList.mkString(\" \"))\n cnt\n }\n\n def innerMergeSort(left: Int, right: Int): Long ={\n \n if(left+1 < right){\n val mid = (left + right) / 2\n val rleft = innerMergeSort(left, mid)\n val rright = innerMergeSort(mid, right)\n val rmerge = merge(left, mid, right)\n \n rleft + rright + rmerge\n } else {\n 0L\n }\n }\n\n innerMergeSort(0, rn)\n\n }\n \n println(mergeSort)\n\n \n}\n\n\n", "language": "Scala", "metadata": {"date": 1523276463, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02274.html", "problem_id": "p02274", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02274/input.txt", "sample_output_relpath": "derived/input_output/data/p02274/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02274/Scala/s183834513.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s183834513", "user_id": "u342234782"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n\n\n val rn = StdIn.readLine().trim.toInt\n val ina = StdIn.readLine().trim.split(' ').map(_.toInt)\n \n final val infity = Int.MaxValue\n def mergeSort(): Long = {\n @inline def copyToArray(start: Int, end: Int): Array[Int] = {\n val alsize = end - start + 1\n val temp = new Array[Int](alsize)\n Array.copy(ina, start, temp, 0, alsize - 1)\n temp(alsize-1) = infity\n temp\n }\n\n def merge(left: Int, mid: Int, right: Int): Long ={\n val al = copyToArray(left, mid)\n val ar = copyToArray(mid, right)\n var i = 0\n var j = 0\n var cnt = 0L\n //println(\"left:\" + al.toList)\n //println(\"right:\" + ar.toList)\n (left until right).foreach{ k =>\n if(al(i) <= ar(j)){\n ina(k) = al(i)\n i += 1\n } else {\n ina(k) = ar(j)\n j += 1\n cnt += mid - left - i\n }\n }\n //println(\"all:\" + ar2.toList.mkString(\" \"))\n cnt\n }\n\n def innerMergeSort(left: Int, right: Int): Long ={\n \n if(left+1 < right){\n val mid = (left + right) / 2\n val rleft = innerMergeSort(left, mid)\n val rright = innerMergeSort(mid, right)\n val rmerge = merge(left, mid, right)\n \n rleft + rright + rmerge\n } else {\n 0L\n }\n }\n\n innerMergeSort(0, rn)\n\n }\n \n println(mergeSort)\n\n \n}\n\n\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nThe Number of Inversions\n\nFor a given sequence $A = \\{a_0, a_1, ... a_{n-1}\\}$, the number of pairs $(i, j)$ where $a_i > a_j$ and $i < j$, is called the number of inversions. The number of inversions is equal to the number of swaps of Bubble Sort defined in the following program:\n\nbubbleSort(A)\ncnt = 0 // the number of inversions\nfor i = 0 to A.length-1\nfor j = A.length-1 downto i+1\nif A[j] < A[j-1]\nswap(A[j], A[j-1])\ncnt++\n\nreturn cnt\n\nFor the given sequence $A$, print the number of inversions of $A$. Note that you should not use the above program, which brings Time Limit Exceeded.\n\nInput\n\nIn the first line, an integer $n$, the number of elements in $A$, is given. In the second line, the elements $a_i$ ($i = 0, 1, .. n-1$) are given separated by space characters.\n\noutput\n\nPrint the number of inversions in a line.\n\nConstraints\n\n$ 1 \\leq n \\leq 200,000$\n\n$ 0 \\leq a_i \\leq 10^9$\n\n$a_i$ are all different\n\nSample Input 1\n\n5\n3 5 2 1 4\n\nSample Output 1\n\n6\n\nSample Input 2\n\n3\n3 1 2\n\nSample Output 2\n\n2", "sample_input": "5\n3 5 2 1 4\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02274", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nThe Number of Inversions\n\nFor a given sequence $A = \\{a_0, a_1, ... a_{n-1}\\}$, the number of pairs $(i, j)$ where $a_i > a_j$ and $i < j$, is called the number of inversions. The number of inversions is equal to the number of swaps of Bubble Sort defined in the following program:\n\nbubbleSort(A)\ncnt = 0 // the number of inversions\nfor i = 0 to A.length-1\nfor j = A.length-1 downto i+1\nif A[j] < A[j-1]\nswap(A[j], A[j-1])\ncnt++\n\nreturn cnt\n\nFor the given sequence $A$, print the number of inversions of $A$. Note that you should not use the above program, which brings Time Limit Exceeded.\n\nInput\n\nIn the first line, an integer $n$, the number of elements in $A$, is given. In the second line, the elements $a_i$ ($i = 0, 1, .. n-1$) are given separated by space characters.\n\noutput\n\nPrint the number of inversions in a line.\n\nConstraints\n\n$ 1 \\leq n \\leq 200,000$\n\n$ 0 \\leq a_i \\leq 10^9$\n\n$a_i$ are all different\n\nSample Input 1\n\n5\n3 5 2 1 4\n\nSample Output 1\n\n6\n\nSample Input 2\n\n3\n3 1 2\n\nSample Output 2\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1406, "cpu_time_ms": 470, "memory_kb": 120940}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s968191891", "group_id": "codeNet:p02275", "input_text": "import scala.io.StdIn.{readInt, readLine}\n\nobject Main extends App {\n import CountingSort.countingSort\n\n val n = readInt()\n val xs = readLine().split(' ').map { _.toInt }\n\n val ys = countingSort(xs)\n println(ys.mkString(\" \"))\n}\n\nobject CountingSort {\n val MaxValue = 10000\n\n def countingSort(xs: Array[Int]): Array[Int] = {\n val counts = {\n val counts = Array.fill(MaxValue + 1)(0)\n for (x <- xs) {\n counts(x) += 1\n }\n\n var i = 1\n while (i <= MaxValue) {\n counts(i) = counts(i) + counts(i - 1)\n i += 1\n }\n\n counts\n }\n\n val ys = new Array[Int](xs.length)\n for (x <- xs) {\n ys(counts(x) - 1) = x\n counts(x) -= 1\n }\n\n ys\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1590286779, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02275.html", "problem_id": "p02275", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02275/input.txt", "sample_output_relpath": "derived/input_output/data/p02275/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02275/Scala/s968191891.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s968191891", "user_id": "u912124184"}, "prompt_components": {"gold_output": "0 1 2 2 3 3 5\n", "input_to_evaluate": "import scala.io.StdIn.{readInt, readLine}\n\nobject Main extends App {\n import CountingSort.countingSort\n\n val n = readInt()\n val xs = readLine().split(' ').map { _.toInt }\n\n val ys = countingSort(xs)\n println(ys.mkString(\" \"))\n}\n\nobject CountingSort {\n val MaxValue = 10000\n\n def countingSort(xs: Array[Int]): Array[Int] = {\n val counts = {\n val counts = Array.fill(MaxValue + 1)(0)\n for (x <- xs) {\n counts(x) += 1\n }\n\n var i = 1\n while (i <= MaxValue) {\n counts(i) = counts(i) + counts(i - 1)\n i += 1\n }\n\n counts\n }\n\n val ys = new Array[Int](xs.length)\n for (x <- xs) {\n ys(counts(x) - 1) = x\n counts(x) -= 1\n }\n\n ys\n }\n}\n\n", "problem_context": "Counting Sort\n\nCounting sort can be used for sorting elements in an array which each of the n input elements is an integer in the range 0 to k. The idea of counting sort is to determine, for each input element x, the number of elements less than x as C[x]. This information can be used to place element x directly into its position in the output array B. This scheme must be modified to handle the situation in which several elements have the same value. Please see the following pseudocode for the detail:\n\nCounting-Sort(A, B, k)\n1 for i = 0 to k\n2 do C[i] = 0\n3 for j = 1 to length[A]\n4 do C[A[j]] = C[A[j]]+1\n5 /* C[i] now contains the number of elements equal to i */\n6 for i = 1 to k\n7 do C[i] = C[i] + C[i-1]\n8 /* C[i] now contains the number of elements less than or equal to i */\n9 for j = length[A] downto 1\n10 do B[C[A[j]]] = A[j]\n11 C[A[j]] = C[A[j]]-1\n\nWrite a program which sorts elements of given array ascending order based on the counting sort.\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\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character.\n\nConstraints\n\n1 ≤ n ≤ 2,000,000\n\n0 ≤ A[i] ≤ 10,000\n\nSample Input 1\n\n7\n2 5 1 3 2 3 0\n\nSample Output 1\n\n0 1 2 2 3 3 5", "sample_input": "7\n2 5 1 3 2 3 0\n"}, "reference_outputs": ["0 1 2 2 3 3 5\n"], "source_document_id": "p02275", "source_text": "Counting Sort\n\nCounting sort can be used for sorting elements in an array which each of the n input elements is an integer in the range 0 to k. The idea of counting sort is to determine, for each input element x, the number of elements less than x as C[x]. This information can be used to place element x directly into its position in the output array B. This scheme must be modified to handle the situation in which several elements have the same value. Please see the following pseudocode for the detail:\n\nCounting-Sort(A, B, k)\n1 for i = 0 to k\n2 do C[i] = 0\n3 for j = 1 to length[A]\n4 do C[A[j]] = C[A[j]]+1\n5 /* C[i] now contains the number of elements equal to i */\n6 for i = 1 to k\n7 do C[i] = C[i] + C[i-1]\n8 /* C[i] now contains the number of elements less than or equal to i */\n9 for j = length[A] downto 1\n10 do B[C[A[j]]] = A[j]\n11 C[A[j]] = C[A[j]]-1\n\nWrite a program which sorts elements of given array ascending order based on the counting sort.\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\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character.\n\nConstraints\n\n1 ≤ n ≤ 2,000,000\n\n0 ≤ A[i] ≤ 10,000\n\nSample Input 1\n\n7\n2 5 1 3 2 3 0\n\nSample Output 1\n\n0 1 2 2 3 3 5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 717, "cpu_time_ms": 950, "memory_kb": 471072}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s317313532", "group_id": "codeNet:p02276", "input_text": "object Main extends App {\n val n: Int = io.StdIn.readLine().toInt\n val arr: Array[Int] = io.StdIn.readLine().split(\" \") map(_.toInt)\n\n def partition(arr: Array[Int], i: Int, p: Int, r:Int): (Array[Int], Int) = {\n val a: Array[Int] = arr.clone()\n var p: Int = 0\n\n for(i <- 0 until r) {\n val (ai, ap, ar) = (a(i), a(p), a(r))\n if (i == p) {if (ai <= ar) p += 1}\n else {if (ai <= ar && ai < ap) {a(i) = ap; a(p) = ai; p += 1}}\n }\n val ap = a(p)\n a(p) = a(r); a(r) = ap\n \n (a,p)\n }\n\n val (pa, i): (Array[Int], Int) = partition(arr, 0, 0, n-1)\n println(pa.slice(0, i).mkString(\" \") + \" [\" + pa(i) + \"] \" + pa.slice(i+1, n).mkString(\" \"))\n}", "language": "Scala", "metadata": {"date": 1500479990, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02276.html", "problem_id": "p02276", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02276/input.txt", "sample_output_relpath": "derived/input_output/data/p02276/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02276/Scala/s317313532.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s317313532", "user_id": "u995793569"}, "prompt_components": {"gold_output": "9 5 8 7 4 2 6 [11] 21 13 19 12\n", "input_to_evaluate": "object Main extends App {\n val n: Int = io.StdIn.readLine().toInt\n val arr: Array[Int] = io.StdIn.readLine().split(\" \") map(_.toInt)\n\n def partition(arr: Array[Int], i: Int, p: Int, r:Int): (Array[Int], Int) = {\n val a: Array[Int] = arr.clone()\n var p: Int = 0\n\n for(i <- 0 until r) {\n val (ai, ap, ar) = (a(i), a(p), a(r))\n if (i == p) {if (ai <= ar) p += 1}\n else {if (ai <= ar && ai < ap) {a(i) = ap; a(p) = ai; p += 1}}\n }\n val ap = a(p)\n a(p) = a(r); a(r) = ap\n \n (a,p)\n }\n\n val (pa, i): (Array[Int], Int) = partition(arr, 0, 0, n-1)\n println(pa.slice(0, i).mkString(\" \") + \" [\" + pa(i) + \"] \" + pa.slice(i+1, n).mkString(\" \"))\n}", "problem_context": "Partition\n\nQuick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], which is, inturn, less than or equal to each element of A[q+1..r]. It also computes the index q.\n\nIn the conquer processes, the two subarrays A[p..q-1] and A[q+1..r] are sorted by recursive calls of QuickSort(A, p, q-1) and QuickSort(A, q+1, r).\n\nYour task is to read a sequence A and perform the Partition based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j]\n7 exchange A[i+1] and A[r]\n8 return i+1\n\nNote that, in this algorithm, Partition always selects an element A[r] as a pivot element around which to partition the array A[p..r].\n\nInput\n\nThe first line of the input includes an integer n, the number of elements in the sequence A.\n\nIn the second line, Ai (i = 1,2,...,n), elements of the sequence are given separated by space characters.\n\nOutput\n\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character. The element which is selected as the pivot of the partition should be indicated by [  ].\n\nConstraints\n\n1 ≤ n ≤ 100,000\n\n0 ≤ Ai ≤ 100,000\n\nSample Input 1\n\n12\n13 19 9 5 12 8 7 4 21 2 6 11\n\nSample Output 1\n\n9 5 8 7 4 2 6 [11] 21 13 19 12", "sample_input": "12\n13 19 9 5 12 8 7 4 21 2 6 11\n"}, "reference_outputs": ["9 5 8 7 4 2 6 [11] 21 13 19 12\n"], "source_document_id": "p02276", "source_text": "Partition\n\nQuick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], which is, inturn, less than or equal to each element of A[q+1..r]. It also computes the index q.\n\nIn the conquer processes, the two subarrays A[p..q-1] and A[q+1..r] are sorted by recursive calls of QuickSort(A, p, q-1) and QuickSort(A, q+1, r).\n\nYour task is to read a sequence A and perform the Partition based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j]\n7 exchange A[i+1] and A[r]\n8 return i+1\n\nNote that, in this algorithm, Partition always selects an element A[r] as a pivot element around which to partition the array A[p..r].\n\nInput\n\nThe first line of the input includes an integer n, the number of elements in the sequence A.\n\nIn the second line, Ai (i = 1,2,...,n), elements of the sequence are given separated by space characters.\n\nOutput\n\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character. The element which is selected as the pivot of the partition should be indicated by [  ].\n\nConstraints\n\n1 ≤ n ≤ 100,000\n\n0 ≤ Ai ≤ 100,000\n\nSample Input 1\n\n12\n13 19 9 5 12 8 7 4 21 2 6 11\n\nSample Output 1\n\n9 5 8 7 4 2 6 [11] 21 13 19 12", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 400, "memory_kb": 85672}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s796262832", "group_id": "codeNet:p02277", "input_text": "import scala.io.StdIn.{readInt, readLine};\nimport scala.reflect.ClassTag;\n\nobject Main {\n \n def main(args: Array[String]): Unit = {\n implicit val ord = Ordering.by((e: (String, Long)) => e._2);\n val n = readInt;\n val arr1 = new Array[(String, Long)](n);\n val arr2 = new Array[(String, Long)](n);\n (0 until n).foreach { i => \n val input = readLine.split(\" \");\n val elem = (input(0), input(1).toLong);\n arr1(i) = elem;\n arr2(i) = elem;\n }\n \n quickSort[(String, Long)](arr1, n);\n mergeSort[(String, Long)](arr2, n);\n \n if ((0 until n).exists( i => arr1(i) != arr2(i))) println(\"Not stable\") else println(\"Stable\");\n println(arr1.map(e => e._1 + \" \" + e._2).mkString(\"\\n\"));\n }\n \n def quickSort[A](arr: Array[A], n: Int)(implicit ord: Ordering[A]): Unit = {\n def _quickSort(first: Int, last: Int): Unit = {\n if (first < last){\n val pivot = partition(arr, first, last);\n _quickSort(first, pivot - 1);\n _quickSort(pivot + 1, last);\n }\n }\n _quickSort(0, n - 1);\n }\n \n def partition[A](arr: Array[A], first: Int, last: Int)(implicit ord: Ordering[A]): Int = {\n import ord._;\n val pivot = arr(last);\n def _partition(ptr: Int, laterPtr: Int): Int = {\n if (ptr > last) {\n laterPtr;\n } else {\n if (arr(ptr) > pivot) {\n _partition(ptr + 1, laterPtr);\n } else {\n swap(arr, ptr, laterPtr + 1);\n _partition(ptr + 1, laterPtr + 1);\n }\n }\n }\n _partition(0, -1);\n }\n\n private def swap[A](arr: Array[A], a: Int, b: Int): Unit = {\n val tmp = arr(a);\n arr(a) = arr(b);\n arr(b) = tmp;\n }\n \n def mergeSort[A](arr: Array[A], n: Int)(implicit ord: Ordering[A], m: ClassTag[A]): Int = {\n import ord._;\n def _mergeSort(first: Int, last: Int): Int = {\n if (last - first > 0) {\n val pivot = (first + last) / 2;\n val cnt1 = _mergeSort(first, pivot);\n val cnt2 = _mergeSort(pivot + 1, last);\n merge(arr, first, last, pivot);\n cnt1 + cnt2 + (last - first + 1);\n } else {\n 0;\n }\n }\n _mergeSort(0, n - 1);\n }\n \n def merge[A](arr: Array[A], first: Int, last: Int, pivot: Int)(implicit ord: Ordering[A], m: ClassTag[A]): Unit = {\n import ord._;\n val tmpArr = arr.slice(first, pivot + 1);\n var ptr1 = 0;\n var ptr2 = pivot + 1;\n for (i <- (first to last)) {\n if (ptr1 >= tmpArr.length) {\n arr(i) = arr(ptr2);\n ptr2 += 1;\n } else if (ptr2 > last) {\n arr(i) = tmpArr(ptr1);\n ptr1 += 1;\n } else {\n if (arr(ptr2) < tmpArr(ptr1)) {\n arr(i) = arr(ptr2);\n ptr2 += 1;\n } else {\n arr(i) = tmpArr(ptr1);\n ptr1 += 1;\n }\n }\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1525648650, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02277.html", "problem_id": "p02277", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02277/input.txt", "sample_output_relpath": "derived/input_output/data/p02277/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02277/Scala/s796262832.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s796262832", "user_id": "u909989059"}, "prompt_components": {"gold_output": "Not stable\nD 1\nC 1\nD 2\nH 2\nD 3\nS 3\n", "input_to_evaluate": "import scala.io.StdIn.{readInt, readLine};\nimport scala.reflect.ClassTag;\n\nobject Main {\n \n def main(args: Array[String]): Unit = {\n implicit val ord = Ordering.by((e: (String, Long)) => e._2);\n val n = readInt;\n val arr1 = new Array[(String, Long)](n);\n val arr2 = new Array[(String, Long)](n);\n (0 until n).foreach { i => \n val input = readLine.split(\" \");\n val elem = (input(0), input(1).toLong);\n arr1(i) = elem;\n arr2(i) = elem;\n }\n \n quickSort[(String, Long)](arr1, n);\n mergeSort[(String, Long)](arr2, n);\n \n if ((0 until n).exists( i => arr1(i) != arr2(i))) println(\"Not stable\") else println(\"Stable\");\n println(arr1.map(e => e._1 + \" \" + e._2).mkString(\"\\n\"));\n }\n \n def quickSort[A](arr: Array[A], n: Int)(implicit ord: Ordering[A]): Unit = {\n def _quickSort(first: Int, last: Int): Unit = {\n if (first < last){\n val pivot = partition(arr, first, last);\n _quickSort(first, pivot - 1);\n _quickSort(pivot + 1, last);\n }\n }\n _quickSort(0, n - 1);\n }\n \n def partition[A](arr: Array[A], first: Int, last: Int)(implicit ord: Ordering[A]): Int = {\n import ord._;\n val pivot = arr(last);\n def _partition(ptr: Int, laterPtr: Int): Int = {\n if (ptr > last) {\n laterPtr;\n } else {\n if (arr(ptr) > pivot) {\n _partition(ptr + 1, laterPtr);\n } else {\n swap(arr, ptr, laterPtr + 1);\n _partition(ptr + 1, laterPtr + 1);\n }\n }\n }\n _partition(0, -1);\n }\n\n private def swap[A](arr: Array[A], a: Int, b: Int): Unit = {\n val tmp = arr(a);\n arr(a) = arr(b);\n arr(b) = tmp;\n }\n \n def mergeSort[A](arr: Array[A], n: Int)(implicit ord: Ordering[A], m: ClassTag[A]): Int = {\n import ord._;\n def _mergeSort(first: Int, last: Int): Int = {\n if (last - first > 0) {\n val pivot = (first + last) / 2;\n val cnt1 = _mergeSort(first, pivot);\n val cnt2 = _mergeSort(pivot + 1, last);\n merge(arr, first, last, pivot);\n cnt1 + cnt2 + (last - first + 1);\n } else {\n 0;\n }\n }\n _mergeSort(0, n - 1);\n }\n \n def merge[A](arr: Array[A], first: Int, last: Int, pivot: Int)(implicit ord: Ordering[A], m: ClassTag[A]): Unit = {\n import ord._;\n val tmpArr = arr.slice(first, pivot + 1);\n var ptr1 = 0;\n var ptr2 = pivot + 1;\n for (i <- (first to last)) {\n if (ptr1 >= tmpArr.length) {\n arr(i) = arr(ptr2);\n ptr2 += 1;\n } else if (ptr2 > last) {\n arr(i) = tmpArr(ptr1);\n ptr1 += 1;\n } else {\n if (arr(ptr2) < tmpArr(ptr1)) {\n arr(i) = arr(ptr2);\n ptr2 += 1;\n } else {\n arr(i) = tmpArr(ptr1);\n ptr1 += 1;\n }\n }\n }\n }\n}\n", "problem_context": "Quick Sort\n\nLet's arrange a deck of cards. Your task is to sort totally n cards. A card consists of a part of a suit (S, H, C or D) and an number. Write a program which sorts such cards based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j]\n7 exchange A[i+1] and A[r]\n8 return i+1\n\nQuicksort(A, p, r)\n1 if p < r\n2 then q = Partition(A, p, r)\n3 run Quicksort(A, p, q-1)\n4 run Quicksort(A, q+1, r)\n\nHere, A is an array which represents a deck of cards and comparison operations are performed based on the numbers.\n\nYour program should also report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).\n\nInput\n\nThe first line contains an integer n, the number of cards.\n\nn cards are given in the following lines. Each card is given in a line and represented by a pair of a character and an integer separated by a single space.\n\nOutput\n\nIn the first line, print the stability (\"Stable\" or \"Not stable\") of this output.\n\nIn the following lines, print the arranged cards in the same manner of that of the input.\n\nConstraints\n\n1 ≤ n ≤ 100,000\n\n1 ≤ the number of a card ≤ 109\n\nThere are no identical card in the input\n\nSample Input 1\n\n6\nD 3\nH 2\nD 1\nS 3\nD 2\nC 1\n\nSample Output 1\n\nNot stable\nD 1\nC 1\nD 2\nH 2\nD 3\nS 3\n\nSample Input 2\n\n2\nS 1\nH 1\n\nSample Output 2\n\nStable\nS 1\nH 1", "sample_input": "6\nD 3\nH 2\nD 1\nS 3\nD 2\nC 1\n"}, "reference_outputs": ["Not stable\nD 1\nC 1\nD 2\nH 2\nD 3\nS 3\n"], "source_document_id": "p02277", "source_text": "Quick Sort\n\nLet's arrange a deck of cards. Your task is to sort totally n cards. A card consists of a part of a suit (S, H, C or D) and an number. Write a program which sorts such cards based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j]\n7 exchange A[i+1] and A[r]\n8 return i+1\n\nQuicksort(A, p, r)\n1 if p < r\n2 then q = Partition(A, p, r)\n3 run Quicksort(A, p, q-1)\n4 run Quicksort(A, q+1, r)\n\nHere, A is an array which represents a deck of cards and comparison operations are performed based on the numbers.\n\nYour program should also report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).\n\nInput\n\nThe first line contains an integer n, the number of cards.\n\nn cards are given in the following lines. Each card is given in a line and represented by a pair of a character and an integer separated by a single space.\n\nOutput\n\nIn the first line, print the stability (\"Stable\" or \"Not stable\") of this output.\n\nIn the following lines, print the arranged cards in the same manner of that of the input.\n\nConstraints\n\n1 ≤ n ≤ 100,000\n\n1 ≤ the number of a card ≤ 109\n\nThere are no identical card in the input\n\nSample Input 1\n\n6\nD 3\nH 2\nD 1\nS 3\nD 2\nC 1\n\nSample Output 1\n\nNot stable\nD 1\nC 1\nD 2\nH 2\nD 3\nS 3\n\nSample Input 2\n\n2\nS 1\nH 1\n\nSample Output 2\n\nStable\nS 1\nH 1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3273, "cpu_time_ms": 2670, "memory_kb": 577416}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s049072602", "group_id": "codeNet:p02277", "input_text": "import scala.io.StdIn.{readInt, readLine};\n\nobject Main {\n \n def main(args: Array[String]): Unit = {\n implicit val ord = Ordering.by((e: (String, Long)) => e._2);\n val n = readInt;\n val arr1 = new Array[(String, Long)](n);\n val arr2 = new Array[(String, Long)](n);\n (0 until n).foreach { i => \n val input = readLine.split(\" \");\n val elem = (input(0), input(1).toLong);\n arr1(i) = elem;\n arr2(i) = elem;\n }\n val s = new Sort[(String, Long)]();\n s.quickSort(arr1, n);\n s.mergeSort(arr2, n);\n \n if ((0 until n).exists( i => arr1(i) != arr2(i))) println(\"Not stable\") else println(\"Stable\");\n println(arr1.map(e => e._1 + \" \" + e._2).mkString(\"\\n\"));\n }\n}\nclass Sort[A](implicit ord: Ordering[A]) {\n import ord._;\n \n def quickSort(arr: Array[A], n: Int): Unit = {\n def _quickSort(first: Int, last: Int): Unit = {\n if (first < last){\n val pivot = partition(arr, first, last);\n _quickSort(first, pivot - 1);\n _quickSort(pivot + 1, last);\n }\n }\n _quickSort(0, n - 1);\n }\n \n private def partition(arr: Array[A], first: Int, last: Int): Int = {\n val pivot = arr(last);\n def _partition(ptr: Int, laterPtr: Int): Int = {\n if (ptr > last) {\n laterPtr;\n } else {\n if (arr(ptr) > pivot) {\n _partition(ptr + 1, laterPtr);\n } else {\n swap(arr, ptr, laterPtr + 1);\n _partition(ptr + 1, laterPtr + 1);\n }\n }\n }\n _partition(0, -1);\n }\n\n private def swap(arr: Array[A], a: Int, b: Int): Unit = {\n val tmp = arr(a);\n arr(a) = arr(b);\n arr(b) = tmp;\n }\n \n def mergeSort(arr: Array[A], n: Int): Int = {\n def _mergeSort(first: Int, last: Int): Int = {\n if (last - first > 0) {\n val pivot = (first + last) / 2;\n val cnt1 = _mergeSort(first, pivot);\n val cnt2 = _mergeSort(pivot + 1, last);\n merge(arr, first, last, pivot);\n cnt1 + cnt2 + (last - first + 1);\n } else {\n 0;\n }\n }\n _mergeSort(0, n - 1);\n }\n \n private def merge(arr: Array[A], first: Int, last: Int, pivot: Int): Unit = {\n val tmpArr = arr.slice(first, pivot + 1);\n var ptr1 = 0;\n var ptr2 = pivot + 1;\n for (i <- (first to last)) {\n if (ptr1 >= tmpArr.length) {\n arr(i) = arr(ptr2);\n ptr2 += 1;\n } else if (ptr2 > last) {\n arr(i) = tmpArr(ptr1);\n ptr1 += 1;\n } else {\n if (arr(ptr2) < tmpArr(ptr1)) {\n arr(i) = arr(ptr2);\n ptr2 += 1;\n } else {\n arr(i) = tmpArr(ptr1);\n ptr1 += 1;\n }\n }\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1525690160, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02277.html", "problem_id": "p02277", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02277/input.txt", "sample_output_relpath": "derived/input_output/data/p02277/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02277/Scala/s049072602.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s049072602", "user_id": "u909989059"}, "prompt_components": {"gold_output": "Not stable\nD 1\nC 1\nD 2\nH 2\nD 3\nS 3\n", "input_to_evaluate": "import scala.io.StdIn.{readInt, readLine};\n\nobject Main {\n \n def main(args: Array[String]): Unit = {\n implicit val ord = Ordering.by((e: (String, Long)) => e._2);\n val n = readInt;\n val arr1 = new Array[(String, Long)](n);\n val arr2 = new Array[(String, Long)](n);\n (0 until n).foreach { i => \n val input = readLine.split(\" \");\n val elem = (input(0), input(1).toLong);\n arr1(i) = elem;\n arr2(i) = elem;\n }\n val s = new Sort[(String, Long)]();\n s.quickSort(arr1, n);\n s.mergeSort(arr2, n);\n \n if ((0 until n).exists( i => arr1(i) != arr2(i))) println(\"Not stable\") else println(\"Stable\");\n println(arr1.map(e => e._1 + \" \" + e._2).mkString(\"\\n\"));\n }\n}\nclass Sort[A](implicit ord: Ordering[A]) {\n import ord._;\n \n def quickSort(arr: Array[A], n: Int): Unit = {\n def _quickSort(first: Int, last: Int): Unit = {\n if (first < last){\n val pivot = partition(arr, first, last);\n _quickSort(first, pivot - 1);\n _quickSort(pivot + 1, last);\n }\n }\n _quickSort(0, n - 1);\n }\n \n private def partition(arr: Array[A], first: Int, last: Int): Int = {\n val pivot = arr(last);\n def _partition(ptr: Int, laterPtr: Int): Int = {\n if (ptr > last) {\n laterPtr;\n } else {\n if (arr(ptr) > pivot) {\n _partition(ptr + 1, laterPtr);\n } else {\n swap(arr, ptr, laterPtr + 1);\n _partition(ptr + 1, laterPtr + 1);\n }\n }\n }\n _partition(0, -1);\n }\n\n private def swap(arr: Array[A], a: Int, b: Int): Unit = {\n val tmp = arr(a);\n arr(a) = arr(b);\n arr(b) = tmp;\n }\n \n def mergeSort(arr: Array[A], n: Int): Int = {\n def _mergeSort(first: Int, last: Int): Int = {\n if (last - first > 0) {\n val pivot = (first + last) / 2;\n val cnt1 = _mergeSort(first, pivot);\n val cnt2 = _mergeSort(pivot + 1, last);\n merge(arr, first, last, pivot);\n cnt1 + cnt2 + (last - first + 1);\n } else {\n 0;\n }\n }\n _mergeSort(0, n - 1);\n }\n \n private def merge(arr: Array[A], first: Int, last: Int, pivot: Int): Unit = {\n val tmpArr = arr.slice(first, pivot + 1);\n var ptr1 = 0;\n var ptr2 = pivot + 1;\n for (i <- (first to last)) {\n if (ptr1 >= tmpArr.length) {\n arr(i) = arr(ptr2);\n ptr2 += 1;\n } else if (ptr2 > last) {\n arr(i) = tmpArr(ptr1);\n ptr1 += 1;\n } else {\n if (arr(ptr2) < tmpArr(ptr1)) {\n arr(i) = arr(ptr2);\n ptr2 += 1;\n } else {\n arr(i) = tmpArr(ptr1);\n ptr1 += 1;\n }\n }\n }\n }\n}\n", "problem_context": "Quick Sort\n\nLet's arrange a deck of cards. Your task is to sort totally n cards. A card consists of a part of a suit (S, H, C or D) and an number. Write a program which sorts such cards based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j]\n7 exchange A[i+1] and A[r]\n8 return i+1\n\nQuicksort(A, p, r)\n1 if p < r\n2 then q = Partition(A, p, r)\n3 run Quicksort(A, p, q-1)\n4 run Quicksort(A, q+1, r)\n\nHere, A is an array which represents a deck of cards and comparison operations are performed based on the numbers.\n\nYour program should also report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).\n\nInput\n\nThe first line contains an integer n, the number of cards.\n\nn cards are given in the following lines. Each card is given in a line and represented by a pair of a character and an integer separated by a single space.\n\nOutput\n\nIn the first line, print the stability (\"Stable\" or \"Not stable\") of this output.\n\nIn the following lines, print the arranged cards in the same manner of that of the input.\n\nConstraints\n\n1 ≤ n ≤ 100,000\n\n1 ≤ the number of a card ≤ 109\n\nThere are no identical card in the input\n\nSample Input 1\n\n6\nD 3\nH 2\nD 1\nS 3\nD 2\nC 1\n\nSample Output 1\n\nNot stable\nD 1\nC 1\nD 2\nH 2\nD 3\nS 3\n\nSample Input 2\n\n2\nS 1\nH 1\n\nSample Output 2\n\nStable\nS 1\nH 1", "sample_input": "6\nD 3\nH 2\nD 1\nS 3\nD 2\nC 1\n"}, "reference_outputs": ["Not stable\nD 1\nC 1\nD 2\nH 2\nD 3\nS 3\n"], "source_document_id": "p02277", "source_text": "Quick Sort\n\nLet's arrange a deck of cards. Your task is to sort totally n cards. A card consists of a part of a suit (S, H, C or D) and an number. Write a program which sorts such cards based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j]\n7 exchange A[i+1] and A[r]\n8 return i+1\n\nQuicksort(A, p, r)\n1 if p < r\n2 then q = Partition(A, p, r)\n3 run Quicksort(A, p, q-1)\n4 run Quicksort(A, q+1, r)\n\nHere, A is an array which represents a deck of cards and comparison operations are performed based on the numbers.\n\nYour program should also report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).\n\nInput\n\nThe first line contains an integer n, the number of cards.\n\nn cards are given in the following lines. Each card is given in a line and represented by a pair of a character and an integer separated by a single space.\n\nOutput\n\nIn the first line, print the stability (\"Stable\" or \"Not stable\") of this output.\n\nIn the following lines, print the arranged cards in the same manner of that of the input.\n\nConstraints\n\n1 ≤ n ≤ 100,000\n\n1 ≤ the number of a card ≤ 109\n\nThere are no identical card in the input\n\nSample Input 1\n\n6\nD 3\nH 2\nD 1\nS 3\nD 2\nC 1\n\nSample Output 1\n\nNot stable\nD 1\nC 1\nD 2\nH 2\nD 3\nS 3\n\nSample Input 2\n\n2\nS 1\nH 1\n\nSample Output 2\n\nStable\nS 1\nH 1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3107, "cpu_time_ms": 2820, "memory_kb": 575876}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s793405544", "group_id": "codeNet:p02277", "input_text": "import scala.io.StdIn.{readInt, readLine};\n\nobject Main {\n def main(args: Array[String]): Unit = {\n implicit val ord = Ordering.by((e: (String, Long)) => e._2);\n val n = readInt;\n val arr1 = new Array[Card](n);\n val arr2 = new Array[Card](n);\n (0 until n).foreach { i => \n val input = readLine.split(\" \");\n val elem = Card(input(0), input(1).toInt);\n arr1(i) = elem;\n arr2(i) = elem;\n }\n quickSort(arr1, n);\n mergeSort(arr2, n);\n \n if ((0 until n).exists( i => arr1(i) != arr2(i))) println(\"Not stable\") else println(\"Stable\");\n println(arr1.mkString(\"\\n\"));\n }\n \n def quickSort(arr: Array[Card], n: Int): Unit = {\n def _quickSort(first: Int, last: Int): Unit = {\n if (first < last){\n val (pivot, needsPartition) = partition(first, last);\n if (needsPartition) {\n _quickSort(first, pivot - 1);\n _quickSort(pivot + 1, last);\n }\n }\n }\n def partition(first: Int, last: Int): (Int, Boolean) = {\n val pivot = arr(last);\n def _partition(sep: Int, ptr: Int, flag: Boolean): (Int, Boolean) = {\n if (ptr > last) {\n (sep, flag);\n } else if (arr(ptr) > pivot) {\n _partition(sep, ptr + 1, true);\n }else if (arr(ptr) < pivot) {\n swap(arr, sep + 1, ptr);\n _partition(sep + 1, ptr + 1, true);\n } else {\n swap(arr, sep + 1, ptr);\n _partition(sep + 1, ptr + 1, flag);\n }\n }\n _partition(-1, 0, false);\n }\n _quickSort(0, n - 1);\n }\n \n\n\n private def swap(arr: Array[Card], a: Int, b: Int): Unit = {\n val tmp = arr(a);\n arr(a) = arr(b);\n arr(b) = tmp;\n }\n \n def mergeSort(arr: Array[Card], n: Int): Unit = {\n def _mergeSort(first: Int, last: Int): Unit = {\n if (first < last) {\n val pivot = (first + last) / 2;\n val cnt1 = _mergeSort(first, pivot);\n val cnt2 = _mergeSort(pivot + 1, last);\n merge(first, last, pivot);\n }\n }\n def merge(first: Int, last: Int, pivot: Int): Unit = {\n val tmpArr = arr.slice(first, pivot + 1);\n var ptr1 = 0;\n var ptr2 = pivot + 1;\n for (i <- (first to last)) {\n if (ptr1 >= tmpArr.length) {\n ptr2 += 1;\n } else if (ptr2 > last || tmpArr(ptr1) <= arr(ptr2)) {\n arr(i) = tmpArr(ptr1);\n ptr1 += 1;\n } else {\n arr(i) = arr(ptr2);\n ptr2 += 1;\n }\n }\n }\n \n _mergeSort(0, n - 1);\n }\n}\ncase class Card(symbol: String, num: Int) {\n override def toString(): String = symbol + \" \" + num\n def <(a: Card): Boolean = this.num < a.num\n def <=(a: Card): Boolean = this.num <= a.num\n def >(a: Card): Boolean = this.num > a.num\n def >=(a: Card): Boolean = this.num >= a.num\n}\n", "language": "Scala", "metadata": {"date": 1525734343, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02277.html", "problem_id": "p02277", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02277/input.txt", "sample_output_relpath": "derived/input_output/data/p02277/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02277/Scala/s793405544.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s793405544", "user_id": "u909989059"}, "prompt_components": {"gold_output": "Not stable\nD 1\nC 1\nD 2\nH 2\nD 3\nS 3\n", "input_to_evaluate": "import scala.io.StdIn.{readInt, readLine};\n\nobject Main {\n def main(args: Array[String]): Unit = {\n implicit val ord = Ordering.by((e: (String, Long)) => e._2);\n val n = readInt;\n val arr1 = new Array[Card](n);\n val arr2 = new Array[Card](n);\n (0 until n).foreach { i => \n val input = readLine.split(\" \");\n val elem = Card(input(0), input(1).toInt);\n arr1(i) = elem;\n arr2(i) = elem;\n }\n quickSort(arr1, n);\n mergeSort(arr2, n);\n \n if ((0 until n).exists( i => arr1(i) != arr2(i))) println(\"Not stable\") else println(\"Stable\");\n println(arr1.mkString(\"\\n\"));\n }\n \n def quickSort(arr: Array[Card], n: Int): Unit = {\n def _quickSort(first: Int, last: Int): Unit = {\n if (first < last){\n val (pivot, needsPartition) = partition(first, last);\n if (needsPartition) {\n _quickSort(first, pivot - 1);\n _quickSort(pivot + 1, last);\n }\n }\n }\n def partition(first: Int, last: Int): (Int, Boolean) = {\n val pivot = arr(last);\n def _partition(sep: Int, ptr: Int, flag: Boolean): (Int, Boolean) = {\n if (ptr > last) {\n (sep, flag);\n } else if (arr(ptr) > pivot) {\n _partition(sep, ptr + 1, true);\n }else if (arr(ptr) < pivot) {\n swap(arr, sep + 1, ptr);\n _partition(sep + 1, ptr + 1, true);\n } else {\n swap(arr, sep + 1, ptr);\n _partition(sep + 1, ptr + 1, flag);\n }\n }\n _partition(-1, 0, false);\n }\n _quickSort(0, n - 1);\n }\n \n\n\n private def swap(arr: Array[Card], a: Int, b: Int): Unit = {\n val tmp = arr(a);\n arr(a) = arr(b);\n arr(b) = tmp;\n }\n \n def mergeSort(arr: Array[Card], n: Int): Unit = {\n def _mergeSort(first: Int, last: Int): Unit = {\n if (first < last) {\n val pivot = (first + last) / 2;\n val cnt1 = _mergeSort(first, pivot);\n val cnt2 = _mergeSort(pivot + 1, last);\n merge(first, last, pivot);\n }\n }\n def merge(first: Int, last: Int, pivot: Int): Unit = {\n val tmpArr = arr.slice(first, pivot + 1);\n var ptr1 = 0;\n var ptr2 = pivot + 1;\n for (i <- (first to last)) {\n if (ptr1 >= tmpArr.length) {\n ptr2 += 1;\n } else if (ptr2 > last || tmpArr(ptr1) <= arr(ptr2)) {\n arr(i) = tmpArr(ptr1);\n ptr1 += 1;\n } else {\n arr(i) = arr(ptr2);\n ptr2 += 1;\n }\n }\n }\n \n _mergeSort(0, n - 1);\n }\n}\ncase class Card(symbol: String, num: Int) {\n override def toString(): String = symbol + \" \" + num\n def <(a: Card): Boolean = this.num < a.num\n def <=(a: Card): Boolean = this.num <= a.num\n def >(a: Card): Boolean = this.num > a.num\n def >=(a: Card): Boolean = this.num >= a.num\n}\n", "problem_context": "Quick Sort\n\nLet's arrange a deck of cards. Your task is to sort totally n cards. A card consists of a part of a suit (S, H, C or D) and an number. Write a program which sorts such cards based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j]\n7 exchange A[i+1] and A[r]\n8 return i+1\n\nQuicksort(A, p, r)\n1 if p < r\n2 then q = Partition(A, p, r)\n3 run Quicksort(A, p, q-1)\n4 run Quicksort(A, q+1, r)\n\nHere, A is an array which represents a deck of cards and comparison operations are performed based on the numbers.\n\nYour program should also report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).\n\nInput\n\nThe first line contains an integer n, the number of cards.\n\nn cards are given in the following lines. Each card is given in a line and represented by a pair of a character and an integer separated by a single space.\n\nOutput\n\nIn the first line, print the stability (\"Stable\" or \"Not stable\") of this output.\n\nIn the following lines, print the arranged cards in the same manner of that of the input.\n\nConstraints\n\n1 ≤ n ≤ 100,000\n\n1 ≤ the number of a card ≤ 109\n\nThere are no identical card in the input\n\nSample Input 1\n\n6\nD 3\nH 2\nD 1\nS 3\nD 2\nC 1\n\nSample Output 1\n\nNot stable\nD 1\nC 1\nD 2\nH 2\nD 3\nS 3\n\nSample Input 2\n\n2\nS 1\nH 1\n\nSample Output 2\n\nStable\nS 1\nH 1", "sample_input": "6\nD 3\nH 2\nD 1\nS 3\nD 2\nC 1\n"}, "reference_outputs": ["Not stable\nD 1\nC 1\nD 2\nH 2\nD 3\nS 3\n"], "source_document_id": "p02277", "source_text": "Quick Sort\n\nLet's arrange a deck of cards. Your task is to sort totally n cards. A card consists of a part of a suit (S, H, C or D) and an number. Write a program which sorts such cards based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j]\n7 exchange A[i+1] and A[r]\n8 return i+1\n\nQuicksort(A, p, r)\n1 if p < r\n2 then q = Partition(A, p, r)\n3 run Quicksort(A, p, q-1)\n4 run Quicksort(A, q+1, r)\n\nHere, A is an array which represents a deck of cards and comparison operations are performed based on the numbers.\n\nYour program should also report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).\n\nInput\n\nThe first line contains an integer n, the number of cards.\n\nn cards are given in the following lines. Each card is given in a line and represented by a pair of a character and an integer separated by a single space.\n\nOutput\n\nIn the first line, print the stability (\"Stable\" or \"Not stable\") of this output.\n\nIn the following lines, print the arranged cards in the same manner of that of the input.\n\nConstraints\n\n1 ≤ n ≤ 100,000\n\n1 ≤ the number of a card ≤ 109\n\nThere are no identical card in the input\n\nSample Input 1\n\n6\nD 3\nH 2\nD 1\nS 3\nD 2\nC 1\n\nSample Output 1\n\nNot stable\nD 1\nC 1\nD 2\nH 2\nD 3\nS 3\n\nSample Input 2\n\n2\nS 1\nH 1\n\nSample Output 2\n\nStable\nS 1\nH 1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3264, "cpu_time_ms": 1200, "memory_kb": 70204}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s186171004", "group_id": "codeNet:p02279", "input_text": "object Main extends App {\n val children = collection.mutable.Map.empty[String, Array[String]]\n val parent = collection.mutable.Map.empty[String, String]\n val n = io.StdIn.readInt()\n\n for {\n _ <- 0 until n\n l = io.StdIn.readLine()split(\" \", 3)\n } l match {\n case Array(id, _) => children.put(id, Array.empty[String])\n case Array(id, _, nodes) =>\n val nodeSeq = nodes.split(\" \")\n children.put(id, nodeSeq)\n nodeSeq foreach(parent.put(_, id))\n }\n\n for (i <- 0 until n) {\n val current = i.toString\n val p = parent.get(current) match {\n case None => \"-1\"\n case Some(x) => x\n }\n def depth(s: String): Int = parent.get(s) match {\n case None => 0\n case Some(x) => depth(x)\n }\n val d = depth(current)\n val c = children(current).mkString(\"[\", \", \", \"]\")\n\n val t = if (p == \"-1\") \"root\" else if (c == \"[]\") \"leaf\" else \"internal node\"\n\n println(s\"node $i: parent = $p, depth = $d, $t, $c\")\n }\n}", "language": "Scala", "metadata": {"date": 1510895863, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02279.html", "problem_id": "p02279", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02279/input.txt", "sample_output_relpath": "derived/input_output/data/p02279/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02279/Scala/s186171004.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s186171004", "user_id": "u995793569"}, "prompt_components": {"gold_output": "node 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n", "input_to_evaluate": "object Main extends App {\n val children = collection.mutable.Map.empty[String, Array[String]]\n val parent = collection.mutable.Map.empty[String, String]\n val n = io.StdIn.readInt()\n\n for {\n _ <- 0 until n\n l = io.StdIn.readLine()split(\" \", 3)\n } l match {\n case Array(id, _) => children.put(id, Array.empty[String])\n case Array(id, _, nodes) =>\n val nodeSeq = nodes.split(\" \")\n children.put(id, nodeSeq)\n nodeSeq foreach(parent.put(_, id))\n }\n\n for (i <- 0 until n) {\n val current = i.toString\n val p = parent.get(current) match {\n case None => \"-1\"\n case Some(x) => x\n }\n def depth(s: String): Int = parent.get(s) match {\n case None => 0\n case Some(x) => depth(x)\n }\n val d = depth(current)\n val c = children(current).mkString(\"[\", \", \", \"]\")\n\n val t = if (p == \"-1\") \"root\" else if (c == \"[]\") \"leaf\" else \"internal node\"\n\n println(s\"node $i: parent = $p, depth = $d, $t, $c\")\n }\n}", "problem_context": "Rooted Trees\n\nA graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs).\n\nFig. 1\n\nA free tree is a connnected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called \"node.\"\n\nYour task is to write a program which reports the following information for each node u of a given rooted tree T:\n\nnode ID of u\n\nparent of u\n\ndepth of u\n\nnode type (root, internal node or leaf)\n\na list of chidlren of u\n\nIf the last edge on the path from the root r of a tree T to a node x is (p, x), then p is the parent of x, and x is a child of p. The root is the only node in T with no parent.\n\nA node with no children is an external node or leaf. A nonleaf node is an internal node\n\nThe number of children of a node x in a rooted tree T is called the degree of x.\n\nThe length of the path from the root r to a node x is the depth of x in T.\n\nHere, the given tree consists of n nodes and evey node has a unique ID from 0 to n-1.\n\nFig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input.\n\nFig. 2\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node u is given in the following format:\n\nid k c1 c2 ... ck\n\nwhere id is the node ID of u, k is the degree of u, c1 ... ck are node IDs of 1st, ... kth child of u. If the node does not have a child, the k is 0.\n\nOutput\n\nPrint the information of each node in the following format ordered by IDs:\n\nnode id: parent = p, depth = d, type, [c1...ck]\n\np is ID of its parent. If the node does not have a parent, print -1.\n\nd is depth of the node.\n\ntype is a type of nodes represented by a string (root, internal node or leaf). If the root can be considered as a leaf or an internal node, print root.\n\nc1...ck is the list of children as a ordered tree.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\nSample Input 1\n\n13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n\nSample Output 1\n\nnode 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n\nSample Input 2\n\n4\n1 3 3 2 0\n0 0\n3 0\n2 0\n\nSample Output 2\n\nnode 0: parent = 1, depth = 1, leaf, []\nnode 1: parent = -1, depth = 0, root, [3, 2, 0]\nnode 2: parent = 1, depth = 1, leaf, []\nnode 3: parent = 1, depth = 1, leaf, []\n\nNote\n\nYou can use a left-child, right-sibling representation to implement a tree which has the following data:\n\nthe parent of u\n\nthe leftmost child of u\n\nthe immediate right sibling of u\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n"}, "reference_outputs": ["node 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n"], "source_document_id": "p02279", "source_text": "Rooted Trees\n\nA graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs).\n\nFig. 1\n\nA free tree is a connnected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called \"node.\"\n\nYour task is to write a program which reports the following information for each node u of a given rooted tree T:\n\nnode ID of u\n\nparent of u\n\ndepth of u\n\nnode type (root, internal node or leaf)\n\na list of chidlren of u\n\nIf the last edge on the path from the root r of a tree T to a node x is (p, x), then p is the parent of x, and x is a child of p. The root is the only node in T with no parent.\n\nA node with no children is an external node or leaf. A nonleaf node is an internal node\n\nThe number of children of a node x in a rooted tree T is called the degree of x.\n\nThe length of the path from the root r to a node x is the depth of x in T.\n\nHere, the given tree consists of n nodes and evey node has a unique ID from 0 to n-1.\n\nFig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input.\n\nFig. 2\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node u is given in the following format:\n\nid k c1 c2 ... ck\n\nwhere id is the node ID of u, k is the degree of u, c1 ... ck are node IDs of 1st, ... kth child of u. If the node does not have a child, the k is 0.\n\nOutput\n\nPrint the information of each node in the following format ordered by IDs:\n\nnode id: parent = p, depth = d, type, [c1...ck]\n\np is ID of its parent. If the node does not have a parent, print -1.\n\nd is depth of the node.\n\ntype is a type of nodes represented by a string (root, internal node or leaf). If the root can be considered as a leaf or an internal node, print root.\n\nc1...ck is the list of children as a ordered tree.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\nSample Input 1\n\n13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n\nSample Output 1\n\nnode 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n\nSample Input 2\n\n4\n1 3 3 2 0\n0 0\n3 0\n2 0\n\nSample Output 2\n\nnode 0: parent = 1, depth = 1, leaf, []\nnode 1: parent = -1, depth = 0, root, [3, 2, 0]\nnode 2: parent = 1, depth = 1, leaf, []\nnode 3: parent = 1, depth = 1, leaf, []\n\nNote\n\nYou can use a left-child, right-sibling representation to implement a tree which has the following data:\n\nthe parent of u\n\nthe leftmost child of u\n\nthe immediate right sibling of u\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 965, "cpu_time_ms": 230, "memory_kb": 43904}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s457866635", "group_id": "codeNet:p02280", "input_text": "import scala.collection.mutable\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val n: Int = io.StdIn.readInt()\n val children = Array.fill(n)(Seq(-1,-1))\n val parent: Array[Option[Int]] = Array.fill(n)(None)\n\n for {\n _ <- 0 until n\n l = io.StdIn.readLine()\n } {\n val Seq(i, c1, c2): Seq[Int] = l.split(\" \", 3).map(_.toInt)\n children(i) = Seq(c1, c2)\n if (c1 != -1) parent(c1) = Some(i)\n if (c2 != -1) parent(c2) = Some(i)\n }\n\n def depth: Memoized[Int, Int] = Memoized {i =>\n parent(i) match {\n case None => 0\n case Some(x) => 1 + depth(x)\n }\n }\n def hight: Memoized[Int, Int] = Memoized {i =>\n children(i) match {\n case Seq(-1, -1) => 0\n case Seq(x, -1) => 1 + hight(x)\n case Seq(-1, y) => 1 + hight(y)\n case Seq(x, y) => 1 + (hight(x) max hight(y))\n }\n }\n\n for (i <- 0 until n) {\n val p = parent(i).getOrElse(-1)\n val s: Int = if (p == -1) -1 else children(p).filterNot(_ == i).head\n val deg: Int = children(i).filterNot(_ == -1).length\n val t = if (p == -1) \"root\" else if (deg == 0) \"leaf\" else \"internal node\"\n\n println(s\"node $i: parent = $p, sibling = $s, degree = $deg, depth = ${depth(i)}, height = ${hight(i)}, $t\")\n }\n }\n\n case class Memoized[Arg, Ret](f: Arg => Ret) extends (Arg => Ret) {\n val cache: mutable.Map[Arg, Ret] = mutable.Map[Arg, Ret]()\n def apply(arg: Arg): Ret = cache.getOrElseUpdate(arg, f(arg))\n\n }\n}", "language": "Scala", "metadata": {"date": 1511189481, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02280.html", "problem_id": "p02280", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02280/input.txt", "sample_output_relpath": "derived/input_output/data/p02280/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02280/Scala/s457866635.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s457866635", "user_id": "u995793569"}, "prompt_components": {"gold_output": "node 0: parent = -1, sibling = -1, degree = 2, depth = 0, height = 3, root\nnode 1: parent = 0, sibling = 4, degree = 2, depth = 1, height = 1, internal node\nnode 2: parent = 1, sibling = 3, degree = 0, depth = 2, height = 0, leaf\nnode 3: parent = 1, sibling = 2, degree = 0, depth = 2, height = 0, leaf\nnode 4: parent = 0, sibling = 1, degree = 2, depth = 1, height = 2, internal node\nnode 5: parent = 4, sibling = 8, degree = 2, depth = 2, height = 1, internal node\nnode 6: parent = 5, sibling = 7, degree = 0, depth = 3, height = 0, leaf\nnode 7: parent = 5, sibling = 6, degree = 0, depth = 3, height = 0, leaf\nnode 8: parent = 4, sibling = 5, degree = 0, depth = 2, height = 0, leaf\n", "input_to_evaluate": "import scala.collection.mutable\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val n: Int = io.StdIn.readInt()\n val children = Array.fill(n)(Seq(-1,-1))\n val parent: Array[Option[Int]] = Array.fill(n)(None)\n\n for {\n _ <- 0 until n\n l = io.StdIn.readLine()\n } {\n val Seq(i, c1, c2): Seq[Int] = l.split(\" \", 3).map(_.toInt)\n children(i) = Seq(c1, c2)\n if (c1 != -1) parent(c1) = Some(i)\n if (c2 != -1) parent(c2) = Some(i)\n }\n\n def depth: Memoized[Int, Int] = Memoized {i =>\n parent(i) match {\n case None => 0\n case Some(x) => 1 + depth(x)\n }\n }\n def hight: Memoized[Int, Int] = Memoized {i =>\n children(i) match {\n case Seq(-1, -1) => 0\n case Seq(x, -1) => 1 + hight(x)\n case Seq(-1, y) => 1 + hight(y)\n case Seq(x, y) => 1 + (hight(x) max hight(y))\n }\n }\n\n for (i <- 0 until n) {\n val p = parent(i).getOrElse(-1)\n val s: Int = if (p == -1) -1 else children(p).filterNot(_ == i).head\n val deg: Int = children(i).filterNot(_ == -1).length\n val t = if (p == -1) \"root\" else if (deg == 0) \"leaf\" else \"internal node\"\n\n println(s\"node $i: parent = $p, sibling = $s, degree = $deg, depth = ${depth(i)}, height = ${hight(i)}, $t\")\n }\n }\n\n case class Memoized[Arg, Ret](f: Arg => Ret) extends (Arg => Ret) {\n val cache: mutable.Map[Arg, Ret] = mutable.Map[Arg, Ret]()\n def apply(arg: Arg): Ret = cache.getOrElseUpdate(arg, f(arg))\n\n }\n}", "problem_context": "Binary Tree\n\nA rooted binary tree is a tree with a root node in which every node has at most two children.\n\nYour task is to write a program which reads a rooted binary tree T and prints the following information for each node u of T:\n\nnode ID of u\n\nparent of u\n\nsibling of u\n\nthe number of children of u\n\ndepth of u\n\nheight of u\n\nnode type (root, internal node or leaf)\n\nIf two nodes have the same parent, they are siblings. Here, if u and v have the same parent, we say u is a sibling of v (vice versa).\n\nThe height of a node in a tree is the number of edges on the longest simple downward path from the node to a leaf.\n\nHere, the given binary tree consists of n nodes and evey node has a unique ID from 0 to n-1.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node is given in the following format:\n\nid left right\n\nid is the node ID, left is ID of the left child and right is ID of the right child. If the node does not have the left (right) child, the left(right) is indicated by -1.\n\nOutput\n\nPrint the information of each node in the following format:\n\nnode id: parent = p, sibling = s, degree = deg, depth = dep, height = h, type\n\np is ID of its parent. If the node does not have a parent, print -1.\n\ns is ID of its sibling. If the node does not have a sibling, print -1.\n\ndeg, dep and h are the number of children, depth and height of the node respectively.\n\ntype is a type of nodes represented by a string (root, internal node or leaf. If the root can be considered as a leaf or an internal node, print root.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 ≤ n ≤ 25\n\nSample Input 1\n\n9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n\nSample Output 1\n\nnode 0: parent = -1, sibling = -1, degree = 2, depth = 0, height = 3, root\nnode 1: parent = 0, sibling = 4, degree = 2, depth = 1, height = 1, internal node\nnode 2: parent = 1, sibling = 3, degree = 0, depth = 2, height = 0, leaf\nnode 3: parent = 1, sibling = 2, degree = 0, depth = 2, height = 0, leaf\nnode 4: parent = 0, sibling = 1, degree = 2, depth = 1, height = 2, internal node\nnode 5: parent = 4, sibling = 8, degree = 2, depth = 2, height = 1, internal node\nnode 6: parent = 5, sibling = 7, degree = 0, depth = 3, height = 0, leaf\nnode 7: parent = 5, sibling = 6, degree = 0, depth = 3, height = 0, leaf\nnode 8: parent = 4, sibling = 5, degree = 0, depth = 2, height = 0, leaf\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n"}, "reference_outputs": ["node 0: parent = -1, sibling = -1, degree = 2, depth = 0, height = 3, root\nnode 1: parent = 0, sibling = 4, degree = 2, depth = 1, height = 1, internal node\nnode 2: parent = 1, sibling = 3, degree = 0, depth = 2, height = 0, leaf\nnode 3: parent = 1, sibling = 2, degree = 0, depth = 2, height = 0, leaf\nnode 4: parent = 0, sibling = 1, degree = 2, depth = 1, height = 2, internal node\nnode 5: parent = 4, sibling = 8, degree = 2, depth = 2, height = 1, internal node\nnode 6: parent = 5, sibling = 7, degree = 0, depth = 3, height = 0, leaf\nnode 7: parent = 5, sibling = 6, degree = 0, depth = 3, height = 0, leaf\nnode 8: parent = 4, sibling = 5, degree = 0, depth = 2, height = 0, leaf\n"], "source_document_id": "p02280", "source_text": "Binary Tree\n\nA rooted binary tree is a tree with a root node in which every node has at most two children.\n\nYour task is to write a program which reads a rooted binary tree T and prints the following information for each node u of T:\n\nnode ID of u\n\nparent of u\n\nsibling of u\n\nthe number of children of u\n\ndepth of u\n\nheight of u\n\nnode type (root, internal node or leaf)\n\nIf two nodes have the same parent, they are siblings. Here, if u and v have the same parent, we say u is a sibling of v (vice versa).\n\nThe height of a node in a tree is the number of edges on the longest simple downward path from the node to a leaf.\n\nHere, the given binary tree consists of n nodes and evey node has a unique ID from 0 to n-1.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node is given in the following format:\n\nid left right\n\nid is the node ID, left is ID of the left child and right is ID of the right child. If the node does not have the left (right) child, the left(right) is indicated by -1.\n\nOutput\n\nPrint the information of each node in the following format:\n\nnode id: parent = p, sibling = s, degree = deg, depth = dep, height = h, type\n\np is ID of its parent. If the node does not have a parent, print -1.\n\ns is ID of its sibling. If the node does not have a sibling, print -1.\n\ndeg, dep and h are the number of children, depth and height of the node respectively.\n\ntype is a type of nodes represented by a string (root, internal node or leaf. If the root can be considered as a leaf or an internal node, print root.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 ≤ n ≤ 25\n\nSample Input 1\n\n9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n\nSample Output 1\n\nnode 0: parent = -1, sibling = -1, degree = 2, depth = 0, height = 3, root\nnode 1: parent = 0, sibling = 4, degree = 2, depth = 1, height = 1, internal node\nnode 2: parent = 1, sibling = 3, degree = 0, depth = 2, height = 0, leaf\nnode 3: parent = 1, sibling = 2, degree = 0, depth = 2, height = 0, leaf\nnode 4: parent = 0, sibling = 1, degree = 2, depth = 1, height = 2, internal node\nnode 5: parent = 4, sibling = 8, degree = 2, depth = 2, height = 1, internal node\nnode 6: parent = 5, sibling = 7, degree = 0, depth = 3, height = 0, leaf\nnode 7: parent = 5, sibling = 6, degree = 0, depth = 3, height = 0, leaf\nnode 8: parent = 4, sibling = 5, degree = 0, depth = 2, height = 0, leaf\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1505, "cpu_time_ms": 250, "memory_kb": 44388}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s036624438", "group_id": "codeNet:p02280", "input_text": "import scala.io.StdIn.{ readLine, readInt };\nobject Main {\n def main(args: Array[String]): Unit = {\n val n = readInt;\n val l = (0 until n).map{ a => \n readLine.split(\" \") match {\n case Array(v, l, r) => Some((v.toInt, l.toInt, r.toInt));\n case _ => None;\n }\n }.toList\n val bTree = new BinaryTrees(n);\n bTree.build(l);\n bTree.dump();\n }\n}\nclass BinaryTrees(len: Int) {\n case class Node(left: Int, right: Int)\n var root = -1;\n val tree = new Array[Node](len);\n def build(data: List[Option[(Int, Int, Int)]]): Unit = data match {\n case Some((value, left, right)) :: xs =>\n tree(value) = Node(left, right);\n if (root == -1 || left == root || right == root) root = value;\n build(xs);\n case x :: xs => build(xs);\n case Nil => ()\n }\n def dump(): Unit = {\n val dumpArr = new Array[String](len);\n def _dump(curr: Int, parent: Int, sibling: Int, depth: Int): Unit = {\n if (curr == -1) {\n // nop\n } else {\n val degree = getDegree(curr);\n val nodeType = getNodeType(curr, parent);\n val height = getHeight(curr);\n dumpArr(curr) = nodeToString(curr, parent, sibling, degree, depth, height, nodeType);\n _dump(tree(curr).left, curr, tree(curr).right, depth + 1);\n _dump(tree(curr).right, curr, tree(curr).left, depth + 1);\n }\n }\n _dump(root, -1, -1, 0);\n println(dumpArr.mkString(\"\\n\"));\n }\n def getHeight(curr: Int): Int = {\n if (curr == -1) {\n -1;\n } else {\n val leftHeight = getHeight(tree(curr).left);\n val rightHeight = getHeight(tree(curr).right);\n if (leftHeight < rightHeight) rightHeight + 1 else leftHeight + 1;\n }\n }\n def nodeToString(curr: Int, parent: Int, sibling: Int, degree: Int, depth: Int, height: Int, nodeType: String): String = {\n s\"node ${curr}: parent = ${parent}, sibling = ${sibling}, degree = ${degree}, depth = ${depth}, height = ${height}, ${nodeType}\";\n }\n def getDegree(v: Int): Int = {\n val n = tree(v);\n var ret = 2;\n if (n.left == -1) ret -= 1;\n if (n.right == -1) ret -= 1;\n ret;\n }\n def getNodeType(v: Int, parent: Int): String = {\n if (parent == -1) \"root\" else if (tree(v).left == -1 && tree(v).right == -1) \"leaf\" else \"internal node\";\n }\n}\n", "language": "Scala", "metadata": {"date": 1519358907, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02280.html", "problem_id": "p02280", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02280/input.txt", "sample_output_relpath": "derived/input_output/data/p02280/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02280/Scala/s036624438.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s036624438", "user_id": "u909989059"}, "prompt_components": {"gold_output": "node 0: parent = -1, sibling = -1, degree = 2, depth = 0, height = 3, root\nnode 1: parent = 0, sibling = 4, degree = 2, depth = 1, height = 1, internal node\nnode 2: parent = 1, sibling = 3, degree = 0, depth = 2, height = 0, leaf\nnode 3: parent = 1, sibling = 2, degree = 0, depth = 2, height = 0, leaf\nnode 4: parent = 0, sibling = 1, degree = 2, depth = 1, height = 2, internal node\nnode 5: parent = 4, sibling = 8, degree = 2, depth = 2, height = 1, internal node\nnode 6: parent = 5, sibling = 7, degree = 0, depth = 3, height = 0, leaf\nnode 7: parent = 5, sibling = 6, degree = 0, depth = 3, height = 0, leaf\nnode 8: parent = 4, sibling = 5, degree = 0, depth = 2, height = 0, leaf\n", "input_to_evaluate": "import scala.io.StdIn.{ readLine, readInt };\nobject Main {\n def main(args: Array[String]): Unit = {\n val n = readInt;\n val l = (0 until n).map{ a => \n readLine.split(\" \") match {\n case Array(v, l, r) => Some((v.toInt, l.toInt, r.toInt));\n case _ => None;\n }\n }.toList\n val bTree = new BinaryTrees(n);\n bTree.build(l);\n bTree.dump();\n }\n}\nclass BinaryTrees(len: Int) {\n case class Node(left: Int, right: Int)\n var root = -1;\n val tree = new Array[Node](len);\n def build(data: List[Option[(Int, Int, Int)]]): Unit = data match {\n case Some((value, left, right)) :: xs =>\n tree(value) = Node(left, right);\n if (root == -1 || left == root || right == root) root = value;\n build(xs);\n case x :: xs => build(xs);\n case Nil => ()\n }\n def dump(): Unit = {\n val dumpArr = new Array[String](len);\n def _dump(curr: Int, parent: Int, sibling: Int, depth: Int): Unit = {\n if (curr == -1) {\n // nop\n } else {\n val degree = getDegree(curr);\n val nodeType = getNodeType(curr, parent);\n val height = getHeight(curr);\n dumpArr(curr) = nodeToString(curr, parent, sibling, degree, depth, height, nodeType);\n _dump(tree(curr).left, curr, tree(curr).right, depth + 1);\n _dump(tree(curr).right, curr, tree(curr).left, depth + 1);\n }\n }\n _dump(root, -1, -1, 0);\n println(dumpArr.mkString(\"\\n\"));\n }\n def getHeight(curr: Int): Int = {\n if (curr == -1) {\n -1;\n } else {\n val leftHeight = getHeight(tree(curr).left);\n val rightHeight = getHeight(tree(curr).right);\n if (leftHeight < rightHeight) rightHeight + 1 else leftHeight + 1;\n }\n }\n def nodeToString(curr: Int, parent: Int, sibling: Int, degree: Int, depth: Int, height: Int, nodeType: String): String = {\n s\"node ${curr}: parent = ${parent}, sibling = ${sibling}, degree = ${degree}, depth = ${depth}, height = ${height}, ${nodeType}\";\n }\n def getDegree(v: Int): Int = {\n val n = tree(v);\n var ret = 2;\n if (n.left == -1) ret -= 1;\n if (n.right == -1) ret -= 1;\n ret;\n }\n def getNodeType(v: Int, parent: Int): String = {\n if (parent == -1) \"root\" else if (tree(v).left == -1 && tree(v).right == -1) \"leaf\" else \"internal node\";\n }\n}\n", "problem_context": "Binary Tree\n\nA rooted binary tree is a tree with a root node in which every node has at most two children.\n\nYour task is to write a program which reads a rooted binary tree T and prints the following information for each node u of T:\n\nnode ID of u\n\nparent of u\n\nsibling of u\n\nthe number of children of u\n\ndepth of u\n\nheight of u\n\nnode type (root, internal node or leaf)\n\nIf two nodes have the same parent, they are siblings. Here, if u and v have the same parent, we say u is a sibling of v (vice versa).\n\nThe height of a node in a tree is the number of edges on the longest simple downward path from the node to a leaf.\n\nHere, the given binary tree consists of n nodes and evey node has a unique ID from 0 to n-1.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node is given in the following format:\n\nid left right\n\nid is the node ID, left is ID of the left child and right is ID of the right child. If the node does not have the left (right) child, the left(right) is indicated by -1.\n\nOutput\n\nPrint the information of each node in the following format:\n\nnode id: parent = p, sibling = s, degree = deg, depth = dep, height = h, type\n\np is ID of its parent. If the node does not have a parent, print -1.\n\ns is ID of its sibling. If the node does not have a sibling, print -1.\n\ndeg, dep and h are the number of children, depth and height of the node respectively.\n\ntype is a type of nodes represented by a string (root, internal node or leaf. If the root can be considered as a leaf or an internal node, print root.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 ≤ n ≤ 25\n\nSample Input 1\n\n9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n\nSample Output 1\n\nnode 0: parent = -1, sibling = -1, degree = 2, depth = 0, height = 3, root\nnode 1: parent = 0, sibling = 4, degree = 2, depth = 1, height = 1, internal node\nnode 2: parent = 1, sibling = 3, degree = 0, depth = 2, height = 0, leaf\nnode 3: parent = 1, sibling = 2, degree = 0, depth = 2, height = 0, leaf\nnode 4: parent = 0, sibling = 1, degree = 2, depth = 1, height = 2, internal node\nnode 5: parent = 4, sibling = 8, degree = 2, depth = 2, height = 1, internal node\nnode 6: parent = 5, sibling = 7, degree = 0, depth = 3, height = 0, leaf\nnode 7: parent = 5, sibling = 6, degree = 0, depth = 3, height = 0, leaf\nnode 8: parent = 4, sibling = 5, degree = 0, depth = 2, height = 0, leaf\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n"}, "reference_outputs": ["node 0: parent = -1, sibling = -1, degree = 2, depth = 0, height = 3, root\nnode 1: parent = 0, sibling = 4, degree = 2, depth = 1, height = 1, internal node\nnode 2: parent = 1, sibling = 3, degree = 0, depth = 2, height = 0, leaf\nnode 3: parent = 1, sibling = 2, degree = 0, depth = 2, height = 0, leaf\nnode 4: parent = 0, sibling = 1, degree = 2, depth = 1, height = 2, internal node\nnode 5: parent = 4, sibling = 8, degree = 2, depth = 2, height = 1, internal node\nnode 6: parent = 5, sibling = 7, degree = 0, depth = 3, height = 0, leaf\nnode 7: parent = 5, sibling = 6, degree = 0, depth = 3, height = 0, leaf\nnode 8: parent = 4, sibling = 5, degree = 0, depth = 2, height = 0, leaf\n"], "source_document_id": "p02280", "source_text": "Binary Tree\n\nA rooted binary tree is a tree with a root node in which every node has at most two children.\n\nYour task is to write a program which reads a rooted binary tree T and prints the following information for each node u of T:\n\nnode ID of u\n\nparent of u\n\nsibling of u\n\nthe number of children of u\n\ndepth of u\n\nheight of u\n\nnode type (root, internal node or leaf)\n\nIf two nodes have the same parent, they are siblings. Here, if u and v have the same parent, we say u is a sibling of v (vice versa).\n\nThe height of a node in a tree is the number of edges on the longest simple downward path from the node to a leaf.\n\nHere, the given binary tree consists of n nodes and evey node has a unique ID from 0 to n-1.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node is given in the following format:\n\nid left right\n\nid is the node ID, left is ID of the left child and right is ID of the right child. If the node does not have the left (right) child, the left(right) is indicated by -1.\n\nOutput\n\nPrint the information of each node in the following format:\n\nnode id: parent = p, sibling = s, degree = deg, depth = dep, height = h, type\n\np is ID of its parent. If the node does not have a parent, print -1.\n\ns is ID of its sibling. If the node does not have a sibling, print -1.\n\ndeg, dep and h are the number of children, depth and height of the node respectively.\n\ntype is a type of nodes represented by a string (root, internal node or leaf. If the root can be considered as a leaf or an internal node, print root.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 ≤ n ≤ 25\n\nSample Input 1\n\n9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n\nSample Output 1\n\nnode 0: parent = -1, sibling = -1, degree = 2, depth = 0, height = 3, root\nnode 1: parent = 0, sibling = 4, degree = 2, depth = 1, height = 1, internal node\nnode 2: parent = 1, sibling = 3, degree = 0, depth = 2, height = 0, leaf\nnode 3: parent = 1, sibling = 2, degree = 0, depth = 2, height = 0, leaf\nnode 4: parent = 0, sibling = 1, degree = 2, depth = 1, height = 2, internal node\nnode 5: parent = 4, sibling = 8, degree = 2, depth = 2, height = 1, internal node\nnode 6: parent = 5, sibling = 7, degree = 0, depth = 3, height = 0, leaf\nnode 7: parent = 5, sibling = 6, degree = 0, depth = 3, height = 0, leaf\nnode 8: parent = 4, sibling = 5, degree = 0, depth = 2, height = 0, leaf\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2551, "cpu_time_ms": 240, "memory_kb": 43848}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s657688739", "group_id": "codeNet:p02280", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n\n final val nil = -1\n \n case class Node(var parent: Int = -1,var left: Int = -1, var right: Int = -1){\n \n def typeInfo: String = if(parent == -1) {\n \"root\"\n } else if(left == nil && right == nil) {\n \"leaf\"\n } else {\n \"internal node\"\n }\n \n def nodeLiteral(depth: Int, sibling: Int, height: Int): String = {\n val degree = (if(left == nil) 0 else 1) + (if(right == nil) 0 else 1)\n s\"parent = $parent, sibling = $sibling, degree = $degree, depth = $depth, height = $height, $typeInfo\"\n }\n override def toString: String = s\"parent = $parent, depth = X, $typeInfo, [child]\"\n \n }\n\n def setDepth(index: Int, cnt: Int): Unit = {\n //println(\"setDepth:\" + index)\n depth(index) = cnt\n if(input(index).right != nil){ \n setDepth(input(index).right, cnt + 1)\n }\n if(input(index).left != nil){ \n setDepth(input(index).left, cnt + 1)\n }\n }\n \n def setHeight(index: Int): Int = {\n //println(\"setDepth:\" + index)\n val h1 = if(input(index).right != nil){\n setHeight(input(index).right) + 1\n } else 0\n val h2 = if(input(index).left != nil){\n setHeight(input(index).left) + 1\n } else 0\n height(index) = scala.math.max(h1, h2)\n height(index)\n }\n \n def getChild(index: Int): Array[Int] = (input(index).left, input(index).right) match {\n case (-1, -1) => Array.empty[Int]\n case (left, -1) => Array(left)\n case (-1, right) => Array(right)\n case (left, right) => Array(left, right)\n }\n \n val n = StdIn.readLine().trim.toInt\n val input = Array.fill[Node](n)(Node())\n val depth = Array.fill[Int](n)(0)\n val height = Array.fill[Int](n)(0)\n\n (0 until n).foreach{ _ =>\n val Array(current, left, right) = StdIn.readLine().trim.split(\" \").map(_.toInt)\n input(current).left = left\n input(current).right = right\n if(left != nil) input(left).parent = current\n if(right != nil) input(right).parent = current\n }\n\n var root = nil\n (0 until n).foreach{ i =>\n //println(s\"$i:\" + input(i))\n if(input(i).parent == nil) root = i\n }\n \n setDepth(root, 0)\n setHeight(root)\n \n (0 until n).foreach{ i =>\n val ch = getChild(i)\n val parent = input(i).parent\n val sibling = if(parent != nil){\n if(input(parent).left == i) input(parent).right\n else input(parent).left\n } else -1\n \n println(s\"node $i: \" + input(i).nodeLiteral(depth(i), sibling, height(i)))\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1523573080, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02280.html", "problem_id": "p02280", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02280/input.txt", "sample_output_relpath": "derived/input_output/data/p02280/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02280/Scala/s657688739.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s657688739", "user_id": "u342234782"}, "prompt_components": {"gold_output": "node 0: parent = -1, sibling = -1, degree = 2, depth = 0, height = 3, root\nnode 1: parent = 0, sibling = 4, degree = 2, depth = 1, height = 1, internal node\nnode 2: parent = 1, sibling = 3, degree = 0, depth = 2, height = 0, leaf\nnode 3: parent = 1, sibling = 2, degree = 0, depth = 2, height = 0, leaf\nnode 4: parent = 0, sibling = 1, degree = 2, depth = 1, height = 2, internal node\nnode 5: parent = 4, sibling = 8, degree = 2, depth = 2, height = 1, internal node\nnode 6: parent = 5, sibling = 7, degree = 0, depth = 3, height = 0, leaf\nnode 7: parent = 5, sibling = 6, degree = 0, depth = 3, height = 0, leaf\nnode 8: parent = 4, sibling = 5, degree = 0, depth = 2, height = 0, leaf\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n\n final val nil = -1\n \n case class Node(var parent: Int = -1,var left: Int = -1, var right: Int = -1){\n \n def typeInfo: String = if(parent == -1) {\n \"root\"\n } else if(left == nil && right == nil) {\n \"leaf\"\n } else {\n \"internal node\"\n }\n \n def nodeLiteral(depth: Int, sibling: Int, height: Int): String = {\n val degree = (if(left == nil) 0 else 1) + (if(right == nil) 0 else 1)\n s\"parent = $parent, sibling = $sibling, degree = $degree, depth = $depth, height = $height, $typeInfo\"\n }\n override def toString: String = s\"parent = $parent, depth = X, $typeInfo, [child]\"\n \n }\n\n def setDepth(index: Int, cnt: Int): Unit = {\n //println(\"setDepth:\" + index)\n depth(index) = cnt\n if(input(index).right != nil){ \n setDepth(input(index).right, cnt + 1)\n }\n if(input(index).left != nil){ \n setDepth(input(index).left, cnt + 1)\n }\n }\n \n def setHeight(index: Int): Int = {\n //println(\"setDepth:\" + index)\n val h1 = if(input(index).right != nil){\n setHeight(input(index).right) + 1\n } else 0\n val h2 = if(input(index).left != nil){\n setHeight(input(index).left) + 1\n } else 0\n height(index) = scala.math.max(h1, h2)\n height(index)\n }\n \n def getChild(index: Int): Array[Int] = (input(index).left, input(index).right) match {\n case (-1, -1) => Array.empty[Int]\n case (left, -1) => Array(left)\n case (-1, right) => Array(right)\n case (left, right) => Array(left, right)\n }\n \n val n = StdIn.readLine().trim.toInt\n val input = Array.fill[Node](n)(Node())\n val depth = Array.fill[Int](n)(0)\n val height = Array.fill[Int](n)(0)\n\n (0 until n).foreach{ _ =>\n val Array(current, left, right) = StdIn.readLine().trim.split(\" \").map(_.toInt)\n input(current).left = left\n input(current).right = right\n if(left != nil) input(left).parent = current\n if(right != nil) input(right).parent = current\n }\n\n var root = nil\n (0 until n).foreach{ i =>\n //println(s\"$i:\" + input(i))\n if(input(i).parent == nil) root = i\n }\n \n setDepth(root, 0)\n setHeight(root)\n \n (0 until n).foreach{ i =>\n val ch = getChild(i)\n val parent = input(i).parent\n val sibling = if(parent != nil){\n if(input(parent).left == i) input(parent).right\n else input(parent).left\n } else -1\n \n println(s\"node $i: \" + input(i).nodeLiteral(depth(i), sibling, height(i)))\n }\n\n}\n", "problem_context": "Binary Tree\n\nA rooted binary tree is a tree with a root node in which every node has at most two children.\n\nYour task is to write a program which reads a rooted binary tree T and prints the following information for each node u of T:\n\nnode ID of u\n\nparent of u\n\nsibling of u\n\nthe number of children of u\n\ndepth of u\n\nheight of u\n\nnode type (root, internal node or leaf)\n\nIf two nodes have the same parent, they are siblings. Here, if u and v have the same parent, we say u is a sibling of v (vice versa).\n\nThe height of a node in a tree is the number of edges on the longest simple downward path from the node to a leaf.\n\nHere, the given binary tree consists of n nodes and evey node has a unique ID from 0 to n-1.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node is given in the following format:\n\nid left right\n\nid is the node ID, left is ID of the left child and right is ID of the right child. If the node does not have the left (right) child, the left(right) is indicated by -1.\n\nOutput\n\nPrint the information of each node in the following format:\n\nnode id: parent = p, sibling = s, degree = deg, depth = dep, height = h, type\n\np is ID of its parent. If the node does not have a parent, print -1.\n\ns is ID of its sibling. If the node does not have a sibling, print -1.\n\ndeg, dep and h are the number of children, depth and height of the node respectively.\n\ntype is a type of nodes represented by a string (root, internal node or leaf. If the root can be considered as a leaf or an internal node, print root.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 ≤ n ≤ 25\n\nSample Input 1\n\n9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n\nSample Output 1\n\nnode 0: parent = -1, sibling = -1, degree = 2, depth = 0, height = 3, root\nnode 1: parent = 0, sibling = 4, degree = 2, depth = 1, height = 1, internal node\nnode 2: parent = 1, sibling = 3, degree = 0, depth = 2, height = 0, leaf\nnode 3: parent = 1, sibling = 2, degree = 0, depth = 2, height = 0, leaf\nnode 4: parent = 0, sibling = 1, degree = 2, depth = 1, height = 2, internal node\nnode 5: parent = 4, sibling = 8, degree = 2, depth = 2, height = 1, internal node\nnode 6: parent = 5, sibling = 7, degree = 0, depth = 3, height = 0, leaf\nnode 7: parent = 5, sibling = 6, degree = 0, depth = 3, height = 0, leaf\nnode 8: parent = 4, sibling = 5, degree = 0, depth = 2, height = 0, leaf\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n"}, "reference_outputs": ["node 0: parent = -1, sibling = -1, degree = 2, depth = 0, height = 3, root\nnode 1: parent = 0, sibling = 4, degree = 2, depth = 1, height = 1, internal node\nnode 2: parent = 1, sibling = 3, degree = 0, depth = 2, height = 0, leaf\nnode 3: parent = 1, sibling = 2, degree = 0, depth = 2, height = 0, leaf\nnode 4: parent = 0, sibling = 1, degree = 2, depth = 1, height = 2, internal node\nnode 5: parent = 4, sibling = 8, degree = 2, depth = 2, height = 1, internal node\nnode 6: parent = 5, sibling = 7, degree = 0, depth = 3, height = 0, leaf\nnode 7: parent = 5, sibling = 6, degree = 0, depth = 3, height = 0, leaf\nnode 8: parent = 4, sibling = 5, degree = 0, depth = 2, height = 0, leaf\n"], "source_document_id": "p02280", "source_text": "Binary Tree\n\nA rooted binary tree is a tree with a root node in which every node has at most two children.\n\nYour task is to write a program which reads a rooted binary tree T and prints the following information for each node u of T:\n\nnode ID of u\n\nparent of u\n\nsibling of u\n\nthe number of children of u\n\ndepth of u\n\nheight of u\n\nnode type (root, internal node or leaf)\n\nIf two nodes have the same parent, they are siblings. Here, if u and v have the same parent, we say u is a sibling of v (vice versa).\n\nThe height of a node in a tree is the number of edges on the longest simple downward path from the node to a leaf.\n\nHere, the given binary tree consists of n nodes and evey node has a unique ID from 0 to n-1.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node is given in the following format:\n\nid left right\n\nid is the node ID, left is ID of the left child and right is ID of the right child. If the node does not have the left (right) child, the left(right) is indicated by -1.\n\nOutput\n\nPrint the information of each node in the following format:\n\nnode id: parent = p, sibling = s, degree = deg, depth = dep, height = h, type\n\np is ID of its parent. If the node does not have a parent, print -1.\n\ns is ID of its sibling. If the node does not have a sibling, print -1.\n\ndeg, dep and h are the number of children, depth and height of the node respectively.\n\ntype is a type of nodes represented by a string (root, internal node or leaf. If the root can be considered as a leaf or an internal node, print root.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 ≤ n ≤ 25\n\nSample Input 1\n\n9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n\nSample Output 1\n\nnode 0: parent = -1, sibling = -1, degree = 2, depth = 0, height = 3, root\nnode 1: parent = 0, sibling = 4, degree = 2, depth = 1, height = 1, internal node\nnode 2: parent = 1, sibling = 3, degree = 0, depth = 2, height = 0, leaf\nnode 3: parent = 1, sibling = 2, degree = 0, depth = 2, height = 0, leaf\nnode 4: parent = 0, sibling = 1, degree = 2, depth = 1, height = 2, internal node\nnode 5: parent = 4, sibling = 8, degree = 2, depth = 2, height = 1, internal node\nnode 6: parent = 5, sibling = 7, degree = 0, depth = 3, height = 0, leaf\nnode 7: parent = 5, sibling = 6, degree = 0, depth = 3, height = 0, leaf\nnode 8: parent = 4, sibling = 5, degree = 0, depth = 2, height = 0, leaf\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2472, "cpu_time_ms": 240, "memory_kb": 44424}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s084365510", "group_id": "codeNet:p02283", "input_text": "import java.io._\nimport scala.io.StdIn.{readInt, readLine}\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n val tree0 = new Array[Int](500001)\n val tree1 = new Array[Int](500001)\n val tree2 = new Array[Int](500001)\n val a = new ArrayBuffer[Int]\n\n def insert(i:Int, j:Int):Unit =\n if(tree0(i) > tree0(j)) {\n if(tree1(i) == -1) tree1(i) = j\n else insert(tree1(i), j)\n } else {\n if(tree2(i) == -1) tree2(i) = j\n else insert(tree2(i), j)\n }\n\n def inOrder():Unit = {\n var stack:List[Int] = Nil\n var curr = 0\n var flg = true\n\n while(flg) {\n while(curr != -1) {\n stack = curr::stack\n curr = tree1(curr)\n }\n if(curr == -1 && stack != Nil) {\n val item = stack.head\n stack = stack.tail\n a.append(tree0(item))\n curr = tree2(item)\n } else {\n flg = false\n }\n }\n }\n\n def scan(list:List[Int]):Unit = {\n list match {\n case Nil => ()\n case hd::tl => {\n a.append(tree0(hd))\n val hd2 =\n if(tree2(hd) != -1 && tree1(hd) != -1) tree1(hd)::tree2(hd)::tl\n else if(tree2(hd) != -1 && tree1(hd) == -1) tree2(hd)::tl\n else if(tree2(hd) == -1 && tree1(hd) != -1) tree1(hd)::tl\n else tl\n scan(hd2)\n }\n }\n }\n\n def preOrder(i:Int):Unit =\n if(i == -1) return\n else scan(i::Nil)\n\n def main(args:Array[String]) = {\n val n = readInt\n var j = 0\n val out:BufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(java.io.FileDescriptor.out), \"ASCII\"), 512)\n\n for(i<-0 until n) {\n val s = readLine.split(\" \")\n s(0) match {\n case \"insert\" => {\n tree0(j) = s(1).toInt\n tree1(j) = -1\n tree2(j) = -1\n if(j!=0) insert(0, j)\n j+=1\n }\n case _ => {\n a.clear\n inOrder();\n out.write(\" \")\n out.write(a.mkString(\" \"))\n out.write(\"\\n\")\n out.flush()\n a.clear\n preOrder(0)\n out.write(\" \")\n out.write(a.mkString(\" \"))\n out.write(\"\\n\")\n out.flush()\n }\n }\n }\n }\n}", "language": "Scala", "metadata": {"date": 1493998881, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02283.html", "problem_id": "p02283", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02283/input.txt", "sample_output_relpath": "derived/input_output/data/p02283/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02283/Scala/s084365510.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Memory Limit Exceeded", "submission_id": "s084365510", "user_id": "u508732591"}, "prompt_components": {"gold_output": " 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n", "input_to_evaluate": "import java.io._\nimport scala.io.StdIn.{readInt, readLine}\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n val tree0 = new Array[Int](500001)\n val tree1 = new Array[Int](500001)\n val tree2 = new Array[Int](500001)\n val a = new ArrayBuffer[Int]\n\n def insert(i:Int, j:Int):Unit =\n if(tree0(i) > tree0(j)) {\n if(tree1(i) == -1) tree1(i) = j\n else insert(tree1(i), j)\n } else {\n if(tree2(i) == -1) tree2(i) = j\n else insert(tree2(i), j)\n }\n\n def inOrder():Unit = {\n var stack:List[Int] = Nil\n var curr = 0\n var flg = true\n\n while(flg) {\n while(curr != -1) {\n stack = curr::stack\n curr = tree1(curr)\n }\n if(curr == -1 && stack != Nil) {\n val item = stack.head\n stack = stack.tail\n a.append(tree0(item))\n curr = tree2(item)\n } else {\n flg = false\n }\n }\n }\n\n def scan(list:List[Int]):Unit = {\n list match {\n case Nil => ()\n case hd::tl => {\n a.append(tree0(hd))\n val hd2 =\n if(tree2(hd) != -1 && tree1(hd) != -1) tree1(hd)::tree2(hd)::tl\n else if(tree2(hd) != -1 && tree1(hd) == -1) tree2(hd)::tl\n else if(tree2(hd) == -1 && tree1(hd) != -1) tree1(hd)::tl\n else tl\n scan(hd2)\n }\n }\n }\n\n def preOrder(i:Int):Unit =\n if(i == -1) return\n else scan(i::Nil)\n\n def main(args:Array[String]) = {\n val n = readInt\n var j = 0\n val out:BufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(java.io.FileDescriptor.out), \"ASCII\"), 512)\n\n for(i<-0 until n) {\n val s = readLine.split(\" \")\n s(0) match {\n case \"insert\" => {\n tree0(j) = s(1).toInt\n tree1(j) = -1\n tree2(j) = -1\n if(j!=0) insert(0, j)\n j+=1\n }\n case _ => {\n a.clear\n inOrder();\n out.write(\" \")\n out.write(a.mkString(\" \"))\n out.write(\"\\n\")\n out.flush()\n a.clear\n preOrder(0)\n out.write(\" \")\n out.write(a.mkString(\" \"))\n out.write(\"\\n\")\n out.flush()\n }\n }\n }\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nBinary Search Tree I\n\nSearch trees are data structures that support dynamic set operations including insert, search, delete and so on. Thus a search tree can be used both as a dictionary and as a priority queue.\n\nBinary search tree is one of fundamental search trees. The keys in a binary search tree are always stored in such a way as to satisfy the following binary search tree property:\n\nLet $x$ be a node in a binary search tree. If $y$ is a node in the left subtree of $x$, then $y.key \\leq x.key$. If $y$ is a node in the right subtree of $x$, then $x.key \\leq y.key$.\n\nThe following figure shows an example of the binary search tree.\n\nFor example, keys of nodes which belong to the left sub-tree of the node containing 80 are less than or equal to 80, and keys of nodes which belong to the right sub-tree are more than or equal to 80. The binary search tree property allows us to print out all the keys in the tree in sorted order by an inorder tree walk.\n\nA binary search tree should be implemented in such a way that the binary search tree property continues to hold after modifications by insertions and deletions. A binary search tree can be represented by a linked data structure in which each node is an object. In addition to a key field and satellite data, each node contains fields left, right, and p that point to the nodes corresponding to its left child, its right child, and its parent, respectively.\n\nTo insert a new value $v$ into a binary search tree $T$, we can use the procedure insert as shown in the following pseudo code. The insert procedure is passed a node $z$ for which $z.key = v$, $z.left = NIL$, and $z.right = NIL$. The procedure modifies $T$ and some of the fields of $z$ in such a way that $z$ is inserted into an appropriate position in the tree.\n\n1 insert(T, z)\n2 y = NIL // parent of x\n3 x = 'the root of T'\n4 while x ≠ NIL\n5 y = x // set the parent\n6 if z.key < x.key\n7 x = x.left // move to the left child\n8 else\n9 x = x.right // move to the right child\n10 z.p = y\n11\n12 if y == NIL // T is empty\n13 'the root of T' = z\n14 else if z.key < y.key\n15 y.left = z // z is the left child of y\n16 else\n17 y.right = z // z is the right child of y\n\nWrite a program which performs the following operations to a binary search tree $T$.\n\ninsert $k$: Insert a node containing $k$ as key into $T$.\n\nprint: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively.\n\nYou should use the above pseudo code to implement the insert operation. $T$ is empty at the initial state.\n\nInput\n\nIn the first line, the number of operations $m$ is given. In the following $m$ lines, operations represented by insert $k$ or print are given.\n\nOutput\n\nFor each print operation, print a list of keys obtained by inorder tree walk and preorder tree walk in a line respectively. Put a space character before each key.\n\nConstraints\n\nThe number of operations $\\leq 500,000$\n\nThe number of print operations $\\leq 10$.\n\n$-2,000,000,000 \\leq key \\leq 2,000,000,000$\n\nThe height of the binary tree does not exceed 100 if you employ the above pseudo code.\n\nThe keys in the binary search tree are all different.\n\nSample Input 1\n\n8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n\nSample Output 1\n\n1 12 17 20 25 30 88\n30 12 1 20 17 25 88\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n"}, "reference_outputs": [" 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n"], "source_document_id": "p02283", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nBinary Search Tree I\n\nSearch trees are data structures that support dynamic set operations including insert, search, delete and so on. Thus a search tree can be used both as a dictionary and as a priority queue.\n\nBinary search tree is one of fundamental search trees. The keys in a binary search tree are always stored in such a way as to satisfy the following binary search tree property:\n\nLet $x$ be a node in a binary search tree. If $y$ is a node in the left subtree of $x$, then $y.key \\leq x.key$. If $y$ is a node in the right subtree of $x$, then $x.key \\leq y.key$.\n\nThe following figure shows an example of the binary search tree.\n\nFor example, keys of nodes which belong to the left sub-tree of the node containing 80 are less than or equal to 80, and keys of nodes which belong to the right sub-tree are more than or equal to 80. The binary search tree property allows us to print out all the keys in the tree in sorted order by an inorder tree walk.\n\nA binary search tree should be implemented in such a way that the binary search tree property continues to hold after modifications by insertions and deletions. A binary search tree can be represented by a linked data structure in which each node is an object. In addition to a key field and satellite data, each node contains fields left, right, and p that point to the nodes corresponding to its left child, its right child, and its parent, respectively.\n\nTo insert a new value $v$ into a binary search tree $T$, we can use the procedure insert as shown in the following pseudo code. The insert procedure is passed a node $z$ for which $z.key = v$, $z.left = NIL$, and $z.right = NIL$. The procedure modifies $T$ and some of the fields of $z$ in such a way that $z$ is inserted into an appropriate position in the tree.\n\n1 insert(T, z)\n2 y = NIL // parent of x\n3 x = 'the root of T'\n4 while x ≠ NIL\n5 y = x // set the parent\n6 if z.key < x.key\n7 x = x.left // move to the left child\n8 else\n9 x = x.right // move to the right child\n10 z.p = y\n11\n12 if y == NIL // T is empty\n13 'the root of T' = z\n14 else if z.key < y.key\n15 y.left = z // z is the left child of y\n16 else\n17 y.right = z // z is the right child of y\n\nWrite a program which performs the following operations to a binary search tree $T$.\n\ninsert $k$: Insert a node containing $k$ as key into $T$.\n\nprint: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively.\n\nYou should use the above pseudo code to implement the insert operation. $T$ is empty at the initial state.\n\nInput\n\nIn the first line, the number of operations $m$ is given. In the following $m$ lines, operations represented by insert $k$ or print are given.\n\nOutput\n\nFor each print operation, print a list of keys obtained by inorder tree walk and preorder tree walk in a line respectively. Put a space character before each key.\n\nConstraints\n\nThe number of operations $\\leq 500,000$\n\nThe number of print operations $\\leq 10$.\n\n$-2,000,000,000 \\leq key \\leq 2,000,000,000$\n\nThe height of the binary tree does not exceed 100 if you employ the above pseudo code.\n\nThe keys in the binary search tree are all different.\n\nSample Input 1\n\n8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n\nSample Output 1\n\n1 12 17 20 25 30 88\n30 12 1 20 17 25 88\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2166, "cpu_time_ms": 1090, "memory_kb": 421152}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s770572310", "group_id": "codeNet:p02283", "input_text": "import java.io._\nimport scala.io.StdIn.{readInt, readLine}\n\nobject Main {\n val tree0 = new Array[Int](500001)\n val tree1 = new Array[Int](500001)\n val tree2 = new Array[Int](500001)\n val out:BufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(java.io.FileDescriptor.out), \"ASCII\"), 512)\n var count = 0\n\n def insert(i:Int, j:Int):Unit =\n if(tree0(i) > tree0(j)) {\n if(tree1(i) == -1) tree1(i) = j\n else insert(tree1(i), j)\n } else {\n if(tree2(i) == -1) tree2(i) = j\n else insert(tree2(i), j)\n }\n\n def inOrder():Unit = {\n var stack:List[Int] = Nil\n var curr = 0\n var flg = true\n\n while(flg) {\n while(curr != -1) {\n stack = curr::stack\n curr = tree1(curr)\n }\n if(curr == -1 && stack != Nil) {\n val item = stack.head\n stack = stack.tail\n out.write(\" \")\n out.write(tree0(item).toString)\n if(count<100) count += 1\n else {\n out.flush\n count = 0\n }\n curr = tree2(item)\n } else {\n flg = false\n }\n }\n }\n\n def scan(list:List[Int]):Unit = {\n list match {\n case Nil => ()\n case hd::tl => {\n out.write(\" \")\n out.write(tree0(hd).toString)\n if(count<100) count += 1\n else {\n out.flush\n count = 0\n }\n val hd2 =\n if(tree2(hd) != -1 && tree1(hd) != -1) tree1(hd)::tree2(hd)::tl\n else if(tree2(hd) != -1 && tree1(hd) == -1) tree2(hd)::tl\n else if(tree2(hd) == -1 && tree1(hd) != -1) tree1(hd)::tl\n else tl\n scan(hd2)\n }\n }\n }\n\n def preOrder(i:Int):Unit =\n if(i == -1) return\n else scan(i::Nil)\n\n def main(args:Array[String]) = {\n val n = readInt\n var j = 0\n\n for(i<-0 until n) {\n val s = readLine.split(\" \")\n s(0) match {\n case \"insert\" => {\n tree0(j) = s(1).toInt\n tree1(j) = -1\n tree2(j) = -1\n if(j!=0) insert(0, j)\n j+=1\n }\n case _ => {\n inOrder()\n out.write(\"\\n\")\n out.flush()\n preOrder(0)\n out.write(\"\\n\")\n out.flush()\n }\n }\n }\n }\n}", "language": "Scala", "metadata": {"date": 1493999725, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02283.html", "problem_id": "p02283", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02283/input.txt", "sample_output_relpath": "derived/input_output/data/p02283/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02283/Scala/s770572310.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s770572310", "user_id": "u508732591"}, "prompt_components": {"gold_output": " 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n", "input_to_evaluate": "import java.io._\nimport scala.io.StdIn.{readInt, readLine}\n\nobject Main {\n val tree0 = new Array[Int](500001)\n val tree1 = new Array[Int](500001)\n val tree2 = new Array[Int](500001)\n val out:BufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(java.io.FileDescriptor.out), \"ASCII\"), 512)\n var count = 0\n\n def insert(i:Int, j:Int):Unit =\n if(tree0(i) > tree0(j)) {\n if(tree1(i) == -1) tree1(i) = j\n else insert(tree1(i), j)\n } else {\n if(tree2(i) == -1) tree2(i) = j\n else insert(tree2(i), j)\n }\n\n def inOrder():Unit = {\n var stack:List[Int] = Nil\n var curr = 0\n var flg = true\n\n while(flg) {\n while(curr != -1) {\n stack = curr::stack\n curr = tree1(curr)\n }\n if(curr == -1 && stack != Nil) {\n val item = stack.head\n stack = stack.tail\n out.write(\" \")\n out.write(tree0(item).toString)\n if(count<100) count += 1\n else {\n out.flush\n count = 0\n }\n curr = tree2(item)\n } else {\n flg = false\n }\n }\n }\n\n def scan(list:List[Int]):Unit = {\n list match {\n case Nil => ()\n case hd::tl => {\n out.write(\" \")\n out.write(tree0(hd).toString)\n if(count<100) count += 1\n else {\n out.flush\n count = 0\n }\n val hd2 =\n if(tree2(hd) != -1 && tree1(hd) != -1) tree1(hd)::tree2(hd)::tl\n else if(tree2(hd) != -1 && tree1(hd) == -1) tree2(hd)::tl\n else if(tree2(hd) == -1 && tree1(hd) != -1) tree1(hd)::tl\n else tl\n scan(hd2)\n }\n }\n }\n\n def preOrder(i:Int):Unit =\n if(i == -1) return\n else scan(i::Nil)\n\n def main(args:Array[String]) = {\n val n = readInt\n var j = 0\n\n for(i<-0 until n) {\n val s = readLine.split(\" \")\n s(0) match {\n case \"insert\" => {\n tree0(j) = s(1).toInt\n tree1(j) = -1\n tree2(j) = -1\n if(j!=0) insert(0, j)\n j+=1\n }\n case _ => {\n inOrder()\n out.write(\"\\n\")\n out.flush()\n preOrder(0)\n out.write(\"\\n\")\n out.flush()\n }\n }\n }\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nBinary Search Tree I\n\nSearch trees are data structures that support dynamic set operations including insert, search, delete and so on. Thus a search tree can be used both as a dictionary and as a priority queue.\n\nBinary search tree is one of fundamental search trees. The keys in a binary search tree are always stored in such a way as to satisfy the following binary search tree property:\n\nLet $x$ be a node in a binary search tree. If $y$ is a node in the left subtree of $x$, then $y.key \\leq x.key$. If $y$ is a node in the right subtree of $x$, then $x.key \\leq y.key$.\n\nThe following figure shows an example of the binary search tree.\n\nFor example, keys of nodes which belong to the left sub-tree of the node containing 80 are less than or equal to 80, and keys of nodes which belong to the right sub-tree are more than or equal to 80. The binary search tree property allows us to print out all the keys in the tree in sorted order by an inorder tree walk.\n\nA binary search tree should be implemented in such a way that the binary search tree property continues to hold after modifications by insertions and deletions. A binary search tree can be represented by a linked data structure in which each node is an object. In addition to a key field and satellite data, each node contains fields left, right, and p that point to the nodes corresponding to its left child, its right child, and its parent, respectively.\n\nTo insert a new value $v$ into a binary search tree $T$, we can use the procedure insert as shown in the following pseudo code. The insert procedure is passed a node $z$ for which $z.key = v$, $z.left = NIL$, and $z.right = NIL$. The procedure modifies $T$ and some of the fields of $z$ in such a way that $z$ is inserted into an appropriate position in the tree.\n\n1 insert(T, z)\n2 y = NIL // parent of x\n3 x = 'the root of T'\n4 while x ≠ NIL\n5 y = x // set the parent\n6 if z.key < x.key\n7 x = x.left // move to the left child\n8 else\n9 x = x.right // move to the right child\n10 z.p = y\n11\n12 if y == NIL // T is empty\n13 'the root of T' = z\n14 else if z.key < y.key\n15 y.left = z // z is the left child of y\n16 else\n17 y.right = z // z is the right child of y\n\nWrite a program which performs the following operations to a binary search tree $T$.\n\ninsert $k$: Insert a node containing $k$ as key into $T$.\n\nprint: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively.\n\nYou should use the above pseudo code to implement the insert operation. $T$ is empty at the initial state.\n\nInput\n\nIn the first line, the number of operations $m$ is given. In the following $m$ lines, operations represented by insert $k$ or print are given.\n\nOutput\n\nFor each print operation, print a list of keys obtained by inorder tree walk and preorder tree walk in a line respectively. Put a space character before each key.\n\nConstraints\n\nThe number of operations $\\leq 500,000$\n\nThe number of print operations $\\leq 10$.\n\n$-2,000,000,000 \\leq key \\leq 2,000,000,000$\n\nThe height of the binary tree does not exceed 100 if you employ the above pseudo code.\n\nThe keys in the binary search tree are all different.\n\nSample Input 1\n\n8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n\nSample Output 1\n\n1 12 17 20 25 30 88\n30 12 1 20 17 25 88\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n"}, "reference_outputs": [" 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n"], "source_document_id": "p02283", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nBinary Search Tree I\n\nSearch trees are data structures that support dynamic set operations including insert, search, delete and so on. Thus a search tree can be used both as a dictionary and as a priority queue.\n\nBinary search tree is one of fundamental search trees. The keys in a binary search tree are always stored in such a way as to satisfy the following binary search tree property:\n\nLet $x$ be a node in a binary search tree. If $y$ is a node in the left subtree of $x$, then $y.key \\leq x.key$. If $y$ is a node in the right subtree of $x$, then $x.key \\leq y.key$.\n\nThe following figure shows an example of the binary search tree.\n\nFor example, keys of nodes which belong to the left sub-tree of the node containing 80 are less than or equal to 80, and keys of nodes which belong to the right sub-tree are more than or equal to 80. The binary search tree property allows us to print out all the keys in the tree in sorted order by an inorder tree walk.\n\nA binary search tree should be implemented in such a way that the binary search tree property continues to hold after modifications by insertions and deletions. A binary search tree can be represented by a linked data structure in which each node is an object. In addition to a key field and satellite data, each node contains fields left, right, and p that point to the nodes corresponding to its left child, its right child, and its parent, respectively.\n\nTo insert a new value $v$ into a binary search tree $T$, we can use the procedure insert as shown in the following pseudo code. The insert procedure is passed a node $z$ for which $z.key = v$, $z.left = NIL$, and $z.right = NIL$. The procedure modifies $T$ and some of the fields of $z$ in such a way that $z$ is inserted into an appropriate position in the tree.\n\n1 insert(T, z)\n2 y = NIL // parent of x\n3 x = 'the root of T'\n4 while x ≠ NIL\n5 y = x // set the parent\n6 if z.key < x.key\n7 x = x.left // move to the left child\n8 else\n9 x = x.right // move to the right child\n10 z.p = y\n11\n12 if y == NIL // T is empty\n13 'the root of T' = z\n14 else if z.key < y.key\n15 y.left = z // z is the left child of y\n16 else\n17 y.right = z // z is the right child of y\n\nWrite a program which performs the following operations to a binary search tree $T$.\n\ninsert $k$: Insert a node containing $k$ as key into $T$.\n\nprint: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively.\n\nYou should use the above pseudo code to implement the insert operation. $T$ is empty at the initial state.\n\nInput\n\nIn the first line, the number of operations $m$ is given. In the following $m$ lines, operations represented by insert $k$ or print are given.\n\nOutput\n\nFor each print operation, print a list of keys obtained by inorder tree walk and preorder tree walk in a line respectively. Put a space character before each key.\n\nConstraints\n\nThe number of operations $\\leq 500,000$\n\nThe number of print operations $\\leq 10$.\n\n$-2,000,000,000 \\leq key \\leq 2,000,000,000$\n\nThe height of the binary tree does not exceed 100 if you employ the above pseudo code.\n\nThe keys in the binary search tree are all different.\n\nSample Input 1\n\n8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n\nSample Output 1\n\n1 12 17 20 25 30 88\n30 12 1 20 17 25 88\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2206, "cpu_time_ms": 1150, "memory_kb": 310432}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s821224043", "group_id": "codeNet:p02283", "input_text": "import java.io._\nimport scala.io.StdIn.{readInt, readLine}\n\nobject Main {\n val out:BufferedWriter =\n new BufferedWriter(new OutputStreamWriter(new FileOutputStream(java.io.FileDescriptor.out), \"ASCII\"), 512)\n var count = 0\n class Node(var key:Int, var left:Node = null, var right:Node = null) { }\n\n def insert(tree:Node, key:Node) = {\n val keyNode = key\n def loop(node:Node):Node =\n if(node.key > keyNode.key) {\n if(node.left == null) node\n else loop(node.left)\n } else {\n if(node.right == null) node\n else loop(node.right)\n }\n\n val target = loop(tree)\n\n if(keyNode.key < target.key) target.left = keyNode\n else target.right = keyNode\n }\n\n def inOrder(root:Node):Unit = {\n var stack:List[Node] = Nil\n var curr = root\n var flg = true\n\n while(flg) {\n while(curr != null) {\n stack = curr::stack\n curr = curr.left\n }\n if(curr == null && stack != Nil) {\n val item = stack.head\n stack = stack.tail\n out.write(\" \")\n out.write(item.key.toString)\n if(count<100) count += 1\n else {\n out.flush\n count = 0\n }\n curr = item.right\n } else {\n flg = false\n }\n }\n }\n\n def scan(list:List[Node]):Unit = {\n list match {\n case Nil => ()\n case hd::tl => {\n out.write(\" \")\n out.write(hd.key.toString)\n if(count<100) count += 1\n else {\n out.flush\n count = 0\n }\n val hd2 = if(hd.right!=null) hd.right::tl else tl\n val hd3 =if(hd.left!=null) hd.left::hd2 else hd2\n scan(hd3)\n }\n }\n }\n\n def preOrder(tree:Node):Unit =\n if(tree == null) return\n else scan(tree::Nil)\n\n def main(args:Array[String]) = {\n val n = readInt\n val tree = new Node(-1)\n\n for(i<-0 until n) {\n val s = readLine.split(\" \")\n s(0) match {\n case \"insert\" =>\n if(tree.key == -1) tree.key = s(1).toInt\n else insert(tree, new Node(s(1).toInt))\n case _ => {\n inOrder(tree)\n out.write(\"\\n\")\n out.flush()\n preOrder(tree)\n out.write(\"\\n\")\n out.flush()\n }\n }\n }\n }\n}", "language": "Scala", "metadata": {"date": 1494023885, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02283.html", "problem_id": "p02283", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02283/input.txt", "sample_output_relpath": "derived/input_output/data/p02283/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02283/Scala/s821224043.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s821224043", "user_id": "u508732591"}, "prompt_components": {"gold_output": " 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n", "input_to_evaluate": "import java.io._\nimport scala.io.StdIn.{readInt, readLine}\n\nobject Main {\n val out:BufferedWriter =\n new BufferedWriter(new OutputStreamWriter(new FileOutputStream(java.io.FileDescriptor.out), \"ASCII\"), 512)\n var count = 0\n class Node(var key:Int, var left:Node = null, var right:Node = null) { }\n\n def insert(tree:Node, key:Node) = {\n val keyNode = key\n def loop(node:Node):Node =\n if(node.key > keyNode.key) {\n if(node.left == null) node\n else loop(node.left)\n } else {\n if(node.right == null) node\n else loop(node.right)\n }\n\n val target = loop(tree)\n\n if(keyNode.key < target.key) target.left = keyNode\n else target.right = keyNode\n }\n\n def inOrder(root:Node):Unit = {\n var stack:List[Node] = Nil\n var curr = root\n var flg = true\n\n while(flg) {\n while(curr != null) {\n stack = curr::stack\n curr = curr.left\n }\n if(curr == null && stack != Nil) {\n val item = stack.head\n stack = stack.tail\n out.write(\" \")\n out.write(item.key.toString)\n if(count<100) count += 1\n else {\n out.flush\n count = 0\n }\n curr = item.right\n } else {\n flg = false\n }\n }\n }\n\n def scan(list:List[Node]):Unit = {\n list match {\n case Nil => ()\n case hd::tl => {\n out.write(\" \")\n out.write(hd.key.toString)\n if(count<100) count += 1\n else {\n out.flush\n count = 0\n }\n val hd2 = if(hd.right!=null) hd.right::tl else tl\n val hd3 =if(hd.left!=null) hd.left::hd2 else hd2\n scan(hd3)\n }\n }\n }\n\n def preOrder(tree:Node):Unit =\n if(tree == null) return\n else scan(tree::Nil)\n\n def main(args:Array[String]) = {\n val n = readInt\n val tree = new Node(-1)\n\n for(i<-0 until n) {\n val s = readLine.split(\" \")\n s(0) match {\n case \"insert\" =>\n if(tree.key == -1) tree.key = s(1).toInt\n else insert(tree, new Node(s(1).toInt))\n case _ => {\n inOrder(tree)\n out.write(\"\\n\")\n out.flush()\n preOrder(tree)\n out.write(\"\\n\")\n out.flush()\n }\n }\n }\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nBinary Search Tree I\n\nSearch trees are data structures that support dynamic set operations including insert, search, delete and so on. Thus a search tree can be used both as a dictionary and as a priority queue.\n\nBinary search tree is one of fundamental search trees. The keys in a binary search tree are always stored in such a way as to satisfy the following binary search tree property:\n\nLet $x$ be a node in a binary search tree. If $y$ is a node in the left subtree of $x$, then $y.key \\leq x.key$. If $y$ is a node in the right subtree of $x$, then $x.key \\leq y.key$.\n\nThe following figure shows an example of the binary search tree.\n\nFor example, keys of nodes which belong to the left sub-tree of the node containing 80 are less than or equal to 80, and keys of nodes which belong to the right sub-tree are more than or equal to 80. The binary search tree property allows us to print out all the keys in the tree in sorted order by an inorder tree walk.\n\nA binary search tree should be implemented in such a way that the binary search tree property continues to hold after modifications by insertions and deletions. A binary search tree can be represented by a linked data structure in which each node is an object. In addition to a key field and satellite data, each node contains fields left, right, and p that point to the nodes corresponding to its left child, its right child, and its parent, respectively.\n\nTo insert a new value $v$ into a binary search tree $T$, we can use the procedure insert as shown in the following pseudo code. The insert procedure is passed a node $z$ for which $z.key = v$, $z.left = NIL$, and $z.right = NIL$. The procedure modifies $T$ and some of the fields of $z$ in such a way that $z$ is inserted into an appropriate position in the tree.\n\n1 insert(T, z)\n2 y = NIL // parent of x\n3 x = 'the root of T'\n4 while x ≠ NIL\n5 y = x // set the parent\n6 if z.key < x.key\n7 x = x.left // move to the left child\n8 else\n9 x = x.right // move to the right child\n10 z.p = y\n11\n12 if y == NIL // T is empty\n13 'the root of T' = z\n14 else if z.key < y.key\n15 y.left = z // z is the left child of y\n16 else\n17 y.right = z // z is the right child of y\n\nWrite a program which performs the following operations to a binary search tree $T$.\n\ninsert $k$: Insert a node containing $k$ as key into $T$.\n\nprint: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively.\n\nYou should use the above pseudo code to implement the insert operation. $T$ is empty at the initial state.\n\nInput\n\nIn the first line, the number of operations $m$ is given. In the following $m$ lines, operations represented by insert $k$ or print are given.\n\nOutput\n\nFor each print operation, print a list of keys obtained by inorder tree walk and preorder tree walk in a line respectively. Put a space character before each key.\n\nConstraints\n\nThe number of operations $\\leq 500,000$\n\nThe number of print operations $\\leq 10$.\n\n$-2,000,000,000 \\leq key \\leq 2,000,000,000$\n\nThe height of the binary tree does not exceed 100 if you employ the above pseudo code.\n\nThe keys in the binary search tree are all different.\n\nSample Input 1\n\n8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n\nSample Output 1\n\n1 12 17 20 25 30 88\n30 12 1 20 17 25 88\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n"}, "reference_outputs": [" 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n"], "source_document_id": "p02283", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nBinary Search Tree I\n\nSearch trees are data structures that support dynamic set operations including insert, search, delete and so on. Thus a search tree can be used both as a dictionary and as a priority queue.\n\nBinary search tree is one of fundamental search trees. The keys in a binary search tree are always stored in such a way as to satisfy the following binary search tree property:\n\nLet $x$ be a node in a binary search tree. If $y$ is a node in the left subtree of $x$, then $y.key \\leq x.key$. If $y$ is a node in the right subtree of $x$, then $x.key \\leq y.key$.\n\nThe following figure shows an example of the binary search tree.\n\nFor example, keys of nodes which belong to the left sub-tree of the node containing 80 are less than or equal to 80, and keys of nodes which belong to the right sub-tree are more than or equal to 80. The binary search tree property allows us to print out all the keys in the tree in sorted order by an inorder tree walk.\n\nA binary search tree should be implemented in such a way that the binary search tree property continues to hold after modifications by insertions and deletions. A binary search tree can be represented by a linked data structure in which each node is an object. In addition to a key field and satellite data, each node contains fields left, right, and p that point to the nodes corresponding to its left child, its right child, and its parent, respectively.\n\nTo insert a new value $v$ into a binary search tree $T$, we can use the procedure insert as shown in the following pseudo code. The insert procedure is passed a node $z$ for which $z.key = v$, $z.left = NIL$, and $z.right = NIL$. The procedure modifies $T$ and some of the fields of $z$ in such a way that $z$ is inserted into an appropriate position in the tree.\n\n1 insert(T, z)\n2 y = NIL // parent of x\n3 x = 'the root of T'\n4 while x ≠ NIL\n5 y = x // set the parent\n6 if z.key < x.key\n7 x = x.left // move to the left child\n8 else\n9 x = x.right // move to the right child\n10 z.p = y\n11\n12 if y == NIL // T is empty\n13 'the root of T' = z\n14 else if z.key < y.key\n15 y.left = z // z is the left child of y\n16 else\n17 y.right = z // z is the right child of y\n\nWrite a program which performs the following operations to a binary search tree $T$.\n\ninsert $k$: Insert a node containing $k$ as key into $T$.\n\nprint: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively.\n\nYou should use the above pseudo code to implement the insert operation. $T$ is empty at the initial state.\n\nInput\n\nIn the first line, the number of operations $m$ is given. In the following $m$ lines, operations represented by insert $k$ or print are given.\n\nOutput\n\nFor each print operation, print a list of keys obtained by inorder tree walk and preorder tree walk in a line respectively. Put a space character before each key.\n\nConstraints\n\nThe number of operations $\\leq 500,000$\n\nThe number of print operations $\\leq 10$.\n\n$-2,000,000,000 \\leq key \\leq 2,000,000,000$\n\nThe height of the binary tree does not exceed 100 if you employ the above pseudo code.\n\nThe keys in the binary search tree are all different.\n\nSample Input 1\n\n8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n\nSample Output 1\n\n1 12 17 20 25 30 88\n30 12 1 20 17 25 88\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2227, "cpu_time_ms": 1240, "memory_kb": 300600}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s204319961", "group_id": "codeNet:p02288", "input_text": "import scala.io.StdIn.{readInt, readLine};\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val n = readInt;\n val arr = readLine.split(\" \").map(_.toInt);\n build(n, arr);\n println(arr.mkString(\" \"));\n }\n \n def build(length: Int, arr: Array[Int]): Unit = {\n def go(curr: Int): Unit = {\n if (curr < length) {\n go(curr * 2 + 1);\n heapify(length, arr, curr);\n go(curr * 2 + 2);\n }\n }\n go(0);\n }\n \n def heapify(length: Int, arr: Array[Int], idx: Int): Unit = {\n val left = idx * 2 + 1;\n val right = idx * 2 + 2;\n if (right < length) {\n val m = max(arr, idx, left, right);\n if (idx != m) {\n swap(arr, idx, m);\n heapify(length, arr, m);\n }\n } else if (left < length) {\n if (arr(left) > arr(idx)) swap(arr, left, idx);\n } else {\n // nop\n }\n }\n \n def max(arr: Array[Int], k1: Int, k2: Int, k3: Int): Int = {\n val v1 = arr(k1); val v2 = arr(k2); val v3 = arr(k3);\n if (v1 > v2) {\n if (v1 > v3) k1 else k3;\n } else {\n if (v2 > v3) k2 else k3;\n }\n }\n \n def swap(arr: Array[Int], a: Int, b: Int): Unit = {\n val tmp = arr(a);\n arr(a) = arr(b);\n arr(b) = tmp;\n }\n}\n", "language": "Scala", "metadata": {"date": 1525826012, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02288.html", "problem_id": "p02288", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02288/input.txt", "sample_output_relpath": "derived/input_output/data/p02288/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02288/Scala/s204319961.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s204319961", "user_id": "u909989059"}, "prompt_components": {"gold_output": " 16 14 10 8 7 9 3 2 4 1\n", "input_to_evaluate": "import scala.io.StdIn.{readInt, readLine};\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val n = readInt;\n val arr = readLine.split(\" \").map(_.toInt);\n build(n, arr);\n println(arr.mkString(\" \"));\n }\n \n def build(length: Int, arr: Array[Int]): Unit = {\n def go(curr: Int): Unit = {\n if (curr < length) {\n go(curr * 2 + 1);\n heapify(length, arr, curr);\n go(curr * 2 + 2);\n }\n }\n go(0);\n }\n \n def heapify(length: Int, arr: Array[Int], idx: Int): Unit = {\n val left = idx * 2 + 1;\n val right = idx * 2 + 2;\n if (right < length) {\n val m = max(arr, idx, left, right);\n if (idx != m) {\n swap(arr, idx, m);\n heapify(length, arr, m);\n }\n } else if (left < length) {\n if (arr(left) > arr(idx)) swap(arr, left, idx);\n } else {\n // nop\n }\n }\n \n def max(arr: Array[Int], k1: Int, k2: Int, k3: Int): Int = {\n val v1 = arr(k1); val v2 = arr(k2); val v3 = arr(k3);\n if (v1 > v2) {\n if (v1 > v3) k1 else k3;\n } else {\n if (v2 > v3) k2 else k3;\n }\n }\n \n def swap(arr: Array[Int], a: Int, b: Int): Unit = {\n val tmp = arr(a);\n arr(a) = arr(b);\n arr(b) = tmp;\n }\n}\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMaximum Heap\n\nA binary heap which satisfies max-heap property is called max-heap. In a max-heap, for every node $i$ other than the root, $A[i] \\leq A[parent(i)]$, that is, the value of a node is at most the value of its parent. The largest element in a max-heap is stored at the root, and the subtree rooted at a node contains values no larger than that contained at the node itself.\n\nHere is an example of a max-heap.\n\nWrite a program which reads an array and constructs a max-heap from the array based on the following pseudo code.\n\n$maxHeapify(A, i)$ move the value of $A[i]$ down to leaves to make a sub-tree of node $i$ a max-heap. Here, $H$ is the size of the heap.\n\n1 maxHeapify(A, i)\n2 l = left(i)\n3 r = right(i)\n4 // select the node which has the maximum value\n5 if l ≤ H and A[l] > A[i]\n6 largest = l\n7 else\n8 largest = i\n9 if r ≤ H and A[r] > A[largest]\n10 largest = r\n11\n12 if largest ≠ i // value of children is larger than that of i\n13 swap A[i] and A[largest]\n14 maxHeapify(A, largest) // call recursively\n\nThe following procedure buildMaxHeap(A) makes $A$ a max-heap by performing maxHeapify in a bottom-up manner.\n\n1 buildMaxHeap(A)\n2 for i = H/2 downto 1\n3 maxHeapify(A, i)\n\nInput\n\nIn the first line, an integer $H$ is given. In the second line, $H$ integers which represent elements in the binary heap are given in order of node id (from $1$ to $H$).\n\nOutput\n\nPrint values of nodes in the max-heap in order of their id (from $1$ to $H$). Print a single space character before each value.\n\nConstraint\n\n$1 \\leq H \\leq 500,000$\n\n$-2,000,000,000 \\leq$ value of a node $\\leq 2,000,000,000$\n\nSample Input 1\n\n10\n4 1 3 2 16 9 10 14 8 7\n\nSample Output 1\n\n16 14 10 8 7 9 3 2 4 1\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "10\n4 1 3 2 16 9 10 14 8 7\n"}, "reference_outputs": [" 16 14 10 8 7 9 3 2 4 1\n"], "source_document_id": "p02288", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMaximum Heap\n\nA binary heap which satisfies max-heap property is called max-heap. In a max-heap, for every node $i$ other than the root, $A[i] \\leq A[parent(i)]$, that is, the value of a node is at most the value of its parent. The largest element in a max-heap is stored at the root, and the subtree rooted at a node contains values no larger than that contained at the node itself.\n\nHere is an example of a max-heap.\n\nWrite a program which reads an array and constructs a max-heap from the array based on the following pseudo code.\n\n$maxHeapify(A, i)$ move the value of $A[i]$ down to leaves to make a sub-tree of node $i$ a max-heap. Here, $H$ is the size of the heap.\n\n1 maxHeapify(A, i)\n2 l = left(i)\n3 r = right(i)\n4 // select the node which has the maximum value\n5 if l ≤ H and A[l] > A[i]\n6 largest = l\n7 else\n8 largest = i\n9 if r ≤ H and A[r] > A[largest]\n10 largest = r\n11\n12 if largest ≠ i // value of children is larger than that of i\n13 swap A[i] and A[largest]\n14 maxHeapify(A, largest) // call recursively\n\nThe following procedure buildMaxHeap(A) makes $A$ a max-heap by performing maxHeapify in a bottom-up manner.\n\n1 buildMaxHeap(A)\n2 for i = H/2 downto 1\n3 maxHeapify(A, i)\n\nInput\n\nIn the first line, an integer $H$ is given. In the second line, $H$ integers which represent elements in the binary heap are given in order of node id (from $1$ to $H$).\n\nOutput\n\nPrint values of nodes in the max-heap in order of their id (from $1$ to $H$). Print a single space character before each value.\n\nConstraint\n\n$1 \\leq H \\leq 500,000$\n\n$-2,000,000,000 \\leq$ value of a node $\\leq 2,000,000,000$\n\nSample Input 1\n\n10\n4 1 3 2 16 9 10 14 8 7\n\nSample Output 1\n\n16 14 10 8 7 9 3 2 4 1\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1413, "cpu_time_ms": 220, "memory_kb": 43528}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s706438915", "group_id": "codeNet:p02288", "input_text": "import scala.io.StdIn.{readInt, readLine};\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val n = readInt;\n val arr = readLine.split(\" \").map(_.toInt);\n build(n, arr);\n println(\" \" + arr.mkString(\" \"));\n }\n \n def build(length: Int, arr: Array[Int]): Unit = {\n def go(curr: Int): Unit = {\n if (curr < length) {\n go(curr * 2 + 1);\n heapify(length, arr, curr);\n go(curr * 2 + 2);\n }\n }\n go(0);\n }\n \n def heapify(length: Int, arr: Array[Int], idx: Int): Unit = {\n val left = idx * 2 + 1;\n val right = idx * 2 + 2;\n if (right < length) {\n val m = max(arr, idx, left, right);\n if (idx != m) {\n swap(arr, idx, m);\n heapify(length, arr, m);\n }\n } else if (left < length) {\n if (arr(left) > arr(idx)) swap(arr, left, idx);\n } else {\n // nop\n }\n }\n \n def max(arr: Array[Int], k1: Int, k2: Int, k3: Int): Int = {\n val v1 = arr(k1); val v2 = arr(k2); val v3 = arr(k3);\n if (v1 > v2) {\n if (v1 > v3) k1 else k3;\n } else {\n if (v2 > v3) k2 else k3;\n }\n }\n \n def swap(arr: Array[Int], a: Int, b: Int): Unit = {\n val tmp = arr(a);\n arr(a) = arr(b);\n arr(b) = tmp;\n }\n}\n", "language": "Scala", "metadata": {"date": 1525826036, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02288.html", "problem_id": "p02288", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02288/input.txt", "sample_output_relpath": "derived/input_output/data/p02288/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02288/Scala/s706438915.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s706438915", "user_id": "u909989059"}, "prompt_components": {"gold_output": " 16 14 10 8 7 9 3 2 4 1\n", "input_to_evaluate": "import scala.io.StdIn.{readInt, readLine};\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val n = readInt;\n val arr = readLine.split(\" \").map(_.toInt);\n build(n, arr);\n println(\" \" + arr.mkString(\" \"));\n }\n \n def build(length: Int, arr: Array[Int]): Unit = {\n def go(curr: Int): Unit = {\n if (curr < length) {\n go(curr * 2 + 1);\n heapify(length, arr, curr);\n go(curr * 2 + 2);\n }\n }\n go(0);\n }\n \n def heapify(length: Int, arr: Array[Int], idx: Int): Unit = {\n val left = idx * 2 + 1;\n val right = idx * 2 + 2;\n if (right < length) {\n val m = max(arr, idx, left, right);\n if (idx != m) {\n swap(arr, idx, m);\n heapify(length, arr, m);\n }\n } else if (left < length) {\n if (arr(left) > arr(idx)) swap(arr, left, idx);\n } else {\n // nop\n }\n }\n \n def max(arr: Array[Int], k1: Int, k2: Int, k3: Int): Int = {\n val v1 = arr(k1); val v2 = arr(k2); val v3 = arr(k3);\n if (v1 > v2) {\n if (v1 > v3) k1 else k3;\n } else {\n if (v2 > v3) k2 else k3;\n }\n }\n \n def swap(arr: Array[Int], a: Int, b: Int): Unit = {\n val tmp = arr(a);\n arr(a) = arr(b);\n arr(b) = tmp;\n }\n}\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMaximum Heap\n\nA binary heap which satisfies max-heap property is called max-heap. In a max-heap, for every node $i$ other than the root, $A[i] \\leq A[parent(i)]$, that is, the value of a node is at most the value of its parent. The largest element in a max-heap is stored at the root, and the subtree rooted at a node contains values no larger than that contained at the node itself.\n\nHere is an example of a max-heap.\n\nWrite a program which reads an array and constructs a max-heap from the array based on the following pseudo code.\n\n$maxHeapify(A, i)$ move the value of $A[i]$ down to leaves to make a sub-tree of node $i$ a max-heap. Here, $H$ is the size of the heap.\n\n1 maxHeapify(A, i)\n2 l = left(i)\n3 r = right(i)\n4 // select the node which has the maximum value\n5 if l ≤ H and A[l] > A[i]\n6 largest = l\n7 else\n8 largest = i\n9 if r ≤ H and A[r] > A[largest]\n10 largest = r\n11\n12 if largest ≠ i // value of children is larger than that of i\n13 swap A[i] and A[largest]\n14 maxHeapify(A, largest) // call recursively\n\nThe following procedure buildMaxHeap(A) makes $A$ a max-heap by performing maxHeapify in a bottom-up manner.\n\n1 buildMaxHeap(A)\n2 for i = H/2 downto 1\n3 maxHeapify(A, i)\n\nInput\n\nIn the first line, an integer $H$ is given. In the second line, $H$ integers which represent elements in the binary heap are given in order of node id (from $1$ to $H$).\n\nOutput\n\nPrint values of nodes in the max-heap in order of their id (from $1$ to $H$). Print a single space character before each value.\n\nConstraint\n\n$1 \\leq H \\leq 500,000$\n\n$-2,000,000,000 \\leq$ value of a node $\\leq 2,000,000,000$\n\nSample Input 1\n\n10\n4 1 3 2 16 9 10 14 8 7\n\nSample Output 1\n\n16 14 10 8 7 9 3 2 4 1\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "10\n4 1 3 2 16 9 10 14 8 7\n"}, "reference_outputs": [" 16 14 10 8 7 9 3 2 4 1\n"], "source_document_id": "p02288", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMaximum Heap\n\nA binary heap which satisfies max-heap property is called max-heap. In a max-heap, for every node $i$ other than the root, $A[i] \\leq A[parent(i)]$, that is, the value of a node is at most the value of its parent. The largest element in a max-heap is stored at the root, and the subtree rooted at a node contains values no larger than that contained at the node itself.\n\nHere is an example of a max-heap.\n\nWrite a program which reads an array and constructs a max-heap from the array based on the following pseudo code.\n\n$maxHeapify(A, i)$ move the value of $A[i]$ down to leaves to make a sub-tree of node $i$ a max-heap. Here, $H$ is the size of the heap.\n\n1 maxHeapify(A, i)\n2 l = left(i)\n3 r = right(i)\n4 // select the node which has the maximum value\n5 if l ≤ H and A[l] > A[i]\n6 largest = l\n7 else\n8 largest = i\n9 if r ≤ H and A[r] > A[largest]\n10 largest = r\n11\n12 if largest ≠ i // value of children is larger than that of i\n13 swap A[i] and A[largest]\n14 maxHeapify(A, largest) // call recursively\n\nThe following procedure buildMaxHeap(A) makes $A$ a max-heap by performing maxHeapify in a bottom-up manner.\n\n1 buildMaxHeap(A)\n2 for i = H/2 downto 1\n3 maxHeapify(A, i)\n\nInput\n\nIn the first line, an integer $H$ is given. In the second line, $H$ integers which represent elements in the binary heap are given in order of node id (from $1$ to $H$).\n\nOutput\n\nPrint values of nodes in the max-heap in order of their id (from $1$ to $H$). Print a single space character before each value.\n\nConstraint\n\n$1 \\leq H \\leq 500,000$\n\n$-2,000,000,000 \\leq$ value of a node $\\leq 2,000,000,000$\n\nSample Input 1\n\n10\n4 1 3 2 16 9 10 14 8 7\n\nSample Output 1\n\n16 14 10 8 7 9 3 2 4 1\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1419, "cpu_time_ms": 230, "memory_kb": 43768}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s334518107", "group_id": "codeNet:p02290", "input_text": "import java.io._\nimport scala.io.StdIn.{readLine, readInt}\n\nobject Main {\n val out:BufferedWriter =\n new BufferedWriter(new OutputStreamWriter(new FileOutputStream(java.io.FileDescriptor.out), \"ASCII\"), 512)\n var count = 0\n\n def toZero(x:Double) = if(x == -0.0) 0.0 else x\n def main(args:Array[String]) = {\n val p = readLine.split(\" \").map(_.toDouble)\n val n = readInt\n\n val (x0,y0,x1,y1) = (p(0),p(1),p(2),p(3))\n for(i<-0 until n) {\n val p1 = readLine.split(\" \").map(_.toDouble)\n val (x2,y2) = (p1(0),p1(1))\n val sqrt = Math.pow(x1-x0,2) + Math.pow(y1-y0,2)\n val inner = (x1-x0)*(x2-x0) + (y1-y0)*(y2-y0)\n val (xt,yt) = (inner*(x1-x0)/sqrt + x0, inner*(y1-y0)/sqrt + y0)\n out.write(toZero(xt).toString)\n out.write(\" \")\n out.write(toZero(yt).toString)\n out.write(\"\\n\")\n if(count<10) count += 1\n else {\n out.flush\n count = 0\n }\n }\n out.flush\n out.close\n }\n}", "language": "Scala", "metadata": {"date": 1494065551, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02290.html", "problem_id": "p02290", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02290/input.txt", "sample_output_relpath": "derived/input_output/data/p02290/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02290/Scala/s334518107.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s334518107", "user_id": "u508732591"}, "prompt_components": {"gold_output": "-1.0000000000 0.0000000000\n0.0000000000 0.0000000000\n1.0000000000 0.0000000000\n", "input_to_evaluate": "import java.io._\nimport scala.io.StdIn.{readLine, readInt}\n\nobject Main {\n val out:BufferedWriter =\n new BufferedWriter(new OutputStreamWriter(new FileOutputStream(java.io.FileDescriptor.out), \"ASCII\"), 512)\n var count = 0\n\n def toZero(x:Double) = if(x == -0.0) 0.0 else x\n def main(args:Array[String]) = {\n val p = readLine.split(\" \").map(_.toDouble)\n val n = readInt\n\n val (x0,y0,x1,y1) = (p(0),p(1),p(2),p(3))\n for(i<-0 until n) {\n val p1 = readLine.split(\" \").map(_.toDouble)\n val (x2,y2) = (p1(0),p1(1))\n val sqrt = Math.pow(x1-x0,2) + Math.pow(y1-y0,2)\n val inner = (x1-x0)*(x2-x0) + (y1-y0)*(y2-y0)\n val (xt,yt) = (inner*(x1-x0)/sqrt + x0, inner*(y1-y0)/sqrt + y0)\n out.write(toZero(xt).toString)\n out.write(\" \")\n out.write(toZero(yt).toString)\n out.write(\"\\n\")\n if(count<10) count += 1\n else {\n out.flush\n count = 0\n }\n }\n out.flush\n out.close\n }\n}", "problem_context": "Projection\n\nFor given three points p1, p2, p, find the projection point x of p onto p1p2.\n\nInput\n\nxp1 yp1 xp2 yp2\nq\nxp0 yp0\nxp1 yp1\n...\nxpq−1 ypq−1\n\nIn the first line, integer coordinates of p1 and p2 are given. Then, q queries are given for integer coordinates of p.\n\nOutput\n\nFor each query, print the coordinate of the projection point x. The output values should be in a decimal fraction with an error less than 0.00000001.\n\nConstraints\n\n1 ≤ q ≤ 1000\n\n-10000 ≤ xi, yi ≤ 10000\n\np1 and p2 are not identical.\n\nSample Input 1\n\n0 0 2 0\n3\n-1 1\n0 1\n1 1\n\nSample Output 1\n\n-1.0000000000 0.0000000000\n0.0000000000 0.0000000000\n1.0000000000 0.0000000000\n\nSample Input 2\n\n0 0 3 4\n1\n2 5\n\nSample Output 2\n\n3.1200000000 4.1600000000", "sample_input": "0 0 2 0\n3\n-1 1\n0 1\n1 1\n"}, "reference_outputs": ["-1.0000000000 0.0000000000\n0.0000000000 0.0000000000\n1.0000000000 0.0000000000\n"], "source_document_id": "p02290", "source_text": "Projection\n\nFor given three points p1, p2, p, find the projection point x of p onto p1p2.\n\nInput\n\nxp1 yp1 xp2 yp2\nq\nxp0 yp0\nxp1 yp1\n...\nxpq−1 ypq−1\n\nIn the first line, integer coordinates of p1 and p2 are given. Then, q queries are given for integer coordinates of p.\n\nOutput\n\nFor each query, print the coordinate of the projection point x. The output values should be in a decimal fraction with an error less than 0.00000001.\n\nConstraints\n\n1 ≤ q ≤ 1000\n\n-10000 ≤ xi, yi ≤ 10000\n\np1 and p2 are not identical.\n\nSample Input 1\n\n0 0 2 0\n3\n-1 1\n0 1\n1 1\n\nSample Output 1\n\n-1.0000000000 0.0000000000\n0.0000000000 0.0000000000\n1.0000000000 0.0000000000\n\nSample Input 2\n\n0 0 3 4\n1\n2 5\n\nSample Output 2\n\n3.1200000000 4.1600000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 936, "cpu_time_ms": 290, "memory_kb": 46696}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s087216854", "group_id": "codeNet:p02294", "input_text": "import scala.io.StdIn.{readInt,readLine}\n\nobject Main {\n def cross(x0:Double, y0:Double, x1:Double, y1:Double) = x0*y1-x1*y0\n def inner(x0:Double, y0:Double, x1:Double, y1:Double) = x0*x1+y0*y1\n def norm(x:Double, y:Double) = x*x+y*y\n\n def dir(x0:Double,y0:Double,x1:Double,y1:Double) =\n if(cross(x0,y0,x1,y1) > (1e-10)) (-1)\n else if(cross(x0,y0,x1,y1) < -(1e-10)) 1\n else if(inner(x0,y0,x1,y1) < -(1e-10)) 1\n else if(norm(x0,y0) < norm(x1,y1)) 0\n else 0\n\n def intersect(x0:Double,y0:Double,x1:Double,y1:Double,x2:Double,y2:Double,x3:Double,y3:Double) = {\n (dir(x2-x0,y2-y0,x1-x0,y1-y0) * dir(x3-x0,y3-y0,x1-x0,y1-y0) <= 0) &&\n (dir(x1-x2,y1-y2,x3-x2,y3-y2) * dir(x0-x2,y0-y2,x3-x2,y3-y2) <= 0)\n }\n\n def main(args:Array[String]) = {\n val n = readInt\n for(i<-0 until n) {\n val s = readLine.split(\" \").map(_.toDouble)\n if(intersect(s(0),s(1),s(2),s(3),s(4),s(5),s(6),s(7))) println(1)\n else println(0)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1495358058, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02294.html", "problem_id": "p02294", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02294/input.txt", "sample_output_relpath": "derived/input_output/data/p02294/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02294/Scala/s087216854.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s087216854", "user_id": "u508732591"}, "prompt_components": {"gold_output": "1\n1\n0\n", "input_to_evaluate": "import scala.io.StdIn.{readInt,readLine}\n\nobject Main {\n def cross(x0:Double, y0:Double, x1:Double, y1:Double) = x0*y1-x1*y0\n def inner(x0:Double, y0:Double, x1:Double, y1:Double) = x0*x1+y0*y1\n def norm(x:Double, y:Double) = x*x+y*y\n\n def dir(x0:Double,y0:Double,x1:Double,y1:Double) =\n if(cross(x0,y0,x1,y1) > (1e-10)) (-1)\n else if(cross(x0,y0,x1,y1) < -(1e-10)) 1\n else if(inner(x0,y0,x1,y1) < -(1e-10)) 1\n else if(norm(x0,y0) < norm(x1,y1)) 0\n else 0\n\n def intersect(x0:Double,y0:Double,x1:Double,y1:Double,x2:Double,y2:Double,x3:Double,y3:Double) = {\n (dir(x2-x0,y2-y0,x1-x0,y1-y0) * dir(x3-x0,y3-y0,x1-x0,y1-y0) <= 0) &&\n (dir(x1-x2,y1-y2,x3-x2,y3-y2) * dir(x0-x2,y0-y2,x3-x2,y3-y2) <= 0)\n }\n\n def main(args:Array[String]) = {\n val n = readInt\n for(i<-0 until n) {\n val s = readLine.split(\" \").map(_.toDouble)\n if(intersect(s(0),s(1),s(2),s(3),s(4),s(5),s(6),s(7))) println(1)\n else println(0)\n }\n }\n}", "problem_context": "Intersection\n\nFor given two segments s1 and s2, print \"1\" if they are intersect, \"0\" otherwise.\n\ns1 is formed by end points p0 and p1, and\ns2 is formed by end points p2 and p3.\n\nInput\n\nThe entire input looks like:\n\nq (the number of queries)\n1st query\n2nd query\n...\nqth query\n\nEach query consists of integer coordinates of end points of s1 and s2 in the following format:\n\nxp0 yp0 xp1 yp1 xp2 yp2 xp3 yp3\n\nOutput\n\nFor each query, print \"1\" or \"0\".\n\nConstraints\n\n1 ≤ q ≤ 1000\n\n-10000 ≤ xpi, ypi ≤ 10000\n\np0 ≠ p1 and\np2 ≠ p3.\n\nSample Input 1\n\n3\n0 0 3 0 1 1 2 -1\n0 0 3 0 3 1 3 -1\n0 0 3 0 3 -2 5 0\n\nSample Output 1\n\n1\n1\n0", "sample_input": "3\n0 0 3 0 1 1 2 -1\n0 0 3 0 3 1 3 -1\n0 0 3 0 3 -2 5 0\n"}, "reference_outputs": ["1\n1\n0\n"], "source_document_id": "p02294", "source_text": "Intersection\n\nFor given two segments s1 and s2, print \"1\" if they are intersect, \"0\" otherwise.\n\ns1 is formed by end points p0 and p1, and\ns2 is formed by end points p2 and p3.\n\nInput\n\nThe entire input looks like:\n\nq (the number of queries)\n1st query\n2nd query\n...\nqth query\n\nEach query consists of integer coordinates of end points of s1 and s2 in the following format:\n\nxp0 yp0 xp1 yp1 xp2 yp2 xp3 yp3\n\nOutput\n\nFor each query, print \"1\" or \"0\".\n\nConstraints\n\n1 ≤ q ≤ 1000\n\n-10000 ≤ xpi, ypi ≤ 10000\n\np0 ≠ p1 and\np2 ≠ p3.\n\nSample Input 1\n\n3\n0 0 3 0 1 1 2 -1\n0 0 3 0 3 1 3 -1\n0 0 3 0 3 -2 5 0\n\nSample Output 1\n\n1\n1\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 960, "cpu_time_ms": 350, "memory_kb": 48332}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s020417430", "group_id": "codeNet:p02316", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val (num, limit) = {\n val nw = io.StdIn.readLine().split(\" \").map(_.toInt)\n (nw(0), nw(1))\n }\n val items = new Array[(Int, Int)](num)\n for (i <- 0 until num) {\n val vw = io.StdIn.readLine().split(\" \").map(_.toInt)\n items(i) = (vw(0), vw(1))\n }\n\n val dp = solve(limit, items)\n println(dp(num)(limit))\n }\n\n def solve(limit: Int, items: Array[(Int, Int)]): Array[Array[Int]] = {\n val dp = Array.ofDim[Int](items.length + 1, limit + 1)\n\n items.zipWithIndex.foreach { case ((v, w), i) =>\n for (l <- 1 to limit) {\n if (w <= l && dp(i)(l) < dp(i)(l - w) + v) {\n dp(i + 1)(l) = dp(i)(l - w) + v\n } else {\n dp(i + 1)(l) = dp(i)(l)\n }\n }\n }\n dp\n }\n}", "language": "Scala", "metadata": {"date": 1487658931, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02316.html", "problem_id": "p02316", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02316/input.txt", "sample_output_relpath": "derived/input_output/data/p02316/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02316/Scala/s020417430.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s020417430", "user_id": "u959441351"}, "prompt_components": {"gold_output": "21\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val (num, limit) = {\n val nw = io.StdIn.readLine().split(\" \").map(_.toInt)\n (nw(0), nw(1))\n }\n val items = new Array[(Int, Int)](num)\n for (i <- 0 until num) {\n val vw = io.StdIn.readLine().split(\" \").map(_.toInt)\n items(i) = (vw(0), vw(1))\n }\n\n val dp = solve(limit, items)\n println(dp(num)(limit))\n }\n\n def solve(limit: Int, items: Array[(Int, Int)]): Array[Array[Int]] = {\n val dp = Array.ofDim[Int](items.length + 1, limit + 1)\n\n items.zipWithIndex.foreach { case ((v, w), i) =>\n for (l <- 1 to limit) {\n if (w <= l && dp(i)(l) < dp(i)(l - w) + v) {\n dp(i + 1)(l) = dp(i)(l - w) + v\n } else {\n dp(i + 1)(l) = dp(i)(l)\n }\n }\n }\n dp\n }\n}", "problem_context": "Knapsack Problem\n\nYou have N kinds of items that you want to put them into a knapsack. Item i has value vi and weight wi.\n\nYou want to find a subset of items to put such that:\n\nThe total value of the items is as large as possible.\n\nThe items have combined weight at most W, that is capacity of the knapsack.\n\nYou can select as many items as possible into a knapsack for each kind.\n\nFind the maximum total value of items in the knapsack.\n\nInput\n\nN W\nv1 w1\nv2 w2\n:\nvN wN\n\nThe first line consists of the integers N and W. In the following lines, the value and weight of the i-th item are given.\n\nOutput\n\nPrint the maximum total values of the items in a line.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ vi ≤ 1000\n\n1 ≤ wi ≤ 1000\n\n1 ≤ W ≤ 10000\n\nSample Input 1\n\n4 8\n4 2\n5 2\n2 1\n8 3\n\nSample Output 1\n\n21\n\nSample Input 2\n\n2 20\n5 9\n4 10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n3 9\n2 1\n3 1\n5 2\n\nSample Output 3\n\n27", "sample_input": "4 8\n4 2\n5 2\n2 1\n8 3\n"}, "reference_outputs": ["21\n"], "source_document_id": "p02316", "source_text": "Knapsack Problem\n\nYou have N kinds of items that you want to put them into a knapsack. Item i has value vi and weight wi.\n\nYou want to find a subset of items to put such that:\n\nThe total value of the items is as large as possible.\n\nThe items have combined weight at most W, that is capacity of the knapsack.\n\nYou can select as many items as possible into a knapsack for each kind.\n\nFind the maximum total value of items in the knapsack.\n\nInput\n\nN W\nv1 w1\nv2 w2\n:\nvN wN\n\nThe first line consists of the integers N and W. In the following lines, the value and weight of the i-th item are given.\n\nOutput\n\nPrint the maximum total values of the items in a line.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ vi ≤ 1000\n\n1 ≤ wi ≤ 1000\n\n1 ≤ W ≤ 10000\n\nSample Input 1\n\n4 8\n4 2\n5 2\n2 1\n8 3\n\nSample Output 1\n\n21\n\nSample Input 2\n\n2 20\n5 9\n4 10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n3 9\n2 1\n3 1\n5 2\n\nSample Output 3\n\n27", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 801, "cpu_time_ms": 230, "memory_kb": 43652}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s027135374", "group_id": "codeNet:p02343", "input_text": "object Main {\n\n class UnionFind(val n: Int) {\n private[this] val par = Array.range(0, n)\n\n def root(x: Int): Int = if(par(x) == x) x else root(par(x))\n\n def same(x: Int, y: Int): Boolean = root(x) == root(y)\n\n def unite(x: Int, y: Int): Unit = par(root(x)) = root(y)\n }\n\n def main(args: Array[String]): Unit = {\n val Array(n,q,_*) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n val uf = new UnionFind(n)\n\n for(i <- 1 to q){\n val Array(com,x,y,_*) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n if(com==0)uf.unite(x,y)\n else println(if(uf.same(x,y)) 1 else 0)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1440851617, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02343.html", "problem_id": "p02343", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02343/input.txt", "sample_output_relpath": "derived/input_output/data/p02343/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02343/Scala/s027135374.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s027135374", "user_id": "u047988051"}, "prompt_components": {"gold_output": "0\n0\n1\n1\n1\n0\n1\n1\n", "input_to_evaluate": "object Main {\n\n class UnionFind(val n: Int) {\n private[this] val par = Array.range(0, n)\n\n def root(x: Int): Int = if(par(x) == x) x else root(par(x))\n\n def same(x: Int, y: Int): Boolean = root(x) == root(y)\n\n def unite(x: Int, y: Int): Unit = par(root(x)) = root(y)\n }\n\n def main(args: Array[String]): Unit = {\n val Array(n,q,_*) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n val uf = new UnionFind(n)\n\n for(i <- 1 to q){\n val Array(com,x,y,_*) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n if(com==0)uf.unite(x,y)\n else println(if(uf.same(x,y)) 1 else 0)\n }\n }\n}", "problem_context": "Disjoint Set\n\nWrite a program which manipulates a disjoint set S = {S1, S2, . . . , Sk}.\n\nFirst of all, the program should read an integer n, then make a disjoint set where each element consists of 0, 1, ... n−1 respectively.\n\nNext, the program should read an integer q and manipulate the set for q queries. There are two kinds of queries for different operations:\n\nunite(x, y): unites sets that contain x and y, say Sx and Sy, into a new set.\n\nsame(x, y): determine whether x and y are in the same set.\n\nInput\n\nn q\ncom1 x1 y1\ncom2 x2 y2\n...\ncomq xq yq\n\nIn the first line, n and q are given. Then, q queries are given where com represents the type of queries. '0' denotes unite and '1' denotes same operation.\n\nOutput\n\nFor each same operation, print 1 if x and y are in the same set, otherwise 0, in a line.\n\nConstraints\n\n1 ≤ n ≤ 10000\n\n1 ≤ q ≤ 100000\n\nx ≠ y\n\nSample Input\n\n5 12\n0 1 4\n0 2 3\n1 1 2\n1 3 4\n1 1 4\n1 3 2\n0 1 3\n1 2 4\n1 3 0\n0 0 4\n1 0 2\n1 3 0\n\nSample Output\n\n0\n0\n1\n1\n1\n0\n1\n1", "sample_input": "5 12\n0 1 4\n0 2 3\n1 1 2\n1 3 4\n1 1 4\n1 3 2\n0 1 3\n1 2 4\n1 3 0\n0 0 4\n1 0 2\n1 3 0\n"}, "reference_outputs": ["0\n0\n1\n1\n1\n0\n1\n1\n"], "source_document_id": "p02343", "source_text": "Disjoint Set\n\nWrite a program which manipulates a disjoint set S = {S1, S2, . . . , Sk}.\n\nFirst of all, the program should read an integer n, then make a disjoint set where each element consists of 0, 1, ... n−1 respectively.\n\nNext, the program should read an integer q and manipulate the set for q queries. There are two kinds of queries for different operations:\n\nunite(x, y): unites sets that contain x and y, say Sx and Sy, into a new set.\n\nsame(x, y): determine whether x and y are in the same set.\n\nInput\n\nn q\ncom1 x1 y1\ncom2 x2 y2\n...\ncomq xq yq\n\nIn the first line, n and q are given. Then, q queries are given where com represents the type of queries. '0' denotes unite and '1' denotes same operation.\n\nOutput\n\nFor each same operation, print 1 if x and y are in the same set, otherwise 0, in a line.\n\nConstraints\n\n1 ≤ n ≤ 10000\n\n1 ≤ q ≤ 100000\n\nx ≠ y\n\nSample Input\n\n5 12\n0 1 4\n0 2 3\n1 1 2\n1 3 4\n1 1 4\n1 3 2\n0 1 3\n1 2 4\n1 3 0\n0 0 4\n1 0 2\n1 3 0\n\nSample Output\n\n0\n0\n1\n1\n1\n0\n1\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1580, "memory_kb": 149176}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s987857058", "group_id": "codeNet:p02343", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val s = new Main()\n s.solve()\n s.out.flush()\n }\n}\n\nclass Main {\n import java.io._\n import java.util.StringTokenizer\n\n import scala.collection.mutable\n import scala.util.Sorting\n import math.{abs, max, min}\n import mutable.{ArrayBuffer, ListBuffer}\n import scala.reflect.ClassTag\n\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n\n def solve(): Unit = {\n val N, Q = ni()\n val uf = new UnionFind(N)\n REP(Q) { _ =>\n val com, x, y = ni()\n com match {\n case 0 => uf.unite(x, y)\n case 1 =>\n val res = if (uf.find(x) == uf.find(y)) 1 else 0\n out.println(res)\n }\n }\n }\n\n class UnionFind(val n: Int) {\n private val par = Array.ofDim[Int](n)\n REP(n) (i => par(i) = i)\n val rank: Array[Int] = Array.fill[Int](n)(1) // 集合の要素数\n private val visits = Array.ofDim[Int](n) // 訪れた場所をfind毎に用意するのがもったいないのでつかいまわす\n\n def find(x: Int): Int = {\n var ptr = 0\n def step(x: Int): Int = {\n if (par(x) == x) x\n else {\n visits(ptr) = x\n ptr += 1\n step(par(x))\n }\n }\n\n val res = step(x)\n REP(ptr){ i => par(visits(i)) = res }\n res\n }\n\n def unite(x: Int, y: Int): Int = {\n val x1 = find(x)\n val y1 = find(y)\n if (x1 == y1) x1\n else {\n if (rank(x1) < rank(y)) {\n par(x1) = y1\n y1\n } else {\n par(y1) = x1\n if (rank(x1) == rank(y1)) rank(x1) += rank(y1)\n x1\n }\n }\n }\n\n /**\n * xを解決する必要がないときは直にrankをみる\n */\n def cntNodes(x: Int): Int = rank(find(x))\n }\n\n private val oj = System.getenv(\"ATCODER_DEBUG\") == null\n\n def DEBUG(f: => Unit): Unit = {\n if (!oj){ f }\n }\n\n def debug(as: Array[Boolean]): Unit = DEBUG {\n debug(as.map(x => if(x) \"1\" else \"0\").mkString)\n }\n\n def debug(as: Array[Int]): Unit = DEBUG {\n debug(as.mkString(\" \"))\n }\n\n def debug(as: Array[Long]): Unit = DEBUG {\n debug(as.mkString(\" \"))\n }\n\n def debug(s: => String): Unit = DEBUG {\n System.err.println(s)\n }\n\n def debugNum(num: => Long): Unit = DEBUG {\n System.err.println(num)\n }\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next().toInt\n def nextLong(): Long = next().toLong\n def nextChar(): Char = next().charAt(0)\n }\n val sc = new InputReader(System.in)\n def ni(): Int = sc.nextInt()\n def nl(): Long = sc.nextLong()\n def nc(): Char = sc.nextChar()\n def ns(): String = sc.next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n\n def cumSum(as: Array[Int]) = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1552243332, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02343.html", "problem_id": "p02343", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02343/input.txt", "sample_output_relpath": "derived/input_output/data/p02343/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02343/Scala/s987857058.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s987857058", "user_id": "u716945028"}, "prompt_components": {"gold_output": "0\n0\n1\n1\n1\n0\n1\n1\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val s = new Main()\n s.solve()\n s.out.flush()\n }\n}\n\nclass Main {\n import java.io._\n import java.util.StringTokenizer\n\n import scala.collection.mutable\n import scala.util.Sorting\n import math.{abs, max, min}\n import mutable.{ArrayBuffer, ListBuffer}\n import scala.reflect.ClassTag\n\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n\n def solve(): Unit = {\n val N, Q = ni()\n val uf = new UnionFind(N)\n REP(Q) { _ =>\n val com, x, y = ni()\n com match {\n case 0 => uf.unite(x, y)\n case 1 =>\n val res = if (uf.find(x) == uf.find(y)) 1 else 0\n out.println(res)\n }\n }\n }\n\n class UnionFind(val n: Int) {\n private val par = Array.ofDim[Int](n)\n REP(n) (i => par(i) = i)\n val rank: Array[Int] = Array.fill[Int](n)(1) // 集合の要素数\n private val visits = Array.ofDim[Int](n) // 訪れた場所をfind毎に用意するのがもったいないのでつかいまわす\n\n def find(x: Int): Int = {\n var ptr = 0\n def step(x: Int): Int = {\n if (par(x) == x) x\n else {\n visits(ptr) = x\n ptr += 1\n step(par(x))\n }\n }\n\n val res = step(x)\n REP(ptr){ i => par(visits(i)) = res }\n res\n }\n\n def unite(x: Int, y: Int): Int = {\n val x1 = find(x)\n val y1 = find(y)\n if (x1 == y1) x1\n else {\n if (rank(x1) < rank(y)) {\n par(x1) = y1\n y1\n } else {\n par(y1) = x1\n if (rank(x1) == rank(y1)) rank(x1) += rank(y1)\n x1\n }\n }\n }\n\n /**\n * xを解決する必要がないときは直にrankをみる\n */\n def cntNodes(x: Int): Int = rank(find(x))\n }\n\n private val oj = System.getenv(\"ATCODER_DEBUG\") == null\n\n def DEBUG(f: => Unit): Unit = {\n if (!oj){ f }\n }\n\n def debug(as: Array[Boolean]): Unit = DEBUG {\n debug(as.map(x => if(x) \"1\" else \"0\").mkString)\n }\n\n def debug(as: Array[Int]): Unit = DEBUG {\n debug(as.mkString(\" \"))\n }\n\n def debug(as: Array[Long]): Unit = DEBUG {\n debug(as.mkString(\" \"))\n }\n\n def debug(s: => String): Unit = DEBUG {\n System.err.println(s)\n }\n\n def debugNum(num: => Long): Unit = DEBUG {\n System.err.println(num)\n }\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next().toInt\n def nextLong(): Long = next().toLong\n def nextChar(): Char = next().charAt(0)\n }\n val sc = new InputReader(System.in)\n def ni(): Int = sc.nextInt()\n def nl(): Long = sc.nextLong()\n def nc(): Char = sc.nextChar()\n def ns(): String = sc.next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n\n def cumSum(as: Array[Int]) = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n\n", "problem_context": "Disjoint Set\n\nWrite a program which manipulates a disjoint set S = {S1, S2, . . . , Sk}.\n\nFirst of all, the program should read an integer n, then make a disjoint set where each element consists of 0, 1, ... n−1 respectively.\n\nNext, the program should read an integer q and manipulate the set for q queries. There are two kinds of queries for different operations:\n\nunite(x, y): unites sets that contain x and y, say Sx and Sy, into a new set.\n\nsame(x, y): determine whether x and y are in the same set.\n\nInput\n\nn q\ncom1 x1 y1\ncom2 x2 y2\n...\ncomq xq yq\n\nIn the first line, n and q are given. Then, q queries are given where com represents the type of queries. '0' denotes unite and '1' denotes same operation.\n\nOutput\n\nFor each same operation, print 1 if x and y are in the same set, otherwise 0, in a line.\n\nConstraints\n\n1 ≤ n ≤ 10000\n\n1 ≤ q ≤ 100000\n\nx ≠ y\n\nSample Input\n\n5 12\n0 1 4\n0 2 3\n1 1 2\n1 3 4\n1 1 4\n1 3 2\n0 1 3\n1 2 4\n1 3 0\n0 0 4\n1 0 2\n1 3 0\n\nSample Output\n\n0\n0\n1\n1\n1\n0\n1\n1", "sample_input": "5 12\n0 1 4\n0 2 3\n1 1 2\n1 3 4\n1 1 4\n1 3 2\n0 1 3\n1 2 4\n1 3 0\n0 0 4\n1 0 2\n1 3 0\n"}, "reference_outputs": ["0\n0\n1\n1\n1\n0\n1\n1\n"], "source_document_id": "p02343", "source_text": "Disjoint Set\n\nWrite a program which manipulates a disjoint set S = {S1, S2, . . . , Sk}.\n\nFirst of all, the program should read an integer n, then make a disjoint set where each element consists of 0, 1, ... n−1 respectively.\n\nNext, the program should read an integer q and manipulate the set for q queries. There are two kinds of queries for different operations:\n\nunite(x, y): unites sets that contain x and y, say Sx and Sy, into a new set.\n\nsame(x, y): determine whether x and y are in the same set.\n\nInput\n\nn q\ncom1 x1 y1\ncom2 x2 y2\n...\ncomq xq yq\n\nIn the first line, n and q are given. Then, q queries are given where com represents the type of queries. '0' denotes unite and '1' denotes same operation.\n\nOutput\n\nFor each same operation, print 1 if x and y are in the same set, otherwise 0, in a line.\n\nConstraints\n\n1 ≤ n ≤ 10000\n\n1 ≤ q ≤ 100000\n\nx ≠ y\n\nSample Input\n\n5 12\n0 1 4\n0 2 3\n1 1 2\n1 3 4\n1 1 4\n1 3 2\n0 1 3\n1 2 4\n1 3 0\n0 0 4\n1 0 2\n1 3 0\n\nSample Output\n\n0\n0\n1\n1\n1\n0\n1\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4274, "cpu_time_ms": 530, "memory_kb": 101472}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s598333187", "group_id": "codeNet:p02345", "input_text": "import scala.io.StdIn._\n\nobject Main{\n def main(args: Array[String]): Unit = {\n val Array(n,_*) = readLine.split(\" \").map(_.toInt)\n println(readLine.split(\" \").map(_.toInt).sorted.mkString(\" \"))\n }\n}", "language": "Scala", "metadata": {"date": 1435055475, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02345.html", "problem_id": "p02345", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02345/input.txt", "sample_output_relpath": "derived/input_output/data/p02345/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02345/Scala/s598333187.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s598333187", "user_id": "u047988051"}, "prompt_components": {"gold_output": "1\n2\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main{\n def main(args: Array[String]): Unit = {\n val Array(n,_*) = readLine.split(\" \").map(_.toInt)\n println(readLine.split(\" \").map(_.toInt).sorted.mkString(\" \"))\n }\n}", "problem_context": "Range Minimum Query (RMQ)\n\nWrite a program which manipulates a sequence A = {a0, a1, . . . , an-1} with the following operations:\n\nfind(s, t): report the minimum element in as, as+1, . . . ,at.\n\nupdate(i, x): change ai to x.\n\nNote that the initial values of ai (i = 0, 1, . . . , n−1) are 231-1.\n\nInput\n\nn q\ncom0 x0 y0\ncom1 x1 y1\n...\ncomq−1 xq−1 yq−1\n\nIn the first line, n (the number of elements in A) and q (the number of queries) are given. Then, q queries are given where com represents the type of queries. '0' denotes update(xi, yi) and '1' denotes find(xi, yi).\n\nOutput\n\nFor each find operation, print the minimum element.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n1 ≤ q ≤ 100000\n\nIf comi is 0, then 0 ≤ xi < n, 0 ≤ yi < 231-1.\n\nIf comi is 1, then 0 ≤ xi < n, 0 ≤ yi < n.\n\nSample Input 1\n\n3 5\n0 0 1\n0 1 2\n0 2 3\n1 0 2\n1 1 2\n\nSample Output 1\n\n1\n2\n\nSample Input 2\n\n1 3\n1 0 0\n0 0 5\n1 0 0\n\nSample Output 2\n\n2147483647\n5", "sample_input": "3 5\n0 0 1\n0 1 2\n0 2 3\n1 0 2\n1 1 2\n"}, "reference_outputs": ["1\n2\n"], "source_document_id": "p02345", "source_text": "Range Minimum Query (RMQ)\n\nWrite a program which manipulates a sequence A = {a0, a1, . . . , an-1} with the following operations:\n\nfind(s, t): report the minimum element in as, as+1, . . . ,at.\n\nupdate(i, x): change ai to x.\n\nNote that the initial values of ai (i = 0, 1, . . . , n−1) are 231-1.\n\nInput\n\nn q\ncom0 x0 y0\ncom1 x1 y1\n...\ncomq−1 xq−1 yq−1\n\nIn the first line, n (the number of elements in A) and q (the number of queries) are given. Then, q queries are given where com represents the type of queries. '0' denotes update(xi, yi) and '1' denotes find(xi, yi).\n\nOutput\n\nFor each find operation, print the minimum element.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n1 ≤ q ≤ 100000\n\nIf comi is 0, then 0 ≤ xi < n, 0 ≤ yi < 231-1.\n\nIf comi is 1, then 0 ≤ xi < n, 0 ≤ yi < n.\n\nSample Input 1\n\n3 5\n0 0 1\n0 1 2\n0 2 3\n1 0 2\n1 1 2\n\nSample Output 1\n\n1\n2\n\nSample Input 2\n\n1 3\n1 0 0\n0 0 5\n1 0 0\n\nSample Output 2\n\n2147483647\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 207, "cpu_time_ms": 220, "memory_kb": 41056}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s706240272", "group_id": "codeNet:p02345", "input_text": "import scala.io.StdIn.readLine\n\nobject Main {\n\t\n\tdef find(array: Seq[Int], s: Int, t: Int): Int = array.slice(s, t+1).min\n\t\n\tdef update(array: Seq[Int], i: Int, x: Int): Seq[Int] = array.updated(i,x)\n\t\n\tdef main(args: Array[String]){\n\t\tval in = readLine().split(\" \").map(_.toInt)\n\t\tval n = in(0)\n\t\tval q = in(1)\n\t\t\n\t\tvar a = Seq.fill(n)(Integer.MAX_VALUE)\n\t\t\n\t\tfor(_ <- 1 to q){\n\t\t\tval in = readLine().split(\" \").map(_.toInt)\n\t\t\tval com = in(0)\n\t\t\tval x = in(1)\n\t\t\tval y = in(2)\n\t\t\t\n\t\t\tif(com==0) a = update(a,x,y)\n\t\t\telse println(find(a,x,y))\n\t\t}\n\t}\n}", "language": "Scala", "metadata": {"date": 1453651984, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02345.html", "problem_id": "p02345", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02345/input.txt", "sample_output_relpath": "derived/input_output/data/p02345/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02345/Scala/s706240272.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s706240272", "user_id": "u271453140"}, "prompt_components": {"gold_output": "1\n2\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main {\n\t\n\tdef find(array: Seq[Int], s: Int, t: Int): Int = array.slice(s, t+1).min\n\t\n\tdef update(array: Seq[Int], i: Int, x: Int): Seq[Int] = array.updated(i,x)\n\t\n\tdef main(args: Array[String]){\n\t\tval in = readLine().split(\" \").map(_.toInt)\n\t\tval n = in(0)\n\t\tval q = in(1)\n\t\t\n\t\tvar a = Seq.fill(n)(Integer.MAX_VALUE)\n\t\t\n\t\tfor(_ <- 1 to q){\n\t\t\tval in = readLine().split(\" \").map(_.toInt)\n\t\t\tval com = in(0)\n\t\t\tval x = in(1)\n\t\t\tval y = in(2)\n\t\t\t\n\t\t\tif(com==0) a = update(a,x,y)\n\t\t\telse println(find(a,x,y))\n\t\t}\n\t}\n}", "problem_context": "Range Minimum Query (RMQ)\n\nWrite a program which manipulates a sequence A = {a0, a1, . . . , an-1} with the following operations:\n\nfind(s, t): report the minimum element in as, as+1, . . . ,at.\n\nupdate(i, x): change ai to x.\n\nNote that the initial values of ai (i = 0, 1, . . . , n−1) are 231-1.\n\nInput\n\nn q\ncom0 x0 y0\ncom1 x1 y1\n...\ncomq−1 xq−1 yq−1\n\nIn the first line, n (the number of elements in A) and q (the number of queries) are given. Then, q queries are given where com represents the type of queries. '0' denotes update(xi, yi) and '1' denotes find(xi, yi).\n\nOutput\n\nFor each find operation, print the minimum element.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n1 ≤ q ≤ 100000\n\nIf comi is 0, then 0 ≤ xi < n, 0 ≤ yi < 231-1.\n\nIf comi is 1, then 0 ≤ xi < n, 0 ≤ yi < n.\n\nSample Input 1\n\n3 5\n0 0 1\n0 1 2\n0 2 3\n1 0 2\n1 1 2\n\nSample Output 1\n\n1\n2\n\nSample Input 2\n\n1 3\n1 0 0\n0 0 5\n1 0 0\n\nSample Output 2\n\n2147483647\n5", "sample_input": "3 5\n0 0 1\n0 1 2\n0 2 3\n1 0 2\n1 1 2\n"}, "reference_outputs": ["1\n2\n"], "source_document_id": "p02345", "source_text": "Range Minimum Query (RMQ)\n\nWrite a program which manipulates a sequence A = {a0, a1, . . . , an-1} with the following operations:\n\nfind(s, t): report the minimum element in as, as+1, . . . ,at.\n\nupdate(i, x): change ai to x.\n\nNote that the initial values of ai (i = 0, 1, . . . , n−1) are 231-1.\n\nInput\n\nn q\ncom0 x0 y0\ncom1 x1 y1\n...\ncomq−1 xq−1 yq−1\n\nIn the first line, n (the number of elements in A) and q (the number of queries) are given. Then, q queries are given where com represents the type of queries. '0' denotes update(xi, yi) and '1' denotes find(xi, yi).\n\nOutput\n\nFor each find operation, print the minimum element.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n1 ≤ q ≤ 100000\n\nIf comi is 0, then 0 ≤ xi < n, 0 ≤ yi < 231-1.\n\nIf comi is 1, then 0 ≤ xi < n, 0 ≤ yi < n.\n\nSample Input 1\n\n3 5\n0 0 1\n0 1 2\n0 2 3\n1 0 2\n1 1 2\n\nSample Output 1\n\n1\n2\n\nSample Input 2\n\n1 3\n1 0 0\n0 0 5\n1 0 0\n\nSample Output 2\n\n2147483647\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 552, "cpu_time_ms": 330, "memory_kb": 44480}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s893038541", "group_id": "codeNet:p02348", "input_text": "object Main extends App {\n val in = io.Source.stdin.getLines.map(_.split(\" \").map(_.toInt))\n val x = List(Array(0, in.next.head-1, 2147483647))\n in.foldLeft(x)((qs, q) => q match {\n case Array(0, _*) => q.tail +: qs\n case Array(1, i) => {\n println((qs.find(y => y(0) <= i && y(1) >= i).get)(2))\n qs\n }\n })\n}", "language": "Scala", "metadata": {"date": 1493778843, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02348.html", "problem_id": "p02348", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02348/input.txt", "sample_output_relpath": "derived/input_output/data/p02348/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02348/Scala/s893038541.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s893038541", "user_id": "u475394465"}, "prompt_components": {"gold_output": "1\n3\n", "input_to_evaluate": "object Main extends App {\n val in = io.Source.stdin.getLines.map(_.split(\" \").map(_.toInt))\n val x = List(Array(0, in.next.head-1, 2147483647))\n in.foldLeft(x)((qs, q) => q match {\n case Array(0, _*) => q.tail +: qs\n case Array(1, i) => {\n println((qs.find(y => y(0) <= i && y(1) >= i).get)(2))\n qs\n }\n })\n}", "problem_context": "Range Update Query (RUQ)\n\nWrite a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations:\n\nupdate(s, t, x): change as, as+1, ..., at to x.\n\nfind(i): output the value of ai.\n\nNote that the initial values of ai (i = 0, 1, . . . , n−1) are 231-1.\n\nInput\n\nn q\nquery1\nquery2\n:\nqueryq\n\nIn the first line, n (the number of elements in A) and q (the number of queries) are given. Then, ith query queryi is given in the following format:\n\n0 s t x\n\nor\n\n1 i\n\nThe first digit represents the type of the query. '0' denotes update(s, t, x) and '1' denotes find(i).\n\nOutput\n\nFor each find operation, print the value.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n1 ≤ q ≤ 100000\n\n0 ≤ s ≤ t < n\n\n0 ≤ i < n\n\n0 ≤ x < 231−1\n\nSample Input 1\n\n3 5\n0 0 1 1\n0 1 2 3\n0 2 2 2\n1 0\n1 1\n\nSample Output 1\n\n1\n3\n\nSample Input 2\n\n1 3\n1 0\n0 0 0 5\n1 0\n\nSample Output 2\n\n2147483647\n5", "sample_input": "3 5\n0 0 1 1\n0 1 2 3\n0 2 2 2\n1 0\n1 1\n"}, "reference_outputs": ["1\n3\n"], "source_document_id": "p02348", "source_text": "Range Update Query (RUQ)\n\nWrite a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations:\n\nupdate(s, t, x): change as, as+1, ..., at to x.\n\nfind(i): output the value of ai.\n\nNote that the initial values of ai (i = 0, 1, . . . , n−1) are 231-1.\n\nInput\n\nn q\nquery1\nquery2\n:\nqueryq\n\nIn the first line, n (the number of elements in A) and q (the number of queries) are given. Then, ith query queryi is given in the following format:\n\n0 s t x\n\nor\n\n1 i\n\nThe first digit represents the type of the query. '0' denotes update(s, t, x) and '1' denotes find(i).\n\nOutput\n\nFor each find operation, print the value.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n1 ≤ q ≤ 100000\n\n0 ≤ s ≤ t < n\n\n0 ≤ i < n\n\n0 ≤ x < 231−1\n\nSample Input 1\n\n3 5\n0 0 1 1\n0 1 2 3\n0 2 2 2\n1 0\n1 1\n\nSample Output 1\n\n1\n3\n\nSample Input 2\n\n1 3\n1 0\n0 0 0 5\n1 0\n\nSample Output 2\n\n2147483647\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 362, "cpu_time_ms": 1790, "memory_kb": 192860}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s341729935", "group_id": "codeNet:p02376", "input_text": "import java.util.Scanner\n\nimport scala.collection.mutable\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main extends App {\n val in = new Scanner(System.in)\n val V = in.nextInt()\n val E = in.nextInt()\n val dinitz = new Dinitz(V)\n for (_ <- 0 until E) {\n val s = in.nextInt()\n val t = in.nextInt()\n val c = in.nextInt()\n dinitz.addEdge(s, t, c)\n }\n\n val f = dinitz.maxFlow(0, V - 1)\n println(f)\n}\n\nimport java.util\n\nclass Dinitz(val V: Int) {\n\n class Edge(var to: Int, var cap: Long, var rev: Int)\n\n private val graph = (for (_ <- 0 until V) yield new ArrayBuffer[Edge]()).toArray\n private val iter = new Array[Int](V)\n\n\n def addEdge(from: Int, to: Int, cap: Long): Unit = {\n graph(from).append(new Edge(to, cap, graph(to).size))\n graph(to).append(new Edge(from, 0, graph(from).size - 1))\n }\n\n def maxFlow(source: Int, sink: Int): Long = {\n var flow = 0L\n\n while (true) {\n val queue = new mutable.Queue[Int]()\n val level = Array.fill[Int](V)(-1)\n level(source) = 0\n queue.enqueue(source)\n while (queue.nonEmpty) {\n val v = queue.dequeue()\n for (e <- graph(v)) {\n if (e.cap > 0 && level(e.to) < 0) {\n level(e.to) = level(v) + 1\n queue.enqueue(e.to)\n }\n }\n }\n\n if (level(sink) < 0) return flow\n util.Arrays.fill(iter, 0)\n\n def dfs(v: Int, t: Int, f: Long): Long = {\n if (v == t) return f\n\n while (iter(v) < graph(v).size) {\n val e = graph(v)(iter(v))\n if (e.cap > 0 && level(v) < level(e.to)) {\n val d = dfs(e.to, t, Math.min(f, e.cap))\n if (d > 0) {\n e.cap -= d\n graph(e.to)(e.rev).cap += d\n return d\n }\n }\n\n iter(v) += 1\n }\n 0\n }\n\n var f = 1L\n while (f > 0) {\n f = dfs(source, sink, Long.MaxValue)\n flow += f\n }\n }\n\n throw new IllegalStateException()\n }\n}", "language": "Scala", "metadata": {"date": 1505760438, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02376.html", "problem_id": "p02376", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02376/input.txt", "sample_output_relpath": "derived/input_output/data/p02376/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02376/Scala/s341729935.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s341729935", "user_id": "u568152427"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.collection.mutable\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main extends App {\n val in = new Scanner(System.in)\n val V = in.nextInt()\n val E = in.nextInt()\n val dinitz = new Dinitz(V)\n for (_ <- 0 until E) {\n val s = in.nextInt()\n val t = in.nextInt()\n val c = in.nextInt()\n dinitz.addEdge(s, t, c)\n }\n\n val f = dinitz.maxFlow(0, V - 1)\n println(f)\n}\n\nimport java.util\n\nclass Dinitz(val V: Int) {\n\n class Edge(var to: Int, var cap: Long, var rev: Int)\n\n private val graph = (for (_ <- 0 until V) yield new ArrayBuffer[Edge]()).toArray\n private val iter = new Array[Int](V)\n\n\n def addEdge(from: Int, to: Int, cap: Long): Unit = {\n graph(from).append(new Edge(to, cap, graph(to).size))\n graph(to).append(new Edge(from, 0, graph(from).size - 1))\n }\n\n def maxFlow(source: Int, sink: Int): Long = {\n var flow = 0L\n\n while (true) {\n val queue = new mutable.Queue[Int]()\n val level = Array.fill[Int](V)(-1)\n level(source) = 0\n queue.enqueue(source)\n while (queue.nonEmpty) {\n val v = queue.dequeue()\n for (e <- graph(v)) {\n if (e.cap > 0 && level(e.to) < 0) {\n level(e.to) = level(v) + 1\n queue.enqueue(e.to)\n }\n }\n }\n\n if (level(sink) < 0) return flow\n util.Arrays.fill(iter, 0)\n\n def dfs(v: Int, t: Int, f: Long): Long = {\n if (v == t) return f\n\n while (iter(v) < graph(v).size) {\n val e = graph(v)(iter(v))\n if (e.cap > 0 && level(v) < level(e.to)) {\n val d = dfs(e.to, t, Math.min(f, e.cap))\n if (d > 0) {\n e.cap -= d\n graph(e.to)(e.rev).cap += d\n return d\n }\n }\n\n iter(v) += 1\n }\n 0\n }\n\n var f = 1L\n while (f > 0) {\n f = dfs(source, sink, Long.MaxValue)\n flow += f\n }\n }\n\n throw new IllegalStateException()\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMaximum Flow\n\nA flow network is a directed graph which has a $source$ and a $sink$. In a flow network, each edge $(u, v)$ has a capacity $c(u, v)$. Each edge receives a flow, but the amount of flow on the edge can not exceed the corresponding capacity. Find the maximum flow from the $source$ to the $sink$.\n\nInput\n\nA flow network is given in the following format.\n\n$|V|\\;|E|$\n\n$u_0\\;v_0\\;c_0$\n\n$u_1\\;v_1\\;c_1$\n\n:\n\n$u_{|E|-1}\\;v_{|E|-1}\\;c_{|E|-1}$\n\n$|V|$, $|E|$ is the number of vertices and edges of the flow network respectively. The vertices in $G$ are named with the numbers 0, 1,..., $|V|-1$. The source is 0 and the sink is $|V|-1$.\n\n$u_i$, $v_i$, $c_i$ represent $i$-th edge of the flow network.\nA pair of $u_i$ and $v_i$ denotes that there is an edge from $u_i$ to $v_i$ and $c_i$ is the capacity of $i$-th edge.\n\nOutput\n\nPrint the maximum flow.\n\nConstraints\n\n$2 \\leq |V| \\leq 100$\n\n$1 \\leq |E| \\leq 1000$\n\n$0 \\leq c_i \\leq 10000$\n\nSample Input 1\n\n4 5\n0 1 2\n0 2 1\n1 2 1\n1 3 1\n2 3 2\n\nSample Output 1\n\n3", "sample_input": "4 5\n0 1 2\n0 2 1\n1 2 1\n1 3 1\n2 3 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02376", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMaximum Flow\n\nA flow network is a directed graph which has a $source$ and a $sink$. In a flow network, each edge $(u, v)$ has a capacity $c(u, v)$. Each edge receives a flow, but the amount of flow on the edge can not exceed the corresponding capacity. Find the maximum flow from the $source$ to the $sink$.\n\nInput\n\nA flow network is given in the following format.\n\n$|V|\\;|E|$\n\n$u_0\\;v_0\\;c_0$\n\n$u_1\\;v_1\\;c_1$\n\n:\n\n$u_{|E|-1}\\;v_{|E|-1}\\;c_{|E|-1}$\n\n$|V|$, $|E|$ is the number of vertices and edges of the flow network respectively. The vertices in $G$ are named with the numbers 0, 1,..., $|V|-1$. The source is 0 and the sink is $|V|-1$.\n\n$u_i$, $v_i$, $c_i$ represent $i$-th edge of the flow network.\nA pair of $u_i$ and $v_i$ denotes that there is an edge from $u_i$ to $v_i$ and $c_i$ is the capacity of $i$-th edge.\n\nOutput\n\nPrint the maximum flow.\n\nConstraints\n\n$2 \\leq |V| \\leq 100$\n\n$1 \\leq |E| \\leq 1000$\n\n$0 \\leq c_i \\leq 10000$\n\nSample Input 1\n\n4 5\n0 1 2\n0 2 1\n1 2 1\n1 3 1\n2 3 2\n\nSample Output 1\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1980, "cpu_time_ms": 360, "memory_kb": 52848}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s538573543", "group_id": "codeNet:p02380", "input_text": "object Main extends App {\n val in = readLine.split(' ').map(_.toDouble)\n val a = in(0)\n val b = in(1)\n val C = in(2).toRadians\n\n val c = math.sqrt(a*a + b*b - 2*a*b*math.cos(C))\n\n val L = a + b + c;\n\n val h = b * math.sin(C)\n\n val S = a * h / 2;\n\n println(S)\n println(L)\n println(h)\n}\n\n", "language": "Scala", "metadata": {"date": 1516368175, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02380.html", "problem_id": "p02380", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02380/input.txt", "sample_output_relpath": "derived/input_output/data/p02380/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02380/Scala/s538573543.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s538573543", "user_id": "u816370254"}, "prompt_components": {"gold_output": "6.00000000\n12.00000000\n3.00000000\n", "input_to_evaluate": "object Main extends App {\n val in = readLine.split(' ').map(_.toDouble)\n val a = in(0)\n val b = in(1)\n val C = in(2).toRadians\n\n val c = math.sqrt(a*a + b*b - 2*a*b*math.cos(C))\n\n val L = a + b + c;\n\n val h = b * math.sin(C)\n\n val S = a * h / 2;\n\n println(S)\n println(L)\n println(h)\n}\n\n", "problem_context": "Triangle\n\nFor given two sides of a triangle a and b and the angle C between them, calculate the following properties:\n\nS: Area of the triangle\n\nL: The length of the circumference of the triangle\n\nh: The height of the triangle with side a as a bottom edge\n\nInput\n\nThe length of a, the length of b and the angle C are given in integers.\n\nOutput\n\nPrint S, L and h in a line respectively. The output should not contain an absolute error greater than 10-4.\n\nSample Input\n\n4 3 90\n\nSample Output\n\n6.00000000\n12.00000000\n3.00000000", "sample_input": "4 3 90\n"}, "reference_outputs": ["6.00000000\n12.00000000\n3.00000000\n"], "source_document_id": "p02380", "source_text": "Triangle\n\nFor given two sides of a triangle a and b and the angle C between them, calculate the following properties:\n\nS: Area of the triangle\n\nL: The length of the circumference of the triangle\n\nh: The height of the triangle with side a as a bottom edge\n\nInput\n\nThe length of a, the length of b and the angle C are given in integers.\n\nOutput\n\nPrint S, L and h in a line respectively. The output should not contain an absolute error greater than 10-4.\n\nSample Input\n\n4 3 90\n\nSample Output\n\n6.00000000\n12.00000000\n3.00000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 43916}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s450418293", "group_id": "codeNet:p02381", "input_text": "import scala.io.Source\nimport scala.math._\n\nobject Main{\n def main(args: Array[String]){\n val lines = for{\n in <- Source.stdin.getLines.toList\n }yield in\n\n val num = lines.length / 2\n\n for(i <- 0 until num){\n println(stdDeviation(lines(i * 2 + 1).split(\" \").toList.map(_.toDouble)))\n }\n }\n\n def stdDeviation(list: List[Double]): Double={\n sqrt(list.map{_ - (list.sum / list.length)}.map{pow(_, 2)}.sum / list.length)\n }\n}", "language": "Scala", "metadata": {"date": 1440399231, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02381.html", "problem_id": "p02381", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02381/input.txt", "sample_output_relpath": "derived/input_output/data/p02381/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02381/Scala/s450418293.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s450418293", "user_id": "u085441951"}, "prompt_components": {"gold_output": "27.85677655\n0.00000000\n", "input_to_evaluate": "import scala.io.Source\nimport scala.math._\n\nobject Main{\n def main(args: Array[String]){\n val lines = for{\n in <- Source.stdin.getLines.toList\n }yield in\n\n val num = lines.length / 2\n\n for(i <- 0 until num){\n println(stdDeviation(lines(i * 2 + 1).split(\" \").toList.map(_.toDouble)))\n }\n }\n\n def stdDeviation(list: List[Double]): Double={\n sqrt(list.map{_ - (list.sum / list.length)}.map{pow(_, 2)}.sum / list.length)\n }\n}", "problem_context": "Standard Deviation\n\nYou have final scores of an examination for n students. Calculate standard deviation of the scores s1, s2 ... sn.\n\nThe variance α2 is defined by\n\nα2 = (∑ni=1(si - m)2)/n\n\nwhere m is an average of si.\n\nThe standard deviation of the scores is the square root of their variance.\n\nInput\n\nThe input consists of multiple datasets. Each dataset is given in the following format:\n\nn\ns1 s2 ... sn\n\nThe input ends with single zero for n.\n\nOutput\n\nFor each dataset, print the standard deviation in a line. The output should not contain an absolute error greater than 10-4.\n\nConstraints\n\nn ≤ 1000\n\n0 ≤ si ≤ 100\n\nSample Input\n\n5\n70 80 100 90 20\n3\n80 80 80\n0\n\nSample Output\n\n27.85677655\n0.00000000", "sample_input": "5\n70 80 100 90 20\n3\n80 80 80\n0\n"}, "reference_outputs": ["27.85677655\n0.00000000\n"], "source_document_id": "p02381", "source_text": "Standard Deviation\n\nYou have final scores of an examination for n students. Calculate standard deviation of the scores s1, s2 ... sn.\n\nThe variance α2 is defined by\n\nα2 = (∑ni=1(si - m)2)/n\n\nwhere m is an average of si.\n\nThe standard deviation of the scores is the square root of their variance.\n\nInput\n\nThe input consists of multiple datasets. Each dataset is given in the following format:\n\nn\ns1 s2 ... sn\n\nThe input ends with single zero for n.\n\nOutput\n\nFor each dataset, print the standard deviation in a line. The output should not contain an absolute error greater than 10-4.\n\nConstraints\n\nn ≤ 1000\n\n0 ≤ si ≤ 100\n\nSample Input\n\n5\n70 80 100 90 20\n3\n80 80 80\n0\n\nSample Output\n\n27.85677655\n0.00000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 300, "memory_kb": 92480}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s626938706", "group_id": "codeNet:p02381", "input_text": "import scala.math.sqrt\nimport scala.io.Source\n\nobject Main extends App {\n val src: Iterator[String] = Source.stdin.getLines\n\n def deviator(n: Double, li: List[Double]): Double = {\n def predicate(a: Double, b: Double): Double = {\n val avg = li.sum / n\n a + (b-avg)*(b-avg)\n }\n\n sqrt(li.foldLeft(0.0)(predicate) / n)\n }\n\n for (n <- src if src.hasNext) {\n val li = src.next.split(\" \").map(_.toDouble).toList\n println(deviator(n.toDouble, li))\n }\n}", "language": "Scala", "metadata": {"date": 1512188262, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02381.html", "problem_id": "p02381", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02381/input.txt", "sample_output_relpath": "derived/input_output/data/p02381/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02381/Scala/s626938706.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s626938706", "user_id": "u387507798"}, "prompt_components": {"gold_output": "27.85677655\n0.00000000\n", "input_to_evaluate": "import scala.math.sqrt\nimport scala.io.Source\n\nobject Main extends App {\n val src: Iterator[String] = Source.stdin.getLines\n\n def deviator(n: Double, li: List[Double]): Double = {\n def predicate(a: Double, b: Double): Double = {\n val avg = li.sum / n\n a + (b-avg)*(b-avg)\n }\n\n sqrt(li.foldLeft(0.0)(predicate) / n)\n }\n\n for (n <- src if src.hasNext) {\n val li = src.next.split(\" \").map(_.toDouble).toList\n println(deviator(n.toDouble, li))\n }\n}", "problem_context": "Standard Deviation\n\nYou have final scores of an examination for n students. Calculate standard deviation of the scores s1, s2 ... sn.\n\nThe variance α2 is defined by\n\nα2 = (∑ni=1(si - m)2)/n\n\nwhere m is an average of si.\n\nThe standard deviation of the scores is the square root of their variance.\n\nInput\n\nThe input consists of multiple datasets. Each dataset is given in the following format:\n\nn\ns1 s2 ... sn\n\nThe input ends with single zero for n.\n\nOutput\n\nFor each dataset, print the standard deviation in a line. The output should not contain an absolute error greater than 10-4.\n\nConstraints\n\nn ≤ 1000\n\n0 ≤ si ≤ 100\n\nSample Input\n\n5\n70 80 100 90 20\n3\n80 80 80\n0\n\nSample Output\n\n27.85677655\n0.00000000", "sample_input": "5\n70 80 100 90 20\n3\n80 80 80\n0\n"}, "reference_outputs": ["27.85677655\n0.00000000\n"], "source_document_id": "p02381", "source_text": "Standard Deviation\n\nYou have final scores of an examination for n students. Calculate standard deviation of the scores s1, s2 ... sn.\n\nThe variance α2 is defined by\n\nα2 = (∑ni=1(si - m)2)/n\n\nwhere m is an average of si.\n\nThe standard deviation of the scores is the square root of their variance.\n\nInput\n\nThe input consists of multiple datasets. Each dataset is given in the following format:\n\nn\ns1 s2 ... sn\n\nThe input ends with single zero for n.\n\nOutput\n\nFor each dataset, print the standard deviation in a line. The output should not contain an absolute error greater than 10-4.\n\nConstraints\n\nn ≤ 1000\n\n0 ≤ si ≤ 100\n\nSample Input\n\n5\n70 80 100 90 20\n3\n80 80 80\n0\n\nSample Output\n\n27.85677655\n0.00000000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 300, "memory_kb": 92300}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s623766764", "group_id": "codeNet:p02383", "input_text": "import scala.io.StdIn._\nimport scala.annotation.tailrec\n\nobject Main {\n\n object Dice{\n private val north = List(2,6,3,4,1,5).map(_-1)\n private val east = List(4,2,1,6,5,3).map(_-1)\n private val ccw = List(3,2,6,1,5,4).map(_-1)\n }\n\n case class Dice(pip: List[Int]) {\n private def north = Dice(Dice.north.map(pip))\n private def east = Dice(Dice.east.map(pip))\n private def south = north.north.north\n private def west = east.east.east\n\n def rotate(com: Char):Dice = com match {\n case 'N' => north\n case 'E' => east\n case 'S' => south\n case 'W' => west\n case _ => this\n }\n }\n\n @tailrec\n def loop(com: String, dice: Dice):Dice = {\n if(com.isEmpty)dice\n else loop(com.tail,dice.rotate(com.head))\n }\n\n def main(args: Array[String]): Unit = {\n val pip = readLine.split(\" \").map(_.toInt).toList\n println(loop(readLine,Dice(pip)).pip(0))\n }\n}", "language": "Scala", "metadata": {"date": 1435113860, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02383.html", "problem_id": "p02383", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02383/input.txt", "sample_output_relpath": "derived/input_output/data/p02383/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02383/Scala/s623766764.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s623766764", "user_id": "u047988051"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import scala.io.StdIn._\nimport scala.annotation.tailrec\n\nobject Main {\n\n object Dice{\n private val north = List(2,6,3,4,1,5).map(_-1)\n private val east = List(4,2,1,6,5,3).map(_-1)\n private val ccw = List(3,2,6,1,5,4).map(_-1)\n }\n\n case class Dice(pip: List[Int]) {\n private def north = Dice(Dice.north.map(pip))\n private def east = Dice(Dice.east.map(pip))\n private def south = north.north.north\n private def west = east.east.east\n\n def rotate(com: Char):Dice = com match {\n case 'N' => north\n case 'E' => east\n case 'S' => south\n case 'W' => west\n case _ => this\n }\n }\n\n @tailrec\n def loop(com: String, dice: Dice):Dice = {\n if(com.isEmpty)dice\n else loop(com.tail,dice.rotate(com.head))\n }\n\n def main(args: Array[String]): Unit = {\n val pip = readLine.split(\" \").map(_.toInt).toList\n println(loop(readLine,Dice(pip)).pip(0))\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nDice I\n\nWrite a program to simulate rolling a dice, which can be constructed by the following net.\n\nAs shown in the figures, each face is identified by a different label from 1 to 6.\n\nWrite a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures.\n\nInput\n\nIn the first line, six integers assigned to faces are given in ascending order of their corresponding labels.\n\nIn the second line, a string which represents a sequence of commands, is given. The command is one of 'E', 'N', 'S' and 'W' representing four directions shown in the above figures.\n\nOutput\n\nPrint the integer which appears on the top face after the simulation.\n\nConstraints\n\n$0 \\leq $ the integer assigned to a face $ \\leq 100$\n\n$0 \\leq $ the length of the command $\\leq 100$\n\nSample Input 1\n\n1 2 4 8 16 32\nSE\n\nSample Output 1\n\n8\n\nYou are given a dice where 1, 2, 4, 8, 16 are 32 are assigned to a face labeled by 1, 2, ..., 6 respectively. After you roll the dice to the direction S and then to the direction E, you can see 8 on the top face.\n\nSample Input 2\n\n1 2 4 8 16 32\nEESWN\n\nSample Output 2\n\n32", "sample_input": "1 2 4 8 16 32\nSE\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02383", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nDice I\n\nWrite a program to simulate rolling a dice, which can be constructed by the following net.\n\nAs shown in the figures, each face is identified by a different label from 1 to 6.\n\nWrite a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures.\n\nInput\n\nIn the first line, six integers assigned to faces are given in ascending order of their corresponding labels.\n\nIn the second line, a string which represents a sequence of commands, is given. The command is one of 'E', 'N', 'S' and 'W' representing four directions shown in the above figures.\n\nOutput\n\nPrint the integer which appears on the top face after the simulation.\n\nConstraints\n\n$0 \\leq $ the integer assigned to a face $ \\leq 100$\n\n$0 \\leq $ the length of the command $\\leq 100$\n\nSample Input 1\n\n1 2 4 8 16 32\nSE\n\nSample Output 1\n\n8\n\nYou are given a dice where 1, 2, 4, 8, 16 are 32 are assigned to a face labeled by 1, 2, ..., 6 respectively. After you roll the dice to the direction S and then to the direction E, you can see 8 on the top face.\n\nSample Input 2\n\n1 2 4 8 16 32\nEESWN\n\nSample Output 2\n\n32", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 41192}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s787556129", "group_id": "codeNet:p02383", "input_text": "object Main {\n def step(s: (Int, Int, Int), i: Char) = i match {\n case 'N' => (s._2, 5-s._1, s._3)\n case 'E' => (5-s._3, s._2, s._1)\n case 'W' => (s._3, s._2, 5-s._1)\n case 'S' => (5-s._2, s._1, s._3)\n }\n \n def main(args: Array[String]) = {\n val in = io.Source.stdin.getLines\n val nums = in.next.split(\" \").map(_.toInt)\n println(nums(in.next.foldLeft((0, 1, 2))(step)._1))\n }\n}", "language": "Scala", "metadata": {"date": 1482388264, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02383.html", "problem_id": "p02383", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02383/input.txt", "sample_output_relpath": "derived/input_output/data/p02383/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02383/Scala/s787556129.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s787556129", "user_id": "u475394465"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "object Main {\n def step(s: (Int, Int, Int), i: Char) = i match {\n case 'N' => (s._2, 5-s._1, s._3)\n case 'E' => (5-s._3, s._2, s._1)\n case 'W' => (s._3, s._2, 5-s._1)\n case 'S' => (5-s._2, s._1, s._3)\n }\n \n def main(args: Array[String]) = {\n val in = io.Source.stdin.getLines\n val nums = in.next.split(\" \").map(_.toInt)\n println(nums(in.next.foldLeft((0, 1, 2))(step)._1))\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nDice I\n\nWrite a program to simulate rolling a dice, which can be constructed by the following net.\n\nAs shown in the figures, each face is identified by a different label from 1 to 6.\n\nWrite a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures.\n\nInput\n\nIn the first line, six integers assigned to faces are given in ascending order of their corresponding labels.\n\nIn the second line, a string which represents a sequence of commands, is given. The command is one of 'E', 'N', 'S' and 'W' representing four directions shown in the above figures.\n\nOutput\n\nPrint the integer which appears on the top face after the simulation.\n\nConstraints\n\n$0 \\leq $ the integer assigned to a face $ \\leq 100$\n\n$0 \\leq $ the length of the command $\\leq 100$\n\nSample Input 1\n\n1 2 4 8 16 32\nSE\n\nSample Output 1\n\n8\n\nYou are given a dice where 1, 2, 4, 8, 16 are 32 are assigned to a face labeled by 1, 2, ..., 6 respectively. After you roll the dice to the direction S and then to the direction E, you can see 8 on the top face.\n\nSample Input 2\n\n1 2 4 8 16 32\nEESWN\n\nSample Output 2\n\n32", "sample_input": "1 2 4 8 16 32\nSE\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02383", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nDice I\n\nWrite a program to simulate rolling a dice, which can be constructed by the following net.\n\nAs shown in the figures, each face is identified by a different label from 1 to 6.\n\nWrite a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures.\n\nInput\n\nIn the first line, six integers assigned to faces are given in ascending order of their corresponding labels.\n\nIn the second line, a string which represents a sequence of commands, is given. The command is one of 'E', 'N', 'S' and 'W' representing four directions shown in the above figures.\n\nOutput\n\nPrint the integer which appears on the top face after the simulation.\n\nConstraints\n\n$0 \\leq $ the integer assigned to a face $ \\leq 100$\n\n$0 \\leq $ the length of the command $\\leq 100$\n\nSample Input 1\n\n1 2 4 8 16 32\nSE\n\nSample Output 1\n\n8\n\nYou are given a dice where 1, 2, 4, 8, 16 are 32 are assigned to a face labeled by 1, 2, ..., 6 respectively. After you roll the dice to the direction S and then to the direction E, you can see 8 on the top face.\n\nSample Input 2\n\n1 2 4 8 16 32\nEESWN\n\nSample Output 2\n\n32", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 250, "memory_kb": 43992}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s643112271", "group_id": "codeNet:p02383", "input_text": "import scala.io.StdIn.readLine\n\nobject Dice {\n def rollOnce(dir:Char) =\n dir match {\n case 'S' => Array(4,0,2,3,5,1)\n case 'N' => Array(1,5,2,3,0,4)\n case 'W' => Array(2,1,5,0,4,3)\n case 'E' => Array(3,1,0,5,4,2)\n }\n}\n\nclass Dice(var d:Array[Int]) {\n\n def roll(dirs:String) = {\n d = dirs.foldLeft(Array(0,1,2,3,4,5)) { (x,y) => Dice.rollOnce(y).map(x) }.map(d)\n }\n\n def getTopFace() = d(0)\n}\n\nobject Main extends App {\n val faces = readLine.split(\" \").map(_.toInt)\n val dice = new Dice(faces)\n dice.roll(readLine)\n\n println(dice.getTopFace())\n}", "language": "Scala", "metadata": {"date": 1483108673, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02383.html", "problem_id": "p02383", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02383/input.txt", "sample_output_relpath": "derived/input_output/data/p02383/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02383/Scala/s643112271.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s643112271", "user_id": "u508732591"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Dice {\n def rollOnce(dir:Char) =\n dir match {\n case 'S' => Array(4,0,2,3,5,1)\n case 'N' => Array(1,5,2,3,0,4)\n case 'W' => Array(2,1,5,0,4,3)\n case 'E' => Array(3,1,0,5,4,2)\n }\n}\n\nclass Dice(var d:Array[Int]) {\n\n def roll(dirs:String) = {\n d = dirs.foldLeft(Array(0,1,2,3,4,5)) { (x,y) => Dice.rollOnce(y).map(x) }.map(d)\n }\n\n def getTopFace() = d(0)\n}\n\nobject Main extends App {\n val faces = readLine.split(\" \").map(_.toInt)\n val dice = new Dice(faces)\n dice.roll(readLine)\n\n println(dice.getTopFace())\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nDice I\n\nWrite a program to simulate rolling a dice, which can be constructed by the following net.\n\nAs shown in the figures, each face is identified by a different label from 1 to 6.\n\nWrite a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures.\n\nInput\n\nIn the first line, six integers assigned to faces are given in ascending order of their corresponding labels.\n\nIn the second line, a string which represents a sequence of commands, is given. The command is one of 'E', 'N', 'S' and 'W' representing four directions shown in the above figures.\n\nOutput\n\nPrint the integer which appears on the top face after the simulation.\n\nConstraints\n\n$0 \\leq $ the integer assigned to a face $ \\leq 100$\n\n$0 \\leq $ the length of the command $\\leq 100$\n\nSample Input 1\n\n1 2 4 8 16 32\nSE\n\nSample Output 1\n\n8\n\nYou are given a dice where 1, 2, 4, 8, 16 are 32 are assigned to a face labeled by 1, 2, ..., 6 respectively. After you roll the dice to the direction S and then to the direction E, you can see 8 on the top face.\n\nSample Input 2\n\n1 2 4 8 16 32\nEESWN\n\nSample Output 2\n\n32", "sample_input": "1 2 4 8 16 32\nSE\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02383", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nDice I\n\nWrite a program to simulate rolling a dice, which can be constructed by the following net.\n\nAs shown in the figures, each face is identified by a different label from 1 to 6.\n\nWrite a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures.\n\nInput\n\nIn the first line, six integers assigned to faces are given in ascending order of their corresponding labels.\n\nIn the second line, a string which represents a sequence of commands, is given. The command is one of 'E', 'N', 'S' and 'W' representing four directions shown in the above figures.\n\nOutput\n\nPrint the integer which appears on the top face after the simulation.\n\nConstraints\n\n$0 \\leq $ the integer assigned to a face $ \\leq 100$\n\n$0 \\leq $ the length of the command $\\leq 100$\n\nSample Input 1\n\n1 2 4 8 16 32\nSE\n\nSample Output 1\n\n8\n\nYou are given a dice where 1, 2, 4, 8, 16 are 32 are assigned to a face labeled by 1, 2, ..., 6 respectively. After you roll the dice to the direction S and then to the direction E, you can see 8 on the top face.\n\nSample Input 2\n\n1 2 4 8 16 32\nEESWN\n\nSample Output 2\n\n32", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 260, "memory_kb": 44176}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s633871408", "group_id": "codeNet:p02383", "input_text": "/**\n * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_11_A&lang=jp\n * Structure and Class - Dice I\n */\nobject Main {\n\n class Dice(numbers: IndexedSeq[Int]) {\n def rotateTo(direction: Char): Dice = {\n direction match {\n case 'N' => new Dice(IndexedSeq(numbers(1), numbers(5), numbers(2), numbers(3), numbers(0), numbers(4)))\n case 'S' => new Dice(IndexedSeq(numbers(4), numbers(0), numbers(2), numbers(3), numbers(5), numbers(1)))\n case 'W' => new Dice(IndexedSeq(numbers(2), numbers(1), numbers(5), numbers(0), numbers(4), numbers(3)))\n case 'E' => new Dice(IndexedSeq(numbers(3), numbers(1), numbers(0), numbers(5), numbers(4), numbers(2)))\n }\n }\n\n def apply(number: Int): Int = {\n numbers(number)\n }\n }\n\n def main(args: Array[String]): Unit = {\n val dice = new Dice(io.StdIn.readLine().split(\" \").map(_.toInt))\n val operations = io.StdIn.readLine()\n val operatedDice = operations.foldLeft(dice)(_.rotateTo(_))\n println(operatedDice(0))\n }\n}", "language": "Scala", "metadata": {"date": 1505832539, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02383.html", "problem_id": "p02383", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02383/input.txt", "sample_output_relpath": "derived/input_output/data/p02383/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02383/Scala/s633871408.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s633871408", "user_id": "u757244973"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "/**\n * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_11_A&lang=jp\n * Structure and Class - Dice I\n */\nobject Main {\n\n class Dice(numbers: IndexedSeq[Int]) {\n def rotateTo(direction: Char): Dice = {\n direction match {\n case 'N' => new Dice(IndexedSeq(numbers(1), numbers(5), numbers(2), numbers(3), numbers(0), numbers(4)))\n case 'S' => new Dice(IndexedSeq(numbers(4), numbers(0), numbers(2), numbers(3), numbers(5), numbers(1)))\n case 'W' => new Dice(IndexedSeq(numbers(2), numbers(1), numbers(5), numbers(0), numbers(4), numbers(3)))\n case 'E' => new Dice(IndexedSeq(numbers(3), numbers(1), numbers(0), numbers(5), numbers(4), numbers(2)))\n }\n }\n\n def apply(number: Int): Int = {\n numbers(number)\n }\n }\n\n def main(args: Array[String]): Unit = {\n val dice = new Dice(io.StdIn.readLine().split(\" \").map(_.toInt))\n val operations = io.StdIn.readLine()\n val operatedDice = operations.foldLeft(dice)(_.rotateTo(_))\n println(operatedDice(0))\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nDice I\n\nWrite a program to simulate rolling a dice, which can be constructed by the following net.\n\nAs shown in the figures, each face is identified by a different label from 1 to 6.\n\nWrite a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures.\n\nInput\n\nIn the first line, six integers assigned to faces are given in ascending order of their corresponding labels.\n\nIn the second line, a string which represents a sequence of commands, is given. The command is one of 'E', 'N', 'S' and 'W' representing four directions shown in the above figures.\n\nOutput\n\nPrint the integer which appears on the top face after the simulation.\n\nConstraints\n\n$0 \\leq $ the integer assigned to a face $ \\leq 100$\n\n$0 \\leq $ the length of the command $\\leq 100$\n\nSample Input 1\n\n1 2 4 8 16 32\nSE\n\nSample Output 1\n\n8\n\nYou are given a dice where 1, 2, 4, 8, 16 are 32 are assigned to a face labeled by 1, 2, ..., 6 respectively. After you roll the dice to the direction S and then to the direction E, you can see 8 on the top face.\n\nSample Input 2\n\n1 2 4 8 16 32\nEESWN\n\nSample Output 2\n\n32", "sample_input": "1 2 4 8 16 32\nSE\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02383", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nDice I\n\nWrite a program to simulate rolling a dice, which can be constructed by the following net.\n\nAs shown in the figures, each face is identified by a different label from 1 to 6.\n\nWrite a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures.\n\nInput\n\nIn the first line, six integers assigned to faces are given in ascending order of their corresponding labels.\n\nIn the second line, a string which represents a sequence of commands, is given. The command is one of 'E', 'N', 'S' and 'W' representing four directions shown in the above figures.\n\nOutput\n\nPrint the integer which appears on the top face after the simulation.\n\nConstraints\n\n$0 \\leq $ the integer assigned to a face $ \\leq 100$\n\n$0 \\leq $ the length of the command $\\leq 100$\n\nSample Input 1\n\n1 2 4 8 16 32\nSE\n\nSample Output 1\n\n8\n\nYou are given a dice where 1, 2, 4, 8, 16 are 32 are assigned to a face labeled by 1, 2, ..., 6 respectively. After you roll the dice to the direction S and then to the direction E, you can see 8 on the top face.\n\nSample Input 2\n\n1 2 4 8 16 32\nEESWN\n\nSample Output 2\n\n32", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1031, "cpu_time_ms": 270, "memory_kb": 43832}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s599672041", "group_id": "codeNet:p02384", "input_text": "/**\n * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_11_B&lang=jp\n * Structure and Class - Dice II\n */\nobject Main {\n\n class Dice(numbers: IndexedSeq[Int]) {\n def apply(number: Int): Int = {\n numbers(number)\n }\n\n def rotateTo(direction: Char): Dice = {\n direction match {\n case 'N' => new Dice(IndexedSeq(numbers(1), numbers(5), numbers(2), numbers(3), numbers(0), numbers(4)))\n case 'S' => new Dice(IndexedSeq(numbers(4), numbers(0), numbers(2), numbers(3), numbers(5), numbers(1)))\n case 'W' => new Dice(IndexedSeq(numbers(2), numbers(1), numbers(5), numbers(0), numbers(4), numbers(3)))\n case 'E' => new Dice(IndexedSeq(numbers(3), numbers(1), numbers(0), numbers(5), numbers(4), numbers(2)))\n }\n }\n\n def find(number: Int): Int = {\n numbers.indexWhere(_ == number)\n }\n }\n\n def main(args: Array[String]): Unit = {\n val dice = new Dice(io.StdIn.readLine().split(\" \").map(_.toInt))\n val questions = io.StdIn.readInt()\n Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null).map(_.split(\" \").map(_.toInt))\n .take(questions)\n .map {\n case Array(top, front) => determineRight(dice, top, front)\n }\n .foreach(println)\n }\n\n def determineRight(dice: Dice, top: Int, front: Int): Int = {\n val operationsToTop = Seq(\"\", \"N\", \"W\", \"E\", \"S\", \"NN\")\n val operationsToFront = Seq(\"S\", \"\", \"WSE\", \"ESW\", \"SEEN\", \"N\")\n val dice2 = operationsToTop(dice.find(top)).foldLeft(dice)(_.rotateTo(_))\n val dice3 = operationsToFront(dice2.find(front)).foldLeft(dice2)(_.rotateTo(_))\n dice3(2)\n }\n}", "language": "Scala", "metadata": {"date": 1506217450, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02384.html", "problem_id": "p02384", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02384/input.txt", "sample_output_relpath": "derived/input_output/data/p02384/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02384/Scala/s599672041.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s599672041", "user_id": "u757244973"}, "prompt_components": {"gold_output": "3\n5\n6\n", "input_to_evaluate": "/**\n * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_11_B&lang=jp\n * Structure and Class - Dice II\n */\nobject Main {\n\n class Dice(numbers: IndexedSeq[Int]) {\n def apply(number: Int): Int = {\n numbers(number)\n }\n\n def rotateTo(direction: Char): Dice = {\n direction match {\n case 'N' => new Dice(IndexedSeq(numbers(1), numbers(5), numbers(2), numbers(3), numbers(0), numbers(4)))\n case 'S' => new Dice(IndexedSeq(numbers(4), numbers(0), numbers(2), numbers(3), numbers(5), numbers(1)))\n case 'W' => new Dice(IndexedSeq(numbers(2), numbers(1), numbers(5), numbers(0), numbers(4), numbers(3)))\n case 'E' => new Dice(IndexedSeq(numbers(3), numbers(1), numbers(0), numbers(5), numbers(4), numbers(2)))\n }\n }\n\n def find(number: Int): Int = {\n numbers.indexWhere(_ == number)\n }\n }\n\n def main(args: Array[String]): Unit = {\n val dice = new Dice(io.StdIn.readLine().split(\" \").map(_.toInt))\n val questions = io.StdIn.readInt()\n Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null).map(_.split(\" \").map(_.toInt))\n .take(questions)\n .map {\n case Array(top, front) => determineRight(dice, top, front)\n }\n .foreach(println)\n }\n\n def determineRight(dice: Dice, top: Int, front: Int): Int = {\n val operationsToTop = Seq(\"\", \"N\", \"W\", \"E\", \"S\", \"NN\")\n val operationsToFront = Seq(\"S\", \"\", \"WSE\", \"ESW\", \"SEEN\", \"N\")\n val dice2 = operationsToTop(dice.find(top)).foldLeft(dice)(_.rotateTo(_))\n val dice3 = operationsToFront(dice2.find(front)).foldLeft(dice2)(_.rotateTo(_))\n dice3(2)\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nDice II\n\nConstruct a dice from a given sequence of integers in the same way as Dice I.\n\nYou are given integers on the top face and the front face after the dice was rolled in the same way as Dice I. Write a program to print an integer on the right side face.\n\nInput\n\nIn the first line, six integers assigned to faces are given in ascending order of their corresponding labels.\nIn the second line, the number of questions $q$ is given.\n\nIn the following $q$ lines, $q$ questions are given. Each question consists of two integers on the top face and the front face respectively.\n\nOutput\n\nFor each question, print the integer on the right side face.\n\nConstraints\n\n$0 \\leq $ the integer assigned to a face $ \\leq 100$\n\nThe integers are all different\n\n$1 \\leq q \\leq 24$\n\nSample Input\n\n1 2 3 4 5 6\n3\n6 5\n1 3\n3 2\n\nSample Output\n\n3\n5\n6", "sample_input": "1 2 3 4 5 6\n3\n6 5\n1 3\n3 2\n"}, "reference_outputs": ["3\n5\n6\n"], "source_document_id": "p02384", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nDice II\n\nConstruct a dice from a given sequence of integers in the same way as Dice I.\n\nYou are given integers on the top face and the front face after the dice was rolled in the same way as Dice I. Write a program to print an integer on the right side face.\n\nInput\n\nIn the first line, six integers assigned to faces are given in ascending order of their corresponding labels.\nIn the second line, the number of questions $q$ is given.\n\nIn the following $q$ lines, $q$ questions are given. Each question consists of two integers on the top face and the front face respectively.\n\nOutput\n\nFor each question, print the integer on the right side face.\n\nConstraints\n\n$0 \\leq $ the integer assigned to a face $ \\leq 100$\n\nThe integers are all different\n\n$1 \\leq q \\leq 24$\n\nSample Input\n\n1 2 3 4 5 6\n3\n6 5\n1 3\n3 2\n\nSample Output\n\n3\n5\n6", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1622, "cpu_time_ms": 280, "memory_kb": 44316}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s149500394", "group_id": "codeNet:p02388", "input_text": "object Main {\n def main(args: Array[String]) = {\n for (arg <- args.map(_.toInt)) println(arg * arg * arg)\n }\n}", "language": "Scala", "metadata": {"date": 1436942909, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02388.html", "problem_id": "p02388", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02388/input.txt", "sample_output_relpath": "derived/input_output/data/p02388/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02388/Scala/s149500394.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s149500394", "user_id": "u012178320"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]) = {\n for (arg <- args.map(_.toInt)) println(arg * arg * arg)\n }\n}", "problem_context": "X Cubic\n\nWrite a program which calculates the cube of a given integer x.\n\nInput\n\nAn integer x is given in a line.\n\nOutput\n\nPrint the cube of x in a line.\n\nConstraints\n\n1 ≤ x ≤ 100\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nSample Input 2\n\n3\n\nSample Output 2\n\n27", "sample_input": "2\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02388", "source_text": "X Cubic\n\nWrite a program which calculates the cube of a given integer x.\n\nInput\n\nAn integer x is given in a line.\n\nOutput\n\nPrint the cube of x in a line.\n\nConstraints\n\n1 ≤ x ≤ 100\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nSample Input 2\n\n3\n\nSample Output 2\n\n27", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 115, "cpu_time_ms": 220, "memory_kb": 43980}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s347196847", "group_id": "codeNet:p02388", "input_text": "object Main {\n def main(args: Array[String]) {\n for (arg <- args.map(_.toInt)) print(arg * arg * arg)\n }\n}", "language": "Scala", "metadata": {"date": 1436945517, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02388.html", "problem_id": "p02388", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02388/input.txt", "sample_output_relpath": "derived/input_output/data/p02388/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02388/Scala/s347196847.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s347196847", "user_id": "u012178320"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]) {\n for (arg <- args.map(_.toInt)) print(arg * arg * arg)\n }\n}", "problem_context": "X Cubic\n\nWrite a program which calculates the cube of a given integer x.\n\nInput\n\nAn integer x is given in a line.\n\nOutput\n\nPrint the cube of x in a line.\n\nConstraints\n\n1 ≤ x ≤ 100\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nSample Input 2\n\n3\n\nSample Output 2\n\n27", "sample_input": "2\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02388", "source_text": "X Cubic\n\nWrite a program which calculates the cube of a given integer x.\n\nInput\n\nAn integer x is given in a line.\n\nOutput\n\nPrint the cube of x in a line.\n\nConstraints\n\n1 ≤ x ≤ 100\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nSample Input 2\n\n3\n\nSample Output 2\n\n27", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 111, "cpu_time_ms": 210, "memory_kb": 43760}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s031889415", "group_id": "codeNet:p02388", "input_text": "import java.util.Scanner\nimport scala.math.pow\n\nobject Main {\n def main (args: Array[String]) = {\n val in = new Scanner(System.in)\n val x = in.nextInt\n println(pow(x, 3).toInt)\n }\n}", "language": "Scala", "metadata": {"date": 1448801018, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02388.html", "problem_id": "p02388", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02388/input.txt", "sample_output_relpath": "derived/input_output/data/p02388/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02388/Scala/s031889415.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s031889415", "user_id": "u188848609"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.util.Scanner\nimport scala.math.pow\n\nobject Main {\n def main (args: Array[String]) = {\n val in = new Scanner(System.in)\n val x = in.nextInt\n println(pow(x, 3).toInt)\n }\n}", "problem_context": "X Cubic\n\nWrite a program which calculates the cube of a given integer x.\n\nInput\n\nAn integer x is given in a line.\n\nOutput\n\nPrint the cube of x in a line.\n\nConstraints\n\n1 ≤ x ≤ 100\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nSample Input 2\n\n3\n\nSample Output 2\n\n27", "sample_input": "2\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02388", "source_text": "X Cubic\n\nWrite a program which calculates the cube of a given integer x.\n\nInput\n\nAn integer x is given in a line.\n\nOutput\n\nPrint the cube of x in a line.\n\nConstraints\n\n1 ≤ x ≤ 100\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nSample Input 2\n\n3\n\nSample Output 2\n\n27", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 44804}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s225623628", "group_id": "codeNet:p02388", "input_text": "import scala.io.StdIn.readInt\nobject Main extends App {\n val n = readInt()\n println(n * n * n)\n}\n", "language": "Scala", "metadata": {"date": 1514891567, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02388.html", "problem_id": "p02388", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02388/input.txt", "sample_output_relpath": "derived/input_output/data/p02388/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02388/Scala/s225623628.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s225623628", "user_id": "u909989059"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import scala.io.StdIn.readInt\nobject Main extends App {\n val n = readInt()\n println(n * n * n)\n}\n", "problem_context": "X Cubic\n\nWrite a program which calculates the cube of a given integer x.\n\nInput\n\nAn integer x is given in a line.\n\nOutput\n\nPrint the cube of x in a line.\n\nConstraints\n\n1 ≤ x ≤ 100\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nSample Input 2\n\n3\n\nSample Output 2\n\n27", "sample_input": "2\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02388", "source_text": "X Cubic\n\nWrite a program which calculates the cube of a given integer x.\n\nInput\n\nAn integer x is given in a line.\n\nOutput\n\nPrint the cube of x in a line.\n\nConstraints\n\n1 ≤ x ≤ 100\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nSample Input 2\n\n3\n\nSample Output 2\n\n27", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 103, "cpu_time_ms": 240, "memory_kb": 43724}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s945740191", "group_id": "codeNet:p02388", "input_text": "import scala.io.StdIn.{readLine,readInt}\n\nobject Main extends App {\n val x = readInt\n println( x*x*x )\n}\n", "language": "Scala", "metadata": {"date": 1529211369, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02388.html", "problem_id": "p02388", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02388/input.txt", "sample_output_relpath": "derived/input_output/data/p02388/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02388/Scala/s945740191.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s945740191", "user_id": "u768801062"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import scala.io.StdIn.{readLine,readInt}\n\nobject Main extends App {\n val x = readInt\n println( x*x*x )\n}\n", "problem_context": "X Cubic\n\nWrite a program which calculates the cube of a given integer x.\n\nInput\n\nAn integer x is given in a line.\n\nOutput\n\nPrint the cube of x in a line.\n\nConstraints\n\n1 ≤ x ≤ 100\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nSample Input 2\n\n3\n\nSample Output 2\n\n27", "sample_input": "2\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02388", "source_text": "X Cubic\n\nWrite a program which calculates the cube of a given integer x.\n\nInput\n\nAn integer x is given in a line.\n\nOutput\n\nPrint the cube of x in a line.\n\nConstraints\n\n1 ≤ x ≤ 100\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nSample Input 2\n\n3\n\nSample Output 2\n\n27", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 111, "cpu_time_ms": 220, "memory_kb": 43728}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s315160896", "group_id": "codeNet:p02388", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val x = io.StdIn.readLine().toInt\n println(x * x * x)\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1550739560, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02388.html", "problem_id": "p02388", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02388/input.txt", "sample_output_relpath": "derived/input_output/data/p02388/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02388/Scala/s315160896.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s315160896", "user_id": "u990117429"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val x = io.StdIn.readLine().toInt\n println(x * x * x)\n }\n}\n\n", "problem_context": "X Cubic\n\nWrite a program which calculates the cube of a given integer x.\n\nInput\n\nAn integer x is given in a line.\n\nOutput\n\nPrint the cube of x in a line.\n\nConstraints\n\n1 ≤ x ≤ 100\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nSample Input 2\n\n3\n\nSample Output 2\n\n27", "sample_input": "2\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02388", "source_text": "X Cubic\n\nWrite a program which calculates the cube of a given integer x.\n\nInput\n\nAn integer x is given in a line.\n\nOutput\n\nPrint the cube of x in a line.\n\nConstraints\n\n1 ≤ x ≤ 100\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nSample Input 2\n\n3\n\nSample Output 2\n\n27", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43676}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s466843431", "group_id": "codeNet:p02388", "input_text": "import scala.io.StdIn._\n\nobject Main{\n def main(args : Array[String]){\n val x : BigInt = readInt\n println(x * x * x)\n }\n}\n", "language": "Scala", "metadata": {"date": 1539337191, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02388.html", "problem_id": "p02388", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02388/input.txt", "sample_output_relpath": "derived/input_output/data/p02388/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02388/Scala/s466843431.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s466843431", "user_id": "u932482488"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main{\n def main(args : Array[String]){\n val x : BigInt = readInt\n println(x * x * x)\n }\n}\n", "problem_context": "X Cubic\n\nWrite a program which calculates the cube of a given integer x.\n\nInput\n\nAn integer x is given in a line.\n\nOutput\n\nPrint the cube of x in a line.\n\nConstraints\n\n1 ≤ x ≤ 100\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nSample Input 2\n\n3\n\nSample Output 2\n\n27", "sample_input": "2\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02388", "source_text": "X Cubic\n\nWrite a program which calculates the cube of a given integer x.\n\nInput\n\nAn integer x is given in a line.\n\nOutput\n\nPrint the cube of x in a line.\n\nConstraints\n\n1 ≤ x ≤ 100\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nSample Input 2\n\n3\n\nSample Output 2\n\n27", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 130, "cpu_time_ms": 220, "memory_kb": 43740}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s273404241", "group_id": "codeNet:p02388", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val x = io.StdIn.readInt()\n println(x * x * x)\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1532871248, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02388.html", "problem_id": "p02388", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02388/input.txt", "sample_output_relpath": "derived/input_output/data/p02388/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02388/Scala/s273404241.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s273404241", "user_id": "u482991451"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val x = io.StdIn.readInt()\n println(x * x * x)\n }\n}\n\n", "problem_context": "X Cubic\n\nWrite a program which calculates the cube of a given integer x.\n\nInput\n\nAn integer x is given in a line.\n\nOutput\n\nPrint the cube of x in a line.\n\nConstraints\n\n1 ≤ x ≤ 100\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nSample Input 2\n\n3\n\nSample Output 2\n\n27", "sample_input": "2\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02388", "source_text": "X Cubic\n\nWrite a program which calculates the cube of a given integer x.\n\nInput\n\nAn integer x is given in a line.\n\nOutput\n\nPrint the cube of x in a line.\n\nConstraints\n\n1 ≤ x ≤ 100\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nSample Input 2\n\n3\n\nSample Output 2\n\n27", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 117, "cpu_time_ms": 230, "memory_kb": 43712}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s683825179", "group_id": "codeNet:p02389", "input_text": "import scala.io.StdIn\n\nobject Main {\n def main(args:Array[String]) {\n val inputs = StdIn.readLine().split(\" \")\n val a = inputs(0).toInt\n val b = inputs(1).toInt\n println((a * b) + \" \" + (2 * a + 2 * b))\n }\n}", "language": "Scala", "metadata": {"date": 1449126562, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02389.html", "problem_id": "p02389", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02389/input.txt", "sample_output_relpath": "derived/input_output/data/p02389/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02389/Scala/s683825179.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s683825179", "user_id": "u231083279"}, "prompt_components": {"gold_output": "15 16\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main {\n def main(args:Array[String]) {\n val inputs = StdIn.readLine().split(\" \")\n val a = inputs(0).toInt\n val b = inputs(1).toInt\n println((a * b) + \" \" + (2 * a + 2 * b))\n }\n}", "problem_context": "Rectangle\n\nWrite a program which calculates the area and perimeter of a given rectangle.\n\nInput\n\nThe length a and breadth b of the rectangle are given in a line separated by a single space.\n\nOutput\n\nPrint the area and perimeter of the rectangle in a line. The two integers should be separated by a single space.\n\nConstraints\n\n1 ≤ a, b ≤ 100\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n15 16", "sample_input": "3 5\n"}, "reference_outputs": ["15 16\n"], "source_document_id": "p02389", "source_text": "Rectangle\n\nWrite a program which calculates the area and perimeter of a given rectangle.\n\nInput\n\nThe length a and breadth b of the rectangle are given in a line separated by a single space.\n\nOutput\n\nPrint the area and perimeter of the rectangle in a line. The two integers should be separated by a single space.\n\nConstraints\n\n1 ≤ a, b ≤ 100\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n15 16", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43476}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s713297078", "group_id": "codeNet:p02389", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val ab = io.StdIn.readLine().split(\" \").map(_.toInt)\n val a = ab(0)\n val b = ab(1)\n println(s\"${a * b} ${2 * a + 2 * b}\")\n }\n}", "language": "Scala", "metadata": {"date": 1488727697, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02389.html", "problem_id": "p02389", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02389/input.txt", "sample_output_relpath": "derived/input_output/data/p02389/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02389/Scala/s713297078.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s713297078", "user_id": "u959441351"}, "prompt_components": {"gold_output": "15 16\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val ab = io.StdIn.readLine().split(\" \").map(_.toInt)\n val a = ab(0)\n val b = ab(1)\n println(s\"${a * b} ${2 * a + 2 * b}\")\n }\n}", "problem_context": "Rectangle\n\nWrite a program which calculates the area and perimeter of a given rectangle.\n\nInput\n\nThe length a and breadth b of the rectangle are given in a line separated by a single space.\n\nOutput\n\nPrint the area and perimeter of the rectangle in a line. The two integers should be separated by a single space.\n\nConstraints\n\n1 ≤ a, b ≤ 100\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n15 16", "sample_input": "3 5\n"}, "reference_outputs": ["15 16\n"], "source_document_id": "p02389", "source_text": "Rectangle\n\nWrite a program which calculates the area and perimeter of a given rectangle.\n\nInput\n\nThe length a and breadth b of the rectangle are given in a line separated by a single space.\n\nOutput\n\nPrint the area and perimeter of the rectangle in a line. The two integers should be separated by a single space.\n\nConstraints\n\n1 ≤ a, b ≤ 100\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n15 16", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 43540}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s825830394", "group_id": "codeNet:p02389", "input_text": "object Main {\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val x = sc.nextInt\n val y = sc.nextInt\n\n println(calcArea(x, y) + ' ' + calcPerimeter(x, y))\n }\n\n def calcArea(x: Int, y: Int): Int = x * y\n def calcPerimeter(x: Int, y: Int): Int = 2*x + 2*y\n}", "language": "Scala", "metadata": {"date": 1490097407, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02389.html", "problem_id": "p02389", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02389/input.txt", "sample_output_relpath": "derived/input_output/data/p02389/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02389/Scala/s825830394.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s825830394", "user_id": "u860843819"}, "prompt_components": {"gold_output": "15 16\n", "input_to_evaluate": "object Main {\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val x = sc.nextInt\n val y = sc.nextInt\n\n println(calcArea(x, y) + ' ' + calcPerimeter(x, y))\n }\n\n def calcArea(x: Int, y: Int): Int = x * y\n def calcPerimeter(x: Int, y: Int): Int = 2*x + 2*y\n}", "problem_context": "Rectangle\n\nWrite a program which calculates the area and perimeter of a given rectangle.\n\nInput\n\nThe length a and breadth b of the rectangle are given in a line separated by a single space.\n\nOutput\n\nPrint the area and perimeter of the rectangle in a line. The two integers should be separated by a single space.\n\nConstraints\n\n1 ≤ a, b ≤ 100\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n15 16", "sample_input": "3 5\n"}, "reference_outputs": ["15 16\n"], "source_document_id": "p02389", "source_text": "Rectangle\n\nWrite a program which calculates the area and perimeter of a given rectangle.\n\nInput\n\nThe length a and breadth b of the rectangle are given in a line separated by a single space.\n\nOutput\n\nPrint the area and perimeter of the rectangle in a line. The two integers should be separated by a single space.\n\nConstraints\n\n1 ≤ a, b ≤ 100\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n15 16", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 250, "memory_kb": 44484}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s116394692", "group_id": "codeNet:p02390", "input_text": "import scala.io.StdIn\n\nobject Main {\n def main(args:Array[String]) {\n val input = StdIn.readLine()\n val rawS = input.toInt\n val s:Int = rawS % 60\n val m:Int = (rawS / 60) % 60\n val h:Int = (rawS / 60) / 60\n println(h + \":\" + m + \":\" + s)\n }\n}", "language": "Scala", "metadata": {"date": 1449127782, "filename_ext": "scala", "original_language": "Scala", "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/Scala/s116394692.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s116394692", "user_id": "u231083279"}, "prompt_components": {"gold_output": "13:2:59\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main {\n def main(args:Array[String]) {\n val input = StdIn.readLine()\n val rawS = input.toInt\n val s:Int = rawS % 60\n val m:Int = (rawS / 60) % 60\n val h:Int = (rawS / 60) / 60\n println(h + \":\" + m + \":\" + s)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 262, "cpu_time_ms": 270, "memory_kb": 43712}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s202616739", "group_id": "codeNet:p02390", "input_text": "import scala.io.StdIn.readInt\n\nobject Main {\n\n def main(args: Array[String]) = {\n val n = readInt\n println(n/3600 + \":\" + n/60%60 + \":\" + n%60)\n }\n}", "language": "Scala", "metadata": {"date": 1476288639, "filename_ext": "scala", "original_language": "Scala", "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/Scala/s202616739.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s202616739", "user_id": "u508732591"}, "prompt_components": {"gold_output": "13:2:59\n", "input_to_evaluate": "import scala.io.StdIn.readInt\n\nobject Main {\n\n def main(args: Array[String]) = {\n val n = readInt\n println(n/3600 + \":\" + n/60%60 + \":\" + n%60)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43600}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s594334030", "group_id": "codeNet:p02390", "input_text": "object Main {\n case class Line(string: String) {\n def strings: Seq[String] = string.split(' ')\n def ints: Seq[Int] = strings.map(_.toInt)\n def i(n: Int): Int = ints(n)\n }\n\n def readLine: Line = Line(io.StdIn.readLine())\n def readLines(n: Int): Seq[Line] = List.fill(n)(Line(io.StdIn.readLine()))\n\n def yesNo(b: Boolean): String = if (b) \"Yes\" else \"No\"\n\n def main(args: Array[String]) {\n val s: Int = readLine.i(0)\n println(List(s / (60 * 60), (s % (60 * 60)) / 60, s % 60).mkString(\":\"))\n }\n}", "language": "Scala", "metadata": {"date": 1480670654, "filename_ext": "scala", "original_language": "Scala", "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/Scala/s594334030.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s594334030", "user_id": "u767513951"}, "prompt_components": {"gold_output": "13:2:59\n", "input_to_evaluate": "object Main {\n case class Line(string: String) {\n def strings: Seq[String] = string.split(' ')\n def ints: Seq[Int] = strings.map(_.toInt)\n def i(n: Int): Int = ints(n)\n }\n\n def readLine: Line = Line(io.StdIn.readLine())\n def readLines(n: Int): Seq[Line] = List.fill(n)(Line(io.StdIn.readLine()))\n\n def yesNo(b: Boolean): String = if (b) \"Yes\" else \"No\"\n\n def main(args: Array[String]) {\n val s: Int = readLine.i(0)\n println(List(s / (60 * 60), (s % (60 * 60)) / 60, s % 60).mkString(\":\"))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 260, "memory_kb": 43860}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s206619139", "group_id": "codeNet:p02390", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val s = sc.nextInt\n val h : Int = s / 3600\n val m : Int = (s - h * 3600)/60\n val ss : Int = s % 60\n println(s\"$h:$m:$ss\")\n}\n", "language": "Scala", "metadata": {"date": 1550154690, "filename_ext": "scala", "original_language": "Scala", "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/Scala/s206619139.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s206619139", "user_id": "u338068150"}, "prompt_components": {"gold_output": "13:2:59\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val s = sc.nextInt\n val h : Int = s / 3600\n val m : Int = (s - h * 3600)/60\n val ss : Int = s % 60\n println(s\"$h:$m:$ss\")\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 250, "memory_kb": 45056}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s652285654", "group_id": "codeNet:p02391", "input_text": "import scala.io.StdIn._\nobject Main {\n\tdef main(args :Array[String]) = {\n\t\tvar mtrl = readLine.split(\" \").map(_.toInt)\n\t\t\n\t\tif (mtrl(0)==mtrl(1)) { val f = \"==\"; println(mtrl(0)+f+mtrl(1)) } \n\t\telse if (mtrl(0)>mtrl(1)) { val f = \"<\"; println(mtrl(0)+f+mtrl(1)) }\n\t\telse { val f = \">\"; println(mtrl(0)+f+mtrl(1)) }\t\n\t}\n\t\n}", "language": "Scala", "metadata": {"date": 1461498534, "filename_ext": "scala", "original_language": "Scala", "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/Scala/s652285654.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s652285654", "user_id": "u116590310"}, "prompt_components": {"gold_output": "a\n", "input_to_evaluate": "import scala.io.StdIn._\nobject Main {\n\tdef main(args :Array[String]) = {\n\t\tvar mtrl = readLine.split(\" \").map(_.toInt)\n\t\t\n\t\tif (mtrl(0)==mtrl(1)) { val f = \"==\"; println(mtrl(0)+f+mtrl(1)) } \n\t\telse if (mtrl(0)>mtrl(1)) { val f = \"<\"; println(mtrl(0)+f+mtrl(1)) }\n\t\telse { val f = \">\"; println(mtrl(0)+f+mtrl(1)) }\t\n\t}\n\t\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 220, "memory_kb": 43476}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s649804090", "group_id": "codeNet:p02391", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val a, b = sc.nextInt()\n if (a < b) println(\"a < b\")\n else if (a > b) println(\"a > b\")\n else println(\"a == b\")\n}", "language": "Scala", "metadata": {"date": 1464920529, "filename_ext": "scala", "original_language": "Scala", "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/Scala/s649804090.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s649804090", "user_id": "u859425877"}, "prompt_components": {"gold_output": "a\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val a, b = sc.nextInt()\n if (a < b) println(\"a < b\")\n else if (a > b) println(\"a > b\")\n else println(\"a == b\")\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 203, "cpu_time_ms": 280, "memory_kb": 45060}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s269305801", "group_id": "codeNet:p02392", "input_text": "import scala.io.StdIn\n\nobject Main{\n def main(args: Array[String]){\n var list = List[Int]()\n\n for(in <- StdIn.readLine.split(\" \").map(_.toInt)){\n list = in :: list\n }\n\n boc(list.reverse)\n }\n\n def boc(a: List[Int])={\n if(a(0) < a(1) && a(1) < a(2)) println(\"Yes\")\n else println(\"No\")\n }\n}", "language": "Scala", "metadata": {"date": 1435246765, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02392.html", "problem_id": "p02392", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02392/input.txt", "sample_output_relpath": "derived/input_output/data/p02392/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02392/Scala/s269305801.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s269305801", "user_id": "u085441951"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main{\n def main(args: Array[String]){\n var list = List[Int]()\n\n for(in <- StdIn.readLine.split(\" \").map(_.toInt)){\n list = in :: list\n }\n\n boc(list.reverse)\n }\n\n def boc(a: List[Int])={\n if(a(0) < a(1) && a(1) < a(2)) println(\"Yes\")\n else println(\"No\")\n }\n}", "problem_context": "Range\n\nWrite a program which reads three integers a, b and c, and prints \"Yes\" if a < b < c, otherwise \"No\".\n\nInput\n\nThree integers a, b and c separated by a single space are given in a line.\n\nOutput\n\nPrint \"Yes\" or \"No\" in a line.\n\nConstraints\n\n0 ≤ a, b, c ≤ 100\n\nSample Input 1\n\n1 3 8\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n3 8 1\n\nSample Output 2\n\nNo", "sample_input": "1 3 8\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02392", "source_text": "Range\n\nWrite a program which reads three integers a, b and c, and prints \"Yes\" if a < b < c, otherwise \"No\".\n\nInput\n\nThree integers a, b and c separated by a single space are given in a line.\n\nOutput\n\nPrint \"Yes\" or \"No\" in a line.\n\nConstraints\n\n0 ≤ a, b, c ≤ 100\n\nSample Input 1\n\n1 3 8\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n3 8 1\n\nSample Output 2\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43904}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s806560608", "group_id": "codeNet:p02392", "input_text": "object Main {\n def main(args:Array[String]) {\n val sc = new java.util.Scanner(System.in)\n val a = sc.nextInt \n val b = sc.nextInt\n val c = sc.nextInt\n println(if(a Integer.parseInt(i))\n println(\"%s\".format(if (s(0) Integer.parseInt(i))\n println(\"%s\".format(if (s(0) s.toInt)\n\n println(if(in(0) < in(1) && in(1) < in(2)){\"Yes\"}else{\"No\"})\n }\n}", "language": "Scala", "metadata": {"date": 1498286636, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02392.html", "problem_id": "p02392", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02392/input.txt", "sample_output_relpath": "derived/input_output/data/p02392/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02392/Scala/s905193886.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s905193886", "user_id": "u048060093"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.io.StdIn\n\n/**\n * AOJ\n */\nobject Main {\n\n def main(args: Array[String]): Unit = {\n\n val in = StdIn.readLine().split(\" \").map(s => s.toInt)\n\n println(if(in(0) < in(1) && in(1) < in(2)){\"Yes\"}else{\"No\"})\n }\n}", "problem_context": "Range\n\nWrite a program which reads three integers a, b and c, and prints \"Yes\" if a < b < c, otherwise \"No\".\n\nInput\n\nThree integers a, b and c separated by a single space are given in a line.\n\nOutput\n\nPrint \"Yes\" or \"No\" in a line.\n\nConstraints\n\n0 ≤ a, b, c ≤ 100\n\nSample Input 1\n\n1 3 8\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n3 8 1\n\nSample Output 2\n\nNo", "sample_input": "1 3 8\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02392", "source_text": "Range\n\nWrite a program which reads three integers a, b and c, and prints \"Yes\" if a < b < c, otherwise \"No\".\n\nInput\n\nThree integers a, b and c separated by a single space are given in a line.\n\nOutput\n\nPrint \"Yes\" or \"No\" in a line.\n\nConstraints\n\n0 ≤ a, b, c ≤ 100\n\nSample Input 1\n\n1 3 8\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n3 8 1\n\nSample Output 2\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 220, "memory_kb": 43696}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s494067596", "group_id": "codeNet:p02392", "input_text": "object Main {\n def main(args: Array[String]) = {\n \n val input: String = readLine()\n val list: Array[String] = input.split(\" \")\n \n val a: Int = list(0).toInt\n val b: Int = list(1).toInt\n val c: Int = list(2).toInt\n\n var ans = \"No\"\n if (a < b && b < c) {\n ans = \"Yes\"\n }\n println(ans)\n }\n \n// def readLine(): String = {\"5 5\"}\n}\n", "language": "Scala", "metadata": {"date": 1587200778, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02392.html", "problem_id": "p02392", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02392/input.txt", "sample_output_relpath": "derived/input_output/data/p02392/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02392/Scala/s494067596.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s494067596", "user_id": "u657361950"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]) = {\n \n val input: String = readLine()\n val list: Array[String] = input.split(\" \")\n \n val a: Int = list(0).toInt\n val b: Int = list(1).toInt\n val c: Int = list(2).toInt\n\n var ans = \"No\"\n if (a < b && b < c) {\n ans = \"Yes\"\n }\n println(ans)\n }\n \n// def readLine(): String = {\"5 5\"}\n}\n", "problem_context": "Range\n\nWrite a program which reads three integers a, b and c, and prints \"Yes\" if a < b < c, otherwise \"No\".\n\nInput\n\nThree integers a, b and c separated by a single space are given in a line.\n\nOutput\n\nPrint \"Yes\" or \"No\" in a line.\n\nConstraints\n\n0 ≤ a, b, c ≤ 100\n\nSample Input 1\n\n1 3 8\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n3 8 1\n\nSample Output 2\n\nNo", "sample_input": "1 3 8\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02392", "source_text": "Range\n\nWrite a program which reads three integers a, b and c, and prints \"Yes\" if a < b < c, otherwise \"No\".\n\nInput\n\nThree integers a, b and c separated by a single space are given in a line.\n\nOutput\n\nPrint \"Yes\" or \"No\" in a line.\n\nConstraints\n\n0 ≤ a, b, c ≤ 100\n\nSample Input 1\n\n1 3 8\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n3 8 1\n\nSample Output 2\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 368, "cpu_time_ms": 340, "memory_kb": 43708}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s093604617", "group_id": "codeNet:p02392", "input_text": "object Main extends App {\n val x = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n val a = x(0)\n val b = x(1)\n val c = x(2)\n if (a < b && b < c) println(\"Yes\")\n else println(\"No\")\n}\n", "language": "Scala", "metadata": {"date": 1538472504, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02392.html", "problem_id": "p02392", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02392/input.txt", "sample_output_relpath": "derived/input_output/data/p02392/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02392/Scala/s093604617.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s093604617", "user_id": "u300645832"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n val x = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n val a = x(0)\n val b = x(1)\n val c = x(2)\n if (a < b && b < c) println(\"Yes\")\n else println(\"No\")\n}\n", "problem_context": "Range\n\nWrite a program which reads three integers a, b and c, and prints \"Yes\" if a < b < c, otherwise \"No\".\n\nInput\n\nThree integers a, b and c separated by a single space are given in a line.\n\nOutput\n\nPrint \"Yes\" or \"No\" in a line.\n\nConstraints\n\n0 ≤ a, b, c ≤ 100\n\nSample Input 1\n\n1 3 8\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n3 8 1\n\nSample Output 2\n\nNo", "sample_input": "1 3 8\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02392", "source_text": "Range\n\nWrite a program which reads three integers a, b and c, and prints \"Yes\" if a < b < c, otherwise \"No\".\n\nInput\n\nThree integers a, b and c separated by a single space are given in a line.\n\nOutput\n\nPrint \"Yes\" or \"No\" in a line.\n\nConstraints\n\n0 ≤ a, b, c ≤ 100\n\nSample Input 1\n\n1 3 8\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n3 8 1\n\nSample Output 2\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 220, "memory_kb": 43832}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s527247551", "group_id": "codeNet:p02393", "input_text": "import scala.io.StdIn\n\nobject Main{\n def main(args: Array[String]){\n var list = List[Int]()\n\n for(in <- StdIn.readLine.split(\" \").map(_.toInt)){\n list = in :: list\n }\n\n list.reverse.sortWith((s,t: Int) => s < t).foreach((s: Int) => printf(\"%d \", s))\n println()\n }\n}", "language": "Scala", "metadata": {"date": 1435248379, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02393.html", "problem_id": "p02393", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02393/input.txt", "sample_output_relpath": "derived/input_output/data/p02393/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02393/Scala/s527247551.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s527247551", "user_id": "u085441951"}, "prompt_components": {"gold_output": "1 3 8\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main{\n def main(args: Array[String]){\n var list = List[Int]()\n\n for(in <- StdIn.readLine.split(\" \").map(_.toInt)){\n list = in :: list\n }\n\n list.reverse.sortWith((s,t: Int) => s < t).foreach((s: Int) => printf(\"%d \", s))\n println()\n }\n}", "problem_context": "Sorting Three Numbers\n\nWrite a program which reads three integers, and prints them in ascending order.\n\nInput\n\nThree integers separated by a single space are given in a line.\n\nOutput\n\nPrint the given integers in ascending order in a line. Put a single space between two integers.\n\nConstraints\n\n1 ≤ the three integers ≤ 10000\n\nSample Input 1\n\n3 8 1\n\nSample Output 1\n\n1 3 8", "sample_input": "3 8 1\n"}, "reference_outputs": ["1 3 8\n"], "source_document_id": "p02393", "source_text": "Sorting Three Numbers\n\nWrite a program which reads three integers, and prints them in ascending order.\n\nInput\n\nThree integers separated by a single space are given in a line.\n\nOutput\n\nPrint the given integers in ascending order in a line. Put a single space between two integers.\n\nConstraints\n\n1 ≤ the three integers ≤ 10000\n\nSample Input 1\n\n3 8 1\n\nSample Output 1\n\n1 3 8", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 287, "cpu_time_ms": 230, "memory_kb": 44128}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s681870319", "group_id": "codeNet:p02393", "input_text": "import scala.io.StdIn.readLine\n\nobject Main {\n\n def main(args: Array[String]) = {\n val n = readLine().split(\" \").map(_.toInt).sorted\n val (a,b,c) = (n(0),n(1),n(2))\n println(a + \" \" + b + \" \" + c)\n }\n}", "language": "Scala", "metadata": {"date": 1476435075, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02393.html", "problem_id": "p02393", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02393/input.txt", "sample_output_relpath": "derived/input_output/data/p02393/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02393/Scala/s681870319.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s681870319", "user_id": "u508732591"}, "prompt_components": {"gold_output": "1 3 8\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main {\n\n def main(args: Array[String]) = {\n val n = readLine().split(\" \").map(_.toInt).sorted\n val (a,b,c) = (n(0),n(1),n(2))\n println(a + \" \" + b + \" \" + c)\n }\n}", "problem_context": "Sorting Three Numbers\n\nWrite a program which reads three integers, and prints them in ascending order.\n\nInput\n\nThree integers separated by a single space are given in a line.\n\nOutput\n\nPrint the given integers in ascending order in a line. Put a single space between two integers.\n\nConstraints\n\n1 ≤ the three integers ≤ 10000\n\nSample Input 1\n\n3 8 1\n\nSample Output 1\n\n1 3 8", "sample_input": "3 8 1\n"}, "reference_outputs": ["1 3 8\n"], "source_document_id": "p02393", "source_text": "Sorting Three Numbers\n\nWrite a program which reads three integers, and prints them in ascending order.\n\nInput\n\nThree integers separated by a single space are given in a line.\n\nOutput\n\nPrint the given integers in ascending order in a line. Put a single space between two integers.\n\nConstraints\n\n1 ≤ the three integers ≤ 10000\n\nSample Input 1\n\n3 8 1\n\nSample Output 1\n\n1 3 8", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 220, "memory_kb": 43820}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s155034249", "group_id": "codeNet:p02393", "input_text": "object Main {\n case class Line(string: String) {\n def strings: Seq[String] = string.split(' ')\n def ints: Seq[Int] = strings.map(_.toInt)\n def i(n: Int): Int = ints(n)\n }\n\n def readLine: Line = Line(io.StdIn.readLine())\n def readLines(n: Int): Seq[Line] = List.fill(n)(Line(io.StdIn.readLine()))\n\n def yesNo(b: Boolean): String = if (b) \"Yes\" else \"No\"\n\n def main(args: Array[String]) {\n println(readLine.ints.sorted.mkString(\" \"))\n }\n}", "language": "Scala", "metadata": {"date": 1480671026, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02393.html", "problem_id": "p02393", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02393/input.txt", "sample_output_relpath": "derived/input_output/data/p02393/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02393/Scala/s155034249.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s155034249", "user_id": "u767513951"}, "prompt_components": {"gold_output": "1 3 8\n", "input_to_evaluate": "object Main {\n case class Line(string: String) {\n def strings: Seq[String] = string.split(' ')\n def ints: Seq[Int] = strings.map(_.toInt)\n def i(n: Int): Int = ints(n)\n }\n\n def readLine: Line = Line(io.StdIn.readLine())\n def readLines(n: Int): Seq[Line] = List.fill(n)(Line(io.StdIn.readLine()))\n\n def yesNo(b: Boolean): String = if (b) \"Yes\" else \"No\"\n\n def main(args: Array[String]) {\n println(readLine.ints.sorted.mkString(\" \"))\n }\n}", "problem_context": "Sorting Three Numbers\n\nWrite a program which reads three integers, and prints them in ascending order.\n\nInput\n\nThree integers separated by a single space are given in a line.\n\nOutput\n\nPrint the given integers in ascending order in a line. Put a single space between two integers.\n\nConstraints\n\n1 ≤ the three integers ≤ 10000\n\nSample Input 1\n\n3 8 1\n\nSample Output 1\n\n1 3 8", "sample_input": "3 8 1\n"}, "reference_outputs": ["1 3 8\n"], "source_document_id": "p02393", "source_text": "Sorting Three Numbers\n\nWrite a program which reads three integers, and prints them in ascending order.\n\nInput\n\nThree integers separated by a single space are given in a line.\n\nOutput\n\nPrint the given integers in ascending order in a line. Put a single space between two integers.\n\nConstraints\n\n1 ≤ the three integers ≤ 10000\n\nSample Input 1\n\n3 8 1\n\nSample Output 1\n\n1 3 8", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 43716}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s633065906", "group_id": "codeNet:p02393", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n val a = StdIn.readLine().trim.split(' ').map(_.toInt)\n\n println(a.sorted.toList.mkString(\" \"))\n \n}\n", "language": "Scala", "metadata": {"date": 1521758432, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02393.html", "problem_id": "p02393", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02393/input.txt", "sample_output_relpath": "derived/input_output/data/p02393/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02393/Scala/s633065906.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s633065906", "user_id": "u342234782"}, "prompt_components": {"gold_output": "1 3 8\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n val a = StdIn.readLine().trim.split(' ').map(_.toInt)\n\n println(a.sorted.toList.mkString(\" \"))\n \n}\n", "problem_context": "Sorting Three Numbers\n\nWrite a program which reads three integers, and prints them in ascending order.\n\nInput\n\nThree integers separated by a single space are given in a line.\n\nOutput\n\nPrint the given integers in ascending order in a line. Put a single space between two integers.\n\nConstraints\n\n1 ≤ the three integers ≤ 10000\n\nSample Input 1\n\n3 8 1\n\nSample Output 1\n\n1 3 8", "sample_input": "3 8 1\n"}, "reference_outputs": ["1 3 8\n"], "source_document_id": "p02393", "source_text": "Sorting Three Numbers\n\nWrite a program which reads three integers, and prints them in ascending order.\n\nInput\n\nThree integers separated by a single space are given in a line.\n\nOutput\n\nPrint the given integers in ascending order in a line. Put a single space between two integers.\n\nConstraints\n\n1 ≤ the three integers ≤ 10000\n\nSample Input 1\n\n3 8 1\n\nSample Output 1\n\n1 3 8", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 43896}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s780860438", "group_id": "codeNet:p02394", "input_text": "object Main {\n def main (args: Array[String]) {\n val Array(width, height, x, y, r) = scala.io.StdIn.readLine().split(\" \").map(_.toInt).filter(_ >= 0)\n \n width match{\n case w if (x-r >= 0) && (y-r >=0) && (x+r <= width) && (y+r <= height) => println(\"Yes\")\n case _ => println(\"No\")\n }\n }\n}", "language": "Scala", "metadata": {"date": 1436969717, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02394.html", "problem_id": "p02394", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02394/input.txt", "sample_output_relpath": "derived/input_output/data/p02394/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02394/Scala/s780860438.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s780860438", "user_id": "u012178320"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main {\n def main (args: Array[String]) {\n val Array(width, height, x, y, r) = scala.io.StdIn.readLine().split(\" \").map(_.toInt).filter(_ >= 0)\n \n width match{\n case w if (x-r >= 0) && (y-r >=0) && (x+r <= width) && (y+r <= height) => println(\"Yes\")\n case _ => println(\"No\")\n }\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nCircle in a Rectangle\n\nWrite a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given.\n\nInput\n\nFive integers $W$, $H$, $x$, $y$ and $r$ separated by a single space are given in a line.\n\nOutput\n\nPrint \"Yes\" if the circle is placed inside the rectangle, otherwise \"No\" in a line.\n\nConstraints\n\n$ -100 \\leq x, y \\leq 100$\n\n$ 0 < W, H, r \\leq 100$\n\nSample Input 1\n\n5 4 2 2 1\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n5 4 2 4 1\n\nSample Output 2\n\nNo", "sample_input": "5 4 2 2 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02394", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nCircle in a Rectangle\n\nWrite a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given.\n\nInput\n\nFive integers $W$, $H$, $x$, $y$ and $r$ separated by a single space are given in a line.\n\nOutput\n\nPrint \"Yes\" if the circle is placed inside the rectangle, otherwise \"No\" in a line.\n\nConstraints\n\n$ -100 \\leq x, y \\leq 100$\n\n$ 0 < W, H, r \\leq 100$\n\nSample Input 1\n\n5 4 2 2 1\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n5 4 2 4 1\n\nSample Output 2\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 43964}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s393078231", "group_id": "codeNet:p02394", "input_text": "import java.util.Scanner\n\nobject Main {\n def main (args: Array[String]) = {\n val in = new Scanner(System.in)\n val W = in.nextInt\n val H = in.nextInt\n val x = in.nextInt\n val y = in.nextInt\n val r = in.nextInt\n\n val wIn = (0 < (x - r)) && (W >= (x + r))\n val hIn = (0 < (y - r)) && (H >= (y + r))\n val result = if(wIn && hIn) \"Yes\" else \"No\"\n\n println(result)\n\n }\n}", "language": "Scala", "metadata": {"date": 1449291754, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02394.html", "problem_id": "p02394", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02394/input.txt", "sample_output_relpath": "derived/input_output/data/p02394/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02394/Scala/s393078231.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s393078231", "user_id": "u188848609"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def main (args: Array[String]) = {\n val in = new Scanner(System.in)\n val W = in.nextInt\n val H = in.nextInt\n val x = in.nextInt\n val y = in.nextInt\n val r = in.nextInt\n\n val wIn = (0 < (x - r)) && (W >= (x + r))\n val hIn = (0 < (y - r)) && (H >= (y + r))\n val result = if(wIn && hIn) \"Yes\" else \"No\"\n\n println(result)\n\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nCircle in a Rectangle\n\nWrite a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given.\n\nInput\n\nFive integers $W$, $H$, $x$, $y$ and $r$ separated by a single space are given in a line.\n\nOutput\n\nPrint \"Yes\" if the circle is placed inside the rectangle, otherwise \"No\" in a line.\n\nConstraints\n\n$ -100 \\leq x, y \\leq 100$\n\n$ 0 < W, H, r \\leq 100$\n\nSample Input 1\n\n5 4 2 2 1\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n5 4 2 4 1\n\nSample Output 2\n\nNo", "sample_input": "5 4 2 2 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02394", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nCircle in a Rectangle\n\nWrite a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given.\n\nInput\n\nFive integers $W$, $H$, $x$, $y$ and $r$ separated by a single space are given in a line.\n\nOutput\n\nPrint \"Yes\" if the circle is placed inside the rectangle, otherwise \"No\" in a line.\n\nConstraints\n\n$ -100 \\leq x, y \\leq 100$\n\n$ 0 < W, H, r \\leq 100$\n\nSample Input 1\n\n5 4 2 2 1\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n5 4 2 4 1\n\nSample Output 2\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 396, "cpu_time_ms": 250, "memory_kb": 44884}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s108088980", "group_id": "codeNet:p02394", "input_text": "object Main {\n def main(args: Array[String]) {\n val sc = new java.util.Scanner(System.in)\n val w, h, x, y, r = sc.nextInt\n if (r <= x && r <= y && (x <= ( w - r )) && ( y <= ( h - r ))) println(\"Yes\")\n else println(\"No\")\n\n }\n\n}", "language": "Scala", "metadata": {"date": 1454324464, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02394.html", "problem_id": "p02394", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02394/input.txt", "sample_output_relpath": "derived/input_output/data/p02394/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02394/Scala/s108088980.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s108088980", "user_id": "u859425877"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]) {\n val sc = new java.util.Scanner(System.in)\n val w, h, x, y, r = sc.nextInt\n if (r <= x && r <= y && (x <= ( w - r )) && ( y <= ( h - r ))) println(\"Yes\")\n else println(\"No\")\n\n }\n\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nCircle in a Rectangle\n\nWrite a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given.\n\nInput\n\nFive integers $W$, $H$, $x$, $y$ and $r$ separated by a single space are given in a line.\n\nOutput\n\nPrint \"Yes\" if the circle is placed inside the rectangle, otherwise \"No\" in a line.\n\nConstraints\n\n$ -100 \\leq x, y \\leq 100$\n\n$ 0 < W, H, r \\leq 100$\n\nSample Input 1\n\n5 4 2 2 1\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n5 4 2 4 1\n\nSample Output 2\n\nNo", "sample_input": "5 4 2 2 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02394", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nCircle in a Rectangle\n\nWrite a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given.\n\nInput\n\nFive integers $W$, $H$, $x$, $y$ and $r$ separated by a single space are given in a line.\n\nOutput\n\nPrint \"Yes\" if the circle is placed inside the rectangle, otherwise \"No\" in a line.\n\nConstraints\n\n$ -100 \\leq x, y \\leq 100$\n\n$ 0 < W, H, r \\leq 100$\n\nSample Input 1\n\n5 4 2 2 1\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n5 4 2 4 1\n\nSample Output 2\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 245, "cpu_time_ms": 280, "memory_kb": 45076}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s169094757", "group_id": "codeNet:p02394", "input_text": "import scala.io.StdIn.readLine\n\nobject Main {\n def main(args:Array[String]) {\n val in = readLine().split(\" \").map(_.toInt)\n val (h, w, x, y, r) = (in(0), in(1), in(2), in(3), in(4))\n\n if (0 <= x - r && 0 <= y - r && x + r <= w && y + r <= h) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n }\n}", "language": "Scala", "metadata": {"date": 1510551074, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02394.html", "problem_id": "p02394", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02394/input.txt", "sample_output_relpath": "derived/input_output/data/p02394/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02394/Scala/s169094757.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s169094757", "user_id": "u343251190"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main {\n def main(args:Array[String]) {\n val in = readLine().split(\" \").map(_.toInt)\n val (h, w, x, y, r) = (in(0), in(1), in(2), in(3), in(4))\n\n if (0 <= x - r && 0 <= y - r && x + r <= w && y + r <= h) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nCircle in a Rectangle\n\nWrite a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given.\n\nInput\n\nFive integers $W$, $H$, $x$, $y$ and $r$ separated by a single space are given in a line.\n\nOutput\n\nPrint \"Yes\" if the circle is placed inside the rectangle, otherwise \"No\" in a line.\n\nConstraints\n\n$ -100 \\leq x, y \\leq 100$\n\n$ 0 < W, H, r \\leq 100$\n\nSample Input 1\n\n5 4 2 2 1\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n5 4 2 4 1\n\nSample Output 2\n\nNo", "sample_input": "5 4 2 2 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02394", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nCircle in a Rectangle\n\nWrite a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given.\n\nInput\n\nFive integers $W$, $H$, $x$, $y$ and $r$ separated by a single space are given in a line.\n\nOutput\n\nPrint \"Yes\" if the circle is placed inside the rectangle, otherwise \"No\" in a line.\n\nConstraints\n\n$ -100 \\leq x, y \\leq 100$\n\n$ 0 < W, H, r \\leq 100$\n\nSample Input 1\n\n5 4 2 2 1\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n5 4 2 4 1\n\nSample Output 2\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43412}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s342389602", "group_id": "codeNet:p02396", "input_text": "object Main extends App {\n var i = 0\n val sb = StringBuilder.newBuilder\n for(x <- io.Source.stdin.getLines() if x != \"0\") {\n i += 1\n sb.append(\"Case \").append(i).append(\": \")\n .append(x).append('\\n')\n }\n print(sb.toString())\n}\n", "language": "Scala", "metadata": {"date": 1540801787, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02396.html", "problem_id": "p02396", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02396/input.txt", "sample_output_relpath": "derived/input_output/data/p02396/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02396/Scala/s342389602.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s342389602", "user_id": "u768801062"}, "prompt_components": {"gold_output": "Case 1: 3\nCase 2: 5\nCase 3: 11\nCase 4: 7\nCase 5: 8\nCase 6: 19\n", "input_to_evaluate": "object Main extends App {\n var i = 0\n val sb = StringBuilder.newBuilder\n for(x <- io.Source.stdin.getLines() if x != \"0\") {\n i += 1\n sb.append(\"Case \").append(i).append(\": \")\n .append(x).append('\\n')\n }\n print(sb.toString())\n}\n", "problem_context": "Print Test Cases\n\nIn the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets.\n\nWrite a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of an integer x in a line.\n\nThe input ends with an integer 0. You program should not process (print) for this terminal symbol.\n\nOutput\n\nFor each dataset, print x in the following format:\n\nCase i: x\n\nwhere i is the case number which starts with 1. Put a single space between \"Case\" and i. Also, put a single space between ':' and x.\n\nConstraints\n\n1 ≤ x ≤ 10000\n\nThe number of datasets ≤ 10000\n\nSample Input\n\n3\n5\n11\n7\n8\n19\n0\n\nSample Output\n\nCase 1: 3\nCase 2: 5\nCase 3: 11\nCase 4: 7\nCase 5: 8\nCase 6: 19", "sample_input": "3\n5\n11\n7\n8\n19\n0\n"}, "reference_outputs": ["Case 1: 3\nCase 2: 5\nCase 3: 11\nCase 4: 7\nCase 5: 8\nCase 6: 19\n"], "source_document_id": "p02396", "source_text": "Print Test Cases\n\nIn the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets.\n\nWrite a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of an integer x in a line.\n\nThe input ends with an integer 0. You program should not process (print) for this terminal symbol.\n\nOutput\n\nFor each dataset, print x in the following format:\n\nCase i: x\n\nwhere i is the case number which starts with 1. Put a single space between \"Case\" and i. Also, put a single space between ':' and x.\n\nConstraints\n\n1 ≤ x ≤ 10000\n\nThe number of datasets ≤ 10000\n\nSample Input\n\n3\n5\n11\n7\n8\n19\n0\n\nSample Output\n\nCase 1: 3\nCase 2: 5\nCase 3: 11\nCase 4: 7\nCase 5: 8\nCase 6: 19", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 270, "memory_kb": 49320}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s316883280", "group_id": "codeNet:p02396", "input_text": "object Main extends App {\n var i = 0\n val sb = StringBuilder.newBuilder\n for(x <- io.Source.stdin.getLines() if x != \"0\") {\n i += 1\n // sb.append(\"Case \").append(i).append(\": \")\n // .append(x).append('\\n')\n sb.append(s\"Case $i: $x\\n\")\n }\n print(sb.toString())\n}\n", "language": "Scala", "metadata": {"date": 1540802142, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02396.html", "problem_id": "p02396", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02396/input.txt", "sample_output_relpath": "derived/input_output/data/p02396/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02396/Scala/s316883280.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s316883280", "user_id": "u768801062"}, "prompt_components": {"gold_output": "Case 1: 3\nCase 2: 5\nCase 3: 11\nCase 4: 7\nCase 5: 8\nCase 6: 19\n", "input_to_evaluate": "object Main extends App {\n var i = 0\n val sb = StringBuilder.newBuilder\n for(x <- io.Source.stdin.getLines() if x != \"0\") {\n i += 1\n // sb.append(\"Case \").append(i).append(\": \")\n // .append(x).append('\\n')\n sb.append(s\"Case $i: $x\\n\")\n }\n print(sb.toString())\n}\n", "problem_context": "Print Test Cases\n\nIn the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets.\n\nWrite a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of an integer x in a line.\n\nThe input ends with an integer 0. You program should not process (print) for this terminal symbol.\n\nOutput\n\nFor each dataset, print x in the following format:\n\nCase i: x\n\nwhere i is the case number which starts with 1. Put a single space between \"Case\" and i. Also, put a single space between ':' and x.\n\nConstraints\n\n1 ≤ x ≤ 10000\n\nThe number of datasets ≤ 10000\n\nSample Input\n\n3\n5\n11\n7\n8\n19\n0\n\nSample Output\n\nCase 1: 3\nCase 2: 5\nCase 3: 11\nCase 4: 7\nCase 5: 8\nCase 6: 19", "sample_input": "3\n5\n11\n7\n8\n19\n0\n"}, "reference_outputs": ["Case 1: 3\nCase 2: 5\nCase 3: 11\nCase 4: 7\nCase 5: 8\nCase 6: 19\n"], "source_document_id": "p02396", "source_text": "Print Test Cases\n\nIn the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets.\n\nWrite a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of an integer x in a line.\n\nThe input ends with an integer 0. You program should not process (print) for this terminal symbol.\n\nOutput\n\nFor each dataset, print x in the following format:\n\nCase i: x\n\nwhere i is the case number which starts with 1. Put a single space between \"Case\" and i. Also, put a single space between ':' and x.\n\nConstraints\n\n1 ≤ x ≤ 10000\n\nThe number of datasets ≤ 10000\n\nSample Input\n\n3\n5\n11\n7\n8\n19\n0\n\nSample Output\n\nCase 1: 3\nCase 2: 5\nCase 3: 11\nCase 4: 7\nCase 5: 8\nCase 6: 19", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 281, "cpu_time_ms": 300, "memory_kb": 55660}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s768884031", "group_id": "codeNet:p02397", "input_text": "\nobject Main {\n def main(args: Array[String]): Unit = {\n for(line <- io.Source.stdin.getLines() if line != \"0 0\") {\n val arr = line.split(\" \").map(_.toInt).sorted\n println(arr(0) + \" \" + arr(1))\n }\n }\n}", "language": "Scala", "metadata": {"date": 1489211822, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02397.html", "problem_id": "p02397", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02397/input.txt", "sample_output_relpath": "derived/input_output/data/p02397/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02397/Scala/s768884031.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s768884031", "user_id": "u119127920"}, "prompt_components": {"gold_output": "2 3\n2 2\n3 5\n", "input_to_evaluate": "\nobject Main {\n def main(args: Array[String]): Unit = {\n for(line <- io.Source.stdin.getLines() if line != \"0 0\") {\n val arr = line.split(\" \").map(_.toInt).sorted\n println(arr(0) + \" \" + arr(1))\n }\n }\n}", "problem_context": "Swapping Two Numbers\n\nWrite a program which reads two integers x and y, and prints them in ascending order.\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of two integers x and y separated by a single space.\n\nThe input ends with two 0 (when both x and y are zero). Your program should not process for these terminal symbols.\n\nOutput\n\nFor each dataset, print x and y in ascending order in a line. Put a single space between x and y.\n\nConstraints\n\n0 ≤ x, y ≤ 10000\n\nthe number of datasets ≤ 3000\n\nSample Input\n\n3 2\n2 2\n5 3\n0 0\n\nSample Output\n\n2 3\n2 2\n3 5", "sample_input": "3 2\n2 2\n5 3\n0 0\n"}, "reference_outputs": ["2 3\n2 2\n3 5\n"], "source_document_id": "p02397", "source_text": "Swapping Two Numbers\n\nWrite a program which reads two integers x and y, and prints them in ascending order.\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of two integers x and y separated by a single space.\n\nThe input ends with two 0 (when both x and y are zero). Your program should not process for these terminal symbols.\n\nOutput\n\nFor each dataset, print x and y in ascending order in a line. Put a single space between x and y.\n\nConstraints\n\n0 ≤ x, y ≤ 10000\n\nthe number of datasets ≤ 3000\n\nSample Input\n\n3 2\n2 2\n5 3\n0 0\n\nSample Output\n\n2 3\n2 2\n3 5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 310, "memory_kb": 47176}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s362041394", "group_id": "codeNet:p02398", "input_text": "object Main {\n def main (args: Array[String]) {\n var count:Int = 0\n for(line <- scala.io.Source.stdin.getLines()){\n val Array(min, max, o) = line.split(\" \").map(_.toInt)\n var list: List[Int] = List()\n for( i <- min to max if ((o % i) == 0) ) list = i::list\n println(list)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1437024085, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02398.html", "problem_id": "p02398", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02398/input.txt", "sample_output_relpath": "derived/input_output/data/p02398/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02398/Scala/s362041394.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s362041394", "user_id": "u012178320"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main {\n def main (args: Array[String]) {\n var count:Int = 0\n for(line <- scala.io.Source.stdin.getLines()){\n val Array(min, max, o) = line.split(\" \").map(_.toInt)\n var list: List[Int] = List()\n for( i <- min to max if ((o % i) == 0) ) list = i::list\n println(list)\n }\n }\n}", "problem_context": "How Many Divisors?\n\nWrite a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.\n\nInput\n\nThree integers a, b and c are given in a line separated by a single space.\n\nOutput\n\nPrint the number of divisors in a line.\n\nConstraints\n\n1 ≤ a, b, c ≤ 10000\n\na ≤ b\n\nSample Input 1\n\n5 14 80\n\nSample Output 1\n\n3", "sample_input": "5 14 80\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02398", "source_text": "How Many Divisors?\n\nWrite a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.\n\nInput\n\nThree integers a, b and c are given in a line separated by a single space.\n\nOutput\n\nPrint the number of divisors in a line.\n\nConstraints\n\n1 ≤ a, b, c ≤ 10000\n\na ≤ b\n\nSample Input 1\n\n5 14 80\n\nSample Output 1\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43852}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s530378189", "group_id": "codeNet:p02398", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val a, b, c = sc.nextInt\n println((a to b).filter(c % _ == 0).size)\n}", "language": "Scala", "metadata": {"date": 1440228769, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02398.html", "problem_id": "p02398", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02398/input.txt", "sample_output_relpath": "derived/input_output/data/p02398/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02398/Scala/s530378189.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s530378189", "user_id": "u490032117"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val a, b, c = sc.nextInt\n println((a to b).filter(c % _ == 0).size)\n}", "problem_context": "How Many Divisors?\n\nWrite a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.\n\nInput\n\nThree integers a, b and c are given in a line separated by a single space.\n\nOutput\n\nPrint the number of divisors in a line.\n\nConstraints\n\n1 ≤ a, b, c ≤ 10000\n\na ≤ b\n\nSample Input 1\n\n5 14 80\n\nSample Output 1\n\n3", "sample_input": "5 14 80\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02398", "source_text": "How Many Divisors?\n\nWrite a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.\n\nInput\n\nThree integers a, b and c are given in a line separated by a single space.\n\nOutput\n\nPrint the number of divisors in a line.\n\nConstraints\n\n1 ≤ a, b, c ≤ 10000\n\na ≤ b\n\nSample Input 1\n\n5 14 80\n\nSample Output 1\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 270, "memory_kb": 45272}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s642689337", "group_id": "codeNet:p02398", "input_text": "import java.util.Scanner\n\nobject Main {\n def main (args: Array[String]) = {\n val in = new Scanner(System.in)\n val a = in.nextInt\n val b = in.nextInt\n val c = in.nextInt\n\n val div = for (\n i <- 1 to c\n if ((c % i) == 0)\n if (a <= i && b >= i)\n ) yield i\n\n println(div.length)\n }\n}", "language": "Scala", "metadata": {"date": 1449385673, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02398.html", "problem_id": "p02398", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02398/input.txt", "sample_output_relpath": "derived/input_output/data/p02398/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02398/Scala/s642689337.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s642689337", "user_id": "u188848609"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def main (args: Array[String]) = {\n val in = new Scanner(System.in)\n val a = in.nextInt\n val b = in.nextInt\n val c = in.nextInt\n\n val div = for (\n i <- 1 to c\n if ((c % i) == 0)\n if (a <= i && b >= i)\n ) yield i\n\n println(div.length)\n }\n}", "problem_context": "How Many Divisors?\n\nWrite a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.\n\nInput\n\nThree integers a, b and c are given in a line separated by a single space.\n\nOutput\n\nPrint the number of divisors in a line.\n\nConstraints\n\n1 ≤ a, b, c ≤ 10000\n\na ≤ b\n\nSample Input 1\n\n5 14 80\n\nSample Output 1\n\n3", "sample_input": "5 14 80\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02398", "source_text": "How Many Divisors?\n\nWrite a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.\n\nInput\n\nThree integers a, b and c are given in a line separated by a single space.\n\nOutput\n\nPrint the number of divisors in a line.\n\nConstraints\n\n1 ≤ a, b, c ≤ 10000\n\na ≤ b\n\nSample Input 1\n\n5 14 80\n\nSample Output 1\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 260, "memory_kb": 45380}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s083205777", "group_id": "codeNet:p02398", "input_text": "object Main {\n def main(args:Array[String]){\n var count=0\n val sc=new java.util.Scanner(System.in)\n val a,b,c=sc.nextInt\n for(i<-a to b){\n if(c%i==0) count+=1\n }\n println(count)\n }\n}", "language": "Scala", "metadata": {"date": 1471526007, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02398.html", "problem_id": "p02398", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02398/input.txt", "sample_output_relpath": "derived/input_output/data/p02398/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02398/Scala/s083205777.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s083205777", "user_id": "u496100636"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main {\n def main(args:Array[String]){\n var count=0\n val sc=new java.util.Scanner(System.in)\n val a,b,c=sc.nextInt\n for(i<-a to b){\n if(c%i==0) count+=1\n }\n println(count)\n }\n}", "problem_context": "How Many Divisors?\n\nWrite a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.\n\nInput\n\nThree integers a, b and c are given in a line separated by a single space.\n\nOutput\n\nPrint the number of divisors in a line.\n\nConstraints\n\n1 ≤ a, b, c ≤ 10000\n\na ≤ b\n\nSample Input 1\n\n5 14 80\n\nSample Output 1\n\n3", "sample_input": "5 14 80\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02398", "source_text": "How Many Divisors?\n\nWrite a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.\n\nInput\n\nThree integers a, b and c are given in a line separated by a single space.\n\nOutput\n\nPrint the number of divisors in a line.\n\nConstraints\n\n1 ≤ a, b, c ≤ 10000\n\na ≤ b\n\nSample Input 1\n\n5 14 80\n\nSample Output 1\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 207, "cpu_time_ms": 270, "memory_kb": 45136}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s209866780", "group_id": "codeNet:p02398", "input_text": "object Main{\n def main(args: Array[String]): Unit ={\n var in = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n println((in(0) to in(1)).filter(i => in(2) % i == 0).length)\n }\n}", "language": "Scala", "metadata": {"date": 1479975743, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02398.html", "problem_id": "p02398", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02398/input.txt", "sample_output_relpath": "derived/input_output/data/p02398/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02398/Scala/s209866780.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s209866780", "user_id": "u803981213"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main{\n def main(args: Array[String]): Unit ={\n var in = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n println((in(0) to in(1)).filter(i => in(2) % i == 0).length)\n }\n}", "problem_context": "How Many Divisors?\n\nWrite a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.\n\nInput\n\nThree integers a, b and c are given in a line separated by a single space.\n\nOutput\n\nPrint the number of divisors in a line.\n\nConstraints\n\n1 ≤ a, b, c ≤ 10000\n\na ≤ b\n\nSample Input 1\n\n5 14 80\n\nSample Output 1\n\n3", "sample_input": "5 14 80\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02398", "source_text": "How Many Divisors?\n\nWrite a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.\n\nInput\n\nThree integers a, b and c are given in a line separated by a single space.\n\nOutput\n\nPrint the number of divisors in a line.\n\nConstraints\n\n1 ≤ a, b, c ≤ 10000\n\na ≤ b\n\nSample Input 1\n\n5 14 80\n\nSample Output 1\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 270, "memory_kb": 43832}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s084374002", "group_id": "codeNet:p02398", "input_text": "object Main {\n def main(args : Array[String]) : Unit = {\n val input = io.StdIn.readLine().split(\" \").map(_.toInt)\n var count = 0\n for (i <- input(0) to input(1)) {\n if ((input(2) % i) == 0)\n count += 1\n }\n println(count)\n }\n}", "language": "Scala", "metadata": {"date": 1505608451, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02398.html", "problem_id": "p02398", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02398/input.txt", "sample_output_relpath": "derived/input_output/data/p02398/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02398/Scala/s084374002.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s084374002", "user_id": "u918841551"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main {\n def main(args : Array[String]) : Unit = {\n val input = io.StdIn.readLine().split(\" \").map(_.toInt)\n var count = 0\n for (i <- input(0) to input(1)) {\n if ((input(2) % i) == 0)\n count += 1\n }\n println(count)\n }\n}", "problem_context": "How Many Divisors?\n\nWrite a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.\n\nInput\n\nThree integers a, b and c are given in a line separated by a single space.\n\nOutput\n\nPrint the number of divisors in a line.\n\nConstraints\n\n1 ≤ a, b, c ≤ 10000\n\na ≤ b\n\nSample Input 1\n\n5 14 80\n\nSample Output 1\n\n3", "sample_input": "5 14 80\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02398", "source_text": "How Many Divisors?\n\nWrite a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.\n\nInput\n\nThree integers a, b and c are given in a line separated by a single space.\n\nOutput\n\nPrint the number of divisors in a line.\n\nConstraints\n\n1 ≤ a, b, c ≤ 10000\n\na ≤ b\n\nSample Input 1\n\n5 14 80\n\nSample Output 1\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 43896}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s907612769", "group_id": "codeNet:p02398", "input_text": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n\n val Array(a, b, c) = readLine().split(\" \").map { _.toInt }\n\n val n = (a to b).count { c % _ == 0 }\n println(n)\n}\n\n", "language": "Scala", "metadata": {"date": 1590164759, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02398.html", "problem_id": "p02398", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02398/input.txt", "sample_output_relpath": "derived/input_output/data/p02398/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02398/Scala/s907612769.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s907612769", "user_id": "u912124184"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n\n val Array(a, b, c) = readLine().split(\" \").map { _.toInt }\n\n val n = (a to b).count { c % _ == 0 }\n println(n)\n}\n\n", "problem_context": "How Many Divisors?\n\nWrite a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.\n\nInput\n\nThree integers a, b and c are given in a line separated by a single space.\n\nOutput\n\nPrint the number of divisors in a line.\n\nConstraints\n\n1 ≤ a, b, c ≤ 10000\n\na ≤ b\n\nSample Input 1\n\n5 14 80\n\nSample Output 1\n\n3", "sample_input": "5 14 80\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02398", "source_text": "How Many Divisors?\n\nWrite a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.\n\nInput\n\nThree integers a, b and c are given in a line separated by a single space.\n\nOutput\n\nPrint the number of divisors in a line.\n\nConstraints\n\n1 ≤ a, b, c ≤ 10000\n\na ≤ b\n\nSample Input 1\n\n5 14 80\n\nSample Output 1\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 310, "memory_kb": 44048}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s272148887", "group_id": "codeNet:p02399", "input_text": "object Main {\n def main(args: Array[String]) {\n val sc = new java.util.Scanner(System.in)\n val a, b = sc.nextInt\n val d:Int = a / b\n val r:Int = a % b\n val f:Double = a.toDouble / b\n println(\"%d %d %f\".format(d, r, f))\n\n }\n}", "language": "Scala", "metadata": {"date": 1454327691, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02399.html", "problem_id": "p02399", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02399/input.txt", "sample_output_relpath": "derived/input_output/data/p02399/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02399/Scala/s272148887.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s272148887", "user_id": "u859425877"}, "prompt_components": {"gold_output": "1 1 1.50000\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]) {\n val sc = new java.util.Scanner(System.in)\n val a, b = sc.nextInt\n val d:Int = a / b\n val r:Int = a % b\n val f:Double = a.toDouble / b\n println(\"%d %d %f\".format(d, r, f))\n\n }\n}", "problem_context": "A/B Problem\n\nWrite a program which reads two integers a and b, and calculates the following values:\n\na ÷ b: d (in integer)\n\nremainder of a ÷ b: r (in integer)\n\na ÷ b: f (in real number)\n\nInput\n\nTwo integers a and b are given in a line.\n\nOutput\n\nPrint d, r and f separated by a space in a line. For f, the output should not contain an absolute error greater than 10-5.\n\nConstraints\n\n1 ≤ a, b ≤ 109\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n1 1 1.50000", "sample_input": "3 2\n"}, "reference_outputs": ["1 1 1.50000\n"], "source_document_id": "p02399", "source_text": "A/B Problem\n\nWrite a program which reads two integers a and b, and calculates the following values:\n\na ÷ b: d (in integer)\n\nremainder of a ÷ b: r (in integer)\n\na ÷ b: f (in real number)\n\nInput\n\nTwo integers a and b are given in a line.\n\nOutput\n\nPrint d, r and f separated by a space in a line. For f, the output should not contain an absolute error greater than 10-5.\n\nConstraints\n\n1 ≤ a, b ≤ 109\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n1 1 1.50000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 250, "memory_kb": 45260}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s622342424", "group_id": "codeNet:p02399", "input_text": "object Main {\n def main(args:Array[String]){\n val sc=new java.util.Scanner(System.in)\n val a,b=sc.nextInt\n println(\"%d %d %.8f\".format(a/b,a%b,a/b.toDouble))\n }\n}", "language": "Scala", "metadata": {"date": 1471526494, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02399.html", "problem_id": "p02399", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02399/input.txt", "sample_output_relpath": "derived/input_output/data/p02399/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02399/Scala/s622342424.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s622342424", "user_id": "u496100636"}, "prompt_components": {"gold_output": "1 1 1.50000\n", "input_to_evaluate": "object Main {\n def main(args:Array[String]){\n val sc=new java.util.Scanner(System.in)\n val a,b=sc.nextInt\n println(\"%d %d %.8f\".format(a/b,a%b,a/b.toDouble))\n }\n}", "problem_context": "A/B Problem\n\nWrite a program which reads two integers a and b, and calculates the following values:\n\na ÷ b: d (in integer)\n\nremainder of a ÷ b: r (in integer)\n\na ÷ b: f (in real number)\n\nInput\n\nTwo integers a and b are given in a line.\n\nOutput\n\nPrint d, r and f separated by a space in a line. For f, the output should not contain an absolute error greater than 10-5.\n\nConstraints\n\n1 ≤ a, b ≤ 109\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n1 1 1.50000", "sample_input": "3 2\n"}, "reference_outputs": ["1 1 1.50000\n"], "source_document_id": "p02399", "source_text": "A/B Problem\n\nWrite a program which reads two integers a and b, and calculates the following values:\n\na ÷ b: d (in integer)\n\nremainder of a ÷ b: r (in integer)\n\na ÷ b: f (in real number)\n\nInput\n\nTwo integers a and b are given in a line.\n\nOutput\n\nPrint d, r and f separated by a space in a line. For f, the output should not contain an absolute error greater than 10-5.\n\nConstraints\n\n1 ≤ a, b ≤ 109\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n1 1 1.50000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 290, "memory_kb": 45184}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s531329163", "group_id": "codeNet:p02399", "input_text": "\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val a, b = sc.nextInt\n println((a / b) + \" \" + (a % b) + \" \" + (a * 1.0 / b))\n }\n}", "language": "Scala", "metadata": {"date": 1489213927, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02399.html", "problem_id": "p02399", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02399/input.txt", "sample_output_relpath": "derived/input_output/data/p02399/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02399/Scala/s531329163.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s531329163", "user_id": "u119127920"}, "prompt_components": {"gold_output": "1 1 1.50000\n", "input_to_evaluate": "\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val a, b = sc.nextInt\n println((a / b) + \" \" + (a % b) + \" \" + (a * 1.0 / b))\n }\n}", "problem_context": "A/B Problem\n\nWrite a program which reads two integers a and b, and calculates the following values:\n\na ÷ b: d (in integer)\n\nremainder of a ÷ b: r (in integer)\n\na ÷ b: f (in real number)\n\nInput\n\nTwo integers a and b are given in a line.\n\nOutput\n\nPrint d, r and f separated by a space in a line. For f, the output should not contain an absolute error greater than 10-5.\n\nConstraints\n\n1 ≤ a, b ≤ 109\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n1 1 1.50000", "sample_input": "3 2\n"}, "reference_outputs": ["1 1 1.50000\n"], "source_document_id": "p02399", "source_text": "A/B Problem\n\nWrite a program which reads two integers a and b, and calculates the following values:\n\na ÷ b: d (in integer)\n\nremainder of a ÷ b: r (in integer)\n\na ÷ b: f (in real number)\n\nInput\n\nTwo integers a and b are given in a line.\n\nOutput\n\nPrint d, r and f separated by a space in a line. For f, the output should not contain an absolute error greater than 10-5.\n\nConstraints\n\n1 ≤ a, b ≤ 109\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n1 1 1.50000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 193, "cpu_time_ms": 250, "memory_kb": 45048}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s977274480", "group_id": "codeNet:p02399", "input_text": "import scala.io.StdIn\n\nobject Main{\n def main(args: Array[String]){\n val list = StdIn.readLine.split(\" \").toList.map(_.toInt)\n\n printf(\"%d %d %10.8f\\n\", list(0) / list(1), list(0) % list(1), list(0).toDouble / list(1).toDouble)\n }\n}", "language": "Scala", "metadata": {"date": 1497601911, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02399.html", "problem_id": "p02399", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02399/input.txt", "sample_output_relpath": "derived/input_output/data/p02399/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02399/Scala/s977274480.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s977274480", "user_id": "u085441951"}, "prompt_components": {"gold_output": "1 1 1.50000\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main{\n def main(args: Array[String]){\n val list = StdIn.readLine.split(\" \").toList.map(_.toInt)\n\n printf(\"%d %d %10.8f\\n\", list(0) / list(1), list(0) % list(1), list(0).toDouble / list(1).toDouble)\n }\n}", "problem_context": "A/B Problem\n\nWrite a program which reads two integers a and b, and calculates the following values:\n\na ÷ b: d (in integer)\n\nremainder of a ÷ b: r (in integer)\n\na ÷ b: f (in real number)\n\nInput\n\nTwo integers a and b are given in a line.\n\nOutput\n\nPrint d, r and f separated by a space in a line. For f, the output should not contain an absolute error greater than 10-5.\n\nConstraints\n\n1 ≤ a, b ≤ 109\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n1 1 1.50000", "sample_input": "3 2\n"}, "reference_outputs": ["1 1 1.50000\n"], "source_document_id": "p02399", "source_text": "A/B Problem\n\nWrite a program which reads two integers a and b, and calculates the following values:\n\na ÷ b: d (in integer)\n\nremainder of a ÷ b: r (in integer)\n\na ÷ b: f (in real number)\n\nInput\n\nTwo integers a and b are given in a line.\n\nOutput\n\nPrint d, r and f separated by a space in a line. For f, the output should not contain an absolute error greater than 10-5.\n\nConstraints\n\n1 ≤ a, b ≤ 109\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n1 1 1.50000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 43972}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s884828727", "group_id": "codeNet:p02399", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n \n val a = StdIn.readLine().trim.split(' ').map(_.toInt)\n val d: Int = a(0)/a(1)\n val r: Int = a(0)/a(1)\n val f: Double = a(0).toDouble/a(1).toDouble\n \n print(d + \" \" + r + \" \" + f\"$f%.5f\")\n\n}\n\n", "language": "Scala", "metadata": {"date": 1523776411, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02399.html", "problem_id": "p02399", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02399/input.txt", "sample_output_relpath": "derived/input_output/data/p02399/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02399/Scala/s884828727.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s884828727", "user_id": "u342234782"}, "prompt_components": {"gold_output": "1 1 1.50000\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n \n val a = StdIn.readLine().trim.split(' ').map(_.toInt)\n val d: Int = a(0)/a(1)\n val r: Int = a(0)/a(1)\n val f: Double = a(0).toDouble/a(1).toDouble\n \n print(d + \" \" + r + \" \" + f\"$f%.5f\")\n\n}\n\n", "problem_context": "A/B Problem\n\nWrite a program which reads two integers a and b, and calculates the following values:\n\na ÷ b: d (in integer)\n\nremainder of a ÷ b: r (in integer)\n\na ÷ b: f (in real number)\n\nInput\n\nTwo integers a and b are given in a line.\n\nOutput\n\nPrint d, r and f separated by a space in a line. For f, the output should not contain an absolute error greater than 10-5.\n\nConstraints\n\n1 ≤ a, b ≤ 109\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n1 1 1.50000", "sample_input": "3 2\n"}, "reference_outputs": ["1 1 1.50000\n"], "source_document_id": "p02399", "source_text": "A/B Problem\n\nWrite a program which reads two integers a and b, and calculates the following values:\n\na ÷ b: d (in integer)\n\nremainder of a ÷ b: r (in integer)\n\na ÷ b: f (in real number)\n\nInput\n\nTwo integers a and b are given in a line.\n\nOutput\n\nPrint d, r and f separated by a space in a line. For f, the output should not contain an absolute error greater than 10-5.\n\nConstraints\n\n1 ≤ a, b ≤ 109\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n1 1 1.50000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 250, "cpu_time_ms": 220, "memory_kb": 44116}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s944974574", "group_id": "codeNet:p02400", "input_text": "import scala.io.StdIn.readDouble\nimport scala.math.Pi\n\nobject Main {\n\n def main(args: Array[String]) = {\n val r = readDouble()\n println(\"%.6f\".format(r*r*Pi) + \" \" + \"%.6f\".format(2*r*Pi))\n }\n}", "language": "Scala", "metadata": {"date": 1479264364, "filename_ext": "scala", "original_language": "Scala", "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/Scala/s944974574.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s944974574", "user_id": "u508732591"}, "prompt_components": {"gold_output": "12.566371 12.566371\n", "input_to_evaluate": "import scala.io.StdIn.readDouble\nimport scala.math.Pi\n\nobject Main {\n\n def main(args: Array[String]) = {\n val r = readDouble()\n println(\"%.6f\".format(r*r*Pi) + \" \" + \"%.6f\".format(2*r*Pi))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 205, "cpu_time_ms": 240, "memory_kb": 43912}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s698752911", "group_id": "codeNet:p02400", "input_text": "import scala.io.StdIn.readLine\nimport scala.math.Pi\n\nobject Main {\n\tdef main(args: Array[String]) = {\n\t\tval r = io.StdIn.readLine.split(\" \").map(_.toDouble)\n\t\tprintf(\"%.6f %.6f\\n\", r(0)*r(0)*math.Pi, 2*r(0)*math.Pi)\n\t}\n}", "language": "Scala", "metadata": {"date": 1484533783, "filename_ext": "scala", "original_language": "Scala", "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/Scala/s698752911.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s698752911", "user_id": "u996485583"}, "prompt_components": {"gold_output": "12.566371 12.566371\n", "input_to_evaluate": "import scala.io.StdIn.readLine\nimport scala.math.Pi\n\nobject Main {\n\tdef main(args: Array[String]) = {\n\t\tval r = io.StdIn.readLine.split(\" \").map(_.toDouble)\n\t\tprintf(\"%.6f %.6f\\n\", r(0)*r(0)*math.Pi, 2*r(0)*math.Pi)\n\t}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43824}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s080701314", "group_id": "codeNet:p02401", "input_text": "import scala.io.Source\n\nobject Main{\n def main(args: Array[String]){\n var list = List[String]()\n for(in <- Source.stdin.getLines.toList){\n list = in :: list\n }\n\n for(i <- 0 until list.length){\n if(list(list.length - i - 1).size > 4){\n val arr = list(list.length - i - 1).split(Array(' '))\n\n arr(1) match {\n case \"+\" => println(arr(0).toInt + arr(2).toInt)\n case \"-\" => println(arr(0).toInt - arr(2).toInt)\n case \"*\" => println(arr(0).toInt * arr(2).toInt)\n case \"/\" => println(arr(0).toInt / arr(2).toInt)\n case \"?\" =>\n }\n }\n }\n }\n}", "language": "Scala", "metadata": {"date": 1435907425, "filename_ext": "scala", "original_language": "Scala", "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/Scala/s080701314.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s080701314", "user_id": "u085441951"}, "prompt_components": {"gold_output": "3\n38\n26\n10\n108\n", "input_to_evaluate": "import scala.io.Source\n\nobject Main{\n def main(args: Array[String]){\n var list = List[String]()\n for(in <- Source.stdin.getLines.toList){\n list = in :: list\n }\n\n for(i <- 0 until list.length){\n if(list(list.length - i - 1).size > 4){\n val arr = list(list.length - i - 1).split(Array(' '))\n\n arr(1) match {\n case \"+\" => println(arr(0).toInt + arr(2).toInt)\n case \"-\" => println(arr(0).toInt - arr(2).toInt)\n case \"*\" => println(arr(0).toInt * arr(2).toInt)\n case \"/\" => println(arr(0).toInt / arr(2).toInt)\n case \"?\" =>\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 44008}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s124087280", "group_id": "codeNet:p02401", "input_text": "import scala.io.Source\n\nobject Main extends App{\n Source.stdin.getLines.toList.init\n .map(_.split(\" \"))\n .map(x => (x(0).toInt,x(1),x(2).toInt))\n .map(x => (if(x._2 == \"+\") x._1+x._3 else if(x._2 == \"-\") x._1-x._3 else if(x._2 == \"*\") x._1*x._3 else if(x._2 == \"/\") x._1/x._3))\n .map(println)\n}", "language": "Scala", "metadata": {"date": 1440264104, "filename_ext": "scala", "original_language": "Scala", "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/Scala/s124087280.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s124087280", "user_id": "u121003333"}, "prompt_components": {"gold_output": "3\n38\n26\n10\n108\n", "input_to_evaluate": "import scala.io.Source\n\nobject Main extends App{\n Source.stdin.getLines.toList.init\n .map(_.split(\" \"))\n .map(x => (x(0).toInt,x(1),x(2).toInt))\n .map(x => (if(x._2 == \"+\") x._1+x._3 else if(x._2 == \"-\") x._1-x._3 else if(x._2 == \"*\") x._1*x._3 else if(x._2 == \"/\") x._1/x._3))\n .map(println)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 307, "cpu_time_ms": 230, "memory_kb": 44152}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s196474053", "group_id": "codeNet:p02402", "input_text": "object Main extends App {\n val n = scala.io.StdIn.readLine.toInt\n val a = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n println(s\"${a.min} ${a.max} ${a.sum}\")\n}", "language": "Scala", "metadata": {"date": 1440232258, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02402.html", "problem_id": "p02402", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02402/input.txt", "sample_output_relpath": "derived/input_output/data/p02402/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02402/Scala/s196474053.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s196474053", "user_id": "u490032117"}, "prompt_components": {"gold_output": "1 17 37\n", "input_to_evaluate": "object Main extends App {\n val n = scala.io.StdIn.readLine.toInt\n val a = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n println(s\"${a.min} ${a.max} ${a.sum}\")\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMin, Max and Sum\n\nWrite a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.\n\nInput\n\nIn the first line, an integer $n$ is given. In the next line, $n$ integers $a_i$ are given in a line.\n\nOutput\n\nPrint the minimum value, maximum value and sum in a line. Put a single space between the values.\n\nConstraints\n\n$0 < n \\leq 10000$\n\n$-1000000 \\leq a_i \\leq 1000000$\n\nSample Input\n\n5\n10 1 5 4 17\n\nSample Output\n\n1 17 37", "sample_input": "5\n10 1 5 4 17\n"}, "reference_outputs": ["1 17 37\n"], "source_document_id": "p02402", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMin, Max and Sum\n\nWrite a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.\n\nInput\n\nIn the first line, an integer $n$ is given. In the next line, $n$ integers $a_i$ are given in a line.\n\nOutput\n\nPrint the minimum value, maximum value and sum in a line. Put a single space between the values.\n\nConstraints\n\n$0 < n \\leq 10000$\n\n$-1000000 \\leq a_i \\leq 1000000$\n\nSample Input\n\n5\n10 1 5 4 17\n\nSample Output\n\n1 17 37", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 300, "memory_kb": 49232}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s414013997", "group_id": "codeNet:p02402", "input_text": "import scala.io.StdIn.{readLine,readInt}\n\nobject Main {\n\n def main(args: Array[String]) = {\n val n = readInt\n val (min,max,sum) = readLine.split(\" \")\n .map(_.toInt)\n .foldLeft(Int.MaxValue,Int.MinValue,0){ case ((min,max,sum),x)=>(Math.min(min,x),Math.max(max,x),sum+x) }\n printf(\"%d %d %d\\n\",min,max,sum)\n }\n}", "language": "Scala", "metadata": {"date": 1479804645, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02402.html", "problem_id": "p02402", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02402/input.txt", "sample_output_relpath": "derived/input_output/data/p02402/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02402/Scala/s414013997.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s414013997", "user_id": "u508732591"}, "prompt_components": {"gold_output": "1 17 37\n", "input_to_evaluate": "import scala.io.StdIn.{readLine,readInt}\n\nobject Main {\n\n def main(args: Array[String]) = {\n val n = readInt\n val (min,max,sum) = readLine.split(\" \")\n .map(_.toInt)\n .foldLeft(Int.MaxValue,Int.MinValue,0){ case ((min,max,sum),x)=>(Math.min(min,x),Math.max(max,x),sum+x) }\n printf(\"%d %d %d\\n\",min,max,sum)\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMin, Max and Sum\n\nWrite a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.\n\nInput\n\nIn the first line, an integer $n$ is given. In the next line, $n$ integers $a_i$ are given in a line.\n\nOutput\n\nPrint the minimum value, maximum value and sum in a line. Put a single space between the values.\n\nConstraints\n\n$0 < n \\leq 10000$\n\n$-1000000 \\leq a_i \\leq 1000000$\n\nSample Input\n\n5\n10 1 5 4 17\n\nSample Output\n\n1 17 37", "sample_input": "5\n10 1 5 4 17\n"}, "reference_outputs": ["1 17 37\n"], "source_document_id": "p02402", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMin, Max and Sum\n\nWrite a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.\n\nInput\n\nIn the first line, an integer $n$ is given. In the next line, $n$ integers $a_i$ are given in a line.\n\nOutput\n\nPrint the minimum value, maximum value and sum in a line. Put a single space between the values.\n\nConstraints\n\n$0 < n \\leq 10000$\n\n$-1000000 \\leq a_i \\leq 1000000$\n\nSample Input\n\n5\n10 1 5 4 17\n\nSample Output\n\n1 17 37", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 383, "cpu_time_ms": 300, "memory_kb": 49684}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s205563192", "group_id": "codeNet:p02402", "input_text": "import scala.io.StdIn.{readLine,readInt}\n\nobject Main {\n\n def main(args: Array[String]) = {\n val n = readInt\n val l = readLine.split(\" \").map(_.toInt)\n printf(\"%d %d %d\\n\",l.min,l.max,l.foldLeft(0.toLong)(_+_))\n }\n}", "language": "Scala", "metadata": {"date": 1479805905, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02402.html", "problem_id": "p02402", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02402/input.txt", "sample_output_relpath": "derived/input_output/data/p02402/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02402/Scala/s205563192.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s205563192", "user_id": "u508732591"}, "prompt_components": {"gold_output": "1 17 37\n", "input_to_evaluate": "import scala.io.StdIn.{readLine,readInt}\n\nobject Main {\n\n def main(args: Array[String]) = {\n val n = readInt\n val l = readLine.split(\" \").map(_.toInt)\n printf(\"%d %d %d\\n\",l.min,l.max,l.foldLeft(0.toLong)(_+_))\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMin, Max and Sum\n\nWrite a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.\n\nInput\n\nIn the first line, an integer $n$ is given. In the next line, $n$ integers $a_i$ are given in a line.\n\nOutput\n\nPrint the minimum value, maximum value and sum in a line. Put a single space between the values.\n\nConstraints\n\n$0 < n \\leq 10000$\n\n$-1000000 \\leq a_i \\leq 1000000$\n\nSample Input\n\n5\n10 1 5 4 17\n\nSample Output\n\n1 17 37", "sample_input": "5\n10 1 5 4 17\n"}, "reference_outputs": ["1 17 37\n"], "source_document_id": "p02402", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMin, Max and Sum\n\nWrite a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.\n\nInput\n\nIn the first line, an integer $n$ is given. In the next line, $n$ integers $a_i$ are given in a line.\n\nOutput\n\nPrint the minimum value, maximum value and sum in a line. Put a single space between the values.\n\nConstraints\n\n$0 < n \\leq 10000$\n\n$-1000000 \\leq a_i \\leq 1000000$\n\nSample Input\n\n5\n10 1 5 4 17\n\nSample Output\n\n1 17 37", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 226, "cpu_time_ms": 300, "memory_kb": 49540}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s347841798", "group_id": "codeNet:p02402", "input_text": "object Main {\n\n def main(args: Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val a = Array.fill(n)(sc.nextLong).sorted\n\n println(a.head + \" \" + a.last + \" \" + a.foldLeft(0L){ (acc, x) => acc+x })\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1544104696, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02402.html", "problem_id": "p02402", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02402/input.txt", "sample_output_relpath": "derived/input_output/data/p02402/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02402/Scala/s347841798.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s347841798", "user_id": "u634490486"}, "prompt_components": {"gold_output": "1 17 37\n", "input_to_evaluate": "object Main {\n\n def main(args: Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val a = Array.fill(n)(sc.nextLong).sorted\n\n println(a.head + \" \" + a.last + \" \" + a.foldLeft(0L){ (acc, x) => acc+x })\n }\n}\n\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMin, Max and Sum\n\nWrite a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.\n\nInput\n\nIn the first line, an integer $n$ is given. In the next line, $n$ integers $a_i$ are given in a line.\n\nOutput\n\nPrint the minimum value, maximum value and sum in a line. Put a single space between the values.\n\nConstraints\n\n$0 < n \\leq 10000$\n\n$-1000000 \\leq a_i \\leq 1000000$\n\nSample Input\n\n5\n10 1 5 4 17\n\nSample Output\n\n1 17 37", "sample_input": "5\n10 1 5 4 17\n"}, "reference_outputs": ["1 17 37\n"], "source_document_id": "p02402", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMin, Max and Sum\n\nWrite a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.\n\nInput\n\nIn the first line, an integer $n$ is given. In the next line, $n$ integers $a_i$ are given in a line.\n\nOutput\n\nPrint the minimum value, maximum value and sum in a line. Put a single space between the values.\n\nConstraints\n\n$0 < n \\leq 10000$\n\n$-1000000 \\leq a_i \\leq 1000000$\n\nSample Input\n\n5\n10 1 5 4 17\n\nSample Output\n\n1 17 37", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 400, "memory_kb": 61052}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s111938476", "group_id": "codeNet:p02403", "input_text": "import scala.io.StdIn\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val inputs = Iterator.continually(StdIn.readLine()).takeWhile(_ != null)\n for{\n in <- inputs\n val Array(h, w, _*) = in.split(\" \").map(_.toInt)\n }{\n if(h != 0 && w != 0){\n for{i <- 0 until h; j <- 0 until h}{\n print(\"#\")\n if(j == h-1)println()\n }\n println()\n }\n }\n }\n}", "language": "Scala", "metadata": {"date": 1436138847, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02403.html", "problem_id": "p02403", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02403/input.txt", "sample_output_relpath": "derived/input_output/data/p02403/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02403/Scala/s111938476.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s111938476", "user_id": "u389172382"}, "prompt_components": {"gold_output": "####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val inputs = Iterator.continually(StdIn.readLine()).takeWhile(_ != null)\n for{\n in <- inputs\n val Array(h, w, _*) = in.split(\" \").map(_.toInt)\n }{\n if(h != 0 && w != 0){\n for{i <- 0 until h; j <- 0 until h}{\n print(\"#\")\n if(j == h-1)println()\n }\n println()\n }\n }\n }\n}", "problem_context": "Print a Rectangle\n\nDraw a rectangle which has a height of H cm and a width of W cm. Draw a 1-cm square by single '#'.\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 rectangle made of H × W '#'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n1 ≤ H ≤ 300\n\n1 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n2 2\n0 0\n\nSample Output\n\n####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##", "sample_input": "3 4\n5 6\n2 2\n0 0\n"}, "reference_outputs": ["####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##\n"], "source_document_id": "p02403", "source_text": "Print a Rectangle\n\nDraw a rectangle which has a height of H cm and a width of W cm. Draw a 1-cm square by single '#'.\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 rectangle made of H × W '#'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n1 ≤ H ≤ 300\n\n1 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n2 2\n0 0\n\nSample Output\n\n####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 44228}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s756172945", "group_id": "codeNet:p02403", "input_text": "\nobject Main {\n def main(args: Array[String]): Unit = {\n val in = new java.util.Scanner(System.in)\n rec(in)\n }\n def rec(in:java.util.Scanner):Unit ={\n val a = in.nextInt\n val b = in.nextInt\n if(a ==0 && b == 0) return\n for(i <- 1 to a){\n for(j <- 1 to b){\n print(\"#\")\n }\n println(\"\")\n }\n println(\"\")\n return rec(in)\n }\n}", "language": "Scala", "metadata": {"date": 1458098429, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02403.html", "problem_id": "p02403", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02403/input.txt", "sample_output_relpath": "derived/input_output/data/p02403/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02403/Scala/s756172945.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s756172945", "user_id": "u892831253"}, "prompt_components": {"gold_output": "####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##\n", "input_to_evaluate": "\nobject Main {\n def main(args: Array[String]): Unit = {\n val in = new java.util.Scanner(System.in)\n rec(in)\n }\n def rec(in:java.util.Scanner):Unit ={\n val a = in.nextInt\n val b = in.nextInt\n if(a ==0 && b == 0) return\n for(i <- 1 to a){\n for(j <- 1 to b){\n print(\"#\")\n }\n println(\"\")\n }\n println(\"\")\n return rec(in)\n }\n}", "problem_context": "Print a Rectangle\n\nDraw a rectangle which has a height of H cm and a width of W cm. Draw a 1-cm square by single '#'.\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 rectangle made of H × W '#'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n1 ≤ H ≤ 300\n\n1 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n2 2\n0 0\n\nSample Output\n\n####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##", "sample_input": "3 4\n5 6\n2 2\n0 0\n"}, "reference_outputs": ["####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##\n"], "source_document_id": "p02403", "source_text": "Print a Rectangle\n\nDraw a rectangle which has a height of H cm and a width of W cm. Draw a 1-cm square by single '#'.\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 rectangle made of H × W '#'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n1 ≤ H ≤ 300\n\n1 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n2 2\n0 0\n\nSample Output\n\n####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 430, "memory_kb": 53140}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s371495558", "group_id": "codeNet:p02403", "input_text": "object Main {\n def main(args:Array[String]){\n val sc=new java.util.Scanner(System.in)\n var tmp=false \n while(true){\n val h,w=sc.nextInt\n if(tmp) println()\n if(h==0&&w==0) return\n for(i<-1 to h;j<-1 to w){\n if(j==w){\n println(\"#\")\n }\n else print(\"#\")\n }\n tmp=true\n }\n }\n}", "language": "Scala", "metadata": {"date": 1471602708, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02403.html", "problem_id": "p02403", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02403/input.txt", "sample_output_relpath": "derived/input_output/data/p02403/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02403/Scala/s371495558.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s371495558", "user_id": "u496100636"}, "prompt_components": {"gold_output": "####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##\n", "input_to_evaluate": "object Main {\n def main(args:Array[String]){\n val sc=new java.util.Scanner(System.in)\n var tmp=false \n while(true){\n val h,w=sc.nextInt\n if(tmp) println()\n if(h==0&&w==0) return\n for(i<-1 to h;j<-1 to w){\n if(j==w){\n println(\"#\")\n }\n else print(\"#\")\n }\n tmp=true\n }\n }\n}", "problem_context": "Print a Rectangle\n\nDraw a rectangle which has a height of H cm and a width of W cm. Draw a 1-cm square by single '#'.\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 rectangle made of H × W '#'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n1 ≤ H ≤ 300\n\n1 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n2 2\n0 0\n\nSample Output\n\n####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##", "sample_input": "3 4\n5 6\n2 2\n0 0\n"}, "reference_outputs": ["####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##\n"], "source_document_id": "p02403", "source_text": "Print a Rectangle\n\nDraw a rectangle which has a height of H cm and a width of W cm. Draw a 1-cm square by single '#'.\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 rectangle made of H × W '#'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n1 ≤ H ≤ 300\n\n1 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n2 2\n0 0\n\nSample Output\n\n####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 500, "memory_kb": 52384}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s419151616", "group_id": "codeNet:p02403", "input_text": "import scala.collection.mutable.ListBuffer\nimport scala.io.StdIn\n\nobject Main extends App {\n\n var temp = Array(-1, -1)\n val buff = new ListBuffer[(Int, Int)]\n while(temp(0) != 0 && temp(1) != 0){\n temp = StdIn.readLine().split(' ').map(_.toInt)\n buff += ((temp(0), temp(1)))\n }\n\n val result = buff.dropRight(1).map { case (h, w) =>\n (0 until h).map { _ =>\n Array.fill(w)(\"#\").mkString(\"\")\n }.mkString(f\"%n\")\n }\n print(result.mkString(f\"%n\"))\n}\n", "language": "Scala", "metadata": {"date": 1523832818, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02403.html", "problem_id": "p02403", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02403/input.txt", "sample_output_relpath": "derived/input_output/data/p02403/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02403/Scala/s419151616.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s419151616", "user_id": "u342234782"}, "prompt_components": {"gold_output": "####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##\n", "input_to_evaluate": "import scala.collection.mutable.ListBuffer\nimport scala.io.StdIn\n\nobject Main extends App {\n\n var temp = Array(-1, -1)\n val buff = new ListBuffer[(Int, Int)]\n while(temp(0) != 0 && temp(1) != 0){\n temp = StdIn.readLine().split(' ').map(_.toInt)\n buff += ((temp(0), temp(1)))\n }\n\n val result = buff.dropRight(1).map { case (h, w) =>\n (0 until h).map { _ =>\n Array.fill(w)(\"#\").mkString(\"\")\n }.mkString(f\"%n\")\n }\n print(result.mkString(f\"%n\"))\n}\n", "problem_context": "Print a Rectangle\n\nDraw a rectangle which has a height of H cm and a width of W cm. Draw a 1-cm square by single '#'.\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 rectangle made of H × W '#'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n1 ≤ H ≤ 300\n\n1 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n2 2\n0 0\n\nSample Output\n\n####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##", "sample_input": "3 4\n5 6\n2 2\n0 0\n"}, "reference_outputs": ["####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##\n"], "source_document_id": "p02403", "source_text": "Print a Rectangle\n\nDraw a rectangle which has a height of H cm and a width of W cm. Draw a 1-cm square by single '#'.\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 rectangle made of H × W '#'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n1 ≤ H ≤ 300\n\n1 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n2 2\n0 0\n\nSample Output\n\n####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 44072}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s548789244", "group_id": "codeNet:p02404", "input_text": "object Main extends App {\n import scala.annotation.tailrec\n\n val sc = new java.util.Scanner(System.in)\n val pw = new java.io.PrintWriter(System.out)\n @tailrec\n def output(h: Int = sc.nextInt, w: Int = sc.nextInt): Unit = {\n if( h != 0 && w != 0 ) {\n pw.println(\"#\"*w)\n for(i <- 1 to h-2) pw.println(\"#\"+\".\"*(w-2)+\"#\")\n pw.println(\"#\"*w)\n pw.println()\n output()\n }\n }\n\n output()\n pw.flush\n}\n", "language": "Scala", "metadata": {"date": 1547894664, "filename_ext": "scala", "original_language": "Scala", "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/Scala/s548789244.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s548789244", "user_id": "u634490486"}, "prompt_components": {"gold_output": "####\n#..#\n####\n\n######\n#....#\n#....#\n#....#\n######\n\n###\n#.#\n###\n", "input_to_evaluate": "object Main extends App {\n import scala.annotation.tailrec\n\n val sc = new java.util.Scanner(System.in)\n val pw = new java.io.PrintWriter(System.out)\n @tailrec\n def output(h: Int = sc.nextInt, w: Int = sc.nextInt): Unit = {\n if( h != 0 && w != 0 ) {\n pw.println(\"#\"*w)\n for(i <- 1 to h-2) pw.println(\"#\"+\".\"*(w-2)+\"#\")\n pw.println(\"#\"*w)\n pw.println()\n output()\n }\n }\n\n output()\n pw.flush\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 483, "cpu_time_ms": 250, "memory_kb": 46268}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s935565943", "group_id": "codeNet:p02405", "input_text": "import scala.io.Source\n\nobject Main {\n def main(args:Array[String]) {\n \n for(line <- Source.stdin.getLines()) {\n val items = line.split(\" \").toList.map(_.toInt)\n if (items(0) == 0 && items(1) == 0) {\n return \n }\n \n for (hIndex <- (1 to items(0))) {\n val w = (1 to items(1)).toList.map{ wIndex => \n if ((hIndex % 2 == 0 && wIndex % 2 != 0) || (hIndex % 2 != 0 && wIndex % 2 == 0)) \".\" \n else \"#\"\n }\n println(w.mkString)\n }\n }\n }\n}", "language": "Scala", "metadata": {"date": 1449740993, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02405.html", "problem_id": "p02405", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02405/input.txt", "sample_output_relpath": "derived/input_output/data/p02405/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02405/Scala/s935565943.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s935565943", "user_id": "u231083279"}, "prompt_components": {"gold_output": "#.#.\n.#.#\n#.#.\n\n#.#.#.\n.#.#.#\n#.#.#.\n.#.#.#\n#.#.#.\n\n#.#\n.#.\n#.#\n\n#.\n.#\n\n#\n", "input_to_evaluate": "import scala.io.Source\n\nobject Main {\n def main(args:Array[String]) {\n \n for(line <- Source.stdin.getLines()) {\n val items = line.split(\" \").toList.map(_.toInt)\n if (items(0) == 0 && items(1) == 0) {\n return \n }\n \n for (hIndex <- (1 to items(0))) {\n val w = (1 to items(1)).toList.map{ wIndex => \n if ((hIndex % 2 == 0 && wIndex % 2 != 0) || (hIndex % 2 != 0 && wIndex % 2 == 0)) \".\" \n else \"#\"\n }\n println(w.mkString)\n }\n }\n }\n}", "problem_context": "Print a Chessboard\n\nDraw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm.\n\n#.#.#.#.#.\n.#.#.#.#.#\n#.#.#.#.#.\n.#.#.#.#.#\n#.#.#.#.#.\n.#.#.#.#.#\n\nNote that the top left corner should be drawn by '#'.\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 chessboard made of '#' and '.'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n1 ≤ H ≤ 300\n\n1 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n3 3\n2 2\n1 1\n0 0\n\nSample Output\n\n#.#.\n.#.#\n#.#.\n\n#.#.#.\n.#.#.#\n#.#.#.\n.#.#.#\n#.#.#.\n\n#.#\n.#.\n#.#\n\n#.\n.#\n\n#", "sample_input": "3 4\n5 6\n3 3\n2 2\n1 1\n0 0\n"}, "reference_outputs": ["#.#.\n.#.#\n#.#.\n\n#.#.#.\n.#.#.#\n#.#.#.\n.#.#.#\n#.#.#.\n\n#.#\n.#.\n#.#\n\n#.\n.#\n\n#\n"], "source_document_id": "p02405", "source_text": "Print a Chessboard\n\nDraw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm.\n\n#.#.#.#.#.\n.#.#.#.#.#\n#.#.#.#.#.\n.#.#.#.#.#\n#.#.#.#.#.\n.#.#.#.#.#\n\nNote that the top left corner should be drawn by '#'.\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 chessboard made of '#' and '.'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n1 ≤ H ≤ 300\n\n1 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n3 3\n2 2\n1 1\n0 0\n\nSample Output\n\n#.#.\n.#.#\n#.#.\n\n#.#.#.\n.#.#.#\n#.#.#.\n.#.#.#\n#.#.#.\n\n#.#\n.#.\n#.#\n\n#.\n.#\n\n#", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 521, "cpu_time_ms": 220, "memory_kb": 43676}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s629182327", "group_id": "codeNet:p02405", "input_text": "import scala.io.StdIn.readLine\n\nobject Main {\n\n def main(args: Array[String]) = {\n\n var n = readLine.split(\" \").map(_.toInt)\n while( n(0) != 0 || n(1) != 0) {\n val h = n(0)\n val w = n(1)\n\n for(i <- 0 to h-1) {\n val str = if(i%2==0) \"#.\"*w else \".#\"*w\n println(str.take(w))\n }\n println()\n n = readLine.split(\" \").map(_.toInt)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1480559954, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02405.html", "problem_id": "p02405", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02405/input.txt", "sample_output_relpath": "derived/input_output/data/p02405/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02405/Scala/s629182327.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s629182327", "user_id": "u508732591"}, "prompt_components": {"gold_output": "#.#.\n.#.#\n#.#.\n\n#.#.#.\n.#.#.#\n#.#.#.\n.#.#.#\n#.#.#.\n\n#.#\n.#.\n#.#\n\n#.\n.#\n\n#\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main {\n\n def main(args: Array[String]) = {\n\n var n = readLine.split(\" \").map(_.toInt)\n while( n(0) != 0 || n(1) != 0) {\n val h = n(0)\n val w = n(1)\n\n for(i <- 0 to h-1) {\n val str = if(i%2==0) \"#.\"*w else \".#\"*w\n println(str.take(w))\n }\n println()\n n = readLine.split(\" \").map(_.toInt)\n }\n }\n}", "problem_context": "Print a Chessboard\n\nDraw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm.\n\n#.#.#.#.#.\n.#.#.#.#.#\n#.#.#.#.#.\n.#.#.#.#.#\n#.#.#.#.#.\n.#.#.#.#.#\n\nNote that the top left corner should be drawn by '#'.\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 chessboard made of '#' and '.'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n1 ≤ H ≤ 300\n\n1 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n3 3\n2 2\n1 1\n0 0\n\nSample Output\n\n#.#.\n.#.#\n#.#.\n\n#.#.#.\n.#.#.#\n#.#.#.\n.#.#.#\n#.#.#.\n\n#.#\n.#.\n#.#\n\n#.\n.#\n\n#", "sample_input": "3 4\n5 6\n3 3\n2 2\n1 1\n0 0\n"}, "reference_outputs": ["#.#.\n.#.#\n#.#.\n\n#.#.#.\n.#.#.#\n#.#.#.\n.#.#.#\n#.#.#.\n\n#.#\n.#.\n#.#\n\n#.\n.#\n\n#\n"], "source_document_id": "p02405", "source_text": "Print a Chessboard\n\nDraw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm.\n\n#.#.#.#.#.\n.#.#.#.#.#\n#.#.#.#.#.\n.#.#.#.#.#\n#.#.#.#.#.\n.#.#.#.#.#\n\nNote that the top left corner should be drawn by '#'.\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 chessboard made of '#' and '.'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n1 ≤ H ≤ 300\n\n1 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n3 3\n2 2\n1 1\n0 0\n\nSample Output\n\n#.#.\n.#.#\n#.#.\n\n#.#.#.\n.#.#.#\n#.#.#.\n.#.#.#\n#.#.#.\n\n#.#\n.#.\n#.#\n\n#.\n.#\n\n#", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 387, "cpu_time_ms": 260, "memory_kb": 45208}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s918457435", "group_id": "codeNet:p02405", "input_text": "import scala.io.Source\n\nobject Main extends App {\n for (line <- Source.stdin.getLines if line != \"0 0\") {\n val Array(h, w) = line.split(\" \").map(_.toInt)\n for (i <- 1 to h) {\n for ( j <- 1 to w) {\n print { if ((i+j) % 2 == 0) \"#\" else \".\" }\n }\n println()\n }\n println()\n }\n}", "language": "Scala", "metadata": {"date": 1511428342, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02405.html", "problem_id": "p02405", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02405/input.txt", "sample_output_relpath": "derived/input_output/data/p02405/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02405/Scala/s918457435.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s918457435", "user_id": "u387507798"}, "prompt_components": {"gold_output": "#.#.\n.#.#\n#.#.\n\n#.#.#.\n.#.#.#\n#.#.#.\n.#.#.#\n#.#.#.\n\n#.#\n.#.\n#.#\n\n#.\n.#\n\n#\n", "input_to_evaluate": "import scala.io.Source\n\nobject Main extends App {\n for (line <- Source.stdin.getLines if line != \"0 0\") {\n val Array(h, w) = line.split(\" \").map(_.toInt)\n for (i <- 1 to h) {\n for ( j <- 1 to w) {\n print { if ((i+j) % 2 == 0) \"#\" else \".\" }\n }\n println()\n }\n println()\n }\n}", "problem_context": "Print a Chessboard\n\nDraw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm.\n\n#.#.#.#.#.\n.#.#.#.#.#\n#.#.#.#.#.\n.#.#.#.#.#\n#.#.#.#.#.\n.#.#.#.#.#\n\nNote that the top left corner should be drawn by '#'.\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 chessboard made of '#' and '.'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n1 ≤ H ≤ 300\n\n1 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n3 3\n2 2\n1 1\n0 0\n\nSample Output\n\n#.#.\n.#.#\n#.#.\n\n#.#.#.\n.#.#.#\n#.#.#.\n.#.#.#\n#.#.#.\n\n#.#\n.#.\n#.#\n\n#.\n.#\n\n#", "sample_input": "3 4\n5 6\n3 3\n2 2\n1 1\n0 0\n"}, "reference_outputs": ["#.#.\n.#.#\n#.#.\n\n#.#.#.\n.#.#.#\n#.#.#.\n.#.#.#\n#.#.#.\n\n#.#\n.#.\n#.#\n\n#.\n.#\n\n#\n"], "source_document_id": "p02405", "source_text": "Print a Chessboard\n\nDraw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm.\n\n#.#.#.#.#.\n.#.#.#.#.#\n#.#.#.#.#.\n.#.#.#.#.#\n#.#.#.#.#.\n.#.#.#.#.#\n\nNote that the top left corner should be drawn by '#'.\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 chessboard made of '#' and '.'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n1 ≤ H ≤ 300\n\n1 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n3 3\n2 2\n1 1\n0 0\n\nSample Output\n\n#.#.\n.#.#\n#.#.\n\n#.#.#.\n.#.#.#\n#.#.#.\n.#.#.#\n#.#.#.\n\n#.#\n.#.\n#.#\n\n#.\n.#\n\n#", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 440, "memory_kb": 54304}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s050733617", "group_id": "codeNet:p02405", "input_text": "import io.Source.stdin\n\nobject Main {\n\n def main(args: Array[String]) {\n for ((list) <- stdin.getLines().takeWhile(_ != \"0 0\").map(_.split(\" \").map(_.toInt))) {\n val (h: Int, w: Int) = (list(0), list(1))\n printChessBoard(h, w)\n }\n }\n\n def printChessBoard(h: Int, w: Int) {\n for (i <- 1 to h) {\n for (j <- 1 to w) {\n printChar(isSharp(i, j))\n }\n println()\n }\n println()\n }\n \n def printChar(isSharp: Boolean) {\n if (isSharp) {\n print(\"#\")\n } else {\n print(\".\")\n }\n }\n \n def isSharp(i: Int, j: Int): Boolean = {\n if ((i % 2 == 0 && j % 2 != 0) || (j % 2 == 0 && i % 2 != 0)) {\n false\n } else {\n true\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1587259562, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02405.html", "problem_id": "p02405", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02405/input.txt", "sample_output_relpath": "derived/input_output/data/p02405/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02405/Scala/s050733617.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s050733617", "user_id": "u657361950"}, "prompt_components": {"gold_output": "#.#.\n.#.#\n#.#.\n\n#.#.#.\n.#.#.#\n#.#.#.\n.#.#.#\n#.#.#.\n\n#.#\n.#.\n#.#\n\n#.\n.#\n\n#\n", "input_to_evaluate": "import io.Source.stdin\n\nobject Main {\n\n def main(args: Array[String]) {\n for ((list) <- stdin.getLines().takeWhile(_ != \"0 0\").map(_.split(\" \").map(_.toInt))) {\n val (h: Int, w: Int) = (list(0), list(1))\n printChessBoard(h, w)\n }\n }\n\n def printChessBoard(h: Int, w: Int) {\n for (i <- 1 to h) {\n for (j <- 1 to w) {\n printChar(isSharp(i, j))\n }\n println()\n }\n println()\n }\n \n def printChar(isSharp: Boolean) {\n if (isSharp) {\n print(\"#\")\n } else {\n print(\".\")\n }\n }\n \n def isSharp(i: Int, j: Int): Boolean = {\n if ((i % 2 == 0 && j % 2 != 0) || (j % 2 == 0 && i % 2 != 0)) {\n false\n } else {\n true\n }\n }\n}\n", "problem_context": "Print a Chessboard\n\nDraw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm.\n\n#.#.#.#.#.\n.#.#.#.#.#\n#.#.#.#.#.\n.#.#.#.#.#\n#.#.#.#.#.\n.#.#.#.#.#\n\nNote that the top left corner should be drawn by '#'.\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 chessboard made of '#' and '.'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n1 ≤ H ≤ 300\n\n1 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n3 3\n2 2\n1 1\n0 0\n\nSample Output\n\n#.#.\n.#.#\n#.#.\n\n#.#.#.\n.#.#.#\n#.#.#.\n.#.#.#\n#.#.#.\n\n#.#\n.#.\n#.#\n\n#.\n.#\n\n#", "sample_input": "3 4\n5 6\n3 3\n2 2\n1 1\n0 0\n"}, "reference_outputs": ["#.#.\n.#.#\n#.#.\n\n#.#.#.\n.#.#.#\n#.#.#.\n.#.#.#\n#.#.#.\n\n#.#\n.#.\n#.#\n\n#.\n.#\n\n#\n"], "source_document_id": "p02405", "source_text": "Print a Chessboard\n\nDraw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm.\n\n#.#.#.#.#.\n.#.#.#.#.#\n#.#.#.#.#.\n.#.#.#.#.#\n#.#.#.#.#.\n.#.#.#.#.#\n\nNote that the top left corner should be drawn by '#'.\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 chessboard made of '#' and '.'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n1 ≤ H ≤ 300\n\n1 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n3 3\n2 2\n1 1\n0 0\n\nSample Output\n\n#.#.\n.#.#\n#.#.\n\n#.#.#.\n.#.#.#\n#.#.#.\n.#.#.#\n#.#.#.\n\n#.#\n.#.\n#.#\n\n#.\n.#\n\n#", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 700, "cpu_time_ms": 480, "memory_kb": 53356}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s431948682", "group_id": "codeNet:p02406", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt()\n println(\" \" + (1 to n).filter(i => isMultipleOf3(i) || hasNumberOf3(i)).mkString(\" \"))\n\n def isMultipleOf3(i: Int): Boolean = i % 3 == 0\n def hasNumberOf3(i: Int): Boolean = i % 10 == 3 || i / 10 == 3\n}", "language": "Scala", "metadata": {"date": 1451417088, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02406.html", "problem_id": "p02406", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02406/input.txt", "sample_output_relpath": "derived/input_output/data/p02406/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02406/Scala/s431948682.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s431948682", "user_id": "u223249350"}, "prompt_components": {"gold_output": " 3 6 9 12 13 15 18 21 23 24 27 30\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt()\n println(\" \" + (1 to n).filter(i => isMultipleOf3(i) || hasNumberOf3(i)).mkString(\" \"))\n\n def isMultipleOf3(i: Int): Boolean = i % 3 == 0\n def hasNumberOf3(i: Int): Boolean = i % 10 == 3 || i / 10 == 3\n}", "problem_context": "Structured Programming\n\nIn programming languages like C/C++, a goto statement provides an unconditional jump from the \"goto\" to a labeled statement. For example, a statement \"goto CHECK_NUM;\" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops.\n\nNote that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto.\n\nWrite a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements.\n\nvoid call(int n){\nint i = 1;\nCHECK_NUM:\nint x = i;\nif ( x % 3 == 0 ){\ncout << \" \" << i;\ngoto END_CHECK_NUM;\n}\nINCLUDE3:\nif ( x % 10 == 3 ){\ncout << \" \" << i;\ngoto END_CHECK_NUM;\n}\nx /= 10;\nif ( x ) goto INCLUDE3;\nEND_CHECK_NUM:\nif ( ++i <= n ) goto CHECK_NUM;\n\ncout << endl;\n}\n\nInput\n\nAn integer n is given in a line.\n\nOutput\n\nPrint the output result of the above program for given integer n.\n\nConstraints\n\n3 ≤ n ≤ 10000\n\nSample Input\n\n30\n\nSample Output\n\n3 6 9 12 13 15 18 21 23 24 27 30\n\nPut a single space character before each element.", "sample_input": "30\n"}, "reference_outputs": [" 3 6 9 12 13 15 18 21 23 24 27 30\n"], "source_document_id": "p02406", "source_text": "Structured Programming\n\nIn programming languages like C/C++, a goto statement provides an unconditional jump from the \"goto\" to a labeled statement. For example, a statement \"goto CHECK_NUM;\" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops.\n\nNote that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto.\n\nWrite a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements.\n\nvoid call(int n){\nint i = 1;\nCHECK_NUM:\nint x = i;\nif ( x % 3 == 0 ){\ncout << \" \" << i;\ngoto END_CHECK_NUM;\n}\nINCLUDE3:\nif ( x % 10 == 3 ){\ncout << \" \" << i;\ngoto END_CHECK_NUM;\n}\nx /= 10;\nif ( x ) goto INCLUDE3;\nEND_CHECK_NUM:\nif ( ++i <= n ) goto CHECK_NUM;\n\ncout << endl;\n}\n\nInput\n\nAn integer n is given in a line.\n\nOutput\n\nPrint the output result of the above program for given integer n.\n\nConstraints\n\n3 ≤ n ≤ 10000\n\nSample Input\n\n30\n\nSample Output\n\n3 6 9 12 13 15 18 21 23 24 27 30\n\nPut a single space character before each element.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 310, "memory_kb": 45048}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s955908212", "group_id": "codeNet:p02406", "input_text": "\nobject Main {\n\tdef main(args: Array[String]): Unit = {\n\t val in = new java.util.Scanner(System.in)\n\t val n = in.nextInt\n\t call(1,n)\n\t}\n\tdef call(n : Int,lim:Int): Unit = {\n\t if (lim < n){\n println(\"\")\n return\n }\n\t val i = n\n\t if(i % 3 == 0){\n\t printf(\" \"+i)\n\t }else{\n\t callRec(i)\n\t }\n\t call(i+1,lim)\n\t}\n\tdef callRec(n:Int):Unit={\n\t if(n == 0) return\n\t if(n % 10 == 3) {\n\t printf(\" \"+n)\n\t return\n\t }\n\t callRec(n/10)\n\t}\n}", "language": "Scala", "metadata": {"date": 1458100786, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02406.html", "problem_id": "p02406", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02406/input.txt", "sample_output_relpath": "derived/input_output/data/p02406/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02406/Scala/s955908212.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s955908212", "user_id": "u892831253"}, "prompt_components": {"gold_output": " 3 6 9 12 13 15 18 21 23 24 27 30\n", "input_to_evaluate": "\nobject Main {\n\tdef main(args: Array[String]): Unit = {\n\t val in = new java.util.Scanner(System.in)\n\t val n = in.nextInt\n\t call(1,n)\n\t}\n\tdef call(n : Int,lim:Int): Unit = {\n\t if (lim < n){\n println(\"\")\n return\n }\n\t val i = n\n\t if(i % 3 == 0){\n\t printf(\" \"+i)\n\t }else{\n\t callRec(i)\n\t }\n\t call(i+1,lim)\n\t}\n\tdef callRec(n:Int):Unit={\n\t if(n == 0) return\n\t if(n % 10 == 3) {\n\t printf(\" \"+n)\n\t return\n\t }\n\t callRec(n/10)\n\t}\n}", "problem_context": "Structured Programming\n\nIn programming languages like C/C++, a goto statement provides an unconditional jump from the \"goto\" to a labeled statement. For example, a statement \"goto CHECK_NUM;\" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops.\n\nNote that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto.\n\nWrite a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements.\n\nvoid call(int n){\nint i = 1;\nCHECK_NUM:\nint x = i;\nif ( x % 3 == 0 ){\ncout << \" \" << i;\ngoto END_CHECK_NUM;\n}\nINCLUDE3:\nif ( x % 10 == 3 ){\ncout << \" \" << i;\ngoto END_CHECK_NUM;\n}\nx /= 10;\nif ( x ) goto INCLUDE3;\nEND_CHECK_NUM:\nif ( ++i <= n ) goto CHECK_NUM;\n\ncout << endl;\n}\n\nInput\n\nAn integer n is given in a line.\n\nOutput\n\nPrint the output result of the above program for given integer n.\n\nConstraints\n\n3 ≤ n ≤ 10000\n\nSample Input\n\n30\n\nSample Output\n\n3 6 9 12 13 15 18 21 23 24 27 30\n\nPut a single space character before each element.", "sample_input": "30\n"}, "reference_outputs": [" 3 6 9 12 13 15 18 21 23 24 27 30\n"], "source_document_id": "p02406", "source_text": "Structured Programming\n\nIn programming languages like C/C++, a goto statement provides an unconditional jump from the \"goto\" to a labeled statement. For example, a statement \"goto CHECK_NUM;\" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops.\n\nNote that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto.\n\nWrite a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements.\n\nvoid call(int n){\nint i = 1;\nCHECK_NUM:\nint x = i;\nif ( x % 3 == 0 ){\ncout << \" \" << i;\ngoto END_CHECK_NUM;\n}\nINCLUDE3:\nif ( x % 10 == 3 ){\ncout << \" \" << i;\ngoto END_CHECK_NUM;\n}\nx /= 10;\nif ( x ) goto INCLUDE3;\nEND_CHECK_NUM:\nif ( ++i <= n ) goto CHECK_NUM;\n\ncout << endl;\n}\n\nInput\n\nAn integer n is given in a line.\n\nOutput\n\nPrint the output result of the above program for given integer n.\n\nConstraints\n\n3 ≤ n ≤ 10000\n\nSample Input\n\n30\n\nSample Output\n\n3 6 9 12 13 15 18 21 23 24 27 30\n\nPut a single space character before each element.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 475, "cpu_time_ms": 250, "memory_kb": 44964}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s602527078", "group_id": "codeNet:p02406", "input_text": "\nobject Main {\n\tdef main(args: Array[String]): Unit = {\n\t val in = new java.util.Scanner(System.in)\n\t val n = in.nextInt\n\t call(1,n)\n\t}\n\tdef call(n : Int,lim:Int): Unit = {\n\t if (lim < n){\n\t println(\"\")\n\t return\n\t }\n\t val i = n\n\t if(i % 3 == 0){\n\t printf(\" \"+i)\n\t }else{\n\t callRec(i,i)\n\t }\n\t call(i+1,lim)\n\t}\n\tdef callRec(ori:Int,n:Int):Unit={\n\t if(n == 0) return\n\t if(n % 10 == 3) {\n\t printf(\" \"+ori)\n\t return\n\t }\n\t callRec(ori,n/10)\n\t}\n}", "language": "Scala", "metadata": {"date": 1458100972, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02406.html", "problem_id": "p02406", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02406/input.txt", "sample_output_relpath": "derived/input_output/data/p02406/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02406/Scala/s602527078.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s602527078", "user_id": "u892831253"}, "prompt_components": {"gold_output": " 3 6 9 12 13 15 18 21 23 24 27 30\n", "input_to_evaluate": "\nobject Main {\n\tdef main(args: Array[String]): Unit = {\n\t val in = new java.util.Scanner(System.in)\n\t val n = in.nextInt\n\t call(1,n)\n\t}\n\tdef call(n : Int,lim:Int): Unit = {\n\t if (lim < n){\n\t println(\"\")\n\t return\n\t }\n\t val i = n\n\t if(i % 3 == 0){\n\t printf(\" \"+i)\n\t }else{\n\t callRec(i,i)\n\t }\n\t call(i+1,lim)\n\t}\n\tdef callRec(ori:Int,n:Int):Unit={\n\t if(n == 0) return\n\t if(n % 10 == 3) {\n\t printf(\" \"+ori)\n\t return\n\t }\n\t callRec(ori,n/10)\n\t}\n}", "problem_context": "Structured Programming\n\nIn programming languages like C/C++, a goto statement provides an unconditional jump from the \"goto\" to a labeled statement. For example, a statement \"goto CHECK_NUM;\" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops.\n\nNote that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto.\n\nWrite a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements.\n\nvoid call(int n){\nint i = 1;\nCHECK_NUM:\nint x = i;\nif ( x % 3 == 0 ){\ncout << \" \" << i;\ngoto END_CHECK_NUM;\n}\nINCLUDE3:\nif ( x % 10 == 3 ){\ncout << \" \" << i;\ngoto END_CHECK_NUM;\n}\nx /= 10;\nif ( x ) goto INCLUDE3;\nEND_CHECK_NUM:\nif ( ++i <= n ) goto CHECK_NUM;\n\ncout << endl;\n}\n\nInput\n\nAn integer n is given in a line.\n\nOutput\n\nPrint the output result of the above program for given integer n.\n\nConstraints\n\n3 ≤ n ≤ 10000\n\nSample Input\n\n30\n\nSample Output\n\n3 6 9 12 13 15 18 21 23 24 27 30\n\nPut a single space character before each element.", "sample_input": "30\n"}, "reference_outputs": [" 3 6 9 12 13 15 18 21 23 24 27 30\n"], "source_document_id": "p02406", "source_text": "Structured Programming\n\nIn programming languages like C/C++, a goto statement provides an unconditional jump from the \"goto\" to a labeled statement. For example, a statement \"goto CHECK_NUM;\" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops.\n\nNote that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto.\n\nWrite a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements.\n\nvoid call(int n){\nint i = 1;\nCHECK_NUM:\nint x = i;\nif ( x % 3 == 0 ){\ncout << \" \" << i;\ngoto END_CHECK_NUM;\n}\nINCLUDE3:\nif ( x % 10 == 3 ){\ncout << \" \" << i;\ngoto END_CHECK_NUM;\n}\nx /= 10;\nif ( x ) goto INCLUDE3;\nEND_CHECK_NUM:\nif ( ++i <= n ) goto CHECK_NUM;\n\ncout << endl;\n}\n\nInput\n\nAn integer n is given in a line.\n\nOutput\n\nPrint the output result of the above program for given integer n.\n\nConstraints\n\n3 ≤ n ≤ 10000\n\nSample Input\n\n30\n\nSample Output\n\n3 6 9 12 13 15 18 21 23 24 27 30\n\nPut a single space character before each element.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 472, "cpu_time_ms": 340, "memory_kb": 53368}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s890658815", "group_id": "codeNet:p02406", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val n = io.StdIn.readInt()\n val output =\n (for {\n i <- 1 to n\n if i % 3 == 0 || include3(i)\n } yield s\" $i\").mkString\n println(output)\n }\n\n def include3(x: Int): Boolean = {\n var included = false\n var i = x\n while (!included && i > 0) {\n included |= i % 10 == 3\n i /= 10\n }\n included\n }\n}", "language": "Scala", "metadata": {"date": 1488775761, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02406.html", "problem_id": "p02406", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02406/input.txt", "sample_output_relpath": "derived/input_output/data/p02406/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02406/Scala/s890658815.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s890658815", "user_id": "u959441351"}, "prompt_components": {"gold_output": " 3 6 9 12 13 15 18 21 23 24 27 30\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val n = io.StdIn.readInt()\n val output =\n (for {\n i <- 1 to n\n if i % 3 == 0 || include3(i)\n } yield s\" $i\").mkString\n println(output)\n }\n\n def include3(x: Int): Boolean = {\n var included = false\n var i = x\n while (!included && i > 0) {\n included |= i % 10 == 3\n i /= 10\n }\n included\n }\n}", "problem_context": "Structured Programming\n\nIn programming languages like C/C++, a goto statement provides an unconditional jump from the \"goto\" to a labeled statement. For example, a statement \"goto CHECK_NUM;\" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops.\n\nNote that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto.\n\nWrite a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements.\n\nvoid call(int n){\nint i = 1;\nCHECK_NUM:\nint x = i;\nif ( x % 3 == 0 ){\ncout << \" \" << i;\ngoto END_CHECK_NUM;\n}\nINCLUDE3:\nif ( x % 10 == 3 ){\ncout << \" \" << i;\ngoto END_CHECK_NUM;\n}\nx /= 10;\nif ( x ) goto INCLUDE3;\nEND_CHECK_NUM:\nif ( ++i <= n ) goto CHECK_NUM;\n\ncout << endl;\n}\n\nInput\n\nAn integer n is given in a line.\n\nOutput\n\nPrint the output result of the above program for given integer n.\n\nConstraints\n\n3 ≤ n ≤ 10000\n\nSample Input\n\n30\n\nSample Output\n\n3 6 9 12 13 15 18 21 23 24 27 30\n\nPut a single space character before each element.", "sample_input": "30\n"}, "reference_outputs": [" 3 6 9 12 13 15 18 21 23 24 27 30\n"], "source_document_id": "p02406", "source_text": "Structured Programming\n\nIn programming languages like C/C++, a goto statement provides an unconditional jump from the \"goto\" to a labeled statement. For example, a statement \"goto CHECK_NUM;\" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops.\n\nNote that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto.\n\nWrite a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements.\n\nvoid call(int n){\nint i = 1;\nCHECK_NUM:\nint x = i;\nif ( x % 3 == 0 ){\ncout << \" \" << i;\ngoto END_CHECK_NUM;\n}\nINCLUDE3:\nif ( x % 10 == 3 ){\ncout << \" \" << i;\ngoto END_CHECK_NUM;\n}\nx /= 10;\nif ( x ) goto INCLUDE3;\nEND_CHECK_NUM:\nif ( ++i <= n ) goto CHECK_NUM;\n\ncout << endl;\n}\n\nInput\n\nAn integer n is given in a line.\n\nOutput\n\nPrint the output result of the above program for given integer n.\n\nConstraints\n\n3 ≤ n ≤ 10000\n\nSample Input\n\n30\n\nSample Output\n\n3 6 9 12 13 15 18 21 23 24 27 30\n\nPut a single space character before each element.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 406, "cpu_time_ms": 260, "memory_kb": 47608}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s348084544", "group_id": "codeNet:p02407", "input_text": "import scala.io.StdIn.readLine\n\nobject Main {\n def main(args: Array[String]): Unit = {\n readLine\n println(readLine.split(\" \").map(_.toInt).reverse.mkString(\" \"))\n }\n}", "language": "Scala", "metadata": {"date": 1435910281, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02407.html", "problem_id": "p02407", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02407/input.txt", "sample_output_relpath": "derived/input_output/data/p02407/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02407/Scala/s348084544.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s348084544", "user_id": "u047988051"}, "prompt_components": {"gold_output": "5 4 3 2 1\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main {\n def main(args: Array[String]): Unit = {\n readLine\n println(readLine.split(\" \").map(_.toInt).reverse.mkString(\" \"))\n }\n}", "problem_context": "Reversing Numbers\n\nWrite a program which reads a sequence and prints it in the reverse order.\n\nInput\n\nThe input is given in the following format:\n\nn\na1 a2 . . . an\n\nn is the size of the sequence and ai is the ith element of the sequence.\n\nOutput\n\nPrint the reversed sequence in a line. Print a single space character between adjacent elements (Note that your program should not put a space character after the last element).\n\nConstraints\n\nn ≤ 100\n\n0 ≤ ai < 1000\n\nSample Input 1\n\n5\n1 2 3 4 5\n\nSample Output 1\n\n5 4 3 2 1\n\nSample Input 2\n\n8\n3 3 4 4 5 8 7 9\n\nSample Output 2\n\n9 7 8 5 4 4 3 3\n\nNote\n\n      解説", "sample_input": "5\n1 2 3 4 5\n"}, "reference_outputs": ["5 4 3 2 1\n"], "source_document_id": "p02407", "source_text": "Reversing Numbers\n\nWrite a program which reads a sequence and prints it in the reverse order.\n\nInput\n\nThe input is given in the following format:\n\nn\na1 a2 . . . an\n\nn is the size of the sequence and ai is the ith element of the sequence.\n\nOutput\n\nPrint the reversed sequence in a line. Print a single space character between adjacent elements (Note that your program should not put a space character after the last element).\n\nConstraints\n\nn ≤ 100\n\n0 ≤ ai < 1000\n\nSample Input 1\n\n5\n1 2 3 4 5\n\nSample Output 1\n\n5 4 3 2 1\n\nSample Input 2\n\n8\n3 3 4 4 5 8 7 9\n\nSample Output 2\n\n9 7 8 5 4 4 3 3\n\nNote\n\n      解説", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43928}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s594135511", "group_id": "codeNet:p02407", "input_text": "import scala.io.StdIn\n\nobject Main {\n def main(args: Array[String]): Unit = {\n StdIn.readInt()\n val list = StdIn.readLine().split(\" \")\n println(list.reverse.mkString(\" \"))\n }\n}", "language": "Scala", "metadata": {"date": 1436165048, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02407.html", "problem_id": "p02407", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02407/input.txt", "sample_output_relpath": "derived/input_output/data/p02407/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02407/Scala/s594135511.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s594135511", "user_id": "u389172382"}, "prompt_components": {"gold_output": "5 4 3 2 1\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main {\n def main(args: Array[String]): Unit = {\n StdIn.readInt()\n val list = StdIn.readLine().split(\" \")\n println(list.reverse.mkString(\" \"))\n }\n}", "problem_context": "Reversing Numbers\n\nWrite a program which reads a sequence and prints it in the reverse order.\n\nInput\n\nThe input is given in the following format:\n\nn\na1 a2 . . . an\n\nn is the size of the sequence and ai is the ith element of the sequence.\n\nOutput\n\nPrint the reversed sequence in a line. Print a single space character between adjacent elements (Note that your program should not put a space character after the last element).\n\nConstraints\n\nn ≤ 100\n\n0 ≤ ai < 1000\n\nSample Input 1\n\n5\n1 2 3 4 5\n\nSample Output 1\n\n5 4 3 2 1\n\nSample Input 2\n\n8\n3 3 4 4 5 8 7 9\n\nSample Output 2\n\n9 7 8 5 4 4 3 3\n\nNote\n\n      解説", "sample_input": "5\n1 2 3 4 5\n"}, "reference_outputs": ["5 4 3 2 1\n"], "source_document_id": "p02407", "source_text": "Reversing Numbers\n\nWrite a program which reads a sequence and prints it in the reverse order.\n\nInput\n\nThe input is given in the following format:\n\nn\na1 a2 . . . an\n\nn is the size of the sequence and ai is the ith element of the sequence.\n\nOutput\n\nPrint the reversed sequence in a line. Print a single space character between adjacent elements (Note that your program should not put a space character after the last element).\n\nConstraints\n\nn ≤ 100\n\n0 ≤ ai < 1000\n\nSample Input 1\n\n5\n1 2 3 4 5\n\nSample Output 1\n\n5 4 3 2 1\n\nSample Input 2\n\n8\n3 3 4 4 5 8 7 9\n\nSample Output 2\n\n9 7 8 5 4 4 3 3\n\nNote\n\n      解説", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 220, "memory_kb": 43696}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s598147465", "group_id": "codeNet:p02407", "input_text": "object Main {\n def main(args: Array[String]) {\n val num = scala.io.StdIn.readInt()\n println(scala.io.StdIn.readLine().split(\" \").toList.reverse.mkString(\" \"))\n }\n}", "language": "Scala", "metadata": {"date": 1437042815, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02407.html", "problem_id": "p02407", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02407/input.txt", "sample_output_relpath": "derived/input_output/data/p02407/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02407/Scala/s598147465.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s598147465", "user_id": "u012178320"}, "prompt_components": {"gold_output": "5 4 3 2 1\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]) {\n val num = scala.io.StdIn.readInt()\n println(scala.io.StdIn.readLine().split(\" \").toList.reverse.mkString(\" \"))\n }\n}", "problem_context": "Reversing Numbers\n\nWrite a program which reads a sequence and prints it in the reverse order.\n\nInput\n\nThe input is given in the following format:\n\nn\na1 a2 . . . an\n\nn is the size of the sequence and ai is the ith element of the sequence.\n\nOutput\n\nPrint the reversed sequence in a line. Print a single space character between adjacent elements (Note that your program should not put a space character after the last element).\n\nConstraints\n\nn ≤ 100\n\n0 ≤ ai < 1000\n\nSample Input 1\n\n5\n1 2 3 4 5\n\nSample Output 1\n\n5 4 3 2 1\n\nSample Input 2\n\n8\n3 3 4 4 5 8 7 9\n\nSample Output 2\n\n9 7 8 5 4 4 3 3\n\nNote\n\n      解説", "sample_input": "5\n1 2 3 4 5\n"}, "reference_outputs": ["5 4 3 2 1\n"], "source_document_id": "p02407", "source_text": "Reversing Numbers\n\nWrite a program which reads a sequence and prints it in the reverse order.\n\nInput\n\nThe input is given in the following format:\n\nn\na1 a2 . . . an\n\nn is the size of the sequence and ai is the ith element of the sequence.\n\nOutput\n\nPrint the reversed sequence in a line. Print a single space character between adjacent elements (Note that your program should not put a space character after the last element).\n\nConstraints\n\nn ≤ 100\n\n0 ≤ ai < 1000\n\nSample Input 1\n\n5\n1 2 3 4 5\n\nSample Output 1\n\n5 4 3 2 1\n\nSample Input 2\n\n8\n3 3 4 4 5 8 7 9\n\nSample Output 2\n\n9 7 8 5 4 4 3 3\n\nNote\n\n      解説", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43692}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s254044202", "group_id": "codeNet:p02407", "input_text": "import scala.io.StdIn.readLine\n\nobject Main {\n def main(args: Array[String]) {\n readLine()\n val input = readLine().split(\" \").map(_.toInt).sortWith(_ > _).mkString(\" \")\n println(input)\n }\n}", "language": "Scala", "metadata": {"date": 1457937022, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02407.html", "problem_id": "p02407", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02407/input.txt", "sample_output_relpath": "derived/input_output/data/p02407/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02407/Scala/s254044202.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s254044202", "user_id": "u123244675"}, "prompt_components": {"gold_output": "5 4 3 2 1\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main {\n def main(args: Array[String]) {\n readLine()\n val input = readLine().split(\" \").map(_.toInt).sortWith(_ > _).mkString(\" \")\n println(input)\n }\n}", "problem_context": "Reversing Numbers\n\nWrite a program which reads a sequence and prints it in the reverse order.\n\nInput\n\nThe input is given in the following format:\n\nn\na1 a2 . . . an\n\nn is the size of the sequence and ai is the ith element of the sequence.\n\nOutput\n\nPrint the reversed sequence in a line. Print a single space character between adjacent elements (Note that your program should not put a space character after the last element).\n\nConstraints\n\nn ≤ 100\n\n0 ≤ ai < 1000\n\nSample Input 1\n\n5\n1 2 3 4 5\n\nSample Output 1\n\n5 4 3 2 1\n\nSample Input 2\n\n8\n3 3 4 4 5 8 7 9\n\nSample Output 2\n\n9 7 8 5 4 4 3 3\n\nNote\n\n      解説", "sample_input": "5\n1 2 3 4 5\n"}, "reference_outputs": ["5 4 3 2 1\n"], "source_document_id": "p02407", "source_text": "Reversing Numbers\n\nWrite a program which reads a sequence and prints it in the reverse order.\n\nInput\n\nThe input is given in the following format:\n\nn\na1 a2 . . . an\n\nn is the size of the sequence and ai is the ith element of the sequence.\n\nOutput\n\nPrint the reversed sequence in a line. Print a single space character between adjacent elements (Note that your program should not put a space character after the last element).\n\nConstraints\n\nn ≤ 100\n\n0 ≤ ai < 1000\n\nSample Input 1\n\n5\n1 2 3 4 5\n\nSample Output 1\n\n5 4 3 2 1\n\nSample Input 2\n\n8\n3 3 4 4 5 8 7 9\n\nSample Output 2\n\n9 7 8 5 4 4 3 3\n\nNote\n\n      解説", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 43932}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s689922823", "group_id": "codeNet:p02407", "input_text": "import scala.io.StdIn.readLine\n\nobject Main {\n\n def main(args: Array[String]) = {\n readLine\n println(readLine.split(\" \").reverse.mkString(\" \"))\n\n }\n}", "language": "Scala", "metadata": {"date": 1480929615, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02407.html", "problem_id": "p02407", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02407/input.txt", "sample_output_relpath": "derived/input_output/data/p02407/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02407/Scala/s689922823.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s689922823", "user_id": "u508732591"}, "prompt_components": {"gold_output": "5 4 3 2 1\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main {\n\n def main(args: Array[String]) = {\n readLine\n println(readLine.split(\" \").reverse.mkString(\" \"))\n\n }\n}", "problem_context": "Reversing Numbers\n\nWrite a program which reads a sequence and prints it in the reverse order.\n\nInput\n\nThe input is given in the following format:\n\nn\na1 a2 . . . an\n\nn is the size of the sequence and ai is the ith element of the sequence.\n\nOutput\n\nPrint the reversed sequence in a line. Print a single space character between adjacent elements (Note that your program should not put a space character after the last element).\n\nConstraints\n\nn ≤ 100\n\n0 ≤ ai < 1000\n\nSample Input 1\n\n5\n1 2 3 4 5\n\nSample Output 1\n\n5 4 3 2 1\n\nSample Input 2\n\n8\n3 3 4 4 5 8 7 9\n\nSample Output 2\n\n9 7 8 5 4 4 3 3\n\nNote\n\n      解説", "sample_input": "5\n1 2 3 4 5\n"}, "reference_outputs": ["5 4 3 2 1\n"], "source_document_id": "p02407", "source_text": "Reversing Numbers\n\nWrite a program which reads a sequence and prints it in the reverse order.\n\nInput\n\nThe input is given in the following format:\n\nn\na1 a2 . . . an\n\nn is the size of the sequence and ai is the ith element of the sequence.\n\nOutput\n\nPrint the reversed sequence in a line. Print a single space character between adjacent elements (Note that your program should not put a space character after the last element).\n\nConstraints\n\nn ≤ 100\n\n0 ≤ ai < 1000\n\nSample Input 1\n\n5\n1 2 3 4 5\n\nSample Output 1\n\n5 4 3 2 1\n\nSample Input 2\n\n8\n3 3 4 4 5 8 7 9\n\nSample Output 2\n\n9 7 8 5 4 4 3 3\n\nNote\n\n      解説", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43796}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s572071157", "group_id": "codeNet:p02407", "input_text": "object Main {\n def main(args: Array[String]): Unit =\n println(io.StdIn.readLine().split(\" \").reverse.mkString(\" \"))\n}\n", "language": "Scala", "metadata": {"date": 1523796342, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02407.html", "problem_id": "p02407", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02407/input.txt", "sample_output_relpath": "derived/input_output/data/p02407/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02407/Scala/s572071157.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s572071157", "user_id": "u250696856"}, "prompt_components": {"gold_output": "5 4 3 2 1\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit =\n println(io.StdIn.readLine().split(\" \").reverse.mkString(\" \"))\n}\n", "problem_context": "Reversing Numbers\n\nWrite a program which reads a sequence and prints it in the reverse order.\n\nInput\n\nThe input is given in the following format:\n\nn\na1 a2 . . . an\n\nn is the size of the sequence and ai is the ith element of the sequence.\n\nOutput\n\nPrint the reversed sequence in a line. Print a single space character between adjacent elements (Note that your program should not put a space character after the last element).\n\nConstraints\n\nn ≤ 100\n\n0 ≤ ai < 1000\n\nSample Input 1\n\n5\n1 2 3 4 5\n\nSample Output 1\n\n5 4 3 2 1\n\nSample Input 2\n\n8\n3 3 4 4 5 8 7 9\n\nSample Output 2\n\n9 7 8 5 4 4 3 3\n\nNote\n\n      解説", "sample_input": "5\n1 2 3 4 5\n"}, "reference_outputs": ["5 4 3 2 1\n"], "source_document_id": "p02407", "source_text": "Reversing Numbers\n\nWrite a program which reads a sequence and prints it in the reverse order.\n\nInput\n\nThe input is given in the following format:\n\nn\na1 a2 . . . an\n\nn is the size of the sequence and ai is the ith element of the sequence.\n\nOutput\n\nPrint the reversed sequence in a line. Print a single space character between adjacent elements (Note that your program should not put a space character after the last element).\n\nConstraints\n\nn ≤ 100\n\n0 ≤ ai < 1000\n\nSample Input 1\n\n5\n1 2 3 4 5\n\nSample Output 1\n\n5 4 3 2 1\n\nSample Input 2\n\n8\n3 3 4 4 5 8 7 9\n\nSample Output 2\n\n9 7 8 5 4 4 3 3\n\nNote\n\n      解説", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 220, "memory_kb": 43616}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s345713212", "group_id": "codeNet:p02407", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n\n val n = StdIn.readLine().toInt\n var k = n - 1\n val out = Array.fill(n)(\"0\")\n val buff = StdIn.readLine().split(' ').foreach{ e =>\n out(k) = e\n k -= 1\n }\n println(out.mkString(\" \"))\n \n}\n", "language": "Scala", "metadata": {"date": 1523966217, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02407.html", "problem_id": "p02407", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02407/input.txt", "sample_output_relpath": "derived/input_output/data/p02407/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02407/Scala/s345713212.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s345713212", "user_id": "u342234782"}, "prompt_components": {"gold_output": "5 4 3 2 1\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n\n val n = StdIn.readLine().toInt\n var k = n - 1\n val out = Array.fill(n)(\"0\")\n val buff = StdIn.readLine().split(' ').foreach{ e =>\n out(k) = e\n k -= 1\n }\n println(out.mkString(\" \"))\n \n}\n", "problem_context": "Reversing Numbers\n\nWrite a program which reads a sequence and prints it in the reverse order.\n\nInput\n\nThe input is given in the following format:\n\nn\na1 a2 . . . an\n\nn is the size of the sequence and ai is the ith element of the sequence.\n\nOutput\n\nPrint the reversed sequence in a line. Print a single space character between adjacent elements (Note that your program should not put a space character after the last element).\n\nConstraints\n\nn ≤ 100\n\n0 ≤ ai < 1000\n\nSample Input 1\n\n5\n1 2 3 4 5\n\nSample Output 1\n\n5 4 3 2 1\n\nSample Input 2\n\n8\n3 3 4 4 5 8 7 9\n\nSample Output 2\n\n9 7 8 5 4 4 3 3\n\nNote\n\n      解説", "sample_input": "5\n1 2 3 4 5\n"}, "reference_outputs": ["5 4 3 2 1\n"], "source_document_id": "p02407", "source_text": "Reversing Numbers\n\nWrite a program which reads a sequence and prints it in the reverse order.\n\nInput\n\nThe input is given in the following format:\n\nn\na1 a2 . . . an\n\nn is the size of the sequence and ai is the ith element of the sequence.\n\nOutput\n\nPrint the reversed sequence in a line. Print a single space character between adjacent elements (Note that your program should not put a space character after the last element).\n\nConstraints\n\nn ≤ 100\n\n0 ≤ ai < 1000\n\nSample Input 1\n\n5\n1 2 3 4 5\n\nSample Output 1\n\n5 4 3 2 1\n\nSample Input 2\n\n8\n3 3 4 4 5 8 7 9\n\nSample Output 2\n\n9 7 8 5 4 4 3 3\n\nNote\n\n      解説", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43876}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s201378724", "group_id": "codeNet:p02408", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt()\n val in = List.fill(n, 2)(sc.next())\n val groupedBySuit = in.groupBy(e => e(0))\n\n // ???????????????'S'???????????????'H'???????????????'C'???????????????'D'\n // ????????????????????????????????????????????????????????????????????§???????????????????????????\n val suit = List(\"S\", \"H\", \"C\", \"D\")\n for (s <- suit) {\n if (groupedBySuit.get(s).get.size == 13) {}\n else {\n val numList = groupedBySuit.get(s).get.map(e => e(1).toInt)\n val shortage = (1 to 13).diff(numList).toList.sorted\n shortage.foreach(e => println(s\"${s} ${e}\"))\n }\n }\n}", "language": "Scala", "metadata": {"date": 1451483666, "filename_ext": "scala", "original_language": "Scala", "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/Scala/s201378724.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s201378724", "user_id": "u223249350"}, "prompt_components": {"gold_output": "S 1\nH 3\nH 7\nC 12\nD 8\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt()\n val in = List.fill(n, 2)(sc.next())\n val groupedBySuit = in.groupBy(e => e(0))\n\n // ???????????????'S'???????????????'H'???????????????'C'???????????????'D'\n // ????????????????????????????????????????????????????????????????????§???????????????????????????\n val suit = List(\"S\", \"H\", \"C\", \"D\")\n for (s <- suit) {\n if (groupedBySuit.get(s).get.size == 13) {}\n else {\n val numList = groupedBySuit.get(s).get.map(e => e(1).toInt)\n val shortage = (1 to 13).diff(numList).toList.sorted\n shortage.foreach(e => println(s\"${s} ${e}\"))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 661, "cpu_time_ms": 290, "memory_kb": 45212}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s358230814", "group_id": "codeNet:p02409", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val scanner = new java.util.Scanner(System.in)\n val record = List.fill(4)(List.fill(3)(Array.fill(10)(0)))\n\n val n = scanner.nextInt\n for(_ <- 1 to n) {\n val b, f, r, v = scanner.nextInt\n record(b - 1)(f - 1)(r - 1) = record(b - 1)(f - 1)(r - 1) + v\n }\n\n for(b <- record) {\n for(f <- b) {\n println(\" \" + f.mkString(\" \"))\n }\n println(\"#\" * 20)\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1523799646, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02409.html", "problem_id": "p02409", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02409/input.txt", "sample_output_relpath": "derived/input_output/data/p02409/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02409/Scala/s358230814.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s358230814", "user_id": "u250696856"}, "prompt_components": {"gold_output": " 0 0 8 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n####################\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n####################\n 0 0 0 0 0 0 0 0 0 0\n 0 7 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n####################\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 1 0 0\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val scanner = new java.util.Scanner(System.in)\n val record = List.fill(4)(List.fill(3)(Array.fill(10)(0)))\n\n val n = scanner.nextInt\n for(_ <- 1 to n) {\n val b, f, r, v = scanner.nextInt\n record(b - 1)(f - 1)(r - 1) = record(b - 1)(f - 1)(r - 1) + v\n }\n\n for(b <- record) {\n for(f <- b) {\n println(\" \" + f.mkString(\" \"))\n }\n println(\"#\" * 20)\n }\n }\n}\n", "problem_context": "Official House\n\nYou manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room.\n\nFor each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left.\n\nAssume that initially no person lives in the building.\n\nInput\n\nIn the first line, the number of notices n is given. In the following n lines, a set of four integers b, f, r and v which represents ith notice is given in a line.\n\nOutput\n\nFor each building, print the information of 1st, 2nd and 3rd floor in this order. For each floor information, print the number of tenants of 1st, 2nd, .. and 10th room in this order. Print a single space character before the number of tenants. Print \"####################\" (20 '#') between buildings.\n\nConstraints\n\nNo incorrect building, floor and room numbers are given.\n\n0 ≤ the number of tenants during the management ≤ 9\n\nSample Input\n\n3\n1 1 3 8\n3 2 2 7\n4 3 8 1\n\nSample Output\n\n0 0 8 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n####################\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n####################\n0 0 0 0 0 0 0 0 0 0\n0 7 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n####################\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 1 0 0", "sample_input": "3\n1 1 3 8\n3 2 2 7\n4 3 8 1\n"}, "reference_outputs": [" 0 0 8 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n####################\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n####################\n 0 0 0 0 0 0 0 0 0 0\n 0 7 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n####################\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 1 0 0\n"], "source_document_id": "p02409", "source_text": "Official House\n\nYou manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room.\n\nFor each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left.\n\nAssume that initially no person lives in the building.\n\nInput\n\nIn the first line, the number of notices n is given. In the following n lines, a set of four integers b, f, r and v which represents ith notice is given in a line.\n\nOutput\n\nFor each building, print the information of 1st, 2nd and 3rd floor in this order. For each floor information, print the number of tenants of 1st, 2nd, .. and 10th room in this order. Print a single space character before the number of tenants. Print \"####################\" (20 '#') between buildings.\n\nConstraints\n\nNo incorrect building, floor and room numbers are given.\n\n0 ≤ the number of tenants during the management ≤ 9\n\nSample Input\n\n3\n1 1 3 8\n3 2 2 7\n4 3 8 1\n\nSample Output\n\n0 0 8 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n####################\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n####################\n0 0 0 0 0 0 0 0 0 0\n0 7 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n####################\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 1 0 0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 250, "memory_kb": 44980}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s450649377", "group_id": "codeNet:p02410", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n, m = sc.nextInt()\n val matrix = List.fill(n, m)(sc.nextInt())\n val vector = List.fill(m)(sc.nextInt())\n\n println(matrix.map(multiply(_, vector)).map(_.sum).mkString(\"\\n\"))\n\n def multiply(row: Seq[Int], vector: Seq[Int]): Seq[Int] = row.zip(vector).map(e => e._1 * e._2)\n}", "language": "Scala", "metadata": {"date": 1451499758, "filename_ext": "scala", "original_language": "Scala", "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/Scala/s450649377.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s450649377", "user_id": "u223249350"}, "prompt_components": {"gold_output": "5\n6\n9\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n, m = sc.nextInt()\n val matrix = List.fill(n, m)(sc.nextInt())\n val vector = List.fill(m)(sc.nextInt())\n\n println(matrix.map(multiply(_, vector)).map(_.sum).mkString(\"\\n\"))\n\n def multiply(row: Seq[Int], vector: Seq[Int]): Seq[Int] = row.zip(vector).map(e => e._1 * e._2)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 420, "memory_kb": 59964}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s252858639", "group_id": "codeNet:p02411", "input_text": "import scala.io.StdIn._\n\nobject Main {\n def main(args: Array[String]) {\n def testResultPrint(test: String): Unit ={\n val Array(test1, test2, test3) = test.split(\" \").map(_.toInt)\n val testResult = testCheck(test1, test2, test3)\n if(testResult != \"end\") {\n println(testResult)\n testResultPrint(readLine())\n }\n }\n\n def testCheck(t1: Int, t2: Int, t3: Int): String = {\n val t12 = t1 + t2\n if(t1 + t2 + t3 == -3) \"end\"\n else if(t1 == -1 || t2 == -1 || t12 < 30) \"F\"\n else if(t12 >= 80) \"A\"\n else if(t12 >= 65) \"B\"\n else if(t12 >= 50 || (t12 >= 30 && t3 >= 50)) \"C\"\n else if(t12 >= 30) \"D\"\n else \"end\"\n }\n\n testResultPrint(readLine())\n }\n}", "language": "Scala", "metadata": {"date": 1458119726, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02411.html", "problem_id": "p02411", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02411/input.txt", "sample_output_relpath": "derived/input_output/data/p02411/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02411/Scala/s252858639.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s252858639", "user_id": "u123244675"}, "prompt_components": {"gold_output": "A\nC\nF\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main {\n def main(args: Array[String]) {\n def testResultPrint(test: String): Unit ={\n val Array(test1, test2, test3) = test.split(\" \").map(_.toInt)\n val testResult = testCheck(test1, test2, test3)\n if(testResult != \"end\") {\n println(testResult)\n testResultPrint(readLine())\n }\n }\n\n def testCheck(t1: Int, t2: Int, t3: Int): String = {\n val t12 = t1 + t2\n if(t1 + t2 + t3 == -3) \"end\"\n else if(t1 == -1 || t2 == -1 || t12 < 30) \"F\"\n else if(t12 >= 80) \"A\"\n else if(t12 >= 65) \"B\"\n else if(t12 >= 50 || (t12 >= 30 && t3 >= 50)) \"C\"\n else if(t12 >= 30) \"D\"\n else \"end\"\n }\n\n testResultPrint(readLine())\n }\n}", "problem_context": "Grading\n\nWrite a program which reads a list of student test scores and evaluates the performance for each student.\n\nThe test scores for a student include scores of the midterm examination m (out of 50), the final examination f (out of 50) and the makeup examination r (out of 100). If the student does not take the examination, the score is indicated by -1.\n\nThe final performance of a student is evaluated by the following procedure:\n\nIf the student does not take the midterm or final examination, the student's grade shall be F.\n\nIf the total score of the midterm and final examination is greater than or equal to 80, the student's grade shall be A.\n\nIf the total score of the midterm and final examination is greater than or equal to 65 and less than 80, the student's grade shall be B.\n\nIf the total score of the midterm and final examination is greater than or equal to 50 and less than 65, the student's grade shall be C.\n\nIf the total score of the midterm and final examination is greater than or equal to 30 and less than 50, the student's grade shall be D. However, if the score of the makeup examination is greater than or equal to 50, the grade shall be C.\n\nIf the total score of the midterm and final examination is less than 30, the student's grade shall be F.\n\nInput\n\nThe input consists of multiple datasets. For each dataset, three integers m, f and r are given in a line.\n\nThe input ends with three -1 for m, f and r respectively. Your program should not process for the terminal symbols.\n\nThe number of datasets (the number of students) does not exceed 50.\n\nOutput\n\nFor each dataset, print the grade (A, B, C, D or F) in a line.\n\nSample Input\n\n40 42 -1\n20 30 -1\n0 2 -1\n-1 -1 -1\n\nSample Output\n\nA\nC\nF", "sample_input": "40 42 -1\n20 30 -1\n0 2 -1\n-1 -1 -1\n"}, "reference_outputs": ["A\nC\nF\n"], "source_document_id": "p02411", "source_text": "Grading\n\nWrite a program which reads a list of student test scores and evaluates the performance for each student.\n\nThe test scores for a student include scores of the midterm examination m (out of 50), the final examination f (out of 50) and the makeup examination r (out of 100). If the student does not take the examination, the score is indicated by -1.\n\nThe final performance of a student is evaluated by the following procedure:\n\nIf the student does not take the midterm or final examination, the student's grade shall be F.\n\nIf the total score of the midterm and final examination is greater than or equal to 80, the student's grade shall be A.\n\nIf the total score of the midterm and final examination is greater than or equal to 65 and less than 80, the student's grade shall be B.\n\nIf the total score of the midterm and final examination is greater than or equal to 50 and less than 65, the student's grade shall be C.\n\nIf the total score of the midterm and final examination is greater than or equal to 30 and less than 50, the student's grade shall be D. However, if the score of the makeup examination is greater than or equal to 50, the grade shall be C.\n\nIf the total score of the midterm and final examination is less than 30, the student's grade shall be F.\n\nInput\n\nThe input consists of multiple datasets. For each dataset, three integers m, f and r are given in a line.\n\nThe input ends with three -1 for m, f and r respectively. Your program should not process for the terminal symbols.\n\nThe number of datasets (the number of students) does not exceed 50.\n\nOutput\n\nFor each dataset, print the grade (A, B, C, D or F) in a line.\n\nSample Input\n\n40 42 -1\n20 30 -1\n0 2 -1\n-1 -1 -1\n\nSample Output\n\nA\nC\nF", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 725, "cpu_time_ms": 230, "memory_kb": 43944}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s882481969", "group_id": "codeNet:p02411", "input_text": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n var n:Array[Int] = readLine.split(\" \").map(_.toInt)\n\n while( n(0) != -1 || n(1) != -1 || n(2) != -1 ) {\n val Array(m,f,r) = n\n val score = m+f\n var grade = \"\"\n\n if( m == -1 || f == -1)\n grade = \"F\"\n else if(score >= 80)\n grade = \"A\"\n else if(score < 80 && score >= 65)\n grade = \"B\"\n else if(score < 65 && score >= 50)\n grade = \"C\"\n else if(score < 50 && score >= 30)\n if(r>=50)\n grade = \"C\"\n else\n grade = \"D\"\n else\n grade = \"F\"\n\n println(grade)\n\n\n n = readLine.split(\" \").map(_.toInt)\n }\n}", "language": "Scala", "metadata": {"date": 1482286678, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02411.html", "problem_id": "p02411", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02411/input.txt", "sample_output_relpath": "derived/input_output/data/p02411/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02411/Scala/s882481969.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s882481969", "user_id": "u508732591"}, "prompt_components": {"gold_output": "A\nC\nF\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n var n:Array[Int] = readLine.split(\" \").map(_.toInt)\n\n while( n(0) != -1 || n(1) != -1 || n(2) != -1 ) {\n val Array(m,f,r) = n\n val score = m+f\n var grade = \"\"\n\n if( m == -1 || f == -1)\n grade = \"F\"\n else if(score >= 80)\n grade = \"A\"\n else if(score < 80 && score >= 65)\n grade = \"B\"\n else if(score < 65 && score >= 50)\n grade = \"C\"\n else if(score < 50 && score >= 30)\n if(r>=50)\n grade = \"C\"\n else\n grade = \"D\"\n else\n grade = \"F\"\n\n println(grade)\n\n\n n = readLine.split(\" \").map(_.toInt)\n }\n}", "problem_context": "Grading\n\nWrite a program which reads a list of student test scores and evaluates the performance for each student.\n\nThe test scores for a student include scores of the midterm examination m (out of 50), the final examination f (out of 50) and the makeup examination r (out of 100). If the student does not take the examination, the score is indicated by -1.\n\nThe final performance of a student is evaluated by the following procedure:\n\nIf the student does not take the midterm or final examination, the student's grade shall be F.\n\nIf the total score of the midterm and final examination is greater than or equal to 80, the student's grade shall be A.\n\nIf the total score of the midterm and final examination is greater than or equal to 65 and less than 80, the student's grade shall be B.\n\nIf the total score of the midterm and final examination is greater than or equal to 50 and less than 65, the student's grade shall be C.\n\nIf the total score of the midterm and final examination is greater than or equal to 30 and less than 50, the student's grade shall be D. However, if the score of the makeup examination is greater than or equal to 50, the grade shall be C.\n\nIf the total score of the midterm and final examination is less than 30, the student's grade shall be F.\n\nInput\n\nThe input consists of multiple datasets. For each dataset, three integers m, f and r are given in a line.\n\nThe input ends with three -1 for m, f and r respectively. Your program should not process for the terminal symbols.\n\nThe number of datasets (the number of students) does not exceed 50.\n\nOutput\n\nFor each dataset, print the grade (A, B, C, D or F) in a line.\n\nSample Input\n\n40 42 -1\n20 30 -1\n0 2 -1\n-1 -1 -1\n\nSample Output\n\nA\nC\nF", "sample_input": "40 42 -1\n20 30 -1\n0 2 -1\n-1 -1 -1\n"}, "reference_outputs": ["A\nC\nF\n"], "source_document_id": "p02411", "source_text": "Grading\n\nWrite a program which reads a list of student test scores and evaluates the performance for each student.\n\nThe test scores for a student include scores of the midterm examination m (out of 50), the final examination f (out of 50) and the makeup examination r (out of 100). If the student does not take the examination, the score is indicated by -1.\n\nThe final performance of a student is evaluated by the following procedure:\n\nIf the student does not take the midterm or final examination, the student's grade shall be F.\n\nIf the total score of the midterm and final examination is greater than or equal to 80, the student's grade shall be A.\n\nIf the total score of the midterm and final examination is greater than or equal to 65 and less than 80, the student's grade shall be B.\n\nIf the total score of the midterm and final examination is greater than or equal to 50 and less than 65, the student's grade shall be C.\n\nIf the total score of the midterm and final examination is greater than or equal to 30 and less than 50, the student's grade shall be D. However, if the score of the makeup examination is greater than or equal to 50, the grade shall be C.\n\nIf the total score of the midterm and final examination is less than 30, the student's grade shall be F.\n\nInput\n\nThe input consists of multiple datasets. For each dataset, three integers m, f and r are given in a line.\n\nThe input ends with three -1 for m, f and r respectively. Your program should not process for the terminal symbols.\n\nThe number of datasets (the number of students) does not exceed 50.\n\nOutput\n\nFor each dataset, print the grade (A, B, C, D or F) in a line.\n\nSample Input\n\n40 42 -1\n20 30 -1\n0 2 -1\n-1 -1 -1\n\nSample Output\n\nA\nC\nF", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 44056}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s612948463", "group_id": "codeNet:p02411", "input_text": "/**\n * http://judge.u-aizu.ac.jp/onlinejudge/topic.jsp?cid=ITP1#problems/ITP1_7\n */\nobject Main {\n def main(args: Array[String]): Unit = {\n Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null).map(_.split(\" \").map(_.toInt))\n .map { case Array(m, f, r) => (m, f, r) }\n .takeWhile(_ != (-1, -1, -1))\n .map {\n case (m, f, _) if m == -1 || f == -1 => \"F\"\n case (m, f, _) if 80 <= (m + f) => \"A\"\n case (m, f, _) if 65 until 80 contains (m + f) => \"B\"\n case (m, f, _) if 50 until 65 contains (m + f) => \"C\"\n case (m, f, r) if 30 until 50 contains (m + f) => if (r >= 50) \"C\" else \"D\"\n case (m, f, _) if (m + f) < 30 => \"F\"\n }\n .foreach(println)\n }\n}", "language": "Scala", "metadata": {"date": 1503062202, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02411.html", "problem_id": "p02411", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02411/input.txt", "sample_output_relpath": "derived/input_output/data/p02411/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02411/Scala/s612948463.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s612948463", "user_id": "u757244973"}, "prompt_components": {"gold_output": "A\nC\nF\n", "input_to_evaluate": "/**\n * http://judge.u-aizu.ac.jp/onlinejudge/topic.jsp?cid=ITP1#problems/ITP1_7\n */\nobject Main {\n def main(args: Array[String]): Unit = {\n Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null).map(_.split(\" \").map(_.toInt))\n .map { case Array(m, f, r) => (m, f, r) }\n .takeWhile(_ != (-1, -1, -1))\n .map {\n case (m, f, _) if m == -1 || f == -1 => \"F\"\n case (m, f, _) if 80 <= (m + f) => \"A\"\n case (m, f, _) if 65 until 80 contains (m + f) => \"B\"\n case (m, f, _) if 50 until 65 contains (m + f) => \"C\"\n case (m, f, r) if 30 until 50 contains (m + f) => if (r >= 50) \"C\" else \"D\"\n case (m, f, _) if (m + f) < 30 => \"F\"\n }\n .foreach(println)\n }\n}", "problem_context": "Grading\n\nWrite a program which reads a list of student test scores and evaluates the performance for each student.\n\nThe test scores for a student include scores of the midterm examination m (out of 50), the final examination f (out of 50) and the makeup examination r (out of 100). If the student does not take the examination, the score is indicated by -1.\n\nThe final performance of a student is evaluated by the following procedure:\n\nIf the student does not take the midterm or final examination, the student's grade shall be F.\n\nIf the total score of the midterm and final examination is greater than or equal to 80, the student's grade shall be A.\n\nIf the total score of the midterm and final examination is greater than or equal to 65 and less than 80, the student's grade shall be B.\n\nIf the total score of the midterm and final examination is greater than or equal to 50 and less than 65, the student's grade shall be C.\n\nIf the total score of the midterm and final examination is greater than or equal to 30 and less than 50, the student's grade shall be D. However, if the score of the makeup examination is greater than or equal to 50, the grade shall be C.\n\nIf the total score of the midterm and final examination is less than 30, the student's grade shall be F.\n\nInput\n\nThe input consists of multiple datasets. For each dataset, three integers m, f and r are given in a line.\n\nThe input ends with three -1 for m, f and r respectively. Your program should not process for the terminal symbols.\n\nThe number of datasets (the number of students) does not exceed 50.\n\nOutput\n\nFor each dataset, print the grade (A, B, C, D or F) in a line.\n\nSample Input\n\n40 42 -1\n20 30 -1\n0 2 -1\n-1 -1 -1\n\nSample Output\n\nA\nC\nF", "sample_input": "40 42 -1\n20 30 -1\n0 2 -1\n-1 -1 -1\n"}, "reference_outputs": ["A\nC\nF\n"], "source_document_id": "p02411", "source_text": "Grading\n\nWrite a program which reads a list of student test scores and evaluates the performance for each student.\n\nThe test scores for a student include scores of the midterm examination m (out of 50), the final examination f (out of 50) and the makeup examination r (out of 100). If the student does not take the examination, the score is indicated by -1.\n\nThe final performance of a student is evaluated by the following procedure:\n\nIf the student does not take the midterm or final examination, the student's grade shall be F.\n\nIf the total score of the midterm and final examination is greater than or equal to 80, the student's grade shall be A.\n\nIf the total score of the midterm and final examination is greater than or equal to 65 and less than 80, the student's grade shall be B.\n\nIf the total score of the midterm and final examination is greater than or equal to 50 and less than 65, the student's grade shall be C.\n\nIf the total score of the midterm and final examination is greater than or equal to 30 and less than 50, the student's grade shall be D. However, if the score of the makeup examination is greater than or equal to 50, the grade shall be C.\n\nIf the total score of the midterm and final examination is less than 30, the student's grade shall be F.\n\nInput\n\nThe input consists of multiple datasets. For each dataset, three integers m, f and r are given in a line.\n\nThe input ends with three -1 for m, f and r respectively. Your program should not process for the terminal symbols.\n\nThe number of datasets (the number of students) does not exceed 50.\n\nOutput\n\nFor each dataset, print the grade (A, B, C, D or F) in a line.\n\nSample Input\n\n40 42 -1\n20 30 -1\n0 2 -1\n-1 -1 -1\n\nSample Output\n\nA\nC\nF", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 727, "cpu_time_ms": 230, "memory_kb": 43828}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s645668843", "group_id": "codeNet:p02411", "input_text": "object Main {\n def main(args:Array[String]): Unit = {\n Iterator.continually(readLine())\n .map(s => {\n val xs = s.split(\" \").map(_.toInt)\n (xs(0), xs(1), xs(2))\n })\n .takeWhile{\n case (-1, -1, -1) => false\n case _ => true\n }\n .foreach{s => \n val a = (s._1, s._2, s._3) match {\n case (-1, _, _) => \"F\"\n case (_, -1, _) => \"F\"\n case (m, f, r) if (m + f) >= 80 => \"A\"\n case (m, f, r) if ((m + f) < 80 && (m + f) >= 65) => \"B\"\n case (m, f, r) if ((m + f) < 65 && (m + f) >= 50) => \"C\"\n case (m, f, r) if ((m + f) < 50 && (m + f) >= 30 && r >= 50) => \"C\"\n case (m, f, r) if ((m + f) < 50 && (m + f) >= 30) => \"D\"\n case (m, f, r) if ((m + f) < 30) => \"F\"\n }\n println(a)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1509890590, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02411.html", "problem_id": "p02411", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02411/input.txt", "sample_output_relpath": "derived/input_output/data/p02411/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02411/Scala/s645668843.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s645668843", "user_id": "u072097554"}, "prompt_components": {"gold_output": "A\nC\nF\n", "input_to_evaluate": "object Main {\n def main(args:Array[String]): Unit = {\n Iterator.continually(readLine())\n .map(s => {\n val xs = s.split(\" \").map(_.toInt)\n (xs(0), xs(1), xs(2))\n })\n .takeWhile{\n case (-1, -1, -1) => false\n case _ => true\n }\n .foreach{s => \n val a = (s._1, s._2, s._3) match {\n case (-1, _, _) => \"F\"\n case (_, -1, _) => \"F\"\n case (m, f, r) if (m + f) >= 80 => \"A\"\n case (m, f, r) if ((m + f) < 80 && (m + f) >= 65) => \"B\"\n case (m, f, r) if ((m + f) < 65 && (m + f) >= 50) => \"C\"\n case (m, f, r) if ((m + f) < 50 && (m + f) >= 30 && r >= 50) => \"C\"\n case (m, f, r) if ((m + f) < 50 && (m + f) >= 30) => \"D\"\n case (m, f, r) if ((m + f) < 30) => \"F\"\n }\n println(a)\n }\n }\n}", "problem_context": "Grading\n\nWrite a program which reads a list of student test scores and evaluates the performance for each student.\n\nThe test scores for a student include scores of the midterm examination m (out of 50), the final examination f (out of 50) and the makeup examination r (out of 100). If the student does not take the examination, the score is indicated by -1.\n\nThe final performance of a student is evaluated by the following procedure:\n\nIf the student does not take the midterm or final examination, the student's grade shall be F.\n\nIf the total score of the midterm and final examination is greater than or equal to 80, the student's grade shall be A.\n\nIf the total score of the midterm and final examination is greater than or equal to 65 and less than 80, the student's grade shall be B.\n\nIf the total score of the midterm and final examination is greater than or equal to 50 and less than 65, the student's grade shall be C.\n\nIf the total score of the midterm and final examination is greater than or equal to 30 and less than 50, the student's grade shall be D. However, if the score of the makeup examination is greater than or equal to 50, the grade shall be C.\n\nIf the total score of the midterm and final examination is less than 30, the student's grade shall be F.\n\nInput\n\nThe input consists of multiple datasets. For each dataset, three integers m, f and r are given in a line.\n\nThe input ends with three -1 for m, f and r respectively. Your program should not process for the terminal symbols.\n\nThe number of datasets (the number of students) does not exceed 50.\n\nOutput\n\nFor each dataset, print the grade (A, B, C, D or F) in a line.\n\nSample Input\n\n40 42 -1\n20 30 -1\n0 2 -1\n-1 -1 -1\n\nSample Output\n\nA\nC\nF", "sample_input": "40 42 -1\n20 30 -1\n0 2 -1\n-1 -1 -1\n"}, "reference_outputs": ["A\nC\nF\n"], "source_document_id": "p02411", "source_text": "Grading\n\nWrite a program which reads a list of student test scores and evaluates the performance for each student.\n\nThe test scores for a student include scores of the midterm examination m (out of 50), the final examination f (out of 50) and the makeup examination r (out of 100). If the student does not take the examination, the score is indicated by -1.\n\nThe final performance of a student is evaluated by the following procedure:\n\nIf the student does not take the midterm or final examination, the student's grade shall be F.\n\nIf the total score of the midterm and final examination is greater than or equal to 80, the student's grade shall be A.\n\nIf the total score of the midterm and final examination is greater than or equal to 65 and less than 80, the student's grade shall be B.\n\nIf the total score of the midterm and final examination is greater than or equal to 50 and less than 65, the student's grade shall be C.\n\nIf the total score of the midterm and final examination is greater than or equal to 30 and less than 50, the student's grade shall be D. However, if the score of the makeup examination is greater than or equal to 50, the grade shall be C.\n\nIf the total score of the midterm and final examination is less than 30, the student's grade shall be F.\n\nInput\n\nThe input consists of multiple datasets. For each dataset, three integers m, f and r are given in a line.\n\nThe input ends with three -1 for m, f and r respectively. Your program should not process for the terminal symbols.\n\nThe number of datasets (the number of students) does not exceed 50.\n\nOutput\n\nFor each dataset, print the grade (A, B, C, D or F) in a line.\n\nSample Input\n\n40 42 -1\n20 30 -1\n0 2 -1\n-1 -1 -1\n\nSample Output\n\nA\nC\nF", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 43884}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s773246378", "group_id": "codeNet:p02411", "input_text": "import scala.collection.mutable.ListBuffer\nimport scala.io.StdIn\n\nobject Main extends App {\n\n val result = ListBuffer.empty[String]\n var Array(m, f, r) = Array(0, 0, 0)\n while(m != -1 || f != -1 || r != -1){\n val Array(inm, inf, inr) = StdIn.readLine().split(' ').map(_.toInt)\n m = inm\n f = inf\n r = inr\n val rank = (m, f, r) match {\n case (-1, -1, -1) => \"\"\n case (-1, y, z) => \"F\"\n case ( x, -1, z) => \"F\"\n case ( x, y, z) if x + y >= 80 => \"A\"\n case ( x, y, z) if (65 <= x + y ) && (x + y < 80) => \"B\"\n case ( x, y, z) if (50 <= x + y ) && (x + y < 65) => \"C\"\n case ( x, y, z) if (30 <= x + y ) && (x + y < 50) => {\n if (50 <= z) \"C\" else \"D\"\n }\n case ( x, y, z) if x + y < 30 => \"F\"\n case _ => \"\"\n }\n result += rank\n \n }\n \n print(result.mkString(f\"%n\"))\n //result.foreach(println)\n \n}\n", "language": "Scala", "metadata": {"date": 1524150500, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02411.html", "problem_id": "p02411", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02411/input.txt", "sample_output_relpath": "derived/input_output/data/p02411/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02411/Scala/s773246378.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s773246378", "user_id": "u342234782"}, "prompt_components": {"gold_output": "A\nC\nF\n", "input_to_evaluate": "import scala.collection.mutable.ListBuffer\nimport scala.io.StdIn\n\nobject Main extends App {\n\n val result = ListBuffer.empty[String]\n var Array(m, f, r) = Array(0, 0, 0)\n while(m != -1 || f != -1 || r != -1){\n val Array(inm, inf, inr) = StdIn.readLine().split(' ').map(_.toInt)\n m = inm\n f = inf\n r = inr\n val rank = (m, f, r) match {\n case (-1, -1, -1) => \"\"\n case (-1, y, z) => \"F\"\n case ( x, -1, z) => \"F\"\n case ( x, y, z) if x + y >= 80 => \"A\"\n case ( x, y, z) if (65 <= x + y ) && (x + y < 80) => \"B\"\n case ( x, y, z) if (50 <= x + y ) && (x + y < 65) => \"C\"\n case ( x, y, z) if (30 <= x + y ) && (x + y < 50) => {\n if (50 <= z) \"C\" else \"D\"\n }\n case ( x, y, z) if x + y < 30 => \"F\"\n case _ => \"\"\n }\n result += rank\n \n }\n \n print(result.mkString(f\"%n\"))\n //result.foreach(println)\n \n}\n", "problem_context": "Grading\n\nWrite a program which reads a list of student test scores and evaluates the performance for each student.\n\nThe test scores for a student include scores of the midterm examination m (out of 50), the final examination f (out of 50) and the makeup examination r (out of 100). If the student does not take the examination, the score is indicated by -1.\n\nThe final performance of a student is evaluated by the following procedure:\n\nIf the student does not take the midterm or final examination, the student's grade shall be F.\n\nIf the total score of the midterm and final examination is greater than or equal to 80, the student's grade shall be A.\n\nIf the total score of the midterm and final examination is greater than or equal to 65 and less than 80, the student's grade shall be B.\n\nIf the total score of the midterm and final examination is greater than or equal to 50 and less than 65, the student's grade shall be C.\n\nIf the total score of the midterm and final examination is greater than or equal to 30 and less than 50, the student's grade shall be D. However, if the score of the makeup examination is greater than or equal to 50, the grade shall be C.\n\nIf the total score of the midterm and final examination is less than 30, the student's grade shall be F.\n\nInput\n\nThe input consists of multiple datasets. For each dataset, three integers m, f and r are given in a line.\n\nThe input ends with three -1 for m, f and r respectively. Your program should not process for the terminal symbols.\n\nThe number of datasets (the number of students) does not exceed 50.\n\nOutput\n\nFor each dataset, print the grade (A, B, C, D or F) in a line.\n\nSample Input\n\n40 42 -1\n20 30 -1\n0 2 -1\n-1 -1 -1\n\nSample Output\n\nA\nC\nF", "sample_input": "40 42 -1\n20 30 -1\n0 2 -1\n-1 -1 -1\n"}, "reference_outputs": ["A\nC\nF\n"], "source_document_id": "p02411", "source_text": "Grading\n\nWrite a program which reads a list of student test scores and evaluates the performance for each student.\n\nThe test scores for a student include scores of the midterm examination m (out of 50), the final examination f (out of 50) and the makeup examination r (out of 100). If the student does not take the examination, the score is indicated by -1.\n\nThe final performance of a student is evaluated by the following procedure:\n\nIf the student does not take the midterm or final examination, the student's grade shall be F.\n\nIf the total score of the midterm and final examination is greater than or equal to 80, the student's grade shall be A.\n\nIf the total score of the midterm and final examination is greater than or equal to 65 and less than 80, the student's grade shall be B.\n\nIf the total score of the midterm and final examination is greater than or equal to 50 and less than 65, the student's grade shall be C.\n\nIf the total score of the midterm and final examination is greater than or equal to 30 and less than 50, the student's grade shall be D. However, if the score of the makeup examination is greater than or equal to 50, the grade shall be C.\n\nIf the total score of the midterm and final examination is less than 30, the student's grade shall be F.\n\nInput\n\nThe input consists of multiple datasets. For each dataset, three integers m, f and r are given in a line.\n\nThe input ends with three -1 for m, f and r respectively. Your program should not process for the terminal symbols.\n\nThe number of datasets (the number of students) does not exceed 50.\n\nOutput\n\nFor each dataset, print the grade (A, B, C, D or F) in a line.\n\nSample Input\n\n40 42 -1\n20 30 -1\n0 2 -1\n-1 -1 -1\n\nSample Output\n\nA\nC\nF", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 44120}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s321307109", "group_id": "codeNet:p02412", "input_text": "import scala.io.StdIn.readLine\nimport scala.math.{max,min}\n\nobject Main extends App {\n\n var (n,x) = (0,0)\n while({val Array(n2,x2) = readLine.split(\" \").map(_.toInt);n=n2;x=x2;(n,x)} != (0,0) ) {\n println(\n ( 1 until min(n-1,x/3) ).foldLeft(0) { (sum,i) =>\n sum + (max(i+1,x-i-n) until min(n,(x-i+1)/2)).length\n }\n )\n }\n}", "language": "Scala", "metadata": {"date": 1482337181, "filename_ext": "scala", "original_language": "Scala", "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/Scala/s321307109.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s321307109", "user_id": "u508732591"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.io.StdIn.readLine\nimport scala.math.{max,min}\n\nobject Main extends App {\n\n var (n,x) = (0,0)\n while({val Array(n2,x2) = readLine.split(\" \").map(_.toInt);n=n2;x=x2;(n,x)} != (0,0) ) {\n println(\n ( 1 until min(n-1,x/3) ).foldLeft(0) { (sum,i) =>\n sum + (max(i+1,x-i-n) until min(n,(x-i+1)/2)).length\n }\n )\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 347, "cpu_time_ms": 240, "memory_kb": 44208}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s348637693", "group_id": "codeNet:p02412", "input_text": "import scala.collection.mutable\nimport scala.io.StdIn\n\n/**\n * AOJ\n */\nobject Main {\n\n def main(args: Array[String]): Unit = {\n\n while (true) {\n\n val in = StdIn.readLine().split(\" \").map(_.toInt)\n if (in(0) == 0 && in(1) == 0) { return }\n\n var count = 0\n for(i <- 1 to in(0); j <- 1 to in(0); k <- 1 to in(0)){\n if(Set(i,j,k).size == 3 && i + j + k == in(1)){\n count += 1\n }\n }\n println(count / 6)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1498389056, "filename_ext": "scala", "original_language": "Scala", "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/Scala/s348637693.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Memory Limit Exceeded", "submission_id": "s348637693", "user_id": "u048060093"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.collection.mutable\nimport scala.io.StdIn\n\n/**\n * AOJ\n */\nobject Main {\n\n def main(args: Array[String]): Unit = {\n\n while (true) {\n\n val in = StdIn.readLine().split(\" \").map(_.toInt)\n if (in(0) == 0 && in(1) == 0) { return }\n\n var count = 0\n for(i <- 1 to in(0); j <- 1 to in(0); k <- 1 to in(0)){\n if(Set(i,j,k).size == 3 && i + j + k == in(1)){\n count += 1\n }\n }\n println(count / 6)\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 467, "cpu_time_ms": 770, "memory_kb": 437088}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s546939721", "group_id": "codeNet:p02413", "input_text": "object Main{\n def main(args:Array[String]){\n val sc=new java.util.Scanner(System.in)\n val r,c=sc.nextInt\n val a=Array.fill(r,c)(sc.nextInt)\n a.foreach(b=>println(b.mkString(\" \")+\" \"+b.sum))\n var SUM=0\n for(i<-0 until c){\n var sum=0\n for(j<-0 until r){\n sum+=a(j)(i)\n SUM+=a(j)(i)\n }\n print(sum+\" \")\n }\n println(SUM)\n }\n}", "language": "Scala", "metadata": {"date": 1482322666, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02413.html", "problem_id": "p02413", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02413/input.txt", "sample_output_relpath": "derived/input_output/data/p02413/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02413/Scala/s546939721.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s546939721", "user_id": "u496100636"}, "prompt_components": {"gold_output": "1 1 3 4 5 14\n2 2 2 4 5 15\n3 3 0 1 1 8\n2 3 4 4 6 19\n8 9 9 13 17 56\n", "input_to_evaluate": "object Main{\n def main(args:Array[String]){\n val sc=new java.util.Scanner(System.in)\n val r,c=sc.nextInt\n val a=Array.fill(r,c)(sc.nextInt)\n a.foreach(b=>println(b.mkString(\" \")+\" \"+b.sum))\n var SUM=0\n for(i<-0 until c){\n var sum=0\n for(j<-0 until r){\n sum+=a(j)(i)\n SUM+=a(j)(i)\n }\n print(sum+\" \")\n }\n println(SUM)\n }\n}", "problem_context": "Spreadsheet\n\nYour task is to perform a simple table calculation.\n\nWrite a program which reads the number of rows r, columns c and a table of r × c elements, and prints a new table, which includes the total sum for each row and column.\n\nInput\n\nIn the first line, two integers r and c are given. Next, the table is given by r lines, each of which consists of c integers separated by space characters.\n\nOutput\n\nPrint the new table of (r+1) × (c+1) elements. Put a single space character between adjacent elements. For each row, print the sum of it's elements in the last column. For each column, print the sum of it's elements in the last row. Print the total sum of the elements at the bottom right corner of the table.\n\nConstraints\n\n1 ≤ r, c ≤ 100\n\n0 ≤ an element of the table ≤ 100\n\nSample Input\n\n4 5\n1 1 3 4 5\n2 2 2 4 5\n3 3 0 1 1\n2 3 4 4 6\n\nSample Output\n\n1 1 3 4 5 14\n2 2 2 4 5 15\n3 3 0 1 1 8\n2 3 4 4 6 19\n8 9 9 13 17 56", "sample_input": "4 5\n1 1 3 4 5\n2 2 2 4 5\n3 3 0 1 1\n2 3 4 4 6\n"}, "reference_outputs": ["1 1 3 4 5 14\n2 2 2 4 5 15\n3 3 0 1 1 8\n2 3 4 4 6 19\n8 9 9 13 17 56\n"], "source_document_id": "p02413", "source_text": "Spreadsheet\n\nYour task is to perform a simple table calculation.\n\nWrite a program which reads the number of rows r, columns c and a table of r × c elements, and prints a new table, which includes the total sum for each row and column.\n\nInput\n\nIn the first line, two integers r and c are given. Next, the table is given by r lines, each of which consists of c integers separated by space characters.\n\nOutput\n\nPrint the new table of (r+1) × (c+1) elements. Put a single space character between adjacent elements. For each row, print the sum of it's elements in the last column. For each column, print the sum of it's elements in the last row. Print the total sum of the elements at the bottom right corner of the table.\n\nConstraints\n\n1 ≤ r, c ≤ 100\n\n0 ≤ an element of the table ≤ 100\n\nSample Input\n\n4 5\n1 1 3 4 5\n2 2 2 4 5\n3 3 0 1 1\n2 3 4 4 6\n\nSample Output\n\n1 1 3 4 5 14\n2 2 2 4 5 15\n3 3 0 1 1 8\n2 3 4 4 6 19\n8 9 9 13 17 56", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 380, "memory_kb": 58952}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s397585604", "group_id": "codeNet:p02413", "input_text": "import scala.io.Source\n\nobject Main extends App {\n val lines = Source.stdin.getLines.map(_.split(\" \").map(_.toInt).toList).toList\n val (rows, cols) = (lines(0)(0), lines(0)(1))\n val linesOfNum: List[List[Int]] = lines.tail\n\n\n val newLines: List[Int] = for {\n line <- linesOfNum\n } yield { val str = line.mkString(\" \")\n println(s\"$str ${line.sum}\")\n line.sum\n }\n\n // non-tail-recursive\n def addEachElement(ixx: List[List[Int]]): List[Int] = ixx match {\n case Nil => List(0, 0, 0, 0, 0)\n case h :: tail => (h zip addEachElement(tail)).map { case (i, j) => i + j }\n }\n\n // tail-recursive\n def addEachElement(acc: List[Int], ixx: List[List[Int]]): List[Int] = ixx match {\n case Nil => acc\n case h :: tail => addEachElement((acc zip h).map { case (i, j) => i + j }, tail)\n }\n\n println(addEachElement(linesOfNum).mkString(\" \") + \" \" + newLines.sum)\n // println(addEachElement(List(0, 0, 0, 0, 0), linesOfNum))\n}", "language": "Scala", "metadata": {"date": 1511602195, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02413.html", "problem_id": "p02413", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02413/input.txt", "sample_output_relpath": "derived/input_output/data/p02413/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02413/Scala/s397585604.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s397585604", "user_id": "u387507798"}, "prompt_components": {"gold_output": "1 1 3 4 5 14\n2 2 2 4 5 15\n3 3 0 1 1 8\n2 3 4 4 6 19\n8 9 9 13 17 56\n", "input_to_evaluate": "import scala.io.Source\n\nobject Main extends App {\n val lines = Source.stdin.getLines.map(_.split(\" \").map(_.toInt).toList).toList\n val (rows, cols) = (lines(0)(0), lines(0)(1))\n val linesOfNum: List[List[Int]] = lines.tail\n\n\n val newLines: List[Int] = for {\n line <- linesOfNum\n } yield { val str = line.mkString(\" \")\n println(s\"$str ${line.sum}\")\n line.sum\n }\n\n // non-tail-recursive\n def addEachElement(ixx: List[List[Int]]): List[Int] = ixx match {\n case Nil => List(0, 0, 0, 0, 0)\n case h :: tail => (h zip addEachElement(tail)).map { case (i, j) => i + j }\n }\n\n // tail-recursive\n def addEachElement(acc: List[Int], ixx: List[List[Int]]): List[Int] = ixx match {\n case Nil => acc\n case h :: tail => addEachElement((acc zip h).map { case (i, j) => i + j }, tail)\n }\n\n println(addEachElement(linesOfNum).mkString(\" \") + \" \" + newLines.sum)\n // println(addEachElement(List(0, 0, 0, 0, 0), linesOfNum))\n}", "problem_context": "Spreadsheet\n\nYour task is to perform a simple table calculation.\n\nWrite a program which reads the number of rows r, columns c and a table of r × c elements, and prints a new table, which includes the total sum for each row and column.\n\nInput\n\nIn the first line, two integers r and c are given. Next, the table is given by r lines, each of which consists of c integers separated by space characters.\n\nOutput\n\nPrint the new table of (r+1) × (c+1) elements. Put a single space character between adjacent elements. For each row, print the sum of it's elements in the last column. For each column, print the sum of it's elements in the last row. Print the total sum of the elements at the bottom right corner of the table.\n\nConstraints\n\n1 ≤ r, c ≤ 100\n\n0 ≤ an element of the table ≤ 100\n\nSample Input\n\n4 5\n1 1 3 4 5\n2 2 2 4 5\n3 3 0 1 1\n2 3 4 4 6\n\nSample Output\n\n1 1 3 4 5 14\n2 2 2 4 5 15\n3 3 0 1 1 8\n2 3 4 4 6 19\n8 9 9 13 17 56", "sample_input": "4 5\n1 1 3 4 5\n2 2 2 4 5\n3 3 0 1 1\n2 3 4 4 6\n"}, "reference_outputs": ["1 1 3 4 5 14\n2 2 2 4 5 15\n3 3 0 1 1 8\n2 3 4 4 6 19\n8 9 9 13 17 56\n"], "source_document_id": "p02413", "source_text": "Spreadsheet\n\nYour task is to perform a simple table calculation.\n\nWrite a program which reads the number of rows r, columns c and a table of r × c elements, and prints a new table, which includes the total sum for each row and column.\n\nInput\n\nIn the first line, two integers r and c are given. Next, the table is given by r lines, each of which consists of c integers separated by space characters.\n\nOutput\n\nPrint the new table of (r+1) × (c+1) elements. Put a single space character between adjacent elements. For each row, print the sum of it's elements in the last column. For each column, print the sum of it's elements in the last row. Print the total sum of the elements at the bottom right corner of the table.\n\nConstraints\n\n1 ≤ r, c ≤ 100\n\n0 ≤ an element of the table ≤ 100\n\nSample Input\n\n4 5\n1 1 3 4 5\n2 2 2 4 5\n3 3 0 1 1\n2 3 4 4 6\n\nSample Output\n\n1 1 3 4 5 14\n2 2 2 4 5 15\n3 3 0 1 1 8\n2 3 4 4 6 19\n8 9 9 13 17 56", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1074, "cpu_time_ms": 240, "memory_kb": 44276}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s232005442", "group_id": "codeNet:p02415", "input_text": "object Main{\n def main(args:Array[String]) = {\n io.Source.stdin.mkString.toCharArray.foreach(x => print(swap_case_as_int(x.toInt).toChar))\n println(\"\")\n }\n def swap_case_as_int(int: Int) : Int ={\n if (65 <= int && int <= 90) int + 32\n else if (97 <= int && int <= 122) int - 32\n else int\n }\n}", "language": "Scala", "metadata": {"date": 1446141084, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02415.html", "problem_id": "p02415", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02415/input.txt", "sample_output_relpath": "derived/input_output/data/p02415/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02415/Scala/s232005442.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s232005442", "user_id": "u879226672"}, "prompt_components": {"gold_output": "Fair, later, occasionally cloudy.\n", "input_to_evaluate": "object Main{\n def main(args:Array[String]) = {\n io.Source.stdin.mkString.toCharArray.foreach(x => print(swap_case_as_int(x.toInt).toChar))\n println(\"\")\n }\n def swap_case_as_int(int: Int) : Int ={\n if (65 <= int && int <= 90) int + 32\n else if (97 <= int && int <= 122) int - 32\n else int\n }\n}", "problem_context": "Toggling Cases\n\nWrite a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string.\n\nInput\n\nA string is given in a line.\n\nOutput\n\nPrint the converted string in a line. Note that you do not need to convert any characters other than alphabetical letters.\n\nConstraints\n\nThe length of the input string < 1200\n\nSample Input\n\nfAIR, LATER, OCCASIONALLY CLOUDY.\n\nSample Output\n\nFair, later, occasionally cloudy.", "sample_input": "fAIR, LATER, OCCASIONALLY CLOUDY.\n"}, "reference_outputs": ["Fair, later, occasionally cloudy.\n"], "source_document_id": "p02415", "source_text": "Toggling Cases\n\nWrite a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string.\n\nInput\n\nA string is given in a line.\n\nOutput\n\nPrint the converted string in a line. Note that you do not need to convert any characters other than alphabetical letters.\n\nConstraints\n\nThe length of the input string < 1200\n\nSample Input\n\nfAIR, LATER, OCCASIONALLY CLOUDY.\n\nSample Output\n\nFair, later, occasionally cloudy.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 250, "memory_kb": 43888}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s141477968", "group_id": "codeNet:p02415", "input_text": "object Main{\n def main(args:Array[String]) = {\n io.Source.stdin.mkString.toCharArray.foreach(x => print(swap_case_as_int(x.toInt).toChar))\n }\n def swap_case_as_int(int: Int) : Int ={\n if (65 <= int && int <= 90) int + 32\n else if (97 <= int && int <= 122) int - 32\n else int\n }\n}", "language": "Scala", "metadata": {"date": 1446141133, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02415.html", "problem_id": "p02415", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02415/input.txt", "sample_output_relpath": "derived/input_output/data/p02415/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02415/Scala/s141477968.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s141477968", "user_id": "u879226672"}, "prompt_components": {"gold_output": "Fair, later, occasionally cloudy.\n", "input_to_evaluate": "object Main{\n def main(args:Array[String]) = {\n io.Source.stdin.mkString.toCharArray.foreach(x => print(swap_case_as_int(x.toInt).toChar))\n }\n def swap_case_as_int(int: Int) : Int ={\n if (65 <= int && int <= 90) int + 32\n else if (97 <= int && int <= 122) int - 32\n else int\n }\n}", "problem_context": "Toggling Cases\n\nWrite a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string.\n\nInput\n\nA string is given in a line.\n\nOutput\n\nPrint the converted string in a line. Note that you do not need to convert any characters other than alphabetical letters.\n\nConstraints\n\nThe length of the input string < 1200\n\nSample Input\n\nfAIR, LATER, OCCASIONALLY CLOUDY.\n\nSample Output\n\nFair, later, occasionally cloudy.", "sample_input": "fAIR, LATER, OCCASIONALLY CLOUDY.\n"}, "reference_outputs": ["Fair, later, occasionally cloudy.\n"], "source_document_id": "p02415", "source_text": "Toggling Cases\n\nWrite a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string.\n\nInput\n\nA string is given in a line.\n\nOutput\n\nPrint the converted string in a line. Note that you do not need to convert any characters other than alphabetical letters.\n\nConstraints\n\nThe length of the input string < 1200\n\nSample Input\n\nfAIR, LATER, OCCASIONALLY CLOUDY.\n\nSample Output\n\nFair, later, occasionally cloudy.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 270, "memory_kb": 44152}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s432481225", "group_id": "codeNet:p02415", "input_text": "import scala.io.Source\n\nobject Main extends App {\n val line: String = Source.stdin.getLines.toList.head\n\n def isCapital(c: Char): Boolean = ('A' to 'Z').toList.contains(c)\n\n val str = line.map { c => if (isCapital(c)) c.toString.toLowerCase else c.toString.capitalize }\n\n str.map(print)\n println()\n}", "language": "Scala", "metadata": {"date": 1511662030, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02415.html", "problem_id": "p02415", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02415/input.txt", "sample_output_relpath": "derived/input_output/data/p02415/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02415/Scala/s432481225.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s432481225", "user_id": "u387507798"}, "prompt_components": {"gold_output": "Fair, later, occasionally cloudy.\n", "input_to_evaluate": "import scala.io.Source\n\nobject Main extends App {\n val line: String = Source.stdin.getLines.toList.head\n\n def isCapital(c: Char): Boolean = ('A' to 'Z').toList.contains(c)\n\n val str = line.map { c => if (isCapital(c)) c.toString.toLowerCase else c.toString.capitalize }\n\n str.map(print)\n println()\n}", "problem_context": "Toggling Cases\n\nWrite a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string.\n\nInput\n\nA string is given in a line.\n\nOutput\n\nPrint the converted string in a line. Note that you do not need to convert any characters other than alphabetical letters.\n\nConstraints\n\nThe length of the input string < 1200\n\nSample Input\n\nfAIR, LATER, OCCASIONALLY CLOUDY.\n\nSample Output\n\nFair, later, occasionally cloudy.", "sample_input": "fAIR, LATER, OCCASIONALLY CLOUDY.\n"}, "reference_outputs": ["Fair, later, occasionally cloudy.\n"], "source_document_id": "p02415", "source_text": "Toggling Cases\n\nWrite a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string.\n\nInput\n\nA string is given in a line.\n\nOutput\n\nPrint the converted string in a line. Note that you do not need to convert any characters other than alphabetical letters.\n\nConstraints\n\nThe length of the input string < 1200\n\nSample Input\n\nfAIR, LATER, OCCASIONALLY CLOUDY.\n\nSample Output\n\nFair, later, occasionally cloudy.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 290, "memory_kb": 49904}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s807255595", "group_id": "codeNet:p02416", "input_text": "import io.Source.stdin\n\n/**\n * AOJ\n */\nobject Main {\n\n def main(args: Array[String]): Unit = {\n\n for(line <- stdin.getLines()){\n if(line == \"0\"){return}\n println(line.map(_.toString.toInt).sum)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1499498934, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02416.html", "problem_id": "p02416", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02416/input.txt", "sample_output_relpath": "derived/input_output/data/p02416/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02416/Scala/s807255595.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s807255595", "user_id": "u048060093"}, "prompt_components": {"gold_output": "6\n10\n1\n", "input_to_evaluate": "import io.Source.stdin\n\n/**\n * AOJ\n */\nobject Main {\n\n def main(args: Array[String]): Unit = {\n\n for(line <- stdin.getLines()){\n if(line == \"0\"){return}\n println(line.map(_.toString.toInt).sum)\n }\n }\n}", "problem_context": "Sum of Numbers\n\nWrite a program which reads an integer and prints sum of its digits.\n\nInput\n\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000.\n\nThe input ends with a line including single zero. Your program should not process for this terminal symbol.\n\nOutput\n\nFor each dataset, print the sum of digits in x.\n\nSample Input\n\n123\n55\n1000\n0\n\nSample Output\n\n6\n10\n1", "sample_input": "123\n55\n1000\n0\n"}, "reference_outputs": ["6\n10\n1\n"], "source_document_id": "p02416", "source_text": "Sum of Numbers\n\nWrite a program which reads an integer and prints sum of its digits.\n\nInput\n\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000.\n\nThe input ends with a line including single zero. Your program should not process for this terminal symbol.\n\nOutput\n\nFor each dataset, print the sum of digits in x.\n\nSample Input\n\n123\n55\n1000\n0\n\nSample Output\n\n6\n10\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 44280}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s158205245", "group_id": "codeNet:p02417", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n\n private val alphabets = Array.ofDim[Int](26)\n private val target = StdIn.readLine()\n \n target.foreach{ c =>\n val idx = c.toLower - 'a'\n if(idx >= 0) alphabets(idx) += 1\n }\n print(('a' to 'z').map(f => f.toString + \" : \" + alphabets(f - 'a')).mkString(f\"%n\"))\n \n}\n\n", "language": "Scala", "metadata": {"date": 1524696470, "filename_ext": "scala", "original_language": "Scala", "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/Scala/s158205245.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s158205245", "user_id": "u342234782"}, "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 scala.io.StdIn\n\nobject Main extends App {\n\n private val alphabets = Array.ofDim[Int](26)\n private val target = StdIn.readLine()\n \n target.foreach{ c =>\n val idx = c.toLower - 'a'\n if(idx >= 0) alphabets(idx) += 1\n }\n print(('a' to 'z').map(f => f.toString + \" : \" + alphabets(f - 'a')).mkString(f\"%n\"))\n \n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 250, "memory_kb": 44428}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s446157773", "group_id": "codeNet:p02418", "input_text": "import scala.io.Source\n\nobject Main{\n def main(args: Array[String]){\n val line =\n for{\n in <- Source.stdin.getLines.toList\n } yield in.map(c => c.toLower)\n\n println(if((line(0) + line(0)).contains(line(1))) \"Yes\" else \"No\")\n }\n}", "language": "Scala", "metadata": {"date": 1439347473, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02418.html", "problem_id": "p02418", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02418/input.txt", "sample_output_relpath": "derived/input_output/data/p02418/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02418/Scala/s446157773.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s446157773", "user_id": "u085441951"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.io.Source\n\nobject Main{\n def main(args: Array[String]){\n val line =\n for{\n in <- Source.stdin.getLines.toList\n } yield in.map(c => c.toLower)\n\n println(if((line(0) + line(0)).contains(line(1))) \"Yes\" else \"No\")\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nRing\n\nWrite a program which finds a pattern $p$ in a ring shaped text $s$.\n\nInput\n\nIn the first line, the text $s$ is given.\n\nIn the second line, the pattern $p$ is given.\n\nOutput\n\nIf $p$ is in $s$, print Yes in a line, otherwise No.\n\nConstraints\n\n$1 \\leq $ length of $p \\leq $ length of $s \\leq 100$\n\n$s$ and $p$ consists of lower-case letters\n\nSample Input 1\n\nvanceknowledgetoad\nadvance\n\nSample Output 1\n\nYes\n\nSample Input 2\n\nvanceknowledgetoad\nadvanced\n\nSample Output 2\n\nNo", "sample_input": "vanceknowledgetoad\nadvance\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02418", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nRing\n\nWrite a program which finds a pattern $p$ in a ring shaped text $s$.\n\nInput\n\nIn the first line, the text $s$ is given.\n\nIn the second line, the pattern $p$ is given.\n\nOutput\n\nIf $p$ is in $s$, print Yes in a line, otherwise No.\n\nConstraints\n\n$1 \\leq $ length of $p \\leq $ length of $s \\leq 100$\n\n$s$ and $p$ consists of lower-case letters\n\nSample Input 1\n\nvanceknowledgetoad\nadvance\n\nSample Output 1\n\nYes\n\nSample Input 2\n\nvanceknowledgetoad\nadvanced\n\nSample Output 2\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 255, "cpu_time_ms": 230, "memory_kb": 43936}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s379268019", "group_id": "codeNet:p02419", "input_text": "import scala.io.StdIn._\n\nobject Main {\n def mkInputText(i: Iterator[String]): List[String] = {\n (for(j <- i if j != \"END_OF_TEXT\") yield j.replace(\"\\n\", \"\")).mkString(\" \").split(\" \").toList\n }\n\n def main(args: Array[String]) {\n val searchText = readLine()\n val inputTextList = mkInputText(scala.io.Source.stdin.getLines)\n println(inputTextList.count(_ == searchText))\n }\n}", "language": "Scala", "metadata": {"date": 1458339691, "filename_ext": "scala", "original_language": "Scala", "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/Scala/s379268019.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s379268019", "user_id": "u123244675"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main {\n def mkInputText(i: Iterator[String]): List[String] = {\n (for(j <- i if j != \"END_OF_TEXT\") yield j.replace(\"\\n\", \"\")).mkString(\" \").split(\" \").toList\n }\n\n def main(args: Array[String]) {\n val searchText = readLine()\n val inputTextList = mkInputText(scala.io.Source.stdin.getLines)\n println(inputTextList.count(_ == searchText))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 388, "cpu_time_ms": 220, "memory_kb": 43940}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s187254704", "group_id": "codeNet:p02419", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val scanner = new java.util.Scanner(System.in)\n val w = scanner.next.toLowerCase()\n var c = 0\n while(true) {\n val t = scanner.next\n if(t.equals(\"END_OF_TEXT\")) {\n println(c)\n System.exit(0)\n }\n if(w.equals(t.toLowerCase())) c = c + 1\n }\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1523846031, "filename_ext": "scala", "original_language": "Scala", "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/Scala/s187254704.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s187254704", "user_id": "u250696856"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val scanner = new java.util.Scanner(System.in)\n val w = scanner.next.toLowerCase()\n var c = 0\n while(true) {\n val t = scanner.next\n if(t.equals(\"END_OF_TEXT\")) {\n println(c)\n System.exit(0)\n }\n if(w.equals(t.toLowerCase())) c = c + 1\n }\n }\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 44924}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s313112575", "group_id": "codeNet:p02420", "input_text": "import java.util.Scanner\n\nimport scala.collection.Searching._\nimport scala.annotation.tailrec\nimport scala.collection.immutable.Queue\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(new Node(None, 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n @tailrec\n private def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) => root(p)\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n var S = sc.next\n if (S != \"-\") {\n Array.fill(sc.nextInt) {\n val n = sc.nextInt\n S = S.substring(n) + S.substring(0, n)\n ()\n }\n println(S)\n solve(sc)\n }\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\n\n", "language": "Scala", "metadata": {"date": 1515162492, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02420.html", "problem_id": "p02420", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02420/input.txt", "sample_output_relpath": "derived/input_output/data/p02420/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02420/Scala/s313112575.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s313112575", "user_id": "u018134297"}, "prompt_components": {"gold_output": "aabc\nxyzvw\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.collection.Searching._\nimport scala.annotation.tailrec\nimport scala.collection.immutable.Queue\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(new Node(None, 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n @tailrec\n private def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) => root(p)\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n var S = sc.next\n if (S != \"-\") {\n Array.fill(sc.nextInt) {\n val n = sc.nextInt\n S = S.substring(n) + S.substring(0, n)\n ()\n }\n println(S)\n solve(sc)\n }\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\n\n", "problem_context": "Shuffle\n\nYour task is to shuffle a deck of n cards, each of which is marked by a alphabetical letter.\n\nA single shuffle action takes out h cards from the bottom of the deck and moves them to the top of the deck.\n\nThe deck of cards is represented by a string as follows.\n\nabcdeefab\n\nThe first character and the last character correspond to the card located at the bottom of the deck and the card on the top of the deck respectively.\n\nFor example, a shuffle with h = 4 to the above deck, moves the first 4 characters \"abcd\" to the end of the remaining characters \"eefab\", and generates the following deck:\n\neefababcd\n\nYou can repeat such shuffle operations.\n\nWrite a program which reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput\n\nThe input consists of multiple datasets. Each dataset is given in the following format:\n\nA string which represents a deck\nThe number of shuffle m\nh1\nh2\n.\n.\nhm\n\nThe input ends with a single character '-' for the string.\n\nConstraints\n\nThe length of the string ≤ 200\n\n1 ≤ m ≤ 100\n\n1 ≤ hi < The length of the string\n\nThe number of datasets ≤ 10\n\nOutput\n\nFor each dataset, print a string which represents the final state in a line.\n\nSample Input\n\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output\n\naabc\nxyzvw", "sample_input": "aabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n"}, "reference_outputs": ["aabc\nxyzvw\n"], "source_document_id": "p02420", "source_text": "Shuffle\n\nYour task is to shuffle a deck of n cards, each of which is marked by a alphabetical letter.\n\nA single shuffle action takes out h cards from the bottom of the deck and moves them to the top of the deck.\n\nThe deck of cards is represented by a string as follows.\n\nabcdeefab\n\nThe first character and the last character correspond to the card located at the bottom of the deck and the card on the top of the deck respectively.\n\nFor example, a shuffle with h = 4 to the above deck, moves the first 4 characters \"abcd\" to the end of the remaining characters \"eefab\", and generates the following deck:\n\neefababcd\n\nYou can repeat such shuffle operations.\n\nWrite a program which reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput\n\nThe input consists of multiple datasets. Each dataset is given in the following format:\n\nA string which represents a deck\nThe number of shuffle m\nh1\nh2\n.\n.\nhm\n\nThe input ends with a single character '-' for the string.\n\nConstraints\n\nThe length of the string ≤ 200\n\n1 ≤ m ≤ 100\n\n1 ≤ hi < The length of the string\n\nThe number of datasets ≤ 10\n\nOutput\n\nFor each dataset, print a string which represents the final state in a line.\n\nSample Input\n\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output\n\naabc\nxyzvw", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1315, "cpu_time_ms": 260, "memory_kb": 45280}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s911416714", "group_id": "codeNet:p02421", "input_text": "import scala.io.StdIn\n\n/**\n * AOJ\n */\nobject Main {\n\n def main(args: Array[String]): Unit = {\n\n val p = new Point(0,0)\n val n = StdIn.readInt()\n for(_ <- 1 to n){\n val animals = StdIn.readLine().split(\" \")\n if(animals(0) > animals(1)){\n p.taro += 3\n } else if(animals(0) < animals(1)){\n p.hanako += 3\n } else {\n p.taro += 1\n p.hanako += 1\n }\n }\n println(p.taro + \" \" + p.hanako)\n }\n class Point(var taro:Int,var hanako:Int)\n}", "language": "Scala", "metadata": {"date": 1500123491, "filename_ext": "scala", "original_language": "Scala", "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/Scala/s911416714.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s911416714", "user_id": "u048060093"}, "prompt_components": {"gold_output": "1 7\n", "input_to_evaluate": "import scala.io.StdIn\n\n/**\n * AOJ\n */\nobject Main {\n\n def main(args: Array[String]): Unit = {\n\n val p = new Point(0,0)\n val n = StdIn.readInt()\n for(_ <- 1 to n){\n val animals = StdIn.readLine().split(\" \")\n if(animals(0) > animals(1)){\n p.taro += 3\n } else if(animals(0) < animals(1)){\n p.hanako += 3\n } else {\n p.taro += 1\n p.hanako += 1\n }\n }\n println(p.taro + \" \" + p.hanako)\n }\n class Point(var taro:Int,var hanako:Int)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 44056}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s299367182", "group_id": "codeNet:p02431", "input_text": "import scala.collection.mutable.ArrayBuffer\nimport scala.io.StdIn\n\nobject Main extends App {\n\n\n //val a = List.empty[Int]\n val a = ArrayBuffer.empty[Int]\n\n // 2,147,483,647\n def pushBuck(x: Int) = a.append(x)\n\n def popBuck() = if(a.nonEmpty) a.remove(a.size - 1)\n\n def randomAccess(i: Int): Int = a(i)\n\n val q = StdIn.readLine().trim.toInt\n (0 until q).foreach { i =>\n val input = StdIn.readLine()\n val temp = if (input.startsWith(\"2\")) Array(2, 0) else input.split(' ').map(_.toInt)\n val (cmd, x): (Int, Int) = (temp(0), temp(1))\n\n cmd match {\n case 0 =>\n pushBuck(x)\n case 1 => println(randomAccess(x))\n case 2 =>\n popBuck()\n }\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1530331216, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02431.html", "problem_id": "p02431", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02431/input.txt", "sample_output_relpath": "derived/input_output/data/p02431/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02431/Scala/s299367182.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s299367182", "user_id": "u342234782"}, "prompt_components": {"gold_output": "1\n2\n4\n", "input_to_evaluate": "import scala.collection.mutable.ArrayBuffer\nimport scala.io.StdIn\n\nobject Main extends App {\n\n\n //val a = List.empty[Int]\n val a = ArrayBuffer.empty[Int]\n\n // 2,147,483,647\n def pushBuck(x: Int) = a.append(x)\n\n def popBuck() = if(a.nonEmpty) a.remove(a.size - 1)\n\n def randomAccess(i: Int): Int = a(i)\n\n val q = StdIn.readLine().trim.toInt\n (0 until q).foreach { i =>\n val input = StdIn.readLine()\n val temp = if (input.startsWith(\"2\")) Array(2, 0) else input.split(' ').map(_.toInt)\n val (cmd, x): (Int, Int) = (temp(0), temp(1))\n\n cmd match {\n case 0 =>\n pushBuck(x)\n case 1 => println(randomAccess(x))\n case 2 =>\n popBuck()\n }\n }\n}\n\n", "problem_context": "Vector\n\nFor a dynamic array $A = \\{a_0, a_1, ...\\}$ of integers, perform a sequence of the following operations:\n\npushBack($x$): add element $x$ at the end of $A$\n\nrandomAccess($p$):print element $a_p$\n\npopBack(): delete the last element of $A$\n\n$A$ 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$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 $p$\n\nor\n\n2\n\nwhere the first digits 0, 1 and 2 represent pushBack, randomAccess and popBack operations respectively.\n\nrandomAccess and popBack operations will not be given for an empty array.\n\nOutput\n\nFor each randomAccess, print $a_p$ in a line.\n\nConstraints\n\n$1 \\leq q \\leq 200,000$\n\n$0 \\leq p < $ the size of $A$\n\n$-1,000,000,000 \\leq x \\leq 1,000,000,000$\n\nSample Input 1\n\n8\n0 1\n0 2\n0 3\n2\n0 4\n1 0\n1 1\n1 2\n\nSample Output 1\n\n1\n2\n4", "sample_input": "8\n0 1\n0 2\n0 3\n2\n0 4\n1 0\n1 1\n1 2\n"}, "reference_outputs": ["1\n2\n4\n"], "source_document_id": "p02431", "source_text": "Vector\n\nFor a dynamic array $A = \\{a_0, a_1, ...\\}$ of integers, perform a sequence of the following operations:\n\npushBack($x$): add element $x$ at the end of $A$\n\nrandomAccess($p$):print element $a_p$\n\npopBack(): delete the last element of $A$\n\n$A$ 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$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 $p$\n\nor\n\n2\n\nwhere the first digits 0, 1 and 2 represent pushBack, randomAccess and popBack operations respectively.\n\nrandomAccess and popBack operations will not be given for an empty array.\n\nOutput\n\nFor each randomAccess, print $a_p$ in a line.\n\nConstraints\n\n$1 \\leq q \\leq 200,000$\n\n$0 \\leq p < $ the size of $A$\n\n$-1,000,000,000 \\leq x \\leq 1,000,000,000$\n\nSample Input 1\n\n8\n0 1\n0 2\n0 3\n2\n0 4\n1 0\n1 1\n1 2\n\nSample Output 1\n\n1\n2\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 689, "cpu_time_ms": 1310, "memory_kb": 184384}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s758544591", "group_id": "codeNet:p02431", "input_text": "import scala.collection.mutable.ArrayBuffer\nimport scala.io.StdIn.{readInt, readLine}\n\nobject Main extends App {\n val pushBack = 0\n val randomAccess = 1\n val popBack = 2\n\n val n = readInt()\n val lines = Iterator.fill(n)(readLine())\n\n val orders = lines.map { _.split(\" \").map { _.toInt } }\n var xs = Vector[Int]()\n orders.foreach {\n case Array(`pushBack`, x) => xs = xs :+ x\n case Array(`randomAccess`, x) => println(xs(x))\n case Array(`popBack`) => xs = xs.init\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1590188674, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02431.html", "problem_id": "p02431", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02431/input.txt", "sample_output_relpath": "derived/input_output/data/p02431/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02431/Scala/s758544591.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s758544591", "user_id": "u912124184"}, "prompt_components": {"gold_output": "1\n2\n4\n", "input_to_evaluate": "import scala.collection.mutable.ArrayBuffer\nimport scala.io.StdIn.{readInt, readLine}\n\nobject Main extends App {\n val pushBack = 0\n val randomAccess = 1\n val popBack = 2\n\n val n = readInt()\n val lines = Iterator.fill(n)(readLine())\n\n val orders = lines.map { _.split(\" \").map { _.toInt } }\n var xs = Vector[Int]()\n orders.foreach {\n case Array(`pushBack`, x) => xs = xs :+ x\n case Array(`randomAccess`, x) => println(xs(x))\n case Array(`popBack`) => xs = xs.init\n }\n}\n\n", "problem_context": "Vector\n\nFor a dynamic array $A = \\{a_0, a_1, ...\\}$ of integers, perform a sequence of the following operations:\n\npushBack($x$): add element $x$ at the end of $A$\n\nrandomAccess($p$):print element $a_p$\n\npopBack(): delete the last element of $A$\n\n$A$ 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$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 $p$\n\nor\n\n2\n\nwhere the first digits 0, 1 and 2 represent pushBack, randomAccess and popBack operations respectively.\n\nrandomAccess and popBack operations will not be given for an empty array.\n\nOutput\n\nFor each randomAccess, print $a_p$ in a line.\n\nConstraints\n\n$1 \\leq q \\leq 200,000$\n\n$0 \\leq p < $ the size of $A$\n\n$-1,000,000,000 \\leq x \\leq 1,000,000,000$\n\nSample Input 1\n\n8\n0 1\n0 2\n0 3\n2\n0 4\n1 0\n1 1\n1 2\n\nSample Output 1\n\n1\n2\n4", "sample_input": "8\n0 1\n0 2\n0 3\n2\n0 4\n1 0\n1 1\n1 2\n"}, "reference_outputs": ["1\n2\n4\n"], "source_document_id": "p02431", "source_text": "Vector\n\nFor a dynamic array $A = \\{a_0, a_1, ...\\}$ of integers, perform a sequence of the following operations:\n\npushBack($x$): add element $x$ at the end of $A$\n\nrandomAccess($p$):print element $a_p$\n\npopBack(): delete the last element of $A$\n\n$A$ 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$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 $p$\n\nor\n\n2\n\nwhere the first digits 0, 1 and 2 represent pushBack, randomAccess and popBack operations respectively.\n\nrandomAccess and popBack operations will not be given for an empty array.\n\nOutput\n\nFor each randomAccess, print $a_p$ in a line.\n\nConstraints\n\n$1 \\leq q \\leq 200,000$\n\n$0 \\leq p < $ the size of $A$\n\n$-1,000,000,000 \\leq x \\leq 1,000,000,000$\n\nSample Input 1\n\n8\n0 1\n0 2\n0 3\n2\n0 4\n1 0\n1 1\n1 2\n\nSample Output 1\n\n1\n2\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1190, "memory_kb": 267556}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s706094324", "group_id": "codeNet:p02443", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n \n val n = StdIn.readLine().toInt\n val a = StdIn.readLine().split(\" \")\n val q = StdIn.readLine().toInt\n\n (0 until q).foreach { i =>\n val qa = StdIn.readLine().split(\" \").map(_.toInt)\n val buff = a.slice(qa(0), qa(1)).reverse\n buff.zipWithIndex.foreach{ case (s, index) =>\n a(qa(0) + index) = s\n }\n }\n println(a.mkString(\" \"))\n \n}\n", "language": "Scala", "metadata": {"date": 1531084931, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02443.html", "problem_id": "p02443", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02443/input.txt", "sample_output_relpath": "derived/input_output/data/p02443/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02443/Scala/s706094324.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s706094324", "user_id": "u342234782"}, "prompt_components": {"gold_output": "1 6 5 8 7 2 3 4\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n \n val n = StdIn.readLine().toInt\n val a = StdIn.readLine().split(\" \")\n val q = StdIn.readLine().toInt\n\n (0 until q).foreach { i =>\n val qa = StdIn.readLine().split(\" \").map(_.toInt)\n val buff = a.slice(qa(0), qa(1)).reverse\n buff.zipWithIndex.foreach{ case (s, index) =>\n a(qa(0) + index) = s\n }\n }\n println(a.mkString(\" \"))\n \n}\n", "problem_context": "Reverse\n\nWrite a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and reverse specified elements by a list of the following operation:\n\nreverse($b, e$): reverse the order of $a_b, a_{b+1}, ..., a_{e-1}$\n\nInput\n\nThe input is given in the following format.\n\n$n$\n$a_0 \\; a_1 \\; ...,\\; a_{n-1}$\n$q$\n$b_1 \\; e_1$\n$b_2 \\; e_2$\n:\n$b_{q} \\; b_{q}$\n\nIn the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by two integers $b_i \\; e_i$ in the following $q$ lines.\n\nOutput\n\nPrint all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element.\n\nConstraints\n\n$1 \\leq n \\leq 1,000$\n\n$-1,000,000,000 \\leq a_i \\leq 1,000,000,000$\n\n$1 \\leq q \\leq 1,000$\n\n$0 \\leq b < e \\leq n$\n\nSample Input 1\n\n8\n1 2 3 4 5 6 7 8\n2\n1 6\n3 8\n\nSample Output 1\n\n1 6 5 8 7 2 3 4", "sample_input": "8\n1 2 3 4 5 6 7 8\n2\n1 6\n3 8\n"}, "reference_outputs": ["1 6 5 8 7 2 3 4\n"], "source_document_id": "p02443", "source_text": "Reverse\n\nWrite a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and reverse specified elements by a list of the following operation:\n\nreverse($b, e$): reverse the order of $a_b, a_{b+1}, ..., a_{e-1}$\n\nInput\n\nThe input is given in the following format.\n\n$n$\n$a_0 \\; a_1 \\; ...,\\; a_{n-1}$\n$q$\n$b_1 \\; e_1$\n$b_2 \\; e_2$\n:\n$b_{q} \\; b_{q}$\n\nIn the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by two integers $b_i \\; e_i$ in the following $q$ lines.\n\nOutput\n\nPrint all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element.\n\nConstraints\n\n$1 \\leq n \\leq 1,000$\n\n$-1,000,000,000 \\leq a_i \\leq 1,000,000,000$\n\n$1 \\leq q \\leq 1,000$\n\n$0 \\leq b < e \\leq n$\n\nSample Input 1\n\n8\n1 2 3 4 5 6 7 8\n2\n1 6\n3 8\n\nSample Output 1\n\n1 6 5 8 7 2 3 4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 350, "memory_kb": 56360}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s435208411", "group_id": "codeNet:p02467", "input_text": "import collection.mutable.ListBuffer\nimport io.StdIn\n\nobject Main extends App {\n\n def primeFact(n:Long):List[Long] = {\n val ret = ListBuffer.empty[Long]\n\n var num = n\n var root = 2L\n while(root * root <= num) {\n if(num % root == 0L) {\n ret += root\n num /= root\n }\n else root += 1L\n }\n\n (ret += num).toList\n }\n\n val n = StdIn.readLong\n\n val ans = primeFact(n)\n println(n + \": \" + ans.mkString(\" \"))\n}\n", "language": "Scala", "metadata": {"date": 1545885343, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02467.html", "problem_id": "p02467", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02467/input.txt", "sample_output_relpath": "derived/input_output/data/p02467/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02467/Scala/s435208411.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s435208411", "user_id": "u768801062"}, "prompt_components": {"gold_output": "12: 2 2 3\n", "input_to_evaluate": "import collection.mutable.ListBuffer\nimport io.StdIn\n\nobject Main extends App {\n\n def primeFact(n:Long):List[Long] = {\n val ret = ListBuffer.empty[Long]\n\n var num = n\n var root = 2L\n while(root * root <= num) {\n if(num % root == 0L) {\n ret += root\n num /= root\n }\n else root += 1L\n }\n\n (ret += num).toList\n }\n\n val n = StdIn.readLong\n\n val ans = primeFact(n)\n println(n + \": \" + ans.mkString(\" \"))\n}\n", "problem_context": "Prime Factorization\n\nFactorize a given integer n.\n\nInput\n\nn\n\nAn integer n is given in a line.\n\nOutput\n\nPrint the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a space before each prime factor.\n\nConstraints\n\n2 ≤ n ≤ 109\n\nSample Input 1\n\n12\n\nSample Output 1\n\n12: 2 2 3\n\nSample Input 2\n\n126\n\nSample Output 2\n\n126: 2 3 3 7", "sample_input": "12\n"}, "reference_outputs": ["12: 2 2 3\n"], "source_document_id": "p02467", "source_text": "Prime Factorization\n\nFactorize a given integer n.\n\nInput\n\nn\n\nAn integer n is given in a line.\n\nOutput\n\nPrint the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a space before each prime factor.\n\nConstraints\n\n2 ≤ n ≤ 109\n\nSample Input 1\n\n12\n\nSample Output 1\n\n12: 2 2 3\n\nSample Input 2\n\n126\n\nSample Output 2\n\n126: 2 3 3 7", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 260, "memory_kb": 43828}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s042325360", "group_id": "codeNet:p02469", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val _ = io.StdIn.readInt()\n val an: Iterator[Int] = io.StdIn.readLine().split(\" \").map(_.toInt).toIterator\n var acc = an.next()\n while(an.hasNext) acc = lcm(acc, an.next())\n println(acc)\n }\n def lcm(m: Int, n: Int): Int = (m * n) / gcd(m, n)\n def gcd(x: Int, y: Int): Int = {\n var (m, n) = if (x < y) (y, x) else (x, y)\n while(n > 0) {\n val tmp = m\n m = n\n n = tmp % n\n }\n m\n }\n}", "language": "Scala", "metadata": {"date": 1513016318, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02469.html", "problem_id": "p02469", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02469/input.txt", "sample_output_relpath": "derived/input_output/data/p02469/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02469/Scala/s042325360.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s042325360", "user_id": "u995793569"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val _ = io.StdIn.readInt()\n val an: Iterator[Int] = io.StdIn.readLine().split(\" \").map(_.toInt).toIterator\n var acc = an.next()\n while(an.hasNext) acc = lcm(acc, an.next())\n println(acc)\n }\n def lcm(m: Int, n: Int): Int = (m * n) / gcd(m, n)\n def gcd(x: Int, y: Int): Int = {\n var (m, n) = if (x < y) (y, x) else (x, y)\n while(n > 0) {\n val tmp = m\n m = n\n n = tmp % n\n }\n m\n }\n}", "problem_context": "Least Common Multiple\n\nFind the least common multiple (LCM) of given n integers.\n\nInput\n\nn\na1 a2 ... an\n\nn is given in the first line. Then, n integers are given in the second line.\n\nOutput\n\nPrint the least common multiple of the given integers in a line.\n\nConstraints\n\n2 ≤ n ≤ 10\n\n1 ≤ ai ≤ 1000\n\nProduct of given integers ai(i = 1, 2, ... n) does not exceed 231-1\n\nSample Input 1\n\n3\n3 4 6\n\nSample Output 1\n\n12\n\nSample Input 2\n\n4\n1 2 3 5\n\nSample Output 2\n\n30", "sample_input": "3\n3 4 6\n"}, "reference_outputs": ["12\n"], "source_document_id": "p02469", "source_text": "Least Common Multiple\n\nFind the least common multiple (LCM) of given n integers.\n\nInput\n\nn\na1 a2 ... an\n\nn is given in the first line. Then, n integers are given in the second line.\n\nOutput\n\nPrint the least common multiple of the given integers in a line.\n\nConstraints\n\n2 ≤ n ≤ 10\n\n1 ≤ ai ≤ 1000\n\nProduct of given integers ai(i = 1, 2, ... n) does not exceed 231-1\n\nSample Input 1\n\n3\n3 4 6\n\nSample Output 1\n\n12\n\nSample Input 2\n\n4\n1 2 3 5\n\nSample Output 2\n\n30", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 270, "memory_kb": 43968}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s500760915", "group_id": "codeNet:p02470", "input_text": "object Main extends App {\n val n = io.StdIn.readInt()\n\n println(phi(n))\n\n def phi(n: Int): Int =\n if (isPrime(n)) n-1\n else {\n val pfs = primeFactors(n)\n val x = n*pfs.map(1 - 1/_.toDouble).product\n x.toInt\n }\n def primeFactors(n: Int): Seq[Int] = {\n if (n == 1) Seq()\n else if (isPrime(n)) Seq(n)\n else {\n var x = n\n val p = rho(n)\n if (isPrime(p)) {\n while(x % p == 0) x /= p\n p +: primeFactors(x)\n }\n else {\n val ps = primeFactors(p)\n ps foreach (p => while(x % p == 0) x /= p)\n ps ++ primeFactors(x)\n }\n }\n }\n\n def rho(n: Int): Int = {\n def f(x: Int, c: Int): Int = (x * x + c) % n\n def loop(x: Int, y: Int, d: Int, c: Int = 1): Int =\n if (d != 1) {\n if (d == n) loop(2,2,1,c+1)\n else d\n }\n else {\n val a = f(x, c)\n val b = f(f(y, c), c)\n loop(a, b, gcd(Math.abs(a-b), n), c)\n }\n if (n % 2 == 0) 2\n else loop(2,2,1)\n }\n def gcd(x: Int, y: Int): Int = {\n if (x < y) gcd(y, x)\n else {\n if (y > 0) {\n val r = x % y\n gcd(y, r)\n } else x\n }\n }\n def isPrime(n: Int): Boolean = Primes.miller_rabin_test(n)\n object Primes {\n private def mod_exp(x: BigInt, n: Int, m: Int): BigInt = {\n def loop(x: BigInt, n: Int, acc: BigInt): BigInt = {\n if (n == 0) acc\n else loop (\n (x * x) % m,\n n >> 1,\n if ((n & 1) == 1) (acc * x) % m else acc\n )\n }\n loop(x,n,1)\n }\n private def div_pow_2(d: Int, s: Int = 0): (Int, Int) ={\n if ((d % 2) != 0) (d,s)\n else div_pow_2(d/2, s+1)\n }\n\n private def miller_rabin(n: Int, a: Int): Boolean = {\n val (d,s): (Int, Int) = div_pow_2(n-1)\n val a_exp_d: BigInt = mod_exp(a,d,n)\n def double(x: BigInt): BigInt = mod_exp(x,2,n)\n def loop(e: BigInt, i: Int): Boolean = {\n if (i == 0) false\n else if (e == n-1) true\n else loop(double(e), i-1)\n }\n a_exp_d == 1 || loop(a_exp_d, s)\n }\n def miller_rabin_test(n: Int, k: Int = 20): Boolean = {\n def loop(i: Int): Boolean = {\n if (i == 0) true\n else {\n val a = scala.util.Random.nextInt(n-1)+1\n if (miller_rabin(n,a)) loop(i-1)\n else false\n }\n }\n if (n < 2) false\n else loop(k)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1512106721, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02470.html", "problem_id": "p02470", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02470/input.txt", "sample_output_relpath": "derived/input_output/data/p02470/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02470/Scala/s500760915.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s500760915", "user_id": "u995793569"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n val n = io.StdIn.readInt()\n\n println(phi(n))\n\n def phi(n: Int): Int =\n if (isPrime(n)) n-1\n else {\n val pfs = primeFactors(n)\n val x = n*pfs.map(1 - 1/_.toDouble).product\n x.toInt\n }\n def primeFactors(n: Int): Seq[Int] = {\n if (n == 1) Seq()\n else if (isPrime(n)) Seq(n)\n else {\n var x = n\n val p = rho(n)\n if (isPrime(p)) {\n while(x % p == 0) x /= p\n p +: primeFactors(x)\n }\n else {\n val ps = primeFactors(p)\n ps foreach (p => while(x % p == 0) x /= p)\n ps ++ primeFactors(x)\n }\n }\n }\n\n def rho(n: Int): Int = {\n def f(x: Int, c: Int): Int = (x * x + c) % n\n def loop(x: Int, y: Int, d: Int, c: Int = 1): Int =\n if (d != 1) {\n if (d == n) loop(2,2,1,c+1)\n else d\n }\n else {\n val a = f(x, c)\n val b = f(f(y, c), c)\n loop(a, b, gcd(Math.abs(a-b), n), c)\n }\n if (n % 2 == 0) 2\n else loop(2,2,1)\n }\n def gcd(x: Int, y: Int): Int = {\n if (x < y) gcd(y, x)\n else {\n if (y > 0) {\n val r = x % y\n gcd(y, r)\n } else x\n }\n }\n def isPrime(n: Int): Boolean = Primes.miller_rabin_test(n)\n object Primes {\n private def mod_exp(x: BigInt, n: Int, m: Int): BigInt = {\n def loop(x: BigInt, n: Int, acc: BigInt): BigInt = {\n if (n == 0) acc\n else loop (\n (x * x) % m,\n n >> 1,\n if ((n & 1) == 1) (acc * x) % m else acc\n )\n }\n loop(x,n,1)\n }\n private def div_pow_2(d: Int, s: Int = 0): (Int, Int) ={\n if ((d % 2) != 0) (d,s)\n else div_pow_2(d/2, s+1)\n }\n\n private def miller_rabin(n: Int, a: Int): Boolean = {\n val (d,s): (Int, Int) = div_pow_2(n-1)\n val a_exp_d: BigInt = mod_exp(a,d,n)\n def double(x: BigInt): BigInt = mod_exp(x,2,n)\n def loop(e: BigInt, i: Int): Boolean = {\n if (i == 0) false\n else if (e == n-1) true\n else loop(double(e), i-1)\n }\n a_exp_d == 1 || loop(a_exp_d, s)\n }\n def miller_rabin_test(n: Int, k: Int = 20): Boolean = {\n def loop(i: Int): Boolean = {\n if (i == 0) true\n else {\n val a = scala.util.Random.nextInt(n-1)+1\n if (miller_rabin(n,a)) loop(i-1)\n else false\n }\n }\n if (n < 2) false\n else loop(k)\n }\n }\n}", "problem_context": "Euler's Phi Function\n\nFor given integer n, count the totatives of n, that is, the positive integers less than or equal to n that are relatively prime to n.\n\nInput\n\nn\n\nAn integer n (1 ≤ n ≤ 1000000000).\n\nOutput\n\nThe number of totatives in a line.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n2\n\nSample Input 2\n\n1000000\n\nSample Output 2\n\n400000", "sample_input": "6\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02470", "source_text": "Euler's Phi Function\n\nFor given integer n, count the totatives of n, that is, the positive integers less than or equal to n that are relatively prime to n.\n\nInput\n\nn\n\nAn integer n (1 ≤ n ≤ 1000000000).\n\nOutput\n\nThe number of totatives in a line.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n2\n\nSample Input 2\n\n1000000\n\nSample Output 2\n\n400000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2374, "cpu_time_ms": 250, "memory_kb": 44608}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s651994882", "group_id": "codeNet:p02471", "input_text": "import scala.io.Source.stdin\n\nobject Main {\n\n def euclid(m:Int, n:Int):(Int, Int) = {\n if(m==0) {\n (0,1)\n } else {\n val (x,y) = euclid(n%m,m)\n if(x*m+y*n == x*n+y*m) {\n if(y-(n/m)*x < x)\n (y-(n/m)*x, x)\n else\n (x, y-(n/m)*x)\n } else {\n (y-(n/m)*x, x)\n }\n }\n }\n def main(args:Array[String]) =\n stdin.getLines.foreach { s=>\n val n = s.split(\" \").map(_.toInt)\n val (x,y) = euclid(n(0),n(1))\n println(x+\" \"+y)\n }\n}", "language": "Scala", "metadata": {"date": 1493819806, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02471.html", "problem_id": "p02471", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02471/input.txt", "sample_output_relpath": "derived/input_output/data/p02471/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02471/Scala/s651994882.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s651994882", "user_id": "u508732591"}, "prompt_components": {"gold_output": "1 0\n", "input_to_evaluate": "import scala.io.Source.stdin\n\nobject Main {\n\n def euclid(m:Int, n:Int):(Int, Int) = {\n if(m==0) {\n (0,1)\n } else {\n val (x,y) = euclid(n%m,m)\n if(x*m+y*n == x*n+y*m) {\n if(y-(n/m)*x < x)\n (y-(n/m)*x, x)\n else\n (x, y-(n/m)*x)\n } else {\n (y-(n/m)*x, x)\n }\n }\n }\n def main(args:Array[String]) =\n stdin.getLines.foreach { s=>\n val n = s.split(\" \").map(_.toInt)\n val (x,y) = euclid(n(0),n(1))\n println(x+\" \"+y)\n }\n}", "problem_context": "Extended Euclid Algorithm\n\nGiven positive integers a and b, find the integer solution (x, y) to ax + by = gcd(a, b), where gcd(a, b) is the greatest common divisor of a and b.\n\nInput\n\na b\n\nTwo positive integers a and b are given separated by a space in a line.\n\nOutput\n\nPrint two integers x and y separated by a space. If there are several pairs of such x and y, print that pair for which |x| + |y| is the minimal (primarily) and x ≤ y (secondarily).\n\nConstraints\n\n1 ≤ a, b ≤ 109\n\nSample Input 1\n\n4 12\n\nSample Output 1\n\n1 0\n\nSample Input 2\n\n3 8\n\nSample Output 2\n\n3 -1", "sample_input": "4 12\n"}, "reference_outputs": ["1 0\n"], "source_document_id": "p02471", "source_text": "Extended Euclid Algorithm\n\nGiven positive integers a and b, find the integer solution (x, y) to ax + by = gcd(a, b), where gcd(a, b) is the greatest common divisor of a and b.\n\nInput\n\na b\n\nTwo positive integers a and b are given separated by a space in a line.\n\nOutput\n\nPrint two integers x and y separated by a space. If there are several pairs of such x and y, print that pair for which |x| + |y| is the minimal (primarily) and x ≤ y (secondarily).\n\nConstraints\n\n1 ≤ a, b ≤ 109\n\nSample Input 1\n\n4 12\n\nSample Output 1\n\n1 0\n\nSample Input 2\n\n3 8\n\nSample Output 2\n\n3 -1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 507, "cpu_time_ms": 240, "memory_kb": 44128}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s499190801", "group_id": "codeNet:p02547", "input_text": "\nobject Main extends App {\n \n val sc = new java.util.Scanner(System.in)\n val s = sc.nextInt()\n val d = Array.fill(s)(sc.nextInt(), sc.nextInt())\n val ret = d.sliding(3).exists{\n l => l(0)._1 == l(0)._2 && l(1)._1 == l(1)._2 && l(2)._1 == l(2)._2\n } \n println(if(ret) \"Yes\" else \"No\")\n}\n", "language": "Scala", "metadata": {"date": 1600543197, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s499190801.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s499190801", "user_id": "u396472025"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "\nobject Main extends App {\n \n val sc = new java.util.Scanner(System.in)\n val s = sc.nextInt()\n val d = Array.fill(s)(sc.nextInt(), sc.nextInt())\n val ret = d.sliding(3).exists{\n l => l(0)._1 == l(0)._2 && l(1)._1 == l(1)._2 && l(2)._1 == l(2)._2\n } \n println(if(ret) \"Yes\" else \"No\")\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTak performed the following action N times: rolling two dice.\nThe result of the i-th roll is D_{i,1} and D_{i,2}.\n\nCheck if doublets occurred at least three times in a row.\nSpecifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.\n\nConstraints\n\n3 \\leq N \\leq 100\n\n1\\leq D_{i,j} \\leq 6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_{1,1} D_{1,2}\n\\vdots\nD_{N,1} D_{N,2}\n\nOutput\n\nPrint Yes if doublets occurred at least three times in a row. Print No otherwise.\n\nSample Input 1\n\n5\n1 2\n6 6\n4 4\n3 3\n3 2\n\nSample Output 1\n\nYes\n\nFrom the second roll to the fourth roll, three doublets occurred in a row.\n\nSample Input 2\n\n5\n1 1\n2 2\n3 4\n5 5\n6 6\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n6\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n\nSample Output 3\n\nYes", "sample_input": "5\n1 2\n6 6\n4 4\n3 3\n3 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02547", "source_text": "Score : 200 points\n\nProblem Statement\n\nTak performed the following action N times: rolling two dice.\nThe result of the i-th roll is D_{i,1} and D_{i,2}.\n\nCheck if doublets occurred at least three times in a row.\nSpecifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.\n\nConstraints\n\n3 \\leq N \\leq 100\n\n1\\leq D_{i,j} \\leq 6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_{1,1} D_{1,2}\n\\vdots\nD_{N,1} D_{N,2}\n\nOutput\n\nPrint Yes if doublets occurred at least three times in a row. Print No otherwise.\n\nSample Input 1\n\n5\n1 2\n6 6\n4 4\n3 3\n3 2\n\nSample Output 1\n\nYes\n\nFrom the second roll to the fourth roll, three doublets occurred in a row.\n\nSample Input 2\n\n5\n1 1\n2 2\n3 4\n5 5\n6 6\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n6\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 561, "memory_kb": 58076}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s872323921", "group_id": "codeNet:p02548", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in);\n val n = sc.nextInt();\n\n val answer = (1 to (n-1)).map(i => (n-1) / i).sum;\n println(answer);\n}", "language": "Scala", "metadata": {"date": 1600556275, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s872323921.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s872323921", "user_id": "u691782712"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in);\n val n = sc.nextInt();\n\n val answer = (1 to (n-1)).map(i => (n-1) / i).sum;\n println(answer);\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 169, "cpu_time_ms": 596, "memory_kb": 62844}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s568481452", "group_id": "codeNet:p02550", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextLong()\n val x, m = sc.nextInt()\n\n val a = Array.fill(m)(0L)\n val idx = Array.fill(m)(-1)\n\n var i = 0\n var now = x.toLong\n while (idx(now.toInt) == -1) {\n idx(now.toInt) = i\n a(i) = now\n now = (now * now) % m\n i += 1\n }\n\n val s = idx(now.toInt)\n val e = i - 1\n val l = e - s + 1\n val ac = a.scanLeft(0L)(_+_)\n var ans = 0L\n\n if (n < s) {\n ans += ac(n.toInt)\n } else {\n var r = n\n ans += ac(s)\n r -= s\n\n ans += (ac(e+1) - ac(s)) * (r / l)\n ans += ac(s + (r % l).toInt) - ac(s)\n }\n\n println(ans)\n}\n", "language": "Scala", "metadata": {"date": 1600583682, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s568481452.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s568481452", "user_id": "u191819389"}, "prompt_components": {"gold_output": "1369\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextLong()\n val x, m = sc.nextInt()\n\n val a = Array.fill(m)(0L)\n val idx = Array.fill(m)(-1)\n\n var i = 0\n var now = x.toLong\n while (idx(now.toInt) == -1) {\n idx(now.toInt) = i\n a(i) = now\n now = (now * now) % m\n i += 1\n }\n\n val s = idx(now.toInt)\n val e = i - 1\n val l = e - s + 1\n val ac = a.scanLeft(0L)(_+_)\n var ans = 0L\n\n if (n < s) {\n ans += ac(n.toInt)\n } else {\n var r = n\n ans += ac(s)\n r -= s\n\n ans += (ac(e+1) - ac(s)) * (r / l)\n ans += ac(s + (r % l).toInt) - ac(s)\n }\n\n println(ans)\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 550, "memory_kb": 58840}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s220237550", "group_id": "codeNet:p02552", "input_text": "object Main extends App {\n \n val sc = new java.util.Scanner(System.in)\n val x = sc.nextInt()\n println(if (x == 1) 0 else 1)\n}", "language": "Scala", "metadata": {"date": 1600023706, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02552.html", "problem_id": "p02552", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02552/input.txt", "sample_output_relpath": "derived/input_output/data/p02552/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02552/Scala/s220237550.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s220237550", "user_id": "u396472025"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "object Main extends App {\n \n val sc = new java.util.Scanner(System.in)\n val x = sc.nextInt()\n println(if (x == 1) 0 else 1)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer x that is greater than or equal to 0, and less than or equal to 1.\nOutput 1 if x is equal to 0, or 0 if x is equal to 1.\n\nConstraints\n\n0 \\leq x \\leq 1\n\nx is an integer\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx\n\nOutput\n\nPrint 1 if x is equal to 0, or 0 if x is equal to 1.\n\nSample Input 1\n\n1\n\nSample Output 1\n\n0\n\nSample Input 2\n\n0\n\nSample Output 2\n\n1", "sample_input": "1\n"}, "reference_outputs": ["0\n"], "source_document_id": "p02552", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer x that is greater than or equal to 0, and less than or equal to 1.\nOutput 1 if x is equal to 0, or 0 if x is equal to 1.\n\nConstraints\n\n0 \\leq x \\leq 1\n\nx is an integer\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx\n\nOutput\n\nPrint 1 if x is equal to 0, or 0 if x is equal to 1.\n\nSample Input 1\n\n1\n\nSample Output 1\n\n0\n\nSample Input 2\n\n0\n\nSample Output 2\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 505, "memory_kb": 55264}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s309083358", "group_id": "codeNet:p02557", "input_text": "import scala.collection.mutable.Map\n\nobject Main extends App {\n val sc = new FastScanner(System.in)\n val n = sc.nextInt()\n val a, b = Array.fill(n)(sc.nextInt() - 1)\n val count = Array.fill(n)(0)\n val idxa = Map[Int, List[Int]]().withDefaultValue(Nil)\n val idxb = Map[Int, List[Int]]().withDefaultValue(Nil)\n for (i <- 0 until n) {\n count(a(i)) += 1\n count(b(i)) += 1\n idxa(a(i)) ::= i\n idxb(b(i)) ::= i\n }\n\n if (count.max > n) {\n println(\"No\")\n } else {\n val x = Array.fill(n+1)(Set[Int]())\n for (i <- 0 until n) {\n x(count(i)) += i\n }\n\n val ans = Array.fill(n)(-1)\n\n def update(p: Int, q: Int): Unit = {\n val idx = idxa(p).head\n ans(idx) = q + 1\n idxa(p) = idxa(p).tail\n idxb(q) = idxb(q).tail\n\n if (idxa(p).isEmpty) {\n idxa -= p\n }\n\n if (idxb(q).isEmpty) {\n idxb -= q\n }\n\n x(count(p)) -= p\n x(count(q)) -= q\n count(p) -= 1\n count(q) -= 1\n x(count(p)) += p\n x(count(q)) += q\n }\n\n def getAny(m: Map[Int, List[Int]], except: Int): Int = {\n m.keys.find(_ != except).get\n }\n\n for (i <- n until 0 by -1) {\n var p = -1\n var q = -1\n x(i).size match {\n case 0 =>\n p = getAny(idxa, -1)\n q = getAny(idxb, p)\n case 1 =>\n if (idxa(x(i).head).nonEmpty) {\n p = x(i).head\n q = getAny(idxb, p)\n } else {\n q = x(i).head\n p = getAny(idxa, q)\n }\n case 2 =>\n if (idxa(x(i).head).nonEmpty) {\n p = x(i).head\n q = x(i).last\n } else {\n p = x(i).last\n q = x(i).head\n }\n }\n update(p, q)\n }\n\n println(\"Yes\")\n println(ans.mkString(\" \"))\n }\n}\n\nclass FastScanner(source: java.io.InputStream) {\n val buf = new Array[Byte](1024)\n var now, end = 0\n\n def isPrintable(b: Byte): Boolean = 33 <= b && b <= 126\n def isNum(b: Byte): Boolean = 48 <= b && b <= 57\n\n def hasNextByte: Boolean = {\n if (now < end) {\n true\n } else {\n now = 0\n end = source.read(buf)\n end > 0\n }\n }\n\n def nextByte(): Byte = {\n if (hasNextByte) {\n val b = buf(now)\n now += 1\n b\n } else {\n -1\n }\n }\n\n def hasNext: Boolean = {\n while (hasNextByte && !isPrintable(buf(now))) {\n now += 1\n }\n hasNextByte\n }\n\n def next(): String = {\n if (hasNext) {\n val sb = new StringBuilder()\n var b = nextByte()\n while (isPrintable(b)) {\n sb += b.toChar\n b = nextByte()\n }\n sb.toString\n } else {\n throw new NoSuchElementException()\n }\n }\n\n def nextInt(): Int = {\n nextLong().toInt\n }\n\n def nextLong(): Long = {\n if (hasNext) {\n var b = nextByte()\n var sign = 1\n var n = 0L\n if (b == '-') {\n sign = -1\n b = nextByte()\n }\n while (isNum(b)) {\n n = n * 10 + (b - 48)\n b = nextByte()\n }\n sign * n\n } else {\n throw new NoSuchElementException()\n }\n }\n\n def nextDouble(): Double = next().toDouble\n}\n", "language": "Scala", "metadata": {"date": 1600538316, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s309083358.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s309083358", "user_id": "u191819389"}, "prompt_components": {"gold_output": "Yes\n2 2 3 1 1 1\n", "input_to_evaluate": "import scala.collection.mutable.Map\n\nobject Main extends App {\n val sc = new FastScanner(System.in)\n val n = sc.nextInt()\n val a, b = Array.fill(n)(sc.nextInt() - 1)\n val count = Array.fill(n)(0)\n val idxa = Map[Int, List[Int]]().withDefaultValue(Nil)\n val idxb = Map[Int, List[Int]]().withDefaultValue(Nil)\n for (i <- 0 until n) {\n count(a(i)) += 1\n count(b(i)) += 1\n idxa(a(i)) ::= i\n idxb(b(i)) ::= i\n }\n\n if (count.max > n) {\n println(\"No\")\n } else {\n val x = Array.fill(n+1)(Set[Int]())\n for (i <- 0 until n) {\n x(count(i)) += i\n }\n\n val ans = Array.fill(n)(-1)\n\n def update(p: Int, q: Int): Unit = {\n val idx = idxa(p).head\n ans(idx) = q + 1\n idxa(p) = idxa(p).tail\n idxb(q) = idxb(q).tail\n\n if (idxa(p).isEmpty) {\n idxa -= p\n }\n\n if (idxb(q).isEmpty) {\n idxb -= q\n }\n\n x(count(p)) -= p\n x(count(q)) -= q\n count(p) -= 1\n count(q) -= 1\n x(count(p)) += p\n x(count(q)) += q\n }\n\n def getAny(m: Map[Int, List[Int]], except: Int): Int = {\n m.keys.find(_ != except).get\n }\n\n for (i <- n until 0 by -1) {\n var p = -1\n var q = -1\n x(i).size match {\n case 0 =>\n p = getAny(idxa, -1)\n q = getAny(idxb, p)\n case 1 =>\n if (idxa(x(i).head).nonEmpty) {\n p = x(i).head\n q = getAny(idxb, p)\n } else {\n q = x(i).head\n p = getAny(idxa, q)\n }\n case 2 =>\n if (idxa(x(i).head).nonEmpty) {\n p = x(i).head\n q = x(i).last\n } else {\n p = x(i).last\n q = x(i).head\n }\n }\n update(p, q)\n }\n\n println(\"Yes\")\n println(ans.mkString(\" \"))\n }\n}\n\nclass FastScanner(source: java.io.InputStream) {\n val buf = new Array[Byte](1024)\n var now, end = 0\n\n def isPrintable(b: Byte): Boolean = 33 <= b && b <= 126\n def isNum(b: Byte): Boolean = 48 <= b && b <= 57\n\n def hasNextByte: Boolean = {\n if (now < end) {\n true\n } else {\n now = 0\n end = source.read(buf)\n end > 0\n }\n }\n\n def nextByte(): Byte = {\n if (hasNextByte) {\n val b = buf(now)\n now += 1\n b\n } else {\n -1\n }\n }\n\n def hasNext: Boolean = {\n while (hasNextByte && !isPrintable(buf(now))) {\n now += 1\n }\n hasNextByte\n }\n\n def next(): String = {\n if (hasNext) {\n val sb = new StringBuilder()\n var b = nextByte()\n while (isPrintable(b)) {\n sb += b.toChar\n b = nextByte()\n }\n sb.toString\n } else {\n throw new NoSuchElementException()\n }\n }\n\n def nextInt(): Int = {\n nextLong().toInt\n }\n\n def nextLong(): Long = {\n if (hasNext) {\n var b = nextByte()\n var sign = 1\n var n = 0L\n if (b == '-') {\n sign = -1\n b = nextByte()\n }\n while (isNum(b)) {\n n = n * 10 + (b - 48)\n b = nextByte()\n }\n sign * n\n } else {\n throw new NoSuchElementException()\n }\n }\n\n def nextDouble(): Double = next().toDouble\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3100, "cpu_time_ms": 2205, "memory_kb": 127208}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s325081833", "group_id": "codeNet:p02557", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt()\n val a, b = List.fill(n)(sc.nextInt()-1)\n val c = Array.fill(n)(0)\n val d = Array.fill(n)(0)\n for (i <- a) {\n c(i) += 1\n }\n\n for (i <- b) {\n d(i) += 1\n }\n\n if ((0 until n).exists(i => c(i) + d(i) > n)) {\n println(\"No\")\n } else {\n val cc = c.scanLeft(0)(_+_)\n val cd = d.scanLeft(0)(_+_)\n var m = 0\n for (i <- 1 to n) {\n m = m.max(cc(i) - cd(i-1))\n }\n println(\"Yes\")\n println((b.takeRight(m) ++ b.dropRight(m)).map(_+1).mkString(\" \"))\n }\n}\n", "language": "Scala", "metadata": {"date": 1600037225, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s325081833.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s325081833", "user_id": "u191819389"}, "prompt_components": {"gold_output": "Yes\n2 2 3 1 1 1\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt()\n val a, b = List.fill(n)(sc.nextInt()-1)\n val c = Array.fill(n)(0)\n val d = Array.fill(n)(0)\n for (i <- a) {\n c(i) += 1\n }\n\n for (i <- b) {\n d(i) += 1\n }\n\n if ((0 until n).exists(i => c(i) + d(i) > n)) {\n println(\"No\")\n } else {\n val cc = c.scanLeft(0)(_+_)\n val cd = d.scanLeft(0)(_+_)\n var m = 0\n for (i <- 1 to n) {\n m = m.max(cc(i) - cd(i-1))\n }\n println(\"Yes\")\n println((b.takeRight(m) ++ b.dropRight(m)).map(_+1).mkString(\" \"))\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1445, "memory_kb": 104404}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s076892216", "group_id": "codeNet:p02570", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val d, t, s = sc.nextInt()\n println(if (d <= s * t) \"Yes\" else \"No\")\n}", "language": "Scala", "metadata": {"date": 1598727699, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s076892216.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s076892216", "user_id": "u191819389"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val d, t, s = sc.nextInt()\n println(if (d <= s * t) \"Yes\" else \"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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 541, "memory_kb": 55208}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s536591460", "group_id": "codeNet:p02576", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val N, X, T = sc.nextInt\n\n val z = (N / X + (if (N % X != 0) 1 else 0)) * T\n\n println(z)\n}\n", "language": "Scala", "metadata": {"date": 1598122899, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s536591460.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s536591460", "user_id": "u786167609"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val N, X, T = sc.nextInt\n\n val z = (N / X + (if (N % X != 0) 1 else 0)) * T\n\n println(z)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 534, "memory_kb": 55320}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s254544165", "group_id": "codeNet:p02576", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n, x, t = sc.nextInt()\n println(((n + x - 1) / x) * t)\n}\n", "language": "Scala", "metadata": {"date": 1598122870, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s254544165.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s254544165", "user_id": "u191819389"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n, x, t = sc.nextInt()\n println(((n + x - 1) / x) * 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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 508, "memory_kb": 55352}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s866882375", "group_id": "codeNet:p02577", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val N = sc.nextLine\n\n val z = if (N == \"0\" || N.foldLeft(0L)((z, x) => z + x.toLong) % 9L == 0L) \"Yes\" else \"No\"\n\n println(z)\n}\n", "language": "Scala", "metadata": {"date": 1598123165, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s866882375.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s866882375", "user_id": "u786167609"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val N = sc.nextLine\n\n val z = if (N == \"0\" || N.foldLeft(0L)((z, x) => z + x.toLong) % 9L == 0L) \"Yes\" else \"No\"\n\n println(z)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 642, "memory_kb": 58432}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s390935552", "group_id": "codeNet:p02578", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val x :: xs = List.fill(sc.nextInt())(sc.nextInt())\n val (_, sum) = xs.foldLeft((x, 0)) {\n case ((l, acc), r) => (l.max(r), acc + (l - r).max(0))\n }\n println(sum)\n}\n", "language": "Scala", "metadata": {"date": 1598512731, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s390935552.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s390935552", "user_id": "u737111725"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val x :: xs = List.fill(sc.nextInt())(sc.nextInt())\n val (_, sum) = xs.foldLeft((x, 0)) {\n case ((l, acc), r) => (l.max(r), acc + (l - r).max(0))\n }\n println(sum)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 974, "memory_kb": 66636}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s596535390", "group_id": "codeNet:p02579", "input_text": "import scala.io.StdIn._\n\nobject Main extends App {\n\n val Array(h,w) = readLine().split(\" \").map(_.toInt)\n val Array(ch,cw) = readLine().split(\" \").map(_.toInt-1)\n val Array(dh,dw) = readLine().split(\" \").map(_.toInt-1)\n val S = Array.fill(h)(readLine().split(\"\"))\n\n var ans = Int.MaxValue\n var canGoal = false\n def solve() = {\n val visitedArr = Array.fill(h,w)(false)\n dfs((ch,cw), 0, \".\", visitedArr)\n if(canGoal) ans else -1\n }\n\n def dfs(cur: (Int, Int), warpCnt: Int, prev: String, visited: Array[Array[Boolean]],\n over: Boolean = false): Unit = {\n if(cur == (dh,dw)) {\n ans = Math.min(ans, warpCnt)\n canGoal = true\n }\n else if(over) ()\n else {\n val (x,y) = cur\n for {\n nx <- x-1 to x+1 if 0 <= nx && nx < h\n ny <- y-1 to y+1 if 0 <= ny && ny < w\n if !visited(nx)(ny)\n } {\n val updateVisited = visited.updated(nx, visited(nx).updated(ny, true))\n // not use warp\n if(S(nx)(ny) == \".\" && !isWarped((x,y), (nx,ny))) dfs((nx,ny), warpCnt, \".\", updateVisited)\n // use warp\n else {\n if(prev == \".\") dfs((nx,ny), warpCnt+1, \"#\", updateVisited)\n else dfs((nx,ny), warpCnt+1, \"#\", updateVisited, over = true)\n }\n }\n }\n }\n\n def isWarped(cur: (Int, Int), next: (Int, Int)): Boolean = {\n val (x,y) = cur\n val (nx, ny) = next\n if((nx-x).abs == 1 && (ny-y).abs == 1) true else false\n }\n\n println(solve())\n\n}\n\n", "language": "Scala", "metadata": {"date": 1598128308, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s596535390.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s596535390", "user_id": "u947008426"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main extends App {\n\n val Array(h,w) = readLine().split(\" \").map(_.toInt)\n val Array(ch,cw) = readLine().split(\" \").map(_.toInt-1)\n val Array(dh,dw) = readLine().split(\" \").map(_.toInt-1)\n val S = Array.fill(h)(readLine().split(\"\"))\n\n var ans = Int.MaxValue\n var canGoal = false\n def solve() = {\n val visitedArr = Array.fill(h,w)(false)\n dfs((ch,cw), 0, \".\", visitedArr)\n if(canGoal) ans else -1\n }\n\n def dfs(cur: (Int, Int), warpCnt: Int, prev: String, visited: Array[Array[Boolean]],\n over: Boolean = false): Unit = {\n if(cur == (dh,dw)) {\n ans = Math.min(ans, warpCnt)\n canGoal = true\n }\n else if(over) ()\n else {\n val (x,y) = cur\n for {\n nx <- x-1 to x+1 if 0 <= nx && nx < h\n ny <- y-1 to y+1 if 0 <= ny && ny < w\n if !visited(nx)(ny)\n } {\n val updateVisited = visited.updated(nx, visited(nx).updated(ny, true))\n // not use warp\n if(S(nx)(ny) == \".\" && !isWarped((x,y), (nx,ny))) dfs((nx,ny), warpCnt, \".\", updateVisited)\n // use warp\n else {\n if(prev == \".\") dfs((nx,ny), warpCnt+1, \"#\", updateVisited)\n else dfs((nx,ny), warpCnt+1, \"#\", updateVisited, over = true)\n }\n }\n }\n }\n\n def isWarped(cur: (Int, Int), next: (Int, Int)): Boolean = {\n val (x,y) = cur\n val (nx, ny) = next\n if((nx-x).abs == 1 && (ny-y).abs == 1) true else false\n }\n\n println(solve())\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1458, "cpu_time_ms": 2205, "memory_kb": 415020}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s444276972", "group_id": "codeNet:p02583", "input_text": "import io.StdIn.{readInt, readLine}\nobject Main extends App {\n val n = readInt\n val ls = readLine.split(\" \").map(_.toInt)\n\n def different(i1: Int, i2: Int, i3: Int): Boolean = i1 != i2 && i2 != i3 && i3 != i1\n def makeable(i1: Int, i2: Int, i3: Int): Boolean = {\n val sorted = Seq(i1, i2, i3).sorted\n sorted(2) < sorted(0) + sorted(1)\n }\n\n val count = for (i <- 0 until n-2; j <- i until n-1; k <- j until n) yield {\n val li = ls(i)\n val lj = ls(j)\n val lk = ls(k)\n if (different(li, lj, lk) && makeable(li, lj, lk)) 1\n else 0\n }\n\n val result = count.sum\n println(result)\n}\n", "language": "Scala", "metadata": {"date": 1597525762, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s444276972.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s444276972", "user_id": "u104354966"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import io.StdIn.{readInt, readLine}\nobject Main extends App {\n val n = readInt\n val ls = readLine.split(\" \").map(_.toInt)\n\n def different(i1: Int, i2: Int, i3: Int): Boolean = i1 != i2 && i2 != i3 && i3 != i1\n def makeable(i1: Int, i2: Int, i3: Int): Boolean = {\n val sorted = Seq(i1, i2, i3).sorted\n sorted(2) < sorted(0) + sorted(1)\n }\n\n val count = for (i <- 0 until n-2; j <- i until n-1; k <- j until n) yield {\n val li = ls(i)\n val lj = ls(j)\n val lk = ls(k)\n if (different(li, lj, lk) && makeable(li, lj, lk)) 1\n else 0\n }\n\n val result = count.sum\n println(result)\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 604, "cpu_time_ms": 851, "memory_kb": 58300}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s697301977", "group_id": "codeNet:p02584", "input_text": "import scala.io.StdIn._\n\nobject Main extends App {\n\n val Array(x,k,d) = readLine().split(\" \").map(_.toLong)\n\n def solve() = {\n val xAbs = x.abs\n val movedCnt = xAbs / d\n if(k > movedCnt) {\n val nearP = xAbs % d\n val farP = (xAbs - d).abs\n val fixP = Math.min(nearP, farP)\n\n if(fixP == nearP) {\n val restMoveCnt = k - movedCnt\n if(restMoveCnt % 2 == 0) nearP else (nearP - d).abs\n } else {\n val restMoveCnt = k - movedCnt - 1\n if(restMoveCnt % 2 == 0) farP else (farP - d).abs\n }\n } else {\n xAbs - (k * d)\n }\n }\n\n println(solve())\n\n}\n\n", "language": "Scala", "metadata": {"date": 1597521336, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s697301977.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s697301977", "user_id": "u947008426"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main extends App {\n\n val Array(x,k,d) = readLine().split(\" \").map(_.toLong)\n\n def solve() = {\n val xAbs = x.abs\n val movedCnt = xAbs / d\n if(k > movedCnt) {\n val nearP = xAbs % d\n val farP = (xAbs - d).abs\n val fixP = Math.min(nearP, farP)\n\n if(fixP == nearP) {\n val restMoveCnt = k - movedCnt\n if(restMoveCnt % 2 == 0) nearP else (nearP - d).abs\n } else {\n val restMoveCnt = k - movedCnt - 1\n if(restMoveCnt % 2 == 0) farP else (farP - d).abs\n }\n } else {\n xAbs - (k * d)\n }\n }\n\n println(solve())\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 499, "memory_kb": 54860}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s080232556", "group_id": "codeNet:p02585", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n, k = sc.nextInt()\n val p = Array.fill(n)(sc.nextInt()-1)\n val c = Array.fill(n)(sc.nextLong())\n\n def decompose(a: Array[Int]): Array[Array[Int]] = {\n val n = a.length\n val visited = Array.fill(n)(false)\n var res = Array[Array[Int]]()\n\n for (i <- 0 until n) {\n var next = i\n var factor = Array[Int]()\n while (!visited(next)) {\n visited(next) = true\n factor :+= next\n next = a(next)\n }\n if (factor.nonEmpty) {\n res :+= factor\n }\n }\n\n res\n }\n\n val d = decompose(p).map(_.map(c))\n\n var ans = Long.MinValue\n for (f <- d) {\n val l = f.length\n val fa = (f ++ f).scanLeft(0L)(_ + _)\n val sum = fa(l) - fa(0)\n if (sum > 0) {\n val x = k / l\n val y = k % l\n for {\n i <- 0 until l\n j <- i to i+y\n } {\n ans = ans.max(sum * x + fa(j) - fa(i))\n }\n } else {\n for {\n i <- 0 until l\n j <- i+1 to i+(k.min(l))\n } {\n ans = ans.max(fa(j) - fa(i))\n }\n }\n }\n\n println(ans)\n}\n", "language": "Scala", "metadata": {"date": 1597543673, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02585.html", "problem_id": "p02585", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02585/input.txt", "sample_output_relpath": "derived/input_output/data/p02585/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02585/Scala/s080232556.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s080232556", "user_id": "u191819389"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n, k = sc.nextInt()\n val p = Array.fill(n)(sc.nextInt()-1)\n val c = Array.fill(n)(sc.nextLong())\n\n def decompose(a: Array[Int]): Array[Array[Int]] = {\n val n = a.length\n val visited = Array.fill(n)(false)\n var res = Array[Array[Int]]()\n\n for (i <- 0 until n) {\n var next = i\n var factor = Array[Int]()\n while (!visited(next)) {\n visited(next) = true\n factor :+= next\n next = a(next)\n }\n if (factor.nonEmpty) {\n res :+= factor\n }\n }\n\n res\n }\n\n val d = decompose(p).map(_.map(c))\n\n var ans = Long.MinValue\n for (f <- d) {\n val l = f.length\n val fa = (f ++ f).scanLeft(0L)(_ + _)\n val sum = fa(l) - fa(0)\n if (sum > 0) {\n val x = k / l\n val y = k % l\n for {\n i <- 0 until l\n j <- i to i+y\n } {\n ans = ans.max(sum * x + fa(j) - fa(i))\n }\n } else {\n for {\n i <- 0 until l\n j <- i+1 to i+(k.min(l))\n } {\n ans = ans.max(fa(j) - fa(i))\n }\n }\n }\n\n println(ans)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi will play a game using a piece on an array of squares numbered 1, 2, \\cdots, N. Square i has an integer C_i written on it. Also, he is given a permutation of 1, 2, \\cdots, N: P_1, P_2, \\cdots, P_N.\n\nNow, he will choose one square and place the piece on that square. Then, he will make the following move some number of times between 1 and K (inclusive):\n\nIn one move, if the piece is now on Square i (1 \\leq i \\leq N), move it to Square P_i. Here, his score increases by C_{P_i}.\n\nHelp him by finding the maximum possible score at the end of the game. (The score is 0 at the beginning of the game.)\n\nConstraints\n\n2 \\leq N \\leq 5000\n\n1 \\leq K \\leq 10^9\n\n1 \\leq P_i \\leq N\n\nP_i \\neq i\n\nP_1, P_2, \\cdots, P_N are all different.\n\n-10^9 \\leq C_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nP_1 P_2 \\cdots P_N\nC_1 C_2 \\cdots C_N\n\nOutput\n\nPrint the maximum possible score at the end of the game.\n\nSample Input 1\n\n5 2\n2 4 5 1 3\n3 4 -10 -8 8\n\nSample Output 1\n\n8\n\nWhen we start at some square of our choice and make at most two moves, we have the following options:\n\nIf we start at Square 1, making one move sends the piece to Square 2, after which the score is 4. Making another move sends the piece to Square 4, after which the score is 4 + (-8) = -4.\n\nIf we start at Square 2, making one move sends the piece to Square 4, after which the score is -8. Making another move sends the piece to Square 1, after which the score is -8 + 3 = -5.\n\nIf we start at Square 3, making one move sends the piece to Square 5, after which the score is 8. Making another move sends the piece to Square 3, after which the score is 8 + (-10) = -2.\n\nIf we start at Square 4, making one move sends the piece to Square 1, after which the score is 3. Making another move sends the piece to Square 2, after which the score is 3 + 4 = 7.\n\nIf we start at Square 5, making one move sends the piece to Square 3, after which the score is -10. Making another move sends the piece to Square 5, after which the score is -10 + 8 = -2.\n\nThe maximum score achieved is 8.\n\nSample Input 2\n\n2 3\n2 1\n10 -7\n\nSample Output 2\n\n13\n\nSample Input 3\n\n3 3\n3 1 2\n-1000 -2000 -3000\n\nSample Output 3\n\n-1000\n\nWe have to make at least one move.\n\nSample Input 4\n\n10 58\n9 1 6 7 8 4 3 2 10 5\n695279662 988782657 -119067776 382975538 -151885171 -177220596 -169777795 37619092 389386780 980092719\n\nSample Output 4\n\n29507023469\n\nThe absolute value of the answer may be enormous.", "sample_input": "5 2\n2 4 5 1 3\n3 4 -10 -8 8\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02585", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi will play a game using a piece on an array of squares numbered 1, 2, \\cdots, N. Square i has an integer C_i written on it. Also, he is given a permutation of 1, 2, \\cdots, N: P_1, P_2, \\cdots, P_N.\n\nNow, he will choose one square and place the piece on that square. Then, he will make the following move some number of times between 1 and K (inclusive):\n\nIn one move, if the piece is now on Square i (1 \\leq i \\leq N), move it to Square P_i. Here, his score increases by C_{P_i}.\n\nHelp him by finding the maximum possible score at the end of the game. (The score is 0 at the beginning of the game.)\n\nConstraints\n\n2 \\leq N \\leq 5000\n\n1 \\leq K \\leq 10^9\n\n1 \\leq P_i \\leq N\n\nP_i \\neq i\n\nP_1, P_2, \\cdots, P_N are all different.\n\n-10^9 \\leq C_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nP_1 P_2 \\cdots P_N\nC_1 C_2 \\cdots C_N\n\nOutput\n\nPrint the maximum possible score at the end of the game.\n\nSample Input 1\n\n5 2\n2 4 5 1 3\n3 4 -10 -8 8\n\nSample Output 1\n\n8\n\nWhen we start at some square of our choice and make at most two moves, we have the following options:\n\nIf we start at Square 1, making one move sends the piece to Square 2, after which the score is 4. Making another move sends the piece to Square 4, after which the score is 4 + (-8) = -4.\n\nIf we start at Square 2, making one move sends the piece to Square 4, after which the score is -8. Making another move sends the piece to Square 1, after which the score is -8 + 3 = -5.\n\nIf we start at Square 3, making one move sends the piece to Square 5, after which the score is 8. Making another move sends the piece to Square 3, after which the score is 8 + (-10) = -2.\n\nIf we start at Square 4, making one move sends the piece to Square 1, after which the score is 3. Making another move sends the piece to Square 2, after which the score is 3 + 4 = 7.\n\nIf we start at Square 5, making one move sends the piece to Square 3, after which the score is -10. Making another move sends the piece to Square 5, after which the score is -10 + 8 = -2.\n\nThe maximum score achieved is 8.\n\nSample Input 2\n\n2 3\n2 1\n10 -7\n\nSample Output 2\n\n13\n\nSample Input 3\n\n3 3\n3 1 2\n-1000 -2000 -3000\n\nSample Output 3\n\n-1000\n\nWe have to make at least one move.\n\nSample Input 4\n\n10 58\n9 1 6 7 8 4 3 2 10 5\n695279662 988782657 -119067776 382975538 -151885171 -177220596 -169777795 37619092 389386780 980092719\n\nSample Output 4\n\n29507023469\n\nThe absolute value of the answer may be enormous.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1115, "cpu_time_ms": 743, "memory_kb": 58924}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s253961625", "group_id": "codeNet:p02594", "input_text": "object Main extends App {\n val temp = io.StdIn.readLine().toInt\n if (temp >= 30) println(\"Yes\") else println(\"No\")\n}", "language": "Scala", "metadata": {"date": 1597095652, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s253961625.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s253961625", "user_id": "u396472025"}, "prompt_components": {"gold_output": "No\n", "input_to_evaluate": "object Main extends App {\n val temp = io.StdIn.readLine().toInt\n if (temp >= 30) println(\"Yes\") else println(\"No\")\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 502, "memory_kb": 54508}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s996230034", "group_id": "codeNet:p02597", "input_text": "import io.StdIn.{readInt, readLine}\nobject Main extends App {\n val n = readInt\n val wrs = readLine\n\n val w_count = readLine.count(_ == 'W')\n val r_count = readLine.count(_ == 'R')\n \n val case1 = w_count\n val case2 = r_count\n val case3 = w_count - wrs.takeRight(w_count).count(_ == 'W')\n\n val result = Array(case1, case2, case3).min\n println(result)\n}", "language": "Scala", "metadata": {"date": 1596422392, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s996230034.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s996230034", "user_id": "u104354966"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import io.StdIn.{readInt, readLine}\nobject Main extends App {\n val n = readInt\n val wrs = readLine\n\n val w_count = readLine.count(_ == 'W')\n val r_count = readLine.count(_ == 'R')\n \n val case1 = w_count\n val case2 = r_count\n val case3 = w_count - wrs.takeRight(w_count).count(_ == 'W')\n\n val result = Array(case1, case2, case3).min\n println(result)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 360, "cpu_time_ms": 545, "memory_kb": 55252}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s613985457", "group_id": "codeNet:p02597", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val num = scala.io.StdIn.readInt\n val array = scala.io.StdIn.readLine.split(\"\")\n var count = 0\n var white_point = num - 1\n\n ( 0 until num ).foreach{ i =>\n if( array( i ) == \"W\" && white_point > i){\n while( array( white_point ) == \"W\" ) white_point -= 1\n array( i ) = \"R\"\n array( white_point ) = \"W\"\n count += 1\n }\n }\n println( count )\n }\n}", "language": "Scala", "metadata": {"date": 1596420578, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s613985457.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s613985457", "user_id": "u888177577"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val num = scala.io.StdIn.readInt\n val array = scala.io.StdIn.readLine.split(\"\")\n var count = 0\n var white_point = num - 1\n\n ( 0 until num ).foreach{ i =>\n if( array( i ) == \"W\" && white_point > i){\n while( array( white_point ) == \"W\" ) white_point -= 1\n array( i ) = \"R\"\n array( white_point ) = \"W\"\n count += 1\n }\n }\n println( count )\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 456, "cpu_time_ms": 703, "memory_kb": 64944}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s969111080", "group_id": "codeNet:p02598", "input_text": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val N, K = in.nextInt\n val As = Array.fill(N)(in.nextDouble)\n\n def cuts(orig: Double, max: Int): Double = (orig / max).ceil - 1\n\n def binSearch(min: Int, max: Int, cur: Int): Int = {\n if (min + 1 == max) max\n else {\n val totalCuts = As.map(cuts(_, cur)).sum\n if (totalCuts > K) binSearch(cur, max, (cur + max) / 2)\n else binSearch(min, cur, (min + cur) / 2)\n }\n }\n\n println(binSearch(0, 1_000_000_000, 500_000_000))\n}", "language": "Scala", "metadata": {"date": 1596747945, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s969111080.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s969111080", "user_id": "u132324749"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val N, K = in.nextInt\n val As = Array.fill(N)(in.nextDouble)\n\n def cuts(orig: Double, max: Int): Double = (orig / max).ceil - 1\n\n def binSearch(min: Int, max: Int, cur: Int): Int = {\n if (min + 1 == max) max\n else {\n val totalCuts = As.map(cuts(_, cur)).sum\n if (totalCuts > K) binSearch(cur, max, (cur + max) / 2)\n else binSearch(min, cur, (min + cur) / 2)\n }\n }\n\n println(binSearch(0, 1_000_000_000, 500_000_000))\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 0) {\n res += tree(i)\n i -= i & -i\n }\n res\n }\n\n def add(idx: Int, a: Int): Unit = {\n var i = idx+1\n while (i <= n) {\n tree(i) += a\n i += i & -i\n }\n }\n}\n\nclass FastScanner(source: java.io.InputStream) {\n val buf = new Array[Byte](1024)\n var now, end = 0\n\n def isPrintable(b: Byte): Boolean = 33 <= b && b <= 126\n def isNum(b: Byte): Boolean = 48 <= b && b <= 57\n\n def hasNextByte: Boolean = {\n if (now < end) {\n true\n } else {\n now = 0\n end = source.read(buf)\n end > 0\n }\n }\n\n def nextByte(): Byte = {\n if (hasNextByte) {\n val b = buf(now)\n now += 1\n b\n } else {\n -1\n }\n }\n\n def hasNext: Boolean = {\n while (hasNextByte && !isPrintable(buf(now))) {\n now += 1\n }\n hasNextByte\n }\n\n def next(): String = {\n if (hasNext) {\n val sb = new StringBuilder()\n var b = nextByte()\n while (isPrintable(b)) {\n sb += b.toChar\n b = nextByte()\n }\n sb.toString\n } else {\n throw new NoSuchElementException()\n }\n }\n\n def nextInt(): Int = {\n nextLong().toInt\n }\n\n def nextLong(): Long = {\n if (hasNext) {\n var b = nextByte()\n var sign = 1\n var n = 0L\n if (b == '-') {\n sign = -1\n b = nextByte()\n }\n while (isNum(b)) {\n n = n * 10 + (b - 48)\n b = nextByte()\n }\n sign * n\n } else {\n throw new NoSuchElementException()\n }\n }\n\n def nextDouble(): Double = next().toDouble\n}\n", "language": "Scala", "metadata": {"date": 1596512777, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02599.html", "problem_id": "p02599", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02599/input.txt", "sample_output_relpath": "derived/input_output/data/p02599/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02599/Scala/s152600358.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s152600358", "user_id": "u191819389"}, "prompt_components": {"gold_output": "2\n3\n1\n", "input_to_evaluate": "object Main extends App {\n val sc = new FastScanner(System.in)\n val n, q = sc.nextInt()\n val c = Array.fill(n)(sc.nextInt()-1)\n val lr = List.fill(q)((sc.nextInt()-1, sc.nextInt()-1))\n val ans = Array.fill(q)(0)\n\n val pos = Array.fill(n)(-1)\n val bit = new BinaryIndexedTree(n)\n var lPrev = n\n\n for (((l, r), idx) <- lr.zipWithIndex.sortBy(-_._1._1)) {\n for (i <- lPrev-1 to l by -1) {\n val ci = c(i)\n val p = pos(ci)\n pos(ci) = i\n if (p != -1) {\n bit.add(p, -1)\n }\n bit.add(i, 1)\n }\n lPrev = l\n ans(idx) = bit.query(r+1)\n }\n\n val pw = new java.io.PrintWriter(Console.out)\n ans.foreach(pw.println)\n pw.flush()\n}\n\nclass BinaryIndexedTree(n: Int) {\n private val tree = Array.fill(n+1)(0)\n\n def query(r: Int): Int = {\n var res = 0\n var i = r\n while (i > 0) {\n res += tree(i)\n i -= i & -i\n }\n res\n }\n\n def add(idx: Int, a: Int): Unit = {\n var i = idx+1\n while (i <= n) {\n tree(i) += a\n i += i & -i\n }\n }\n}\n\nclass FastScanner(source: java.io.InputStream) {\n val buf = new Array[Byte](1024)\n var now, end = 0\n\n def isPrintable(b: Byte): Boolean = 33 <= b && b <= 126\n def isNum(b: Byte): Boolean = 48 <= b && b <= 57\n\n def hasNextByte: Boolean = {\n if (now < end) {\n true\n } else {\n now = 0\n end = source.read(buf)\n end > 0\n }\n }\n\n def nextByte(): Byte = {\n if (hasNextByte) {\n val b = buf(now)\n now += 1\n b\n } else {\n -1\n }\n }\n\n def hasNext: Boolean = {\n while (hasNextByte && !isPrintable(buf(now))) {\n now += 1\n }\n hasNextByte\n }\n\n def next(): String = {\n if (hasNext) {\n val sb = new StringBuilder()\n var b = nextByte()\n while (isPrintable(b)) {\n sb += b.toChar\n b = nextByte()\n }\n sb.toString\n } else {\n throw new NoSuchElementException()\n }\n }\n\n def nextInt(): Int = {\n nextLong().toInt\n }\n\n def nextLong(): Long = {\n if (hasNext) {\n var b = nextByte()\n var sign = 1\n var n = 0L\n if (b == '-') {\n sign = -1\n b = nextByte()\n }\n while (isNum(b)) {\n n = n * 10 + (b - 48)\n b = nextByte()\n }\n sign * n\n } else {\n throw new NoSuchElementException()\n }\n }\n\n def nextDouble(): Double = next().toDouble\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have N colored balls arranged in a row from left to right; the color of the i-th ball from the left is c_i.\n\nYou are given Q queries. The i-th query is as follows: how many different colors do the l_i-th through r_i-th balls from the left have?\n\nConstraints\n\n1\\leq N,Q \\leq 5 \\times 10^5\n\n1\\leq c_i \\leq N\n\n1\\leq l_i \\leq r_i \\leq N\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nc_1 c_2 \\cdots c_N\nl_1 r_1\nl_2 r_2\n:\nl_Q r_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the response to the i-th query.\n\nSample Input 1\n\n4 3\n1 2 1 3\n1 3\n2 4\n3 3\n\nSample Output 1\n\n2\n3\n1\n\nThe 1-st, 2-nd, and 3-rd balls from the left have the colors 1, 2, and 1 - two different colors.\n\nThe 2-st, 3-rd, and 4-th balls from the left have the colors 2, 1, and 3 - three different colors.\n\nThe 3-rd ball from the left has the color 1 - just one color.\n\nSample Input 2\n\n10 10\n2 5 6 5 2 1 7 9 7 2\n5 5\n2 4\n6 7\n2 2\n7 8\n7 9\n1 8\n6 9\n8 10\n6 8\n\nSample Output 2\n\n1\n2\n2\n1\n2\n2\n6\n3\n3\n3", "sample_input": "4 3\n1 2 1 3\n1 3\n2 4\n3 3\n"}, "reference_outputs": ["2\n3\n1\n"], "source_document_id": "p02599", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have N colored balls arranged in a row from left to right; the color of the i-th ball from the left is c_i.\n\nYou are given Q queries. The i-th query is as follows: how many different colors do the l_i-th through r_i-th balls from the left have?\n\nConstraints\n\n1\\leq N,Q \\leq 5 \\times 10^5\n\n1\\leq c_i \\leq N\n\n1\\leq l_i \\leq r_i \\leq N\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nc_1 c_2 \\cdots c_N\nl_1 r_1\nl_2 r_2\n:\nl_Q r_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the response to the i-th query.\n\nSample Input 1\n\n4 3\n1 2 1 3\n1 3\n2 4\n3 3\n\nSample Output 1\n\n2\n3\n1\n\nThe 1-st, 2-nd, and 3-rd balls from the left have the colors 1, 2, and 1 - two different colors.\n\nThe 2-st, 3-rd, and 4-th balls from the left have the colors 2, 1, and 3 - three different colors.\n\nThe 3-rd ball from the left has the color 1 - just one color.\n\nSample Input 2\n\n10 10\n2 5 6 5 2 1 7 9 7 2\n5 5\n2 4\n6 7\n2 2\n7 8\n7 9\n1 8\n6 9\n8 10\n6 8\n\nSample Output 2\n\n1\n2\n2\n1\n2\n2\n6\n3\n3\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2335, "cpu_time_ms": 1986, "memory_kb": 176328}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s930463926", "group_id": "codeNet:p02601", "input_text": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\nimport java.lang\n\nimport scala.annotation.tailrec\nimport scala.collection.mutable.ArrayBuffer\nimport scala.reflect.ClassTag\n\nobject Main {\n def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {\n converter(in.readLine)\n }\n\n def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {\n get[String].split(\"\\\\s+\").map[T](converter)\n }\n\n implicit val idConverter: String => String = s => s\n implicit val intConverter: String => Int = s => Integer.parseInt(s)\n implicit val longConverter: String => Long = s => lang.Long.parseLong(s)\n\n def get[T1, T2](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2\n ): (T1, T2) = {\n getArray[String] match {\n case Array(v1, v2) => (converter1(v1), converter2(v2))\n }\n }\n\n def get[T1, T2, T3](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3\n ): (T1, T2, T3) = {\n getArray[String] match {\n case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))\n }\n }\n\n def get[T1, T2, T3, T4](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3,\n converter4: String => T4\n ): (T1, T2, T3, T4) = {\n getArray[String] match {\n case Array(v1, v2, v3, v4) => (converter1(v1), converter2(v2), converter3(v3), converter4(v4))\n }\n }\n\n implicit class TimesInt(val n: Int) {\n def times(f: Int => Unit): Unit = {\n for (i <- 0 until n) {\n f(i)\n }\n }\n }\n\n def primes(n: Long): ArrayBuffer[Long] = {\n val buf = ArrayBuffer.empty[Long]\n val s = Math.sqrt(n).toInt\n\n var v = n\n for (i <- 2 to s) {\n if (v == 1 || v == 0) {\n return buf\n } else {\n while (v % i == 0) {\n buf.append(i)\n v /= i\n }\n }\n }\n if (v > s) {\n buf.append(v)\n }\n buf\n }\n\n def divisors(n: Int): ArrayBuffer[Int] = {\n val buf = ArrayBuffer.empty[Int]\n val s = Math.sqrt(n).toInt\n\n for (i <- 1 to s) {\n if (n % i == 0) {\n buf.append(i)\n if (i != n / i) {\n buf.append(n / i)\n }\n }\n }\n buf\n }\n\n @tailrec\n def gcd(a: Long, b: Long): Long = {\n val reminder = a % b\n if (reminder == 0) {\n b\n } else {\n gcd(b, reminder)\n }\n }\n\n @tailrec\n def gcd(a: Int, b: Int): Int = {\n val reminder = a % b\n if (reminder == 0) {\n b\n } else {\n gcd(b, reminder)\n }\n }\n\n def lcm(a: Long, b: Long): Long = {\n a / gcd(a, b) * b\n }\n\n def toBitArray(n: Int, width: Int): Array[Boolean] = {\n val buf = ArrayBuffer.fill(width)(false)\n\n @tailrec\n def inner(n: Int, i: Int): Array[Boolean] = {\n buf(i) = (n & 1) == 0\n if (i == 0) {\n buf.toArray\n } else {\n inner(n / 2, i - 1)\n }\n }\n\n inner(n, width - 1)\n }\n\n def modpow(n: Long, p: Long, m: Long): Long = {\n @tailrec\n def inner(n: Long, p: Long, acc: Long): Long = {\n if (p == 0) {\n acc\n } else if ((p & 1) == 0) {\n inner(n * n % m, p >> 1, acc)\n } else {\n inner(n * n % m, p >> 1, acc * n % m)\n }\n }\n\n inner(n % m, p, 1)\n }\n\n def main(args: Array[String]): Unit = {\n implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n var (a, b, c) = get[Int, Int, Int]\n val k = get[Int]\n\n var count = 0\n while (a >= b) {\n count += 1\n b *= 2\n }\n\n while (b >= c) {\n count += 1\n c *= 2\n }\n\n out.println(\n if (count <= k) {\n \"Yes\"\n } else {\n \"No\"\n }\n )\n\n out.flush()\n }\n}", "language": "Scala", "metadata": {"date": 1595725519, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02601.html", "problem_id": "p02601", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02601/input.txt", "sample_output_relpath": "derived/input_output/data/p02601/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02601/Scala/s930463926.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s930463926", "user_id": "u178269371"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\nimport java.lang\n\nimport scala.annotation.tailrec\nimport scala.collection.mutable.ArrayBuffer\nimport scala.reflect.ClassTag\n\nobject Main {\n def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {\n converter(in.readLine)\n }\n\n def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {\n get[String].split(\"\\\\s+\").map[T](converter)\n }\n\n implicit val idConverter: String => String = s => s\n implicit val intConverter: String => Int = s => Integer.parseInt(s)\n implicit val longConverter: String => Long = s => lang.Long.parseLong(s)\n\n def get[T1, T2](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2\n ): (T1, T2) = {\n getArray[String] match {\n case Array(v1, v2) => (converter1(v1), converter2(v2))\n }\n }\n\n def get[T1, T2, T3](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3\n ): (T1, T2, T3) = {\n getArray[String] match {\n case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))\n }\n }\n\n def get[T1, T2, T3, T4](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3,\n converter4: String => T4\n ): (T1, T2, T3, T4) = {\n getArray[String] match {\n case Array(v1, v2, v3, v4) => (converter1(v1), converter2(v2), converter3(v3), converter4(v4))\n }\n }\n\n implicit class TimesInt(val n: Int) {\n def times(f: Int => Unit): Unit = {\n for (i <- 0 until n) {\n f(i)\n }\n }\n }\n\n def primes(n: Long): ArrayBuffer[Long] = {\n val buf = ArrayBuffer.empty[Long]\n val s = Math.sqrt(n).toInt\n\n var v = n\n for (i <- 2 to s) {\n if (v == 1 || v == 0) {\n return buf\n } else {\n while (v % i == 0) {\n buf.append(i)\n v /= i\n }\n }\n }\n if (v > s) {\n buf.append(v)\n }\n buf\n }\n\n def divisors(n: Int): ArrayBuffer[Int] = {\n val buf = ArrayBuffer.empty[Int]\n val s = Math.sqrt(n).toInt\n\n for (i <- 1 to s) {\n if (n % i == 0) {\n buf.append(i)\n if (i != n / i) {\n buf.append(n / i)\n }\n }\n }\n buf\n }\n\n @tailrec\n def gcd(a: Long, b: Long): Long = {\n val reminder = a % b\n if (reminder == 0) {\n b\n } else {\n gcd(b, reminder)\n }\n }\n\n @tailrec\n def gcd(a: Int, b: Int): Int = {\n val reminder = a % b\n if (reminder == 0) {\n b\n } else {\n gcd(b, reminder)\n }\n }\n\n def lcm(a: Long, b: Long): Long = {\n a / gcd(a, b) * b\n }\n\n def toBitArray(n: Int, width: Int): Array[Boolean] = {\n val buf = ArrayBuffer.fill(width)(false)\n\n @tailrec\n def inner(n: Int, i: Int): Array[Boolean] = {\n buf(i) = (n & 1) == 0\n if (i == 0) {\n buf.toArray\n } else {\n inner(n / 2, i - 1)\n }\n }\n\n inner(n, width - 1)\n }\n\n def modpow(n: Long, p: Long, m: Long): Long = {\n @tailrec\n def inner(n: Long, p: Long, acc: Long): Long = {\n if (p == 0) {\n acc\n } else if ((p & 1) == 0) {\n inner(n * n % m, p >> 1, acc)\n } else {\n inner(n * n % m, p >> 1, acc * n % m)\n }\n }\n\n inner(n % m, p, 1)\n }\n\n def main(args: Array[String]): Unit = {\n implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n var (a, b, c) = get[Int, Int, Int]\n val k = get[Int]\n\n var count = 0\n while (a >= b) {\n count += 1\n b *= 2\n }\n\n while (b >= c) {\n count += 1\n c *= 2\n }\n\n out.println(\n if (count <= k) {\n \"Yes\"\n } else {\n \"No\"\n }\n )\n\n out.flush()\n }\n}", "problem_context": "Score: 200 points\n\nProblem Statement\n\nM-kun has the following three cards:\n\nA red card with the integer A.\n\nA green card with the integer B.\n\nA blue card with the integer C.\n\nHe is a genius magician who can do the following operation at most K times:\n\nChoose one of the three cards and multiply the written integer by 2.\n\nHis magic is successful if both of the following conditions are satisfied after the operations:\n\nThe integer on the green card is strictly greater than the integer on the red card.\n\nThe integer on the blue card is strictly greater than the integer on the green card.\n\nDetermine whether the magic can be successful.\n\nConstraints\n\n1 \\leq A, B, C \\leq 7\n\n1 \\leq K \\leq 7\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\nK\n\nOutput\n\nIf the magic can be successful, print Yes; otherwise, print No.\n\nSample Input 1\n\n7 2 5\n3\n\nSample Output 1\n\nYes\n\nThe magic will be successful if, for example, he does the following operations:\n\nFirst, choose the blue card. The integers on the red, green, and blue cards are now 7, 2, and 10, respectively.\n\nSecond, choose the green card. The integers on the red, green, and blue cards are now 7, 4, and 10, respectively.\n\nThird, choose the green card. The integers on the red, green, and blue cards are now 7, 8, and 10, respectively.\n\nSample Input 2\n\n7 4 2\n3\n\nSample Output 2\n\nNo\n\nHe has no way to succeed in the magic with at most three operations.", "sample_input": "7 2 5\n3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02601", "source_text": "Score: 200 points\n\nProblem Statement\n\nM-kun has the following three cards:\n\nA red card with the integer A.\n\nA green card with the integer B.\n\nA blue card with the integer C.\n\nHe is a genius magician who can do the following operation at most K times:\n\nChoose one of the three cards and multiply the written integer by 2.\n\nHis magic is successful if both of the following conditions are satisfied after the operations:\n\nThe integer on the green card is strictly greater than the integer on the red card.\n\nThe integer on the blue card is strictly greater than the integer on the green card.\n\nDetermine whether the magic can be successful.\n\nConstraints\n\n1 \\leq A, B, C \\leq 7\n\n1 \\leq K \\leq 7\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\nK\n\nOutput\n\nIf the magic can be successful, print Yes; otherwise, print No.\n\nSample Input 1\n\n7 2 5\n3\n\nSample Output 1\n\nYes\n\nThe magic will be successful if, for example, he does the following operations:\n\nFirst, choose the blue card. The integers on the red, green, and blue cards are now 7, 2, and 10, respectively.\n\nSecond, choose the green card. The integers on the red, green, and blue cards are now 7, 4, and 10, respectively.\n\nThird, choose the green card. The integers on the red, green, and blue cards are now 7, 8, and 10, respectively.\n\nSample Input 2\n\n7 4 2\n3\n\nSample Output 2\n\nNo\n\nHe has no way to succeed in the magic with at most three operations.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4157, "cpu_time_ms": 550, "memory_kb": 56952}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s729415910", "group_id": "codeNet:p02602", "input_text": "object Main extends App {\n val nkInput = scala.io.StdIn.readLine()\n val nkArray = nkInput.split(\" \").map(_.toInt).toVector\n val n = nkArray(0)\n var k = nkArray(1)\n\n val aInput = scala.io.StdIn.readLine()\n val aArray = aInput.split(\" \").map(_.toLong).toVector\n\n var hikakuMotoIndex = 0\n\n (k to n - 1).foreach { i =>\n val hikakuSaki = aArray(i)\n val hikakuMoto = aArray(hikakuMotoIndex)\n\n if (hikakuSaki > hikakuMoto) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n hikakuMotoIndex = hikakuMotoIndex + 1\n }\n\n}", "language": "Scala", "metadata": {"date": 1595727012, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02602.html", "problem_id": "p02602", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02602/input.txt", "sample_output_relpath": "derived/input_output/data/p02602/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02602/Scala/s729415910.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s729415910", "user_id": "u105921924"}, "prompt_components": {"gold_output": "Yes\nNo\n", "input_to_evaluate": "object Main extends App {\n val nkInput = scala.io.StdIn.readLine()\n val nkArray = nkInput.split(\" \").map(_.toInt).toVector\n val n = nkArray(0)\n var k = nkArray(1)\n\n val aInput = scala.io.StdIn.readLine()\n val aArray = aInput.split(\" \").map(_.toLong).toVector\n\n var hikakuMotoIndex = 0\n\n (k to n - 1).foreach { i =>\n val hikakuSaki = aArray(i)\n val hikakuMoto = aArray(hikakuMotoIndex)\n\n if (hikakuSaki > hikakuMoto) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n hikakuMotoIndex = hikakuMotoIndex + 1\n }\n\n}", "problem_context": "Score: 300 points\n\nProblem Statement\n\nM-kun is a student in Aoki High School, where a year is divided into N terms.\n\nThere is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows:\n\nFor the first through (K-1)-th terms: not given.\n\nFor each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term.\n\nM-kun scored A_i in the exam at the end of the i-th term.\n\nFor each i such that K+1 \\leq i \\leq N, determine whether his grade for the i-th term is strictly greater than the grade for the (i-1)-th term.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq K \\leq N-1\n\n1 \\leq A_i \\leq 10^{9}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 A_3 \\ldots A_N\n\nOutput\n\nPrint the answer in N-K lines.\n\nThe i-th line should contain Yes if the grade for the (K+i)-th term is greater than the grade for the (K+i-1)-th term, and No otherwise.\n\nSample Input 1\n\n5 3\n96 98 95 100 20\n\nSample Output 1\n\nYes\nNo\n\nHis grade for each term is computed as follows:\n\n3-rd term: (96 \\times 98 \\times 95) = 893760\n\n4-th term: (98 \\times 95 \\times 100) = 931000\n\n5-th term: (95 \\times 100 \\times 20) = 190000\n\nSample Input 2\n\n3 2\n1001 869120 1001\n\nSample Output 2\n\nNo\n\nNote that the output should be No if the grade for the 3-rd term is equal to the grade for the 2-nd term.\n\nSample Input 3\n\n15 7\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9\n\nSample Output 3\n\nYes\nYes\nNo\nYes\nYes\nNo\nYes\nYes", "sample_input": "5 3\n96 98 95 100 20\n"}, "reference_outputs": ["Yes\nNo\n"], "source_document_id": "p02602", "source_text": "Score: 300 points\n\nProblem Statement\n\nM-kun is a student in Aoki High School, where a year is divided into N terms.\n\nThere is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows:\n\nFor the first through (K-1)-th terms: not given.\n\nFor each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term.\n\nM-kun scored A_i in the exam at the end of the i-th term.\n\nFor each i such that K+1 \\leq i \\leq N, determine whether his grade for the i-th term is strictly greater than the grade for the (i-1)-th term.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq K \\leq N-1\n\n1 \\leq A_i \\leq 10^{9}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 A_3 \\ldots A_N\n\nOutput\n\nPrint the answer in N-K lines.\n\nThe i-th line should contain Yes if the grade for the (K+i)-th term is greater than the grade for the (K+i-1)-th term, and No otherwise.\n\nSample Input 1\n\n5 3\n96 98 95 100 20\n\nSample Output 1\n\nYes\nNo\n\nHis grade for each term is computed as follows:\n\n3-rd term: (96 \\times 98 \\times 95) = 893760\n\n4-th term: (98 \\times 95 \\times 100) = 931000\n\n5-th term: (95 \\times 100 \\times 20) = 190000\n\nSample Input 2\n\n3 2\n1001 869120 1001\n\nSample Output 2\n\nNo\n\nNote that the output should be No if the grade for the 3-rd term is equal to the grade for the 2-nd term.\n\nSample Input 3\n\n15 7\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9\n\nSample Output 3\n\nYes\nYes\nNo\nYes\nYes\nNo\nYes\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1528, "memory_kb": 88264}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s814188030", "group_id": "codeNet:p02603", "input_text": "import scala.io.StdIn._\n\nobject Main extends App {\n\n val n = readInt()\n val A = readLine().split(\" \").map(_.toInt)\n\n def solve() = {\n var curMoney = 1000L\n for(i <- 0 until n-1) {\n if(A(i) < A(i+1)) {\n val stock = curMoney / A(i)\n curMoney %= A(i)\n curMoney += stock * A(i+1)\n }\n }\n curMoney\n }\n\n\n println(solve())\n\n}\n\n", "language": "Scala", "metadata": {"date": 1595791918, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s814188030.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s814188030", "user_id": "u947008426"}, "prompt_components": {"gold_output": "1685\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main extends App {\n\n val n = readInt()\n val A = readLine().split(\" \").map(_.toInt)\n\n def solve() = {\n var curMoney = 1000L\n for(i <- 0 until n-1) {\n if(A(i) < A(i+1)) {\n val stock = curMoney / A(i)\n curMoney %= A(i)\n curMoney += stock * A(i+1)\n }\n }\n curMoney\n }\n\n\n println(solve())\n\n}\n\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 501, "memory_kb": 54692}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s544074610", "group_id": "codeNet:p02603", "input_text": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\nimport java.lang\n\nimport scala.annotation.tailrec\nimport scala.collection.mutable.ArrayBuffer\nimport scala.reflect.ClassTag\n\nobject Main {\n def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {\n converter(in.readLine)\n }\n\n def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {\n get[String].split(\"\\\\s+\").map[T](converter)\n }\n\n implicit val idConverter: String => String = s => s\n implicit val intConverter: String => Int = s => Integer.parseInt(s)\n implicit val longConverter: String => Long = s => lang.Long.parseLong(s)\n\n def get[T1, T2](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2\n ): (T1, T2) = {\n getArray[String] match {\n case Array(v1, v2) => (converter1(v1), converter2(v2))\n }\n }\n\n def get[T1, T2, T3](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3\n ): (T1, T2, T3) = {\n getArray[String] match {\n case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))\n }\n }\n\n def get[T1, T2, T3, T4](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3,\n converter4: String => T4\n ): (T1, T2, T3, T4) = {\n getArray[String] match {\n case Array(v1, v2, v3, v4) => (converter1(v1), converter2(v2), converter3(v3), converter4(v4))\n }\n }\n\n implicit class TimesInt(val n: Int) {\n def times(f: Int => Unit): Unit = {\n for (i <- 0 until n) {\n f(i)\n }\n }\n }\n\n def primes(n: Long): ArrayBuffer[Long] = {\n val buf = ArrayBuffer.empty[Long]\n val s = Math.sqrt(n).toInt\n\n var v = n\n for (i <- 2 to s) {\n if (v == 1 || v == 0) {\n return buf\n } else {\n while (v % i == 0) {\n buf.append(i)\n v /= i\n }\n }\n }\n if (v > s) {\n buf.append(v)\n }\n buf\n }\n\n def divisors(n: Int): ArrayBuffer[Int] = {\n val buf = ArrayBuffer.empty[Int]\n val s = Math.sqrt(n).toInt\n\n for (i <- 1 to s) {\n if (n % i == 0) {\n buf.append(i)\n if (i != n / i) {\n buf.append(n / i)\n }\n }\n }\n buf\n }\n\n @tailrec\n def gcd(a: Long, b: Long): Long = {\n val reminder = a % b\n if (reminder == 0) {\n b\n } else {\n gcd(b, reminder)\n }\n }\n\n @tailrec\n def gcd(a: Int, b: Int): Int = {\n val reminder = a % b\n if (reminder == 0) {\n b\n } else {\n gcd(b, reminder)\n }\n }\n\n def lcm(a: Long, b: Long): Long = {\n a / gcd(a, b) * b\n }\n\n def toBitArray(n: Int, width: Int): Array[Boolean] = {\n val buf = ArrayBuffer.fill(width)(false)\n\n @tailrec\n def inner(n: Int, i: Int): Array[Boolean] = {\n buf(i) = (n & 1) == 0\n if (i == 0) {\n buf.toArray\n } else {\n inner(n / 2, i - 1)\n }\n }\n\n inner(n, width - 1)\n }\n\n def modpow(n: Long, p: Long, m: Long): Long = {\n @tailrec\n def inner(n: Long, p: Long, acc: Long): Long = {\n if (p == 0) {\n acc\n } else if ((p & 1) == 0) {\n inner(n * n % m, p >> 1, acc)\n } else {\n inner(n * n % m, p >> 1, acc * n % m)\n }\n }\n\n inner(n % m, p, 1)\n }\n\n def main(args: Array[String]): Unit = {\n implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n val n = get[Int]\n val as = getArray[Int]\n\n val das = Array.ofDim[Int](n - 1)\n for (i <- 0 until (n - 1)) {\n das(i) = as(i + 1) - as(i)\n }\n\n var money = 1000L\n var stock = 0L\n\n for(i <- das.indices) {\n if (das(i) > 0) {\n stock += money / as(i)\n money -= money / as(i) * as(i)\n } else if (das(i) < 0) {\n money += as(i) * stock\n stock = 0L\n }\n }\n\n money += as.last * stock\n\n out.println(money)\n out.flush()\n }\n}", "language": "Scala", "metadata": {"date": 1595726580, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s544074610.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s544074610", "user_id": "u178269371"}, "prompt_components": {"gold_output": "1685\n", "input_to_evaluate": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\nimport java.lang\n\nimport scala.annotation.tailrec\nimport scala.collection.mutable.ArrayBuffer\nimport scala.reflect.ClassTag\n\nobject Main {\n def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {\n converter(in.readLine)\n }\n\n def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {\n get[String].split(\"\\\\s+\").map[T](converter)\n }\n\n implicit val idConverter: String => String = s => s\n implicit val intConverter: String => Int = s => Integer.parseInt(s)\n implicit val longConverter: String => Long = s => lang.Long.parseLong(s)\n\n def get[T1, T2](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2\n ): (T1, T2) = {\n getArray[String] match {\n case Array(v1, v2) => (converter1(v1), converter2(v2))\n }\n }\n\n def get[T1, T2, T3](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3\n ): (T1, T2, T3) = {\n getArray[String] match {\n case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))\n }\n }\n\n def get[T1, T2, T3, T4](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3,\n converter4: String => T4\n ): (T1, T2, T3, T4) = {\n getArray[String] match {\n case Array(v1, v2, v3, v4) => (converter1(v1), converter2(v2), converter3(v3), converter4(v4))\n }\n }\n\n implicit class TimesInt(val n: Int) {\n def times(f: Int => Unit): Unit = {\n for (i <- 0 until n) {\n f(i)\n }\n }\n }\n\n def primes(n: Long): ArrayBuffer[Long] = {\n val buf = ArrayBuffer.empty[Long]\n val s = Math.sqrt(n).toInt\n\n var v = n\n for (i <- 2 to s) {\n if (v == 1 || v == 0) {\n return buf\n } else {\n while (v % i == 0) {\n buf.append(i)\n v /= i\n }\n }\n }\n if (v > s) {\n buf.append(v)\n }\n buf\n }\n\n def divisors(n: Int): ArrayBuffer[Int] = {\n val buf = ArrayBuffer.empty[Int]\n val s = Math.sqrt(n).toInt\n\n for (i <- 1 to s) {\n if (n % i == 0) {\n buf.append(i)\n if (i != n / i) {\n buf.append(n / i)\n }\n }\n }\n buf\n }\n\n @tailrec\n def gcd(a: Long, b: Long): Long = {\n val reminder = a % b\n if (reminder == 0) {\n b\n } else {\n gcd(b, reminder)\n }\n }\n\n @tailrec\n def gcd(a: Int, b: Int): Int = {\n val reminder = a % b\n if (reminder == 0) {\n b\n } else {\n gcd(b, reminder)\n }\n }\n\n def lcm(a: Long, b: Long): Long = {\n a / gcd(a, b) * b\n }\n\n def toBitArray(n: Int, width: Int): Array[Boolean] = {\n val buf = ArrayBuffer.fill(width)(false)\n\n @tailrec\n def inner(n: Int, i: Int): Array[Boolean] = {\n buf(i) = (n & 1) == 0\n if (i == 0) {\n buf.toArray\n } else {\n inner(n / 2, i - 1)\n }\n }\n\n inner(n, width - 1)\n }\n\n def modpow(n: Long, p: Long, m: Long): Long = {\n @tailrec\n def inner(n: Long, p: Long, acc: Long): Long = {\n if (p == 0) {\n acc\n } else if ((p & 1) == 0) {\n inner(n * n % m, p >> 1, acc)\n } else {\n inner(n * n % m, p >> 1, acc * n % m)\n }\n }\n\n inner(n % m, p, 1)\n }\n\n def main(args: Array[String]): Unit = {\n implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n val n = get[Int]\n val as = getArray[Int]\n\n val das = Array.ofDim[Int](n - 1)\n for (i <- 0 until (n - 1)) {\n das(i) = as(i + 1) - as(i)\n }\n\n var money = 1000L\n var stock = 0L\n\n for(i <- das.indices) {\n if (das(i) > 0) {\n stock += money / as(i)\n money -= money / as(i) * as(i)\n } else if (das(i) < 0) {\n money += as(i) * stock\n stock = 0L\n }\n }\n\n money += as.last * stock\n\n out.println(money)\n out.flush()\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4337, "cpu_time_ms": 530, "memory_kb": 57208}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s365194856", "group_id": "codeNet:p02606", "input_text": "object Main extends App {\n val lrdInput = scala.io.StdIn.readLine()\n val lrdArray = lrdInput.split(\" \").map(_.toInt).toSeq\n\n val l = lrdArray(0)\n val r = lrdArray(1)\n val d = lrdArray(2)\n\n var result = 0\n (l to r).foreach { i =>\n if (i % d == 0) {\n result = result + 1\n }\n }\n\n println(result)\n}", "language": "Scala", "metadata": {"date": 1594515846, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s365194856.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s365194856", "user_id": "u105921924"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main extends App {\n val lrdInput = scala.io.StdIn.readLine()\n val lrdArray = lrdInput.split(\" \").map(_.toInt).toSeq\n\n val l = lrdArray(0)\n val r = lrdArray(1)\n val d = lrdArray(2)\n\n var result = 0\n (l to r).foreach { i =>\n if (i % d == 0) {\n result = result + 1\n }\n }\n\n println(result)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 315, "cpu_time_ms": 514, "memory_kb": 54492}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s972365124", "group_id": "codeNet:p02608", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n var n = sc.nextInt()\n var ans = Array.fill(200050)(0)\n var a = 17\n for (i <- 1 to 105){\n for (j <- 1 to 105) {\n for (k <- 1 to 105) {\n ans((i*i+j*j+k*k+i*j+j*k+k*i)-1)+=1\n }\n }\n }\n for (i <- 0 until n){\n println(ans(i))\n }\n}\n", "language": "Scala", "metadata": {"date": 1594525379, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s972365124.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s972365124", "user_id": "u488417454"}, "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": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n var n = sc.nextInt()\n var ans = Array.fill(200050)(0)\n var a = 17\n for (i <- 1 to 105){\n for (j <- 1 to 105) {\n for (k <- 1 to 105) {\n ans((i*i+j*j+k*k+i*j+j*k+k*i)-1)+=1\n }\n }\n }\n for (i <- 0 until n){\n println(ans(i))\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 651, "memory_kb": 58084}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s919677502", "group_id": "codeNet:p02613", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val N = sc.nextInt()\n val hashMap = new scala.collection.mutable.HashMap[String, Int]()\n 1.to(N).foreach { _ =>\n val word = sc.next()\n val count = hashMap.getOrElse(word, 0)\n hashMap.update(word, count + 1)\n }\n val keys = Seq(\"AC\", \"WA\", \"TLE\", \"RE\")\n keys.foreach { key =>\n val count = hashMap.getOrElse(key, 0)\n println(s\"$key x $count\")\n }\n}\n", "language": "Scala", "metadata": {"date": 1595033909, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s919677502.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s919677502", "user_id": "u737111725"}, "prompt_components": {"gold_output": "AC x 3\nWA x 1\nTLE x 2\nRE x 0\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val N = sc.nextInt()\n val hashMap = new scala.collection.mutable.HashMap[String, Int]()\n 1.to(N).foreach { _ =>\n val word = sc.next()\n val count = hashMap.getOrElse(word, 0)\n hashMap.update(word, count + 1)\n }\n val keys = Seq(\"AC\", \"WA\", \"TLE\", \"RE\")\n keys.foreach { key =>\n val count = hashMap.getOrElse(key, 0)\n println(s\"$key x $count\")\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 740, "memory_kb": 59428}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s027916174", "group_id": "codeNet:p02613", "input_text": "object Main {\n def main(args: Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val N = sc.nextInt()\n val S = List.fill(N)(sc.next())\n val res = List(\"AC\", \"WA\", \"TLE\", \"RE\")\n for(r <- res){\n println(s\"$r x ${S.count(_ == r)}\")\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1594694917, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s027916174.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s027916174", "user_id": "u430175622"}, "prompt_components": {"gold_output": "AC x 3\nWA x 1\nTLE x 2\nRE x 0\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val N = sc.nextInt()\n val S = List.fill(N)(sc.next())\n val res = List(\"AC\", \"WA\", \"TLE\", \"RE\")\n for(r <- res){\n println(s\"$r x ${S.count(_ == r)}\")\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 781, "memory_kb": 64748}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s958657108", "group_id": "codeNet:p02613", "input_text": "object Main extends App {\n\n var N = scala.io.StdIn.readInt()\n var C0 = 0\n var C1 = 0 \n var C2 = 0\n var C3 = 0\n for(i <- 1 to N) {\n var S = io.StdIn.readLine()\n S match {\n case \"AC\" => C0 += 1 \n case \"WA\" => C1 += 1\n case \"TLE\" => C2 += 1\n case \"RE \" => C3 += 1\n }\n }\n\n println(\"AC ×\" + C0)\n println(\"WA ×\" + C1)\n println(\"TLE ×\" + C2)\n println(\"RE ×\" + C3)\n}", "language": "Scala", "metadata": {"date": 1594265024, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s958657108.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s958657108", "user_id": "u363845649"}, "prompt_components": {"gold_output": "AC x 3\nWA x 1\nTLE x 2\nRE x 0\n", "input_to_evaluate": "object Main extends App {\n\n var N = scala.io.StdIn.readInt()\n var C0 = 0\n var C1 = 0 \n var C2 = 0\n var C3 = 0\n for(i <- 1 to N) {\n var S = io.StdIn.readLine()\n S match {\n case \"AC\" => C0 += 1 \n case \"WA\" => C1 += 1\n case \"TLE\" => C2 += 1\n case \"RE \" => C3 += 1\n }\n }\n\n println(\"AC ×\" + C0)\n println(\"WA ×\" + C1)\n println(\"TLE ×\" + C2)\n println(\"RE ×\" + C3)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 522, "memory_kb": 56160}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s250833674", "group_id": "codeNet:p02613", "input_text": "import scala.io.StdIn\nimport scala.collection.mutable.{Map => MMap}\n\nobject Main extends App {\n val line = StdIn.readInt()\n\n val map = MMap[String,Int]().withDefaultValue(0)\n\n for(_ <- 1 to line){\n map(StdIn.readLine()) += 1\n }\n\n for(str <- Array(\"AC\",\"WA\",\"TLE\",\"RE\")){\n println(s\"$str x ${map(str)}\")\n }\n}\n", "language": "Scala", "metadata": {"date": 1593997905, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s250833674.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s250833674", "user_id": "u416662335"}, "prompt_components": {"gold_output": "AC x 3\nWA x 1\nTLE x 2\nRE x 0\n", "input_to_evaluate": "import scala.io.StdIn\nimport scala.collection.mutable.{Map => MMap}\n\nobject Main extends App {\n val line = StdIn.readInt()\n\n val map = MMap[String,Int]().withDefaultValue(0)\n\n for(_ <- 1 to line){\n map(StdIn.readLine()) += 1\n }\n\n for(str <- Array(\"AC\",\"WA\",\"TLE\",\"RE\")){\n println(s\"$str x ${map(str)}\")\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 320, "cpu_time_ms": 610, "memory_kb": 56420}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s574038753", "group_id": "codeNet:p02615", "input_text": "object Main extends App {\n\tval pw = new java.io.PrintWriter(System.out)\n\n\t@scala.annotation.tailrec\n\tdef loop(start: Int, end: Int)(f: Int => Unit): Unit =\n\t\tif (start < end) {\n\t\t\tf(start)\n\t\t\tloop(start + 1, end)(f)\n\t\t}\n\n\tval n = Scanner.nextInt\n\tval a = Array.fill(n)(Scanner.nextLong).sortWith(_ > _)\n\n\tpw.println(a(0) + 2L * a.tail.take((n-2) / 2).sum + (if (n % 2 == 0) 0 else a((n-1) / 2)))\n\tpw.flush()\n}\n\nobject Scanner {\n\tprivate val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0\n\n\t@inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126\n\t@inline private def hasNextByte(): Boolean = if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else true\n\t@inline private def hasNext(): Boolean = {\n\t\twhile (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1\n\t\thasNextByte()\n\t}\n\t@inline private def readByte(): Byte = if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else -1\n\n\tdef next(): String = {\n\t\tif(!hasNext()) ???\n\t\tval sb = new StringBuilder; var b = readByte()\n\t\twhile (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }\n\t\tsb.toString\n\t}\n\n\tdef nextInt(): Int = {\n\t\tval n = nextLong()\n\t\tif (n < Int.MinValue || Int.MaxValue < n) ???\n\t\tn.toInt\n\t}\n\n\tdef nextLong(): Long = {\n\t\tif(!hasNext()) ???\n\t\tvar minus = false; var b = readByte()\n\t\tif (b == '-') { minus = true; b = readByte() }\n\n\t\t@scala.annotation.tailrec\n\t\tdef go (b: Byte, n: Long = 0): Long = if ('0' <= b && b <= '9') go(readByte(), n * 10 + b - '0') else if (minus) -n else n\n\n\t\tgo(b)\n\t}\n\n\tdef nextDouble(): Double = next().toDouble\n}\n", "language": "Scala", "metadata": {"date": 1594003732, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s574038753.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s574038753", "user_id": "u822029894"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "object Main extends App {\n\tval pw = new java.io.PrintWriter(System.out)\n\n\t@scala.annotation.tailrec\n\tdef loop(start: Int, end: Int)(f: Int => Unit): Unit =\n\t\tif (start < end) {\n\t\t\tf(start)\n\t\t\tloop(start + 1, end)(f)\n\t\t}\n\n\tval n = Scanner.nextInt\n\tval a = Array.fill(n)(Scanner.nextLong).sortWith(_ > _)\n\n\tpw.println(a(0) + 2L * a.tail.take((n-2) / 2).sum + (if (n % 2 == 0) 0 else a((n-1) / 2)))\n\tpw.flush()\n}\n\nobject Scanner {\n\tprivate val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0\n\n\t@inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126\n\t@inline private def hasNextByte(): Boolean = if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else true\n\t@inline private def hasNext(): Boolean = {\n\t\twhile (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1\n\t\thasNextByte()\n\t}\n\t@inline private def readByte(): Byte = if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else -1\n\n\tdef next(): String = {\n\t\tif(!hasNext()) ???\n\t\tval sb = new StringBuilder; var b = readByte()\n\t\twhile (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }\n\t\tsb.toString\n\t}\n\n\tdef nextInt(): Int = {\n\t\tval n = nextLong()\n\t\tif (n < Int.MinValue || Int.MaxValue < n) ???\n\t\tn.toInt\n\t}\n\n\tdef nextLong(): Long = {\n\t\tif(!hasNext()) ???\n\t\tvar minus = false; var b = readByte()\n\t\tif (b == '-') { minus = true; b = readByte() }\n\n\t\t@scala.annotation.tailrec\n\t\tdef go (b: Byte, n: Long = 0): Long = if ('0' <= b && b <= '9') go(readByte(), n * 10 + b - '0') else if (minus) -n else n\n\n\t\tgo(b)\n\t}\n\n\tdef nextDouble(): Double = next().toDouble\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1577, "cpu_time_ms": 854, "memory_kb": 64424}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s536275007", "group_id": "codeNet:p02615", "input_text": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\nimport java.lang\n\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.mutable.ArrayBuffer\nimport scala.reflect.ClassTag\n\nobject Main {\n def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {\n converter(in.readLine)\n }\n\n def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {\n get[String].split(\"\\\\s+\").map[T](converter)\n }\n\n implicit val idConverter: String => String = s => s\n implicit val intConverter: String => Int = s => Integer.parseInt(s)\n implicit val longConverter: String => Long = s => lang.Long.parseLong(s)\n\n def get[T1, T2](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2\n ): (T1, T2) = {\n getArray[String] match {\n case Array(v1, v2) => (converter1(v1), converter2(v2))\n }\n }\n\n def get[T1, T2, T3](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3\n ): (T1, T2, T3) = {\n getArray[String] match {\n case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))\n }\n }\n\n def get[T1, T2, T3, T4](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3,\n converter4: String => T4\n ): (T1, T2, T3, T4) = {\n getArray[String] match {\n case Array(v1, v2, v3, v4) => (converter1(v1), converter2(v2), converter3(v3), converter4(v4))\n }\n }\n\n implicit class TimesInt(val n: Int) {\n def times(f: Int => Unit): Unit = {\n for (i <- 0 until n) {\n f(i)\n }\n }\n }\n\n def primes(n: Long): ArrayBuffer[Long] = {\n val buf = ArrayBuffer.empty[Long]\n val s = Math.sqrt(n).toInt\n\n var v = n\n for (i <- 2 to s) {\n if (v == 1 || v == 0) {\n return buf\n } else {\n while (v % i == 0) {\n buf.append(i)\n v /= i\n }\n }\n }\n if (v > s) {\n buf.append(v)\n }\n buf\n }\n\n def divisors(n: Int): ArrayBuffer[Int] = {\n val buf = ArrayBuffer.empty[Int]\n val s = Math.sqrt(n).toInt\n\n for (i <- 1 to s) {\n if (n % i == 0) {\n buf.append(i)\n if (i != n / i) {\n buf.append(n / i)\n }\n }\n }\n buf\n }\n\n @tailrec\n def gcd(a: Long, b: Long): Long = {\n val reminder = a % b\n if (reminder == 0) {\n b\n } else {\n gcd(b, reminder)\n }\n }\n\n @tailrec\n def gcd(a: Int, b: Int): Int = {\n val reminder = a % b\n if (reminder == 0) {\n b\n } else {\n gcd(b, reminder)\n }\n }\n\n def lcm(a: Long, b: Long): Long = {\n a / gcd(a, b) * b\n }\n\n def toBitArray(n: Int, width: Int): Array[Boolean] = {\n val buf = ArrayBuffer.fill(width)(false)\n\n @tailrec\n def inner(n: Int, i: Int): Array[Boolean] = {\n buf(i) = (n & 1) == 0\n if (i == 0) {\n buf.toArray\n } else {\n inner(n / 2, i - 1)\n }\n }\n\n inner(n, width - 1)\n }\n\n def modpow(n: Long, p: Long, m: Long): Long = {\n @tailrec\n def inner(n: Long, p: Long, acc: Long): Long = {\n if (p == 0) {\n acc\n } else if ((p & 1) == 0) {\n inner(n * n % m, p >> 1, acc)\n } else {\n inner(n * n % m, p >> 1, acc * n % m)\n }\n }\n\n inner(n % m, p, 1)\n }\n\n def main(args: Array[String]): Unit = {\n implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n val n = get[Int]\n val as = getArray[Int]\n\n val asIn = mutable.PriorityQueue.empty[Int](Ordering[Int])\n asIn.addAll(as)\n val asOut = mutable.PriorityQueue.empty[Int](Ordering[Int])\n\n asOut += asIn.dequeue()\n\n var count = 0L\n for(ai <- asIn) {\n val head = asOut.dequeue()\n count += head\n asOut += ai\n asOut += ai\n }\n\n out.println(count)\n out.flush()\n }\n}", "language": "Scala", "metadata": {"date": 1594000055, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s536275007.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s536275007", "user_id": "u178269371"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\nimport java.lang\n\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.mutable.ArrayBuffer\nimport scala.reflect.ClassTag\n\nobject Main {\n def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {\n converter(in.readLine)\n }\n\n def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {\n get[String].split(\"\\\\s+\").map[T](converter)\n }\n\n implicit val idConverter: String => String = s => s\n implicit val intConverter: String => Int = s => Integer.parseInt(s)\n implicit val longConverter: String => Long = s => lang.Long.parseLong(s)\n\n def get[T1, T2](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2\n ): (T1, T2) = {\n getArray[String] match {\n case Array(v1, v2) => (converter1(v1), converter2(v2))\n }\n }\n\n def get[T1, T2, T3](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3\n ): (T1, T2, T3) = {\n getArray[String] match {\n case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))\n }\n }\n\n def get[T1, T2, T3, T4](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3,\n converter4: String => T4\n ): (T1, T2, T3, T4) = {\n getArray[String] match {\n case Array(v1, v2, v3, v4) => (converter1(v1), converter2(v2), converter3(v3), converter4(v4))\n }\n }\n\n implicit class TimesInt(val n: Int) {\n def times(f: Int => Unit): Unit = {\n for (i <- 0 until n) {\n f(i)\n }\n }\n }\n\n def primes(n: Long): ArrayBuffer[Long] = {\n val buf = ArrayBuffer.empty[Long]\n val s = Math.sqrt(n).toInt\n\n var v = n\n for (i <- 2 to s) {\n if (v == 1 || v == 0) {\n return buf\n } else {\n while (v % i == 0) {\n buf.append(i)\n v /= i\n }\n }\n }\n if (v > s) {\n buf.append(v)\n }\n buf\n }\n\n def divisors(n: Int): ArrayBuffer[Int] = {\n val buf = ArrayBuffer.empty[Int]\n val s = Math.sqrt(n).toInt\n\n for (i <- 1 to s) {\n if (n % i == 0) {\n buf.append(i)\n if (i != n / i) {\n buf.append(n / i)\n }\n }\n }\n buf\n }\n\n @tailrec\n def gcd(a: Long, b: Long): Long = {\n val reminder = a % b\n if (reminder == 0) {\n b\n } else {\n gcd(b, reminder)\n }\n }\n\n @tailrec\n def gcd(a: Int, b: Int): Int = {\n val reminder = a % b\n if (reminder == 0) {\n b\n } else {\n gcd(b, reminder)\n }\n }\n\n def lcm(a: Long, b: Long): Long = {\n a / gcd(a, b) * b\n }\n\n def toBitArray(n: Int, width: Int): Array[Boolean] = {\n val buf = ArrayBuffer.fill(width)(false)\n\n @tailrec\n def inner(n: Int, i: Int): Array[Boolean] = {\n buf(i) = (n & 1) == 0\n if (i == 0) {\n buf.toArray\n } else {\n inner(n / 2, i - 1)\n }\n }\n\n inner(n, width - 1)\n }\n\n def modpow(n: Long, p: Long, m: Long): Long = {\n @tailrec\n def inner(n: Long, p: Long, acc: Long): Long = {\n if (p == 0) {\n acc\n } else if ((p & 1) == 0) {\n inner(n * n % m, p >> 1, acc)\n } else {\n inner(n * n % m, p >> 1, acc * n % m)\n }\n }\n\n inner(n % m, p, 1)\n }\n\n def main(args: Array[String]): Unit = {\n implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n val n = get[Int]\n val as = getArray[Int]\n\n val asIn = mutable.PriorityQueue.empty[Int](Ordering[Int])\n asIn.addAll(as)\n val asOut = mutable.PriorityQueue.empty[Int](Ordering[Int])\n\n asOut += asIn.dequeue()\n\n var count = 0L\n for(ai <- asIn) {\n val head = asOut.dequeue()\n count += head\n asOut += ai\n asOut += ai\n }\n\n out.println(count)\n out.flush()\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4282, "cpu_time_ms": 1084, "memory_kb": 90344}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s135529263", "group_id": "codeNet:p02616", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n, k = sc.nextInt()\n val a = Array.fill(n)(sc.nextLong())\n\n val mod = 1000000007\n\n def minus(a: Long, b: Long): Long = (a - b + mod) % mod\n def times(a: Long, b: Long): Long = (a * b) % mod\n\n val b = a.filter(_ != 0).map(e => (e.abs, e)).sorted\n if (b.length < k) {\n println(0)\n } else if (b.length == k) {\n if (b.count(_._2 < 0) % 2 == 0) {\n println(b.map(_._1).reduceLeft(times))\n } else {\n if (a.contains(0)) {\n println(0)\n } else {\n println(minus(0, b.map(_._1).reduceLeft(times)))\n }\n }\n } else {\n if (b.forall(_._2 > 0)) {\n println(b.takeRight(k).map(_._1).reduceLeft(times))\n } else if (b.forall(_._2 < 0)) {\n if (k % 2 == 0) {\n println(b.takeRight(k).map(_._1).reduceLeft(times))\n } else {\n if (a.contains(0)) {\n println(0)\n } else {\n println(minus(0, b.take(k).map(_._1).reduceLeft(times)))\n }\n }\n } else {\n val (r, c) = b.splitAt(b.length - k)\n if (c.count(_._2 < 0) % 2 == 0) {\n println(c.map(_._1).reduceLeft(times))\n } else {\n val pf = c.indexWhere(_._2 > 0)\n val mf = c.indexWhere(_._2 < 0)\n if (pf == -1) {\n c(mf) = r.findLast(_._2 > 0).get\n } else {\n val ml = r.findLast(_._2 < 0)\n val pl = r.findLast(_._2 > 0)\n var pd = Long.MaxValue\n var md = Long.MaxValue\n if (ml.isDefined) {\n pd = c(pf)._1 - ml.get._1\n }\n if (pl.isDefined) {\n md = c(mf)._1 - pl.get._1\n }\n if (pd < md) {\n c(pf) = ml.get\n } else {\n c(mf) = pl.get\n }\n }\n println(c.map(_._1).reduceLeft(times))\n }\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1593981471, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s135529263.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s135529263", "user_id": "u191819389"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n, k = sc.nextInt()\n val a = Array.fill(n)(sc.nextLong())\n\n val mod = 1000000007\n\n def minus(a: Long, b: Long): Long = (a - b + mod) % mod\n def times(a: Long, b: Long): Long = (a * b) % mod\n\n val b = a.filter(_ != 0).map(e => (e.abs, e)).sorted\n if (b.length < k) {\n println(0)\n } else if (b.length == k) {\n if (b.count(_._2 < 0) % 2 == 0) {\n println(b.map(_._1).reduceLeft(times))\n } else {\n if (a.contains(0)) {\n println(0)\n } else {\n println(minus(0, b.map(_._1).reduceLeft(times)))\n }\n }\n } else {\n if (b.forall(_._2 > 0)) {\n println(b.takeRight(k).map(_._1).reduceLeft(times))\n } else if (b.forall(_._2 < 0)) {\n if (k % 2 == 0) {\n println(b.takeRight(k).map(_._1).reduceLeft(times))\n } else {\n if (a.contains(0)) {\n println(0)\n } else {\n println(minus(0, b.take(k).map(_._1).reduceLeft(times)))\n }\n }\n } else {\n val (r, c) = b.splitAt(b.length - k)\n if (c.count(_._2 < 0) % 2 == 0) {\n println(c.map(_._1).reduceLeft(times))\n } else {\n val pf = c.indexWhere(_._2 > 0)\n val mf = c.indexWhere(_._2 < 0)\n if (pf == -1) {\n c(mf) = r.findLast(_._2 > 0).get\n } else {\n val ml = r.findLast(_._2 < 0)\n val pl = r.findLast(_._2 > 0)\n var pd = Long.MaxValue\n var md = Long.MaxValue\n if (ml.isDefined) {\n pd = c(pf)._1 - ml.get._1\n }\n if (pl.isDefined) {\n md = c(mf)._1 - pl.get._1\n }\n if (pd < md) {\n c(pf) = ml.get\n } else {\n c(mf) = pl.get\n }\n }\n println(c.map(_._1).reduceLeft(times))\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1823, "cpu_time_ms": 1408, "memory_kb": 75952}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s430246102", "group_id": "codeNet:p02619", "input_text": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\nimport scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}\nimport scala.util.Random\nimport java.util.Date\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val D = in.next().toInt\n val c = new Array[Long](26+1)\n val s = Array.ofDim[Long](D+1, 26+1)\n\n for (i <- 1 to 26) {\n c(i) = in.next().toInt\n }\n for (d <- 1 to D) {\n for (i <- 1 to 26) {\n s(d)(i) = in.next().toInt\n }\n }\n\n // optional\n val t = new Array[Int](D+1)\n for (i <- 1 to D) {\n t(i) = in.next().toInt\n }\n\n\n def calcScore(t: Array[Int]): Long = {\n var res = 0L\n\n val last = new Array[Int](26+1)\n for (day <- 1 to D) {\n val now = t(day)\n last(now) = day\n\n res += s(day)(now)\n for (contest <- 1 to 26) {\n res -= c(contest) * (day - last(contest))\n }\n pw.println(res)\n }\n\n res\n }\n\n calcScore(t)\n pw.flush()\n}\n\nobject Sub {\n def print2DimArray[A](mat: Array[Array[A]]): Unit = {\n mat.foreach(lin => println(lin.toList))\n }\n}\n\nclass InputReader(stream: InputStream) {\n private[this] val reader = new BufferedReader(new InputStreamReader(stream))\n private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n", "language": "Scala", "metadata": {"date": 1594503785, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02619.html", "problem_id": "p02619", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02619/input.txt", "sample_output_relpath": "derived/input_output/data/p02619/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02619/Scala/s430246102.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s430246102", "user_id": "u098968285"}, "prompt_components": {"gold_output": "18398\n35037\n51140\n65837\n79325\n", "input_to_evaluate": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\nimport scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}\nimport scala.util.Random\nimport java.util.Date\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val D = in.next().toInt\n val c = new Array[Long](26+1)\n val s = Array.ofDim[Long](D+1, 26+1)\n\n for (i <- 1 to 26) {\n c(i) = in.next().toInt\n }\n for (d <- 1 to D) {\n for (i <- 1 to 26) {\n s(d)(i) = in.next().toInt\n }\n }\n\n // optional\n val t = new Array[Int](D+1)\n for (i <- 1 to D) {\n t(i) = in.next().toInt\n }\n\n\n def calcScore(t: Array[Int]): Long = {\n var res = 0L\n\n val last = new Array[Int](26+1)\n for (day <- 1 to D) {\n val now = t(day)\n last(now) = day\n\n res += s(day)(now)\n for (contest <- 1 to 26) {\n res -= c(contest) * (day - last(contest))\n }\n pw.println(res)\n }\n\n res\n }\n\n calcScore(t)\n pw.flush()\n}\n\nobject Sub {\n def print2DimArray[A](mat: Array[Array[A]]): Unit = {\n mat.foreach(lin => println(lin.toList))\n }\n}\n\nclass InputReader(stream: InputStream) {\n private[this] val reader = new BufferedReader(new InputStreamReader(stream))\n private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n", "problem_context": "(Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.)\n\nBeginner's Guide\n\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement\n\nYou will be given a contest schedule for D days.\nFor each d=1,2,\\ldots,D, calculate the satisfaction at the end of day d.\n\nInput\n\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\n\nD\nc_1 c_2 \\cdots c_{26}\ns_{1,1} s_{1,2} \\cdots s_{1,26}\n\\vdots\ns_{D,1} s_{D,2} \\cdots s_{D,26}\nt_1\nt_2\n\\vdots\nt_D\n\nThe constraints and generation methods for the input part are the same as those for Problem A.\n\nFor each d, t_d is an integer satisfying 1\\leq t_d \\leq 26, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput\n\nLet v_d be the satisfaction at the end of day d.\nPrint D integers v_d to Standard Output in the following format:\n\nv_1\nv_2\n\\vdots\nv_D\n\nSample Input 1\n\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1\n\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step\n\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,\\ldots,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\n\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "sample_input": "5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n"}, "reference_outputs": ["18398\n35037\n51140\n65837\n79325\n"], "source_document_id": "p02619", "source_text": "(Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.)\n\nBeginner's Guide\n\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement\n\nYou will be given a contest schedule for D days.\nFor each d=1,2,\\ldots,D, calculate the satisfaction at the end of day d.\n\nInput\n\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\n\nD\nc_1 c_2 \\cdots c_{26}\ns_{1,1} s_{1,2} \\cdots s_{1,26}\n\\vdots\ns_{D,1} s_{D,2} \\cdots s_{D,26}\nt_1\nt_2\n\\vdots\nt_D\n\nThe constraints and generation methods for the input part are the same as those for Problem A.\n\nFor each d, t_d is an integer satisfying 1\\leq t_d \\leq 26, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput\n\nLet v_d be the satisfaction at the end of day d.\nPrint D integers v_d to Standard Output in the following format:\n\nv_1\nv_2\n\\vdots\nv_D\n\nSample Input 1\n\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1\n\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step\n\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,\\ldots,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\n\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1511, "cpu_time_ms": 532, "memory_kb": 54844}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s360679896", "group_id": "codeNet:p02621", "input_text": "object methods {\n def solver: Unit = {\n val scanner = new java.util.Scanner(System.in)\n val tempList: Seq[Seq[String]] = {\n for(line <- io.Source.stdin.getLines()) yield {\n line.split(' ').toSeq\n }\n }.toSeq\n\n val num: Int = tempList(0)(0).toInt\n \n val calc: Int = num + num*num + num*num*num \n\n\n println(calc)\n }\n}\n\nobject Main extends App {\n methods.solver\n}", "language": "Scala", "metadata": {"date": 1593307245, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s360679896.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s360679896", "user_id": "u570039786"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "object methods {\n def solver: Unit = {\n val scanner = new java.util.Scanner(System.in)\n val tempList: Seq[Seq[String]] = {\n for(line <- io.Source.stdin.getLines()) yield {\n line.split(' ').toSeq\n }\n }.toSeq\n\n val num: Int = tempList(0)(0).toInt\n \n val calc: Int = num + num*num + num*num*num \n\n\n println(calc)\n }\n}\n\nobject Main extends App {\n methods.solver\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 557, "memory_kb": 55528}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s556021377", "group_id": "codeNet:p02621", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n import scala.io.StdIn.readLine\n val a = readLine.split(\" \").map(_.toInt).head\n\n\n println(a + (a * a) + (a * a * a))\n }\n}\n", "language": "Scala", "metadata": {"date": 1593306114, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s556021377.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s556021377", "user_id": "u014716041"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n import scala.io.StdIn.readLine\n val a = readLine.split(\" \").map(_.toInt).head\n\n\n println(a + (a * a) + (a * a * a))\n }\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 529, "memory_kb": 54524}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s960574286", "group_id": "codeNet:p02627", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val input = io.StdIn.readChar\n if( input.toInt <= 90 ) println( 'A' )\n else println( 'a' )\n }\n}", "language": "Scala", "metadata": {"date": 1592978827, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s960574286.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s960574286", "user_id": "u888177577"}, "prompt_components": {"gold_output": "A\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val input = io.StdIn.readChar\n if( input.toInt <= 90 ) println( 'A' )\n else 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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 54600}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s180104508", "group_id": "codeNet:p02627", "input_text": "import java.util.Scanner\n\nimport scala.io.StdIn._\nobject Main extends App {\n\n\n val a = scala.io.StdIn.readLine()\n\n def solve(): String = {\n if(('a' to 'z').toString.contains(a)) \"a\" else \"A\"\n }\n\n println(solve())\n\n}\n", "language": "Scala", "metadata": {"date": 1592787831, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s180104508.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s180104508", "user_id": "u947008426"}, "prompt_components": {"gold_output": "A\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.io.StdIn._\nobject Main extends App {\n\n\n val a = scala.io.StdIn.readLine()\n\n def solve(): String = {\n if(('a' to 'z').toString.contains(a)) \"a\" else \"A\"\n }\n\n println(solve())\n\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 223, "cpu_time_ms": 494, "memory_kb": 55416}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s233215506", "group_id": "codeNet:p02627", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val s = sc.next().head\n if ('a' <= s && s <= 'z') {\n println(\"a\")\n } else {\n println(\"A\")\n }\n}\n", "language": "Scala", "metadata": {"date": 1592787734, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s233215506.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s233215506", "user_id": "u191819389"}, "prompt_components": {"gold_output": "A\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val s = sc.next().head\n if ('a' <= s && s <= 'z') {\n println(\"a\")\n } else {\n println(\"A\")\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 527, "memory_kb": 55196}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s515673085", "group_id": "codeNet:p02628", "input_text": "object Main extends App {\n\n\n val Array(n, k) = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n val pArr = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n\n def solve(): Int = {\n pArr.sorted.take(k).sum\n }\n\n println(solve())\n\n}\n", "language": "Scala", "metadata": {"date": 1592788270, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s515673085.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s515673085", "user_id": "u947008426"}, "prompt_components": {"gold_output": "210\n", "input_to_evaluate": "object Main extends App {\n\n\n val Array(n, k) = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n val pArr = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n\n def solve(): Int = {\n pArr.sorted.take(k).sum\n }\n\n println(solve())\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 533, "memory_kb": 54912}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s539008381", "group_id": "codeNet:p02628", "input_text": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\nimport java.lang\n\nimport scala.annotation.tailrec\nimport scala.collection.mutable.ArrayBuffer\nimport scala.reflect.ClassTag\n\nobject Main {\n def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {\n converter(in.readLine)\n }\n\n def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {\n get[String].split(\"\\\\s+\").map[T](converter)\n }\n\n implicit val idConverter: String => String = s => s\n implicit val intConverter: String => Int = s => Integer.parseInt(s)\n implicit val longConverter: String => Long = s => lang.Long.parseLong(s)\n\n def get[T1, T2](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2\n ): (T1, T2) = {\n getArray[String] match {\n case Array(v1, v2) => (converter1(v1), converter2(v2))\n }\n }\n\n def get[T1, T2, T3](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3\n ): (T1, T2, T3) = {\n getArray[String] match {\n case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))\n }\n }\n\n def get[T1, T2, T3, T4](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3,\n converter4: String => T4\n ): (T1, T2, T3, T4) = {\n getArray[String] match {\n case Array(v1, v2, v3, v4) => (converter1(v1), converter2(v2), converter3(v3), converter4(v4))\n }\n }\n\n implicit class TimesInt(val n: Int) {\n def times(f: Int => Unit): Unit = {\n for (i <- 0 until n) {\n f(i)\n }\n }\n }\n\n def primes(n: Long): ArrayBuffer[Long] = {\n val buf = ArrayBuffer.empty[Long]\n val s = Math.sqrt(n).toInt\n\n var v = n\n for (i <- 2 to s) {\n if (v == 1 || v == 0) {\n return buf\n } else {\n while (v % i == 0) {\n buf.append(i)\n v /= i\n }\n }\n }\n if (v > s) {\n buf.append(v)\n }\n buf\n }\n\n def divisors(n: Int): ArrayBuffer[Int] = {\n val buf = ArrayBuffer.empty[Int]\n val s = Math.sqrt(n).toInt\n\n for (i <- 1 to s) {\n if (n % i == 0) {\n buf.append(i)\n if (i != n / i) {\n buf.append(n / i)\n }\n }\n }\n buf\n }\n\n @tailrec\n def gcd(a: Long, b: Long): Long = {\n val reminder = a % b\n if (reminder == 0) {\n b\n } else {\n gcd(b, reminder)\n }\n }\n\n def lcm(a: Long, b: Long): Long = {\n a / gcd(a, b) * b\n }\n\n def toBitArray(n: Int, width: Int): Array[Boolean] = {\n val buf = ArrayBuffer.fill(width)(false)\n\n @tailrec\n def inner(n: Int, i: Int): Array[Boolean] = {\n buf(i) = (n & 1) == 0\n if (i == 0) {\n buf.toArray\n } else {\n inner(n / 2, i - 1)\n }\n }\n\n inner(n, width - 1)\n }\n\n def main(args: Array[String]): Unit = {\n implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n val (n, k) = get[Int,Int]\n val ps = getArray[Int].sorted\n\n out.println(ps.take(k).sum)\n \n out.flush()\n }\n}", "language": "Scala", "metadata": {"date": 1592787787, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s539008381.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s539008381", "user_id": "u178269371"}, "prompt_components": {"gold_output": "210\n", "input_to_evaluate": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\nimport java.lang\n\nimport scala.annotation.tailrec\nimport scala.collection.mutable.ArrayBuffer\nimport scala.reflect.ClassTag\n\nobject Main {\n def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {\n converter(in.readLine)\n }\n\n def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {\n get[String].split(\"\\\\s+\").map[T](converter)\n }\n\n implicit val idConverter: String => String = s => s\n implicit val intConverter: String => Int = s => Integer.parseInt(s)\n implicit val longConverter: String => Long = s => lang.Long.parseLong(s)\n\n def get[T1, T2](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2\n ): (T1, T2) = {\n getArray[String] match {\n case Array(v1, v2) => (converter1(v1), converter2(v2))\n }\n }\n\n def get[T1, T2, T3](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3\n ): (T1, T2, T3) = {\n getArray[String] match {\n case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))\n }\n }\n\n def get[T1, T2, T3, T4](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3,\n converter4: String => T4\n ): (T1, T2, T3, T4) = {\n getArray[String] match {\n case Array(v1, v2, v3, v4) => (converter1(v1), converter2(v2), converter3(v3), converter4(v4))\n }\n }\n\n implicit class TimesInt(val n: Int) {\n def times(f: Int => Unit): Unit = {\n for (i <- 0 until n) {\n f(i)\n }\n }\n }\n\n def primes(n: Long): ArrayBuffer[Long] = {\n val buf = ArrayBuffer.empty[Long]\n val s = Math.sqrt(n).toInt\n\n var v = n\n for (i <- 2 to s) {\n if (v == 1 || v == 0) {\n return buf\n } else {\n while (v % i == 0) {\n buf.append(i)\n v /= i\n }\n }\n }\n if (v > s) {\n buf.append(v)\n }\n buf\n }\n\n def divisors(n: Int): ArrayBuffer[Int] = {\n val buf = ArrayBuffer.empty[Int]\n val s = Math.sqrt(n).toInt\n\n for (i <- 1 to s) {\n if (n % i == 0) {\n buf.append(i)\n if (i != n / i) {\n buf.append(n / i)\n }\n }\n }\n buf\n }\n\n @tailrec\n def gcd(a: Long, b: Long): Long = {\n val reminder = a % b\n if (reminder == 0) {\n b\n } else {\n gcd(b, reminder)\n }\n }\n\n def lcm(a: Long, b: Long): Long = {\n a / gcd(a, b) * b\n }\n\n def toBitArray(n: Int, width: Int): Array[Boolean] = {\n val buf = ArrayBuffer.fill(width)(false)\n\n @tailrec\n def inner(n: Int, i: Int): Array[Boolean] = {\n buf(i) = (n & 1) == 0\n if (i == 0) {\n buf.toArray\n } else {\n inner(n / 2, i - 1)\n }\n }\n\n inner(n, width - 1)\n }\n\n def main(args: Array[String]): Unit = {\n implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n val (n, k) = get[Int,Int]\n val ps = getArray[Int].sorted\n\n out.println(ps.take(k).sum)\n \n out.flush()\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3492, "cpu_time_ms": 534, "memory_kb": 57296}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s877792776", "group_id": "codeNet:p02630", "input_text": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val N = in.nextInt\n val As = new Array[Long](100_001)\n val sum = (1 to N).map{_ =>\n val i = in.nextInt\n As(i) += 1\n i.toLong\n }.sum\n\n val Q = in.nextInt\n (1 to Q).foldLeft(sum) {(sum, i) =>\n val from = in.nextInt\n val to = in.nextInt\n val newSum = sum + (to - from) * As(from)\n println(newSum)\n As(to) += As(from)\n As(from) = 0\n newSum\n }\n}", "language": "Scala", "metadata": {"date": 1592851994, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s877792776.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s877792776", "user_id": "u132324749"}, "prompt_components": {"gold_output": "11\n12\n16\n", "input_to_evaluate": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val N = in.nextInt\n val As = new Array[Long](100_001)\n val sum = (1 to N).map{_ =>\n val i = in.nextInt\n As(i) += 1\n i.toLong\n }.sum\n\n val Q = in.nextInt\n (1 to Q).foldLeft(sum) {(sum, i) =>\n val from = in.nextInt\n val to = in.nextInt\n val newSum = sum + (to - from) * As(from)\n println(newSum)\n As(to) += As(from)\n As(from) = 0\n newSum\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1419, "memory_kb": 63764}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s346616322", "group_id": "codeNet:p02639", "input_text": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\nimport java.lang\n\nimport scala.collection.mutable.ArrayBuffer\nimport scala.reflect.ClassTag\n\nobject Main {\n def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {\n converter(in.readLine)\n }\n\n def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {\n get[String].split(\"\\\\s+\").map[T](converter)\n }\n\n implicit val idConverter: String => String = s => s\n implicit val intConverter: String => Int = s => Integer.parseInt(s)\n implicit val longConverter: String => Long = s => lang.Long.parseLong(s)\n\n def get[T1, T2](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2\n ): (T1, T2) = {\n getArray[String] match {\n case Array(v1, v2) => (converter1(v1), converter2(v2))\n }\n }\n\n def get[T1, T2, T3](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3\n ): (T1, T2, T3) = {\n getArray[String] match {\n case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))\n }\n }\n\n implicit class TimesInt(val n: Int) {\n def times(f: Int => Unit): Unit = {\n for (i <- 0 until n) {\n f(i)\n }\n }\n }\n\n def primes(n: Long): ArrayBuffer[Long] = {\n val buf = ArrayBuffer.empty[Long]\n val s = Math.sqrt(n).toInt\n\n var v = n\n for (i <- 2 to s) {\n if (v == 1 || v == 0) {\n return buf\n } else {\n while (v % i == 0) {\n buf.append(i)\n v /= i\n }\n }\n }\n if (v > s) {\n buf.append(v)\n }\n buf\n }\n\n def main(args: Array[String]): Unit = {\n implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n val xs = getArray[Int]\n\n out.println(\n xs.zipWithIndex.find {\n case (x, i) => x == 0\n }.get._2 + 1\n )\n\n out.flush()\n }\n}", "language": "Scala", "metadata": {"date": 1592182906, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s346616322.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s346616322", "user_id": "u178269371"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\nimport java.lang\n\nimport scala.collection.mutable.ArrayBuffer\nimport scala.reflect.ClassTag\n\nobject Main {\n def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {\n converter(in.readLine)\n }\n\n def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {\n get[String].split(\"\\\\s+\").map[T](converter)\n }\n\n implicit val idConverter: String => String = s => s\n implicit val intConverter: String => Int = s => Integer.parseInt(s)\n implicit val longConverter: String => Long = s => lang.Long.parseLong(s)\n\n def get[T1, T2](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2\n ): (T1, T2) = {\n getArray[String] match {\n case Array(v1, v2) => (converter1(v1), converter2(v2))\n }\n }\n\n def get[T1, T2, T3](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3\n ): (T1, T2, T3) = {\n getArray[String] match {\n case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))\n }\n }\n\n implicit class TimesInt(val n: Int) {\n def times(f: Int => Unit): Unit = {\n for (i <- 0 until n) {\n f(i)\n }\n }\n }\n\n def primes(n: Long): ArrayBuffer[Long] = {\n val buf = ArrayBuffer.empty[Long]\n val s = Math.sqrt(n).toInt\n\n var v = n\n for (i <- 2 to s) {\n if (v == 1 || v == 0) {\n return buf\n } else {\n while (v % i == 0) {\n buf.append(i)\n v /= i\n }\n }\n }\n if (v > s) {\n buf.append(v)\n }\n buf\n }\n\n def main(args: Array[String]): Unit = {\n implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n val xs = getArray[Int]\n\n out.println(\n xs.zipWithIndex.find {\n case (x, i) => x == 0\n }.get._2 + 1\n )\n\n out.flush()\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2189, "cpu_time_ms": 479, "memory_kb": 56976}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s078075605", "group_id": "codeNet:p02639", "input_text": "import scala.io.StdIn._\nobject Main extends App {\n\n val arr = readLine().split(\" \").map(_.toInt)\n\n def solve() = {\n arr.indexOf(0) + 1\n }\n\n println(solve())\n\n}", "language": "Scala", "metadata": {"date": 1592182904, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s078075605.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s078075605", "user_id": "u947008426"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import scala.io.StdIn._\nobject Main extends App {\n\n val arr = readLine().split(\" \").map(_.toInt)\n\n def solve() = {\n arr.indexOf(0) + 1\n }\n\n println(solve())\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 511, "memory_kb": 54488}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s370301735", "group_id": "codeNet:p02640", "input_text": "import scala.io.StdIn._\n\nobject Main extends App {\n val Array(x, y) = readLine.split(\" \").map(_.toInt)\n\n val ans = (0 to 50).exists { i =>\n i <= x &&\n i * 2 + (x - i) * 4 == y\n }\n\n println(if (ans) \"Yes\" else \"No\")\n}\n\n", "language": "Scala", "metadata": {"date": 1592540280, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s370301735.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s370301735", "user_id": "u611263604"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main extends App {\n val Array(x, y) = readLine.split(\" \").map(_.toInt)\n\n val ans = (0 to 50).exists { i =>\n i <= x &&\n i * 2 + (x - i) * 4 == y\n }\n\n println(if (ans) \"Yes\" else \"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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 485, "memory_kb": 54756}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s371326892", "group_id": "codeNet:p02640", "input_text": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val X, Y = in.nextInt\n val judge = Y % 2 == 0 && Y >= X * 2 && Y <= X * 4\n println(if (judge) \"Yes\" else \"No\")\n}", "language": "Scala", "metadata": {"date": 1592327938, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s371326892.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s371326892", "user_id": "u132324749"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val X, Y = in.nextInt\n val judge = Y % 2 == 0 && Y >= X * 2 && Y <= X * 4\n println(if (judge) \"Yes\" else \"No\")\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 186, "cpu_time_ms": 489, "memory_kb": 55404}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s514583941", "group_id": "codeNet:p02640", "input_text": "object Main extends App {\n val xy = scala.io.StdIn.readLine()\n val xyArray = xy.split(\" \").map(_.toInt).toSeq\n val x = xyArray(0)\n val y = xyArray(1)\n\n if (y % 2 != 0) {\n println(\"No\")\n } else if (x * 4 < y) {\n println(\"No\")\n } else if (x * 2 > y){\n println(\"No\")\n } else {\n println(\"Yes\")\n }\n}", "language": "Scala", "metadata": {"date": 1592183651, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s514583941.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s514583941", "user_id": "u105921924"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n val xy = scala.io.StdIn.readLine()\n val xyArray = xy.split(\" \").map(_.toInt).toSeq\n val x = xyArray(0)\n val y = xyArray(1)\n\n if (y % 2 != 0) {\n println(\"No\")\n } else if (x * 4 < y) {\n println(\"No\")\n } else if (x * 2 > y){\n println(\"No\")\n } else {\n println(\"Yes\")\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 512, "memory_kb": 54692}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s304944263", "group_id": "codeNet:p02640", "input_text": "object Main extends App{\n val sc = new java.util.Scanner(System.in)\n var a , b=sc.nextInt()\n print(if(4*a >= b & b%2 == 0 & a < b) \"Yes\" else \"No\")\n}\n", "language": "Scala", "metadata": {"date": 1592183644, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s304944263.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s304944263", "user_id": "u488417454"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App{\n val sc = new java.util.Scanner(System.in)\n var a , b=sc.nextInt()\n print(if(4*a >= b & b%2 == 0 & a < b) \"Yes\" else \"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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 520, "memory_kb": 55212}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s467564477", "group_id": "codeNet:p02641", "input_text": "object methods {\n def solver(): Unit = {\n\n val tempList: Seq[Seq[String]] = {\n for (line <- io.Source.stdin.getLines()) yield {\n line.split(' ').toSeq\n }\n }.toSeq\n val X: Int = tempList(0)(0).toInt\n val N: Int = tempList(0)(1).toInt\n\n val numList: Seq[Int] = tempList(1).map(_.toInt)\n \n // 0~101までで正数列が含まれない集合を求める\n val rangeList: Set[Int] = Range(0, 101).toList.toSet \n val diffRange: List[Int] = rangeList.diff(numList.toSet).toList \n val diffAbsRange: List[Int] = diffRange.map(x => (x-X).abs)\n val minIndex: Int = diffAbsRange.indexOf(diffAbsRange.min)\n val minOfRange: Int = diffRange(minIndex)\n\n\n println(minOfRange)\n }\n}\n\nobject Main extends App {\n methods.solver()\n}", "language": "Scala", "metadata": {"date": 1592438809, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s467564477.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s467564477", "user_id": "u570039786"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "object methods {\n def solver(): Unit = {\n\n val tempList: Seq[Seq[String]] = {\n for (line <- io.Source.stdin.getLines()) yield {\n line.split(' ').toSeq\n }\n }.toSeq\n val X: Int = tempList(0)(0).toInt\n val N: Int = tempList(0)(1).toInt\n\n val numList: Seq[Int] = tempList(1).map(_.toInt)\n \n // 0~101までで正数列が含まれない集合を求める\n val rangeList: Set[Int] = Range(0, 101).toList.toSet \n val diffRange: List[Int] = rangeList.diff(numList.toSet).toList \n val diffAbsRange: List[Int] = diffRange.map(x => (x-X).abs)\n val minIndex: Int = diffAbsRange.indexOf(diffAbsRange.min)\n val minOfRange: Int = diffRange(minIndex)\n\n\n println(minOfRange)\n }\n}\n\nobject Main extends App {\n methods.solver()\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 768, "cpu_time_ms": 523, "memory_kb": 57416}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s414443708", "group_id": "codeNet:p02645", "input_text": "import scala.math._\n\nobject Main extends App {\n val tempList: Seq[Seq[String]] = {\n for(line <- io.Source.stdin.getLines()) yield {\n line.split(' ').toSeq\n }\n }.toSeq\n\n val aInfo: Seq[Int] = tempList(0).map(_.toInt)\n val bInfo: Seq[Int] = tempList(1).map(_.toInt)\n val timeLimit: Int = tempList(2)(0).toInt\n\n //AとBの速度差: -ならその時点でNO\n val diffSpeed: Int = aInfo(1) - bInfo(1)\n //T秒で縮められる距離\n val diffInSec: Int = diffSpeed*timeLimit\n //AとBの距離\n val distance: Int = abs(aInfo(0) - bInfo(0))\n\n if(diffInSec >= distance) println(\"YES\")\n else println(\"NO\")\n}", "language": "Scala", "metadata": {"date": 1592098343, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s414443708.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s414443708", "user_id": "u570039786"}, "prompt_components": {"gold_output": "tak\n", "input_to_evaluate": "import scala.math._\n\nobject Main extends App {\n val tempList: Seq[Seq[String]] = {\n for(line <- io.Source.stdin.getLines()) yield {\n line.split(' ').toSeq\n }\n }.toSeq\n\n val aInfo: Seq[Int] = tempList(0).map(_.toInt)\n val bInfo: Seq[Int] = tempList(1).map(_.toInt)\n val timeLimit: Int = tempList(2)(0).toInt\n\n //AとBの速度差: -ならその時点でNO\n val diffSpeed: Int = aInfo(1) - bInfo(1)\n //T秒で縮められる距離\n val diffInSec: Int = diffSpeed*timeLimit\n //AとBの距離\n val distance: Int = abs(aInfo(0) - bInfo(0))\n\n if(diffInSec >= distance) println(\"YES\")\n else println(\"NO\")\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 655, "cpu_time_ms": 724, "memory_kb": 55184}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s228600042", "group_id": "codeNet:p02646", "input_text": "object Main extends App {\n val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList\n \n \n val tracker = inputs(0).split(\" \").map(_.toInt)\n val a = tracker(0)\n val v = tracker(1)\n val runaway = inputs(1).split(\" \").map(_.toInt)\n val b = runaway(0)\n val w = runaway(1)\n val t = inputs(2).toInt\n\n println(solve(a, v, b, w, t))\n\n private def solve(a: Int, v: Int, b: Int, w: Int, t: Int): String = {\n if(a < b) {\n val speedDiff = v - w\n val positiondiff = Math.abs(b - a)\n\n if(0 < speedDiff && (positiondiff / speedDiff) <= t) {\n return \"YES\"\n } else {\n return \"NO\"\n }\n } else {\n return \"NO\"\n // val speedDiff = w - v\n // val positiondiff = Math.abs(a - b)\n\n // if(0 < speedDiff && (positiondiff / speedDiff) <= t) {\n // return \"YES\"\n // } else {\n // return \"NO\"\n // }\n }\n }\n}", "language": "Scala", "metadata": {"date": 1592098883, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s228600042.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s228600042", "user_id": "u631102131"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "object Main extends App {\n val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList\n \n \n val tracker = inputs(0).split(\" \").map(_.toInt)\n val a = tracker(0)\n val v = tracker(1)\n val runaway = inputs(1).split(\" \").map(_.toInt)\n val b = runaway(0)\n val w = runaway(1)\n val t = inputs(2).toInt\n\n println(solve(a, v, b, w, t))\n\n private def solve(a: Int, v: Int, b: Int, w: Int, t: Int): String = {\n if(a < b) {\n val speedDiff = v - w\n val positiondiff = Math.abs(b - a)\n\n if(0 < speedDiff && (positiondiff / speedDiff) <= t) {\n return \"YES\"\n } else {\n return \"NO\"\n }\n } else {\n return \"NO\"\n // val speedDiff = w - v\n // val positiondiff = Math.abs(a - b)\n\n // if(0 < speedDiff && (positiondiff / speedDiff) <= t) {\n // return \"YES\"\n // } else {\n // return \"NO\"\n // }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 885, "cpu_time_ms": 504, "memory_kb": 54936}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s630699119", "group_id": "codeNet:p02646", "input_text": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\nimport java.lang\n\nimport scala.collection.mutable.ArrayBuffer\nimport scala.reflect.ClassTag\n\nobject Main {\n def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {\n converter(in.readLine)\n }\n\n def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {\n get[String].split(\"\\\\s+\").map[T](converter)\n }\n\n implicit val idConverter: String => String = s => s\n implicit val intConverter: String => Int = s => Integer.parseInt(s)\n implicit val longConverter: String => Long = s => lang.Long.parseLong(s)\n\n def get[T1, T2](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2\n ): (T1, T2) = {\n getArray[String] match {\n case Array(v1, v2) => (converter1(v1), converter2(v2))\n }\n }\n\n def get[T1, T2, T3](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3\n ): (T1, T2, T3) = {\n getArray[String] match {\n case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))\n }\n }\n\n implicit class TimesInt(val n: Int) {\n def times(f: Int => Unit): Unit = {\n for (i <- 0 until n) {\n f(i)\n }\n }\n }\n\n def primes(n: Long): ArrayBuffer[Long] = {\n val buf = ArrayBuffer.empty[Long]\n val s = Math.sqrt(n).toInt\n\n var v = n\n for (i <- 2 to s) {\n if (v == 1 || v == 0) {\n return buf\n } else {\n while (v % i == 0) {\n buf.append(i)\n v /= i\n }\n }\n }\n if (v > s) {\n buf.append(v)\n }\n buf\n }\n\n def main(args: Array[String]): Unit = {\n implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n val (a, v) = get[Int, Int]\n val (b, w) = get[Int, Int]\n val t = get[Int]\n\n out.println(\n if (v > w && 1L * (v - w) * t >= Math.abs(a - b)) {\n \"YES\"\n } else {\n \"NO\"\n }\n )\n\n out.flush()\n }\n}", "language": "Scala", "metadata": {"date": 1592097838, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s630699119.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s630699119", "user_id": "u178269371"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\nimport java.lang\n\nimport scala.collection.mutable.ArrayBuffer\nimport scala.reflect.ClassTag\n\nobject Main {\n def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {\n converter(in.readLine)\n }\n\n def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {\n get[String].split(\"\\\\s+\").map[T](converter)\n }\n\n implicit val idConverter: String => String = s => s\n implicit val intConverter: String => Int = s => Integer.parseInt(s)\n implicit val longConverter: String => Long = s => lang.Long.parseLong(s)\n\n def get[T1, T2](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2\n ): (T1, T2) = {\n getArray[String] match {\n case Array(v1, v2) => (converter1(v1), converter2(v2))\n }\n }\n\n def get[T1, T2, T3](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3\n ): (T1, T2, T3) = {\n getArray[String] match {\n case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))\n }\n }\n\n implicit class TimesInt(val n: Int) {\n def times(f: Int => Unit): Unit = {\n for (i <- 0 until n) {\n f(i)\n }\n }\n }\n\n def primes(n: Long): ArrayBuffer[Long] = {\n val buf = ArrayBuffer.empty[Long]\n val s = Math.sqrt(n).toInt\n\n var v = n\n for (i <- 2 to s) {\n if (v == 1 || v == 0) {\n return buf\n } else {\n while (v % i == 0) {\n buf.append(i)\n v /= i\n }\n }\n }\n if (v > s) {\n buf.append(v)\n }\n buf\n }\n\n def main(args: Array[String]): Unit = {\n implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n val (a, v) = get[Int, Int]\n val (b, w) = get[Int, Int]\n val t = get[Int]\n\n out.println(\n if (v > w && 1L * (v - w) * t >= Math.abs(a - b)) {\n \"YES\"\n } else {\n \"NO\"\n }\n )\n\n out.flush()\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2275, "cpu_time_ms": 520, "memory_kb": 56972}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s649902469", "group_id": "codeNet:p02646", "input_text": "import java.util.Scanner\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val a = sc.nextLong()\n val v = sc.nextLong()\n val b = sc.nextLong()\n val w = sc.nextLong()\n val t = sc.nextLong()\n if (v < w) {\n println(\"NO\")\n } else {\n val l = Math.abs(b - a)\n val d = t * (v - w)\n if (l > d) {\n println(\"NO\")\n } else {\n println(\"YES\")\n }\n }\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1592097111, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s649902469.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s649902469", "user_id": "u197909036"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val a = sc.nextLong()\n val v = sc.nextLong()\n val b = sc.nextLong()\n val w = sc.nextLong()\n val t = sc.nextLong()\n if (v < w) {\n println(\"NO\")\n } else {\n val l = Math.abs(b - a)\n val d = t * (v - w)\n if (l > d) {\n println(\"NO\")\n } else {\n println(\"YES\")\n }\n }\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 487, "memory_kb": 55252}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s295215432", "group_id": "codeNet:p02646", "input_text": "object Main extends App {\n val a = scala.io.StdIn.readLine()\n val aArray = a.split(\" \").map(_.toInt).toSeq\n val aPos = aArray(0)\n val aHayasa = aArray(1)\n\n val b = scala.io.StdIn.readLine()\n val bArray = b.split(\" \").map(_.toInt).toSeq\n val bPos = bArray(0)\n val bHayasa = bArray(1)\n\n val t = scala.io.StdIn.readInt()\n\n if ((bPos - aPos) - (aHayasa * t - bHayasa * t) <= 0) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}", "language": "Scala", "metadata": {"date": 1592096983, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s295215432.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s295215432", "user_id": "u105921924"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "object Main extends App {\n val a = scala.io.StdIn.readLine()\n val aArray = a.split(\" \").map(_.toInt).toSeq\n val aPos = aArray(0)\n val aHayasa = aArray(1)\n\n val b = scala.io.StdIn.readLine()\n val bArray = b.split(\" \").map(_.toInt).toSeq\n val bPos = bArray(0)\n val bHayasa = bArray(1)\n\n val t = scala.io.StdIn.readInt()\n\n if ((bPos - aPos) - (aHayasa * t - bHayasa * t) <= 0) {\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 488, "memory_kb": 54732}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s669294058", "group_id": "codeNet:p02647", "input_text": "object methods {\n def solver(): Unit = {\n\n val tempList: Seq[Seq[String]] = {\n for (line <- io.Source.stdin.getLines()) yield {\n line.split(' ').toSeq\n }\n }.toSeq\n val N: Int = tempList(0)(0).toInt //電球の個数\n val K: Int = tempList(0)(1).toInt //操作回数\n val initBrightness: Seq[Int] = tempList(1).map(_.toInt)\n\n //K回更新:いもす法ならこの関数でO((N+N)*K):ナイーブな解法ならO(N*N*K)\n val kUpBrightness: Seq[Int] = loop(1, K, N, initBrightness)\n\n //val kUpBrightness: Seq[Int] = UpdateBrightness(N, initBrightness):いもす法では累積和が答え\n println(kUpBrightness.mkString(\" \"))\n }\n\n //累積和を使った計算(いもす法):ランプの左始点に+1ランプの右切れ端に-1\n def UpdateByCumulativeSum(N: Int, BrightSeq: Seq[Int]): Seq[Int] = {\n //記録\n val illuminateNumCount: Array[Int] = Seq.fill(N)(0).toArray[Int]\n var i = 0\n var count: Boolean = true\n while (i < N) {\n val illuminateStart: Int = {\n if (i - BrightSeq(i) < 0) 0\n else i - BrightSeq(i)\n }\n val illuminateOut: Int = {\n if (i + BrightSeq(i) + 1 > BrightSeq.length -1) { //インデックス最大値よりも.lengthは1多い\n count = false\n BrightSeq.length\n } else {\n count = true\n i + BrightSeq(i) + 1\n }\n }\n illuminateNumCount(illuminateStart) += 1\n if (count) illuminateNumCount(illuminateOut) -= 1\n i += 1\n }\n //計測:ここで計算量はO(N+N)\n val cumulativeIlluminateNum: Seq[Int] = illuminateNumCount.scanLeft(0)((x, y) => x+y).toSeq \n cumulativeIlluminateNum.drop(1) //累積和の一番最初はいらないのでそれを覗いたSeqを返す\n }\n\n def loop(k: Int, K: Int, N: Int, Brightness: Seq[Int]): Seq[Int] = {\n val CurrentBrightness = UpdateByCumulativeSum(N, Brightness)\n\n // 計算時間エラー起こった:O(logN)回の操作で収束するらしい。なにそれってかんじだが41回を上限とする\n if(k < K && k < 42) loop(k+1, K, N, CurrentBrightness)\n else CurrentBrightness\n }\n\n}\n\nobject Main extends App {\n methods.solver()\n}", "language": "Scala", "metadata": {"date": 1592436432, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s669294058.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s669294058", "user_id": "u570039786"}, "prompt_components": {"gold_output": "1 2 2 1 2\n", "input_to_evaluate": "object methods {\n def solver(): Unit = {\n\n val tempList: Seq[Seq[String]] = {\n for (line <- io.Source.stdin.getLines()) yield {\n line.split(' ').toSeq\n }\n }.toSeq\n val N: Int = tempList(0)(0).toInt //電球の個数\n val K: Int = tempList(0)(1).toInt //操作回数\n val initBrightness: Seq[Int] = tempList(1).map(_.toInt)\n\n //K回更新:いもす法ならこの関数でO((N+N)*K):ナイーブな解法ならO(N*N*K)\n val kUpBrightness: Seq[Int] = loop(1, K, N, initBrightness)\n\n //val kUpBrightness: Seq[Int] = UpdateBrightness(N, initBrightness):いもす法では累積和が答え\n println(kUpBrightness.mkString(\" \"))\n }\n\n //累積和を使った計算(いもす法):ランプの左始点に+1ランプの右切れ端に-1\n def UpdateByCumulativeSum(N: Int, BrightSeq: Seq[Int]): Seq[Int] = {\n //記録\n val illuminateNumCount: Array[Int] = Seq.fill(N)(0).toArray[Int]\n var i = 0\n var count: Boolean = true\n while (i < N) {\n val illuminateStart: Int = {\n if (i - BrightSeq(i) < 0) 0\n else i - BrightSeq(i)\n }\n val illuminateOut: Int = {\n if (i + BrightSeq(i) + 1 > BrightSeq.length -1) { //インデックス最大値よりも.lengthは1多い\n count = false\n BrightSeq.length\n } else {\n count = true\n i + BrightSeq(i) + 1\n }\n }\n illuminateNumCount(illuminateStart) += 1\n if (count) illuminateNumCount(illuminateOut) -= 1\n i += 1\n }\n //計測:ここで計算量はO(N+N)\n val cumulativeIlluminateNum: Seq[Int] = illuminateNumCount.scanLeft(0)((x, y) => x+y).toSeq \n cumulativeIlluminateNum.drop(1) //累積和の一番最初はいらないのでそれを覗いたSeqを返す\n }\n\n def loop(k: Int, K: Int, N: Int, Brightness: Seq[Int]): Seq[Int] = {\n val CurrentBrightness = UpdateByCumulativeSum(N, Brightness)\n\n // 計算時間エラー起こった:O(logN)回の操作で収束するらしい。なにそれってかんじだが41回を上限とする\n if(k < K && k < 42) loop(k+1, K, N, CurrentBrightness)\n else CurrentBrightness\n }\n\n}\n\nobject Main extends App {\n methods.solver()\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2205, "cpu_time_ms": 1483, "memory_kb": 107840}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s244222815", "group_id": "codeNet:p02647", "input_text": "object methods {\n def solver(): Unit = {\n\n val tempList: Seq[Seq[String]] = {\n for (line <- io.Source.stdin.getLines()) yield {\n line.split(' ').toSeq\n }\n }.toSeq\n val N: Int = tempList(0)(0).toInt //電球の個数\n val K: Int = tempList(0)(1).toInt //操作回数\n val initBrightness: Seq[Int] = tempList(1).map(_.toInt)\n\n //K回更新:いもす法ならこの関数でO((N+N)*K):ナイーブな解法ならO(N*N*K)\n val kUpBrightness: Seq[Int] = loop(1, K, N, initBrightness)\n\n //val kUpBrightness: Seq[Int] = UpdateBrightness(N, initBrightness):いもす法では累積和が答え\n println(kUpBrightness.mkString(\" \"))\n }\n\n //K回この操作をする: 照らしている個数のシーケンスを返す\n def UpdateBrightness(N: Int, BrightSeq: Seq[Int]): Seq[Int] = {\n val illuminateNum: Array[Int] = Seq.fill(N)(0).toArray[Int]\n\n //Mapとかでもできそう。時間制限にひっかかるなら改良\n var i = 0\n while (i < N) {\n //照らす範囲下部分\n val illuminateBottom: Int = {\n if (i - BrightSeq(i) < 0) 0\n else i - BrightSeq(i)\n }\n val illuminateTop: Int = {\n if(i + BrightSeq(i) > BrightSeq.length) BrightSeq.length\n else i + BrightSeq(i)\n }\n\n //この操作でO(N*N)を作り出している\n illuminateNum.zipWithIndex.foreach{\n case (v, i) => if(illuminateBottom <= i && i <= illuminateTop) illuminateNum(i) = v + 1\n }\n i += 1\n }//while締め\n illuminateNum\n }\n\n //累積和を使った計算(いもす法):ランプの左始点に+1ランプの右切れ端に-1\n def UpdateByCumulativeSum(N: Int, BrightSeq: Seq[Int]): Seq[Int] = {\n //記録\n val illuminateNumCount: Array[Int] = Seq.fill(N)(0).toArray[Int]\n var i = 0\n var count: Boolean = true\n while (i < N) {\n val illuminateStart: Int = {\n if (i - BrightSeq(i) < 0) 0\n else i - BrightSeq(i)\n }\n val illuminateOut: Int = {\n if (i + BrightSeq(i) + 1 > BrightSeq.length -1) { //インデックス最大値よりも.lengthは1多い\n count = false\n BrightSeq.length\n } else {\n count = true\n i + BrightSeq(i) + 1\n }\n }\n illuminateNumCount(illuminateStart) += 1\n if (count) illuminateNumCount(illuminateOut) -= 1\n i += 1\n }\n //計測:ここで計算量はO(N+N)\n val cumulativeIlluminateNum: Seq[Int] = illuminateNumCount.scanLeft(0)((x, y) => x+y)\n cumulativeIlluminateNum.drop(1) //累積和の一番最初はいらないのでそれを覗いたSeqを返す\n }\n\n def loop(k: Int, K: Int, N: Int, Brightness: Seq[Int]): Seq[Int] = {\n val CurrentBrightness = UpdateByCumulativeSum(N, Brightness)\n\n // 計算時間エラー起こった:O(logN)回の操作で収束するらしい。なにそれってかんじだが41回を上限とする\n if(k < K && k < 42) loop(k+1, K, N, CurrentBrightness)\n else CurrentBrightness\n }\n\n}\n\nobject Main extends App {\n methods.solver\n}", "language": "Scala", "metadata": {"date": 1592376595, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s244222815.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s244222815", "user_id": "u570039786"}, "prompt_components": {"gold_output": "1 2 2 1 2\n", "input_to_evaluate": "object methods {\n def solver(): Unit = {\n\n val tempList: Seq[Seq[String]] = {\n for (line <- io.Source.stdin.getLines()) yield {\n line.split(' ').toSeq\n }\n }.toSeq\n val N: Int = tempList(0)(0).toInt //電球の個数\n val K: Int = tempList(0)(1).toInt //操作回数\n val initBrightness: Seq[Int] = tempList(1).map(_.toInt)\n\n //K回更新:いもす法ならこの関数でO((N+N)*K):ナイーブな解法ならO(N*N*K)\n val kUpBrightness: Seq[Int] = loop(1, K, N, initBrightness)\n\n //val kUpBrightness: Seq[Int] = UpdateBrightness(N, initBrightness):いもす法では累積和が答え\n println(kUpBrightness.mkString(\" \"))\n }\n\n //K回この操作をする: 照らしている個数のシーケンスを返す\n def UpdateBrightness(N: Int, BrightSeq: Seq[Int]): Seq[Int] = {\n val illuminateNum: Array[Int] = Seq.fill(N)(0).toArray[Int]\n\n //Mapとかでもできそう。時間制限にひっかかるなら改良\n var i = 0\n while (i < N) {\n //照らす範囲下部分\n val illuminateBottom: Int = {\n if (i - BrightSeq(i) < 0) 0\n else i - BrightSeq(i)\n }\n val illuminateTop: Int = {\n if(i + BrightSeq(i) > BrightSeq.length) BrightSeq.length\n else i + BrightSeq(i)\n }\n\n //この操作でO(N*N)を作り出している\n illuminateNum.zipWithIndex.foreach{\n case (v, i) => if(illuminateBottom <= i && i <= illuminateTop) illuminateNum(i) = v + 1\n }\n i += 1\n }//while締め\n illuminateNum\n }\n\n //累積和を使った計算(いもす法):ランプの左始点に+1ランプの右切れ端に-1\n def UpdateByCumulativeSum(N: Int, BrightSeq: Seq[Int]): Seq[Int] = {\n //記録\n val illuminateNumCount: Array[Int] = Seq.fill(N)(0).toArray[Int]\n var i = 0\n var count: Boolean = true\n while (i < N) {\n val illuminateStart: Int = {\n if (i - BrightSeq(i) < 0) 0\n else i - BrightSeq(i)\n }\n val illuminateOut: Int = {\n if (i + BrightSeq(i) + 1 > BrightSeq.length -1) { //インデックス最大値よりも.lengthは1多い\n count = false\n BrightSeq.length\n } else {\n count = true\n i + BrightSeq(i) + 1\n }\n }\n illuminateNumCount(illuminateStart) += 1\n if (count) illuminateNumCount(illuminateOut) -= 1\n i += 1\n }\n //計測:ここで計算量はO(N+N)\n val cumulativeIlluminateNum: Seq[Int] = illuminateNumCount.scanLeft(0)((x, y) => x+y)\n cumulativeIlluminateNum.drop(1) //累積和の一番最初はいらないのでそれを覗いたSeqを返す\n }\n\n def loop(k: Int, K: Int, N: Int, Brightness: Seq[Int]): Seq[Int] = {\n val CurrentBrightness = UpdateByCumulativeSum(N, Brightness)\n\n // 計算時間エラー起こった:O(logN)回の操作で収束するらしい。なにそれってかんじだが41回を上限とする\n if(k < K && k < 42) loop(k+1, K, N, CurrentBrightness)\n else CurrentBrightness\n }\n\n}\n\nobject Main extends App {\n methods.solver\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3058, "cpu_time_ms": 1394, "memory_kb": 107456}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s520435488", "group_id": "codeNet:p02647", "input_text": "object Main extends App{\n val sc = new java.util.Scanner(System.in)\n var n = sc.nextDouble()\n var k = sc.nextDouble\n var a = Array.fill(n.asInstanceOf[Int])(sc.nextDouble)\n var b = Array.fill(n.asInstanceOf[Int])(0.0)\n var ka,kb = 0.0\n for (i <- 0 until k.asInstanceOf[Int]){\n for (j <- 1 to n.asInstanceOf[Int]){\n ka = j - a(j-1) - 0.5\n kb = j + a(j-1) + 0.5\n for (kk <- (ka.asInstanceOf[Int] + 1) to kb.asInstanceOf[Int] if kk > 0 & kk <= 5){\n b(kk-1) += 1\n }\n }\n System.arraycopy(b,0,a,0,a.length)\n b = Array.fill(n.asInstanceOf[Int])(0.0)\n }\n for (i <- 0 until n.asInstanceOf[Int]){\n print(a(i).asInstanceOf[Int])\n print(\" \")\n }\n}\n", "language": "Scala", "metadata": {"date": 1592101906, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s520435488.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s520435488", "user_id": "u488417454"}, "prompt_components": {"gold_output": "1 2 2 1 2\n", "input_to_evaluate": "object Main extends App{\n val sc = new java.util.Scanner(System.in)\n var n = sc.nextDouble()\n var k = sc.nextDouble\n var a = Array.fill(n.asInstanceOf[Int])(sc.nextDouble)\n var b = Array.fill(n.asInstanceOf[Int])(0.0)\n var ka,kb = 0.0\n for (i <- 0 until k.asInstanceOf[Int]){\n for (j <- 1 to n.asInstanceOf[Int]){\n ka = j - a(j-1) - 0.5\n kb = j + a(j-1) + 0.5\n for (kk <- (ka.asInstanceOf[Int] + 1) to kb.asInstanceOf[Int] if kk > 0 & kk <= 5){\n b(kk-1) += 1\n }\n }\n System.arraycopy(b,0,a,0,a.length)\n b = Array.fill(n.asInstanceOf[Int])(0.0)\n }\n for (i <- 0 until n.asInstanceOf[Int]){\n print(a(i).asInstanceOf[Int])\n print(\" \")\n }\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 690, "cpu_time_ms": 2206, "memory_kb": 85144}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s842563837", "group_id": "codeNet:p02661", "input_text": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val N = in.nextInt\n val ABs = Array.fill(N)((in.nextInt, in.nextInt))\n val As = ABs.map(_._1).sorted\n val Bs = ABs.map(_._2).sorted\n\n def diff(i: Int): Int = Bs(i) - As(i)\n println(diff(N / 2) + 1 + (if (N % 2 == 1) 0 else diff(N / 2 - 1)))\n}", "language": "Scala", "metadata": {"date": 1591382496, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s842563837.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s842563837", "user_id": "u132324749"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val N = in.nextInt\n val ABs = Array.fill(N)((in.nextInt, in.nextInt))\n val As = ABs.map(_._1).sorted\n val Bs = ABs.map(_._2).sorted\n\n def diff(i: Int): Int = Bs(i) - As(i)\n println(diff(N / 2) + 1 + (if (N % 2 == 1) 0 else diff(N / 2 - 1)))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1291, "memory_kb": 67572}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s814475664", "group_id": "codeNet:p02661", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt()\n val c = IndexedSeq.fill(n)((sc.nextInt(), sc.nextInt()))\n val a = c.map(_._1).sorted\n val b = c.map(_._2).sorted\n val amed = if (n % 2 == 1) a((n-1)/2) else (a(n/2 - 1) + a(n/2)) / 2\n val bmed = if (n % 2 == 1) b((n-1)/2) else (b(n/2 - 1) + b(n/2)) / 2\n if (n % 2 == 1) {\n println(bmed - amed + 1)\n } else {\n println(2L * (bmed - amed + 1) - 1)\n }\n}\n", "language": "Scala", "metadata": {"date": 1590987369, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s814475664.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s814475664", "user_id": "u191819389"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt()\n val c = IndexedSeq.fill(n)((sc.nextInt(), sc.nextInt()))\n val a = c.map(_._1).sorted\n val b = c.map(_._2).sorted\n val amed = if (n % 2 == 1) a((n-1)/2) else (a(n/2 - 1) + a(n/2)) / 2\n val bmed = if (n % 2 == 1) b((n-1)/2) else (b(n/2 - 1) + b(n/2)) / 2\n if (n % 2 == 1) {\n println(bmed - amed + 1)\n } else {\n println(2L * (bmed - amed + 1) - 1)\n }\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1510, "memory_kb": 75844}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s580307225", "group_id": "codeNet:p02663", "input_text": "object Main extends App {\n val hmhmk = scala.io.StdIn.readLine()\n val hmhmkArray = hmhmk.split(\" \").map(_.toInt).toSeq\n val start = hmhmkArray(0) * 60 + hmhmkArray(1)\n val end = hmhmkArray(2) * 60 + hmhmkArray(3)\n val k = hmhmkArray(4)\n \n println(end - start - k)\n \n}", "language": "Scala", "metadata": {"date": 1590887236, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s580307225.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s580307225", "user_id": "u105921924"}, "prompt_components": {"gold_output": "270\n", "input_to_evaluate": "object Main extends App {\n val hmhmk = scala.io.StdIn.readLine()\n val hmhmkArray = hmhmk.split(\" \").map(_.toInt).toSeq\n val start = hmhmkArray(0) * 60 + hmhmkArray(1)\n val end = hmhmkArray(2) * 60 + hmhmkArray(3)\n val k = hmhmkArray(4)\n \n println(end - start - 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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 499, "memory_kb": 54776}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s194547487", "group_id": "codeNet:p02664", "input_text": "object Main extends App {\n val t = scala.io.StdIn.readLine()\n println(t.replaceAll(\"\\\\?\", \"D\"))\n\n}", "language": "Scala", "metadata": {"date": 1590887989, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02664.html", "problem_id": "p02664", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02664/input.txt", "sample_output_relpath": "derived/input_output/data/p02664/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02664/Scala/s194547487.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s194547487", "user_id": "u105921924"}, "prompt_components": {"gold_output": "PDPDPDP\n", "input_to_evaluate": "object Main extends App {\n val t = scala.io.StdIn.readLine()\n println(t.replaceAll(\"\\\\?\", \"D\"))\n\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nFor a string S consisting of the uppercase English letters P and D, let the doctoral and postdoctoral quotient of S be the total number of occurrences of D and PD in S as contiguous substrings. For example, if S = PPDDP, it contains two occurrences of D and one occurrence of PD as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3.\n\nWe have a string T consisting of P, D, and ?.\n\nAmong the strings that can be obtained by replacing each ? in T with P or D, find one with the maximum possible doctoral and postdoctoral quotient.\n\nConstraints\n\n1 \\leq |T| \\leq 2 \\times 10^5\n\nT consists of P, D, and ?.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT\n\nOutput\n\nPrint one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each ? in T with P or D.\nIf there are multiple such strings, you may print any of them.\n\nSample Input 1\n\nPD?D??P\n\nSample Output 1\n\nPDPDPDP\n\nThis string contains three occurrences of D and three occurrences of PD as contiguous substrings, so its doctoral and postdoctoral quotient is 6, which is the maximum doctoral and postdoctoral quotient of a string obtained by replacing each ? in T with P or D.\n\nSample Input 2\n\nP?P?\n\nSample Output 2\n\nPDPD", "sample_input": "PD?D??P\n"}, "reference_outputs": ["PDPDPDP\n"], "source_document_id": "p02664", "source_text": "Score : 200 points\n\nProblem Statement\n\nFor a string S consisting of the uppercase English letters P and D, let the doctoral and postdoctoral quotient of S be the total number of occurrences of D and PD in S as contiguous substrings. For example, if S = PPDDP, it contains two occurrences of D and one occurrence of PD as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3.\n\nWe have a string T consisting of P, D, and ?.\n\nAmong the strings that can be obtained by replacing each ? in T with P or D, find one with the maximum possible doctoral and postdoctoral quotient.\n\nConstraints\n\n1 \\leq |T| \\leq 2 \\times 10^5\n\nT consists of P, D, and ?.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT\n\nOutput\n\nPrint one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each ? in T with P or D.\nIf there are multiple such strings, you may print any of them.\n\nSample Input 1\n\nPD?D??P\n\nSample Output 1\n\nPDPDPDP\n\nThis string contains three occurrences of D and three occurrences of PD as contiguous substrings, so its doctoral and postdoctoral quotient is 6, which is the maximum doctoral and postdoctoral quotient of a string obtained by replacing each ? in T with P or D.\n\nSample Input 2\n\nP?P?\n\nSample Output 2\n\nPDPD", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 100, "cpu_time_ms": 592, "memory_kb": 57596}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s133193742", "group_id": "codeNet:p02675", "input_text": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\nimport scala.language.postfixOps\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n\n def nodeSize(t: Int): Int = nodes(root(t)).treeSize\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n println(sc.nextInt() % 10 match {\n case 2 | 4 | 5 | 7 | 9 => \"hon\"\n case 0 | 1 | 6 | 8 => \"pon\"\n case _ => \"bon\"\n })\n }\n\n def recursive(N: Int,\n A: IndexedSeq[Array[Long]],\n group: Array[Array[Int]] = Array.fill(3)(Array[Int]()),\n ans: Long = 0,\n now: Int = 0): Long = {\n if (now == N) ans\n else (0 until 3).map(i => recursive(N, A, {\n val nextGroup = group.clone()\n nextGroup(i) :+= now\n nextGroup\n }, ans + group(i).map(j => (now, j)).map { case (i, j) => A(Math.min(i, j))(Math.max(i, j) - Math.min(i, j) - 1) }.sum\n , now + 1)).max\n }\n\n @scala.annotation.tailrec\n def recursive2(N: Long, now: Long = 1): Long = {\n if (N >= now) recursive2(N - now, now + 1)\n else now - 1\n }\n\n def flip(A: Array[Boolean], B: Array[(Int, Long)]): Array[(Int, Long)] = {\n B.map { case (index, _) =>\n (index, (if (0 < index && A(index - 1)) B(index - 1)._2 else 0L) + (if (index + 1 < B.length && !A(index + 1)) B(index + 1)._2 else 0L))\n }\n }\n\n val mod: Long = (1e9 + 7).toLong\n\n\n @scala.annotation.tailrec\n def factorial(now: Long, ans: Long = 1): Long = {\n if (now == 0) 0 else if (now == 1) ans else factorial(now - 1, now * ans)\n }\n\n implicit class implicitInt(val N: Int) {\n def times[B](function: Int => B): IndexedSeq[B] = (0 until N).map(function)\n }\n\n def calc(input: (Long, Long, Long, Long, Long, Long)): Long = {\n input match {\n case (a, b, c, x, y, z) =>\n var ans: Long = Long.MaxValue\n if (b >= 3 && (a >= 2 || c >= 2)) {\n ans = Math.min(ans, Math.max(a - (b - 1), 0) * x + Math.max(c - Math.min(a - 1, b - 2), 0) * z)\n ans = Math.min(ans, Math.max(a - Math.min(c - 1, b - 2), 0) * x + Math.max(c - (b - 1), 0) * z)\n }\n // println(ans)\n if (b >= 2 && (a >= b && c >= b + 1)) {\n ans = Math.min(ans, y + Math.max(0, a - (c - 1)) * x)\n }\n // println(ans)\n if (b >= 2 && (a >= b + 1 && c >= b)) {\n ans = Math.min(ans, y + Math.max(0, c - (a - 1)) * z)\n }\n // println(ans)\n if (a >= 2 && c >= 2)\n if (a != c)\n ans = Math.min(ans, Math.max(0, b - (Math.min(a, c) - 1)) * y)\n else if (a >= 3 && c >= 3)\n ans = Math.min(ans, Math.max(0, b - (Math.min(a, c) - 2)) * y + Math.min(x, z))\n // println(ans)\n if (ans == Long.MaxValue) ans = -1\n ans\n }\n }\n\n def time(s: String): Int =\n s.substring(0, 2).toInt * 60 + s.substring(3, 5).toInt\n\n /*\n def getPermutation(begin: Long = 0): LazyList[Long] =\n LazyList.cons(begin, getPermutation(begin + 1))\n\n def getFibonacci(prevprev: Long = 0, prev: Long = 1): LazyList[Long] =\n LazyList.cons(prevprev, getFibonacci(prev, prevprev + prev))\n\n @scala.annotation.tailrec\n def recursive2(X: Set[Long], Y: LazyList[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n*/\n def check(i: Int, X: String): Long = {\n if (X == \"\") 0 else check(i, X.tail) * i + X.head.toString.toLong\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n @scala.annotation.tailrec\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def primeFactors(i: Long): List[Long] = primeFactors_(i, 1).sorted\n\n\n def primeFactors_(i: Long, j: Long): List[Long] = {\n if (j * j > i) List.empty else if (i % j == 0) primeFactors_(i, j + 1) ++ List[Long](j, i / j) else primeFactors_(i, j + 1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\n/*\nobject Util {\n def getPermutation(begin: Long = 0): LazyList[Long] =\n LazyList.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: LazyList[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: LazyList[Long]): LazyList[Long] =\n LazyList.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): LazyList[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\n */\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n private val codeTable: List[(Int, String)] = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n @scala.annotation.tailrec\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n @scala.annotation.tailrec\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n}\n\nobject PowMod {\n def naivePowMod(a: Long, k: Long, m: Long): Long = {\n var t: Long = 1\n val aMod: Long = a % m\n\n for (_ <- 1L to k) {\n t = ((t % m) * aMod) % m\n }\n t.toInt\n }\n\n def powMod(a: Long, k: Long, m: Long): Long = {\n if (k == 0) 1\n else {\n val t = powMod(a, k / 2, m)\n if ((k % 2) == 0) (t * t) % m else (((t * t) % m) * a) % m\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1593140657, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s133193742.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s133193742", "user_id": "u779353743"}, "prompt_components": {"gold_output": "pon\n", "input_to_evaluate": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\nimport scala.language.postfixOps\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n\n def nodeSize(t: Int): Int = nodes(root(t)).treeSize\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n println(sc.nextInt() % 10 match {\n case 2 | 4 | 5 | 7 | 9 => \"hon\"\n case 0 | 1 | 6 | 8 => \"pon\"\n case _ => \"bon\"\n })\n }\n\n def recursive(N: Int,\n A: IndexedSeq[Array[Long]],\n group: Array[Array[Int]] = Array.fill(3)(Array[Int]()),\n ans: Long = 0,\n now: Int = 0): Long = {\n if (now == N) ans\n else (0 until 3).map(i => recursive(N, A, {\n val nextGroup = group.clone()\n nextGroup(i) :+= now\n nextGroup\n }, ans + group(i).map(j => (now, j)).map { case (i, j) => A(Math.min(i, j))(Math.max(i, j) - Math.min(i, j) - 1) }.sum\n , now + 1)).max\n }\n\n @scala.annotation.tailrec\n def recursive2(N: Long, now: Long = 1): Long = {\n if (N >= now) recursive2(N - now, now + 1)\n else now - 1\n }\n\n def flip(A: Array[Boolean], B: Array[(Int, Long)]): Array[(Int, Long)] = {\n B.map { case (index, _) =>\n (index, (if (0 < index && A(index - 1)) B(index - 1)._2 else 0L) + (if (index + 1 < B.length && !A(index + 1)) B(index + 1)._2 else 0L))\n }\n }\n\n val mod: Long = (1e9 + 7).toLong\n\n\n @scala.annotation.tailrec\n def factorial(now: Long, ans: Long = 1): Long = {\n if (now == 0) 0 else if (now == 1) ans else factorial(now - 1, now * ans)\n }\n\n implicit class implicitInt(val N: Int) {\n def times[B](function: Int => B): IndexedSeq[B] = (0 until N).map(function)\n }\n\n def calc(input: (Long, Long, Long, Long, Long, Long)): Long = {\n input match {\n case (a, b, c, x, y, z) =>\n var ans: Long = Long.MaxValue\n if (b >= 3 && (a >= 2 || c >= 2)) {\n ans = Math.min(ans, Math.max(a - (b - 1), 0) * x + Math.max(c - Math.min(a - 1, b - 2), 0) * z)\n ans = Math.min(ans, Math.max(a - Math.min(c - 1, b - 2), 0) * x + Math.max(c - (b - 1), 0) * z)\n }\n // println(ans)\n if (b >= 2 && (a >= b && c >= b + 1)) {\n ans = Math.min(ans, y + Math.max(0, a - (c - 1)) * x)\n }\n // println(ans)\n if (b >= 2 && (a >= b + 1 && c >= b)) {\n ans = Math.min(ans, y + Math.max(0, c - (a - 1)) * z)\n }\n // println(ans)\n if (a >= 2 && c >= 2)\n if (a != c)\n ans = Math.min(ans, Math.max(0, b - (Math.min(a, c) - 1)) * y)\n else if (a >= 3 && c >= 3)\n ans = Math.min(ans, Math.max(0, b - (Math.min(a, c) - 2)) * y + Math.min(x, z))\n // println(ans)\n if (ans == Long.MaxValue) ans = -1\n ans\n }\n }\n\n def time(s: String): Int =\n s.substring(0, 2).toInt * 60 + s.substring(3, 5).toInt\n\n /*\n def getPermutation(begin: Long = 0): LazyList[Long] =\n LazyList.cons(begin, getPermutation(begin + 1))\n\n def getFibonacci(prevprev: Long = 0, prev: Long = 1): LazyList[Long] =\n LazyList.cons(prevprev, getFibonacci(prev, prevprev + prev))\n\n @scala.annotation.tailrec\n def recursive2(X: Set[Long], Y: LazyList[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n*/\n def check(i: Int, X: String): Long = {\n if (X == \"\") 0 else check(i, X.tail) * i + X.head.toString.toLong\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n @scala.annotation.tailrec\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def primeFactors(i: Long): List[Long] = primeFactors_(i, 1).sorted\n\n\n def primeFactors_(i: Long, j: Long): List[Long] = {\n if (j * j > i) List.empty else if (i % j == 0) primeFactors_(i, j + 1) ++ List[Long](j, i / j) else primeFactors_(i, j + 1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\n/*\nobject Util {\n def getPermutation(begin: Long = 0): LazyList[Long] =\n LazyList.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: LazyList[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: LazyList[Long]): LazyList[Long] =\n LazyList.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): LazyList[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\n */\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n private val codeTable: List[(Int, String)] = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n @scala.annotation.tailrec\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n @scala.annotation.tailrec\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n}\n\nobject PowMod {\n def naivePowMod(a: Long, k: Long, m: Long): Long = {\n var t: Long = 1\n val aMod: Long = a % m\n\n for (_ <- 1L to k) {\n t = ((t % m) * aMod) % m\n }\n t.toInt\n }\n\n def powMod(a: Long, k: Long, m: Long): Long = {\n if (k == 0) 1\n else {\n val t = powMod(a, k / 2, m)\n if ((k % 2) == 0) (t * t) % m else (((t * t) % m) * a) % m\n }\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 9361, "cpu_time_ms": 511, "memory_kb": 54852}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s415559348", "group_id": "codeNet:p02675", "input_text": "import scala.io.StdIn._\n\nobject Main extends App {\n val ans = readInt % 10 match {\n case 0 | 1 | 6 | 8 => \"pon\"\n case 3 => \"bon\"\n case _ => \"hon\"\n }\n println(ans)\n}\n", "language": "Scala", "metadata": {"date": 1591656771, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s415559348.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s415559348", "user_id": "u220774651"}, "prompt_components": {"gold_output": "pon\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main extends App {\n val ans = readInt % 10 match {\n case 0 | 1 | 6 | 8 => \"pon\"\n case 3 => \"bon\"\n case _ => \"hon\"\n }\n println(ans)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 491, "memory_kb": 54628}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s610300374", "group_id": "codeNet:p02676", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val K = sc.nextInt\n sc.nextLine\n val S = sc.nextLine\n\n val z = if (S.length <= K) S else S.take(K) + \"...\"\n println(z)\n}\n", "language": "Scala", "metadata": {"date": 1589763839, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s610300374.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s610300374", "user_id": "u786167609"}, "prompt_components": {"gold_output": "nikoand...\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val K = sc.nextInt\n sc.nextLine\n val S = sc.nextLine\n\n val z = if (S.length <= K) S else S.take(K) + \"...\"\n println(z)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 505, "memory_kb": 55260}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s469480450", "group_id": "codeNet:p02678", "input_text": "import java.util.Scanner\n\nimport scala.collection.mutable\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val N, M = sc.nextInt\n val AB = Array.fill(M)((sc.nextInt, sc.nextInt))\n\n val G = (AB ++ AB.map(_.swap)).groupBy(_._1).toSeq.sortBy(_._1).map(_._2.map(_._2))\n\n val X = Array.fill(N)(false)\n val Y = Array.fill(N)(-1)\n\n def BFS(x: Int): Unit = {\n val Q = new mutable.Queue[Int]()\n X(x - 1) = true\n Y(x - 1) = 0\n Q += x\n while (Q.nonEmpty) {\n val v = Q.dequeue\n X(v - 1) = true\n G(v - 1).foreach(i => {\n if (!X(i - 1)) {\n X(i - 1) = true\n Y(i - 1) = v\n Q += i\n }\n })\n }\n }\n BFS(1)\n\n println(\"Yes\")\n Y.tail.foreach(println)\n}\n", "language": "Scala", "metadata": {"date": 1589770407, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s469480450.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s469480450", "user_id": "u786167609"}, "prompt_components": {"gold_output": "Yes\n1\n2\n2\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.collection.mutable\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val N, M = sc.nextInt\n val AB = Array.fill(M)((sc.nextInt, sc.nextInt))\n\n val G = (AB ++ AB.map(_.swap)).groupBy(_._1).toSeq.sortBy(_._1).map(_._2.map(_._2))\n\n val X = Array.fill(N)(false)\n val Y = Array.fill(N)(-1)\n\n def BFS(x: Int): Unit = {\n val Q = new mutable.Queue[Int]()\n X(x - 1) = true\n Y(x - 1) = 0\n Q += x\n while (Q.nonEmpty) {\n val v = Q.dequeue\n X(v - 1) = true\n G(v - 1).foreach(i => {\n if (!X(i - 1)) {\n X(i - 1) = true\n Y(i - 1) = v\n Q += i\n }\n })\n }\n }\n BFS(1)\n\n println(\"Yes\")\n Y.tail.foreach(println)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2205, "memory_kb": 104196}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s089595813", "group_id": "codeNet:p02679", "input_text": "import math._\nimport collection.mutable.{Map => MTMap}\n\nobject Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val c = Vector.fill(n)((sc.nextLong, sc.nextLong))\n\n val mod = 1000000007\n\n def plus(a: Long, b: Long): Long = (a + b) % mod\n def minus(a: Long, b: Long): Long = (a - b + mod) % mod\n def times(a: Long, b: Long): Long = (a * b) % mod\n\n def pow(a: Long, n: Long, res: Long = 1): Long = {\n if (n == 0) {\n res\n } else if ((n&1) == 0) {\n pow(times(a,a), n >> 1, res)\n } else {\n pow(times(a,a), n >> 1, times(a,res))\n }\n }\n\n def gcd(a: Long, b: Long): Long = {\n if (b == 0) a else gcd(b, a % b)\n }\n\n val m = MTMap[(Long,Long), Long]()\n var z = 0\n\n for ((a,b) <- c) {\n if (a == 0 && b == 0) {\n z += 1\n } else {\n val d = gcd(a.abs, b.abs)\n if (b == 0) {\n m((1, 0)) = m.getOrElse((1, 0), 0L) + 1\n } else if (b > 0) {\n m((a / d, b / d)) = m.getOrElse((a / d, b / d), 0L) + 1\n } else {\n m((-a / d, -b / d)) = m.getOrElse((-a / d, -b / d), 0L) + 1\n }\n }\n }\n\n val bads = m.toList.collect{\n case ((a, b), l) if a > 0 && m.isDefinedAt((-b, a)) => (l, m((-b, a)))\n }\n\n val ans = minus(plus(times(\n pow(2, n - z - bads.map{case (x,y) => x+y}.sum),\n bads.map{case (x,y) => minus(plus(pow(2,x), pow(2,y)), 1)}.foldLeft(1L)(times(_,_))\n ), z), 1)\n\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1589775763, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s089595813.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s089595813", "user_id": "u191819389"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import math._\nimport collection.mutable.{Map => MTMap}\n\nobject Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val c = Vector.fill(n)((sc.nextLong, sc.nextLong))\n\n val mod = 1000000007\n\n def plus(a: Long, b: Long): Long = (a + b) % mod\n def minus(a: Long, b: Long): Long = (a - b + mod) % mod\n def times(a: Long, b: Long): Long = (a * b) % mod\n\n def pow(a: Long, n: Long, res: Long = 1): Long = {\n if (n == 0) {\n res\n } else if ((n&1) == 0) {\n pow(times(a,a), n >> 1, res)\n } else {\n pow(times(a,a), n >> 1, times(a,res))\n }\n }\n\n def gcd(a: Long, b: Long): Long = {\n if (b == 0) a else gcd(b, a % b)\n }\n\n val m = MTMap[(Long,Long), Long]()\n var z = 0\n\n for ((a,b) <- c) {\n if (a == 0 && b == 0) {\n z += 1\n } else {\n val d = gcd(a.abs, b.abs)\n if (b == 0) {\n m((1, 0)) = m.getOrElse((1, 0), 0L) + 1\n } else if (b > 0) {\n m((a / d, b / d)) = m.getOrElse((a / d, b / d), 0L) + 1\n } else {\n m((-a / d, -b / d)) = m.getOrElse((-a / d, -b / d), 0L) + 1\n }\n }\n }\n\n val bads = m.toList.collect{\n case ((a, b), l) if a > 0 && m.isDefinedAt((-b, a)) => (l, m((-b, a)))\n }\n\n val ans = minus(plus(times(\n pow(2, n - z - bads.map{case (x,y) => x+y}.sum),\n bads.map{case (x,y) => minus(plus(pow(2,x), pow(2,y)), 1)}.foldLeft(1L)(times(_,_))\n ), z), 1)\n\n println(ans)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1408, "cpu_time_ms": 1710, "memory_kb": 99584}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s776955188", "group_id": "codeNet:p02680", "input_text": "object Main extends App {\n val sc = new FastScanner(System.in)\n val n, m = sc.nextInt()\n var xs, ys = List[Int](0)\n var lx, ly = List[(Int, Int, Int)]()\n for (i <- 1 to n) {\n val a, b, c = sc.nextInt()\n lx ::= (a,b,c)\n xs ::= a\n xs ::= b\n ys ::= c\n }\n for (i <- 1 to m) {\n val d, e, f = sc.nextInt()\n ly ::= (d,e,f)\n xs ::= d\n ys ::= e\n ys ::= f\n }\n\n val xsSorted = xs.distinct.sorted.toVector\n val ysSorted = ys.distinct.sorted.toVector\n\n if (xsSorted.length == 1 || ysSorted.length == 1) {\n println(\"INF\")\n } else {\n val h = xsSorted.length\n val w = ysSorted.length\n val xCmp = xsSorted.zipWithIndex.toMap\n val yCmp = ysSorted.zipWithIndex.toMap\n val lxCmp = lx.map{case (x1,x2,y) => (xCmp(x1),xCmp(x2),yCmp(y))}\n val lyCmp = ly.map{case (x,y1,y2) => (xCmp(x),yCmp(y1),yCmp(y2))}\n val xWidth = Array.fill(h-1)(0)\n val yWidth = Array.fill(w-1)(0)\n for (x <- 0 until h - 1) {\n xWidth(x) = xsSorted(x+1) - xsSorted(x)\n }\n for (y <- 0 until w - 1) {\n yWidth(y) = ysSorted(y+1) - xsSorted(y)\n }\n\n val visited = Array.fill(2 * h - 1, 2 * w - 1)(false)\n for {\n (x1,x2,y) <- lxCmp\n x <- 2 * x1 to 2 * x2\n } {\n visited(x)(y*2) = true\n }\n for {\n (x,y1,y2) <- lyCmp\n y <- 2 * y1 to 2 * y2\n } {\n visited(x*2)(y) = true\n }\n\n val xInit = xCmp(0) * 2\n val yInit = yCmp(0) * 2\n\n if (xInit == 0 || xInit == 2 * h - 2 || yInit == 0 || yInit == 2 * w - 2) {\n println(\"INF\")\n } else {\n visited(xInit)(yInit) = true\n\n var ans = 0L\n var queue = List((xCmp(0) * 2, yCmp(0) * 2))\n val d = List((1,0),(-1,0),(0,1),(0,-1))\n while (queue.nonEmpty) {\n val (x,y) = queue.head\n queue = queue.tail\n for ((dx, dy) <- d) {\n val x1 = x + dx\n val y1 = y + dy\n if (!visited(x1)(y1)) {\n if (x1 == 0 || x1 == 2 * h - 2 || y1 == 0 || y1 == 2 * w - 2) {\n ans = -1\n queue = Nil\n } else {\n queue ::= (x1, y1)\n visited(x1)(y1) = true\n if (x1 % 2 == 1 && y1 % 2 == 1) {\n ans += xWidth(x1 / 2) * yWidth(y1 / 2)\n }\n }\n }\n }\n }\n\n println(if (ans == -1) \"INF\" else ans)\n }\n }\n}\n\nclass FastScanner(source: java.io.InputStream) {\n val buf = new Array[Byte](1024)\n var now, end = 0\n\n def isPrintable(b: Byte): Boolean = 33 <= b && b <= 126\n def isNum(b: Byte): Boolean = 48 <= b && b <= 57\n\n def hasNextByte(): Boolean = {\n if (now < end) {\n true\n } else {\n now = 0\n end = source.read(buf)\n end > 0\n }\n }\n\n def nextByte(): Byte = {\n if (hasNextByte()) {\n val b = buf(now)\n now += 1\n b\n } else {\n -1\n }\n }\n\n def hasNext(): Boolean = {\n while (hasNextByte() && !isPrintable(buf(now))) {\n now += 1\n }\n hasNextByte()\n }\n\n def next(): String = {\n if (hasNext()) {\n val sb = new StringBuilder()\n var b = nextByte()\n while (isPrintable(b)) {\n sb += b.toChar\n b = nextByte()\n }\n sb.toString\n } else {\n throw new NoSuchElementException()\n }\n }\n\n def nextInt(): Int = {\n nextLong().toInt\n }\n\n def nextLong(): Long = {\n if (hasNext()) {\n var b = nextByte()\n var sign = 1\n var n = 0L\n if (b == '-') {\n sign = -1\n b = nextByte()\n }\n while (isNum(b)) {\n n = n * 10 + (b - 48)\n b = nextByte()\n }\n sign * n\n } else {\n throw new NoSuchElementException()\n }\n }\n\n def nextDouble(): Double = next().toDouble\n}\n", "language": "Scala", "metadata": {"date": 1590122687, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02680.html", "problem_id": "p02680", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02680/input.txt", "sample_output_relpath": "derived/input_output/data/p02680/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02680/Scala/s776955188.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s776955188", "user_id": "u191819389"}, "prompt_components": {"gold_output": "13\n", "input_to_evaluate": "object Main extends App {\n val sc = new FastScanner(System.in)\n val n, m = sc.nextInt()\n var xs, ys = List[Int](0)\n var lx, ly = List[(Int, Int, Int)]()\n for (i <- 1 to n) {\n val a, b, c = sc.nextInt()\n lx ::= (a,b,c)\n xs ::= a\n xs ::= b\n ys ::= c\n }\n for (i <- 1 to m) {\n val d, e, f = sc.nextInt()\n ly ::= (d,e,f)\n xs ::= d\n ys ::= e\n ys ::= f\n }\n\n val xsSorted = xs.distinct.sorted.toVector\n val ysSorted = ys.distinct.sorted.toVector\n\n if (xsSorted.length == 1 || ysSorted.length == 1) {\n println(\"INF\")\n } else {\n val h = xsSorted.length\n val w = ysSorted.length\n val xCmp = xsSorted.zipWithIndex.toMap\n val yCmp = ysSorted.zipWithIndex.toMap\n val lxCmp = lx.map{case (x1,x2,y) => (xCmp(x1),xCmp(x2),yCmp(y))}\n val lyCmp = ly.map{case (x,y1,y2) => (xCmp(x),yCmp(y1),yCmp(y2))}\n val xWidth = Array.fill(h-1)(0)\n val yWidth = Array.fill(w-1)(0)\n for (x <- 0 until h - 1) {\n xWidth(x) = xsSorted(x+1) - xsSorted(x)\n }\n for (y <- 0 until w - 1) {\n yWidth(y) = ysSorted(y+1) - xsSorted(y)\n }\n\n val visited = Array.fill(2 * h - 1, 2 * w - 1)(false)\n for {\n (x1,x2,y) <- lxCmp\n x <- 2 * x1 to 2 * x2\n } {\n visited(x)(y*2) = true\n }\n for {\n (x,y1,y2) <- lyCmp\n y <- 2 * y1 to 2 * y2\n } {\n visited(x*2)(y) = true\n }\n\n val xInit = xCmp(0) * 2\n val yInit = yCmp(0) * 2\n\n if (xInit == 0 || xInit == 2 * h - 2 || yInit == 0 || yInit == 2 * w - 2) {\n println(\"INF\")\n } else {\n visited(xInit)(yInit) = true\n\n var ans = 0L\n var queue = List((xCmp(0) * 2, yCmp(0) * 2))\n val d = List((1,0),(-1,0),(0,1),(0,-1))\n while (queue.nonEmpty) {\n val (x,y) = queue.head\n queue = queue.tail\n for ((dx, dy) <- d) {\n val x1 = x + dx\n val y1 = y + dy\n if (!visited(x1)(y1)) {\n if (x1 == 0 || x1 == 2 * h - 2 || y1 == 0 || y1 == 2 * w - 2) {\n ans = -1\n queue = Nil\n } else {\n queue ::= (x1, y1)\n visited(x1)(y1) = true\n if (x1 % 2 == 1 && y1 % 2 == 1) {\n ans += xWidth(x1 / 2) * yWidth(y1 / 2)\n }\n }\n }\n }\n }\n\n println(if (ans == -1) \"INF\" else ans)\n }\n }\n}\n\nclass FastScanner(source: java.io.InputStream) {\n val buf = new Array[Byte](1024)\n var now, end = 0\n\n def isPrintable(b: Byte): Boolean = 33 <= b && b <= 126\n def isNum(b: Byte): Boolean = 48 <= b && b <= 57\n\n def hasNextByte(): Boolean = {\n if (now < end) {\n true\n } else {\n now = 0\n end = source.read(buf)\n end > 0\n }\n }\n\n def nextByte(): Byte = {\n if (hasNextByte()) {\n val b = buf(now)\n now += 1\n b\n } else {\n -1\n }\n }\n\n def hasNext(): Boolean = {\n while (hasNextByte() && !isPrintable(buf(now))) {\n now += 1\n }\n hasNextByte()\n }\n\n def next(): String = {\n if (hasNext()) {\n val sb = new StringBuilder()\n var b = nextByte()\n while (isPrintable(b)) {\n sb += b.toChar\n b = nextByte()\n }\n sb.toString\n } else {\n throw new NoSuchElementException()\n }\n }\n\n def nextInt(): Int = {\n nextLong().toInt\n }\n\n def nextLong(): Long = {\n if (hasNext()) {\n var b = nextByte()\n var sign = 1\n var n = 0L\n if (b == '-') {\n sign = -1\n b = nextByte()\n }\n while (isNum(b)) {\n n = n * 10 + (b - 48)\n b = nextByte()\n }\n sign * n\n } else {\n throw new NoSuchElementException()\n }\n }\n\n def nextDouble(): Double = next().toDouble\n}\n", "problem_context": "Score: 600 points\n\nProblem Statement\n\nThere is a grass field that stretches infinitely.\n\nIn this field, there is a negligibly small cow. Let (x, y) denote the point that is x\\ \\mathrm{cm} south and y\\ \\mathrm{cm} east of the point where the cow stands now. The cow itself is standing at (0, 0).\n\nThere are also N north-south lines and M east-west lines drawn on the field. The i-th north-south line is the segment connecting the points (A_i, C_i) and (B_i, C_i), and the j-th east-west line is the segment connecting the points (D_j, E_j) and (D_j, F_j).\n\nWhat is the area of the region the cow can reach when it can move around as long as it does not cross the segments (including the endpoints)? If this area is infinite, print INF instead.\n\nConstraints\n\nAll values in input are integers between -10^9 and 10^9 (inclusive).\n\n1 \\leq N, M \\leq 1000\n\nA_i < B_i\\ (1 \\leq i \\leq N)\n\nE_j < F_j\\ (1 \\leq j \\leq M)\n\nThe point (0, 0) does not lie on any of the given segments.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1 C_1\n:\nA_N B_N C_N\nD_1 E_1 F_1\n:\nD_M E_M F_M\n\nOutput\n\nIf the area of the region the cow can reach is infinite, print INF; otherwise, print an integer representing the area in \\mathrm{cm^2}.\n\n(Under the constraints, it can be proved that the area of the region is always an integer if it is not infinite.)\n\nSample Input 1\n\n5 6\n1 2 0\n0 1 1\n0 2 2\n-3 4 -1\n-2 6 3\n1 0 1\n0 1 2\n2 0 2\n-1 -4 5\n3 -2 4\n1 2 4\n\nSample Output 1\n\n13\n\nThe area of the region the cow can reach is 13\\ \\mathrm{cm^2}.\n\nSample Input 2\n\n6 1\n-3 -1 -2\n-3 -1 1\n-2 -1 2\n1 4 -2\n1 4 -1\n1 4 1\n3 1 4\n\nSample Output 2\n\nINF\n\nThe area of the region the cow can reach is infinite.", "sample_input": "5 6\n1 2 0\n0 1 1\n0 2 2\n-3 4 -1\n-2 6 3\n1 0 1\n0 1 2\n2 0 2\n-1 -4 5\n3 -2 4\n1 2 4\n"}, "reference_outputs": ["13\n"], "source_document_id": "p02680", "source_text": "Score: 600 points\n\nProblem Statement\n\nThere is a grass field that stretches infinitely.\n\nIn this field, there is a negligibly small cow. Let (x, y) denote the point that is x\\ \\mathrm{cm} south and y\\ \\mathrm{cm} east of the point where the cow stands now. The cow itself is standing at (0, 0).\n\nThere are also N north-south lines and M east-west lines drawn on the field. The i-th north-south line is the segment connecting the points (A_i, C_i) and (B_i, C_i), and the j-th east-west line is the segment connecting the points (D_j, E_j) and (D_j, F_j).\n\nWhat is the area of the region the cow can reach when it can move around as long as it does not cross the segments (including the endpoints)? If this area is infinite, print INF instead.\n\nConstraints\n\nAll values in input are integers between -10^9 and 10^9 (inclusive).\n\n1 \\leq N, M \\leq 1000\n\nA_i < B_i\\ (1 \\leq i \\leq N)\n\nE_j < F_j\\ (1 \\leq j \\leq M)\n\nThe point (0, 0) does not lie on any of the given segments.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1 C_1\n:\nA_N B_N C_N\nD_1 E_1 F_1\n:\nD_M E_M F_M\n\nOutput\n\nIf the area of the region the cow can reach is infinite, print INF; otherwise, print an integer representing the area in \\mathrm{cm^2}.\n\n(Under the constraints, it can be proved that the area of the region is always an integer if it is not infinite.)\n\nSample Input 1\n\n5 6\n1 2 0\n0 1 1\n0 2 2\n-3 4 -1\n-2 6 3\n1 0 1\n0 1 2\n2 0 2\n-1 -4 5\n3 -2 4\n1 2 4\n\nSample Output 1\n\n13\n\nThe area of the region the cow can reach is 13\\ \\mathrm{cm^2}.\n\nSample Input 2\n\n6 1\n-3 -1 -2\n-3 -1 1\n-2 -1 2\n1 4 -2\n1 4 -1\n1 4 1\n3 1 4\n\nSample Output 2\n\nINF\n\nThe area of the region the cow can reach is infinite.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3656, "cpu_time_ms": 3308, "memory_kb": 306756}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s246878597", "group_id": "codeNet:p02683", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val N, M, X = sc.nextInt\n val CA = Array.fill(N, M + 1)(sc.nextInt)\n val C = CA.map(_.head)\n val A = CA.map(_.tail)\n\n val a = (0 until N).foldLeft(Set(Set.empty[Int])) {\n (set, element) => set union (set map (_ + element))\n }\n val b = a.toSeq.filter(xs => {\n xs.map(A(_)).foldLeft(Array.fill(M)(0))((x, y) => {\n (x zip y).map { case (x, y) => x + y }\n }).forall(_ >= X)\n })\n val c = b.map(_.map(C(_)).sum)\n val x = if (c.isEmpty) -1 else c.min\n println(x)\n}\n", "language": "Scala", "metadata": {"date": 1589164988, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s246878597.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s246878597", "user_id": "u786167609"}, "prompt_components": {"gold_output": "120\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val N, M, X = sc.nextInt\n val CA = Array.fill(N, M + 1)(sc.nextInt)\n val C = CA.map(_.head)\n val A = CA.map(_.tail)\n\n val a = (0 until N).foldLeft(Set(Set.empty[Int])) {\n (set, element) => set union (set map (_ + element))\n }\n val b = a.toSeq.filter(xs => {\n xs.map(A(_)).foldLeft(Array.fill(M)(0))((x, y) => {\n (x zip y).map { case (x, y) => x + y }\n }).forall(_ >= X)\n })\n val c = b.map(_.map(C(_)).sum)\n val x = if (c.isEmpty) -1 else c.min\n println(x)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 570, "cpu_time_ms": 832, "memory_kb": 66048}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s928134258", "group_id": "codeNet:p02683", "input_text": "object Main extends App {\n val nmx = scala.io.StdIn.readLine()\n val nmxArray = nmx.split(\" \").map(_.toInt).toSeq\n val n = nmxArray(0)\n val m = nmxArray(1)\n val x = nmxArray(2)\n\n var caVector = Vector.empty[Vector[Int]]\n (1 to n).foreach { _ =>\n val ca = scala.io.StdIn.readLine()\n val caArray = ca.split(\" \").map(_.toInt).toVector\n caVector :+= caArray\n }\n\n var resultVector = Vector.empty[Int]\n (1 to n).foreach { i =>\n caVector.combinations(i).foreach { cas =>\n var rikaiSum = scala.collection.mutable.Seq.empty[Int]\n cas.foreach { ca =>\n if (rikaiSum.length == 0) {\n rikaiSum = scala.collection.mutable.ListBuffer(ca.tail: _*)\n } else {\n (0 to m - 1).foreach { i =>\n rikaiSum(i) = rikaiSum(i) + ca(i + 1)\n }\n }\n\n }\n if (!rikaiSum.exists(r => r < x)) {\n resultVector :+= cas.map(ca => ca.head).sum\n }\n }\n }\n if (resultVector.length == 0) {\n println(-1)\n } else {\n println(resultVector.min)\n }\n}", "language": "Scala", "metadata": {"date": 1589162592, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s928134258.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s928134258", "user_id": "u105921924"}, "prompt_components": {"gold_output": "120\n", "input_to_evaluate": "object Main extends App {\n val nmx = scala.io.StdIn.readLine()\n val nmxArray = nmx.split(\" \").map(_.toInt).toSeq\n val n = nmxArray(0)\n val m = nmxArray(1)\n val x = nmxArray(2)\n\n var caVector = Vector.empty[Vector[Int]]\n (1 to n).foreach { _ =>\n val ca = scala.io.StdIn.readLine()\n val caArray = ca.split(\" \").map(_.toInt).toVector\n caVector :+= caArray\n }\n\n var resultVector = Vector.empty[Int]\n (1 to n).foreach { i =>\n caVector.combinations(i).foreach { cas =>\n var rikaiSum = scala.collection.mutable.Seq.empty[Int]\n cas.foreach { ca =>\n if (rikaiSum.length == 0) {\n rikaiSum = scala.collection.mutable.ListBuffer(ca.tail: _*)\n } else {\n (0 to m - 1).foreach { i =>\n rikaiSum(i) = rikaiSum(i) + ca(i + 1)\n }\n }\n\n }\n if (!rikaiSum.exists(r => r < x)) {\n resultVector :+= cas.map(ca => ca.head).sum\n }\n }\n }\n if (resultVector.length == 0) {\n println(-1)\n } else {\n println(resultVector.min)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1026, "cpu_time_ms": 710, "memory_kb": 60148}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s643646210", "group_id": "codeNet:p02687", "input_text": "import scala.io.StdIn.readLine\nimport scala.io.StdIn.readInt\n\nobject Main extends App {\n val s = readLine\n val ans = if(s == \"ARC\")\"ABC\" else \"ARC\"\n println(ans) // 結果を出力する\n}", "language": "Scala", "metadata": {"date": 1588623779, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02687.html", "problem_id": "p02687", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02687/input.txt", "sample_output_relpath": "derived/input_output/data/p02687/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02687/Scala/s643646210.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s643646210", "user_id": "u093219895"}, "prompt_components": {"gold_output": "ARC\n", "input_to_evaluate": "import scala.io.StdIn.readLine\nimport scala.io.StdIn.readInt\n\nobject Main extends App {\n val s = readLine\n val ans = if(s == \"ARC\")\"ABC\" else \"ARC\"\n println(ans) // 結果を出力する\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAtCoder Inc. holds a contest every Saturday.\n\nThere are two types of contests called ABC and ARC, and just one of them is held at a time.\n\nThe company holds these two types of contests alternately: an ARC follows an ABC and vice versa.\n\nGiven a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.\n\nConstraints\n\nS is ABC or ARC.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the string representing the type of the contest held this week.\n\nSample Input 1\n\nABC\n\nSample Output 1\n\nARC\n\nThey held an ABC last week, so they will hold an ARC this week.", "sample_input": "ABC\n"}, "reference_outputs": ["ARC\n"], "source_document_id": "p02687", "source_text": "Score : 100 points\n\nProblem Statement\n\nAtCoder Inc. holds a contest every Saturday.\n\nThere are two types of contests called ABC and ARC, and just one of them is held at a time.\n\nThe company holds these two types of contests alternately: an ARC follows an ABC and vice versa.\n\nGiven a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.\n\nConstraints\n\nS is ABC or ARC.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the string representing the type of the contest held this week.\n\nSample Input 1\n\nABC\n\nSample Output 1\n\nARC\n\nThey held an ABC last week, so they will hold an ARC this week.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 493, "memory_kb": 54448}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s301481232", "group_id": "codeNet:p02687", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val s = sc.next\n\n if (s == \"ABC\") {\n println(\"ARC\")\n } else {\n println(\"ABC\")\n }\n}\n", "language": "Scala", "metadata": {"date": 1588557270, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02687.html", "problem_id": "p02687", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02687/input.txt", "sample_output_relpath": "derived/input_output/data/p02687/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02687/Scala/s301481232.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s301481232", "user_id": "u015315385"}, "prompt_components": {"gold_output": "ARC\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val s = sc.next\n\n if (s == \"ABC\") {\n println(\"ARC\")\n } else {\n println(\"ABC\")\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAtCoder Inc. holds a contest every Saturday.\n\nThere are two types of contests called ABC and ARC, and just one of them is held at a time.\n\nThe company holds these two types of contests alternately: an ARC follows an ABC and vice versa.\n\nGiven a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.\n\nConstraints\n\nS is ABC or ARC.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the string representing the type of the contest held this week.\n\nSample Input 1\n\nABC\n\nSample Output 1\n\nARC\n\nThey held an ABC last week, so they will hold an ARC this week.", "sample_input": "ABC\n"}, "reference_outputs": ["ARC\n"], "source_document_id": "p02687", "source_text": "Score : 100 points\n\nProblem Statement\n\nAtCoder Inc. holds a contest every Saturday.\n\nThere are two types of contests called ABC and ARC, and just one of them is held at a time.\n\nThe company holds these two types of contests alternately: an ARC follows an ABC and vice versa.\n\nGiven a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.\n\nConstraints\n\nS is ABC or ARC.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the string representing the type of the contest held this week.\n\nSample Input 1\n\nABC\n\nSample Output 1\n\nARC\n\nThey held an ABC last week, so they will hold an ARC this week.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 164, "cpu_time_ms": 511, "memory_kb": 55212}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s148198486", "group_id": "codeNet:p02688", "input_text": "import java.util.Scanner\n\nimport scala.io.StdIn._\nobject Main extends App {\n\n val Array(n, k) = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n val sweets = Array.fill(k * 2)(readLine().split(\" \").map(_.toInt))\n .zipWithIndex.collect {\n case (list, index) if index % 2 == 1 => list.map(_ - 1)\n }\n\n\n def solve() = {\n val hasSweetArr = Array.fill(n)(false)\n sweets.foreach { list =>\n list.foreach { i =>\n if(!hasSweetArr(i)) hasSweetArr(i) = true\n }\n }\n hasSweetArr.count(!_)\n }\n\n println(solve())\n\n}\n\n", "language": "Scala", "metadata": {"date": 1593821373, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s148198486.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s148198486", "user_id": "u947008426"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.io.StdIn._\nobject Main extends App {\n\n val Array(n, k) = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n val sweets = Array.fill(k * 2)(readLine().split(\" \").map(_.toInt))\n .zipWithIndex.collect {\n case (list, index) if index % 2 == 1 => list.map(_ - 1)\n }\n\n\n def solve() = {\n val hasSweetArr = Array.fill(n)(false)\n sweets.foreach { list =>\n list.foreach { i =>\n if(!hasSweetArr(i)) hasSweetArr(i) = true\n }\n }\n hasSweetArr.count(!_)\n }\n\n println(solve())\n\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 520, "memory_kb": 55140}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s663869483", "group_id": "codeNet:p02689", "input_text": "import scala.io.StdIn._\n\nobject Helpers {\n def readIntLine = readLine.split(\" \").map(_.toInt)\n def readInts(n: Int) = Array.fill(n)(readInt)\n\n def splitDigits(i: Int): Seq[Int] = i.toString.map(_.asDigit)\n\n def log[A](x: A): A = {println(x); x}\n\n implicit class IntImplicits(val i: Int) {\n def isEven = i % 2 == 0\n def isOdd = !isEven\n }\n}\n\nobject Main extends App {\n import Helpers._\n\n val Array(n, m) = readIntLine\n val hs: Array[Int] = readIntLine\n\n var roads = Map[Int, Set[Int]]()\n for (_ <- Range(0, m)) {\n val Array(a, b) = readIntLine\n roads = if (roads.contains(a)) roads + (a -> (roads(a) + b)) else roads + (a -> Set(b))\n roads = if (roads.contains(b)) roads + (b -> (roads(b) + a)) else roads + (b -> Set(a))\n }\n\n def isGood(x: Int, roads: Map[Int, Set[Int]]): Boolean = {\n if (roads.contains(x + 1)) {\n val h = hs(x)\n !roads(x + 1).exists((a: Int) => (hs(a - 1) >= h))\n } else {\n true\n }\n }\n\n println(Range(0, n).count(isGood(_, roads)))\n}\n\n", "language": "Scala", "metadata": {"date": 1589049404, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s663869483.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s663869483", "user_id": "u174523836"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Helpers {\n def readIntLine = readLine.split(\" \").map(_.toInt)\n def readInts(n: Int) = Array.fill(n)(readInt)\n\n def splitDigits(i: Int): Seq[Int] = i.toString.map(_.asDigit)\n\n def log[A](x: A): A = {println(x); x}\n\n implicit class IntImplicits(val i: Int) {\n def isEven = i % 2 == 0\n def isOdd = !isEven\n }\n}\n\nobject Main extends App {\n import Helpers._\n\n val Array(n, m) = readIntLine\n val hs: Array[Int] = readIntLine\n\n var roads = Map[Int, Set[Int]]()\n for (_ <- Range(0, m)) {\n val Array(a, b) = readIntLine\n roads = if (roads.contains(a)) roads + (a -> (roads(a) + b)) else roads + (a -> Set(b))\n roads = if (roads.contains(b)) roads + (b -> (roads(b) + a)) else roads + (b -> Set(a))\n }\n\n def isGood(x: Int, roads: Map[Int, Set[Int]]): Boolean = {\n if (roads.contains(x + 1)) {\n val h = hs(x)\n !roads(x + 1).exists((a: Int) => (hs(a - 1) >= h))\n } else {\n true\n }\n }\n\n println(Range(0, n).count(isGood(_, roads)))\n}\n\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1008, "cpu_time_ms": 1632, "memory_kb": 90848}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s236029440", "group_id": "codeNet:p02689", "input_text": "object Main extends App {\n import scala.io.StdIn._\n \n val Array(n,m) = readLine.split(\" \").map{_.toInt}.toArray\n val h = readLine.split(\" \").map{_.toLong}.toList\n val ab = (for (i <- 1 to m) yield {\n val Array(a,b) = readLine.split(\" \").map{_.toInt}.toArray\n (a,b)\n }).toList\n \n val sortedH = h.zipWithIndex.sortWith((x,y) => x._1 > y._1).map{case (x,y) => (x,y+1)}\n val check = Array.fill(n+1)(false)\n check(0) = true\n var ans = 0\n \n for (x <- sortedH if check.count{x => !x} != 0) {\n val i = x._2\n if (!check(i)) {\n ans += 1\n check(i) = true\n }\n ab.filter{case (a,b) => a == i || b == i}.map{case (a,b) => if (a == i) b else a}.foreach{i => check(i) = true}\n }\n \n println(ans)\n \n}", "language": "Scala", "metadata": {"date": 1588558162, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s236029440.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s236029440", "user_id": "u696665136"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n import scala.io.StdIn._\n \n val Array(n,m) = readLine.split(\" \").map{_.toInt}.toArray\n val h = readLine.split(\" \").map{_.toLong}.toList\n val ab = (for (i <- 1 to m) yield {\n val Array(a,b) = readLine.split(\" \").map{_.toInt}.toArray\n (a,b)\n }).toList\n \n val sortedH = h.zipWithIndex.sortWith((x,y) => x._1 > y._1).map{case (x,y) => (x,y+1)}\n val check = Array.fill(n+1)(false)\n check(0) = true\n var ans = 0\n \n for (x <- sortedH if check.count{x => !x} != 0) {\n val i = x._2\n if (!check(i)) {\n ans += 1\n check(i) = true\n }\n ab.filter{case (a,b) => a == i || b == i}.map{case (a,b) => if (a == i) b else a}.foreach{i => check(i) = true}\n }\n \n println(ans)\n \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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 765, "cpu_time_ms": 2205, "memory_kb": 68516}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s458693143", "group_id": "codeNet:p02689", "input_text": "import scala.io.StdIn._\nimport scala.math._\n\nobject Main extends App with StdInHelper {\n val Array(n, m) = readInts\n val map = readLongs.zipWithIndex.map { case (h, i) => (i + 1, h) }.toMap\n var hs = (1 to n).toIndexedSeq\n\n var res = 0L\n for (_ <- 1 to m) {\n val Array(a, b) = readInts\n if (map(a) < map(b)) hs = hs.filterNot(_ == a)\n else hs = hs.filterNot(_ == b)\n }\n println(hs.length)\n}\n\ntrait StdInHelper {\n def readInts = readLine.split(\" \").map(_.toInt)\n def readLongs = readLine.split(\" \").map(_.toLong)\n}\n", "language": "Scala", "metadata": {"date": 1588557882, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s458693143.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s458693143", "user_id": "u301214832"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.io.StdIn._\nimport scala.math._\n\nobject Main extends App with StdInHelper {\n val Array(n, m) = readInts\n val map = readLongs.zipWithIndex.map { case (h, i) => (i + 1, h) }.toMap\n var hs = (1 to n).toIndexedSeq\n\n var res = 0L\n for (_ <- 1 to m) {\n val Array(a, b) = readInts\n if (map(a) < map(b)) hs = hs.filterNot(_ == a)\n else hs = hs.filterNot(_ == b)\n }\n println(hs.length)\n}\n\ntrait StdInHelper {\n def readInts = readLine.split(\" \").map(_.toInt)\n def readLongs = readLine.split(\" \").map(_.toLong)\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2206, "memory_kb": 67544}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s159466232", "group_id": "codeNet:p02692", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val ABC = Array(\"A\", \"B\", \"C\")\n def printABC(n: Int): Unit = {\n println(ABC(n))\n }\n\n val sc = new Scanner(System.in)\n val n = sc.nextInt()\n val (a, b, c) = (sc.nextInt(), sc.nextInt(), sc.nextInt())\n val ss = (1 to n).map { _ =>\n val s = sc.next()\n S.find(s)\n }\n\n var state = State(Array(a, b, c), Nil)\n ss.zipWithIndex.foreach { case (s, idx) =>\n val Array(i, j) = s.target\n if(state(i) + state(j) <= 0) {\n println(\"No\")\n sys.exit(0)\n }\n state = if(state(i) == 0) state.add(i, j)\n else if(state(j) == 0) state.add(j, i)\n else {\n ss.lift(idx + 1).fold { state.add(i, j) } { nextS =>\n if(nextS.target.contains(i)) state.add(i, j) else state.add(j, i)\n }\n }\n }\n println(\"Yes\")\n state.result.reverse.foreach(printABC)\n\n}\n\ncase class State(ary: Array[Int], result: List[Int]) {\n def add(incr: Int, decr: Int): State = {\n val nextAry = ary.clone()\n nextAry(incr) += 1\n nextAry(decr) -= 1\n State(nextAry, incr :: result)\n }\n\n def apply(n: Int): Int = ary(n)\n}\n\nsealed abstract class S {\n lazy val name: String = getClass.getSimpleName.init\n\n def target: Array[Int]\n\n def dup(s: S): Int = (target.toSet & s.target.toSet).head\n}\n\nobject S {\n case object AB extends S {\n override val target: Array[Int] = Array(0, 1)\n }\n\n case object AC extends S {\n override val target: Array[Int] = Array(0, 2)\n }\n\n case object BC extends S {\n override val target: Array[Int] = Array(1, 2)\n }\n\n val values: Seq[S] = AB :: AC :: BC :: Nil\n def find(name: String): S = values.find(_.name == name).get\n}\n", "language": "Scala", "metadata": {"date": 1588572610, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02692.html", "problem_id": "p02692", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02692/input.txt", "sample_output_relpath": "derived/input_output/data/p02692/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02692/Scala/s159466232.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s159466232", "user_id": "u994342365"}, "prompt_components": {"gold_output": "Yes\nA\nC\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n val ABC = Array(\"A\", \"B\", \"C\")\n def printABC(n: Int): Unit = {\n println(ABC(n))\n }\n\n val sc = new Scanner(System.in)\n val n = sc.nextInt()\n val (a, b, c) = (sc.nextInt(), sc.nextInt(), sc.nextInt())\n val ss = (1 to n).map { _ =>\n val s = sc.next()\n S.find(s)\n }\n\n var state = State(Array(a, b, c), Nil)\n ss.zipWithIndex.foreach { case (s, idx) =>\n val Array(i, j) = s.target\n if(state(i) + state(j) <= 0) {\n println(\"No\")\n sys.exit(0)\n }\n state = if(state(i) == 0) state.add(i, j)\n else if(state(j) == 0) state.add(j, i)\n else {\n ss.lift(idx + 1).fold { state.add(i, j) } { nextS =>\n if(nextS.target.contains(i)) state.add(i, j) else state.add(j, i)\n }\n }\n }\n println(\"Yes\")\n state.result.reverse.foreach(printABC)\n\n}\n\ncase class State(ary: Array[Int], result: List[Int]) {\n def add(incr: Int, decr: Int): State = {\n val nextAry = ary.clone()\n nextAry(incr) += 1\n nextAry(decr) -= 1\n State(nextAry, incr :: result)\n }\n\n def apply(n: Int): Int = ary(n)\n}\n\nsealed abstract class S {\n lazy val name: String = getClass.getSimpleName.init\n\n def target: Array[Int]\n\n def dup(s: S): Int = (target.toSet & s.target.toSet).head\n}\n\nobject S {\n case object AB extends S {\n override val target: Array[Int] = Array(0, 1)\n }\n\n case object AC extends S {\n override val target: Array[Int] = Array(0, 2)\n }\n\n case object BC extends S {\n override val target: Array[Int] = Array(1, 2)\n }\n\n val values: Seq[S] = AB :: AC :: BC :: Nil\n def find(name: String): S = values.find(_.name == name).get\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere is a game that involves three variables, denoted A, B, and C.\n\nAs the game progresses, there will be N events where you are asked to make a choice.\nEach of these choices is represented by a string s_i. If s_i is AB, you must add 1 to A or B then subtract 1 from the other; if s_i is AC, you must add 1 to A or C then subtract 1 from the other; if s_i is BC, you must add 1 to B or C then subtract 1 from the other.\n\nAfter each choice, none of A, B, and C should be negative.\n\nDetermine whether it is possible to make N choices under this condition. If it is possible, also give one such way to make the choices.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq A,B,C \\leq 10^9\n\nN, A, B, C are integers.\n\ns_i is AB, AC, or BC.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C\ns_1\ns_2\n:\ns_N\n\nOutput\n\nIf it is possible to make N choices under the condition, print Yes; otherwise, print No.\n\nAlso, in the former case, show one such way to make the choices in the subsequent N lines. The (i+1)-th line should contain the name of the variable (A, B, or C) to which you add 1 in the i-th choice.\n\nSample Input 1\n\n2 1 3 0\nAB\nAC\n\nSample Output 1\n\nYes\nA\nC\n\nYou can successfully make two choices, as follows:\n\nIn the first choice, add 1 to A and subtract 1 from B. A becomes 2, and B becomes 2.\n\nIn the second choice, add 1 to C and subtract 1 from A. C becomes 1, and A becomes 1.\n\nSample Input 2\n\n3 1 0 0\nAB\nBC\nAB\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n1 0 9 0\nAC\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n8 6 9 1\nAC\nBC\nAB\nBC\nAC\nBC\nAB\nAB\n\nSample Output 4\n\nYes\nC\nB\nB\nC\nC\nB\nA\nA", "sample_input": "2 1 3 0\nAB\nAC\n"}, "reference_outputs": ["Yes\nA\nC\n"], "source_document_id": "p02692", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere is a game that involves three variables, denoted A, B, and C.\n\nAs the game progresses, there will be N events where you are asked to make a choice.\nEach of these choices is represented by a string s_i. If s_i is AB, you must add 1 to A or B then subtract 1 from the other; if s_i is AC, you must add 1 to A or C then subtract 1 from the other; if s_i is BC, you must add 1 to B or C then subtract 1 from the other.\n\nAfter each choice, none of A, B, and C should be negative.\n\nDetermine whether it is possible to make N choices under this condition. If it is possible, also give one such way to make the choices.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq A,B,C \\leq 10^9\n\nN, A, B, C are integers.\n\ns_i is AB, AC, or BC.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C\ns_1\ns_2\n:\ns_N\n\nOutput\n\nIf it is possible to make N choices under the condition, print Yes; otherwise, print No.\n\nAlso, in the former case, show one such way to make the choices in the subsequent N lines. The (i+1)-th line should contain the name of the variable (A, B, or C) to which you add 1 in the i-th choice.\n\nSample Input 1\n\n2 1 3 0\nAB\nAC\n\nSample Output 1\n\nYes\nA\nC\n\nYou can successfully make two choices, as follows:\n\nIn the first choice, add 1 to A and subtract 1 from B. A becomes 2, and B becomes 2.\n\nIn the second choice, add 1 to C and subtract 1 from A. C becomes 1, and A becomes 1.\n\nSample Input 2\n\n3 1 0 0\nAB\nBC\nAB\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n1 0 9 0\nAC\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n8 6 9 1\nAC\nBC\nAB\nBC\nAC\nBC\nAB\nAB\n\nSample Output 4\n\nYes\nC\nB\nB\nC\nC\nB\nA\nA", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1635, "cpu_time_ms": 1422, "memory_kb": 71856}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s084566561", "group_id": "codeNet:p02693", "input_text": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n val k = readLine.toInt\n val a = readLine.split(\" \").map(x => x.toInt)\n println(if ((a(0) - 1) / k != a(1) / k) \"OK\" else \"NG\")\n}\n", "language": "Scala", "metadata": {"date": 1588624114, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s084566561.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s084566561", "user_id": "u708618797"}, "prompt_components": {"gold_output": "OK\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n val k = readLine.toInt\n val a = readLine.split(\" \").map(x => x.toInt)\n println(if ((a(0) - 1) / k != a(1) / k) \"OK\" else \"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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 502, "memory_kb": 54664}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s109509670", "group_id": "codeNet:p02694", "input_text": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n println(recursive(sc.nextLong()))\n }\n\n @scala.annotation.tailrec\n def recursive(X: Long, now: Long = 100, ans: Long = 0): Long = {\n if (now >= X) ans\n else recursive(X, (now * 1.01).toLong, ans + 1)\n }\n\n def flip(A: Array[Boolean], B: Array[(Int, Long)]): Array[(Int, Long)] = {\n B.map { case (index, _) =>\n (index, (if (0 < index && A(index - 1)) B(index - 1)._2 else 0L) + (if (index + 1 < B.length && !A(index + 1)) B(index + 1)._2 else 0L))\n }\n }\n\n val mod: Long = (1e9 + 7).toLong\n\n\n @scala.annotation.tailrec\n def factorial(now: Long, ans: Long = 1): Long = {\n if (now == 0) 0 else if (now == 1) ans else factorial(now - 1, now * ans)\n }\n\n implicit class implicitInt(val N: Int) {\n def times[B](function: Int => B): IndexedSeq[B] = (0 until N).map(function)\n }\n\n def calc(input: (Long, Long, Long, Long, Long, Long)): Long = {\n input match {\n case (a, b, c, x, y, z) =>\n var ans: Long = Long.MaxValue\n if (b >= 3 && (a >= 2 || c >= 2)) {\n ans = Math.min(ans, Math.max(a - (b - 1), 0) * x + Math.max(c - Math.min(a - 1, b - 2), 0) * z)\n ans = Math.min(ans, Math.max(a - Math.min(c - 1, b - 2), 0) * x + Math.max(c - (b - 1), 0) * z)\n }\n // println(ans)\n if (b >= 2 && (a >= b && c >= b + 1)) {\n ans = Math.min(ans, y + Math.max(0, a - (c - 1)) * x)\n }\n // println(ans)\n if (b >= 2 && (a >= b + 1 && c >= b)) {\n ans = Math.min(ans, y + Math.max(0, c - (a - 1)) * z)\n }\n // println(ans)\n if (a >= 2 && c >= 2)\n if (a != c)\n ans = Math.min(ans, Math.max(0, b - (Math.min(a, c) - 1)) * y)\n else if (a >= 3 && c >= 3)\n ans = Math.min(ans, Math.max(0, b - (Math.min(a, c) - 2)) * y + Math.min(x, z))\n // println(ans)\n if (ans == Long.MaxValue) ans = -1\n ans\n }\n }\n\n def time(s: String): Int =\n s.substring(0, 2).toInt * 60 + s.substring(3, 5).toInt\n\n /*\n def getPermutation(begin: Long = 0): LazyList[Long] =\n LazyList.cons(begin, getPermutation(begin + 1))\n\n def getFibonacci(prevprev: Long = 0, prev: Long = 1): LazyList[Long] =\n LazyList.cons(prevprev, getFibonacci(prev, prevprev + prev))\n\n @scala.annotation.tailrec\n def recursive2(X: Set[Long], Y: LazyList[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n*/\n def check(i: Int, X: String): Long = {\n if (X == \"\") 0 else check(i, X.tail) * i + X.head.toString.toLong\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n @scala.annotation.tailrec\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def primeFactors(i: Long): List[Long] = primeFactors_(i, 1).sorted\n\n\n def primeFactors_(i: Long, j: Long): List[Long] = {\n if (j * j > i) List.empty else if (i % j == 0) primeFactors_(i, j + 1) ++ List[Long](j, i / j) else primeFactors_(i, j + 1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\n/*\nobject Util {\n def getPermutation(begin: Long = 0): LazyList[Long] =\n LazyList.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: LazyList[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: LazyList[Long]): LazyList[Long] =\n LazyList.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): LazyList[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\n */\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n private val codeTable: List[(Int, String)] = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n @scala.annotation.tailrec\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n @scala.annotation.tailrec\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n}\n\nobject PowMod {\n def naivePowMod(a: Long, k: Long, m: Long): Long = {\n var t: Long = 1\n val aMod: Long = a % m\n\n for (_ <- 1L to k) {\n t = ((t % m) * aMod) % m\n }\n t.toInt\n }\n\n def powMod(a: Long, k: Long, m: Long): Long = {\n if (k == 0) 1\n else {\n val t = powMod(a, k / 2, m)\n if ((k % 2) == 0) (t * t) % m else (((t * t) % m) * a) % m\n }\n }\n}", "language": "Scala", "metadata": {"date": 1589425980, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s109509670.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s109509670", "user_id": "u779353743"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n println(recursive(sc.nextLong()))\n }\n\n @scala.annotation.tailrec\n def recursive(X: Long, now: Long = 100, ans: Long = 0): Long = {\n if (now >= X) ans\n else recursive(X, (now * 1.01).toLong, ans + 1)\n }\n\n def flip(A: Array[Boolean], B: Array[(Int, Long)]): Array[(Int, Long)] = {\n B.map { case (index, _) =>\n (index, (if (0 < index && A(index - 1)) B(index - 1)._2 else 0L) + (if (index + 1 < B.length && !A(index + 1)) B(index + 1)._2 else 0L))\n }\n }\n\n val mod: Long = (1e9 + 7).toLong\n\n\n @scala.annotation.tailrec\n def factorial(now: Long, ans: Long = 1): Long = {\n if (now == 0) 0 else if (now == 1) ans else factorial(now - 1, now * ans)\n }\n\n implicit class implicitInt(val N: Int) {\n def times[B](function: Int => B): IndexedSeq[B] = (0 until N).map(function)\n }\n\n def calc(input: (Long, Long, Long, Long, Long, Long)): Long = {\n input match {\n case (a, b, c, x, y, z) =>\n var ans: Long = Long.MaxValue\n if (b >= 3 && (a >= 2 || c >= 2)) {\n ans = Math.min(ans, Math.max(a - (b - 1), 0) * x + Math.max(c - Math.min(a - 1, b - 2), 0) * z)\n ans = Math.min(ans, Math.max(a - Math.min(c - 1, b - 2), 0) * x + Math.max(c - (b - 1), 0) * z)\n }\n // println(ans)\n if (b >= 2 && (a >= b && c >= b + 1)) {\n ans = Math.min(ans, y + Math.max(0, a - (c - 1)) * x)\n }\n // println(ans)\n if (b >= 2 && (a >= b + 1 && c >= b)) {\n ans = Math.min(ans, y + Math.max(0, c - (a - 1)) * z)\n }\n // println(ans)\n if (a >= 2 && c >= 2)\n if (a != c)\n ans = Math.min(ans, Math.max(0, b - (Math.min(a, c) - 1)) * y)\n else if (a >= 3 && c >= 3)\n ans = Math.min(ans, Math.max(0, b - (Math.min(a, c) - 2)) * y + Math.min(x, z))\n // println(ans)\n if (ans == Long.MaxValue) ans = -1\n ans\n }\n }\n\n def time(s: String): Int =\n s.substring(0, 2).toInt * 60 + s.substring(3, 5).toInt\n\n /*\n def getPermutation(begin: Long = 0): LazyList[Long] =\n LazyList.cons(begin, getPermutation(begin + 1))\n\n def getFibonacci(prevprev: Long = 0, prev: Long = 1): LazyList[Long] =\n LazyList.cons(prevprev, getFibonacci(prev, prevprev + prev))\n\n @scala.annotation.tailrec\n def recursive2(X: Set[Long], Y: LazyList[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n*/\n def check(i: Int, X: String): Long = {\n if (X == \"\") 0 else check(i, X.tail) * i + X.head.toString.toLong\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n @scala.annotation.tailrec\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def primeFactors(i: Long): List[Long] = primeFactors_(i, 1).sorted\n\n\n def primeFactors_(i: Long, j: Long): List[Long] = {\n if (j * j > i) List.empty else if (i % j == 0) primeFactors_(i, j + 1) ++ List[Long](j, i / j) else primeFactors_(i, j + 1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\n/*\nobject Util {\n def getPermutation(begin: Long = 0): LazyList[Long] =\n LazyList.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: LazyList[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: LazyList[Long]): LazyList[Long] =\n LazyList.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): LazyList[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\n */\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n private val codeTable: List[(Int, String)] = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n @scala.annotation.tailrec\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n @scala.annotation.tailrec\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n}\n\nobject PowMod {\n def naivePowMod(a: Long, k: Long, m: Long): Long = {\n var t: Long = 1\n val aMod: Long = a % m\n\n for (_ <- 1L to k) {\n t = ((t % m) * aMod) % m\n }\n t.toInt\n }\n\n def powMod(a: Long, k: Long, m: Long): Long = {\n if (k == 0) 1\n else {\n val t = powMod(a, k / 2, m)\n if ((k % 2) == 0) (t * t) % m else (((t * t) % m) * a) % m\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 8687, "cpu_time_ms": 509, "memory_kb": 54776}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s536472120", "group_id": "codeNet:p02695", "input_text": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val n, m, q = sc.nextInt()\n val qs = Vector.fill(q)((sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()))\n\n val a = (1 to 4).flatMap(_ => 1 to m).combinations(n)\n\n def f(v: Seq[Int]): Int = {\n qs.map { case (a, b, c, d) =>\n val ba = v(b - 1) - v(a - 1)\n if (ba == c) d else 0\n }.sum\n }\n\n val res = a.map(f)\n println(res.max)\n\n }\n}\n", "language": "Scala", "metadata": {"date": 1589339621, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02695.html", "problem_id": "p02695", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02695/input.txt", "sample_output_relpath": "derived/input_output/data/p02695/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02695/Scala/s536472120.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s536472120", "user_id": "u197909036"}, "prompt_components": {"gold_output": "110\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val n, m, q = sc.nextInt()\n val qs = Vector.fill(q)((sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()))\n\n val a = (1 to 4).flatMap(_ => 1 to m).combinations(n)\n\n def f(v: Seq[Int]): Int = {\n qs.map { case (a, b, c, d) =>\n val ba = v(b - 1) - v(a - 1)\n if (ba == c) d else 0\n }.sum\n }\n\n val res = a.map(f)\n println(res.max)\n\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).\n\nConsider a sequence A satisfying the following conditions:\n\nA is a sequence of N positive integers.\n\n1 \\leq A_1 \\leq A_2 \\le \\cdots \\leq A_N \\leq M.\n\nLet us define a score of this sequence as follows:\n\nThe score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)\n\nFind the maximum possible score of A.\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10\n\n1 \\leq M \\leq 10\n\n1 \\leq Q \\leq 50\n\n1 \\leq a_i < b_i \\leq N ( i = 1, 2, ..., Q )\n\n0 \\leq c_i \\leq M - 1 ( i = 1, 2, ..., Q )\n\n(a_i, b_i, c_i) \\neq (a_j, b_j, c_j) (where i \\neq j)\n\n1 \\leq d_i \\leq 10^5 ( i = 1, 2, ..., Q )\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M Q\na_1 b_1 c_1 d_1\n:\na_Q b_Q c_Q d_Q\n\nOutput\n\nPrint the maximum possible score of A.\n\nSample Input 1\n\n3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n\nSample Output 1\n\n110\n\nWhen A = \\{1, 3, 4\\}, its score is 110. Under these conditions, no sequence has a score greater than 110, so the answer is 110.\n\nSample Input 2\n\n4 6 10\n2 4 1 86568\n1 4 0 90629\n2 3 0 90310\n3 4 1 29211\n3 4 3 78537\n3 4 2 8580\n1 2 1 96263\n1 4 2 2156\n1 2 0 94325\n1 4 3 94328\n\nSample Output 2\n\n357500\n\nSample Input 3\n\n10 10 1\n1 10 9 1\n\nSample Output 3\n\n1", "sample_input": "3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n"}, "reference_outputs": ["110\n"], "source_document_id": "p02695", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).\n\nConsider a sequence A satisfying the following conditions:\n\nA is a sequence of N positive integers.\n\n1 \\leq A_1 \\leq A_2 \\le \\cdots \\leq A_N \\leq M.\n\nLet us define a score of this sequence as follows:\n\nThe score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)\n\nFind the maximum possible score of A.\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10\n\n1 \\leq M \\leq 10\n\n1 \\leq Q \\leq 50\n\n1 \\leq a_i < b_i \\leq N ( i = 1, 2, ..., Q )\n\n0 \\leq c_i \\leq M - 1 ( i = 1, 2, ..., Q )\n\n(a_i, b_i, c_i) \\neq (a_j, b_j, c_j) (where i \\neq j)\n\n1 \\leq d_i \\leq 10^5 ( i = 1, 2, ..., Q )\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M Q\na_1 b_1 c_1 d_1\n:\na_Q b_Q c_Q d_Q\n\nOutput\n\nPrint the maximum possible score of A.\n\nSample Input 1\n\n3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n\nSample Output 1\n\n110\n\nWhen A = \\{1, 3, 4\\}, its score is 110. Under these conditions, no sequence has a score greater than 110, so the answer is 110.\n\nSample Input 2\n\n4 6 10\n2 4 1 86568\n1 4 0 90629\n2 3 0 90310\n3 4 1 29211\n3 4 3 78537\n3 4 2 8580\n1 2 1 96263\n1 4 2 2156\n1 2 0 94325\n1 4 3 94328\n\nSample Output 2\n\n357500\n\nSample Input 3\n\n10 10 1\n1 10 9 1\n\nSample Output 3\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 832, "memory_kb": 57764}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s620545938", "group_id": "codeNet:p02695", "input_text": "import java.util.Scanner\n\nimport scala.collection.mutable\nimport scala.math._\n\nobject Main {\n def main(args: Array[String]): Unit = {\n\n\n\n val sc = new Scanner(System.in)\n val n, m, q = sc.nextInt()\n val qs = Vector.fill(q)((sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()))\n\n val a = (1 to m).combinations(n).map(_.sorted).toSeq\n\n def f(v: Seq[Int]): Int = {\n qs.map { case (a, b, c, d) =>\n if (v(b - 1) - v(a - 1) == c) d else 0\n }.sum\n }\n\n val res = a.map(f)\n println(res.max)\n\n }\n}\n", "language": "Scala", "metadata": {"date": 1589320796, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02695.html", "problem_id": "p02695", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02695/input.txt", "sample_output_relpath": "derived/input_output/data/p02695/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02695/Scala/s620545938.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s620545938", "user_id": "u197909036"}, "prompt_components": {"gold_output": "110\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.collection.mutable\nimport scala.math._\n\nobject Main {\n def main(args: Array[String]): Unit = {\n\n\n\n val sc = new Scanner(System.in)\n val n, m, q = sc.nextInt()\n val qs = Vector.fill(q)((sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()))\n\n val a = (1 to m).combinations(n).map(_.sorted).toSeq\n\n def f(v: Seq[Int]): Int = {\n qs.map { case (a, b, c, d) =>\n if (v(b - 1) - v(a - 1) == c) d else 0\n }.sum\n }\n\n val res = a.map(f)\n println(res.max)\n\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).\n\nConsider a sequence A satisfying the following conditions:\n\nA is a sequence of N positive integers.\n\n1 \\leq A_1 \\leq A_2 \\le \\cdots \\leq A_N \\leq M.\n\nLet us define a score of this sequence as follows:\n\nThe score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)\n\nFind the maximum possible score of A.\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10\n\n1 \\leq M \\leq 10\n\n1 \\leq Q \\leq 50\n\n1 \\leq a_i < b_i \\leq N ( i = 1, 2, ..., Q )\n\n0 \\leq c_i \\leq M - 1 ( i = 1, 2, ..., Q )\n\n(a_i, b_i, c_i) \\neq (a_j, b_j, c_j) (where i \\neq j)\n\n1 \\leq d_i \\leq 10^5 ( i = 1, 2, ..., Q )\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M Q\na_1 b_1 c_1 d_1\n:\na_Q b_Q c_Q d_Q\n\nOutput\n\nPrint the maximum possible score of A.\n\nSample Input 1\n\n3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n\nSample Output 1\n\n110\n\nWhen A = \\{1, 3, 4\\}, its score is 110. Under these conditions, no sequence has a score greater than 110, so the answer is 110.\n\nSample Input 2\n\n4 6 10\n2 4 1 86568\n1 4 0 90629\n2 3 0 90310\n3 4 1 29211\n3 4 3 78537\n3 4 2 8580\n1 2 1 96263\n1 4 2 2156\n1 2 0 94325\n1 4 3 94328\n\nSample Output 2\n\n357500\n\nSample Input 3\n\n10 10 1\n1 10 9 1\n\nSample Output 3\n\n1", "sample_input": "3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n"}, "reference_outputs": ["110\n"], "source_document_id": "p02695", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).\n\nConsider a sequence A satisfying the following conditions:\n\nA is a sequence of N positive integers.\n\n1 \\leq A_1 \\leq A_2 \\le \\cdots \\leq A_N \\leq M.\n\nLet us define a score of this sequence as follows:\n\nThe score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)\n\nFind the maximum possible score of A.\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10\n\n1 \\leq M \\leq 10\n\n1 \\leq Q \\leq 50\n\n1 \\leq a_i < b_i \\leq N ( i = 1, 2, ..., Q )\n\n0 \\leq c_i \\leq M - 1 ( i = 1, 2, ..., Q )\n\n(a_i, b_i, c_i) \\neq (a_j, b_j, c_j) (where i \\neq j)\n\n1 \\leq d_i \\leq 10^5 ( i = 1, 2, ..., Q )\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M Q\na_1 b_1 c_1 d_1\n:\na_Q b_Q c_Q d_Q\n\nOutput\n\nPrint the maximum possible score of A.\n\nSample Input 1\n\n3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n\nSample Output 1\n\n110\n\nWhen A = \\{1, 3, 4\\}, its score is 110. Under these conditions, no sequence has a score greater than 110, so the answer is 110.\n\nSample Input 2\n\n4 6 10\n2 4 1 86568\n1 4 0 90629\n2 3 0 90310\n3 4 1 29211\n3 4 3 78537\n3 4 2 8580\n1 2 1 96263\n1 4 2 2156\n1 2 0 94325\n1 4 3 94328\n\nSample Output 2\n\n357500\n\nSample Input 3\n\n10 10 1\n1 10 9 1\n\nSample Output 3\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 535, "cpu_time_ms": 522, "memory_kb": 55680}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s224614950", "group_id": "codeNet:p02695", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val m = sc.nextInt\n val q = sc.nextInt\n val a = Array.ofDim[Int](q)\n val b = Array.ofDim[Int](q)\n val c = Array.ofDim[Int](q)\n val d = Array.ofDim[Int](q)\n (0 until q).foreach { i =>\n a(i) = sc.nextInt\n b(i) = sc.nextInt\n c(i) = sc.nextInt\n d(i) = sc.nextInt\n }\n\n println(new QC(n, m, q, a, b, c, d).solve)\n }\n}\n\nclass QC(n: Int, m: Int, q: Int, a: Array[Int], b: Array[Int], c: Array[Int], d: Array[Int]) {\n def solve: Int = {\n val array = Array.fill[Int](n)(1)\n var ans = 0\n var break = false\n\n def countup(index: Int, indexUp: Boolean): Unit = {\n if (array(index) < m) {\n val next = array(index) + 1\n if (indexUp) {\n (index until n).foreach(array(_) = next)\n } else {\n array(index) = next\n }\n } else {\n countup(index - 1, true)\n }\n }\n\n while (!break) {\n ans = Math.max(ans, calc(array))\n break = array(0) == m\n if(!break) {\n countup(n - 1, false)\n }\n }\n ans\n }\n\n private def calc(array: Array[Int]) = {\n (0 until q).foldLeft(0) { (acc, cur) =>\n if (array(b(cur) - 1) - array(a(cur) - 1) equals c(cur)) {\n acc + d(cur)\n } else {\n acc\n }\n }\n }\n}", "language": "Scala", "metadata": {"date": 1588691154, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02695.html", "problem_id": "p02695", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02695/input.txt", "sample_output_relpath": "derived/input_output/data/p02695/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02695/Scala/s224614950.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s224614950", "user_id": "u291133005"}, "prompt_components": {"gold_output": "110\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val m = sc.nextInt\n val q = sc.nextInt\n val a = Array.ofDim[Int](q)\n val b = Array.ofDim[Int](q)\n val c = Array.ofDim[Int](q)\n val d = Array.ofDim[Int](q)\n (0 until q).foreach { i =>\n a(i) = sc.nextInt\n b(i) = sc.nextInt\n c(i) = sc.nextInt\n d(i) = sc.nextInt\n }\n\n println(new QC(n, m, q, a, b, c, d).solve)\n }\n}\n\nclass QC(n: Int, m: Int, q: Int, a: Array[Int], b: Array[Int], c: Array[Int], d: Array[Int]) {\n def solve: Int = {\n val array = Array.fill[Int](n)(1)\n var ans = 0\n var break = false\n\n def countup(index: Int, indexUp: Boolean): Unit = {\n if (array(index) < m) {\n val next = array(index) + 1\n if (indexUp) {\n (index until n).foreach(array(_) = next)\n } else {\n array(index) = next\n }\n } else {\n countup(index - 1, true)\n }\n }\n\n while (!break) {\n ans = Math.max(ans, calc(array))\n break = array(0) == m\n if(!break) {\n countup(n - 1, false)\n }\n }\n ans\n }\n\n private def calc(array: Array[Int]) = {\n (0 until q).foldLeft(0) { (acc, cur) =>\n if (array(b(cur) - 1) - array(a(cur) - 1) equals c(cur)) {\n acc + d(cur)\n } else {\n acc\n }\n }\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).\n\nConsider a sequence A satisfying the following conditions:\n\nA is a sequence of N positive integers.\n\n1 \\leq A_1 \\leq A_2 \\le \\cdots \\leq A_N \\leq M.\n\nLet us define a score of this sequence as follows:\n\nThe score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)\n\nFind the maximum possible score of A.\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10\n\n1 \\leq M \\leq 10\n\n1 \\leq Q \\leq 50\n\n1 \\leq a_i < b_i \\leq N ( i = 1, 2, ..., Q )\n\n0 \\leq c_i \\leq M - 1 ( i = 1, 2, ..., Q )\n\n(a_i, b_i, c_i) \\neq (a_j, b_j, c_j) (where i \\neq j)\n\n1 \\leq d_i \\leq 10^5 ( i = 1, 2, ..., Q )\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M Q\na_1 b_1 c_1 d_1\n:\na_Q b_Q c_Q d_Q\n\nOutput\n\nPrint the maximum possible score of A.\n\nSample Input 1\n\n3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n\nSample Output 1\n\n110\n\nWhen A = \\{1, 3, 4\\}, its score is 110. Under these conditions, no sequence has a score greater than 110, so the answer is 110.\n\nSample Input 2\n\n4 6 10\n2 4 1 86568\n1 4 0 90629\n2 3 0 90310\n3 4 1 29211\n3 4 3 78537\n3 4 2 8580\n1 2 1 96263\n1 4 2 2156\n1 2 0 94325\n1 4 3 94328\n\nSample Output 2\n\n357500\n\nSample Input 3\n\n10 10 1\n1 10 9 1\n\nSample Output 3\n\n1", "sample_input": "3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n"}, "reference_outputs": ["110\n"], "source_document_id": "p02695", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).\n\nConsider a sequence A satisfying the following conditions:\n\nA is a sequence of N positive integers.\n\n1 \\leq A_1 \\leq A_2 \\le \\cdots \\leq A_N \\leq M.\n\nLet us define a score of this sequence as follows:\n\nThe score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)\n\nFind the maximum possible score of A.\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10\n\n1 \\leq M \\leq 10\n\n1 \\leq Q \\leq 50\n\n1 \\leq a_i < b_i \\leq N ( i = 1, 2, ..., Q )\n\n0 \\leq c_i \\leq M - 1 ( i = 1, 2, ..., Q )\n\n(a_i, b_i, c_i) \\neq (a_j, b_j, c_j) (where i \\neq j)\n\n1 \\leq d_i \\leq 10^5 ( i = 1, 2, ..., Q )\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M Q\na_1 b_1 c_1 d_1\n:\na_Q b_Q c_Q d_Q\n\nOutput\n\nPrint the maximum possible score of A.\n\nSample Input 1\n\n3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n\nSample Output 1\n\n110\n\nWhen A = \\{1, 3, 4\\}, its score is 110. Under these conditions, no sequence has a score greater than 110, so the answer is 110.\n\nSample Input 2\n\n4 6 10\n2 4 1 86568\n1 4 0 90629\n2 3 0 90310\n3 4 1 29211\n3 4 3 78537\n3 4 2 8580\n1 2 1 96263\n1 4 2 2156\n1 2 0 94325\n1 4 3 94328\n\nSample Output 2\n\n357500\n\nSample Input 3\n\n10 10 1\n1 10 9 1\n\nSample Output 3\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1378, "cpu_time_ms": 624, "memory_kb": 57260}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s994438044", "group_id": "codeNet:p02695", "input_text": "import scala.util.control.Breaks\n\nobject Main extends App {\n val nmq = scala.io.StdIn.readLine()\n val nmqArray = nmq.split(\" \").map(_.toInt).toSeq\n val n = nmqArray(0)\n val m = nmqArray(1)\n val q = nmqArray(2)\n\n var abcdVector = Vector.empty[Vector[Int]]\n (1 to q).foreach { _ =>\n val a = scala.io.StdIn.readLine()\n abcdVector :+= a.split(\" \").map(_.toInt).toVector\n }\n val max = abcdVector.map(a => a(3)).sum\n var tempMax = 0\n\n def getInitialAArray(): scala.collection.mutable.Seq[Int] = {\n var returnSeq = scala.collection.mutable.Seq.empty[Int]\n (1 to n).foreach { _=>\n returnSeq :+= 1\n }\n returnSeq\n }\n var aSeq = getInitialAArray()\n\n val break = new Breaks\n break.breakable {\n (0 to n - 1).foreach { i =>\n kensyou(i)\n }\n\n def kensyou(index: Int): Unit = {\n if(index == 0) {\n (1 to m).foreach { i =>\n aSeq(n - 1) = i\n calc(aSeq)\n }\n } else {\n (1 to m).foreach { i =>\n aSeq(n - 1 - index) = i\n kensyou(index - 1)\n }\n }\n }\n\n def calc(kensyouArray: scala.collection.mutable.Seq[Int]) = {\n var tempCalc = 0\n abcdVector.foreach { abcd =>\n if (kensyouArray(abcd(1) - 1) - kensyouArray(abcd(0) - 1) == abcd(2)) {\n tempCalc = tempCalc + abcd(3)\n }\n }\n\n if(tempCalc == max) {\n tempMax = tempCalc\n break.break()\n } else if(tempCalc > tempMax) {\n tempMax = tempCalc\n }\n }\n }\n\n println(tempMax)\n}\n", "language": "Scala", "metadata": {"date": 1588473368, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02695.html", "problem_id": "p02695", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02695/input.txt", "sample_output_relpath": "derived/input_output/data/p02695/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02695/Scala/s994438044.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s994438044", "user_id": "u105921924"}, "prompt_components": {"gold_output": "110\n", "input_to_evaluate": "import scala.util.control.Breaks\n\nobject Main extends App {\n val nmq = scala.io.StdIn.readLine()\n val nmqArray = nmq.split(\" \").map(_.toInt).toSeq\n val n = nmqArray(0)\n val m = nmqArray(1)\n val q = nmqArray(2)\n\n var abcdVector = Vector.empty[Vector[Int]]\n (1 to q).foreach { _ =>\n val a = scala.io.StdIn.readLine()\n abcdVector :+= a.split(\" \").map(_.toInt).toVector\n }\n val max = abcdVector.map(a => a(3)).sum\n var tempMax = 0\n\n def getInitialAArray(): scala.collection.mutable.Seq[Int] = {\n var returnSeq = scala.collection.mutable.Seq.empty[Int]\n (1 to n).foreach { _=>\n returnSeq :+= 1\n }\n returnSeq\n }\n var aSeq = getInitialAArray()\n\n val break = new Breaks\n break.breakable {\n (0 to n - 1).foreach { i =>\n kensyou(i)\n }\n\n def kensyou(index: Int): Unit = {\n if(index == 0) {\n (1 to m).foreach { i =>\n aSeq(n - 1) = i\n calc(aSeq)\n }\n } else {\n (1 to m).foreach { i =>\n aSeq(n - 1 - index) = i\n kensyou(index - 1)\n }\n }\n }\n\n def calc(kensyouArray: scala.collection.mutable.Seq[Int]) = {\n var tempCalc = 0\n abcdVector.foreach { abcd =>\n if (kensyouArray(abcd(1) - 1) - kensyouArray(abcd(0) - 1) == abcd(2)) {\n tempCalc = tempCalc + abcd(3)\n }\n }\n\n if(tempCalc == max) {\n tempMax = tempCalc\n break.break()\n } else if(tempCalc > tempMax) {\n tempMax = tempCalc\n }\n }\n }\n\n println(tempMax)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).\n\nConsider a sequence A satisfying the following conditions:\n\nA is a sequence of N positive integers.\n\n1 \\leq A_1 \\leq A_2 \\le \\cdots \\leq A_N \\leq M.\n\nLet us define a score of this sequence as follows:\n\nThe score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)\n\nFind the maximum possible score of A.\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10\n\n1 \\leq M \\leq 10\n\n1 \\leq Q \\leq 50\n\n1 \\leq a_i < b_i \\leq N ( i = 1, 2, ..., Q )\n\n0 \\leq c_i \\leq M - 1 ( i = 1, 2, ..., Q )\n\n(a_i, b_i, c_i) \\neq (a_j, b_j, c_j) (where i \\neq j)\n\n1 \\leq d_i \\leq 10^5 ( i = 1, 2, ..., Q )\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M Q\na_1 b_1 c_1 d_1\n:\na_Q b_Q c_Q d_Q\n\nOutput\n\nPrint the maximum possible score of A.\n\nSample Input 1\n\n3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n\nSample Output 1\n\n110\n\nWhen A = \\{1, 3, 4\\}, its score is 110. Under these conditions, no sequence has a score greater than 110, so the answer is 110.\n\nSample Input 2\n\n4 6 10\n2 4 1 86568\n1 4 0 90629\n2 3 0 90310\n3 4 1 29211\n3 4 3 78537\n3 4 2 8580\n1 2 1 96263\n1 4 2 2156\n1 2 0 94325\n1 4 3 94328\n\nSample Output 2\n\n357500\n\nSample Input 3\n\n10 10 1\n1 10 9 1\n\nSample Output 3\n\n1", "sample_input": "3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n"}, "reference_outputs": ["110\n"], "source_document_id": "p02695", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).\n\nConsider a sequence A satisfying the following conditions:\n\nA is a sequence of N positive integers.\n\n1 \\leq A_1 \\leq A_2 \\le \\cdots \\leq A_N \\leq M.\n\nLet us define a score of this sequence as follows:\n\nThe score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)\n\nFind the maximum possible score of A.\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10\n\n1 \\leq M \\leq 10\n\n1 \\leq Q \\leq 50\n\n1 \\leq a_i < b_i \\leq N ( i = 1, 2, ..., Q )\n\n0 \\leq c_i \\leq M - 1 ( i = 1, 2, ..., Q )\n\n(a_i, b_i, c_i) \\neq (a_j, b_j, c_j) (where i \\neq j)\n\n1 \\leq d_i \\leq 10^5 ( i = 1, 2, ..., Q )\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M Q\na_1 b_1 c_1 d_1\n:\na_Q b_Q c_Q d_Q\n\nOutput\n\nPrint the maximum possible score of A.\n\nSample Input 1\n\n3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n\nSample Output 1\n\n110\n\nWhen A = \\{1, 3, 4\\}, its score is 110. Under these conditions, no sequence has a score greater than 110, so the answer is 110.\n\nSample Input 2\n\n4 6 10\n2 4 1 86568\n1 4 0 90629\n2 3 0 90310\n3 4 1 29211\n3 4 3 78537\n3 4 2 8580\n1 2 1 96263\n1 4 2 2156\n1 2 0 94325\n1 4 3 94328\n\nSample Output 2\n\n357500\n\nSample Input 3\n\n10 10 1\n1 10 9 1\n\nSample Output 3\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1507, "cpu_time_ms": 2206, "memory_kb": 60892}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s708816667", "group_id": "codeNet:p02707", "input_text": "import java.util.Scanner\n\nimport scala.io.StdIn._\n\nobject Main extends App {\n\n val n = readInt()\n val A = readLine().split(\" \").map(_.toInt)\n\n def solve() = {\n val arr = Array.fill(n)(0)\n A.foreach { i =>\n arr(i-1) += 1\n }\n arr.mkString(\"\\n\")\n }\n\n\n println(solve())\n\n}\n\n", "language": "Scala", "metadata": {"date": 1594180335, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s708816667.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s708816667", "user_id": "u947008426"}, "prompt_components": {"gold_output": "2\n2\n0\n0\n0\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.io.StdIn._\n\nobject Main extends App {\n\n val n = readInt()\n val A = readLine().split(\" \").map(_.toInt)\n\n def solve() = {\n val arr = Array.fill(n)(0)\n A.foreach { i =>\n arr(i-1) += 1\n }\n arr.mkString(\"\\n\")\n }\n\n\n println(solve())\n\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 726, "memory_kb": 78136}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s048079679", "group_id": "codeNet:p02712", "input_text": "import java.util.Scanner\n\nobject Main {\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val a = sc.nextInt //最初の整数が読み込まれる\n \n var b = 0\n \n (1 to a).foreach{j =>\n j match{\n \tcase j if j%15 == 0 => b = b\n case j if j%3 == 0 => b = b\n case j if j%5 == 0 => b = b\n case _ => b = b + j\n }\n }\n println(b)\n }\n}\n", "language": "Scala", "metadata": {"date": 1587087592, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s048079679.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s048079679", "user_id": "u150828278"}, "prompt_components": {"gold_output": "60\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val a = sc.nextInt //最初の整数が読み込まれる\n \n var b = 0\n \n (1 to a).foreach{j =>\n j match{\n \tcase j if j%15 == 0 => b = b\n case j if j%3 == 0 => b = b\n case j if j%5 == 0 => b = b\n case _ => b = b + j\n }\n }\n println(b)\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 499, "memory_kb": 55356}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s166090142", "group_id": "codeNet:p02712", "input_text": "object Main{\n\tprivate[this] val s = new java.util.Scanner(System.in)\n\tdef main(args:Array[String]) {\n\t\tval n=s.nextInt\n\t\tprintln((1L to n).filter(i => i % 5 != 0 && i % 3 != 0).sum)\n\t}\n}\n", "language": "Scala", "metadata": {"date": 1587003279, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s166090142.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s166090142", "user_id": "u059234158"}, "prompt_components": {"gold_output": "60\n", "input_to_evaluate": "object Main{\n\tprivate[this] val s = new java.util.Scanner(System.in)\n\tdef main(args:Array[String]) {\n\t\tval n=s.nextInt\n\t\tprintln((1L to n).filter(i => i % 5 != 0 && i % 3 != 0).sum)\n\t}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 614, "memory_kb": 73860}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s777347282", "group_id": "codeNet:p02712", "input_text": "import scala.io.StdIn._\nobject Main extends App{\n val N = readLine().toInt\n\n var sum = 0L\n (1 to N).foreach(i =>{\n if(i % 3 == 0 || i % 5 == 0){\n }else{\n sum = sum + i\n }\n })\n println(sum)\n}\n", "language": "Scala", "metadata": {"date": 1586740420, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s777347282.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s777347282", "user_id": "u448589884"}, "prompt_components": {"gold_output": "60\n", "input_to_evaluate": "import scala.io.StdIn._\nobject Main extends App{\n val N = readLine().toInt\n\n var sum = 0L\n (1 to N).foreach(i =>{\n if(i % 3 == 0 || i % 5 == 0){\n }else{\n sum = sum + i\n }\n })\n println(sum)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 541, "memory_kb": 54636}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s139441132", "group_id": "codeNet:p02719", "input_text": "import io.StdIn._\nimport scala.math.pow\n \nobject Main extends App {\n val arr = readLine.split(\" \")\n val n = arr(0).toLong\n val k = arr(1).toLong\n \n require(0 <= n && n <= pow(10, 18))\n require(1 <= k && n <= pow(10, 18))\n \n val a = n % k\n val b = k - a\n \n if (a > b) println(b) else print(a)\n}", "language": "Scala", "metadata": {"date": 1595027187, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s139441132.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s139441132", "user_id": "u878625259"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import io.StdIn._\nimport scala.math.pow\n \nobject Main extends App {\n val arr = readLine.split(\" \")\n val n = arr(0).toLong\n val k = arr(1).toLong\n \n require(0 <= n && n <= pow(10, 18))\n require(1 <= k && n <= pow(10, 18))\n \n val a = n % k\n val b = k - a\n \n if (a > b) println(b) else print(a)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 478, "memory_kb": 54672}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s420331697", "group_id": "codeNet:p02719", "input_text": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val n, k = sc.nextLong()\n println(math.min(n % k, math.abs(n % k - k)))\n }\n}", "language": "Scala", "metadata": {"date": 1586270491, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s420331697.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s420331697", "user_id": "u602865659"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val n, k = sc.nextLong()\n println(math.min(n % k, math.abs(n % k - 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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 340, "memory_kb": 27448}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s642304888", "group_id": "codeNet:p02719", "input_text": "object Main extends App {\n val input = readLine\n val n = input.split(\" \")(0).toLong\n val k = input.split(\" \")(1).toLong\n \n if(n == k) println(0)\n else if(n < k) {\n println(Array(n, (n-k).abs).min)\n } else if(k < n) {\n println(Array(n%k, k-(n%k)).min)\n }\n}", "language": "Scala", "metadata": {"date": 1586216226, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s642304888.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s642304888", "user_id": "u104354966"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main extends App {\n val input = readLine\n val n = input.split(\" \")(0).toLong\n val k = input.split(\" \")(1).toLong\n \n if(n == k) println(0)\n else if(n < k) {\n println(Array(n, (n-k).abs).min)\n } else if(k < n) {\n println(Array(n%k, k-(n%k)).min)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 269, "cpu_time_ms": 321, "memory_kb": 27328}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s848620714", "group_id": "codeNet:p02721", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n import scala.io.StdIn._\n val Array(n, k, c, _*) = readLine().split(' ').map(_.toInt)\n def check(comb: List[Int], pre: Int): Boolean =\n comb match {\n case Nil => true\n case head :: tail =>\n if (head <= pre + c) false\n else check(tail, head)\n }\n val possibleDate = readLine().zipWithIndex.collect {\n case ('o', i) => i + 1\n }\n .combinations(k)\n .collect {\n case comb if check(comb.toList, -c) =>\n comb.toSet\n }\n if (possibleDate.nonEmpty) {\n val dates = possibleDate.reduce(_ intersect _)\n dates.toList.foreach(println)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1586572029, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02721.html", "problem_id": "p02721", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02721/input.txt", "sample_output_relpath": "derived/input_output/data/p02721/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02721/Scala/s848620714.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s848620714", "user_id": "u228033537"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n import scala.io.StdIn._\n val Array(n, k, c, _*) = readLine().split(' ').map(_.toInt)\n def check(comb: List[Int], pre: Int): Boolean =\n comb match {\n case Nil => true\n case head :: tail =>\n if (head <= pre + c) false\n else check(tail, head)\n }\n val possibleDate = readLine().zipWithIndex.collect {\n case ('o', i) => i + 1\n }\n .combinations(k)\n .collect {\n case comb if check(comb.toList, -c) =>\n comb.toSet\n }\n if (possibleDate.nonEmpty) {\n val dates = possibleDate.reduce(_ intersect _)\n dates.toList.foreach(println)\n }\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nTakahashi has decided to work on K days of his choice from the N days starting with tomorrow.\n\nYou are given an integer C and a string S. Takahashi will choose his workdays as follows:\n\nAfter working for a day, he will refrain from working on the subsequent C days.\n\nIf the i-th character of S is x, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on.\n\nFind all days on which Takahashi is bound to work.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq K \\leq N\n\n0 \\leq C \\leq N\n\nThe length of S is N.\n\nEach character of S is o or x.\n\nTakahashi can choose his workdays so that the conditions in Problem Statement are satisfied.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K C\nS\n\nOutput\n\nPrint all days on which Takahashi is bound to work in ascending order, one per line.\n\nSample Input 1\n\n11 3 2\nooxxxoxxxoo\n\nSample Output 1\n\n6\n\nTakahashi is going to work on 3 days out of the 11 days. After working for a day, he will refrain from working on the subsequent 2 days.\n\nThere are four possible choices for his workdays: Day 1,6,10, Day 1,6,11, Day 2,6,10, and Day 2,6,11.\n\nThus, he is bound to work on Day 6.\n\nSample Input 2\n\n5 2 3\nooxoo\n\nSample Output 2\n\n1\n5\n\nThere is only one possible choice for his workdays: Day 1,5.\n\nSample Input 3\n\n5 1 0\nooooo\n\nSample Output 3\n\nThere may be no days on which he is bound to work.\n\nSample Input 4\n\n16 4 3\nooxxoxoxxxoxoxxo\n\nSample Output 4\n\n11\n16", "sample_input": "11 3 2\nooxxxoxxxoo\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02721", "source_text": "Score : 500 points\n\nProblem Statement\n\nTakahashi has decided to work on K days of his choice from the N days starting with tomorrow.\n\nYou are given an integer C and a string S. Takahashi will choose his workdays as follows:\n\nAfter working for a day, he will refrain from working on the subsequent C days.\n\nIf the i-th character of S is x, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on.\n\nFind all days on which Takahashi is bound to work.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq K \\leq N\n\n0 \\leq C \\leq N\n\nThe length of S is N.\n\nEach character of S is o or x.\n\nTakahashi can choose his workdays so that the conditions in Problem Statement are satisfied.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K C\nS\n\nOutput\n\nPrint all days on which Takahashi is bound to work in ascending order, one per line.\n\nSample Input 1\n\n11 3 2\nooxxxoxxxoo\n\nSample Output 1\n\n6\n\nTakahashi is going to work on 3 days out of the 11 days. After working for a day, he will refrain from working on the subsequent 2 days.\n\nThere are four possible choices for his workdays: Day 1,6,10, Day 1,6,11, Day 2,6,10, and Day 2,6,11.\n\nThus, he is bound to work on Day 6.\n\nSample Input 2\n\n5 2 3\nooxoo\n\nSample Output 2\n\n1\n5\n\nThere is only one possible choice for his workdays: Day 1,5.\n\nSample Input 3\n\n5 1 0\nooooo\n\nSample Output 3\n\nThere may be no days on which he is bound to work.\n\nSample Input 4\n\n16 4 3\nooxxoxoxxxoxoxxo\n\nSample Output 4\n\n11\n16", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 143048}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s534639861", "group_id": "codeNet:p02723", "input_text": "object Main extends App{\n val sc=new java.util.Scanner(System.in)\n val s=sc.next\n val res=if(s(2)==s(3)&&s(4)==s(5))\"Yes\" else \"No\"\n println(res)\n}", "language": "Scala", "metadata": {"date": 1585443693, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02723.html", "problem_id": "p02723", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02723/input.txt", "sample_output_relpath": "derived/input_output/data/p02723/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02723/Scala/s534639861.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s534639861", "user_id": "u928905735"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App{\n val sc=new java.util.Scanner(System.in)\n val s=sc.next\n val res=if(s(2)==s(3)&&s(4)==s(5))\"Yes\" else \"No\"\n println(res)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal.\n\nGiven a string S, determine whether it is coffee-like.\n\nConstraints\n\nS is a string of length 6 consisting 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 coffee-like, print Yes; otherwise, print No.\n\nSample Input 1\n\nsippuu\n\nSample Output 1\n\nYes\n\nIn sippuu, the 3-rd and 4-th characters are equal, and the 5-th and 6-th characters are also equal.\n\nSample Input 2\n\niphone\n\nSample Output 2\n\nNo\n\nSample Input 3\n\ncoffee\n\nSample Output 3\n\nYes", "sample_input": "sippuu\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02723", "source_text": "Score : 100 points\n\nProblem Statement\n\nA string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal.\n\nGiven a string S, determine whether it is coffee-like.\n\nConstraints\n\nS is a string of length 6 consisting 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 coffee-like, print Yes; otherwise, print No.\n\nSample Input 1\n\nsippuu\n\nSample Output 1\n\nYes\n\nIn sippuu, the 3-rd and 4-th characters are equal, and the 5-th and 6-th characters are also equal.\n\nSample Input 2\n\niphone\n\nSample Output 2\n\nNo\n\nSample Input 3\n\ncoffee\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 348, "memory_kb": 27224}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s276472578", "group_id": "codeNet:p02725", "input_text": "object Main extends App {\n import scala.io.StdIn.readLine\n \n \tval k = readLine.split(\" \").head.toInt;\n \tval homes =readLine.split(\" \").map(_.toInt).toList;\n \tprintln((k - (homes zip (homes.tail :+ homes.head)).map{case (x, y) => scala.math.abs(y - x)}.max).toString)\n}", "language": "Scala", "metadata": {"date": 1595129081, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s276472578.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s276472578", "user_id": "u189998431"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "object Main extends App {\n import scala.io.StdIn.readLine\n \n \tval k = readLine.split(\" \").head.toInt;\n \tval homes =readLine.split(\" \").map(_.toInt).toList;\n \tprintln((k - (homes zip (homes.tail :+ homes.head)).map{case (x, y) => scala.math.abs(y - x)}.max).toString)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 839, "memory_kb": 81152}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s969504347", "group_id": "codeNet:p02725", "input_text": "import scala.io.StdIn._\n\nobject Main extends App {\n\n val Array(k, n) = readLine.split(\" \").map(_.toInt)\n\n val points = readLine.split(\" \").map(_.toInt)\n\n val distances = points.zipWithIndex.map { case (pos, idx) =>\n if (idx == 0) (k - points(points.length - 1)) + pos\n else pos - points(idx - 1)\n }\n\n val maxDis = distances.zipWithIndex.maxBy { case (dis, _) => dis }._1\n\n println(k - maxDis)\n}\n\n", "language": "Scala", "metadata": {"date": 1585444409, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s969504347.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s969504347", "user_id": "u611263604"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main extends App {\n\n val Array(k, n) = readLine.split(\" \").map(_.toInt)\n\n val points = readLine.split(\" \").map(_.toInt)\n\n val distances = points.zipWithIndex.map { case (pos, idx) =>\n if (idx == 0) (k - points(points.length - 1)) + pos\n else pos - points(idx - 1)\n }\n\n val maxDis = distances.zipWithIndex.maxBy { case (dis, _) => dis }._1\n\n println(k - maxDis)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 412, "cpu_time_ms": 698, "memory_kb": 60764}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s823631215", "group_id": "codeNet:p02729", "input_text": "\nobject Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n, m = sc.nextInt\n\n println(n * (n - 1) / 2 + m * (m - 1) / 2)\n}\n", "language": "Scala", "metadata": {"date": 1588089367, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s823631215.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s823631215", "user_id": "u002625175"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "\nobject Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n, m = sc.nextInt\n\n println(n * (n - 1) / 2 + m * (m - 1) / 2)\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 335, "memory_kb": 27060}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s772574341", "group_id": "codeNet:p02730", "input_text": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val in = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n val s = in.readLine()\n\n def isPalindrome(s: String): Boolean = {\n s == s.reverse\n }\n\n out.println({\n if (isPalindrome(s) &&\n isPalindrome(s.substring(0, (s.length - 1) / 2)) &&\n isPalindrome(s.substring((s.length + 3) / 2 - 1))) {\n \"Yes\"\n } else {\n \"No\"\n }\n })\n\n out.flush()\n }\n}\n", "language": "Scala", "metadata": {"date": 1584926191, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s772574341.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s772574341", "user_id": "u178269371"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val in = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n val s = in.readLine()\n\n def isPalindrome(s: String): Boolean = {\n s == s.reverse\n }\n\n out.println({\n if (isPalindrome(s) &&\n isPalindrome(s.substring(0, (s.length - 1) / 2)) &&\n isPalindrome(s.substring((s.length + 3) / 2 - 1))) {\n \"Yes\"\n } else {\n \"No\"\n }\n })\n\n out.flush()\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 625, "cpu_time_ms": 331, "memory_kb": 27212}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s360799801", "group_id": "codeNet:p02732", "input_text": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val N = in.nextInt\n val counts = Array.fill(N + 1)(0L)\n val As = Array.fill(N)(in.nextInt)\n As.foreach(a => counts(a) += 1)\n val pairs = counts.map(c => c * (c - 1) / 2)\n val sum = pairs.sum\n val results = counts.map(c => sum - c * (c - 1) / 2 + (if (c > 0) (c - 1) * (c - 2) / 2 else 0))\n println(As.map(a => results(a)).mkString(\"\\n\"))\n}", "language": "Scala", "metadata": {"date": 1585343835, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s360799801.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s360799801", "user_id": "u132324749"}, "prompt_components": {"gold_output": "2\n2\n3\n2\n3\n", "input_to_evaluate": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val N = in.nextInt\n val counts = Array.fill(N + 1)(0L)\n val As = Array.fill(N)(in.nextInt)\n As.foreach(a => counts(a) += 1)\n val pairs = counts.map(c => c * (c - 1) / 2)\n val sum = pairs.sum\n val results = counts.map(c => sum - c * (c - 1) / 2 + (if (c > 0) (c - 1) * (c - 2) / 2 else 0))\n println(As.map(a => results(a)).mkString(\"\\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1019, "memory_kb": 97504}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s634838792", "group_id": "codeNet:p02732", "input_text": "object Main extends App {\n\tval pw = new java.io.PrintWriter(System.out)\n\n\t@scala.annotation.tailrec\n\tdef loop(start: Int, end: Int)(f: Int => Unit): Unit =\n\t\tif (start <= end) {\n\t\t\tf(start)\n\t\t\tloop(start + 1, end)(f)\n\t\t}\n\n\tval n = Scanner.nextInt()\n\tval a = Array.fill(n)(Scanner.nextInt() - 1)\n\t\n\tval m = Array.fill(n)(0)\n\tloop(0, n-1) { i => m(a(i)) += 1 }\n\t\n\tval ans = m.map(e => e * (e-1) / 2).sum\n\t\n\tloop(0, n-1) { i => pw.println(ans - m(a(i)) + 1) }\n\n\tpw.flush()\n}\n\nobject Scanner {\n\tprivate val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0\n\n\t@inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126\n\t@inline private def hasNextByte(): Boolean = if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else true\n\t@inline private def hasNext(): Boolean = {\n\t\twhile (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1\n\t\thasNextByte()\n\t}\n\t@inline private def readByte(): Byte = if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else -1\n\n\tdef next(): String = {\n\t\tif(!hasNext()) ???\n\t\tval sb = new StringBuilder; var b = readByte()\n\t\twhile (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }\n\t\tsb.toString\n\t}\n\n\tdef nextInt(): Int = {\n\t\tval n = nextLong()\n\t\tif (n < Int.MinValue || Int.MaxValue < n) ???\n\t\tn.toInt\n\t}\n\n\tdef nextLong(): Long = {\n\t\tif(!hasNext()) ???\n\t\tvar minus = false; var b = readByte()\n\t\tif (b == '-') { minus = true; b = readByte() }\n\n\t\t@scala.annotation.tailrec\n\t\tdef go (b: Byte, n: Long = 0): Long = if ('0' <= b && b <= '9') go(readByte(), n * 10 + b - '0') else if (minus) -n else n\n\n\t\tgo(b)\n\t}\n\n\tdef nextDouble(): Double = next().toDouble\n}\n", "language": "Scala", "metadata": {"date": 1584931518, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s634838792.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s634838792", "user_id": "u822029894"}, "prompt_components": {"gold_output": "2\n2\n3\n2\n3\n", "input_to_evaluate": "object Main extends App {\n\tval pw = new java.io.PrintWriter(System.out)\n\n\t@scala.annotation.tailrec\n\tdef loop(start: Int, end: Int)(f: Int => Unit): Unit =\n\t\tif (start <= end) {\n\t\t\tf(start)\n\t\t\tloop(start + 1, end)(f)\n\t\t}\n\n\tval n = Scanner.nextInt()\n\tval a = Array.fill(n)(Scanner.nextInt() - 1)\n\t\n\tval m = Array.fill(n)(0)\n\tloop(0, n-1) { i => m(a(i)) += 1 }\n\t\n\tval ans = m.map(e => e * (e-1) / 2).sum\n\t\n\tloop(0, n-1) { i => pw.println(ans - m(a(i)) + 1) }\n\n\tpw.flush()\n}\n\nobject Scanner {\n\tprivate val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0\n\n\t@inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126\n\t@inline private def hasNextByte(): Boolean = if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else true\n\t@inline private def hasNext(): Boolean = {\n\t\twhile (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1\n\t\thasNextByte()\n\t}\n\t@inline private def readByte(): Byte = if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else -1\n\n\tdef next(): String = {\n\t\tif(!hasNext()) ???\n\t\tval sb = new StringBuilder; var b = readByte()\n\t\twhile (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }\n\t\tsb.toString\n\t}\n\n\tdef nextInt(): Int = {\n\t\tval n = nextLong()\n\t\tif (n < Int.MinValue || Int.MaxValue < n) ???\n\t\tn.toInt\n\t}\n\n\tdef nextLong(): Long = {\n\t\tif(!hasNext()) ???\n\t\tvar minus = false; var b = readByte()\n\t\tif (b == '-') { minus = true; b = readByte() }\n\n\t\t@scala.annotation.tailrec\n\t\tdef go (b: Byte, n: Long = 0): Long = if ('0' <= b && b <= '9') go(readByte(), n * 10 + b - '0') else if (minus) -n else n\n\n\t\tgo(b)\n\t}\n\n\tdef nextDouble(): Double = next().toDouble\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1639, "cpu_time_ms": 557, "memory_kb": 41764}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s974428651", "group_id": "codeNet:p02742", "input_text": "import scala.math.round\n\nobject Main extends App {\n \n val sc = new java.util.Scanner(System.in)\n val H = sc.nextLong()\n val W = sc.nextLong()\n\n println(round(H * W / 2))\n \n}", "language": "Scala", "metadata": {"date": 1597801191, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s974428651.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s974428651", "user_id": "u396472025"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import scala.math.round\n\nobject Main extends App {\n \n val sc = new java.util.Scanner(System.in)\n val H = sc.nextLong()\n val W = sc.nextLong()\n\n println(round(H * W / 2))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 504, "memory_kb": 55268}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s758611617", "group_id": "codeNet:p02742", "input_text": "object Main {\n import java.io.{BufferedReader, InputStream, InputStreamReader}\n import java.util.StringTokenizer\n import scala.reflect.ClassTag\n\n def main(args: Array[String]): Unit = {\n val out = new java.io.PrintWriter(System.out)\n new Main(out, new InputReader(System.in)).solve()\n out.flush()\n }\n\n private[this] val oj = System.getenv(\"MY_DEBUG\") == null\n def DEBUG(f: => Unit): Unit = {\n if (!oj){ f }\n }\n def debug(as: Array[Boolean]): Unit = if (!oj){ debug(as.map(x => if(x) \"1\" else \"0\").mkString) }\n def debug(as: Array[Int]): Unit = if (!oj){ debug(as.mkString(\" \")) }\n def debug(as: Array[Long]): Unit =if (!oj){ debug(as.mkString(\" \")) }\n def debugDim(m: Array[Array[Int]]): Unit = if (!oj){\n REP(m.length) { i =>\n debug(m(i))\n }\n }\n def debugDimFlip(m: Array[Array[Long]]): Unit = if (!oj){\n REP(m(0).length) { j =>\n REP(m.length) { i =>\n System.err.print(m(i)(j))\n System.err.print(\" \")\n }\n System.err.println()\n }\n }\n def debug(s: => String): Unit = {\n if (!oj){ System.err.println(s) }\n }\n def isDebug[A](debug: => A, online: => A): A = {\n if (oj) online else debug\n }\n\n class InputReader(val stream: InputStream) {\n private[this] val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private[this] var tokenizer: StringTokenizer = _\n\n private[this] def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = Integer.parseInt(next())\n def nextLong(): Long = java.lang.Long.parseLong(next())\n def nextChar(): Char = next().charAt(0)\n\n def ni(): Int = nextInt()\n def nl(): Long = nextLong()\n def nc(): Char = nextChar()\n def ns(): String = next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n }\n\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n def TO(from: Int, to: Int)(f: Int => Unit): Unit = {\n REP(to - from + 1, from)(f)\n }\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n def cumSum(as: Array[Int]): Array[Long] = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n\nobject Workspace {\n import Main._\n import java.util.Arrays.sort\n\n import scala.collection.mutable\n import math.{abs, max, min}\n import mutable.ArrayBuffer\n}\n\nclass Main(out: java.io.PrintWriter, sc: Main.InputReader) {\n import sc._\n import Main._\n import java.util.Arrays.sort\n\n import scala.collection.mutable\n import math.{abs, max, min}\n import mutable.ArrayBuffer\n import Workspace._\n\n // toIntとか+7とかするならvalにしろ\n final private[this] val MOD = 1000000007\n\n def solve(): Unit = {\n val H, W = nl()\n if (H == 1 || W == 1) out.println(1)\n else {\n val ans = if (H * W % 2 == 1) H * W / 2 + 1 else H * W / 2\n out.println(ans)\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1584240174, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s758611617.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s758611617", "user_id": "u460609472"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "object Main {\n import java.io.{BufferedReader, InputStream, InputStreamReader}\n import java.util.StringTokenizer\n import scala.reflect.ClassTag\n\n def main(args: Array[String]): Unit = {\n val out = new java.io.PrintWriter(System.out)\n new Main(out, new InputReader(System.in)).solve()\n out.flush()\n }\n\n private[this] val oj = System.getenv(\"MY_DEBUG\") == null\n def DEBUG(f: => Unit): Unit = {\n if (!oj){ f }\n }\n def debug(as: Array[Boolean]): Unit = if (!oj){ debug(as.map(x => if(x) \"1\" else \"0\").mkString) }\n def debug(as: Array[Int]): Unit = if (!oj){ debug(as.mkString(\" \")) }\n def debug(as: Array[Long]): Unit =if (!oj){ debug(as.mkString(\" \")) }\n def debugDim(m: Array[Array[Int]]): Unit = if (!oj){\n REP(m.length) { i =>\n debug(m(i))\n }\n }\n def debugDimFlip(m: Array[Array[Long]]): Unit = if (!oj){\n REP(m(0).length) { j =>\n REP(m.length) { i =>\n System.err.print(m(i)(j))\n System.err.print(\" \")\n }\n System.err.println()\n }\n }\n def debug(s: => String): Unit = {\n if (!oj){ System.err.println(s) }\n }\n def isDebug[A](debug: => A, online: => A): A = {\n if (oj) online else debug\n }\n\n class InputReader(val stream: InputStream) {\n private[this] val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private[this] var tokenizer: StringTokenizer = _\n\n private[this] def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = Integer.parseInt(next())\n def nextLong(): Long = java.lang.Long.parseLong(next())\n def nextChar(): Char = next().charAt(0)\n\n def ni(): Int = nextInt()\n def nl(): Long = nextLong()\n def nc(): Char = nextChar()\n def ns(): String = next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n }\n\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n def TO(from: Int, to: Int)(f: Int => Unit): Unit = {\n REP(to - from + 1, from)(f)\n }\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n def cumSum(as: Array[Int]): Array[Long] = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n\nobject Workspace {\n import Main._\n import java.util.Arrays.sort\n\n import scala.collection.mutable\n import math.{abs, max, min}\n import mutable.ArrayBuffer\n}\n\nclass Main(out: java.io.PrintWriter, sc: Main.InputReader) {\n import sc._\n import Main._\n import java.util.Arrays.sort\n\n import scala.collection.mutable\n import math.{abs, max, min}\n import mutable.ArrayBuffer\n import Workspace._\n\n // toIntとか+7とかするならvalにしろ\n final private[this] val MOD = 1000000007\n\n def solve(): Unit = {\n val H, W = nl()\n if (H == 1 || W == 1) out.println(1)\n else {\n val ans = if (H * W % 2 == 1) H * W / 2 + 1 else H * W / 2\n out.println(ans)\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3988, "cpu_time_ms": 321, "memory_kb": 25516}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s601276856", "group_id": "codeNet:p02747", "input_text": "object Main extends App {\n val in = readLine\n \n val ptn = \"(hi)+\".r\n val t = if( in.matches(\"(hi)+\") ) \"Yes\" else \"No\"\n println(t)\n}", "language": "Scala", "metadata": {"date": 1583724841, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02747.html", "problem_id": "p02747", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02747/input.txt", "sample_output_relpath": "derived/input_output/data/p02747/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02747/Scala/s601276856.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s601276856", "user_id": "u452567689"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n val in = readLine\n \n val ptn = \"(hi)+\".r\n val t = if( in.matches(\"(hi)+\") ) \"Yes\" else \"No\"\n println(t)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA Hitachi string is a concatenation of one or more copies of the string hi.\n\nFor example, hi and hihi are Hitachi strings, while ha and hii are not.\n\nGiven a string S, determine whether S is a Hitachi string.\n\nConstraints\n\nThe length of S is between 1 and 10 (inclusive).\n\nS is a string consisting 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 Hitachi string, print Yes; otherwise, print No.\n\nSample Input 1\n\nhihi\n\nSample Output 1\n\nYes\n\nhihi is the concatenation of two copies of hi, so it is a Hitachi string.\n\nSample Input 2\n\nhi\n\nSample Output 2\n\nYes\n\nSample Input 3\n\nha\n\nSample Output 3\n\nNo", "sample_input": "hihi\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02747", "source_text": "Score : 100 points\n\nProblem Statement\n\nA Hitachi string is a concatenation of one or more copies of the string hi.\n\nFor example, hi and hihi are Hitachi strings, while ha and hii are not.\n\nGiven a string S, determine whether S is a Hitachi string.\n\nConstraints\n\nThe length of S is between 1 and 10 (inclusive).\n\nS is a string consisting 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 Hitachi string, print Yes; otherwise, print No.\n\nSample Input 1\n\nhihi\n\nSample Output 1\n\nYes\n\nhihi is the concatenation of two copies of hi, so it is a Hitachi string.\n\nSample Input 2\n\nhi\n\nSample Output 2\n\nYes\n\nSample Input 3\n\nha\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 323, "memory_kb": 27336}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s198808141", "group_id": "codeNet:p02748", "input_text": "object Main extends App{\n import scala.io.StdIn.readLine\n import scala.io.StdIn.readInt\n \n val m = readLine.split(\" \")(2).toInt\n val a = readLine.split(\" \").map(_.toInt)\n val b = readLine.split(\" \").map(_.toInt)\n \n val coupons = (1 to m).map(x => readLine).map(_.split(\" \").map(_.toInt))\n val buys = coupons.map(x => (a(x(0)) + b(x(1)) - x(2)))\n println( ((a.min+b.min) +: buys).min.toString)\n}\n", "language": "Scala", "metadata": {"date": 1596166355, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02748.html", "problem_id": "p02748", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02748/input.txt", "sample_output_relpath": "derived/input_output/data/p02748/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02748/Scala/s198808141.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s198808141", "user_id": "u189998431"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "object Main extends App{\n import scala.io.StdIn.readLine\n import scala.io.StdIn.readInt\n \n val m = readLine.split(\" \")(2).toInt\n val a = readLine.split(\" \").map(_.toInt)\n val b = readLine.split(\" \").map(_.toInt)\n \n val coupons = (1 to m).map(x => readLine).map(_.split(\" \").map(_.toInt))\n val buys = coupons.map(x => (a(x(0)) + b(x(1)) - x(2)))\n println( ((a.min+b.min) +: buys).min.toString)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are visiting a large electronics store to buy a refrigerator and a microwave.\n\nThe store sells A kinds of refrigerators and B kinds of microwaves. The i-th refrigerator ( 1 \\le i \\le A ) is sold at a_i yen (the currency of Japan), and the j-th microwave ( 1 \\le j \\le B ) is sold at b_j yen.\n\nYou have M discount tickets. With the i-th ticket ( 1 \\le i \\le M ), you can get a discount of c_i yen from the total price when buying the x_i-th refrigerator and the y_i-th microwave together. Only one ticket can be used at a time.\n\nYou are planning to buy one refrigerator and one microwave. Find the minimum amount of money required.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\le A \\le 10^5\n\n1 \\le B \\le 10^5\n\n1 \\le M \\le 10^5\n\n1 \\le a_i , b_i , c_i \\le 10^5\n\n1 \\le x_i \\le A\n\n1 \\le y_i \\le B\n\nc_i \\le a_{x_i} + b_{y_i}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B M\na_1 a_2 ... a_A\nb_1 b_2 ... b_B\nx_1 y_1 c_1\n\\vdots\nx_M y_M c_M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2 3 1\n3 3\n3 3 3\n1 2 1\n\nSample Output 1\n\n5\n\nWith the ticket, you can get the 1-st refrigerator and the 2-nd microwave for 3+3-1=5 yen.\n\nSample Input 2\n\n1 1 2\n10\n10\n1 1 5\n1 1 10\n\nSample Output 2\n\n10\n\nNote that you cannot use more than one ticket at a time.\n\nSample Input 3\n\n2 2 1\n3 5\n3 5\n2 2 2\n\nSample Output 3\n\n6\n\nYou can get the 1-st refrigerator and the 1-st microwave for 6 yen, which is the minimum amount to pay in this case.\nNote that using a ticket is optional.", "sample_input": "2 3 1\n3 3\n3 3 3\n1 2 1\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02748", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are visiting a large electronics store to buy a refrigerator and a microwave.\n\nThe store sells A kinds of refrigerators and B kinds of microwaves. The i-th refrigerator ( 1 \\le i \\le A ) is sold at a_i yen (the currency of Japan), and the j-th microwave ( 1 \\le j \\le B ) is sold at b_j yen.\n\nYou have M discount tickets. With the i-th ticket ( 1 \\le i \\le M ), you can get a discount of c_i yen from the total price when buying the x_i-th refrigerator and the y_i-th microwave together. Only one ticket can be used at a time.\n\nYou are planning to buy one refrigerator and one microwave. Find the minimum amount of money required.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\le A \\le 10^5\n\n1 \\le B \\le 10^5\n\n1 \\le M \\le 10^5\n\n1 \\le a_i , b_i , c_i \\le 10^5\n\n1 \\le x_i \\le A\n\n1 \\le y_i \\le B\n\nc_i \\le a_{x_i} + b_{y_i}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B M\na_1 a_2 ... a_A\nb_1 b_2 ... b_B\nx_1 y_1 c_1\n\\vdots\nx_M y_M c_M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2 3 1\n3 3\n3 3 3\n1 2 1\n\nSample Output 1\n\n5\n\nWith the ticket, you can get the 1-st refrigerator and the 2-nd microwave for 3+3-1=5 yen.\n\nSample Input 2\n\n1 1 2\n10\n10\n1 1 5\n1 1 10\n\nSample Output 2\n\n10\n\nNote that you cannot use more than one ticket at a time.\n\nSample Input 3\n\n2 2 1\n3 5\n3 5\n2 2 2\n\nSample Output 3\n\n6\n\nYou can get the 1-st refrigerator and the 1-st microwave for 6 yen, which is the minimum amount to pay in this case.\nNote that using a ticket is optional.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 882, "memory_kb": 79196}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s252814222", "group_id": "codeNet:p02753", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val S = sc.next()\n println(if (S == \"AAA\" || S == \"BBB\") \"No\" else \"Yes\")\n}\n", "language": "Scala", "metadata": {"date": 1596078085, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s252814222.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s252814222", "user_id": "u737111725"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val S = sc.next()\n println(if (S == \"AAA\" || S == \"BBB\") \"No\" else \"Yes\")\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 511, "memory_kb": 55260}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s775516450", "group_id": "codeNet:p02753", "input_text": "object Main extends App {\n val s = io.StdIn.readLine()\n println(if (s.forall(_ == 'A') || s.forall(_ == 'B')) \"No\" else \"Yes\")\n}", "language": "Scala", "metadata": {"date": 1583633174, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s775516450.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s775516450", "user_id": "u269739894"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n val s = io.StdIn.readLine()\n println(if (s.forall(_ == 'A') || s.forall(_ == 'B')) \"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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 130, "cpu_time_ms": 327, "memory_kb": 25540}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s390197448", "group_id": "codeNet:p02754", "input_text": "object Main extends App {\n @scala.annotation.tailrec\n def loop(n: Long, a: Long, b: Long, acc: Long): Long =\n if (n <= 0) acc else if (n < a) acc + n else loop(n - a - b, a, b, acc + a)\n val sc = new java.util.Scanner(System.in)\n val N, A, B = sc.nextLong()\n println(if (A == 0) 0 else loop(N, A, B, 0))\n}\n", "language": "Scala", "metadata": {"date": 1593385437, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s390197448.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s390197448", "user_id": "u737111725"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "object Main extends App {\n @scala.annotation.tailrec\n def loop(n: Long, a: Long, b: Long, acc: Long): Long =\n if (n <= 0) acc else if (n < a) acc + n else loop(n - a - b, a, b, acc + a)\n val sc = new java.util.Scanner(System.in)\n val N, A, B = sc.nextLong()\n println(if (A == 0) 0 else loop(N, A, B, 0))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2205, "memory_kb": 55248}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s073009417", "group_id": "codeNet:p02754", "input_text": "object Main extends App {\n import scala.io.StdIn._\n val Array(n,a,b) = readLine().split(\" \").map(_.toLong)\n println(n / (a+b)*a + Math.min(a, n%(a+b)))\n}", "language": "Scala", "metadata": {"date": 1588085275, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s073009417.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s073009417", "user_id": "u647522078"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "object Main extends App {\n import scala.io.StdIn._\n val Array(n,a,b) = readLine().split(\" \").map(_.toLong)\n println(n / (a+b)*a + Math.min(a, n%(a+b)))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 324, "memory_kb": 25644}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s864706201", "group_id": "codeNet:p02754", "input_text": "object Main extends App{\n import scala.io.StdIn._\n val Array(n,a,b) =readLine().split(\" \").map(_.toInt)\n println(n/(a+b)*a+n%(a+b))\n}\n", "language": "Scala", "metadata": {"date": 1587748791, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s864706201.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s864706201", "user_id": "u759091915"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "object Main extends App{\n import scala.io.StdIn._\n val Array(n,a,b) =readLine().split(\" \").map(_.toInt)\n println(n/(a+b)*a+n%(a+b))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 331, "memory_kb": 27216}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s941923485", "group_id": "codeNet:p02755", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n solve\n }\n\n def solve(): Unit = {\n val sc = new java.util.Scanner(System.in)\n val a, b = sc.nextInt()\n\n var ans = 1\n var flg = false\n while (!flg && ans <= 10000) {\n val taxA = (ans * 0.08).toInt\n val taxB = (ans * 0.1).toInt\n if (taxA == a && taxB == b) {\n flg = true\n } else {\n ans += 1\n }\n }\n\n println(if (flg) ans else -1)\n }\n}\n", "language": "Scala", "metadata": {"date": 1583633801, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s941923485.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s941923485", "user_id": "u433254839"}, "prompt_components": {"gold_output": "25\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n solve\n }\n\n def solve(): Unit = {\n val sc = new java.util.Scanner(System.in)\n val a, b = sc.nextInt()\n\n var ans = 1\n var flg = false\n while (!flg && ans <= 10000) {\n val taxA = (ans * 0.08).toInt\n val taxB = (ans * 0.1).toInt\n if (taxA == a && taxB == b) {\n flg = true\n } else {\n ans += 1\n }\n }\n\n println(if (flg) ans else -1)\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 454, "cpu_time_ms": 351, "memory_kb": 27440}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s946178724", "group_id": "codeNet:p02756", "input_text": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\n\nimport scala.annotation.tailrec\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val in = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n var s = in.readLine()\n val q = in.readLine().toInt\n\n var reverse = false\n\n for {\n _ <- 0 until q\n } {\n in.readLine().split(\"\\\\s+\") match {\n case Array(\"1\") =>\n reverse = !reverse\n case Array(\"2\", f, c) =>\n if (f == \"1\" && !reverse || f == \"2\" && reverse) {\n s = \"\" + c + s\n } else {\n s = s + c\n }\n }\n }\n\n out.println(\n if (reverse) {\n s.reverse\n } else {\n s\n }\n )\n out.flush()\n }\n}\n", "language": "Scala", "metadata": {"date": 1583635161, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s946178724.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s946178724", "user_id": "u178269371"}, "prompt_components": {"gold_output": "cpa\n", "input_to_evaluate": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\n\nimport scala.annotation.tailrec\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val in = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n var s = in.readLine()\n val q = in.readLine().toInt\n\n var reverse = false\n\n for {\n _ <- 0 until q\n } {\n in.readLine().split(\"\\\\s+\") match {\n case Array(\"1\") =>\n reverse = !reverse\n case Array(\"2\", f, c) =>\n if (f == \"1\" && !reverse || f == \"2\" && reverse) {\n s = \"\" + c + s\n } else {\n s = s + c\n }\n }\n }\n\n out.println(\n if (reverse) {\n s.reverse\n } else {\n s\n }\n )\n out.flush()\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 837, "cpu_time_ms": 2111, "memory_kb": 117608}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s233690364", "group_id": "codeNet:p02757", "input_text": "import io.StdIn._\n\nobject Main extends App {\n val line1 = readLine.split(\" \").map(_.toInt)\n val N = line1(0)\n val P = line1(1)\n\n val S = readLine.toCharArray.map(_.toInt - 48)\n\n val d = Array.fill[Int](N + 1)(0)\n var ten = 1\n for (i <- N - 1 to 0 by -1) {\n val a = S(i) * ten % P\n d(i) = (d(i + 1) + a) % P\n ten = ten * 10 % P\n }\n\n val cnt = Array.fill[Int](P)(0)\n var ans = 0L\n for (i <- N to 0 by -1) {\n ans = ans + cnt(d(i))\n cnt(d(i)) = cnt(d(i)) + 1\n }\n\n println(ans)\n}\n", "language": "Scala", "metadata": {"date": 1583985241, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s233690364.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s233690364", "user_id": "u611263604"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import io.StdIn._\n\nobject Main extends App {\n val line1 = readLine.split(\" \").map(_.toInt)\n val N = line1(0)\n val P = line1(1)\n\n val S = readLine.toCharArray.map(_.toInt - 48)\n\n val d = Array.fill[Int](N + 1)(0)\n var ten = 1\n for (i <- N - 1 to 0 by -1) {\n val a = S(i) * ten % P\n d(i) = (d(i + 1) + a) % P\n ten = ten * 10 % P\n }\n\n val cnt = Array.fill[Int](P)(0)\n var ans = 0L\n for (i <- N to 0 by -1) {\n ans = ans + cnt(d(i))\n cnt(d(i)) = cnt(d(i)) + 1\n }\n\n println(ans)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 503, "cpu_time_ms": 444, "memory_kb": 33352}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s640278515", "group_id": "codeNet:p02759", "input_text": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val in = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n val n = in.readLine().toInt\n\n out.println(\n n / 2 + n % 2\n )\n out.flush()\n }\n}\n", "language": "Scala", "metadata": {"date": 1583114521, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s640278515.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s640278515", "user_id": "u178269371"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val in = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n val n = in.readLine().toInt\n\n out.println(\n n / 2 + n % 2\n )\n out.flush()\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 353, "memory_kb": 27192}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s689438710", "group_id": "codeNet:p02760", "input_text": "object Main extends App{\n val a = for(_ <- 1 to 3) yield scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n val b = for(_ <- 1 to scala.io.StdIn.readInt) yield scala.io.StdIn.readInt\n val a_series = a.reduce(_ ++: _)\n val hit = for(count <- a_series) yield b.contains(count)\n val yoko = hit.grouped(3).map(e1 => e1.forall(e2 => e2 == true)).reduce(_ || _)\n val tate = (0 to 6 by 3).map(hit(_)).forall(_ == true) || (1 to 7 by 3).map(hit(_)).forall(_ == true) || (2 to 8 by 3).map(hit(_)).forall(_ == true)\n val name = (0 to 8 by 4).map(hit(_)).forall(_ == true) || (2 to 6 by 2).map(hit(_)).forall(_ == true)\n if(yoko || tate || name) println(\"Yes\") else println(\"No\")\n}", "language": "Scala", "metadata": {"date": 1589344760, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s689438710.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s689438710", "user_id": "u104354966"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App{\n val a = for(_ <- 1 to 3) yield scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n val b = for(_ <- 1 to scala.io.StdIn.readInt) yield scala.io.StdIn.readInt\n val a_series = a.reduce(_ ++: _)\n val hit = for(count <- a_series) yield b.contains(count)\n val yoko = hit.grouped(3).map(e1 => e1.forall(e2 => e2 == true)).reduce(_ || _)\n val tate = (0 to 6 by 3).map(hit(_)).forall(_ == true) || (1 to 7 by 3).map(hit(_)).forall(_ == true) || (2 to 8 by 3).map(hit(_)).forall(_ == true)\n val name = (0 to 8 by 4).map(hit(_)).forall(_ == true) || (2 to 6 by 2).map(hit(_)).forall(_ == true)\n if(yoko || tate || name) println(\"Yes\") else println(\"No\")\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a bingo card with a 3\\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.\n\nThe MC will choose N numbers, b_1, b_2, \\cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.\n\nDetermine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_{i, j} \\leq 100\n\nA_{i_1, j_1} \\neq A_{i_2, j_2} ((i_1, j_1) \\neq (i_2, j_2))\n\n1 \\leq N \\leq 10\n\n1 \\leq b_i \\leq 100\n\nb_i \\neq b_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_{1, 1} A_{1, 2} A_{1, 3}\nA_{2, 1} A_{2, 2} A_{2, 3}\nA_{3, 1} A_{3, 2} A_{3, 3}\nN\nb_1\n\\vdots\nb_N\n\nOutput\n\nIf we will have a bingo, print Yes; otherwise, print No.\n\nSample Input 1\n\n84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n\nSample Output 1\n\nYes\n\nWe will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.\n\nSample Input 2\n\n41 7 46\n26 89 2\n78 92 8\n5\n6\n45\n16\n57\n17\n\nSample Output 2\n\nNo\n\nWe will mark nothing.\n\nSample Input 3\n\n60 88 34\n92 41 43\n65 73 48\n10\n60\n43\n88\n11\n48\n73\n65\n41\n92\n34\n\nSample Output 3\n\nYes\n\nWe will mark all the squares.", "sample_input": "84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02760", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a bingo card with a 3\\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.\n\nThe MC will choose N numbers, b_1, b_2, \\cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.\n\nDetermine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_{i, j} \\leq 100\n\nA_{i_1, j_1} \\neq A_{i_2, j_2} ((i_1, j_1) \\neq (i_2, j_2))\n\n1 \\leq N \\leq 10\n\n1 \\leq b_i \\leq 100\n\nb_i \\neq b_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_{1, 1} A_{1, 2} A_{1, 3}\nA_{2, 1} A_{2, 2} A_{2, 3}\nA_{3, 1} A_{3, 2} A_{3, 3}\nN\nb_1\n\\vdots\nb_N\n\nOutput\n\nIf we will have a bingo, print Yes; otherwise, print No.\n\nSample Input 1\n\n84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n\nSample Output 1\n\nYes\n\nWe will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.\n\nSample Input 2\n\n41 7 46\n26 89 2\n78 92 8\n5\n6\n45\n16\n57\n17\n\nSample Output 2\n\nNo\n\nWe will mark nothing.\n\nSample Input 3\n\n60 88 34\n92 41 43\n65 73 48\n10\n60\n43\n88\n11\n48\n73\n65\n41\n92\n34\n\nSample Output 3\n\nYes\n\nWe will mark all the squares.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 333, "memory_kb": 25520}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s711707368", "group_id": "codeNet:p02760", "input_text": "object Main extends App { \n\tval sc = new java.util.Scanner (System.in)\n\tval matrix:List[List[Int]] = List(List.fill(3)(sc.nextInt),List.fill(3)(sc.nextInt),List.fill(3)(sc.nextInt))\n\tval n = sc.nextInt\n\tval b = for ( i <- 1 to n) yield (sc.nextInt)\n\tval c = matrix.map(x => x.map( y => if( b.indexOf(y) < 0) y else -1 ) )\n\n\tif (c(0)(0) == -1 & c(0)(1) == -1 & c(0)(2) == -1){\n\t\tprintln(\"Yes\")\n\t}else if (c(0)(0) == -1 & c(1)(1) == -1 & c(2)(2) == -1){\n\t\tprintln(\"Yes\")\n\t}else if (c(0)(0) == -1 & c(1)(0) == -1 & c(2)(0) == -1){\n\t\tprintln(\"Yes\")\n\t}else if (c(0)(2) == -1 & c(1)(1) == -1 & c(2)(0) == -1){\n\t\tprintln(\"Yes\")\n\t}else if (c(2)(0) == -1 & c(2)(1) == -1 & c(2)(2) == -1){\n\t\tprintln(\"Yes\")\n\t}else if (c(0)(2) == -1 & c(1)(2) == -1 & c(2)(2) == -1){\n\t\tprintln(\"Yes\")\n\t}else if (c(0)(1) == -1 & c(1)(1) == -1 & c(2)(1) == -1){\n\t\tprintln(\"Yes\")\n\t}else{\n\t\tprintln(\"No\")\n\t}\n}\n\n", "language": "Scala", "metadata": {"date": 1583120358, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s711707368.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s711707368", "user_id": "u809918012"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App { \n\tval sc = new java.util.Scanner (System.in)\n\tval matrix:List[List[Int]] = List(List.fill(3)(sc.nextInt),List.fill(3)(sc.nextInt),List.fill(3)(sc.nextInt))\n\tval n = sc.nextInt\n\tval b = for ( i <- 1 to n) yield (sc.nextInt)\n\tval c = matrix.map(x => x.map( y => if( b.indexOf(y) < 0) y else -1 ) )\n\n\tif (c(0)(0) == -1 & c(0)(1) == -1 & c(0)(2) == -1){\n\t\tprintln(\"Yes\")\n\t}else if (c(0)(0) == -1 & c(1)(1) == -1 & c(2)(2) == -1){\n\t\tprintln(\"Yes\")\n\t}else if (c(0)(0) == -1 & c(1)(0) == -1 & c(2)(0) == -1){\n\t\tprintln(\"Yes\")\n\t}else if (c(0)(2) == -1 & c(1)(1) == -1 & c(2)(0) == -1){\n\t\tprintln(\"Yes\")\n\t}else if (c(2)(0) == -1 & c(2)(1) == -1 & c(2)(2) == -1){\n\t\tprintln(\"Yes\")\n\t}else if (c(0)(2) == -1 & c(1)(2) == -1 & c(2)(2) == -1){\n\t\tprintln(\"Yes\")\n\t}else if (c(0)(1) == -1 & c(1)(1) == -1 & c(2)(1) == -1){\n\t\tprintln(\"Yes\")\n\t}else{\n\t\tprintln(\"No\")\n\t}\n}\n\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 879, "cpu_time_ms": 348, "memory_kb": 25548}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s860052616", "group_id": "codeNet:p02760", "input_text": "object Main extends App {\n\tval sc = new java.util.Scanner(System.in)\n\tval pw = new java.io.PrintWriter(System.out)\n\t\n\tval a = Array.fill(9)(sc.nextInt)\n\t\n\tSeq.fill(sc.nextInt)(sc.nextInt) foreach {bi =>\n\t\tval i = a.indexWhere(_ == bi)\n\t\tif (i != -1)\n\t\t\ta(i) = 0\n\t}\n\t\n\tlazy val p = (a(0) == 0 && a(1) == 0 && a(2) == 0) || (a(3) == 0 && a(4) == 0 && a(5) == 0) || (a(6) == 0 && a(7) == 0 && a(8) == 0) ||\n\t\t\t\t (a(0) == 0 && a(3) == 0 && a(6) == 0) || (a(1) == 0 && a(4) == 0 && a(7) == 0) || (a(2) == 0 && a(5) == 0 && a(8) == 0) ||\n\t\t\t\t (a(0) == 0 && a(4) == 0 && a(8) == 0) || (a(2) == 0 && a(4) == 0 && a(6) == 0) \n\t\n\tpw.println( if (p) \"Yes\" else \"No\" )\n\tpw.flush()\n}", "language": "Scala", "metadata": {"date": 1583115359, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s860052616.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s860052616", "user_id": "u822029894"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n\tval sc = new java.util.Scanner(System.in)\n\tval pw = new java.io.PrintWriter(System.out)\n\t\n\tval a = Array.fill(9)(sc.nextInt)\n\t\n\tSeq.fill(sc.nextInt)(sc.nextInt) foreach {bi =>\n\t\tval i = a.indexWhere(_ == bi)\n\t\tif (i != -1)\n\t\t\ta(i) = 0\n\t}\n\t\n\tlazy val p = (a(0) == 0 && a(1) == 0 && a(2) == 0) || (a(3) == 0 && a(4) == 0 && a(5) == 0) || (a(6) == 0 && a(7) == 0 && a(8) == 0) ||\n\t\t\t\t (a(0) == 0 && a(3) == 0 && a(6) == 0) || (a(1) == 0 && a(4) == 0 && a(7) == 0) || (a(2) == 0 && a(5) == 0 && a(8) == 0) ||\n\t\t\t\t (a(0) == 0 && a(4) == 0 && a(8) == 0) || (a(2) == 0 && a(4) == 0 && a(6) == 0) \n\t\n\tpw.println( if (p) \"Yes\" else \"No\" )\n\tpw.flush()\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 350, "memory_kb": 25932}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s661043152", "group_id": "codeNet:p02762", "input_text": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\nimport scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val N, M, K = in.next().toInt\n val uf = new UnionFind(N)\n val friend = Array.fill[List[Int]](N+1)(Nil)\n for (_ <- 1 to M) {\n val A, B = in.next().toInt\n uf.connect(A, B)\n friend(A) = B :: friend(A)\n friend(B) = A :: friend(B)\n }\n\n val block = Array.fill[List[Int]](N+1)(Nil)\n for (_ <- 1 to K) {\n val C, D = in.next().toInt\n block(C) = D :: block(C)\n block(D) = C :: block(D)\n }\n\n //\n val ans = new Array[Int](N+1)\n for (i <- 1 to N) {\n ans(i) = (uf.size(i) - 1) - friend(i).length\n val hoge = friend(i).toSet\n for (e <- block(i)) {\n if (!hoge(e) && uf.isConnect(i, e)) {\n ans(i) -= 1\n }\n }\n }\n\n println(ans.drop(1).mkString(\" \"))\n}\n\n// O(α(n)) << O(log(n))\n// v は頂点数\n// ノード番号は 1-origin \nclass UnionFind(v: Int){\n // 根であれば *そのグループの要素数(負)* が、子であれば親の番号が入る。\n val uni = Array.fill(v+1)(-1)\n\n // 頂点 v の所属するグループを調べる\n def root(v: Int): Int =\n uni(v) < 0 match{\n case true => // v が親の場合\n return v\n case false => // v が子の場合\n uni(v) = root(uni(v)) // 親のrootを調べる\n return uni(v)\n }\n\n // 頂点 a と頂点 b をつなぐ。もともと同じグループのとき、False を返す\n def connect(a: Int, b: Int): Boolean = {\n // まずはそれぞれ根の番号に置き換える\n var ra = root(a)\n var rb = root(b)\n if(ra == rb)\n return false // a と b がそもそも同じグループに属しているなら即終了\n\n // ra を大きなグループにしたいので、逆であれば入れ替える\n if(uni(ra) > uni(rb)) { // rbの方が要素数が多ければ\n var tmp = ra\n ra = rb\n rb = tmp\n }\n\n // ra と rb を結合し、rb の親を ra とする\n uni(ra) += uni(rb)\n uni(rb) = ra\n return true\n }\n\n // 頂点 a, b が同じグループであるかを調べる\n def isConnect(a: Int, b: Int): Boolean =\n root(a) == root(b)\n\n // 頂点 a を含むグループの頂点数を調べる\n def size(a: Int): Int = -uni(root(a))\n}\n\n\nobject Sub {\n def print2DimArray[A](mat: Array[Array[A]]): Unit = {\n mat.foreach(lin => println(lin.toList))\n }\n}\n\nclass InputReader(stream: InputStream) {\n private[this] val reader = new BufferedReader(new InputStreamReader(stream))\n private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n", "language": "Scala", "metadata": {"date": 1592263911, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s661043152.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s661043152", "user_id": "u098968285"}, "prompt_components": {"gold_output": "0 1 0 1\n", "input_to_evaluate": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\nimport scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val N, M, K = in.next().toInt\n val uf = new UnionFind(N)\n val friend = Array.fill[List[Int]](N+1)(Nil)\n for (_ <- 1 to M) {\n val A, B = in.next().toInt\n uf.connect(A, B)\n friend(A) = B :: friend(A)\n friend(B) = A :: friend(B)\n }\n\n val block = Array.fill[List[Int]](N+1)(Nil)\n for (_ <- 1 to K) {\n val C, D = in.next().toInt\n block(C) = D :: block(C)\n block(D) = C :: block(D)\n }\n\n //\n val ans = new Array[Int](N+1)\n for (i <- 1 to N) {\n ans(i) = (uf.size(i) - 1) - friend(i).length\n val hoge = friend(i).toSet\n for (e <- block(i)) {\n if (!hoge(e) && uf.isConnect(i, e)) {\n ans(i) -= 1\n }\n }\n }\n\n println(ans.drop(1).mkString(\" \"))\n}\n\n// O(α(n)) << O(log(n))\n// v は頂点数\n// ノード番号は 1-origin \nclass UnionFind(v: Int){\n // 根であれば *そのグループの要素数(負)* が、子であれば親の番号が入る。\n val uni = Array.fill(v+1)(-1)\n\n // 頂点 v の所属するグループを調べる\n def root(v: Int): Int =\n uni(v) < 0 match{\n case true => // v が親の場合\n return v\n case false => // v が子の場合\n uni(v) = root(uni(v)) // 親のrootを調べる\n return uni(v)\n }\n\n // 頂点 a と頂点 b をつなぐ。もともと同じグループのとき、False を返す\n def connect(a: Int, b: Int): Boolean = {\n // まずはそれぞれ根の番号に置き換える\n var ra = root(a)\n var rb = root(b)\n if(ra == rb)\n return false // a と b がそもそも同じグループに属しているなら即終了\n\n // ra を大きなグループにしたいので、逆であれば入れ替える\n if(uni(ra) > uni(rb)) { // rbの方が要素数が多ければ\n var tmp = ra\n ra = rb\n rb = tmp\n }\n\n // ra と rb を結合し、rb の親を ra とする\n uni(ra) += uni(rb)\n uni(rb) = ra\n return true\n }\n\n // 頂点 a, b が同じグループであるかを調べる\n def isConnect(a: Int, b: Int): Boolean =\n root(a) == root(b)\n\n // 頂点 a を含むグループの頂点数を調べる\n def size(a: Int): Int = -uni(root(a))\n}\n\n\nobject Sub {\n def print2DimArray[A](mat: Array[Array[A]]): Unit = {\n mat.foreach(lin => println(lin.toList))\n }\n}\n\nclass InputReader(stream: InputStream) {\n private[this] val reader = new BufferedReader(new InputStreamReader(stream))\n private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2913, "cpu_time_ms": 1582, "memory_kb": 109840}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s340480121", "group_id": "codeNet:p02762", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt()\n val m = sc.nextInt()\n val k = sc.nextInt()\n val uf = UnionFind(n)\n val ans = new Array[Int](n)\n for (i <- 0 until m) {\n val a = sc.nextInt() - 1\n val b = sc.nextInt() - 1\n uf.unite(a, b)\n ans(a) = ans(a) - 1\n ans(b) = ans(b) - 1\n }\n for (i <- 0 until n) {\n ans(i) = ans(i) + uf.size(i) - 1\n }\n for (i <- 0 until k) {\n val c = sc.nextInt() - 1\n val d = sc.nextInt() - 1\n if (uf.same(c, d)) {\n ans(c) = ans(c) - 1\n ans(d) = ans(d) - 1\n }\n }\n for (i <- 0 until n) {\n print(ans(i))\n if (i < n - 1) print(\" \")\n }\n println()\n case class UnionFind(val n: Int) {\n val par = Array.fill(n)(-1)\n val sz = Array.fill(n)(1)\n def find(x: Int): Int = {\n if (par(x) == -1) par(x) = x\n if (par(x) != x) {\n par(x) = find(par(x))\n }\n par(x)\n }\n def unite(x: Int, y: Int): Unit = {\n val a = find(x)\n val b = find(y)\n if (a == b) return\n if (sz(a) > sz(b)) {\n sz(a) += sz(b)\n par(b) = par(a)\n } else {\n sz(b) += sz(a)\n par(a) = par(b)\n }\n }\n def same(x: Int, y: Int): Boolean = {\n find(x) == find(y)\n }\n def size(x: Int): Int = {\n sz(find(x))\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1592238773, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s340480121.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s340480121", "user_id": "u628047647"}, "prompt_components": {"gold_output": "0 1 0 1\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt()\n val m = sc.nextInt()\n val k = sc.nextInt()\n val uf = UnionFind(n)\n val ans = new Array[Int](n)\n for (i <- 0 until m) {\n val a = sc.nextInt() - 1\n val b = sc.nextInt() - 1\n uf.unite(a, b)\n ans(a) = ans(a) - 1\n ans(b) = ans(b) - 1\n }\n for (i <- 0 until n) {\n ans(i) = ans(i) + uf.size(i) - 1\n }\n for (i <- 0 until k) {\n val c = sc.nextInt() - 1\n val d = sc.nextInt() - 1\n if (uf.same(c, d)) {\n ans(c) = ans(c) - 1\n ans(d) = ans(d) - 1\n }\n }\n for (i <- 0 until n) {\n print(ans(i))\n if (i < n - 1) print(\" \")\n }\n println()\n case class UnionFind(val n: Int) {\n val par = Array.fill(n)(-1)\n val sz = Array.fill(n)(1)\n def find(x: Int): Int = {\n if (par(x) == -1) par(x) = x\n if (par(x) != x) {\n par(x) = find(par(x))\n }\n par(x)\n }\n def unite(x: Int, y: Int): Unit = {\n val a = find(x)\n val b = find(y)\n if (a == b) return\n if (sz(a) > sz(b)) {\n sz(a) += sz(b)\n par(b) = par(a)\n } else {\n sz(b) += sz(a)\n par(a) = par(b)\n }\n }\n def same(x: Int, y: Int): Boolean = {\n find(x) == find(y)\n }\n def size(x: Int): Int = {\n sz(find(x))\n }\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1658, "memory_kb": 115088}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s537436650", "group_id": "codeNet:p02762", "input_text": "import io.StdIn._\nimport scala.collection.mutable\n\nobject Main extends App {\n val Array(n, m, k) = readLine.split(\" \").map(_.toInt)\n\n val friends = Array.fill(n)(Array.empty[Int])\n for (_ <- 0 until m) {\n val Array(a, b) = readLine.split(\" \").map(_.toInt - 1)\n friends(a) :+= b\n friends(b) :+= a\n }\n\n val blocks = Array.fill(n)(Array.empty[Int])\n for (_ <- 0 until k) {\n val Array(a, b) = readLine.split(\" \").map(_.toInt - 1)\n blocks(a) :+= b\n blocks(b) :+= a\n }\n\n val groupToMember = mutable.Map.empty[Int, mutable.Set[Int]]\n val memberToGroup = Array.fill(n)(-1)\n val checked = mutable.Set.empty[Int]\n for (i <- 0 until n) {\n groupToMember.put(i, mutable.Set.empty)\n if (!checked.contains(i)) {\n val stack = mutable.Stack[Int](i +: friends(i):_*)\n while (stack.nonEmpty) {\n val next = stack.pop\n if (!checked.contains(next)) {\n memberToGroup(next) = i\n groupToMember(i).add(next)\n checked.add(next)\n stack.pushAll(friends(next))\n }\n }\n }\n }\n\n println(groupToMember.map{ case (k, v) => k -> v.toSeq })\n println(memberToGroup.toSeq)\n\n val ans = Range(0, n).map { i =>\n val gid = memberToGroup(i)\n groupToMember(gid).count(candidate =>\n !(i == candidate || friends(i).contains(candidate) || blocks(i).contains(candidate))\n )\n }\n\n println(ans.mkString(\" \"))\n}", "language": "Scala", "metadata": {"date": 1584677881, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s537436650.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s537436650", "user_id": "u611263604"}, "prompt_components": {"gold_output": "0 1 0 1\n", "input_to_evaluate": "import io.StdIn._\nimport scala.collection.mutable\n\nobject Main extends App {\n val Array(n, m, k) = readLine.split(\" \").map(_.toInt)\n\n val friends = Array.fill(n)(Array.empty[Int])\n for (_ <- 0 until m) {\n val Array(a, b) = readLine.split(\" \").map(_.toInt - 1)\n friends(a) :+= b\n friends(b) :+= a\n }\n\n val blocks = Array.fill(n)(Array.empty[Int])\n for (_ <- 0 until k) {\n val Array(a, b) = readLine.split(\" \").map(_.toInt - 1)\n blocks(a) :+= b\n blocks(b) :+= a\n }\n\n val groupToMember = mutable.Map.empty[Int, mutable.Set[Int]]\n val memberToGroup = Array.fill(n)(-1)\n val checked = mutable.Set.empty[Int]\n for (i <- 0 until n) {\n groupToMember.put(i, mutable.Set.empty)\n if (!checked.contains(i)) {\n val stack = mutable.Stack[Int](i +: friends(i):_*)\n while (stack.nonEmpty) {\n val next = stack.pop\n if (!checked.contains(next)) {\n memberToGroup(next) = i\n groupToMember(i).add(next)\n checked.add(next)\n stack.pushAll(friends(next))\n }\n }\n }\n }\n\n println(groupToMember.map{ case (k, v) => k -> v.toSeq })\n println(memberToGroup.toSeq)\n\n val ans = Range(0, n).map { i =>\n val gid = memberToGroup(i)\n groupToMember(gid).count(candidate =>\n !(i == candidate || friends(i).contains(candidate) || blocks(i).contains(candidate))\n )\n }\n\n println(ans.mkString(\" \"))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1387, "cpu_time_ms": 2119, "memory_kb": 167816}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s641026783", "group_id": "codeNet:p02762", "input_text": "import io.StdIn._\nimport scala.collection.mutable\n \nobject Main extends App {\n val firstLine = readLine.split(\" \").map(_.toInt)\n val N = firstLine(0)\n val M = firstLine(1)\n val K = firstLine(2)\n \n val friends = Array.fill(N + 1)(Array.empty[Int])\n val blocks = Array.fill(N + 1)(Array.empty[Int])\n \n for (_ <- 0 until M) {\n val friendship = readLine.split(\" \").map(_.toInt)\n val a = friendship(0);\n val b = friendship(1);\n friends(a) :+= b\n friends(b) :+= a\n }\n \n for (_ <- 0 until K) {\n val blockship = readLine.split(\" \").map(_.toInt)\n val a = blockship(0)\n val b = blockship(1)\n blocks(a) :+= b\n blocks(b) :+= a\n }\n \n val groupNumbered = Array.fill(N + 1)(-1)\n val checked = mutable.Set.empty[Int]\n \n for (i <- 1 to N) {\n if (!checked.contains(i)) {\n groupNumbered(i) = i\n val stack = mutable.Stack[Int](friends(i):_*)\n while (stack.nonEmpty) {\n val next = stack.pop\n groupNumbered(next) = i\n checked.add(next)\n stack.pushAll(friends(next).filterNot(checked.contains))\n }\n checked.add(i)\n }\n }\n \n for (i <- 1 to N) {\n val groupId = groupNumbered(i)\n \n val count = groupNumbered.zipWithIndex.count { case (gid, id) =>\n gid == groupId && // 同じグループ\n id != i && // 自分自身ではなく\n !blocks(i).contains(id) && // ブロック関係でなく\n !friends(i).contains(id) // 直接の友人関係でもない\n }\n \n print(s\"$count \")\n }\n \n print(\"\\n\")\n}", "language": "Scala", "metadata": {"date": 1584675680, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s641026783.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s641026783", "user_id": "u611263604"}, "prompt_components": {"gold_output": "0 1 0 1\n", "input_to_evaluate": "import io.StdIn._\nimport scala.collection.mutable\n \nobject Main extends App {\n val firstLine = readLine.split(\" \").map(_.toInt)\n val N = firstLine(0)\n val M = firstLine(1)\n val K = firstLine(2)\n \n val friends = Array.fill(N + 1)(Array.empty[Int])\n val blocks = Array.fill(N + 1)(Array.empty[Int])\n \n for (_ <- 0 until M) {\n val friendship = readLine.split(\" \").map(_.toInt)\n val a = friendship(0);\n val b = friendship(1);\n friends(a) :+= b\n friends(b) :+= a\n }\n \n for (_ <- 0 until K) {\n val blockship = readLine.split(\" \").map(_.toInt)\n val a = blockship(0)\n val b = blockship(1)\n blocks(a) :+= b\n blocks(b) :+= a\n }\n \n val groupNumbered = Array.fill(N + 1)(-1)\n val checked = mutable.Set.empty[Int]\n \n for (i <- 1 to N) {\n if (!checked.contains(i)) {\n groupNumbered(i) = i\n val stack = mutable.Stack[Int](friends(i):_*)\n while (stack.nonEmpty) {\n val next = stack.pop\n groupNumbered(next) = i\n checked.add(next)\n stack.pushAll(friends(next).filterNot(checked.contains))\n }\n checked.add(i)\n }\n }\n \n for (i <- 1 to N) {\n val groupId = groupNumbered(i)\n \n val count = groupNumbered.zipWithIndex.count { case (gid, id) =>\n gid == groupId && // 同じグループ\n id != i && // 自分自身ではなく\n !blocks(i).contains(id) && // ブロック関係でなく\n !friends(i).contains(id) // 直接の友人関係でもない\n }\n \n print(s\"$count \")\n }\n \n print(\"\\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1504, "cpu_time_ms": 2118, "memory_kb": 143892}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s130710893", "group_id": "codeNet:p02762", "input_text": "import io.StdIn._\nimport scala.collection.mutable\n \nobject Main extends App {\n val firstLine = readLine.split(\" \").map(_.toInt)\n val N = firstLine(0)\n val M = firstLine(1)\n val K = firstLine(2)\n \n val friends = Array.fill(N + 1)(Array.empty[Int])\n val blocks = Array.fill(N + 1)(Array.empty[Int])\n \n for (_ <- 0 until M) {\n val friendship = readLine.split(\" \").map(_.toInt)\n val a = friendship(0);\n val b = friendship(1);\n friends(a) :+= b\n friends(b) :+= a\n }\n \n for (_ <- 0 until K) {\n val blockship = readLine.split(\" \").map(_.toInt)\n val a = blockship(0)\n val b = blockship(1)\n blocks(a) :+= b\n blocks(b) :+= a\n }\n \n val groupNumbered = Array.fill(N + 1)(-1)\n val checked = mutable.Set.empty[Int]\n \n for (i <- 1 to N) {\n if (!checked.contains(i)) {\n val stack = mutable.Stack[Int](friends(i):_*)\n while (stack.nonEmpty) {\n val next = stack.pop\n groupNumbered(next) = i\n checked.add(next)\n stack.pushAll(friends(next).filterNot(checked.contains))\n }\n checked.add(i)\n }\n }\n \n for (i <- 1 to N) {\n val groupId = groupNumbered(i)\n \n val count = groupNumbered.zipWithIndex.count { case (gid, id) =>\n gid == groupId && // 同じグループ\n id != i && // 自分自身ではなく\n !blocks(i).contains(id) && // ブロック関係でなく\n !friends(i).contains(id) // 直接の友人関係でもない\n }\n \n print(s\"$count \")\n }\n \n print(\"\\n\")\n}", "language": "Scala", "metadata": {"date": 1584592960, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s130710893.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s130710893", "user_id": "u611263604"}, "prompt_components": {"gold_output": "0 1 0 1\n", "input_to_evaluate": "import io.StdIn._\nimport scala.collection.mutable\n \nobject Main extends App {\n val firstLine = readLine.split(\" \").map(_.toInt)\n val N = firstLine(0)\n val M = firstLine(1)\n val K = firstLine(2)\n \n val friends = Array.fill(N + 1)(Array.empty[Int])\n val blocks = Array.fill(N + 1)(Array.empty[Int])\n \n for (_ <- 0 until M) {\n val friendship = readLine.split(\" \").map(_.toInt)\n val a = friendship(0);\n val b = friendship(1);\n friends(a) :+= b\n friends(b) :+= a\n }\n \n for (_ <- 0 until K) {\n val blockship = readLine.split(\" \").map(_.toInt)\n val a = blockship(0)\n val b = blockship(1)\n blocks(a) :+= b\n blocks(b) :+= a\n }\n \n val groupNumbered = Array.fill(N + 1)(-1)\n val checked = mutable.Set.empty[Int]\n \n for (i <- 1 to N) {\n if (!checked.contains(i)) {\n val stack = mutable.Stack[Int](friends(i):_*)\n while (stack.nonEmpty) {\n val next = stack.pop\n groupNumbered(next) = i\n checked.add(next)\n stack.pushAll(friends(next).filterNot(checked.contains))\n }\n checked.add(i)\n }\n }\n \n for (i <- 1 to N) {\n val groupId = groupNumbered(i)\n \n val count = groupNumbered.zipWithIndex.count { case (gid, id) =>\n gid == groupId && // 同じグループ\n id != i && // 自分自身ではなく\n !blocks(i).contains(id) && // ブロック関係でなく\n !friends(i).contains(id) // 直接の友人関係でもない\n }\n \n print(s\"$count \")\n }\n \n print(\"\\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1477, "cpu_time_ms": 2115, "memory_kb": 140160}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s548701350", "group_id": "codeNet:p02762", "input_text": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\n\nimport scala.collection.mutable\nimport scala.collection.mutable.ListBuffer\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val in = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n val Array(n, m, k) = in.readLine().split(\"\\\\s\").map(_.toInt)\n\n val friends = for {\n _ <- 0 until m\n } yield {\n in.readLine().split(\"\\\\s\").map(_.toInt)\n }\n\n val blocks = for {\n _ <- 0 until k\n } yield {\n in.readLine().split(\"\\\\s\").map(_.toInt)\n }\n\n val person2Cluster = mutable.HashMap.empty[Int, ListBuffer[Int]]\n val person2FriendsSize = mutable.HashMap.empty[Int, Int]\n val clusters = ListBuffer.empty[ListBuffer[Int]]\n\n @inline\n def myRelations(sets: IndexedSeq[Array[Int]], me: Int) = {\n sets.filter(_ (0) == me).map(_ (1)) ++ sets.filter(_ (1) == me).map(_ (0))\n }\n\n @inline\n def myFriends(me: Int): IndexedSeq[Int] = {\n myRelations(friends, me)\n }\n\n @inline\n def myBlocks(me: Int): IndexedSeq[Int] = {\n myRelations(blocks, me)\n }\n\n for {\n i <- 1 to n\n if !person2Cluster.contains(i)\n } yield {\n val cluster = ListBuffer.empty[Int]\n clusters.append(cluster)\n cluster.append(i)\n person2Cluster.update(i, cluster)\n\n val edges = new mutable.Stack[Int]\n edges.push(i)\n\n while (edges.nonEmpty) {\n val p = edges.pop()\n val fs = myFriends(p).toArray\n person2FriendsSize.update(p, fs.length)\n\n fs.filter { f =>\n !person2Cluster.contains(f)\n }.foreach { f =>\n cluster.append(f)\n edges.push(f)\n person2Cluster.update(f, cluster)\n }\n }\n }\n\n val cluster2size = clusters.foldLeft(mutable.HashMap.empty[ListBuffer[Int], Int]) { (acc, c) =>\n acc.update(c, c.size)\n acc\n }\n\n out.println(\n (for {\n p <- 1 to n\n } yield {\n val cluster = person2Cluster(p)\n val friendsSize = person2FriendsSize(p)\n val bs = myBlocks(p).filter { b =>\n cluster.contains(b)\n }\n cluster2size(cluster) - friendsSize - bs.size - 1\n }).mkString(\" \")\n )\n out.flush()\n }\n}\n", "language": "Scala", "metadata": {"date": 1583128201, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s548701350.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s548701350", "user_id": "u178269371"}, "prompt_components": {"gold_output": "0 1 0 1\n", "input_to_evaluate": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\n\nimport scala.collection.mutable\nimport scala.collection.mutable.ListBuffer\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val in = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n val Array(n, m, k) = in.readLine().split(\"\\\\s\").map(_.toInt)\n\n val friends = for {\n _ <- 0 until m\n } yield {\n in.readLine().split(\"\\\\s\").map(_.toInt)\n }\n\n val blocks = for {\n _ <- 0 until k\n } yield {\n in.readLine().split(\"\\\\s\").map(_.toInt)\n }\n\n val person2Cluster = mutable.HashMap.empty[Int, ListBuffer[Int]]\n val person2FriendsSize = mutable.HashMap.empty[Int, Int]\n val clusters = ListBuffer.empty[ListBuffer[Int]]\n\n @inline\n def myRelations(sets: IndexedSeq[Array[Int]], me: Int) = {\n sets.filter(_ (0) == me).map(_ (1)) ++ sets.filter(_ (1) == me).map(_ (0))\n }\n\n @inline\n def myFriends(me: Int): IndexedSeq[Int] = {\n myRelations(friends, me)\n }\n\n @inline\n def myBlocks(me: Int): IndexedSeq[Int] = {\n myRelations(blocks, me)\n }\n\n for {\n i <- 1 to n\n if !person2Cluster.contains(i)\n } yield {\n val cluster = ListBuffer.empty[Int]\n clusters.append(cluster)\n cluster.append(i)\n person2Cluster.update(i, cluster)\n\n val edges = new mutable.Stack[Int]\n edges.push(i)\n\n while (edges.nonEmpty) {\n val p = edges.pop()\n val fs = myFriends(p).toArray\n person2FriendsSize.update(p, fs.length)\n\n fs.filter { f =>\n !person2Cluster.contains(f)\n }.foreach { f =>\n cluster.append(f)\n edges.push(f)\n person2Cluster.update(f, cluster)\n }\n }\n }\n\n val cluster2size = clusters.foldLeft(mutable.HashMap.empty[ListBuffer[Int], Int]) { (acc, c) =>\n acc.update(c, c.size)\n acc\n }\n\n out.println(\n (for {\n p <- 1 to n\n } yield {\n val cluster = person2Cluster(p)\n val friendsSize = person2FriendsSize(p)\n val bs = myBlocks(p).filter { b =>\n cluster.contains(b)\n }\n cluster2size(cluster) - friendsSize - bs.size - 1\n }).mkString(\" \")\n )\n out.flush()\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2308, "cpu_time_ms": 2111, "memory_kb": 113956}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s554465856", "group_id": "codeNet:p02762", "input_text": "object Main extends App {\n\tval sc = new java.util.Scanner(System.in)\n\tval pw = new java.io.PrintWriter(System.out)\n\t\n\tval n, m = sc.nextInt\n\t\n\tval a = Array.fill(n)(-1)\n\tvar flag = true\n\t\n\tSeq.fill(m)((sc.nextInt-1, sc.nextInt)) foreach { case (s, c) =>\n\t\tif (a(s) != -1 && a(s) != c) flag = false\n\t\ta(s) = c\n\t}\n\t\n\tif (n != 1 && a(0) == 0) flag = false\n\tif (a(0) == -1) a(0) == 1\n\t\n\tpw.println( if (flag) a.map(e => if (e == -1) \"0\" else s\"$e\").mkString.toInt else -1 )\n\tpw.flush()\n}", "language": "Scala", "metadata": {"date": 1583120299, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s554465856.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s554465856", "user_id": "u822029894"}, "prompt_components": {"gold_output": "0 1 0 1\n", "input_to_evaluate": "object Main extends App {\n\tval sc = new java.util.Scanner(System.in)\n\tval pw = new java.io.PrintWriter(System.out)\n\t\n\tval n, m = sc.nextInt\n\t\n\tval a = Array.fill(n)(-1)\n\tvar flag = true\n\t\n\tSeq.fill(m)((sc.nextInt-1, sc.nextInt)) foreach { case (s, c) =>\n\t\tif (a(s) != -1 && a(s) != c) flag = false\n\t\ta(s) = c\n\t}\n\t\n\tif (n != 1 && a(0) == 0) flag = false\n\tif (a(0) == -1) a(0) == 1\n\t\n\tpw.println( if (flag) a.map(e => if (e == -1) \"0\" else s\"$e\").mkString.toInt else -1 )\n\tpw.flush()\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 483, "cpu_time_ms": 892, "memory_kb": 76764}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s433533844", "group_id": "codeNet:p02765", "input_text": "object Main {\n import scala.io.StdIn._\n def main(args: Array[String]): Unit = {\n val Array(a,b) = readLine().split(\" \").map(_.toInt)\n println(if(a<10) b+(100*(10-a)) else b)\n }\n}\n", "language": "Scala", "metadata": {"date": 1587677334, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02765.html", "problem_id": "p02765", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02765/input.txt", "sample_output_relpath": "derived/input_output/data/p02765/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02765/Scala/s433533844.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s433533844", "user_id": "u759091915"}, "prompt_components": {"gold_output": "3719\n", "input_to_evaluate": "object Main {\n import scala.io.StdIn._\n def main(args: Array[String]): Unit = {\n val Array(a,b) = readLine().split(\" \").map(_.toInt)\n println(if(a<10) b+(100*(10-a)) else b)\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a member of a programming competition site, ButCoder.\n\nEach member of ButCoder is assigned two values: Inner Rating and Displayed Rating.\n\nThe Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \\times (10 - K) when the member has participated in K contests.\n\nTakahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n0 \\leq R \\leq 4111\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN R\n\nOutput\n\nPrint his Inner Rating.\n\nSample Input 1\n\n2 2919\n\nSample Output 1\n\n3719\n\nTakahashi has participated in 2 contests, which is less than 10, so his Displayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\nSample Input 2\n\n22 3051\n\nSample Output 2\n\n3051", "sample_input": "2 2919\n"}, "reference_outputs": ["3719\n"], "source_document_id": "p02765", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a member of a programming competition site, ButCoder.\n\nEach member of ButCoder is assigned two values: Inner Rating and Displayed Rating.\n\nThe Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \\times (10 - K) when the member has participated in K contests.\n\nTakahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n0 \\leq R \\leq 4111\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN R\n\nOutput\n\nPrint his Inner Rating.\n\nSample Input 1\n\n2 2919\n\nSample Output 1\n\n3719\n\nTakahashi has participated in 2 contests, which is less than 10, so his Displayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\nSample Input 2\n\n22 3051\n\nSample Output 2\n\n3051", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 336, "memory_kb": 27308}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s236867911", "group_id": "codeNet:p02765", "input_text": "object Main extends App {\n\tval sc = new java.util.Scanner(System.in)\n\tval n, r = sc.nextLong\n\n\tprintln(r + (if(n >= 10) 0 else 100 * (10 - n)))\n}", "language": "Scala", "metadata": {"date": 1582423605, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02765.html", "problem_id": "p02765", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02765/input.txt", "sample_output_relpath": "derived/input_output/data/p02765/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02765/Scala/s236867911.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s236867911", "user_id": "u822029894"}, "prompt_components": {"gold_output": "3719\n", "input_to_evaluate": "object Main extends App {\n\tval sc = new java.util.Scanner(System.in)\n\tval n, r = sc.nextLong\n\n\tprintln(r + (if(n >= 10) 0 else 100 * (10 - n)))\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a member of a programming competition site, ButCoder.\n\nEach member of ButCoder is assigned two values: Inner Rating and Displayed Rating.\n\nThe Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \\times (10 - K) when the member has participated in K contests.\n\nTakahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n0 \\leq R \\leq 4111\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN R\n\nOutput\n\nPrint his Inner Rating.\n\nSample Input 1\n\n2 2919\n\nSample Output 1\n\n3719\n\nTakahashi has participated in 2 contests, which is less than 10, so his Displayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\nSample Input 2\n\n22 3051\n\nSample Output 2\n\n3051", "sample_input": "2 2919\n"}, "reference_outputs": ["3719\n"], "source_document_id": "p02765", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a member of a programming competition site, ButCoder.\n\nEach member of ButCoder is assigned two values: Inner Rating and Displayed Rating.\n\nThe Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \\times (10 - K) when the member has participated in K contests.\n\nTakahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n0 \\leq R \\leq 4111\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN R\n\nOutput\n\nPrint his Inner Rating.\n\nSample Input 1\n\n2 2919\n\nSample Output 1\n\n3719\n\nTakahashi has participated in 2 contests, which is less than 10, so his Displayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\nSample Input 2\n\n22 3051\n\nSample Output 2\n\n3051", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 145, "cpu_time_ms": 346, "memory_kb": 25912}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s701034000", "group_id": "codeNet:p02766", "input_text": "import scala.io.StdIn._\n\nobject Main extends App {\n\n\n val Array(n, k) = readLine().split(\" \").map(_.toInt)\n\n def solve(): Int = {\n var digit = 0\n var num = n\n while(num > 0) {\n num /= k\n digit += 1\n }\n digit\n }\n\n println(solve())\n\n}\n\n", "language": "Scala", "metadata": {"date": 1594701523, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s701034000.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s701034000", "user_id": "u947008426"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main extends App {\n\n\n val Array(n, k) = readLine().split(\" \").map(_.toInt)\n\n def solve(): Int = {\n var digit = 0\n var num = n\n while(num > 0) {\n num /= k\n digit += 1\n }\n digit\n }\n\n println(solve())\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 503, "memory_kb": 54644}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s697143249", "group_id": "codeNet:p02767", "input_text": "object Main {\n def main(args:Array[String]) {\n val N = readLine().toInt\n var X = readLine().split(' ').map(_.toInt)\n\n var ans = 99999999//X.map(a => a * a).sum\n for(P <- X.min until X.max) {\n var sum = 0\n for(i <- 0 until X.size) {\n sum += (X(i) - P) * (X(i) - P)\n }\n if(sum < ans) ans = sum\n }\n println(ans)\n }\n}\n", "language": "Scala", "metadata": {"date": 1583013462, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s697143249.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s697143249", "user_id": "u240766189"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "object Main {\n def main(args:Array[String]) {\n val N = readLine().toInt\n var X = readLine().split(' ').map(_.toInt)\n\n var ans = 99999999//X.map(a => a * a).sum\n for(P <- X.min until X.max) {\n var sum = 0\n for(i <- 0 until X.size) {\n sum += (X(i) - P) * (X(i) - P)\n }\n if(sum < ans) ans = sum\n }\n println(ans)\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 361, "cpu_time_ms": 330, "memory_kb": 25536}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s029168529", "group_id": "codeNet:p02768", "input_text": "object Main extends App {\n\tval Array(n, a, b) = scala.io.StdIn.readLine.split(\" \").map(_.toLong)\n\n\tval p = 1000000007L\n\n\tvar tp = 1L\n\n\tval p1 = powMod(2L, n, p)\n\tval p2 = combi(n, a, p)\n\tval p3 = combi(n, b, p)\n\n\tval ans = p1 - p2 - p3 - 1\n\n\tif(ans < 0) println((p + ans)%p)\n\telse println(ans%p)\n\n\n\tdef combi(n: Long, r: Long, p: Long): BigInt = {\n\t\tval tp1 = (n - r + 1L to n).foldLeft(1L)((z, i) => z*i % p)\n\t\treturn (1L to r).foldLeft(BigInt(tp1))((z, i) => BigInt(i).modInverse(p) * z % p)\n\t}\n\n\n\tdef powMod(a: Long, n: Long, p: Long): Long = {\n \tdef subpowMod(a: Long, n: Long, mul: Long): Long = {\n \t\tn match{\n\t\t\t\tcase 1L => a * mul % p\n\t\t\t\tcase _ => subpowMod(a*a%p, n/2, mul * (if((n&1) == 1) a else 1) % p )\n \t\t}\n \t}\n \tsubpowMod(a, n, 1L).toInt\n \t}\n\n}", "language": "Scala", "metadata": {"date": 1585139904, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s029168529.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s029168529", "user_id": "u675876401"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "object Main extends App {\n\tval Array(n, a, b) = scala.io.StdIn.readLine.split(\" \").map(_.toLong)\n\n\tval p = 1000000007L\n\n\tvar tp = 1L\n\n\tval p1 = powMod(2L, n, p)\n\tval p2 = combi(n, a, p)\n\tval p3 = combi(n, b, p)\n\n\tval ans = p1 - p2 - p3 - 1\n\n\tif(ans < 0) println((p + ans)%p)\n\telse println(ans%p)\n\n\n\tdef combi(n: Long, r: Long, p: Long): BigInt = {\n\t\tval tp1 = (n - r + 1L to n).foldLeft(1L)((z, i) => z*i % p)\n\t\treturn (1L to r).foldLeft(BigInt(tp1))((z, i) => BigInt(i).modInverse(p) * z % p)\n\t}\n\n\n\tdef powMod(a: Long, n: Long, p: Long): Long = {\n \tdef subpowMod(a: Long, n: Long, mul: Long): Long = {\n \t\tn match{\n\t\t\t\tcase 1L => a * mul % p\n\t\t\t\tcase _ => subpowMod(a*a%p, n/2, mul * (if((n&1) == 1) a else 1) % p )\n \t\t}\n \t}\n \tsubpowMod(a, n, 1L).toInt\n \t}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1341, "memory_kb": 117648}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s304436997", "group_id": "codeNet:p02768", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val n = sc.nextInt()\n val a = sc.nextInt()\n val b = sc.nextInt()\n\n val x = (1 to n).filterNot(i => i == a || i == b)\n\n val max = 200000\n val mod = 1000000007\n\n val fac = new Array[Long](max)\n val finv = new Array[Long](max)\n val inv = new Array[Long](max)\n\n def COMInit(): Unit = {\n fac(0) = 1\n fac(1) = 1\n finv(0) = 1\n finv(1) = 1\n inv(1) = 1\n for (i <- 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 }\n COMInit()\n\n def COM(n: Int, k: Int): Long = {\n if (n < k) 0L\n else if (n < 0 || k < 0) 0L\n else fac(n) * (finv(k) * finv(n - k) % mod) % mod\n }\n\n val y = x.map(COM(n, _)).sum\n\n println(y)\n}\n", "language": "Scala", "metadata": {"date": 1582404011, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s304436997.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s304436997", "user_id": "u786167609"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val n = sc.nextInt()\n val a = sc.nextInt()\n val b = sc.nextInt()\n\n val x = (1 to n).filterNot(i => i == a || i == b)\n\n val max = 200000\n val mod = 1000000007\n\n val fac = new Array[Long](max)\n val finv = new Array[Long](max)\n val inv = new Array[Long](max)\n\n def COMInit(): Unit = {\n fac(0) = 1\n fac(1) = 1\n finv(0) = 1\n finv(1) = 1\n inv(1) = 1\n for (i <- 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 }\n COMInit()\n\n def COM(n: Int, k: Int): Long = {\n if (n < k) 0L\n else if (n < 0 || k < 0) 0L\n else fac(n) * (finv(k) * finv(n - k) % mod) % mod\n }\n\n val y = x.map(COM(n, _)).sum\n\n println(y)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2119, "memory_kb": 227008}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s408504187", "group_id": "codeNet:p02773", "input_text": "import scala.io.StdIn._\n\nobject Main extends App {\n\n\n val n = readInt()\n val S = Array.fill(n)(readLine())\n\n def solve() = {\n val strAndCntSeq = S.groupBy(identity).mapValues(_.length).toSeq.sortBy(- _._2)\n val maxCnt = strAndCntSeq.head._2\n strAndCntSeq.foldLeft(Seq.empty[String]) { case (acc, (str, cnt)) =>\n if(cnt == maxCnt) str +: acc else acc\n }.sorted.mkString(\"\\n\")\n }\n\n println(solve())\n\n}\n\n", "language": "Scala", "metadata": {"date": 1594760360, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02773.html", "problem_id": "p02773", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02773/input.txt", "sample_output_relpath": "derived/input_output/data/p02773/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02773/Scala/s408504187.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s408504187", "user_id": "u947008426"}, "prompt_components": {"gold_output": "beet\nvet\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main extends App {\n\n\n val n = readInt()\n val S = Array.fill(n)(readLine())\n\n def solve() = {\n val strAndCntSeq = S.groupBy(identity).mapValues(_.length).toSeq.sortBy(- _._2)\n val maxCnt = strAndCntSeq.head._2\n strAndCntSeq.foldLeft(Seq.empty[String]) { case (acc, (str, cnt)) =>\n if(cnt == maxCnt) str +: acc else acc\n }.sorted.mkString(\"\\n\")\n }\n\n println(solve())\n\n}\n\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nWe have N voting papers. The i-th vote (1 \\leq i \\leq N) has the string S_i written on it.\n\nPrint all strings that are written on the most number of votes, in lexicographical order.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS_i (1 \\leq i \\leq N) are strings consisting of lowercase English letters.\n\nThe length of S_i (1 \\leq i \\leq N) is between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint all strings in question in lexicographical order.\n\nSample Input 1\n\n7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n\nSample Output 1\n\nbeet\nvet\n\nbeet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.\n\nSample Input 2\n\n8\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\n\nSample Output 2\n\nbuffalo\n\nSample Input 3\n\n7\nbass\nbass\nkick\nkick\nbass\nkick\nkick\n\nSample Output 3\n\nkick\n\nSample Input 4\n\n4\nushi\ntapu\nnichia\nkun\n\nSample Output 4\n\nkun\nnichia\ntapu\nushi", "sample_input": "7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n"}, "reference_outputs": ["beet\nvet\n"], "source_document_id": "p02773", "source_text": "Score: 300 points\n\nProblem Statement\n\nWe have N voting papers. The i-th vote (1 \\leq i \\leq N) has the string S_i written on it.\n\nPrint all strings that are written on the most number of votes, in lexicographical order.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS_i (1 \\leq i \\leq N) are strings consisting of lowercase English letters.\n\nThe length of S_i (1 \\leq i \\leq N) is between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint all strings in question in lexicographical order.\n\nSample Input 1\n\n7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n\nSample Output 1\n\nbeet\nvet\n\nbeet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.\n\nSample Input 2\n\n8\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\n\nSample Output 2\n\nbuffalo\n\nSample Input 3\n\n7\nbass\nbass\nkick\nkick\nbass\nkick\nkick\n\nSample Output 3\n\nkick\n\nSample Input 4\n\n4\nushi\ntapu\nnichia\nkun\n\nSample Output 4\n\nkun\nnichia\ntapu\nushi", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1928, "memory_kb": 163200}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s100316478", "group_id": "codeNet:p02773", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val N = sc.nextInt()\n val treeMap = new scala.collection.mutable.TreeMap[String, Int]()\n 1.to(N).foreach { _ =>\n val x = sc.next()\n val count = treeMap.getOrElseUpdate(x, 0)\n treeMap.update(x, count + 1)\n }\n val max = treeMap.values.max\n treeMap.filter { case (_, count) => count == max }.keys.foreach(println)\n}\n", "language": "Scala", "metadata": {"date": 1593712104, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02773.html", "problem_id": "p02773", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02773/input.txt", "sample_output_relpath": "derived/input_output/data/p02773/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02773/Scala/s100316478.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s100316478", "user_id": "u737111725"}, "prompt_components": {"gold_output": "beet\nvet\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val N = sc.nextInt()\n val treeMap = new scala.collection.mutable.TreeMap[String, Int]()\n 1.to(N).foreach { _ =>\n val x = sc.next()\n val count = treeMap.getOrElseUpdate(x, 0)\n treeMap.update(x, count + 1)\n }\n val max = treeMap.values.max\n treeMap.filter { case (_, count) => count == max }.keys.foreach(println)\n}\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nWe have N voting papers. The i-th vote (1 \\leq i \\leq N) has the string S_i written on it.\n\nPrint all strings that are written on the most number of votes, in lexicographical order.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS_i (1 \\leq i \\leq N) are strings consisting of lowercase English letters.\n\nThe length of S_i (1 \\leq i \\leq N) is between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint all strings in question in lexicographical order.\n\nSample Input 1\n\n7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n\nSample Output 1\n\nbeet\nvet\n\nbeet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.\n\nSample Input 2\n\n8\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\n\nSample Output 2\n\nbuffalo\n\nSample Input 3\n\n7\nbass\nbass\nkick\nkick\nbass\nkick\nkick\n\nSample Output 3\n\nkick\n\nSample Input 4\n\n4\nushi\ntapu\nnichia\nkun\n\nSample Output 4\n\nkun\nnichia\ntapu\nushi", "sample_input": "7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n"}, "reference_outputs": ["beet\nvet\n"], "source_document_id": "p02773", "source_text": "Score: 300 points\n\nProblem Statement\n\nWe have N voting papers. The i-th vote (1 \\leq i \\leq N) has the string S_i written on it.\n\nPrint all strings that are written on the most number of votes, in lexicographical order.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS_i (1 \\leq i \\leq N) are strings consisting of lowercase English letters.\n\nThe length of S_i (1 \\leq i \\leq N) is between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint all strings in question in lexicographical order.\n\nSample Input 1\n\n7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n\nSample Output 1\n\nbeet\nvet\n\nbeet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.\n\nSample Input 2\n\n8\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\n\nSample Output 2\n\nbuffalo\n\nSample Input 3\n\n7\nbass\nbass\nkick\nkick\nbass\nkick\nkick\n\nSample Output 3\n\nkick\n\nSample Input 4\n\n4\nushi\ntapu\nnichia\nkun\n\nSample Output 4\n\nkun\nnichia\ntapu\nushi", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2205, "memory_kb": 96048}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s408464544", "group_id": "codeNet:p02773", "input_text": "object Main extends App{\n import scala.io.StdIn._\n val n=readInt()\n var map=scala.collection.mutable.Map[String,Int]()\n for {i <- (0 until(n))}{\n val s=readLine()\n map(s) = if(map.contains(s)) map(s) + 1 else 1\n }\n val m=map.toSeq.sortWith(_._2>_._2)\n val top=m.head._2\n m.collect{case r if r._2 == top => r._1}.sorted.foreach(println(_))\n}", "language": "Scala", "metadata": {"date": 1588001868, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02773.html", "problem_id": "p02773", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02773/input.txt", "sample_output_relpath": "derived/input_output/data/p02773/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02773/Scala/s408464544.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s408464544", "user_id": "u759091915"}, "prompt_components": {"gold_output": "beet\nvet\n", "input_to_evaluate": "object Main extends App{\n import scala.io.StdIn._\n val n=readInt()\n var map=scala.collection.mutable.Map[String,Int]()\n for {i <- (0 until(n))}{\n val s=readLine()\n map(s) = if(map.contains(s)) map(s) + 1 else 1\n }\n val m=map.toSeq.sortWith(_._2>_._2)\n val top=m.head._2\n m.collect{case r if r._2 == top => r._1}.sorted.foreach(println(_))\n}", "problem_context": "Score: 300 points\n\nProblem Statement\n\nWe have N voting papers. The i-th vote (1 \\leq i \\leq N) has the string S_i written on it.\n\nPrint all strings that are written on the most number of votes, in lexicographical order.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS_i (1 \\leq i \\leq N) are strings consisting of lowercase English letters.\n\nThe length of S_i (1 \\leq i \\leq N) is between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint all strings in question in lexicographical order.\n\nSample Input 1\n\n7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n\nSample Output 1\n\nbeet\nvet\n\nbeet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.\n\nSample Input 2\n\n8\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\n\nSample Output 2\n\nbuffalo\n\nSample Input 3\n\n7\nbass\nbass\nkick\nkick\nbass\nkick\nkick\n\nSample Output 3\n\nkick\n\nSample Input 4\n\n4\nushi\ntapu\nnichia\nkun\n\nSample Output 4\n\nkun\nnichia\ntapu\nushi", "sample_input": "7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n"}, "reference_outputs": ["beet\nvet\n"], "source_document_id": "p02773", "source_text": "Score: 300 points\n\nProblem Statement\n\nWe have N voting papers. The i-th vote (1 \\leq i \\leq N) has the string S_i written on it.\n\nPrint all strings that are written on the most number of votes, in lexicographical order.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS_i (1 \\leq i \\leq N) are strings consisting of lowercase English letters.\n\nThe length of S_i (1 \\leq i \\leq N) is between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint all strings in question in lexicographical order.\n\nSample Input 1\n\n7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n\nSample Output 1\n\nbeet\nvet\n\nbeet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.\n\nSample Input 2\n\n8\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\n\nSample Output 2\n\nbuffalo\n\nSample Input 3\n\n7\nbass\nbass\nkick\nkick\nbass\nkick\nkick\n\nSample Output 3\n\nkick\n\nSample Input 4\n\n4\nushi\ntapu\nnichia\nkun\n\nSample Output 4\n\nkun\nnichia\ntapu\nushi", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 88396}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s876772881", "group_id": "codeNet:p02773", "input_text": "object Main extends App {\n\tval scanner = new java.util.Scanner(System.in)\n\tval N = scanner.nextInt()\n\t\t\n\tval s = Array.fill(N)(scanner.next)\n\n\tval map = scala.collection.mutable.HashMap[String, Int]()\n\n\tfor(i<-0 until N){\n\t\tval tp = s(i)\n\t\tmap.put(tp, 1 + map.getOrElse(tp, 0))\n\t}\n\n\tval vmax = map.values.max\n\tval tmp = map.filter(z => z._2 == vmax).keys.toArray.sorted\n\n\tval pw = new java.io.PrintWriter(System.out)\n\tfor (str <- tmp) {\n pw.println(str)\n }\n pw.flush()\n}\n\n// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4\nobject FastScanner {\n\tprivate val in: java.io.InputStream = System.in\n\tprivate val buf = new Array[Byte](1024)\n\tprivate var ptr: Int = 0\n\tprivate var len: Int = 0\n\n\t@inline def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126\n\t@inline private def hasNextByte(): Boolean = {\n\t\tif(ptr >= len){\n\t\t\tptr = 0\n\t\t\tlen = in.read(buf)\n\t\t\tlen > 0\n\t\t}else{\n\t\t\ttrue\n\t\t}\n\t}\n\t@inline def hasNext(): Boolean = {\n\t\twhile(hasNextByte && !isPrintableChar(buf(ptr))) ptr+=1\n\t\thasNextByte()\n\t} \n\t@inline private def readByte(): Byte = {\n\t\tif(hasNextByte()){\n\t\t\tval res = buf(ptr)\n\t\t\tptr += 1\n\t\t\tres\n\t\t}else{\n\t\t\t-1\n\t\t}\n\t}\n\n\tdef next(): String = {\n\t\tif(!hasNext()) throw new java.io.EOFException(\"Console has reached end of input\")\n\t\tval sb = new scala.collection.mutable.StringBuilder()\n\t\tvar b = readByte()\n\t\twhile(isPrintableChar(b)){\n\t\t\tsb.append(b.toChar)\n\t\t\tb = readByte()\n\t\t}\n\t\treturn sb.toString\n\t}\n\n\tdef nextLong(): Long = {\n\t\tif(!hasNext()) throw new java.io.EOFException(\"Console has reached end of input\")\n\n\t\tvar n = 0L\n\t\tvar minus = false\n\t\tvar b: Int = readByte()\n\t\tif(b == '-'){\n\t\t\tminus = true\n\t\t\tb = readByte()\n\t\t}\n\t\twhile(isPrintableChar(b)){\n\t\t\tif('0' <= b || b < '9'){\n\t\t\t\tn *= 10L\n\t\t\t\tn += (b - '0').toLong\n\t\t\t}\n\t\t\telse if(b == -1 || !isPrintableChar(b)){\n\t\t\t\tif(minus) return n\n\t\t\t\telse return -n\n\t\t\t}else{\n\t\t\t\tthrow new java.io.EOFException(\"Not Number\")\n\t\t\t}\n\t\t\tb = readByte()\n\t\t}\n\t\tif(minus) return -n\n\t\telse return n\n\t}\n}", "language": "Scala", "metadata": {"date": 1585519503, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02773.html", "problem_id": "p02773", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02773/input.txt", "sample_output_relpath": "derived/input_output/data/p02773/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02773/Scala/s876772881.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s876772881", "user_id": "u675876401"}, "prompt_components": {"gold_output": "beet\nvet\n", "input_to_evaluate": "object Main extends App {\n\tval scanner = new java.util.Scanner(System.in)\n\tval N = scanner.nextInt()\n\t\t\n\tval s = Array.fill(N)(scanner.next)\n\n\tval map = scala.collection.mutable.HashMap[String, Int]()\n\n\tfor(i<-0 until N){\n\t\tval tp = s(i)\n\t\tmap.put(tp, 1 + map.getOrElse(tp, 0))\n\t}\n\n\tval vmax = map.values.max\n\tval tmp = map.filter(z => z._2 == vmax).keys.toArray.sorted\n\n\tval pw = new java.io.PrintWriter(System.out)\n\tfor (str <- tmp) {\n pw.println(str)\n }\n pw.flush()\n}\n\n// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4\nobject FastScanner {\n\tprivate val in: java.io.InputStream = System.in\n\tprivate val buf = new Array[Byte](1024)\n\tprivate var ptr: Int = 0\n\tprivate var len: Int = 0\n\n\t@inline def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126\n\t@inline private def hasNextByte(): Boolean = {\n\t\tif(ptr >= len){\n\t\t\tptr = 0\n\t\t\tlen = in.read(buf)\n\t\t\tlen > 0\n\t\t}else{\n\t\t\ttrue\n\t\t}\n\t}\n\t@inline def hasNext(): Boolean = {\n\t\twhile(hasNextByte && !isPrintableChar(buf(ptr))) ptr+=1\n\t\thasNextByte()\n\t} \n\t@inline private def readByte(): Byte = {\n\t\tif(hasNextByte()){\n\t\t\tval res = buf(ptr)\n\t\t\tptr += 1\n\t\t\tres\n\t\t}else{\n\t\t\t-1\n\t\t}\n\t}\n\n\tdef next(): String = {\n\t\tif(!hasNext()) throw new java.io.EOFException(\"Console has reached end of input\")\n\t\tval sb = new scala.collection.mutable.StringBuilder()\n\t\tvar b = readByte()\n\t\twhile(isPrintableChar(b)){\n\t\t\tsb.append(b.toChar)\n\t\t\tb = readByte()\n\t\t}\n\t\treturn sb.toString\n\t}\n\n\tdef nextLong(): Long = {\n\t\tif(!hasNext()) throw new java.io.EOFException(\"Console has reached end of input\")\n\n\t\tvar n = 0L\n\t\tvar minus = false\n\t\tvar b: Int = readByte()\n\t\tif(b == '-'){\n\t\t\tminus = true\n\t\t\tb = readByte()\n\t\t}\n\t\twhile(isPrintableChar(b)){\n\t\t\tif('0' <= b || b < '9'){\n\t\t\t\tn *= 10L\n\t\t\t\tn += (b - '0').toLong\n\t\t\t}\n\t\t\telse if(b == -1 || !isPrintableChar(b)){\n\t\t\t\tif(minus) return n\n\t\t\t\telse return -n\n\t\t\t}else{\n\t\t\t\tthrow new java.io.EOFException(\"Not Number\")\n\t\t\t}\n\t\t\tb = readByte()\n\t\t}\n\t\tif(minus) return -n\n\t\telse return n\n\t}\n}", "problem_context": "Score: 300 points\n\nProblem Statement\n\nWe have N voting papers. The i-th vote (1 \\leq i \\leq N) has the string S_i written on it.\n\nPrint all strings that are written on the most number of votes, in lexicographical order.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS_i (1 \\leq i \\leq N) are strings consisting of lowercase English letters.\n\nThe length of S_i (1 \\leq i \\leq N) is between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint all strings in question in lexicographical order.\n\nSample Input 1\n\n7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n\nSample Output 1\n\nbeet\nvet\n\nbeet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.\n\nSample Input 2\n\n8\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\n\nSample Output 2\n\nbuffalo\n\nSample Input 3\n\n7\nbass\nbass\nkick\nkick\nbass\nkick\nkick\n\nSample Output 3\n\nkick\n\nSample Input 4\n\n4\nushi\ntapu\nnichia\nkun\n\nSample Output 4\n\nkun\nnichia\ntapu\nushi", "sample_input": "7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n"}, "reference_outputs": ["beet\nvet\n"], "source_document_id": "p02773", "source_text": "Score: 300 points\n\nProblem Statement\n\nWe have N voting papers. The i-th vote (1 \\leq i \\leq N) has the string S_i written on it.\n\nPrint all strings that are written on the most number of votes, in lexicographical order.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS_i (1 \\leq i \\leq N) are strings consisting of lowercase English letters.\n\nThe length of S_i (1 \\leq i \\leq N) is between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint all strings in question in lexicographical order.\n\nSample Input 1\n\n7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n\nSample Output 1\n\nbeet\nvet\n\nbeet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.\n\nSample Input 2\n\n8\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\n\nSample Output 2\n\nbuffalo\n\nSample Input 3\n\n7\nbass\nbass\nkick\nkick\nbass\nkick\nkick\n\nSample Output 3\n\nkick\n\nSample Input 4\n\n4\nushi\ntapu\nnichia\nkun\n\nSample Output 4\n\nkun\nnichia\ntapu\nushi", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1973, "cpu_time_ms": 1415, "memory_kb": 81464}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s194556013", "group_id": "codeNet:p02773", "input_text": "import java.io._\nimport scala.collection.mutable.{Map => MMap}\nobject Main extends App {\n val in = new StdinReader\n val N = in.nextInt\n val map = MMap[String, Int]().withDefault(_ => 0)\n (1 to N).foreach{i =>\n val s = in.next\n map.put(s, map(s) + 1)\n }\n\n val list = map.toList.sortWith((l, r) => if (l._2 == r._2) l._1 < r._1 else l._2 > r._2)\n val max = list.head._2\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n list.takeWhile(_._2 == max).foreach(t => out.println(t._1))\n out.flush()\n}\n\nclass StdinReader {\n val is = System.in\n val buffer = new Array[Byte](1024 * 1024)\n var size = 0\n var pos = 0\n\n private def readByte: Byte = {\n if (pos >= size) {\n pos = 0;\n size = is.read(buffer);\n }\n if (size < 0) -1\n else {\n val ret = buffer(pos)\n pos += 1\n ret\n }\n }\n\n // support single byte char only\n def next: String = {\n @scala.annotation.tailrec\n def r(sb: StringBuilder, reading: Boolean): String = {\n readByte match {\n case b if ('!' <= b && b <= '~') => r(sb.append(b.asInstanceOf[Char]), true)\n case _ => if (reading) sb.toString else r(sb, false)\n }\n }\n r(new StringBuilder, false)\n }\n\n def nextInt: Int = {\n @scala.annotation.tailrec\n def r(i: Int, reading: Boolean): Int = {\n readByte match {\n case '-' => r(i * -1, true)\n case b if '0' <= b && b <= '9' => r(i * 10 + (b - '0'), true)\n case _ => if (reading) i else r(i, false)\n }\n }\n r(0, false)\n }\n}", "language": "Scala", "metadata": {"date": 1582298326, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02773.html", "problem_id": "p02773", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02773/input.txt", "sample_output_relpath": "derived/input_output/data/p02773/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02773/Scala/s194556013.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s194556013", "user_id": "u132324749"}, "prompt_components": {"gold_output": "beet\nvet\n", "input_to_evaluate": "import java.io._\nimport scala.collection.mutable.{Map => MMap}\nobject Main extends App {\n val in = new StdinReader\n val N = in.nextInt\n val map = MMap[String, Int]().withDefault(_ => 0)\n (1 to N).foreach{i =>\n val s = in.next\n map.put(s, map(s) + 1)\n }\n\n val list = map.toList.sortWith((l, r) => if (l._2 == r._2) l._1 < r._1 else l._2 > r._2)\n val max = list.head._2\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n list.takeWhile(_._2 == max).foreach(t => out.println(t._1))\n out.flush()\n}\n\nclass StdinReader {\n val is = System.in\n val buffer = new Array[Byte](1024 * 1024)\n var size = 0\n var pos = 0\n\n private def readByte: Byte = {\n if (pos >= size) {\n pos = 0;\n size = is.read(buffer);\n }\n if (size < 0) -1\n else {\n val ret = buffer(pos)\n pos += 1\n ret\n }\n }\n\n // support single byte char only\n def next: String = {\n @scala.annotation.tailrec\n def r(sb: StringBuilder, reading: Boolean): String = {\n readByte match {\n case b if ('!' <= b && b <= '~') => r(sb.append(b.asInstanceOf[Char]), true)\n case _ => if (reading) sb.toString else r(sb, false)\n }\n }\n r(new StringBuilder, false)\n }\n\n def nextInt: Int = {\n @scala.annotation.tailrec\n def r(i: Int, reading: Boolean): Int = {\n readByte match {\n case '-' => r(i * -1, true)\n case b if '0' <= b && b <= '9' => r(i * 10 + (b - '0'), true)\n case _ => if (reading) i else r(i, false)\n }\n }\n r(0, false)\n }\n}", "problem_context": "Score: 300 points\n\nProblem Statement\n\nWe have N voting papers. The i-th vote (1 \\leq i \\leq N) has the string S_i written on it.\n\nPrint all strings that are written on the most number of votes, in lexicographical order.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS_i (1 \\leq i \\leq N) are strings consisting of lowercase English letters.\n\nThe length of S_i (1 \\leq i \\leq N) is between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint all strings in question in lexicographical order.\n\nSample Input 1\n\n7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n\nSample Output 1\n\nbeet\nvet\n\nbeet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.\n\nSample Input 2\n\n8\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\n\nSample Output 2\n\nbuffalo\n\nSample Input 3\n\n7\nbass\nbass\nkick\nkick\nbass\nkick\nkick\n\nSample Output 3\n\nkick\n\nSample Input 4\n\n4\nushi\ntapu\nnichia\nkun\n\nSample Output 4\n\nkun\nnichia\ntapu\nushi", "sample_input": "7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n"}, "reference_outputs": ["beet\nvet\n"], "source_document_id": "p02773", "source_text": "Score: 300 points\n\nProblem Statement\n\nWe have N voting papers. The i-th vote (1 \\leq i \\leq N) has the string S_i written on it.\n\nPrint all strings that are written on the most number of votes, in lexicographical order.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS_i (1 \\leq i \\leq N) are strings consisting of lowercase English letters.\n\nThe length of S_i (1 \\leq i \\leq N) is between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint all strings in question in lexicographical order.\n\nSample Input 1\n\n7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n\nSample Output 1\n\nbeet\nvet\n\nbeet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.\n\nSample Input 2\n\n8\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\n\nSample Output 2\n\nbuffalo\n\nSample Input 3\n\n7\nbass\nbass\nkick\nkick\nbass\nkick\nkick\n\nSample Output 3\n\nkick\n\nSample Input 4\n\n4\nushi\ntapu\nnichia\nkun\n\nSample Output 4\n\nkun\nnichia\ntapu\nushi", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1523, "cpu_time_ms": 1586, "memory_kb": 96640}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s554805447", "group_id": "codeNet:p02773", "input_text": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\n\nimport scala.collection.mutable\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val in = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n val n = in.readLine().toInt\n val strings = mutable.HashMap.empty[String, Int]\n\n for {\n _ <- 0 until n\n } {\n val s = in.readLine()\n strings(s) = if(strings.contains(s)) {\n strings(s) + 1\n } else {\n 1\n }\n }\n\n val orderedStrings = strings.toSeq.sortWith {\n case ((_, count1), (_, count2)) => count1 > count2\n }\n\n val max = orderedStrings.head._2\n orderedStrings.collect {\n case (string, count) if count == max => string\n }.sorted.foreach(out.println)\n\n out.flush()\n }\n}\n", "language": "Scala", "metadata": {"date": 1581891850, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02773.html", "problem_id": "p02773", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02773/input.txt", "sample_output_relpath": "derived/input_output/data/p02773/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02773/Scala/s554805447.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s554805447", "user_id": "u178269371"}, "prompt_components": {"gold_output": "beet\nvet\n", "input_to_evaluate": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\n\nimport scala.collection.mutable\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val in = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n val n = in.readLine().toInt\n val strings = mutable.HashMap.empty[String, Int]\n\n for {\n _ <- 0 until n\n } {\n val s = in.readLine()\n strings(s) = if(strings.contains(s)) {\n strings(s) + 1\n } else {\n 1\n }\n }\n\n val orderedStrings = strings.toSeq.sortWith {\n case ((_, count1), (_, count2)) => count1 > count2\n }\n\n val max = orderedStrings.head._2\n orderedStrings.collect {\n case (string, count) if count == max => string\n }.sorted.foreach(out.println)\n\n out.flush()\n }\n}\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nWe have N voting papers. The i-th vote (1 \\leq i \\leq N) has the string S_i written on it.\n\nPrint all strings that are written on the most number of votes, in lexicographical order.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS_i (1 \\leq i \\leq N) are strings consisting of lowercase English letters.\n\nThe length of S_i (1 \\leq i \\leq N) is between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint all strings in question in lexicographical order.\n\nSample Input 1\n\n7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n\nSample Output 1\n\nbeet\nvet\n\nbeet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.\n\nSample Input 2\n\n8\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\n\nSample Output 2\n\nbuffalo\n\nSample Input 3\n\n7\nbass\nbass\nkick\nkick\nbass\nkick\nkick\n\nSample Output 3\n\nkick\n\nSample Input 4\n\n4\nushi\ntapu\nnichia\nkun\n\nSample Output 4\n\nkun\nnichia\ntapu\nushi", "sample_input": "7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n"}, "reference_outputs": ["beet\nvet\n"], "source_document_id": "p02773", "source_text": "Score: 300 points\n\nProblem Statement\n\nWe have N voting papers. The i-th vote (1 \\leq i \\leq N) has the string S_i written on it.\n\nPrint all strings that are written on the most number of votes, in lexicographical order.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS_i (1 \\leq i \\leq N) are strings consisting of lowercase English letters.\n\nThe length of S_i (1 \\leq i \\leq N) is between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint all strings in question in lexicographical order.\n\nSample Input 1\n\n7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n\nSample Output 1\n\nbeet\nvet\n\nbeet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.\n\nSample Input 2\n\n8\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\nbuffalo\n\nSample Output 2\n\nbuffalo\n\nSample Input 3\n\n7\nbass\nbass\nkick\nkick\nbass\nkick\nkick\n\nSample Output 3\n\nkick\n\nSample Input 4\n\n4\nushi\ntapu\nnichia\nkun\n\nSample Output 4\n\nkun\nnichia\ntapu\nushi", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 861, "cpu_time_ms": 1139, "memory_kb": 74812}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s975435165", "group_id": "codeNet:p02777", "input_text": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val Array(s, t) = sc.nextLine().split(\" \")\n val A, B = sc.nextInt(); sc.nextLine()\n val u = sc.nextLine()\n\n if (u == s) println(s\"${A-1} ${B}\")\n else println(s\"$A ${B-1}\")\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1581278541, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s975435165.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s975435165", "user_id": "u891387249"}, "prompt_components": {"gold_output": "2 4\n", "input_to_evaluate": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val Array(s, t) = sc.nextLine().split(\" \")\n val A, B = sc.nextInt(); sc.nextLine()\n val u = sc.nextLine()\n\n if (u == s) println(s\"${A-1} ${B}\")\n else println(s\"$A ${B-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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 359, "memory_kb": 26056}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s112994259", "group_id": "codeNet:p02778", "input_text": "object Main extends App {\n val s = scala.io.StdIn.readLine()\n val length = s.length\n var result = \"\"\n (1 to length).foreach(_ => result = result + \"x\")\n println(result)\n\n}", "language": "Scala", "metadata": {"date": 1581279064, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02778.html", "problem_id": "p02778", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02778/input.txt", "sample_output_relpath": "derived/input_output/data/p02778/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02778/Scala/s112994259.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s112994259", "user_id": "u105921924"}, "prompt_components": {"gold_output": "xxxxxxx\n", "input_to_evaluate": "object Main extends App {\n val s = scala.io.StdIn.readLine()\n val length = s.length\n var result = \"\"\n (1 to length).foreach(_ => result = result + \"x\")\n println(result)\n\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven is a string S. Replace every character in S with x and print the result.\n\nConstraints\n\nS is a string consisting of lowercase English letters.\n\nThe length of S is between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nReplace every character in S with x and print the result.\n\nSample Input 1\n\nsardine\n\nSample Output 1\n\nxxxxxxx\n\nReplacing every character in S with x results in xxxxxxx.\n\nSample Input 2\n\nxxxx\n\nSample Output 2\n\nxxxx\n\nSample Input 3\n\ngone\n\nSample Output 3\n\nxxxx", "sample_input": "sardine\n"}, "reference_outputs": ["xxxxxxx\n"], "source_document_id": "p02778", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven is a string S. Replace every character in S with x and print the result.\n\nConstraints\n\nS is a string consisting of lowercase English letters.\n\nThe length of S is between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nReplace every character in S with x and print the result.\n\nSample Input 1\n\nsardine\n\nSample Output 1\n\nxxxxxxx\n\nReplacing every character in S with x results in xxxxxxx.\n\nSample Input 2\n\nxxxx\n\nSample Output 2\n\nxxxx\n\nSample Input 3\n\ngone\n\nSample Output 3\n\nxxxx", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 328, "memory_kb": 25520}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s434000858", "group_id": "codeNet:p02779", "input_text": "import scala.io.StdIn._\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val _ = readLine\n println(solve(readLine.split(\" \").map(_.toInt)))\n }\n\n def solve(nums: Array[Int]): Boolean = {\n nums.length == nums.toSet.size\n }\n}", "language": "Scala", "metadata": {"date": 1581370384, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s434000858.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s434000858", "user_id": "u304352308"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val _ = readLine\n println(solve(readLine.split(\" \").map(_.toInt)))\n }\n\n def solve(nums: Array[Int]): Boolean = {\n nums.length == nums.toSet.size\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 877, "memory_kb": 90764}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s600187315", "group_id": "codeNet:p02780", "input_text": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n\n val Array(n, k) = readLine().split(\" \").map(_.toInt)\n val xs = readLine().split(\" \").map(_.toDouble)\n val ys = xs.sliding(k).toArray.distinct.maxBy(_.sum)\n\n val s = ys.map(z => (z * (1 + z) / 2) / z).sum\n\n println(s)\n\n}\n", "language": "Scala", "metadata": {"date": 1581282486, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s600187315.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s600187315", "user_id": "u944710712"}, "prompt_components": {"gold_output": "7.000000000000\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n\n val Array(n, k) = readLine().split(\" \").map(_.toInt)\n val xs = readLine().split(\" \").map(_.toDouble)\n val ys = xs.sliding(k).toArray.distinct.maxBy(_.sum)\n\n val s = ys.map(z => (z * (1 + z) / 2) / z).sum\n\n println(s)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2115, "memory_kb": 300960}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s118822612", "group_id": "codeNet:p02780", "input_text": "object Main extends App {\n val Array(n, k) = io.StdIn.readLine().split(' ').map(_.toInt)\n val pn = io.StdIn.readLine().split(' ').map(_.toInt)\n var max = 0\n var start = 0\n var end = 0\n for (i <- 0 to n-k) {\n var sum = max\n if (i == 0) for (j <- i until i+k) sum += pn(j)\n else {sum = sum - pn(i-1) + pn(i+k-1)}\n if (max < sum) {max = sum; start = i; end = i+k}\n }\n\n val exp = pn.slice(start,end).map(x => (1 to x).sum / x.toDouble).sum\n println(exp)\n}", "language": "Scala", "metadata": {"date": 1581281847, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s118822612.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s118822612", "user_id": "u269739894"}, "prompt_components": {"gold_output": "7.000000000000\n", "input_to_evaluate": "object Main extends App {\n val Array(n, k) = io.StdIn.readLine().split(' ').map(_.toInt)\n val pn = io.StdIn.readLine().split(' ').map(_.toInt)\n var max = 0\n var start = 0\n var end = 0\n for (i <- 0 to n-k) {\n var sum = max\n if (i == 0) for (j <- i until i+k) sum += pn(j)\n else {sum = sum - pn(i-1) + pn(i+k-1)}\n if (max < sum) {max = sum; start = i; end = i+k}\n }\n\n val exp = pn.slice(start,end).map(x => (1 to x).sum / x.toDouble).sum\n println(exp)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 472, "cpu_time_ms": 640, "memory_kb": 74152}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s116678986", "group_id": "codeNet:p02780", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n solve\n }\n\n def solve(): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n, k = sc.nextInt\n val p = new Array[Int](n)\n for (i <- 0 until n) {\n p(i) = sc.nextInt\n }\n\n var index = 0\n var max = 0\n for (i <- 0 to n - k) {\n var sum = 0\n for (j <- i to i + k - 1) {\n sum += p(j)\n }\n if (sum >= max) {\n max = sum\n index = i\n }\n }\n\n var ans = 0d\n for (i <- index to index + k - 1) {\n var sum = 0\n for (j <- 1 to p(i)) {\n sum += j\n }\n ans += sum.toDouble / p(i)\n }\n\n\n printf(\"%.9f\\n\", ans)\n }\n}\n", "language": "Scala", "metadata": {"date": 1581280235, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s116678986.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s116678986", "user_id": "u433254839"}, "prompt_components": {"gold_output": "7.000000000000\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n solve\n }\n\n def solve(): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n, k = sc.nextInt\n val p = new Array[Int](n)\n for (i <- 0 until n) {\n p(i) = sc.nextInt\n }\n\n var index = 0\n var max = 0\n for (i <- 0 to n - k) {\n var sum = 0\n for (j <- i to i + k - 1) {\n sum += p(j)\n }\n if (sum >= max) {\n max = sum\n index = i\n }\n }\n\n var ans = 0d\n for (i <- index to index + k - 1) {\n var sum = 0\n for (j <- 1 to p(i)) {\n sum += j\n }\n ans += sum.toDouble / p(i)\n }\n\n\n printf(\"%.9f\\n\", 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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 70636}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s249196770", "group_id": "codeNet:p02783", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val factors = io.StdIn.readLine.split(\" \").map{_.toInt}\n if( factors( 0 )%factors( 1 ) == 0 ) println( factors( 0 )/factors( 1 ) )\n else println( factors( 0 )/factors( 1 ) + 1 )\n }\n}", "language": "Scala", "metadata": {"date": 1593032023, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s249196770.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s249196770", "user_id": "u888177577"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val factors = io.StdIn.readLine.split(\" \").map{_.toInt}\n if( factors( 0 )%factors( 1 ) == 0 ) println( factors( 0 )/factors( 1 ) )\n else println( factors( 0 )/factors( 1 ) + 1 )\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 281, "cpu_time_ms": 499, "memory_kb": 54292}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s911056208", "group_id": "codeNet:p02783", "input_text": "object Main extends App {\n val input = io.StdIn.readLine()\n val in = input.split(\" \").map(_.toInt)\n\n if (in(0) % in(1) == 0) {\n println((in(0) / in(1)))\n } else {\n println((in(0) / in(1) + 1))\n }\n}\n", "language": "Scala", "metadata": {"date": 1581116047, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s911056208.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s911056208", "user_id": "u097563900"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main extends App {\n val input = io.StdIn.readLine()\n val in = input.split(\" \").map(_.toInt)\n\n if (in(0) % in(1) == 0) {\n println((in(0) / in(1)))\n } else {\n println((in(0) / in(1) + 1))\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 318, "memory_kb": 27200}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s320008562", "group_id": "codeNet:p02783", "input_text": "import java.io.{BufferedReader, InputStreamReader}\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val in = new BufferedReader(new InputStreamReader(System.in))\n val Array(h, a) = in.readLine().split(\"\\\\s+\").map(_.toInt)\n\n System.out.println(\n (h / a) + (if (h % a == 0) 0 else 1)\n )\n }\n}\n", "language": "Scala", "metadata": {"date": 1580068938, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s320008562.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s320008562", "user_id": "u178269371"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.{BufferedReader, InputStreamReader}\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val in = new BufferedReader(new InputStreamReader(System.in))\n val Array(h, a) = in.readLine().split(\"\\\\s+\").map(_.toInt)\n\n System.out.println(\n (h / a) + (if (h % a == 0) 0 else 1)\n )\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 335, "memory_kb": 25540}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s591800333", "group_id": "codeNet:p02784", "input_text": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n\n val Array(h, _) = readLine().split(\" \").map(_.toInt)\n val xs = readLine().split(\" \").map(_.toInt)\n\n println(if (xs.sum >= h) \"Yes\" else \"No\")\n}\n", "language": "Scala", "metadata": {"date": 1580070326, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02784.html", "problem_id": "p02784", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02784/input.txt", "sample_output_relpath": "derived/input_output/data/p02784/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02784/Scala/s591800333.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s591800333", "user_id": "u944710712"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n\n val Array(h, _) = readLine().split(\" \").map(_.toInt)\n val xs = readLine().split(\" \").map(_.toInt)\n\n println(if (xs.sum >= h) \"Yes\" else \"No\")\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nRaccoon is fighting with a monster.\n\nThe health of the monster is H.\n\nRaccoon can use N kinds of special moves. Using the i-th move decreases the monster's health by A_i.\nThere is no other way to decrease the monster's health.\n\nRaccoon wins when the monster's health becomes 0 or below.\n\nIf Raccoon can win without using the same move twice or more, print Yes; otherwise, print No.\n\nConstraints\n\n1 \\leq H \\leq 10^9\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^4\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH N\nA_1 A_2 ... A_N\n\nOutput\n\nIf Raccoon can win without using the same move twice or more, print Yes; otherwise, print No.\n\nSample Input 1\n\n10 3\n4 5 6\n\nSample Output 1\n\nYes\n\nThe monster's health will become 0 or below after, for example, using the second and third moves.\n\nSample Input 2\n\n20 3\n4 5 6\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n210 5\n31 41 59 26 53\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n211 5\n31 41 59 26 53\n\nSample Output 4\n\nNo", "sample_input": "10 3\n4 5 6\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02784", "source_text": "Score : 200 points\n\nProblem Statement\n\nRaccoon is fighting with a monster.\n\nThe health of the monster is H.\n\nRaccoon can use N kinds of special moves. Using the i-th move decreases the monster's health by A_i.\nThere is no other way to decrease the monster's health.\n\nRaccoon wins when the monster's health becomes 0 or below.\n\nIf Raccoon can win without using the same move twice or more, print Yes; otherwise, print No.\n\nConstraints\n\n1 \\leq H \\leq 10^9\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^4\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH N\nA_1 A_2 ... A_N\n\nOutput\n\nIf Raccoon can win without using the same move twice or more, print Yes; otherwise, print No.\n\nSample Input 1\n\n10 3\n4 5 6\n\nSample Output 1\n\nYes\n\nThe monster's health will become 0 or below after, for example, using the second and third moves.\n\nSample Input 2\n\n20 3\n4 5 6\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n210 5\n31 41 59 26 53\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n211 5\n31 41 59 26 53\n\nSample Output 4\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 207, "cpu_time_ms": 521, "memory_kb": 40704}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s341653759", "group_id": "codeNet:p02788", "input_text": "import java.io._\nimport java.util.StringTokenizer\n\nimport scala.collection.mutable\nimport scala.reflect.ClassTag\n\nobject Main {\n def main(args: Array[String]): Unit = {\n try {\n val (in, out) =\n if (isOnlineJudge) {\n (\n new FastScanner(new InputStreamReader(System.in)),\n new PrintWriter(System.out)\n )\n } else {\n (\n new FastScanner(new FileReader(new File(\"src/resource/problem.in\"))),\n new PrintWriter(new File(\"src/resource/problem.out\"))\n )\n }\n new Abc153(in, out).solve()\n out.flush()\n out.close()\n } catch {\n case e: IOException => e.printStackTrace()\n }\n }\n\n private[this] val isOnlineJudge = true\n\n class FastScanner(val streamReader: InputStreamReader) {\n private[this] val reader = new BufferedReader(streamReader, 32768)\n private[this] var tokenizer: StringTokenizer = _\n\n @inline private[this] final def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = Integer.parseInt(next())\n\n def nextLong(): Long = java.lang.Long.parseLong(next())\n\n def nextChar(): Char = next().charAt(0)\n\n def ni(): Int = nextInt()\n\n def nl(): Long = nextLong()\n\n def nc(): Char = nextChar()\n\n def ns(): String = next()\n\n def ns(n: Int): Array[Char] = ns().toCharArray\n\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n)(_ => ns(m))\n }\n\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while (i < N) {\n f(i);\n i += 1\n }\n }\n\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while (i >= offset) {\n f(i);\n i -= 1\n }\n }\n\n def TO(from: Int, to: Int)(f: Int => Unit): Unit = {\n REP(to - from + 1, from)(f)\n }\n\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n\n def cumSum(as: Array[Int]): Array[Long] = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n\nclass Abc153(fScanner: Main.FastScanner, out: java.io.PrintWriter) {\n\n import Main._\n import fScanner._\n\n def solve(): Unit = {\n val n = ni()\n val d = ni()\n val a = ni()\n\n val index = mutable.HashMap.empty[Int, Int]\n x = Array.ofDim[Int](n)\n val h = Array.ofDim[Int](n)\n REP(n) { i =>\n x(i) = ni()\n h(i) = ni()\n index(x(i)) = i\n }\n\n scala.util.Sorting.quickSort(x)\n val store = Array.fill[Long](n)(0L)\n var taken = 0L\n var ans = 0L\n REP(n) { i =>\n taken -= store(index(x(i)))\n val t = x(i) + 2L * d\n val id = bs(t)\n val cut = math.ceil(math.max(h(index(x(i))) - taken, 0) / a.toDouble).toLong\n if(id != -1) store(index(id)) += cut * a\n// print(s\"$i ${x(i)} $id ${h(index(x(i)))} $taken /\")\n taken += cut * a\n ans += cut\n// println(s\"$taken $ans\")\n }\n out.println(ans)\n }\n\n var x: Array[Int] = _\n\n def bs(u: Long): Int = {\n var lo = 0\n var hi = x.length - 1\n\n while (hi - lo > 0) {\n val md = lo + (hi - lo) / 2\n if(x(md) <= u) lo = md + 1\n else hi = md\n }\n if(x(hi) <= u) {\n -1\n }\n else if(x(lo) <= u) x(hi)\n else x(lo)\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1590329340, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s341653759.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s341653759", "user_id": "u685944401"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io._\nimport java.util.StringTokenizer\n\nimport scala.collection.mutable\nimport scala.reflect.ClassTag\n\nobject Main {\n def main(args: Array[String]): Unit = {\n try {\n val (in, out) =\n if (isOnlineJudge) {\n (\n new FastScanner(new InputStreamReader(System.in)),\n new PrintWriter(System.out)\n )\n } else {\n (\n new FastScanner(new FileReader(new File(\"src/resource/problem.in\"))),\n new PrintWriter(new File(\"src/resource/problem.out\"))\n )\n }\n new Abc153(in, out).solve()\n out.flush()\n out.close()\n } catch {\n case e: IOException => e.printStackTrace()\n }\n }\n\n private[this] val isOnlineJudge = true\n\n class FastScanner(val streamReader: InputStreamReader) {\n private[this] val reader = new BufferedReader(streamReader, 32768)\n private[this] var tokenizer: StringTokenizer = _\n\n @inline private[this] final def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = Integer.parseInt(next())\n\n def nextLong(): Long = java.lang.Long.parseLong(next())\n\n def nextChar(): Char = next().charAt(0)\n\n def ni(): Int = nextInt()\n\n def nl(): Long = nextLong()\n\n def nc(): Char = nextChar()\n\n def ns(): String = next()\n\n def ns(n: Int): Array[Char] = ns().toCharArray\n\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n)(_ => ns(m))\n }\n\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while (i < N) {\n f(i);\n i += 1\n }\n }\n\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while (i >= offset) {\n f(i);\n i -= 1\n }\n }\n\n def TO(from: Int, to: Int)(f: Int => Unit): Unit = {\n REP(to - from + 1, from)(f)\n }\n\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n\n def cumSum(as: Array[Int]): Array[Long] = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n\nclass Abc153(fScanner: Main.FastScanner, out: java.io.PrintWriter) {\n\n import Main._\n import fScanner._\n\n def solve(): Unit = {\n val n = ni()\n val d = ni()\n val a = ni()\n\n val index = mutable.HashMap.empty[Int, Int]\n x = Array.ofDim[Int](n)\n val h = Array.ofDim[Int](n)\n REP(n) { i =>\n x(i) = ni()\n h(i) = ni()\n index(x(i)) = i\n }\n\n scala.util.Sorting.quickSort(x)\n val store = Array.fill[Long](n)(0L)\n var taken = 0L\n var ans = 0L\n REP(n) { i =>\n taken -= store(index(x(i)))\n val t = x(i) + 2L * d\n val id = bs(t)\n val cut = math.ceil(math.max(h(index(x(i))) - taken, 0) / a.toDouble).toLong\n if(id != -1) store(index(id)) += cut * a\n// print(s\"$i ${x(i)} $id ${h(index(x(i)))} $taken /\")\n taken += cut * a\n ans += cut\n// println(s\"$taken $ans\")\n }\n out.println(ans)\n }\n\n var x: Array[Int] = _\n\n def bs(u: Long): Int = {\n var lo = 0\n var hi = x.length - 1\n\n while (hi - lo > 0) {\n val md = lo + (hi - lo) / 2\n if(x(md) <= u) lo = md + 1\n else hi = md\n }\n if(x(hi) <= u) {\n -1\n }\n else if(x(lo) <= u) x(hi)\n else x(lo)\n }\n\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4109, "cpu_time_ms": 998, "memory_kb": 66004}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s495305470", "group_id": "codeNet:p02791", "input_text": "object Main extends App {\n val n = io.StdIn.readInt\n val ps = io.StdIn.readLine.split(\" \").map(_.toInt)\n\n /* TLE case\n def rec(count: Int, list: List[Int]): Int = list match {\n case Nil => count\n case head::Nil => count+1\n case head::tail => rec(count+1, tail.filter(_ <= head))\n }\n\n val result = rec(0, ps.toList)\n println(result)\n */ \n\n def enum_min(min: Int, list: List[Int], acc: List[Int]): List[Int] = list match {\n case Nil => acc\n // case head::Nil => enum_min(math.min(min,head), tail, acc:+math.min(min,head))\n case head::tail => enum_min(math.min(min,head), tail, acc:+math.min(min,head))\n }\n val minPs = enum_min(ps.head, ps.toList, Nil)\n\n val result = (minPs.toArray zip ps).count { case (min, p) => min == p }\n println(result)\n}", "language": "Scala", "metadata": {"date": 1592852336, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s495305470.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s495305470", "user_id": "u104354966"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main extends App {\n val n = io.StdIn.readInt\n val ps = io.StdIn.readLine.split(\" \").map(_.toInt)\n\n /* TLE case\n def rec(count: Int, list: List[Int]): Int = list match {\n case Nil => count\n case head::Nil => count+1\n case head::tail => rec(count+1, tail.filter(_ <= head))\n }\n\n val result = rec(0, ps.toList)\n println(result)\n */ \n\n def enum_min(min: Int, list: List[Int], acc: List[Int]): List[Int] = list match {\n case Nil => acc\n // case head::Nil => enum_min(math.min(min,head), tail, acc:+math.min(min,head))\n case head::tail => enum_min(math.min(min,head), tail, acc:+math.min(min,head))\n }\n val minPs = enum_min(ps.head, ps.toList, Nil)\n\n val result = (minPs.toArray zip ps).count { case (min, p) => min == p }\n println(result)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 781, "cpu_time_ms": 2206, "memory_kb": 64112}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s014127913", "group_id": "codeNet:p02792", "input_text": "import java.io._\nimport java.util.StringTokenizer\n\nimport scala.reflect.ClassTag\n\nobject Main {\n def main(args: Array[String]): Unit = {\n try {\n val (in, out) =\n if (isOnlineJudge) {\n (\n new FastScanner(new InputStreamReader(System.in)),\n new PrintWriter(System.out)\n )\n } else {\n (\n new FastScanner(new FileReader(new File(\"src/resource/problem.in\"))),\n new PrintWriter(new File(\"src/resource/problem.out\"))\n )\n }\n new Abc152(in, out).solve()\n out.flush()\n out.close()\n } catch {\n case e: IOException => e.printStackTrace()\n }\n }\n\n private[this] val isOnlineJudge = true\n\n class FastScanner(val streamReader: InputStreamReader) {\n private[this] val reader = new BufferedReader(streamReader, 32768)\n private[this] var tokenizer: StringTokenizer = _\n\n @inline private[this] final def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = Integer.parseInt(next())\n\n def nextLong(): Long = java.lang.Long.parseLong(next())\n\n def nextChar(): Char = next().charAt(0)\n\n def ni(): Int = nextInt()\n\n def nl(): Long = nextLong()\n\n def nc(): Char = nextChar()\n\n def ns(): String = next()\n\n def ns(n: Int): Array[Char] = ns().toCharArray\n\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n)(_ => ns(m))\n }\n\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while (i < N) {\n f(i);\n i += 1\n }\n }\n\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while (i >= offset) {\n f(i);\n i -= 1\n }\n }\n\n def TO(from: Int, to: Int)(f: Int => Unit): Unit = {\n REP(to - from + 1, from)(f)\n }\n\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n\n def cumSum(as: Array[Int]): Array[Long] = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n\nclass Abc152(fScanner: Main.FastScanner, out: java.io.PrintWriter) {\n\n import Main._\n import fScanner._\n\n def solve(): Unit = {\n val n = ni()\n val a = Array.fill[Int](10, 10)(0)\n REP(n+1) { i =>\n val l = i % 10\n val f = i.toString.head - '0'\n a(f)(l) += 1\n }\n var ans = 0L\n REP(10) { i =>\n REP(10) { j =>\n ans += a(i)(j) * a(j)(i)\n }\n }\n out.println(ans-1)\n }\n}\n", "language": "Scala", "metadata": {"date": 1589374132, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s014127913.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s014127913", "user_id": "u685944401"}, "prompt_components": {"gold_output": "17\n", "input_to_evaluate": "import java.io._\nimport java.util.StringTokenizer\n\nimport scala.reflect.ClassTag\n\nobject Main {\n def main(args: Array[String]): Unit = {\n try {\n val (in, out) =\n if (isOnlineJudge) {\n (\n new FastScanner(new InputStreamReader(System.in)),\n new PrintWriter(System.out)\n )\n } else {\n (\n new FastScanner(new FileReader(new File(\"src/resource/problem.in\"))),\n new PrintWriter(new File(\"src/resource/problem.out\"))\n )\n }\n new Abc152(in, out).solve()\n out.flush()\n out.close()\n } catch {\n case e: IOException => e.printStackTrace()\n }\n }\n\n private[this] val isOnlineJudge = true\n\n class FastScanner(val streamReader: InputStreamReader) {\n private[this] val reader = new BufferedReader(streamReader, 32768)\n private[this] var tokenizer: StringTokenizer = _\n\n @inline private[this] final def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = Integer.parseInt(next())\n\n def nextLong(): Long = java.lang.Long.parseLong(next())\n\n def nextChar(): Char = next().charAt(0)\n\n def ni(): Int = nextInt()\n\n def nl(): Long = nextLong()\n\n def nc(): Char = nextChar()\n\n def ns(): String = next()\n\n def ns(n: Int): Array[Char] = ns().toCharArray\n\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n)(_ => ns(m))\n }\n\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while (i < N) {\n f(i);\n i += 1\n }\n }\n\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while (i >= offset) {\n f(i);\n i -= 1\n }\n }\n\n def TO(from: Int, to: Int)(f: Int => Unit): Unit = {\n REP(to - from + 1, from)(f)\n }\n\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n\n def cumSum(as: Array[Int]): Array[Long] = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n\nclass Abc152(fScanner: Main.FastScanner, out: java.io.PrintWriter) {\n\n import Main._\n import fScanner._\n\n def solve(): Unit = {\n val n = ni()\n val a = Array.fill[Int](10, 10)(0)\n REP(n+1) { i =>\n val l = i % 10\n val f = i.toString.head - '0'\n a(f)(l) += 1\n }\n var ans = 0L\n REP(10) { i =>\n REP(10) { j =>\n ans += a(i)(j) * a(j)(i)\n }\n }\n out.println(ans-1)\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3318, "cpu_time_ms": 465, "memory_kb": 36580}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s312437967", "group_id": "codeNet:p02792", "input_text": "object Main extends App{\n val n = readInt\n \n val m = (1 to n).map{ x => \n (x.toString.head,x.toString.last) \n }.groupBy(identity).mapValues(_.size).toMap\n var cnt = 0\n m.foreach{ kv =>\n val (k,v) = kv\n val rk = (k._2,k._1)\n cnt += m(k)*m.getOrElse(rk,0)\n }\n println(cnt)\n}", "language": "Scala", "metadata": {"date": 1579720113, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s312437967.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s312437967", "user_id": "u452567689"}, "prompt_components": {"gold_output": "17\n", "input_to_evaluate": "object Main extends App{\n val n = readInt\n \n val m = (1 to n).map{ x => \n (x.toString.head,x.toString.last) \n }.groupBy(identity).mapValues(_.size).toMap\n var cnt = 0\n m.foreach{ kv =>\n val (k,v) = kv\n val rk = (k._2,k._1)\n cnt += m(k)*m.getOrElse(rk,0)\n }\n println(cnt)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 662, "memory_kb": 52768}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s205331581", "group_id": "codeNet:p02793", "input_text": "import java.io._\nimport java.util.StringTokenizer\n\nimport scala.reflect.ClassTag\n\nobject Main {\n def main(args: Array[String]): Unit = {\n try {\n val (in, out) =\n if (isOnlineJudge) {\n (\n new FastScanner(new InputStreamReader(System.in)),\n new PrintWriter(System.out)\n )\n } else {\n (\n new FastScanner(new FileReader(new File(\"src/resource/problem.in\"))),\n new PrintWriter(new File(\"src/resource/problem.out\"))\n )\n }\n new Abc152(in, out).solve()\n out.flush()\n out.close()\n } catch {\n case e: IOException => e.printStackTrace()\n }\n }\n\n private[this] val isOnlineJudge = true\n\n class FastScanner(val streamReader: InputStreamReader) {\n private[this] val reader = new BufferedReader(streamReader, 32768)\n private[this] var tokenizer: StringTokenizer = _\n\n @inline private[this] final def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = Integer.parseInt(next())\n\n def nextLong(): Long = java.lang.Long.parseLong(next())\n\n def nextChar(): Char = next().charAt(0)\n\n def ni(): Int = nextInt()\n\n def nl(): Long = nextLong()\n\n def nc(): Char = nextChar()\n\n def ns(): String = next()\n\n def ns(n: Int): Array[Char] = ns().toCharArray\n\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n)(_ => ns(m))\n }\n\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while (i < N) {\n f(i);\n i += 1\n }\n }\n\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while (i >= offset) {\n f(i);\n i -= 1\n }\n }\n\n def TO(from: Int, to: Int)(f: Int => Unit): Unit = {\n REP(to - from + 1, from)(f)\n }\n\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n\n def cumSum(as: Array[Int]): Array[Long] = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n\nclass Abc152(fScanner: Main.FastScanner, out: java.io.PrintWriter) {\n\n import Main._\n import fScanner._\n\n def solve(): Unit = {\n val n = ni()\n val a = na(n)\n prePrimes()\n// out.println(primes.length)\n// println(primes.mkString(\" \"))\n val cnt = Array.fill[Int](N)(0)\n REP(n) { i =>\n var x = a(i)\n var run = true\n var id = 0\n while (run && id < primes.length) {\n if(!mrk(x) && cnt(x) < 1) {\n cnt(x) = 1\n x = 1\n } else {\n var c = 0\n while (x % primes(id) == 0) {\n c += 1\n x /= primes(id)\n }\n if(c > cnt(primes(id))) cnt(primes(id)) = c\n }\n if(x <= 1) run = false\n id += 1\n }\n }\n var lm = 1L\n REP(N) { i =>\n if(cnt(i) > 0) {\n lm = lm * pow(i, cnt(i))\n lm %= MOD\n }\n }\n\n var ans = 0L\n REP(n) { i =>\n ans += (lm * modInv(a(i))) % MOD\n ans %= MOD\n }\n\n out.println(ans)\n }\n\n val N: Int = (1e6 + 1).toInt\n val MOD: Int = (1e9 + 7).toInt\n var primes: Array[Int] = _\n var mrk: Array[Boolean] = _\n\n def prePrimes(): Unit = {\n mrk = Array.fill[Boolean](N)(false)\n mrk(0) = true\n mrk(1) = true\n REP(N) { i =>\n if(i >= 2 && !mrk(i)) {\n i*2 until N by i foreach(j => mrk(j) = true)\n }\n }\n primes = mrk.zipWithIndex.filter(!_._1).map(_._2)\n }\n\n def pow(u: Long, n: Int): Long = {\n var ans = 1L\n var v = n\n var ret = u.toLong\n while (v > 0) {\n if(v % 2 != 0) {\n ans = ans * ret\n ans %= MOD\n }\n ret = ret * ret\n ret %= MOD\n v /= 2\n }\n ans\n }\n\n def modInv(x: Long): Long = {\n pow(x, MOD-2)\n }\n}\n", "language": "Scala", "metadata": {"date": 1589383968, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02793.html", "problem_id": "p02793", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02793/input.txt", "sample_output_relpath": "derived/input_output/data/p02793/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02793/Scala/s205331581.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s205331581", "user_id": "u685944401"}, "prompt_components": {"gold_output": "13\n", "input_to_evaluate": "import java.io._\nimport java.util.StringTokenizer\n\nimport scala.reflect.ClassTag\n\nobject Main {\n def main(args: Array[String]): Unit = {\n try {\n val (in, out) =\n if (isOnlineJudge) {\n (\n new FastScanner(new InputStreamReader(System.in)),\n new PrintWriter(System.out)\n )\n } else {\n (\n new FastScanner(new FileReader(new File(\"src/resource/problem.in\"))),\n new PrintWriter(new File(\"src/resource/problem.out\"))\n )\n }\n new Abc152(in, out).solve()\n out.flush()\n out.close()\n } catch {\n case e: IOException => e.printStackTrace()\n }\n }\n\n private[this] val isOnlineJudge = true\n\n class FastScanner(val streamReader: InputStreamReader) {\n private[this] val reader = new BufferedReader(streamReader, 32768)\n private[this] var tokenizer: StringTokenizer = _\n\n @inline private[this] final def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = Integer.parseInt(next())\n\n def nextLong(): Long = java.lang.Long.parseLong(next())\n\n def nextChar(): Char = next().charAt(0)\n\n def ni(): Int = nextInt()\n\n def nl(): Long = nextLong()\n\n def nc(): Char = nextChar()\n\n def ns(): String = next()\n\n def ns(n: Int): Array[Char] = ns().toCharArray\n\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n)(_ => ns(m))\n }\n\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while (i < N) {\n f(i);\n i += 1\n }\n }\n\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while (i >= offset) {\n f(i);\n i -= 1\n }\n }\n\n def TO(from: Int, to: Int)(f: Int => Unit): Unit = {\n REP(to - from + 1, from)(f)\n }\n\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n\n def cumSum(as: Array[Int]): Array[Long] = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n\nclass Abc152(fScanner: Main.FastScanner, out: java.io.PrintWriter) {\n\n import Main._\n import fScanner._\n\n def solve(): Unit = {\n val n = ni()\n val a = na(n)\n prePrimes()\n// out.println(primes.length)\n// println(primes.mkString(\" \"))\n val cnt = Array.fill[Int](N)(0)\n REP(n) { i =>\n var x = a(i)\n var run = true\n var id = 0\n while (run && id < primes.length) {\n if(!mrk(x) && cnt(x) < 1) {\n cnt(x) = 1\n x = 1\n } else {\n var c = 0\n while (x % primes(id) == 0) {\n c += 1\n x /= primes(id)\n }\n if(c > cnt(primes(id))) cnt(primes(id)) = c\n }\n if(x <= 1) run = false\n id += 1\n }\n }\n var lm = 1L\n REP(N) { i =>\n if(cnt(i) > 0) {\n lm = lm * pow(i, cnt(i))\n lm %= MOD\n }\n }\n\n var ans = 0L\n REP(n) { i =>\n ans += (lm * modInv(a(i))) % MOD\n ans %= MOD\n }\n\n out.println(ans)\n }\n\n val N: Int = (1e6 + 1).toInt\n val MOD: Int = (1e9 + 7).toInt\n var primes: Array[Int] = _\n var mrk: Array[Boolean] = _\n\n def prePrimes(): Unit = {\n mrk = Array.fill[Boolean](N)(false)\n mrk(0) = true\n mrk(1) = true\n REP(N) { i =>\n if(i >= 2 && !mrk(i)) {\n i*2 until N by i foreach(j => mrk(j) = true)\n }\n }\n primes = mrk.zipWithIndex.filter(!_._1).map(_._2)\n }\n\n def pow(u: Long, n: Int): Long = {\n var ans = 1L\n var v = n\n var ret = u.toLong\n while (v > 0) {\n if(v % 2 != 0) {\n ans = ans * ret\n ans %= MOD\n }\n ret = ret * ret\n ret %= MOD\n v /= 2\n }\n ans\n }\n\n def modInv(x: Long): Long = {\n pow(x, MOD-2)\n }\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nGiven are N positive integers A_1,...,A_N.\n\nConsider positive integers B_1, ..., B_N that satisfy the following condition.\n\nCondition: For any i, j such that 1 \\leq i < j \\leq N, A_i B_i = A_j B_j holds.\n\nFind the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N.\n\nSince the answer can be enormous, print the sum modulo (10^9 +7).\n\nConstraints\n\n1 \\leq N \\leq 10^4\n\n1 \\leq A_i \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 ... A_N\n\nOutput\n\nPrint the minimum possible value of B_1 + ... + B_N for B_1,...,B_N that satisfy the condition, modulo (10^9 +7).\n\nSample Input 1\n\n3\n2 3 4\n\nSample Output 1\n\n13\n\nLet B_1=6, B_2=4, and B_3=3, and the condition will be satisfied.\n\nSample Input 2\n\n5\n12 12 12 12 12\n\nSample Output 2\n\n5\n\nWe can let all B_i be 1.\n\nSample Input 3\n\n3\n1000000 999999 999998\n\nSample Output 3\n\n996989508\n\nPrint the sum modulo (10^9+7).", "sample_input": "3\n2 3 4\n"}, "reference_outputs": ["13\n"], "source_document_id": "p02793", "source_text": "Score : 500 points\n\nProblem Statement\n\nGiven are N positive integers A_1,...,A_N.\n\nConsider positive integers B_1, ..., B_N that satisfy the following condition.\n\nCondition: For any i, j such that 1 \\leq i < j \\leq N, A_i B_i = A_j B_j holds.\n\nFind the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N.\n\nSince the answer can be enormous, print the sum modulo (10^9 +7).\n\nConstraints\n\n1 \\leq N \\leq 10^4\n\n1 \\leq A_i \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 ... A_N\n\nOutput\n\nPrint the minimum possible value of B_1 + ... + B_N for B_1,...,B_N that satisfy the condition, modulo (10^9 +7).\n\nSample Input 1\n\n3\n2 3 4\n\nSample Output 1\n\n13\n\nLet B_1=6, B_2=4, and B_3=3, and the condition will be satisfied.\n\nSample Input 2\n\n5\n12 12 12 12 12\n\nSample Output 2\n\n5\n\nWe can let all B_i be 1.\n\nSample Input 3\n\n3\n1000000 999999 999998\n\nSample Output 3\n\n996989508\n\nPrint the sum modulo (10^9+7).", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4596, "cpu_time_ms": 1683, "memory_kb": 103900}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s651564981", "group_id": "codeNet:p02794", "input_text": "import java.io._\nimport java.util.StringTokenizer\n\nimport scala.collection.mutable.ListBuffer\nimport scala.reflect.ClassTag\n\nobject Main {\n def main(args: Array[String]): Unit = {\n try {\n val (in, out) =\n if (isOnlineJudge) {\n (\n new FastScanner(new InputStreamReader(System.in)),\n new PrintWriter(System.out)\n )\n } else {\n (\n new FastScanner(new FileReader(new File(\"src/resource/problem.in\"))),\n new PrintWriter(new File(\"src/resource/problem.out\"))\n )\n }\n new Abc152E(in, out).solve()\n out.flush()\n out.close()\n } catch {\n case e: IOException => e.printStackTrace()\n }\n }\n\n private[this] val isOnlineJudge = true\n\n class FastScanner(val streamReader: InputStreamReader) {\n private[this] val reader = new BufferedReader(streamReader, 32768)\n private[this] var tokenizer: StringTokenizer = _\n\n @inline private[this] final def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = Integer.parseInt(next())\n\n def nextLong(): Long = java.lang.Long.parseLong(next())\n\n def nextChar(): Char = next().charAt(0)\n\n def ni(): Int = nextInt()\n\n def nl(): Long = nextLong()\n\n def nc(): Char = nextChar()\n\n def ns(): String = next()\n\n def ns(n: Int): Array[Char] = ns().toCharArray\n\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n)(_ => ns(m))\n }\n\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while (i < N) {\n f(i);\n i += 1\n }\n }\n\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while (i >= offset) {\n f(i);\n i -= 1\n }\n }\n\n def TO(from: Int, to: Int)(f: Int => Unit): Unit = {\n REP(to - from + 1, from)(f)\n }\n\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n\n def cumSum(as: Array[Int]): Array[Long] = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n\nclass Abc152E(fScanner: Main.FastScanner, out: java.io.PrintWriter) {\n\n import Main._\n import fScanner._\n\n def solve(): Unit = {\n val n = ni()\n var ans = 0L\n from = Array.ofDim[Int](n-1)\n to = Array.ofDim[Int](n-1)\n REP(n-1) { i =>\n from(i) = ni()\n to(i) = ni()\n }\n build(n)\n par = Array.fill(n+1, 7)(0)\n height = Array.fill(n+1)(0)\n topo = new ListBuffer[Int]\n dfs(1)\n val m = ni()\n e = Array.ofDim(m, 3)\n REP(m) { i =>\n e(i)(0) = ni()\n e(i)(1) = ni()\n e(i)(2) = lca(e(i)(0), e(i)(1))\n }\n val sum = Array.ofDim[Int](n+1)\n REP(1<\n 0 to n foreach(i => sum(i) = 0)\n var btCount = 0\n REP(m) { j =>\n if((i & (1 << j)) > 0) {\n btCount +=1\n sum(e(j)(0)) += 1\n sum(e(j)(1)) += 1\n sum(e(j)(2)) -= 2\n }\n }\n\n topo.foreach{ v =>\n g(v).foreach { u =>\n if(u != par(v)(0)) sum(v) += sum(u)\n }\n }\n\n\n var tmp = 0L\n 2 to n foreach { j => if(sum(j) == 0) tmp+=1}\n tmp = 1 << tmp\n if(btCount % 2 == 1) tmp = -1* tmp\n ans += tmp\n }\n out.println(ans)\n }\n\n def build(n: Int): Unit = {\n val cnt = Array.fill[Int](n+1)(0)\n from.foreach(u => cnt(u) += 1)\n to.foreach(u => cnt(u) += 1)\n g = Array.ofDim[Array[Int]](n+1)\n REP(n+1) { i =>\n g(i) = Array.ofDim[Int](cnt(i))\n }\n\n REP(n-1) { i =>\n g(from(i))(cnt(from(i))-1) = to(i)\n g(to(i))(cnt(to(i))-1) = from(i)\n cnt(from(i)) -= 1\n cnt(to(i)) -= 1\n }\n }\n\n def dfs(u: Int): Unit = {\n height(u) = height(par(u)(0)) + 1\n 1 until 7 foreach { i =>\n par(u)(i) = par(par(u)(i-1))(i-1)\n }\n g(u).foreach { i =>\n if(i != par(u)(0)) {\n par(i)(0) = u\n dfs(i)\n }\n }\n topo += u\n }\n\n def lca(_u: Int, _v: Int): Int = {\n var u = _u\n var v = _v\n if(height(u) > height(v)) {\n u = _v; v= _u\n }\n\n 0 until 7 foreach { i =>\n if(((height(v) - height(u)) & (1< 0) v = par(v)(i)\n }\n\n if(u == v) v\n else {\n 6 until 0 by -1 foreach { i =>\n if(par(u)(i) != par(v)(i)) {\n u = par(u)(i)\n v = par(v)(i)\n }\n }\n par(u)(0)\n }\n }\n\n var from: Array[Int] = _\n var to: Array[Int] = _\n var height: Array[Int] = _\n var g: Array[Array[Int]] = _\n var e: Array[Array[Int]] = _\n var par: Array[Array[Int]] = _\n var topo: scala.collection.mutable.ListBuffer[Int] = _\n}\n", "language": "Scala", "metadata": {"date": 1589755021, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02794.html", "problem_id": "p02794", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02794/input.txt", "sample_output_relpath": "derived/input_output/data/p02794/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02794/Scala/s651564981.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s651564981", "user_id": "u685944401"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io._\nimport java.util.StringTokenizer\n\nimport scala.collection.mutable.ListBuffer\nimport scala.reflect.ClassTag\n\nobject Main {\n def main(args: Array[String]): Unit = {\n try {\n val (in, out) =\n if (isOnlineJudge) {\n (\n new FastScanner(new InputStreamReader(System.in)),\n new PrintWriter(System.out)\n )\n } else {\n (\n new FastScanner(new FileReader(new File(\"src/resource/problem.in\"))),\n new PrintWriter(new File(\"src/resource/problem.out\"))\n )\n }\n new Abc152E(in, out).solve()\n out.flush()\n out.close()\n } catch {\n case e: IOException => e.printStackTrace()\n }\n }\n\n private[this] val isOnlineJudge = true\n\n class FastScanner(val streamReader: InputStreamReader) {\n private[this] val reader = new BufferedReader(streamReader, 32768)\n private[this] var tokenizer: StringTokenizer = _\n\n @inline private[this] final def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = Integer.parseInt(next())\n\n def nextLong(): Long = java.lang.Long.parseLong(next())\n\n def nextChar(): Char = next().charAt(0)\n\n def ni(): Int = nextInt()\n\n def nl(): Long = nextLong()\n\n def nc(): Char = nextChar()\n\n def ns(): String = next()\n\n def ns(n: Int): Array[Char] = ns().toCharArray\n\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n)(_ => ns(m))\n }\n\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while (i < N) {\n f(i);\n i += 1\n }\n }\n\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while (i >= offset) {\n f(i);\n i -= 1\n }\n }\n\n def TO(from: Int, to: Int)(f: Int => Unit): Unit = {\n REP(to - from + 1, from)(f)\n }\n\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n\n def cumSum(as: Array[Int]): Array[Long] = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n\nclass Abc152E(fScanner: Main.FastScanner, out: java.io.PrintWriter) {\n\n import Main._\n import fScanner._\n\n def solve(): Unit = {\n val n = ni()\n var ans = 0L\n from = Array.ofDim[Int](n-1)\n to = Array.ofDim[Int](n-1)\n REP(n-1) { i =>\n from(i) = ni()\n to(i) = ni()\n }\n build(n)\n par = Array.fill(n+1, 7)(0)\n height = Array.fill(n+1)(0)\n topo = new ListBuffer[Int]\n dfs(1)\n val m = ni()\n e = Array.ofDim(m, 3)\n REP(m) { i =>\n e(i)(0) = ni()\n e(i)(1) = ni()\n e(i)(2) = lca(e(i)(0), e(i)(1))\n }\n val sum = Array.ofDim[Int](n+1)\n REP(1<\n 0 to n foreach(i => sum(i) = 0)\n var btCount = 0\n REP(m) { j =>\n if((i & (1 << j)) > 0) {\n btCount +=1\n sum(e(j)(0)) += 1\n sum(e(j)(1)) += 1\n sum(e(j)(2)) -= 2\n }\n }\n\n topo.foreach{ v =>\n g(v).foreach { u =>\n if(u != par(v)(0)) sum(v) += sum(u)\n }\n }\n\n\n var tmp = 0L\n 2 to n foreach { j => if(sum(j) == 0) tmp+=1}\n tmp = 1 << tmp\n if(btCount % 2 == 1) tmp = -1* tmp\n ans += tmp\n }\n out.println(ans)\n }\n\n def build(n: Int): Unit = {\n val cnt = Array.fill[Int](n+1)(0)\n from.foreach(u => cnt(u) += 1)\n to.foreach(u => cnt(u) += 1)\n g = Array.ofDim[Array[Int]](n+1)\n REP(n+1) { i =>\n g(i) = Array.ofDim[Int](cnt(i))\n }\n\n REP(n-1) { i =>\n g(from(i))(cnt(from(i))-1) = to(i)\n g(to(i))(cnt(to(i))-1) = from(i)\n cnt(from(i)) -= 1\n cnt(to(i)) -= 1\n }\n }\n\n def dfs(u: Int): Unit = {\n height(u) = height(par(u)(0)) + 1\n 1 until 7 foreach { i =>\n par(u)(i) = par(par(u)(i-1))(i-1)\n }\n g(u).foreach { i =>\n if(i != par(u)(0)) {\n par(i)(0) = u\n dfs(i)\n }\n }\n topo += u\n }\n\n def lca(_u: Int, _v: Int): Int = {\n var u = _u\n var v = _v\n if(height(u) > height(v)) {\n u = _v; v= _u\n }\n\n 0 until 7 foreach { i =>\n if(((height(v) - height(u)) & (1< 0) v = par(v)(i)\n }\n\n if(u == v) v\n else {\n 6 until 0 by -1 foreach { i =>\n if(par(u)(i) != par(v)(i)) {\n u = par(u)(i)\n v = par(v)(i)\n }\n }\n par(u)(0)\n }\n }\n\n var from: Array[Int] = _\n var to: Array[Int] = _\n var height: Array[Int] = _\n var g: Array[Array[Int]] = _\n var e: Array[Array[Int]] = _\n var par: Array[Array[Int]] = _\n var topo: scala.collection.mutable.ListBuffer[Int] = _\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices numbered 1 to N.\nThe i-th edge in this tree connects Vertex a_i and Vertex b_i.\n\nConsider painting each of these edges white or black. There are 2^{N-1} such ways to paint the edges. Among them, how many satisfy all of the following M restrictions?\n\nThe i-th (1 \\leq i \\leq M) restriction is represented by two integers u_i and v_i, which mean that the path connecting Vertex u_i and Vertex v_i must contain at least one edge painted black.\n\nConstraints\n\n2 \\leq N \\leq 50\n\n1 \\leq a_i,b_i \\leq N\n\nThe graph given in input is a tree.\n\n1 \\leq M \\leq \\min(20,\\frac{N(N-1)}{2})\n\n1 \\leq u_i < v_i \\leq N\n\nIf i \\not= j, either u_i \\not=u_j or v_i\\not=v_j\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\n:\na_{N-1} b_{N-1}\nM\nu_1 v_1\n:\nu_M v_M\n\nOutput\n\nPrint the number of ways to paint the edges that satisfy all of the M conditions.\n\nSample Input 1\n\n3\n1 2\n2 3\n1\n1 3\n\nSample Output 1\n\n3\n\nThe tree in this input is shown below:\n\nAll of the M restrictions will be satisfied if Edge 1 and 2 are respectively painted (white, black), (black, white), or (black, black), so the answer is 3.\n\nSample Input 2\n\n2\n1 2\n1\n1 2\n\nSample Output 2\n\n1\n\nThe tree in this input is shown below:\n\nAll of the M restrictions will be satisfied only if Edge 1 is painted black, so the answer is 1.\n\nSample Input 3\n\n5\n1 2\n3 2\n3 4\n5 3\n3\n1 3\n2 4\n2 5\n\nSample Output 3\n\n9\n\nThe tree in this input is shown below:\n\nSample Input 4\n\n8\n1 2\n2 3\n4 3\n2 5\n6 3\n6 7\n8 6\n5\n2 7\n3 5\n1 6\n2 8\n7 8\n\nSample Output 4\n\n62\n\nThe tree in this input is shown below:", "sample_input": "3\n1 2\n2 3\n1\n1 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02794", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices numbered 1 to N.\nThe i-th edge in this tree connects Vertex a_i and Vertex b_i.\n\nConsider painting each of these edges white or black. There are 2^{N-1} such ways to paint the edges. Among them, how many satisfy all of the following M restrictions?\n\nThe i-th (1 \\leq i \\leq M) restriction is represented by two integers u_i and v_i, which mean that the path connecting Vertex u_i and Vertex v_i must contain at least one edge painted black.\n\nConstraints\n\n2 \\leq N \\leq 50\n\n1 \\leq a_i,b_i \\leq N\n\nThe graph given in input is a tree.\n\n1 \\leq M \\leq \\min(20,\\frac{N(N-1)}{2})\n\n1 \\leq u_i < v_i \\leq N\n\nIf i \\not= j, either u_i \\not=u_j or v_i\\not=v_j\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\n:\na_{N-1} b_{N-1}\nM\nu_1 v_1\n:\nu_M v_M\n\nOutput\n\nPrint the number of ways to paint the edges that satisfy all of the M conditions.\n\nSample Input 1\n\n3\n1 2\n2 3\n1\n1 3\n\nSample Output 1\n\n3\n\nThe tree in this input is shown below:\n\nAll of the M restrictions will be satisfied if Edge 1 and 2 are respectively painted (white, black), (black, white), or (black, black), so the answer is 3.\n\nSample Input 2\n\n2\n1 2\n1\n1 2\n\nSample Output 2\n\n1\n\nThe tree in this input is shown below:\n\nAll of the M restrictions will be satisfied only if Edge 1 is painted black, so the answer is 1.\n\nSample Input 3\n\n5\n1 2\n3 2\n3 4\n5 3\n3\n1 3\n2 4\n2 5\n\nSample Output 3\n\n9\n\nThe tree in this input is shown below:\n\nSample Input 4\n\n8\n1 2\n2 3\n4 3\n2 5\n6 3\n6 7\n8 6\n5\n2 7\n3 5\n1 6\n2 8\n7 8\n\nSample Output 4\n\n62\n\nThe tree in this input is shown below:", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5410, "cpu_time_ms": 1200, "memory_kb": 66792}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s066546991", "group_id": "codeNet:p02796", "input_text": "import scala.collection.mutable.ArrayBuffer\n\nobject Main {\n def main(args: Array[String]): Unit = {\n solve\n }\n\n def solve(): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n var robots = ArrayBuffer[(Long, Long)]()\n for (i <- 0 until n) {\n val x = sc.nextLong\n val l = sc.nextLong\n robots.+=((x, l))\n }\n robots = robots.sortBy(_._1)\n\n var robotCount = n\n var before = robots(0)\n for (i <- 1 until n) {\n val beforeMax: Long = before._1 + before._2\n val currentMin: Long = robots(i)._1 - robots(i)._2\n val currentMax: Long = robots(i)._1 + robots(i)._2\n if (beforeMax > currentMin) {\n robotCount -= 1\n if (beforeMax > currentMax) {\n before = robots(i)\n }\n } else {\n before = robots(i)\n }\n }\n println(robotCount)\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1579380901, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s066546991.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s066546991", "user_id": "u433254839"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.collection.mutable.ArrayBuffer\n\nobject Main {\n def main(args: Array[String]): Unit = {\n solve\n }\n\n def solve(): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n var robots = ArrayBuffer[(Long, Long)]()\n for (i <- 0 until n) {\n val x = sc.nextLong\n val l = sc.nextLong\n robots.+=((x, l))\n }\n robots = robots.sortBy(_._1)\n\n var robotCount = n\n var before = robots(0)\n for (i <- 1 until n) {\n val beforeMax: Long = before._1 + before._2\n val currentMin: Long = robots(i)._1 - robots(i)._2\n val currentMax: Long = robots(i)._1 + robots(i)._2\n if (beforeMax > currentMin) {\n robotCount -= 1\n if (beforeMax > currentMax) {\n before = robots(i)\n }\n } else {\n before = robots(i)\n }\n }\n println(robotCount)\n }\n\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 862, "cpu_time_ms": 1003, "memory_kb": 76384}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s751196661", "group_id": "codeNet:p02797", "input_text": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val N, K = sc.nextInt()\n val S = sc.nextLong()\n println((Array.fill(K)(S) ++ Array.fill(N - K)(if (S == 1000000000L) 1 else 1000000000L)).mkString(\" \"))\n }\n\n val mod: Long = (1e9 + 7).toLong\n\n @scala.annotation.tailrec\n def recursive(N: Long, X: Array[Long], Y: Array[Long], ans: Long): Long = {\n if (X.forall(_ <= N)) ans else recursive(X.dropWhile(_ <= N).head, Y.dropWhile(_ <= N), X.dropWhile(_ <= N), ans + 1)\n }\n\n implicit class implicitInt(val N: Int) {\n def times[B](function: Int => B): IndexedSeq[B] = (0 until N).map(function)\n }\n\n def calc(input: (Long, Long, Long, Long, Long, Long)): Long = {\n input match {\n case (a, b, c, x, y, z) => {\n var ans: Long = Long.MaxValue\n if (b >= 3 && (a >= 2 || c >= 2)) {\n ans = Math.min(ans, Math.max(a - (b - 1), 0) * x + Math.max(c - Math.min(a - 1, b - 2), 0) * z)\n ans = Math.min(ans, Math.max(a - Math.min(c - 1, b - 2), 0) * x + Math.max(c - (b - 1), 0) * z)\n }\n // println(ans)\n if (b >= 2 && (a >= b && c >= b + 1)) {\n ans = Math.min(ans, y + Math.max(0, a - (c - 1)) * x)\n }\n // println(ans)\n if (b >= 2 && (a >= b + 1 && c >= b)) {\n ans = Math.min(ans, y + Math.max(0, c - (a - 1)) * z)\n }\n // println(ans)\n if (a >= 2 && c >= 2)\n if (a != c)\n ans = Math.min(ans, Math.max(0, b - (Math.min(a, c) - 1)) * y)\n else if (a >= 3 && c >= 3)\n ans = Math.min(ans, Math.max(0, b - (Math.min(a, c) - 2)) * y + Math.min(x, z))\n // println(ans)\n if (ans == Long.MaxValue) ans = -1\n ans\n }\n }\n }\n\n def time(s: String): Int =\n s.substring(0, 2).toInt * 60 + s.substring(3, 5).toInt\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getFibonacci(prevprev: Long = 0, prev: Long = 1): Stream[Long] =\n Stream.cons(prevprev, getFibonacci(prev, prevprev + prev))\n\n var memo: Map[(Long, Long), Long] = Map[(Long, Long), Long]()\n\n @scala.annotation.tailrec\n def recursive2(X: Set[Long], Y: Stream[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n\n def check(i: Int, X: String): Long = {\n if (X == \"\") 0 else check(i, X.tail) * i + X.head.toString.toLong\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n @scala.annotation.tailrec\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def primeFactors(i: Long): List[Long] = primeFactors_(i, 1).sorted\n\n\n def primeFactors_(i: Long, j: Long): List[Long] = {\n if (j * j > i) List.empty else if (i % j == 0) primeFactors_(i, j + 1) ++ List[Long](j, i / j) else primeFactors_(i, j + 1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n private val codeTable: List[(Int, String)] = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n @scala.annotation.tailrec\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n @scala.annotation.tailrec\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n}\n\nobject PowMod {\n def naivePowMod(a: Long, k: Long, m: Long): Long = {\n var t: Long = 1\n val aMod: Long = a % m\n\n for (_ <- 1L to k) {\n t = ((t % m) * aMod) % m\n }\n t.toInt\n }\n\n def powMod(a: Long, k: Long, m: Long): Long = {\n if (k == 0) 1\n else {\n val t = powMod(a, k / 2, m)\n if ((k % 2) == 0) (t * t) % m else (((t * t) % m) * a) % m\n }\n }\n}", "language": "Scala", "metadata": {"date": 1579462068, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s751196661.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s751196661", "user_id": "u779353743"}, "prompt_components": {"gold_output": "1 2 3 4\n", "input_to_evaluate": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val N, K = sc.nextInt()\n val S = sc.nextLong()\n println((Array.fill(K)(S) ++ Array.fill(N - K)(if (S == 1000000000L) 1 else 1000000000L)).mkString(\" \"))\n }\n\n val mod: Long = (1e9 + 7).toLong\n\n @scala.annotation.tailrec\n def recursive(N: Long, X: Array[Long], Y: Array[Long], ans: Long): Long = {\n if (X.forall(_ <= N)) ans else recursive(X.dropWhile(_ <= N).head, Y.dropWhile(_ <= N), X.dropWhile(_ <= N), ans + 1)\n }\n\n implicit class implicitInt(val N: Int) {\n def times[B](function: Int => B): IndexedSeq[B] = (0 until N).map(function)\n }\n\n def calc(input: (Long, Long, Long, Long, Long, Long)): Long = {\n input match {\n case (a, b, c, x, y, z) => {\n var ans: Long = Long.MaxValue\n if (b >= 3 && (a >= 2 || c >= 2)) {\n ans = Math.min(ans, Math.max(a - (b - 1), 0) * x + Math.max(c - Math.min(a - 1, b - 2), 0) * z)\n ans = Math.min(ans, Math.max(a - Math.min(c - 1, b - 2), 0) * x + Math.max(c - (b - 1), 0) * z)\n }\n // println(ans)\n if (b >= 2 && (a >= b && c >= b + 1)) {\n ans = Math.min(ans, y + Math.max(0, a - (c - 1)) * x)\n }\n // println(ans)\n if (b >= 2 && (a >= b + 1 && c >= b)) {\n ans = Math.min(ans, y + Math.max(0, c - (a - 1)) * z)\n }\n // println(ans)\n if (a >= 2 && c >= 2)\n if (a != c)\n ans = Math.min(ans, Math.max(0, b - (Math.min(a, c) - 1)) * y)\n else if (a >= 3 && c >= 3)\n ans = Math.min(ans, Math.max(0, b - (Math.min(a, c) - 2)) * y + Math.min(x, z))\n // println(ans)\n if (ans == Long.MaxValue) ans = -1\n ans\n }\n }\n }\n\n def time(s: String): Int =\n s.substring(0, 2).toInt * 60 + s.substring(3, 5).toInt\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getFibonacci(prevprev: Long = 0, prev: Long = 1): Stream[Long] =\n Stream.cons(prevprev, getFibonacci(prev, prevprev + prev))\n\n var memo: Map[(Long, Long), Long] = Map[(Long, Long), Long]()\n\n @scala.annotation.tailrec\n def recursive2(X: Set[Long], Y: Stream[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n\n def check(i: Int, X: String): Long = {\n if (X == \"\") 0 else check(i, X.tail) * i + X.head.toString.toLong\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n @scala.annotation.tailrec\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def primeFactors(i: Long): List[Long] = primeFactors_(i, 1).sorted\n\n\n def primeFactors_(i: Long, j: Long): List[Long] = {\n if (j * j > i) List.empty else if (i % j == 0) primeFactors_(i, j + 1) ++ List[Long](j, i / j) else primeFactors_(i, j + 1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n private val codeTable: List[(Int, String)] = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n @scala.annotation.tailrec\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n @scala.annotation.tailrec\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n}\n\nobject PowMod {\n def naivePowMod(a: Long, k: Long, m: Long): Long = {\n var t: Long = 1\n val aMod: Long = a % m\n\n for (_ <- 1L to k) {\n t = ((t % m) * aMod) % m\n }\n t.toInt\n }\n\n def powMod(a: Long, k: Long, m: Long): Long = {\n if (k == 0) 1\n else {\n val t = powMod(a, k / 2, m)\n if ((k % 2) == 0) (t * t) % m else (((t * t) % m) * a) % m\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 8481, "cpu_time_ms": 478, "memory_kb": 41148}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s925784993", "group_id": "codeNet:p02802", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n,m = sc.nextInt\n val seq = Seq.fill(m)((sc.nextInt, sc.next))\n \n var acList = Seq[Int]()\n var filterd = Seq[String]()\n \n for ((i, v) <- seq) {\n if (!acList.contains(i)) {\n filterd = filterd :+ v\n if (v == \"AC\") acList = acList :+ i\n }\n }\n println(s\"${filterd.count(_ == \"AC\")} ${filterd.count(_ == \"WA\")}\")\n}", "language": "Scala", "metadata": {"date": 1579068957, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s925784993.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s925784993", "user_id": "u715268393"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n,m = sc.nextInt\n val seq = Seq.fill(m)((sc.nextInt, sc.next))\n \n var acList = Seq[Int]()\n var filterd = Seq[String]()\n \n for ((i, v) <- seq) {\n if (!acList.contains(i)) {\n filterd = filterd :+ v\n if (v == \"AC\") acList = acList :+ i\n }\n }\n println(s\"${filterd.count(_ == \"AC\")} ${filterd.count(_ == \"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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 129520}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s117316229", "group_id": "codeNet:p02802", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val Array(problem_num, answer_num) = io.StdIn.readLine.split(\" \").map{_.toInt}\n\n var count = 0\n var problem = Vector.empty[Tuple2[Int, String]]\n\n while(count < answer_num) {\n val Array(ans_num, pass_or_fail) = io.StdIn.readLine.split(\" \")\n problem = problem :+ (ans_num.toInt, pass_or_fail)\n count += 1\n }\n\n var check_num = 0\n var check = false\n var fail_count = 0\n var fail_each_count = 0\n var pass_count = 0\n problem.sorted.foreach { i =>\n if ( check_num != i._1 ) {\n check_num = i._1\n check = false\n fail_each_count = 0\n }\n\n if(!check) {\n if(i._2 == \"AC\") {\n pass_count += 1\n check = true\n fail_count += fail_each_count\n }\n else {\n fail_each_count += 1\n }\n }\n }\n println(pass_count.toString + \" \" + fail_count.toString)\n }\n}", "language": "Scala", "metadata": {"date": 1578884612, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s117316229.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s117316229", "user_id": "u888177577"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val Array(problem_num, answer_num) = io.StdIn.readLine.split(\" \").map{_.toInt}\n\n var count = 0\n var problem = Vector.empty[Tuple2[Int, String]]\n\n while(count < answer_num) {\n val Array(ans_num, pass_or_fail) = io.StdIn.readLine.split(\" \")\n problem = problem :+ (ans_num.toInt, pass_or_fail)\n count += 1\n }\n\n var check_num = 0\n var check = false\n var fail_count = 0\n var fail_each_count = 0\n var pass_count = 0\n problem.sorted.foreach { i =>\n if ( check_num != i._1 ) {\n check_num = i._1\n check = false\n fail_each_count = 0\n }\n\n if(!check) {\n if(i._2 == \"AC\") {\n pass_count += 1\n check = true\n fail_count += fail_each_count\n }\n else {\n fail_each_count += 1\n }\n }\n }\n println(pass_count.toString + \" \" + fail_count.toString)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 944, "cpu_time_ms": 1194, "memory_kb": 65864}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s530813860", "group_id": "codeNet:p02802", "input_text": "object Main {\n def main(args: Array[String]) = {\n import scala.io.StdIn.readLine\n var Array(n, m) = readLine.split(\" \").map(_.toInt)\n var penalty: Array[Int] = new Array[Int](n)\n var done: Array[Int] = new Array[Int](n)\n\n for(i <- 0 until m) {\n var Array(idstring, ver) = readLine.split(\" \")\n var id = idstring.toInt - 1\n ver match {\n case \"AC\" => done(id) = 1\n case \"WA\" => if( done(id) == 0 ) penalty(id) = penalty(id) + 1\n case _ => ;\n }\n }\n\n var ans: Int = 0; var pen: Int = 0\n for(i <- 0 until n) {\n ans = ans + done(i)\n if(done(i) == 1) pen = pen + penalty(i)\n }\n\n printf(\"%d %d\\n\", ans, pen)\n }\n}", "language": "Scala", "metadata": {"date": 1578882192, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s530813860.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s530813860", "user_id": "u533606242"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]) = {\n import scala.io.StdIn.readLine\n var Array(n, m) = readLine.split(\" \").map(_.toInt)\n var penalty: Array[Int] = new Array[Int](n)\n var done: Array[Int] = new Array[Int](n)\n\n for(i <- 0 until m) {\n var Array(idstring, ver) = readLine.split(\" \")\n var id = idstring.toInt - 1\n ver match {\n case \"AC\" => done(id) = 1\n case \"WA\" => if( done(id) == 0 ) penalty(id) = penalty(id) + 1\n case _ => ;\n }\n }\n\n var ans: Int = 0; var pen: Int = 0\n for(i <- 0 until n) {\n ans = ans + done(i)\n if(done(i) == 1) pen = pen + penalty(i)\n }\n\n printf(\"%d %d\\n\", ans, pen)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 791, "cpu_time_ms": 841, "memory_kb": 49012}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s785342564", "group_id": "codeNet:p02802", "input_text": "object Main extends App {\n import scala.collection.mutable\n\n val Array(n, m) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n val ACseq: mutable.HashSet[Int] = new mutable.HashSet\n var wacnt = 0\n\n (1 to m).foreach { i =>\n val Array(p, s) = scala.io.StdIn.readLine.split(\" \")\n val pp = p.toInt\n if (!ACseq.contains(pp)) {\n if (s == \"AC\") {\n ACseq.add(pp)\n } else {\n wacnt += 1\n }\n }\n }\n println(ACseq.size + \" \" + wacnt)\n}\n", "language": "Scala", "metadata": {"date": 1578881918, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s785342564.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s785342564", "user_id": "u654455149"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "object Main extends App {\n import scala.collection.mutable\n\n val Array(n, m) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n val ACseq: mutable.HashSet[Int] = new mutable.HashSet\n var wacnt = 0\n\n (1 to m).foreach { i =>\n val Array(p, s) = scala.io.StdIn.readLine.split(\" \")\n val pp = p.toInt\n if (!ACseq.contains(pp)) {\n if (s == \"AC\") {\n ACseq.add(pp)\n } else {\n wacnt += 1\n }\n }\n }\n println(ACseq.size + \" \" + wacnt)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 472, "cpu_time_ms": 895, "memory_kb": 50684}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s819113647", "group_id": "codeNet:p02802", "input_text": "object Main {\n import java.io.{BufferedReader, InputStream, InputStreamReader}\n import java.util.StringTokenizer\n import scala.reflect.ClassTag\n\n def main(args: Array[String]): Unit = {\n val out = new java.io.PrintWriter(System.out)\n new Main(out, new InputReader(System.in)).solve()\n out.flush()\n }\n\n private[this] val oj = System.getenv(\"MY_DEBUG\") == null\n def DEBUG(f: => Unit): Unit = {\n if (!oj){ f }\n }\n def debug(as: Array[Boolean]): Unit = if (!oj){ debug(as.map(x => if(x) \"1\" else \"0\").mkString) }\n def debug(as: Array[Int]): Unit = if (!oj){ debug(as.mkString(\" \")) }\n def debug(as: Array[Long]): Unit =if (!oj){ debug(as.mkString(\" \")) }\n def debugDim(m: Array[Array[Int]]): Unit = if (!oj){\n REP(m.length) { i =>\n debug(m(i))\n }\n }\n def debugDimFlip(m: Array[Array[Long]]): Unit = if (!oj){\n REP(m(0).length) { j =>\n REP(m.length) { i =>\n System.err.print(m(i)(j))\n System.err.print(\" \")\n }\n System.err.println()\n }\n }\n def debug(s: => String): Unit = {\n if (!oj){ System.err.println(s) }\n }\n def isDebug[A](debug: => A, online: => A): A = {\n if (oj) online else debug\n }\n\n class InputReader(val stream: InputStream) {\n private[this] val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private[this] var tokenizer: StringTokenizer = _\n\n private[this] def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = Integer.parseInt(next())\n def nextLong(): Long = java.lang.Long.parseLong(next())\n def nextChar(): Char = next().charAt(0)\n\n def ni(): Int = nextInt()\n def nl(): Long = nextLong()\n def nc(): Char = nextChar()\n def ns(): String = next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n }\n\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n def TO(from: Int, to: Int)(f: Int => Unit): Unit = {\n REP(to - from + 1, from)(f)\n }\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n def cumSum(as: Array[Int]): Array[Long] = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n\nobject Workspace {\n import Main._\n import java.util.Arrays.sort\n\n import scala.collection.mutable\n import math.{abs, max, min}\n import mutable.ArrayBuffer\n}\n\nclass Main(out: java.io.PrintWriter, sc: Main.InputReader) {\n import sc._\n import Main._\n import java.util.Arrays.sort\n\n import scala.collection.mutable\n import math.{abs, max, min}\n import mutable.ArrayBuffer\n import Workspace._\n\n // toIntとか+7とかするならvalにしろ\n final private[this] val MOD = 1000000007\n\n def solve(): Unit = {\n val N, M = ni()\n val cnt = Array.ofDim[Int](N + 1)\n val flg = Array.ofDim[Boolean](N + 1)\n var success, failure = 0\n REP(M) { _ =>\n val p = ni()\n val s = ns()\n s match {\n case \"AC\" =>\n if (!flg(p)) {\n flg(p) = true\n success += 1\n failure += cnt(p)\n }\n\n case \"WA\" =>\n cnt(p) += 1\n }\n }\n out.println(s\"$success $failure\")\n }\n}", "language": "Scala", "metadata": {"date": 1578881279, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s819113647.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s819113647", "user_id": "u460609472"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "object Main {\n import java.io.{BufferedReader, InputStream, InputStreamReader}\n import java.util.StringTokenizer\n import scala.reflect.ClassTag\n\n def main(args: Array[String]): Unit = {\n val out = new java.io.PrintWriter(System.out)\n new Main(out, new InputReader(System.in)).solve()\n out.flush()\n }\n\n private[this] val oj = System.getenv(\"MY_DEBUG\") == null\n def DEBUG(f: => Unit): Unit = {\n if (!oj){ f }\n }\n def debug(as: Array[Boolean]): Unit = if (!oj){ debug(as.map(x => if(x) \"1\" else \"0\").mkString) }\n def debug(as: Array[Int]): Unit = if (!oj){ debug(as.mkString(\" \")) }\n def debug(as: Array[Long]): Unit =if (!oj){ debug(as.mkString(\" \")) }\n def debugDim(m: Array[Array[Int]]): Unit = if (!oj){\n REP(m.length) { i =>\n debug(m(i))\n }\n }\n def debugDimFlip(m: Array[Array[Long]]): Unit = if (!oj){\n REP(m(0).length) { j =>\n REP(m.length) { i =>\n System.err.print(m(i)(j))\n System.err.print(\" \")\n }\n System.err.println()\n }\n }\n def debug(s: => String): Unit = {\n if (!oj){ System.err.println(s) }\n }\n def isDebug[A](debug: => A, online: => A): A = {\n if (oj) online else debug\n }\n\n class InputReader(val stream: InputStream) {\n private[this] val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private[this] var tokenizer: StringTokenizer = _\n\n private[this] def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = Integer.parseInt(next())\n def nextLong(): Long = java.lang.Long.parseLong(next())\n def nextChar(): Char = next().charAt(0)\n\n def ni(): Int = nextInt()\n def nl(): Long = nextLong()\n def nc(): Char = nextChar()\n def ns(): String = next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n }\n\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n def TO(from: Int, to: Int)(f: Int => Unit): Unit = {\n REP(to - from + 1, from)(f)\n }\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n def cumSum(as: Array[Int]): Array[Long] = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n\nobject Workspace {\n import Main._\n import java.util.Arrays.sort\n\n import scala.collection.mutable\n import math.{abs, max, min}\n import mutable.ArrayBuffer\n}\n\nclass Main(out: java.io.PrintWriter, sc: Main.InputReader) {\n import sc._\n import Main._\n import java.util.Arrays.sort\n\n import scala.collection.mutable\n import math.{abs, max, min}\n import mutable.ArrayBuffer\n import Workspace._\n\n // toIntとか+7とかするならvalにしろ\n final private[this] val MOD = 1000000007\n\n def solve(): Unit = {\n val N, M = ni()\n val cnt = Array.ofDim[Int](N + 1)\n val flg = Array.ofDim[Boolean](N + 1)\n var success, failure = 0\n REP(M) { _ =>\n val p = ni()\n val s = ns()\n s match {\n case \"AC\" =>\n if (!flg(p)) {\n flg(p) = true\n success += 1\n failure += cnt(p)\n }\n\n case \"WA\" =>\n cnt(p) += 1\n }\n }\n out.println(s\"$success $failure\")\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4257, "cpu_time_ms": 604, "memory_kb": 41584}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s521175738", "group_id": "codeNet:p02803", "input_text": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val H, W = sc.nextInt()\n val A = Array.fill(H)(sc.next())\n\n val M = Array.fill(H * W)(Array.fill(H * W)(Long.MaxValue / 12))\n\n (0 until H * W).foreach(i => M(i)(i) = 0)\n\n (0 until H).foreach(i =>\n (0 until W - 1).foreach(j =>\n if (A(i)(j) == '.' && A(i)(j + 1) == '.') {\n M(H * i + j)(H * i + j + 1) = 1\n M(H * i + j + 1)(H * i + j) = 1\n })\n )\n\n (0 until W).foreach(j =>\n (0 until H - 1).foreach(i =>\n if (A(i)(j) == '.' && A(i + 1)(j) == '.') {\n M(H * i + j)(H * (i + 1) + j) = 1\n M(H * (i + 1) + j)(H * i + j) = 1\n })\n )\n\n (0 until H * W).foreach(k =>\n (0 until H * W).foreach(i =>\n (0 until H * W).foreach(j => {\n M(i)(j) = Math.min(M(i)(j), M(i)(k) + M(k)(j))\n M(j)(i) = M(i)(j)\n }\n )\n )\n )\n println(M.map(x => x.filter(_ != Long.MaxValue / 12).max).max)\n }\n\n val mod: Long = (1e9 + 7).toLong\n\n @scala.annotation.tailrec\n def recursive(N: Long, X: Array[Long], Y: Array[Long], ans: Long): Long = {\n if (X.forall(_ <= N)) ans else recursive(X.dropWhile(_ <= N).head, Y.dropWhile(_ <= N), X.dropWhile(_ <= N), ans + 1)\n }\n\n implicit class implicitInt(val N: Int) {\n def times[B](function: Int => B): IndexedSeq[B] = (0 until N).map(function)\n }\n\n def calc(N: Long): Long = {\n if (N == 0) 0 else if (N % 9 == 0) 9 else N % 9\n }\n\n def time(s: String): Int =\n s.substring(0, 2).toInt * 60 + s.substring(3, 5).toInt\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getFibonacci(prevprev: Long = 0, prev: Long = 1): Stream[Long] =\n Stream.cons(prevprev, getFibonacci(prev, prevprev + prev))\n\n var memo: Map[(Long, Long), Long] = Map[(Long, Long), Long]()\n\n @scala.annotation.tailrec\n def recursive2(X: Set[Long], Y: Stream[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n\n def check(i: Int, X: String): Long = {\n if (X == \"\") 0 else check(i, X.tail) * i + X.head.toString.toLong\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n @scala.annotation.tailrec\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def primeFactors(i: Long): List[Long] = primeFactors_(i, 1).sorted\n\n\n def primeFactors_(i: Long, j: Long): List[Long] = {\n if (j * j > i) List.empty else if (i % j == 0) primeFactors_(i, j + 1) ++ List[Long](j, i / j) else primeFactors_(i, j + 1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n private val codeTable: List[(Int, String)] = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n @scala.annotation.tailrec\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n @scala.annotation.tailrec\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n}\n\nobject PowMod {\n def naivePowMod(a: Long, k: Long, m: Long): Long = {\n var t: Long = 1\n val aMod: Long = a % m\n\n for (_ <- 1L to k) {\n t = ((t % m) * aMod) % m\n }\n t.toInt\n }\n\n def powMod(a: Long, k: Long, m: Long): Long = {\n if (k == 0) 1\n else {\n val t = powMod(a, k / 2, m)\n if ((k % 2) == 0) (t * t) % m else (((t * t) % m) * a) % m\n }\n }\n}", "language": "Scala", "metadata": {"date": 1579008390, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s521175738.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s521175738", "user_id": "u779353743"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val H, W = sc.nextInt()\n val A = Array.fill(H)(sc.next())\n\n val M = Array.fill(H * W)(Array.fill(H * W)(Long.MaxValue / 12))\n\n (0 until H * W).foreach(i => M(i)(i) = 0)\n\n (0 until H).foreach(i =>\n (0 until W - 1).foreach(j =>\n if (A(i)(j) == '.' && A(i)(j + 1) == '.') {\n M(H * i + j)(H * i + j + 1) = 1\n M(H * i + j + 1)(H * i + j) = 1\n })\n )\n\n (0 until W).foreach(j =>\n (0 until H - 1).foreach(i =>\n if (A(i)(j) == '.' && A(i + 1)(j) == '.') {\n M(H * i + j)(H * (i + 1) + j) = 1\n M(H * (i + 1) + j)(H * i + j) = 1\n })\n )\n\n (0 until H * W).foreach(k =>\n (0 until H * W).foreach(i =>\n (0 until H * W).foreach(j => {\n M(i)(j) = Math.min(M(i)(j), M(i)(k) + M(k)(j))\n M(j)(i) = M(i)(j)\n }\n )\n )\n )\n println(M.map(x => x.filter(_ != Long.MaxValue / 12).max).max)\n }\n\n val mod: Long = (1e9 + 7).toLong\n\n @scala.annotation.tailrec\n def recursive(N: Long, X: Array[Long], Y: Array[Long], ans: Long): Long = {\n if (X.forall(_ <= N)) ans else recursive(X.dropWhile(_ <= N).head, Y.dropWhile(_ <= N), X.dropWhile(_ <= N), ans + 1)\n }\n\n implicit class implicitInt(val N: Int) {\n def times[B](function: Int => B): IndexedSeq[B] = (0 until N).map(function)\n }\n\n def calc(N: Long): Long = {\n if (N == 0) 0 else if (N % 9 == 0) 9 else N % 9\n }\n\n def time(s: String): Int =\n s.substring(0, 2).toInt * 60 + s.substring(3, 5).toInt\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getFibonacci(prevprev: Long = 0, prev: Long = 1): Stream[Long] =\n Stream.cons(prevprev, getFibonacci(prev, prevprev + prev))\n\n var memo: Map[(Long, Long), Long] = Map[(Long, Long), Long]()\n\n @scala.annotation.tailrec\n def recursive2(X: Set[Long], Y: Stream[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n\n def check(i: Int, X: String): Long = {\n if (X == \"\") 0 else check(i, X.tail) * i + X.head.toString.toLong\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n @scala.annotation.tailrec\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def primeFactors(i: Long): List[Long] = primeFactors_(i, 1).sorted\n\n\n def primeFactors_(i: Long, j: Long): List[Long] = {\n if (j * j > i) List.empty else if (i % j == 0) primeFactors_(i, j + 1) ++ List[Long](j, i / j) else primeFactors_(i, j + 1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n private val codeTable: List[(Int, String)] = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n @scala.annotation.tailrec\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n @scala.annotation.tailrec\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n}\n\nobject PowMod {\n def naivePowMod(a: Long, k: Long, m: Long): Long = {\n var t: Long = 1\n val aMod: Long = a % m\n\n for (_ <- 1L to k) {\n t = ((t % m) * aMod) % m\n }\n t.toInt\n }\n\n def powMod(a: Long, k: Long, m: Long): Long = {\n if (k == 0) 1\n else {\n val t = powMod(a, k / 2, m)\n if ((k % 2) == 0) (t * t) % m else (((t * t) % m) * a) % m\n }\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 8200, "cpu_time_ms": 1251, "memory_kb": 37216}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s695986508", "group_id": "codeNet:p02804", "input_text": "import java.io.{BufferedReader, InputStreamReader}\n\nimport scala.collection.mutable\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val in = new BufferedReader(new InputStreamReader(System.in))\n val Array(n, k) = in.readLine().split(\"\\\\s+\").map(_.toInt)\n val as = in.readLine().split(\"\\\\s+\").map(_.toLong).sorted\n\n val MOD = 1000000007\n\n val combs = new mutable.HashMap[(Int, Int), Long]()\n\n def comb(n: Int, k: Int): Long = {\n if (n - k < k) {\n comb(n, n - k)\n } else {\n class Node(val n: Int, val k: Int, val parent: Option[Node]) {\n lazy val children: List[Node] = {\n if (k <= 0 || n == k) {\n Nil\n } else {\n List(\n new Node(n - 1, k - 1, Some(this)),\n new Node(n - 1, k, Some(this))\n )\n }\n }\n var c: Option[Long] = None\n }\n\n def inner(root: Node): Node = {\n var node: Node = root\n\n while (node != null) {\n val n = node.n\n val k = node.k\n\n combs.get((n, k)) match {\n case Some(c) =>\n node.c = Some(c)\n node.parent match {\n case Some(p) => node = p\n case None => node = null\n }\n case None =>\n if (node.children.isEmpty) {\n node.c = Some(1)\n combs.update((n, k), node.c.get)\n node.parent match {\n case Some(p) => node = p\n case None => node = null\n }\n } else {\n node.children.find { child =>\n child.c.isEmpty\n } match {\n case Some(unresolvedChild) =>\n node = unresolvedChild\n case None =>\n node.c = Some(node.children.map(_.c).foldLeft(0L) {\n case (sum, Some(c)) => (sum + c) % MOD\n case _ => throw new Exception()\n })\n combs.update((n, k), node.c.get)\n node.parent match {\n case Some(p) =>\n node = p\n case None =>\n node = null\n }\n }\n }\n }\n }\n\n root\n }\n\n inner(new Node(n, k, None)).c.get\n }\n }\n\n var sum = 0L\n\n for {\n s <- 0 to (n - k)\n e <- (s + k - 1) until n\n } {\n sum = (sum + ((as(e) - as(s)) % MOD * comb(e - s - 1, k - 2)) % MOD) % MOD\n }\n\n System.out.println(sum)\n }\n}\n", "language": "Scala", "metadata": {"date": 1578938722, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s695986508.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s695986508", "user_id": "u178269371"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "import java.io.{BufferedReader, InputStreamReader}\n\nimport scala.collection.mutable\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val in = new BufferedReader(new InputStreamReader(System.in))\n val Array(n, k) = in.readLine().split(\"\\\\s+\").map(_.toInt)\n val as = in.readLine().split(\"\\\\s+\").map(_.toLong).sorted\n\n val MOD = 1000000007\n\n val combs = new mutable.HashMap[(Int, Int), Long]()\n\n def comb(n: Int, k: Int): Long = {\n if (n - k < k) {\n comb(n, n - k)\n } else {\n class Node(val n: Int, val k: Int, val parent: Option[Node]) {\n lazy val children: List[Node] = {\n if (k <= 0 || n == k) {\n Nil\n } else {\n List(\n new Node(n - 1, k - 1, Some(this)),\n new Node(n - 1, k, Some(this))\n )\n }\n }\n var c: Option[Long] = None\n }\n\n def inner(root: Node): Node = {\n var node: Node = root\n\n while (node != null) {\n val n = node.n\n val k = node.k\n\n combs.get((n, k)) match {\n case Some(c) =>\n node.c = Some(c)\n node.parent match {\n case Some(p) => node = p\n case None => node = null\n }\n case None =>\n if (node.children.isEmpty) {\n node.c = Some(1)\n combs.update((n, k), node.c.get)\n node.parent match {\n case Some(p) => node = p\n case None => node = null\n }\n } else {\n node.children.find { child =>\n child.c.isEmpty\n } match {\n case Some(unresolvedChild) =>\n node = unresolvedChild\n case None =>\n node.c = Some(node.children.map(_.c).foldLeft(0L) {\n case (sum, Some(c)) => (sum + c) % MOD\n case _ => throw new Exception()\n })\n combs.update((n, k), node.c.get)\n node.parent match {\n case Some(p) =>\n node = p\n case None =>\n node = null\n }\n }\n }\n }\n }\n\n root\n }\n\n inner(new Node(n, k, None)).c.get\n }\n }\n\n var sum = 0L\n\n for {\n s <- 0 to (n - k)\n e <- (s + k - 1) until n\n } {\n sum = (sum + ((as(e) - as(s)) % MOD * comb(e - s - 1, k - 2)) % MOD) % MOD\n }\n\n System.out.println(sum)\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2738, "cpu_time_ms": 2119, "memory_kb": 188564}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s816930233", "group_id": "codeNet:p02806", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val playList = List.fill(sc.nextInt())(sc.next() -> sc.nextInt())\n val sleepySong = sc.next()\n val _ :: xs = playList.dropWhile(_._1 != sleepySong)\n println(xs.map(_._2).sum)\n}\n", "language": "Scala", "metadata": {"date": 1596379180, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s816930233.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s816930233", "user_id": "u737111725"}, "prompt_components": {"gold_output": "30\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val playList = List.fill(sc.nextInt())(sc.next() -> sc.nextInt())\n val sleepySong = sc.next()\n val _ :: xs = playList.dropWhile(_._1 != sleepySong)\n println(xs.map(_._2).sum)\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 252, "cpu_time_ms": 516, "memory_kb": 55592}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s601067034", "group_id": "codeNet:p02811", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n solve\n }\n\n def solve(): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n, x = sc.nextInt\n\n val result =\n if (500 * n >= x) {\n \"Yes\"\n } else {\n \"No\"\n }\n\n println(result)\n }\n}\n", "language": "Scala", "metadata": {"date": 1578708258, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s601067034.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s601067034", "user_id": "u433254839"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n solve\n }\n\n def solve(): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n, x = sc.nextInt\n\n val result =\n if (500 * n >= x) {\n \"Yes\"\n } else {\n \"No\"\n }\n\n println(result)\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 288, "cpu_time_ms": 358, "memory_kb": 25900}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s348362599", "group_id": "codeNet:p02812", "input_text": "import java.security.KeyStore.TrustedCertificateEntry\nimport java.util\nimport java.util.{ArrayList, Collections, Comparator, List => JList}\nimport scala.math._\n\nimport scala.collection.mutable\nimport scala.collection.mutable.{ArrayBuffer, ListBuffer}\nimport scala.util.{Failure, Success, Try}\n\nobject Main{\n val LINE_SEPARATOR = \"\\n\"\n def main(args: Array[String]): Unit = {\n if (sys.env.getOrElse(\"TEST\", \"\")==\"1\"){\n println(test());\n }else{\n val input=io.Source.stdin.getLines().mkString(LINE_SEPARATOR);\n println(solve(input).trim());\n }\n }\n\n def init (nRows: Int, nCols: Int, default: Int) = Array.tabulate(nRows,nCols)( (x,y) => default)\n\n def sortIgnoreCase1(list: JList[String]): JList[String] = {\n val r = new ArrayList[String](list)\n Collections.sort(r, new Comparator[String] {\n override def compare(o1: String, o2: String): Int = o1.compareToIgnoreCase(o2)\n })\n r\n }\n\n def solve(input: String): String = {\n val n = input.split(LINE_SEPARATOR).head.toInt\n val s = input.split(LINE_SEPARATOR).tail.head\n s.split(\"\").sliding(3).map(_.toVector).count(_ == Vector(\"A\", \"B\", \"C\")).toString\n }\n\n def gcd(m: Long, n: Long): Long = n match {\n case 0 => m\n case _ => gcd(n, m % n)\n }\n def lcm(a: Long, b: Long): Long = a * b / gcd(a, b)\n\n val tests=List(\n \"\"\"10\n |ZABCDBABCQ\"\"\".stripMargin -> \"\"\"2\n |\n |\n |\"\"\".stripMargin,\n \"\"\"19\n |THREEONEFOURONEFIVE\"\"\".stripMargin -> \"\"\"0\n |\n |\"\"\".stripMargin,\n \"\"\"33\n |ABCCABCBABCCABACBCBBABCBCBCBCABCB\"\"\".stripMargin -> \"5\"\n )\n\n def test():String= {\n return tests.map{case (i,o)=>(i.trim(),o.trim())}\n .zipWithIndex.map{\n case ((input,outputExpect),i)=>{\n val output=solve(input).trim();\n s\"test${i+1}:\"+(if(output==outputExpect){\n \"Passed\"\n }else{\n s\"Failed\\nexpect:\\n${outputExpect}\\noutput:\\n${output}\"\n })\n }}\n .mkString(\"\\n\");\n }\n}", "language": "Scala", "metadata": {"date": 1590712595, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s348362599.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s348362599", "user_id": "u114537090"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.security.KeyStore.TrustedCertificateEntry\nimport java.util\nimport java.util.{ArrayList, Collections, Comparator, List => JList}\nimport scala.math._\n\nimport scala.collection.mutable\nimport scala.collection.mutable.{ArrayBuffer, ListBuffer}\nimport scala.util.{Failure, Success, Try}\n\nobject Main{\n val LINE_SEPARATOR = \"\\n\"\n def main(args: Array[String]): Unit = {\n if (sys.env.getOrElse(\"TEST\", \"\")==\"1\"){\n println(test());\n }else{\n val input=io.Source.stdin.getLines().mkString(LINE_SEPARATOR);\n println(solve(input).trim());\n }\n }\n\n def init (nRows: Int, nCols: Int, default: Int) = Array.tabulate(nRows,nCols)( (x,y) => default)\n\n def sortIgnoreCase1(list: JList[String]): JList[String] = {\n val r = new ArrayList[String](list)\n Collections.sort(r, new Comparator[String] {\n override def compare(o1: String, o2: String): Int = o1.compareToIgnoreCase(o2)\n })\n r\n }\n\n def solve(input: String): String = {\n val n = input.split(LINE_SEPARATOR).head.toInt\n val s = input.split(LINE_SEPARATOR).tail.head\n s.split(\"\").sliding(3).map(_.toVector).count(_ == Vector(\"A\", \"B\", \"C\")).toString\n }\n\n def gcd(m: Long, n: Long): Long = n match {\n case 0 => m\n case _ => gcd(n, m % n)\n }\n def lcm(a: Long, b: Long): Long = a * b / gcd(a, b)\n\n val tests=List(\n \"\"\"10\n |ZABCDBABCQ\"\"\".stripMargin -> \"\"\"2\n |\n |\n |\"\"\".stripMargin,\n \"\"\"19\n |THREEONEFOURONEFIVE\"\"\".stripMargin -> \"\"\"0\n |\n |\"\"\".stripMargin,\n \"\"\"33\n |ABCCABCBABCCABACBCBBABCBCBCBCABCB\"\"\".stripMargin -> \"5\"\n )\n\n def test():String= {\n return tests.map{case (i,o)=>(i.trim(),o.trim())}\n .zipWithIndex.map{\n case ((input,outputExpect),i)=>{\n val output=solve(input).trim();\n s\"test${i+1}:\"+(if(output==outputExpect){\n \"Passed\"\n }else{\n s\"Failed\\nexpect:\\n${outputExpect}\\noutput:\\n${output}\"\n })\n }}\n .mkString(\"\\n\");\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2123, "cpu_time_ms": 335, "memory_kb": 27324}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s194827384", "group_id": "codeNet:p02813", "input_text": "object Main extends App {\n import scala.math.abs\n \n val n = (1 to readInt).permutations.toList.map{_.mkString}\n val p = readLine.split(\" \").mkString\n val q = readLine.split(\" \").mkString\n \n println(abs(n.indexOf(p)-n.indexOf(q)))\n}", "language": "Scala", "metadata": {"date": 1578968836, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s194827384.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s194827384", "user_id": "u696665136"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main extends App {\n import scala.math.abs\n \n val n = (1 to readInt).permutations.toList.map{_.mkString}\n val p = readLine.split(\" \").mkString\n val q = readLine.split(\" \").mkString\n \n println(abs(n.indexOf(p)-n.indexOf(q)))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 799, "memory_kb": 61484}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s197191435", "group_id": "codeNet:p02817", "input_text": "import io.StdIn._\n\nobject Main extends App {\n println(readLine.split(\" \").reduceRight((s,b) => b + s))\n}\n", "language": "Scala", "metadata": {"date": 1579894313, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s197191435.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s197191435", "user_id": "u518641666"}, "prompt_components": {"gold_output": "atcoder\n", "input_to_evaluate": "import io.StdIn._\n\nobject Main extends App {\n println(readLine.split(\" \").reduceRight((s,b) => b + s))\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 319, "memory_kb": 25548}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s948896535", "group_id": "codeNet:p02817", "input_text": "object Main extends App {\n val s = readLine().split(' ').reverse.mkString\n println(s)\n}", "language": "Scala", "metadata": {"date": 1578365744, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s948896535.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s948896535", "user_id": "u199877973"}, "prompt_components": {"gold_output": "atcoder\n", "input_to_evaluate": "object Main extends App {\n val s = readLine().split(' ').reverse.mkString\n println(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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 324, "memory_kb": 25264}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s675566611", "group_id": "codeNet:p02817", "input_text": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val t = sc.nextLine().split(\" \")\n\n println(t.reverse.mkString)\n }\n\n}", "language": "Scala", "metadata": {"date": 1577669851, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s675566611.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s675566611", "user_id": "u891387249"}, "prompt_components": {"gold_output": "atcoder\n", "input_to_evaluate": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val t = sc.nextLine().split(\" \")\n\n println(t.reverse.mkString)\n }\n\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 180, "cpu_time_ms": 346, "memory_kb": 25664}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s273406262", "group_id": "codeNet:p02819", "input_text": "import scala.io.StdIn.readInt\n\nobject Main extends App {\n val x = readInt()\n lazy val ys = 2 to (x / 2)\n \n def findPrime(x: Int): Int = {\n if (ys.exists(y => x % y == 0))\n findPrime(x + 1)\n else\n x\n }\n \n println(findPrime(x))\n}", "language": "Scala", "metadata": {"date": 1595886978, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s273406262.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s273406262", "user_id": "u598844232"}, "prompt_components": {"gold_output": "23\n", "input_to_evaluate": "import scala.io.StdIn.readInt\n\nobject Main extends App {\n val x = readInt()\n lazy val ys = 2 to (x / 2)\n \n def findPrime(x: Int): Int = {\n if (ys.exists(y => x % y == 0))\n findPrime(x + 1)\n else\n x\n }\n \n println(findPrime(x))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 250, "cpu_time_ms": 489, "memory_kb": 54780}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s264358125", "group_id": "codeNet:p02819", "input_text": "object Main extends App {\n import io.StdIn._\n val x = readLine().toInt\n var primesUnderX: List[Int] = List.empty\n for (i <- 2 to x - 1) {\n if (!primesUnderX.exists(p => i % p == 0)) {\n primesUnderX = i :: primesUnderX\n }\n }\n var ans = x\n while (primesUnderX.exists(p => ans % p == 0)) {\n ans += 1\n }\n\n println(ans)\n}\n", "language": "Scala", "metadata": {"date": 1577898722, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s264358125.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s264358125", "user_id": "u114412102"}, "prompt_components": {"gold_output": "23\n", "input_to_evaluate": "object Main extends App {\n import io.StdIn._\n val x = readLine().toInt\n var primesUnderX: List[Int] = List.empty\n for (i <- 2 to x - 1) {\n if (!primesUnderX.exists(p => i % p == 0)) {\n primesUnderX = i :: primesUnderX\n }\n }\n var ans = x\n while (primesUnderX.exists(p => ans % p == 0)) {\n ans += 1\n }\n\n println(ans)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 340, "cpu_time_ms": 2111, "memory_kb": 25852}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s434937901", "group_id": "codeNet:p02820", "input_text": "object Main extends App {\n val Array(n,k) = readLine.split(\" \").map(_.toInt)\n val Array(r,s,p) = readLine.split(\" \").map(_.toInt)\n val youList = readLine.split(\"\").filter(_.nonEmpty).zipWithIndex\n var meList = scala.collection.mutable.Seq[Int]()\n \n youList.foreach {case (e, index) =>\n if (e == \"r\")\n \tif (index >= k && meList(index - k) == p) meList = meList :+ 0\n \telse meList = meList :+ p\n else if (e == \"s\")\n \tif (index >= k && meList(index - k) == r) meList = meList :+ 0\n \telse meList = meList :+ r\n else if (e == \"p\")\n \tif (index >= k && meList(index - k) == s) meList = meList :+ 0\n \telse meList = meList :+ s\n } \n println(meList.sum)\n}", "language": "Scala", "metadata": {"date": 1578699418, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02820.html", "problem_id": "p02820", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02820/input.txt", "sample_output_relpath": "derived/input_output/data/p02820/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02820/Scala/s434937901.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s434937901", "user_id": "u715268393"}, "prompt_components": {"gold_output": "27\n", "input_to_evaluate": "object Main extends App {\n val Array(n,k) = readLine.split(\" \").map(_.toInt)\n val Array(r,s,p) = readLine.split(\" \").map(_.toInt)\n val youList = readLine.split(\"\").filter(_.nonEmpty).zipWithIndex\n var meList = scala.collection.mutable.Seq[Int]()\n \n youList.foreach {case (e, index) =>\n if (e == \"r\")\n \tif (index >= k && meList(index - k) == p) meList = meList :+ 0\n \telse meList = meList :+ p\n else if (e == \"s\")\n \tif (index >= k && meList(index - k) == r) meList = meList :+ 0\n \telse meList = meList :+ r\n else if (e == \"p\")\n \tif (index >= k && meList(index - k) == s) meList = meList :+ 0\n \telse meList = meList :+ s\n } \n println(meList.sum)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nAt an arcade, Takahashi is playing a game called RPS Battle, which is played as follows:\n\nThe player plays N rounds of Rock Paper Scissors against the machine. (See Notes for the description of Rock Paper Scissors. A draw also counts as a round.)\n\nEach time the player wins a round, depending on which hand he/she uses, he/she earns the following score (no points for a draw or a loss):\n\nR points for winning with Rock;\n\nS points for winning with Scissors;\n\nP points for winning with Paper.\n\nHowever, in the i-th round, the player cannot use the hand he/she used in the (i-K)-th round. (In the first K rounds, the player can use any hand.)\n\nBefore the start of the game, the machine decides the hand it will play in each round. With supernatural power, Takahashi managed to read all of those hands.\n\nThe information Takahashi obtained is given as a string T. If the i-th character of T (1 \\leq i \\leq N) is r, the machine will play Rock in the i-th round. Similarly, p and s stand for Paper and Scissors, respectively.\n\nWhat is the maximum total score earned in the game by adequately choosing the hand to play in each round?\n\nNotes\n\nIn this problem, Rock Paper Scissors can be thought of as a two-player game, in which each player simultaneously forms Rock, Paper, or Scissors with a hand.\n\nIf a player chooses Rock and the other chooses Scissors, the player choosing Rock wins;\n\nif a player chooses Scissors and the other chooses Paper, the player choosing Scissors wins;\n\nif a player chooses Paper and the other chooses Rock, the player choosing Paper wins;\n\nif both players play the same hand, it is a draw.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq K \\leq N-1\n\n1 \\leq R,S,P \\leq 10^4\n\nN,K,R,S, and P are all integers.\n\n|T| = N\n\nT consists of r, p, and s.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nR S P\nT\n\nOutput\n\nPrint the maximum total score earned in the game.\n\nSample Input 1\n\n5 2\n8 7 6\nrsrpr\n\nSample Output 1\n\n27\n\nThe machine will play {Rock, Scissors, Rock, Paper, Rock}.\n\nWe can, for example, play {Paper, Rock, Rock, Scissors, Paper} against it to earn 27 points.\nWe cannot earn more points, so the answer is 27.\n\nSample Input 2\n\n7 1\n100 10 1\nssssppr\n\nSample Output 2\n\n211\n\nSample Input 3\n\n30 5\n325 234 123\nrspsspspsrpspsppprpsprpssprpsr\n\nSample Output 3\n\n4996", "sample_input": "5 2\n8 7 6\nrsrpr\n"}, "reference_outputs": ["27\n"], "source_document_id": "p02820", "source_text": "Score : 400 points\n\nProblem Statement\n\nAt an arcade, Takahashi is playing a game called RPS Battle, which is played as follows:\n\nThe player plays N rounds of Rock Paper Scissors against the machine. (See Notes for the description of Rock Paper Scissors. A draw also counts as a round.)\n\nEach time the player wins a round, depending on which hand he/she uses, he/she earns the following score (no points for a draw or a loss):\n\nR points for winning with Rock;\n\nS points for winning with Scissors;\n\nP points for winning with Paper.\n\nHowever, in the i-th round, the player cannot use the hand he/she used in the (i-K)-th round. (In the first K rounds, the player can use any hand.)\n\nBefore the start of the game, the machine decides the hand it will play in each round. With supernatural power, Takahashi managed to read all of those hands.\n\nThe information Takahashi obtained is given as a string T. If the i-th character of T (1 \\leq i \\leq N) is r, the machine will play Rock in the i-th round. Similarly, p and s stand for Paper and Scissors, respectively.\n\nWhat is the maximum total score earned in the game by adequately choosing the hand to play in each round?\n\nNotes\n\nIn this problem, Rock Paper Scissors can be thought of as a two-player game, in which each player simultaneously forms Rock, Paper, or Scissors with a hand.\n\nIf a player chooses Rock and the other chooses Scissors, the player choosing Rock wins;\n\nif a player chooses Scissors and the other chooses Paper, the player choosing Scissors wins;\n\nif a player chooses Paper and the other chooses Rock, the player choosing Paper wins;\n\nif both players play the same hand, it is a draw.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq K \\leq N-1\n\n1 \\leq R,S,P \\leq 10^4\n\nN,K,R,S, and P are all integers.\n\n|T| = N\n\nT consists of r, p, and s.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nR S P\nT\n\nOutput\n\nPrint the maximum total score earned in the game.\n\nSample Input 1\n\n5 2\n8 7 6\nrsrpr\n\nSample Output 1\n\n27\n\nThe machine will play {Rock, Scissors, Rock, Paper, Rock}.\n\nWe can, for example, play {Paper, Rock, Rock, Scissors, Paper} against it to earn 27 points.\nWe cannot earn more points, so the answer is 27.\n\nSample Input 2\n\n7 1\n100 10 1\nssssppr\n\nSample Output 2\n\n211\n\nSample Input 3\n\n30 5\n325 234 123\nrspsspspsrpspsppprpsprpssprpsr\n\nSample Output 3\n\n4996", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 129612}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s449798898", "group_id": "codeNet:p02830", "input_text": "import java.io.{BufferedReader, InputStreamReader}\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val in = new BufferedReader(new InputStreamReader(System.in))\n val n = in.readLine().toInt\n val Array(s, t) = in.readLine().split(\"\\\\s+\")\n\n System.out.println(\n s.toCharArray.zip(t.toCharArray).flatMap {\n case (a, b) => \"\" + a + b\n }\n )\n }\n}\n", "language": "Scala", "metadata": {"date": 1577066925, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s449798898.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s449798898", "user_id": "u178269371"}, "prompt_components": {"gold_output": "icpc\n", "input_to_evaluate": "import java.io.{BufferedReader, InputStreamReader}\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val in = new BufferedReader(new InputStreamReader(System.in))\n val n = in.readLine().toInt\n val Array(s, t) = in.readLine().split(\"\\\\s+\")\n\n System.out.println(\n s.toCharArray.zip(t.toCharArray).flatMap {\n case (a, b) => \"\" + a + b\n }\n )\n }\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 346, "memory_kb": 27308}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s773294766", "group_id": "codeNet:p02835", "input_text": "import java.io.PrintWriter\n\nobject Loop {\n @inline def rep(n: Int, f: => Unit): Unit = { var c = 0; while (c < n) { f; c += 1 } }\n @inline def rep(n: Int, f: Int => Unit): Unit = { var c = 0; while (c < n) { f(c); c += 1 } }\n\n @inline def breakAble(n: Int, m: Int, f: Int => Boolean): Unit = if (f(n) && n < m) breakAble(n + 1, m, f)\n @inline def !(n: Int): Int = (1 + n) * n / 2\n}\nobject Mod {\n def create(n: Int, mod: Int) = Mod(n, mod)\n}\ncase class Mod(n: Int, mod: Int) {\n val factorial: Array[Int] = Array.fill[Int](n + 1)(1)\n val inverse: Array[Int] = Array.fill[Int](n + 1)(1)\n val inverseFactorial: Array[Int] = Array.fill[Int](n + 1)(1)\n Loop.rep(n - 1, i => {\n val k = i + 2\n factorial(k) = modMultiplyExact(factorial(k - 1), k, mod)\n inverse(k) = modMultiplyExact(inverse(mod % k), mod - (mod / k): Int, mod)\n inverseFactorial(k) = modMultiplyExact(inverseFactorial(k - 1), inverse(k), mod)\n })\n def getFactorial(n: Int): Int = factorial(n)\n def getInverse(n: Int): Int = inverse(n)\n def getInverseFactorial(n: Int): Int = inverseFactorial(n)\n def C(n: Int, k: Int): Int = {\n if (n <= 0 || k < 0 || k > n) 0 else if (k == 0 || k == n) 1 else {\n modMultiplyExact(\n getFactorial(n),\n getInverseFactorial(n - k),\n getInverseFactorial(k),\n mod\n )\n }\n }\n def modMultiplyExact(a: Int, b: Int, m: Int): Int =\n ((a.toLong * b.toLong) % m).toInt\n def modMultiplyExact(a: Int, b: Int, c: Int, m: Int): Int =\n modMultiplyExact(a, modMultiplyExact(b, c, m), m)\n}\nobject Scanner {\n private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0\n @inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126\n @inline private def hasNextByte(): Boolean =\n if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else { true }\n @inline private def hasNext(): Boolean = {\n while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1\n hasNextByte()\n }\n @inline private def readByte(): Byte =\n if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else { -1 }\n def next(): String = {\n if(!hasNext()) ???\n val sb = new StringBuilder; var b = readByte()\n while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }\n sb.toString\n }\n def nextInt(): Int = {\n val n = nextLong()\n if (n < Int.MinValue || Int.MaxValue < n) ???\n n.toInt\n }\n def nextLong(): Long = {\n if(!hasNext()) ???\n var minus = false; var b = readByte()\n if (b == '-') { minus = true; b = readByte() }\n def go (b: Byte, n: Long = 0): Long =\n if ('0' <= b && b <= '9') { go(readByte(), n * 10 + b - '0') }\n else if (minus) { -n } else { n }\n go(b)\n }\n def nextDouble(): Double = next.toDouble\n\n def print(f:PrintWriter => Unit): Unit = {\n val pw: PrintWriter = new java.io.PrintWriter(System.out)\n //pw.println(\"\")\n f(pw)\n pw.flush()\n }\n}\n////////////////////////////////////////\n//\n////////////////////////////////////////\nobject Main extends App {\n\n val a, b, c = Scanner.nextInt()\n val sum = a + b + c\n if (sum >= 22) print(\"bust\") else print(\"win\")\n\n}", "language": "Scala", "metadata": {"date": 1575857655, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s773294766.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s773294766", "user_id": "u817495853"}, "prompt_components": {"gold_output": "win\n", "input_to_evaluate": "import java.io.PrintWriter\n\nobject Loop {\n @inline def rep(n: Int, f: => Unit): Unit = { var c = 0; while (c < n) { f; c += 1 } }\n @inline def rep(n: Int, f: Int => Unit): Unit = { var c = 0; while (c < n) { f(c); c += 1 } }\n\n @inline def breakAble(n: Int, m: Int, f: Int => Boolean): Unit = if (f(n) && n < m) breakAble(n + 1, m, f)\n @inline def !(n: Int): Int = (1 + n) * n / 2\n}\nobject Mod {\n def create(n: Int, mod: Int) = Mod(n, mod)\n}\ncase class Mod(n: Int, mod: Int) {\n val factorial: Array[Int] = Array.fill[Int](n + 1)(1)\n val inverse: Array[Int] = Array.fill[Int](n + 1)(1)\n val inverseFactorial: Array[Int] = Array.fill[Int](n + 1)(1)\n Loop.rep(n - 1, i => {\n val k = i + 2\n factorial(k) = modMultiplyExact(factorial(k - 1), k, mod)\n inverse(k) = modMultiplyExact(inverse(mod % k), mod - (mod / k): Int, mod)\n inverseFactorial(k) = modMultiplyExact(inverseFactorial(k - 1), inverse(k), mod)\n })\n def getFactorial(n: Int): Int = factorial(n)\n def getInverse(n: Int): Int = inverse(n)\n def getInverseFactorial(n: Int): Int = inverseFactorial(n)\n def C(n: Int, k: Int): Int = {\n if (n <= 0 || k < 0 || k > n) 0 else if (k == 0 || k == n) 1 else {\n modMultiplyExact(\n getFactorial(n),\n getInverseFactorial(n - k),\n getInverseFactorial(k),\n mod\n )\n }\n }\n def modMultiplyExact(a: Int, b: Int, m: Int): Int =\n ((a.toLong * b.toLong) % m).toInt\n def modMultiplyExact(a: Int, b: Int, c: Int, m: Int): Int =\n modMultiplyExact(a, modMultiplyExact(b, c, m), m)\n}\nobject Scanner {\n private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0\n @inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126\n @inline private def hasNextByte(): Boolean =\n if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else { true }\n @inline private def hasNext(): Boolean = {\n while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1\n hasNextByte()\n }\n @inline private def readByte(): Byte =\n if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else { -1 }\n def next(): String = {\n if(!hasNext()) ???\n val sb = new StringBuilder; var b = readByte()\n while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }\n sb.toString\n }\n def nextInt(): Int = {\n val n = nextLong()\n if (n < Int.MinValue || Int.MaxValue < n) ???\n n.toInt\n }\n def nextLong(): Long = {\n if(!hasNext()) ???\n var minus = false; var b = readByte()\n if (b == '-') { minus = true; b = readByte() }\n def go (b: Byte, n: Long = 0): Long =\n if ('0' <= b && b <= '9') { go(readByte(), n * 10 + b - '0') }\n else if (minus) { -n } else { n }\n go(b)\n }\n def nextDouble(): Double = next.toDouble\n\n def print(f:PrintWriter => Unit): Unit = {\n val pw: PrintWriter = new java.io.PrintWriter(System.out)\n //pw.println(\"\")\n f(pw)\n pw.flush()\n }\n}\n////////////////////////////////////////\n//\n////////////////////////////////////////\nobject Main extends App {\n\n val a, b, c = Scanner.nextInt()\n val sum = a + b + c\n if (sum >= 22) print(\"bust\") else print(\"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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3128, "cpu_time_ms": 324, "memory_kb": 25496}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s192126364", "group_id": "codeNet:p02835", "input_text": "object Main extends App {\n val Array(a1, a2, a3) = io.StdIn.readLine().split(' ').map(_.toInt)\n println(if (a1+a2+a3 > 21) \"bust\" else \"win\")\n}", "language": "Scala", "metadata": {"date": 1575856915, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s192126364.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s192126364", "user_id": "u269739894"}, "prompt_components": {"gold_output": "win\n", "input_to_evaluate": "object Main extends App {\n val Array(a1, a2, a3) = io.StdIn.readLine().split(' ').map(_.toInt)\n println(if (a1+a2+a3 > 21) \"bust\" else \"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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 145, "cpu_time_ms": 330, "memory_kb": 27320}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s663304337", "group_id": "codeNet:p02836", "input_text": "import java.util.Scanner\nobject Main extends App {\n val sc = new Scanner(System.in)\n val s = sc.next\n println(s.take(s.size / 2).zip(s.reverse).count(x => x._1 != x._2))\n}", "language": "Scala", "metadata": {"date": 1575995219, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02836.html", "problem_id": "p02836", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02836/input.txt", "sample_output_relpath": "derived/input_output/data/p02836/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02836/Scala/s663304337.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s663304337", "user_id": "u132324749"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.Scanner\nobject Main extends App {\n val sc = new Scanner(System.in)\n val s = sc.next\n println(s.take(s.size / 2).zip(s.reverse).count(x => x._1 != x._2))\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves palindromes. Non-palindromic strings are unacceptable to him. Each time he hugs a string, he can change one of its characters to any character of his choice.\n\nGiven is a string S. Find the minimum number of hugs needed to make S palindromic.\n\nConstraints\n\nS is a string consisting of lowercase English letters.\n\nThe length of S is between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum number of hugs needed to make S palindromic.\n\nSample Input 1\n\nredcoder\n\nSample Output 1\n\n1\n\nFor example, we can change the fourth character to o and get a palindrome redooder.\n\nSample Input 2\n\nvvvvvv\n\nSample Output 2\n\n0\n\nWe might need no hugs at all.\n\nSample Input 3\n\nabcdabc\n\nSample Output 3\n\n2", "sample_input": "redcoder\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02836", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves palindromes. Non-palindromic strings are unacceptable to him. Each time he hugs a string, he can change one of its characters to any character of his choice.\n\nGiven is a string S. Find the minimum number of hugs needed to make S palindromic.\n\nConstraints\n\nS is a string consisting of lowercase English letters.\n\nThe length of S is between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum number of hugs needed to make S palindromic.\n\nSample Input 1\n\nredcoder\n\nSample Output 1\n\n1\n\nFor example, we can change the fourth character to o and get a palindrome redooder.\n\nSample Input 2\n\nvvvvvv\n\nSample Output 2\n\n0\n\nWe might need no hugs at all.\n\nSample Input 3\n\nabcdabc\n\nSample Output 3\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 343, "memory_kb": 27316}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s455974253", "group_id": "codeNet:p02837", "input_text": "import java.io.{BufferedReader, InputStreamReader}\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val in = new BufferedReader(new InputStreamReader(System.in))\n val n = in.readLine().toInt\n\n val evs =\n (0 until n).map { _ =>\n val a = in.readLine().toInt\n (0 until a).map { _ =>\n in.readLine().split(\"\\\\s+\").map(_.toInt) match {\n case Array(x, y) => Array(x - 1, y)\n }\n }\n }\n\n System.out.println(\n (0 until (1 << n)).map { i =>\n if (evs.zipWithIndex.filter {\n case (ev, evIndex) => ((i >> evIndex) & 1) == 1\n }.forall {\n case (ev, evIndex) =>\n ev.forall { e =>\n ((i >> e(0)) & 1) == e(1)\n }\n }) {\n countBit(i)\n } else {\n 0\n }\n }.max\n )\n }\n\n def countBit(n: Int): Int = {\n if (n == 0) {\n 0\n } else {\n countBit(n / 2) + n % 2\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1575865737, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02837.html", "problem_id": "p02837", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02837/input.txt", "sample_output_relpath": "derived/input_output/data/p02837/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02837/Scala/s455974253.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s455974253", "user_id": "u178269371"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.{BufferedReader, InputStreamReader}\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val in = new BufferedReader(new InputStreamReader(System.in))\n val n = in.readLine().toInt\n\n val evs =\n (0 until n).map { _ =>\n val a = in.readLine().toInt\n (0 until a).map { _ =>\n in.readLine().split(\"\\\\s+\").map(_.toInt) match {\n case Array(x, y) => Array(x - 1, y)\n }\n }\n }\n\n System.out.println(\n (0 until (1 << n)).map { i =>\n if (evs.zipWithIndex.filter {\n case (ev, evIndex) => ((i >> evIndex) & 1) == 1\n }.forall {\n case (ev, evIndex) =>\n ev.forall { e =>\n ((i >> e(0)) & 1) == e(1)\n }\n }) {\n countBit(i)\n } else {\n 0\n }\n }.max\n )\n }\n\n def countBit(n: Int): Int = {\n if (n == 0) {\n 0\n } else {\n countBit(n / 2) + n % 2\n }\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N people numbered 1 to N. Each of them is either an honest person whose testimonies are always correct or an unkind person whose testimonies may be correct or not.\n\nPerson i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.\n\nHow many honest persons can be among those N people at most?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 15\n\n0 \\leq A_i \\leq N - 1\n\n1 \\leq x_{ij} \\leq N\n\nx_{ij} \\neq i\n\nx_{ij_1} \\neq x_{ij_2} (j_1 \\neq j_2)\n\ny_{ij} = 0, 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\nx_{11} y_{11}\nx_{12} y_{12}\n:\nx_{1A_1} y_{1A_1}\nA_2\nx_{21} y_{21}\nx_{22} y_{22}\n:\nx_{2A_2} y_{2A_2}\n:\nA_N\nx_{N1} y_{N1}\nx_{N2} y_{N2}\n:\nx_{NA_N} y_{NA_N}\n\nOutput\n\nPrint the maximum possible number of honest persons among the N people.\n\nSample Input 1\n\n3\n1\n2 1\n1\n1 1\n1\n2 0\n\nSample Output 1\n\n2\n\nIf Person 1 and Person 2 are honest and Person 3 is unkind, we have two honest persons without inconsistencies, which is the maximum possible number of honest persons.\n\nSample Input 2\n\n3\n2\n2 1\n3 0\n2\n3 1\n1 0\n2\n1 1\n2 0\n\nSample Output 2\n\n0\n\nAssuming that one or more of them are honest immediately leads to a contradiction.\n\nSample Input 3\n\n2\n1\n2 0\n1\n1 0\n\nSample Output 3\n\n1", "sample_input": "3\n1\n2 1\n1\n1 1\n1\n2 0\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02837", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N people numbered 1 to N. Each of them is either an honest person whose testimonies are always correct or an unkind person whose testimonies may be correct or not.\n\nPerson i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.\n\nHow many honest persons can be among those N people at most?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 15\n\n0 \\leq A_i \\leq N - 1\n\n1 \\leq x_{ij} \\leq N\n\nx_{ij} \\neq i\n\nx_{ij_1} \\neq x_{ij_2} (j_1 \\neq j_2)\n\ny_{ij} = 0, 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\nx_{11} y_{11}\nx_{12} y_{12}\n:\nx_{1A_1} y_{1A_1}\nA_2\nx_{21} y_{21}\nx_{22} y_{22}\n:\nx_{2A_2} y_{2A_2}\n:\nA_N\nx_{N1} y_{N1}\nx_{N2} y_{N2}\n:\nx_{NA_N} y_{NA_N}\n\nOutput\n\nPrint the maximum possible number of honest persons among the N people.\n\nSample Input 1\n\n3\n1\n2 1\n1\n1 1\n1\n2 0\n\nSample Output 1\n\n2\n\nIf Person 1 and Person 2 are honest and Person 3 is unkind, we have two honest persons without inconsistencies, which is the maximum possible number of honest persons.\n\nSample Input 2\n\n3\n2\n2 1\n3 0\n2\n3 1\n1 0\n2\n1 1\n2 0\n\nSample Output 2\n\n0\n\nAssuming that one or more of them are honest immediately leads to a contradiction.\n\nSample Input 3\n\n2\n1\n2 0\n1\n1 0\n\nSample Output 3\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 955, "cpu_time_ms": 738, "memory_kb": 49052}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s567408331", "group_id": "codeNet:p02842", "input_text": "import scala.math.{ceil, floor}\n\nobject Main extends App {\n\n val sc = new java.util.Scanner(System.in)\n val N = sc.nextInt()\n val X = ceil(N / 1.08 ).toInt\n if (floor(X * 1.08) == N) {\n print(X)\n } else {\n print(\":(\")\n }\n}\n", "language": "Scala", "metadata": {"date": 1597726286, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s567408331.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s567408331", "user_id": "u396472025"}, "prompt_components": {"gold_output": "400\n", "input_to_evaluate": "import scala.math.{ceil, floor}\n\nobject Main extends App {\n\n val sc = new java.util.Scanner(System.in)\n val N = sc.nextInt()\n val X = ceil(N / 1.08 ).toInt\n if (floor(X * 1.08) == N) {\n print(X)\n } else {\n print(\":(\")\n }\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 500, "memory_kb": 55484}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s615625477", "group_id": "codeNet:p02848", "input_text": "object Main extends App {\n import scala.io.StdIn._\n val n = readInt()\n val s = readLine()\n val a = ('A' to 'Z').toList\n val res = s.toList.map(x => a((a.indexOf(x) + n) % 26)).mkString(\"\")\n println(res)\n}", "language": "Scala", "metadata": {"date": 1588626608, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s615625477.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s615625477", "user_id": "u647522078"}, "prompt_components": {"gold_output": "CDEZAB\n", "input_to_evaluate": "object Main extends App {\n import scala.io.StdIn._\n val n = readInt()\n val s = readLine()\n val a = ('A' to 'Z').toList\n val res = s.toList.map(x => a((a.indexOf(x) + n) % 26)).mkString(\"\")\n println(res)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 464, "memory_kb": 30212}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s272236250", "group_id": "codeNet:p02848", "input_text": "object Main extends App {\n val n = io.StdIn.readLine().toInt\n val s = io.StdIn.readLine()\n\n println(s.map(c => if(c + n > 'Z') (c + n - 26).toChar else (c + n).toChar))\n}", "language": "Scala", "metadata": {"date": 1578454476, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s272236250.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s272236250", "user_id": "u964906869"}, "prompt_components": {"gold_output": "CDEZAB\n", "input_to_evaluate": "object Main extends App {\n val n = io.StdIn.readLine().toInt\n val s = io.StdIn.readLine()\n\n println(s.map(c => if(c + n > 'Z') (c + n - 26).toChar else (c + n).toChar))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 354, "memory_kb": 26024}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s277016488", "group_id": "codeNet:p02859", "input_text": "import java.util.Scanner\nimport java.io.PrintWriter\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val pw = new PrintWriter(System.out)\n\n val r = sc.nextInt()\n pw.println(r * r)\n\n pw.flush()\n }\n}", "language": "Scala", "metadata": {"date": 1586811187, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s277016488.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s277016488", "user_id": "u602865659"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.Scanner\nimport java.io.PrintWriter\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val pw = new PrintWriter(System.out)\n\n val r = sc.nextInt()\n pw.println(r * r)\n\n pw.flush()\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer r.\n\nHow many times is the area of a circle of radius r larger than the area of a circle of radius 1?\n\nIt can be proved that the answer is always an integer under the constraints given.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint the area of a circle of radius r, divided by the area of a circle of radius 1, as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n4\n\nThe area of a circle of radius 2 is 4 times larger than the area of a circle of radius 1.\n\nNote that output must be an integer - for example, 4.0 will not be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n10000", "sample_input": "2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02859", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is an integer r.\n\nHow many times is the area of a circle of radius r larger than the area of a circle of radius 1?\n\nIt can be proved that the answer is always an integer under the constraints given.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint the area of a circle of radius r, divided by the area of a circle of radius 1, as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n4\n\nThe area of a circle of radius 2 is 4 times larger than the area of a circle of radius 1.\n\nNote that output must be an integer - for example, 4.0 will not be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n10000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 255, "cpu_time_ms": 354, "memory_kb": 25932}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s375445194", "group_id": "codeNet:p02860", "input_text": "// Main\nobject Main {\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val len = sc.nextInt\n val s = sc.next\n if (len % 2 != 0) {\n println(\"No\")\n System.exit(0)\n }\n val s1 = s.substring(0,len/2)\n val s2 = s.substring(len/2, len)\n if (s1 == s2) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1573956773, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s375445194.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s375445194", "user_id": "u894128391"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "// Main\nobject Main {\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val len = sc.nextInt\n val s = sc.next\n if (len % 2 != 0) {\n println(\"No\")\n System.exit(0)\n }\n val s1 = s.substring(0,len/2)\n val s2 = s.substring(len/2, len)\n if (s1 == s2) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 376, "cpu_time_ms": 365, "memory_kb": 25804}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s011684210", "group_id": "codeNet:p02860", "input_text": "object Main extends App {\n val n = scala.io.StdIn.readInt()\n val s = scala.io.StdIn.readLine()\n if (n % 2 == 0) {\n val splitLength = n / 2\n val before = s dropRight splitLength\n val after = s drop splitLength\n if (before == after) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n } else {\n println(\"No\")\n }\n}", "language": "Scala", "metadata": {"date": 1573956643, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s011684210.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s011684210", "user_id": "u105921924"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n val n = scala.io.StdIn.readInt()\n val s = scala.io.StdIn.readLine()\n if (n % 2 == 0) {\n val splitLength = n / 2\n val before = s dropRight splitLength\n val after = s drop splitLength\n if (before == after) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n } else {\n println(\"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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 343, "cpu_time_ms": 330, "memory_kb": 25412}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s686817663", "group_id": "codeNet:p02863", "input_text": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val N, T = sc.nextInt()\n val A, B = new Array[Int](N)\n (0 until N) foreach { i =>\n A(i) = sc.nextInt()\n B(i) = sc.nextInt()\n }\n\n val dp = Array.fill(N+1, T+1)(0)\n\n var i = 0\n while (i < N) {\n var t = 0\n while (t < T) {\n val nextT = (t + A(i)) min T\n var j = 0\n while (j <= t) {\n dp(i + 1)(nextT) = dp(i + 1)(nextT) max (dp(i)(j) + B(i))\n j += 1\n }\n dp(i+1)(t) = dp(i+1)(t) max dp(i)(t)\n\n t += 1\n }\n i += 1\n }\n\n println(dp.map(_.max).max)\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1574042653, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s686817663.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s686817663", "user_id": "u891387249"}, "prompt_components": {"gold_output": "110\n", "input_to_evaluate": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val N, T = sc.nextInt()\n val A, B = new Array[Int](N)\n (0 until N) foreach { i =>\n A(i) = sc.nextInt()\n B(i) = sc.nextInt()\n }\n\n val dp = Array.fill(N+1, T+1)(0)\n\n var i = 0\n while (i < N) {\n var t = 0\n while (t < T) {\n val nextT = (t + A(i)) min T\n var j = 0\n while (j <= t) {\n dp(i + 1)(nextT) = dp(i + 1)(nextT) max (dp(i)(j) + B(i))\n j += 1\n }\n dp(i+1)(t) = dp(i+1)(t) max dp(i)(t)\n\n t += 1\n }\n i += 1\n }\n\n println(dp.map(_.max).max)\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 667, "cpu_time_ms": 2111, "memory_kb": 85860}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s271907563", "group_id": "codeNet:p02863", "input_text": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val N, T = sc.nextInt()\n val A, B = new Array[Int](N)\n (0 until N) foreach { i =>\n A(i) = sc.nextInt()\n B(i) = sc.nextInt()\n }\n\n val dp = Array.fill(T+1, N+1)(0)\n var t = 0\n while (t < T) {\n var i = 1\n while (i <= N) {\n val nextT = (t + A(i-1)) min T\n dp(nextT)(i) = dp(nextT)(i-1) max (dp(t)(i-1) + B(i-1))\n dp(t)(i) = dp(t)(i) max dp(t)(i-1)\n dp(T)(N) = dp(T)(N) max dp(nextT)(i)\n i += 1\n }\n t += 1\n }\n\n println(dp(T)(N))\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1574038755, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s271907563.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s271907563", "user_id": "u891387249"}, "prompt_components": {"gold_output": "110\n", "input_to_evaluate": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val N, T = sc.nextInt()\n val A, B = new Array[Int](N)\n (0 until N) foreach { i =>\n A(i) = sc.nextInt()\n B(i) = sc.nextInt()\n }\n\n val dp = Array.fill(T+1, N+1)(0)\n var t = 0\n while (t < T) {\n var i = 1\n while (i <= N) {\n val nextT = (t + A(i-1)) min T\n dp(nextT)(i) = dp(nextT)(i-1) max (dp(t)(i-1) + B(i-1))\n dp(t)(i) = dp(t)(i) max dp(t)(i-1)\n dp(T)(N) = dp(T)(N) max dp(nextT)(i)\n i += 1\n }\n t += 1\n }\n\n println(dp(T)(N))\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 734, "memory_kb": 84332}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s885599963", "group_id": "codeNet:p02868", "input_text": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\nimport scala.collection.mutable.{Map, Stack, Queue, PriorityQueue}\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val N, M = in.next().toInt\n val _graph = new Array[((Int, Int), Long)](M)\n for (i <- 0 until M) {\n val L, R = in.next().toInt\n val C = in.next().toLong\n _graph(i) = ((L, R), C)\n }\n\n val graph = _graph.sorted\n\n\n //\n val rmq = new RMQ(1<<17)\n var ans = 0L\n\n var right = 1 // 届く右端\n\n var nowL = 0\n var now = 0L\n rmq.update(1, 0)\n\n breakable {\n for (node <- graph) {\n val L = node._1._1\n val R = node._1._2\n val C = node._2\n\n if (L > right) {\n ans = -1\n break\n }\n else {\n if (L != nowL) {\n nowL = L\n now = rmq.query(L, N+1)\n }\n\n right = Math.max(right, R)\n rmq.update(R, now + C)\n }\n }\n }\n\n if(ans != -1)\n ans = rmq.query(N, N+1)\n\n println(ans)\n}\n\n// MaxN : 2の乗数でないといけない。要素数に応じた値。(e.g. 10^5なら1<<17にしておくとよい)\nclass RMQ(MaxN: Int) {\n\n val dat = Array.fill[Long](2*MaxN - 1)(Long.MaxValue)\n\n // k番目の値(0-indexed)をaに変更\n def update(_k: Int, a: Long): Unit = {\n // 葉の節点\n var k = _k + (MaxN - 1)\n dat(k) = Math.min(dat(k), a)\n\n // 登りながら更新\n while (k > 0) {\n k = (k-1) / 2\n dat(k) = Math.min(dat(2*k + 1), dat(2*k + 2))\n }\n }\n\n // [a, b) の最小値を求める\n // 後ろの方の引数は、計算の簡単のための引数\n // kは節点の番号。l, r はその節点が[l, r) に対応づいていることを表す。\n def query(a: Int, b: Int): Long = {\n def func(k: Int, l: Int, r: Int): Long = {\n if (r <= a || b <= l) // [a, b)と[l, r)が交差しなければ、Int.MaxValue\n Long.MaxValue\n else if (a <= l && r <= b) // [a, b)が[l, r)を完全に含んでいれば、この節点の値\n dat(k)\n else { // そうでなければ、2つの子の最小値\n val vl = func(2*k + 1, l, (l+r)/2)\n val vr = func(2*k + 2, (l+r)/2, r)\n\n Math.min(vl, vr)\n }\n }\n\n func(0, 0, MaxN)\n }\n\n def print(n: Int): Unit = {\n println(dat.take(n).deep)\n }\n\n}\n\n\nclass InputReader(stream: InputStream) {\n private[this] val reader = new BufferedReader(new InputStreamReader(stream))\n private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n\nobject Sub {\n def print2DimArray[A](mat: Array[Array[A]]): Unit = {\n mat.foreach(lin => println(lin.deep))\n }\n}\n", "language": "Scala", "metadata": {"date": 1573356011, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s885599963.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s885599963", "user_id": "u098968285"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\nimport scala.collection.mutable.{Map, Stack, Queue, PriorityQueue}\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val N, M = in.next().toInt\n val _graph = new Array[((Int, Int), Long)](M)\n for (i <- 0 until M) {\n val L, R = in.next().toInt\n val C = in.next().toLong\n _graph(i) = ((L, R), C)\n }\n\n val graph = _graph.sorted\n\n\n //\n val rmq = new RMQ(1<<17)\n var ans = 0L\n\n var right = 1 // 届く右端\n\n var nowL = 0\n var now = 0L\n rmq.update(1, 0)\n\n breakable {\n for (node <- graph) {\n val L = node._1._1\n val R = node._1._2\n val C = node._2\n\n if (L > right) {\n ans = -1\n break\n }\n else {\n if (L != nowL) {\n nowL = L\n now = rmq.query(L, N+1)\n }\n\n right = Math.max(right, R)\n rmq.update(R, now + C)\n }\n }\n }\n\n if(ans != -1)\n ans = rmq.query(N, N+1)\n\n println(ans)\n}\n\n// MaxN : 2の乗数でないといけない。要素数に応じた値。(e.g. 10^5なら1<<17にしておくとよい)\nclass RMQ(MaxN: Int) {\n\n val dat = Array.fill[Long](2*MaxN - 1)(Long.MaxValue)\n\n // k番目の値(0-indexed)をaに変更\n def update(_k: Int, a: Long): Unit = {\n // 葉の節点\n var k = _k + (MaxN - 1)\n dat(k) = Math.min(dat(k), a)\n\n // 登りながら更新\n while (k > 0) {\n k = (k-1) / 2\n dat(k) = Math.min(dat(2*k + 1), dat(2*k + 2))\n }\n }\n\n // [a, b) の最小値を求める\n // 後ろの方の引数は、計算の簡単のための引数\n // kは節点の番号。l, r はその節点が[l, r) に対応づいていることを表す。\n def query(a: Int, b: Int): Long = {\n def func(k: Int, l: Int, r: Int): Long = {\n if (r <= a || b <= l) // [a, b)と[l, r)が交差しなければ、Int.MaxValue\n Long.MaxValue\n else if (a <= l && r <= b) // [a, b)が[l, r)を完全に含んでいれば、この節点の値\n dat(k)\n else { // そうでなければ、2つの子の最小値\n val vl = func(2*k + 1, l, (l+r)/2)\n val vr = func(2*k + 2, (l+r)/2, r)\n\n Math.min(vl, vr)\n }\n }\n\n func(0, 0, MaxN)\n }\n\n def print(n: Int): Unit = {\n println(dat.take(n).deep)\n }\n\n}\n\n\nclass InputReader(stream: InputStream) {\n private[this] val reader = new BufferedReader(new InputStreamReader(stream))\n private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n\nobject Sub {\n def print2DimArray[A](mat: Array[Array[A]]): Unit = {\n mat.foreach(lin => println(lin.deep))\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2842, "cpu_time_ms": 1074, "memory_kb": 78704}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s947653428", "group_id": "codeNet:p02880", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val n = sc.nextLong\n val answer = if ((1 to 9).filter(n % _ == 0).exists(n / _ < 10)) \"Yes\" else \"No\"\n println(answer)\n}\n", "language": "Scala", "metadata": {"date": 1577335415, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02880.html", "problem_id": "p02880", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02880/input.txt", "sample_output_relpath": "derived/input_output/data/p02880/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02880/Scala/s947653428.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s947653428", "user_id": "u080987909"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val n = sc.nextLong\n val answer = if ((1 to 9).filter(n % _ == 0).exists(n / _ < 10)) \"Yes\" else \"No\"\n println(answer)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nHaving learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together.\n\nGiven an integer N, determine whether N can be represented as the product of two integers between 1 and 9. If it can, print Yes; if it cannot, print No.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N can be represented as the product of two integers between 1 and 9 (inclusive), print Yes; if it cannot, print No.\n\nSample Input 1\n\n10\n\nSample Output 1\n\nYes\n\n10 can be represented as, for example, 2 \\times 5.\n\nSample Input 2\n\n50\n\nSample Output 2\n\nNo\n\n50 cannot be represented as the product of two integers between 1 and 9.\n\nSample Input 3\n\n81\n\nSample Output 3\n\nYes", "sample_input": "10\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02880", "source_text": "Score : 200 points\n\nProblem Statement\n\nHaving learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together.\n\nGiven an integer N, determine whether N can be represented as the product of two integers between 1 and 9. If it can, print Yes; if it cannot, print No.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N can be represented as the product of two integers between 1 and 9 (inclusive), print Yes; if it cannot, print No.\n\nSample Input 1\n\n10\n\nSample Output 1\n\nYes\n\n10 can be represented as, for example, 2 \\times 5.\n\nSample Input 2\n\n50\n\nSample Output 2\n\nNo\n\n50 cannot be represented as the product of two integers between 1 and 9.\n\nSample Input 3\n\n81\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 336, "memory_kb": 25428}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s289081278", "group_id": "codeNet:p02880", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val n = sc.nextInt\n\n val a = (1 to 9).find{ num =>\n n % num == 0 && 1 <= (n / num) && (n / num) <= 9\n }\n\n val res = if(a.nonEmpty) \"Yes\" else \"No\"\n\n println(res)\n\n\n\n}\n", "language": "Scala", "metadata": {"date": 1574888124, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02880.html", "problem_id": "p02880", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02880/input.txt", "sample_output_relpath": "derived/input_output/data/p02880/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02880/Scala/s289081278.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s289081278", "user_id": "u829407811"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val n = sc.nextInt\n\n val a = (1 to 9).find{ num =>\n n % num == 0 && 1 <= (n / num) && (n / num) <= 9\n }\n\n val res = if(a.nonEmpty) \"Yes\" else \"No\"\n\n println(res)\n\n\n\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nHaving learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together.\n\nGiven an integer N, determine whether N can be represented as the product of two integers between 1 and 9. If it can, print Yes; if it cannot, print No.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N can be represented as the product of two integers between 1 and 9 (inclusive), print Yes; if it cannot, print No.\n\nSample Input 1\n\n10\n\nSample Output 1\n\nYes\n\n10 can be represented as, for example, 2 \\times 5.\n\nSample Input 2\n\n50\n\nSample Output 2\n\nNo\n\n50 cannot be represented as the product of two integers between 1 and 9.\n\nSample Input 3\n\n81\n\nSample Output 3\n\nYes", "sample_input": "10\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02880", "source_text": "Score : 200 points\n\nProblem Statement\n\nHaving learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together.\n\nGiven an integer N, determine whether N can be represented as the product of two integers between 1 and 9. If it can, print Yes; if it cannot, print No.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N can be represented as the product of two integers between 1 and 9 (inclusive), print Yes; if it cannot, print No.\n\nSample Input 1\n\n10\n\nSample Output 1\n\nYes\n\n10 can be represented as, for example, 2 \\times 5.\n\nSample Input 2\n\n50\n\nSample Output 2\n\nNo\n\n50 cannot be represented as the product of two integers between 1 and 9.\n\nSample Input 3\n\n81\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 351, "memory_kb": 27332}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s922059641", "group_id": "codeNet:p02882", "input_text": "import scala.math.{abs, max, min}\n\nobject Main {\n import java.io.{BufferedReader, InputStream, InputStreamReader}\n import java.util.StringTokenizer\n import scala.reflect.ClassTag\n\n def main(args: Array[String]): Unit = {\n val out = new java.io.PrintWriter(System.out)\n new Main(out, new InputReader(System.in)).solve()\n out.flush()\n }\n\n private[this] val oj = System.getenv(\"ATCODER_DEBUG\") == null\n @inline private final def DEBUG(f: => Unit): Unit = {\n if (!oj){ f }\n }\n @inline private final def debug(as: Array[Boolean]): Unit = if (!oj){ debug(as.map(x => if(x) \"1\" else \"0\").mkString) }\n @inline def debug(as: Array[Int]): Unit = if (!oj){ debug(as.mkString(\" \")) }\n @inline private final def debug(as: Array[Long]): Unit =if (!oj){ debug(as.mkString(\" \")) }\n @inline private final def debugDim(m: Array[Array[Int]]): Unit = if (!oj){\n REP(m.length) { i =>\n debug(m(i))\n }\n }\n @inline private final def debugDimFlip(m: Array[Array[Long]]): Unit = if (!oj){\n REP(m(0).length) { j =>\n REP(m.length) { i =>\n System.err.print(m(i)(j))\n System.err.print(\" \")\n }\n System.err.println()\n }\n }\n @inline def debug(s: => String): Unit = DEBUG {\n System.err.println(s)\n }\n @inline private final def debugL(num: => Long): Unit = DEBUG {\n System.err.println(num)\n }\n private def isDebug[A](debug: => A, online: => A): A = {\n if (oj) online else debug\n }\n\n class InputReader(val stream: InputStream) {\n private[this] val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private[this] var tokenizer: StringTokenizer = _\n\n @inline private[this] final def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = Integer.parseInt(next())\n def nextLong(): Long = java.lang.Long.parseLong(next())\n def nextChar(): Char = next().charAt(0)\n\n def ni(): Int = nextInt()\n def nl(): Long = nextLong()\n def nc(): Char = nextChar()\n def ns(): String = next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n }\n\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n def TO(from: Int, to: Int)(f: Int => Unit): Unit = {\n REP(to - from + 1, from)(f)\n }\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n def cumSum(as: Array[Int]): Array[Long] = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n\nobject Workspace {\n import Main._\n}\n\nclass Main(out: java.io.PrintWriter, sc: Main.InputReader) {\n import sc._\n import Main._\n import java.util.Arrays.sort\n\n import scala.collection.mutable\n import math.{abs, max, min}\n import mutable.ArrayBuffer\n import Workspace._\n\n // toIntとか+7とかするならvalにしろ\n final private[this] val MOD = 1000000007\n\n def solve(): Unit = {\n val a, b, x = ni()\n val theta = if (a * a * b <= 2 * x) {\n val s = (a * a * b - x).toDouble / a\n math.atan(2 * s / a / a)\n } else {\n val s = x.toDouble / a\n math.atan(b.toDouble * b / s / 2)\n }\n val ans = theta / math.Pi * 180\n out.println(f\"$ans%.10f\")\n }\n}\n", "language": "Scala", "metadata": {"date": 1572228755, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02882.html", "problem_id": "p02882", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02882/input.txt", "sample_output_relpath": "derived/input_output/data/p02882/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02882/Scala/s922059641.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s922059641", "user_id": "u460609472"}, "prompt_components": {"gold_output": "45.0000000000\n", "input_to_evaluate": "import scala.math.{abs, max, min}\n\nobject Main {\n import java.io.{BufferedReader, InputStream, InputStreamReader}\n import java.util.StringTokenizer\n import scala.reflect.ClassTag\n\n def main(args: Array[String]): Unit = {\n val out = new java.io.PrintWriter(System.out)\n new Main(out, new InputReader(System.in)).solve()\n out.flush()\n }\n\n private[this] val oj = System.getenv(\"ATCODER_DEBUG\") == null\n @inline private final def DEBUG(f: => Unit): Unit = {\n if (!oj){ f }\n }\n @inline private final def debug(as: Array[Boolean]): Unit = if (!oj){ debug(as.map(x => if(x) \"1\" else \"0\").mkString) }\n @inline def debug(as: Array[Int]): Unit = if (!oj){ debug(as.mkString(\" \")) }\n @inline private final def debug(as: Array[Long]): Unit =if (!oj){ debug(as.mkString(\" \")) }\n @inline private final def debugDim(m: Array[Array[Int]]): Unit = if (!oj){\n REP(m.length) { i =>\n debug(m(i))\n }\n }\n @inline private final def debugDimFlip(m: Array[Array[Long]]): Unit = if (!oj){\n REP(m(0).length) { j =>\n REP(m.length) { i =>\n System.err.print(m(i)(j))\n System.err.print(\" \")\n }\n System.err.println()\n }\n }\n @inline def debug(s: => String): Unit = DEBUG {\n System.err.println(s)\n }\n @inline private final def debugL(num: => Long): Unit = DEBUG {\n System.err.println(num)\n }\n private def isDebug[A](debug: => A, online: => A): A = {\n if (oj) online else debug\n }\n\n class InputReader(val stream: InputStream) {\n private[this] val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private[this] var tokenizer: StringTokenizer = _\n\n @inline private[this] final def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = Integer.parseInt(next())\n def nextLong(): Long = java.lang.Long.parseLong(next())\n def nextChar(): Char = next().charAt(0)\n\n def ni(): Int = nextInt()\n def nl(): Long = nextLong()\n def nc(): Char = nextChar()\n def ns(): String = next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n }\n\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n def TO(from: Int, to: Int)(f: Int => Unit): Unit = {\n REP(to - from + 1, from)(f)\n }\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n def cumSum(as: Array[Int]): Array[Long] = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n\nobject Workspace {\n import Main._\n}\n\nclass Main(out: java.io.PrintWriter, sc: Main.InputReader) {\n import sc._\n import Main._\n import java.util.Arrays.sort\n\n import scala.collection.mutable\n import math.{abs, max, min}\n import mutable.ArrayBuffer\n import Workspace._\n\n // toIntとか+7とかするならvalにしろ\n final private[this] val MOD = 1000000007\n\n def solve(): Unit = {\n val a, b, x = ni()\n val theta = if (a * a * b <= 2 * x) {\n val s = (a * a * b - x).toDouble / a\n math.atan(2 * s / a / a)\n } else {\n val s = x.toDouble / a\n math.atan(b.toDouble * b / s / 2)\n }\n val ans = theta / math.Pi * 180\n out.println(f\"$ans%.10f\")\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\\mathrm{cm} and whose height is b~\\mathrm{cm}. (The thickness of the bottle can be ignored.)\n\nWe will pour x~\\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base.\n\nWhen will the water be spilled? More formally, find the maximum angle in which we can tilt the bottle without spilling any water.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq a \\leq 100\n\n1 \\leq b \\leq 100\n\n1 \\leq x \\leq a^2b\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b x\n\nOutput\n\nPrint the maximum angle in which we can tilt the bottle without spilling any water, in degrees.\nYour output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}.\n\nSample Input 1\n\n2 2 4\n\nSample Output 1\n\n45.0000000000\n\nThis bottle has a cubic shape, and it is half-full. The water gets spilled when we tilt the bottle more than 45 degrees.\n\nSample Input 2\n\n12 21 10\n\nSample Output 2\n\n89.7834636934\n\nThis bottle is almost empty. When the water gets spilled, the bottle is nearly horizontal.\n\nSample Input 3\n\n3 1 8\n\nSample Output 3\n\n4.2363947991\n\nThis bottle is almost full. When the water gets spilled, the bottle is still nearly vertical.", "sample_input": "2 2 4\n"}, "reference_outputs": ["45.0000000000\n"], "source_document_id": "p02882", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\\mathrm{cm} and whose height is b~\\mathrm{cm}. (The thickness of the bottle can be ignored.)\n\nWe will pour x~\\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base.\n\nWhen will the water be spilled? More formally, find the maximum angle in which we can tilt the bottle without spilling any water.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq a \\leq 100\n\n1 \\leq b \\leq 100\n\n1 \\leq x \\leq a^2b\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b x\n\nOutput\n\nPrint the maximum angle in which we can tilt the bottle without spilling any water, in degrees.\nYour output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}.\n\nSample Input 1\n\n2 2 4\n\nSample Output 1\n\n45.0000000000\n\nThis bottle has a cubic shape, and it is half-full. The water gets spilled when we tilt the bottle more than 45 degrees.\n\nSample Input 2\n\n12 21 10\n\nSample Output 2\n\n89.7834636934\n\nThis bottle is almost empty. When the water gets spilled, the bottle is nearly horizontal.\n\nSample Input 3\n\n3 1 8\n\nSample Output 3\n\n4.2363947991\n\nThis bottle is almost full. When the water gets spilled, the bottle is still nearly vertical.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4270, "cpu_time_ms": 325, "memory_kb": 27448}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s230025973", "group_id": "codeNet:p02883", "input_text": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val N = sc.nextInt()\n val K = sc.nextLong()\n val A = Array.fill(N)(sc.nextInt()).sorted\n val F = Array.fill(N)(sc.nextInt()).sorted(Ordering.Int.reverse)\n val AF: Array[(Int, Int)] = A zip F\n\n val MAX = A.last * F.head\n\n def binarySearch(l: Long, r: Long): Long = {\n if (r - l > 1) {\n val X = l + (r - l) / 2\n val _K = AF.foldLeft(0L) { case (r, (a, f)) =>\n r + (a - X / f)\n }\n if (_K <= K) {\n binarySearch(l, X)\n } else {\n binarySearch(X, r)\n }\n } else r\n }\n\n println(binarySearch(-1, MAX+1))\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1574314566, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s230025973.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s230025973", "user_id": "u891387249"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val N = sc.nextInt()\n val K = sc.nextLong()\n val A = Array.fill(N)(sc.nextInt()).sorted\n val F = Array.fill(N)(sc.nextInt()).sorted(Ordering.Int.reverse)\n val AF: Array[(Int, Int)] = A zip F\n\n val MAX = A.last * F.head\n\n def binarySearch(l: Long, r: Long): Long = {\n if (r - l > 1) {\n val X = l + (r - l) / 2\n val _K = AF.foldLeft(0L) { case (r, (a, f)) =>\n r + (a - X / f)\n }\n if (_K <= K) {\n binarySearch(l, X)\n } else {\n binarySearch(X, r)\n }\n } else r\n }\n\n println(binarySearch(-1, MAX+1))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1453, "memory_kb": 112092}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s315276910", "group_id": "codeNet:p02884", "input_text": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\nimport scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val N, M = in.next().toInt\n val graph = Array.fill[List[Int]](N+1)(Nil)\n\n //\n for (_ <- 1 to M) {\n val s, t = in.next().toInt\n graph(s) = t :: graph(s)\n }\n\n val dp = new Array[Double](N+1)\n var ans = Double.MaxValue\n for (k <- 1 to N) {\n for (i <- 1 to N-1)\n dp(i) = Double.MaxValue\n\n for (i <- (1 to N-1).reverse) {\n val l = graph(i).length\n\n if (i == k && l > 1) {\n dp(i) = graph(i)\n .map(e => dp(e) + 1)\n .sorted.reverse.tail.sum / (l - 1)\n }\n else {\n if (l > 0)\n dp(i) = graph(i)\n .map(e => dp(e) + 1)\n .sum / l\n }\n }\n\n if (dp(1) < ans)\n ans = dp(1)\n }\n\n println(ans)\n}\n\nclass InputReader(stream: InputStream) {\n private[this] val reader = new BufferedReader(new InputStreamReader(stream))\n private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n", "language": "Scala", "metadata": {"date": 1586227121, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02884.html", "problem_id": "p02884", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02884/input.txt", "sample_output_relpath": "derived/input_output/data/p02884/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02884/Scala/s315276910.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s315276910", "user_id": "u098968285"}, "prompt_components": {"gold_output": "1.5000000000\n", "input_to_evaluate": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\nimport scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val N, M = in.next().toInt\n val graph = Array.fill[List[Int]](N+1)(Nil)\n\n //\n for (_ <- 1 to M) {\n val s, t = in.next().toInt\n graph(s) = t :: graph(s)\n }\n\n val dp = new Array[Double](N+1)\n var ans = Double.MaxValue\n for (k <- 1 to N) {\n for (i <- 1 to N-1)\n dp(i) = Double.MaxValue\n\n for (i <- (1 to N-1).reverse) {\n val l = graph(i).length\n\n if (i == k && l > 1) {\n dp(i) = graph(i)\n .map(e => dp(e) + 1)\n .sorted.reverse.tail.sum / (l - 1)\n }\n else {\n if (l > 0)\n dp(i) = graph(i)\n .map(e => dp(e) + 1)\n .sum / l\n }\n }\n\n if (dp(1) < ans)\n ans = dp(1)\n }\n\n println(ans)\n}\n\nclass InputReader(stream: InputStream) {\n private[this] val reader = new BufferedReader(new InputStreamReader(stream))\n private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere is a cave consisting of N rooms and M one-directional passages. The rooms are numbered 1 through N.\n\nTakahashi is now in Room 1, and Room N has the exit. The i-th passage connects Room s_i and Room t_i (s_i < t_i) and can only be traversed in the direction from Room s_i to Room t_i. It is known that, for each room except Room N, there is at least one passage going from that room.\n\nTakahashi will escape from the cave. Each time he reaches a room (assume that he has reached Room 1 at the beginning), he will choose a passage uniformly at random from the ones going from that room and take that passage.\n\nAoki, a friend of Takahashi's, can block one of the passages (or do nothing) before Takahashi leaves Room 1. However, it is not allowed to block a passage so that Takahashi is potentially unable to reach Room N.\n\nLet E be the expected number of passages Takahashi takes before he reaches Room N. Find the value of E when Aoki makes a choice that minimizes E.\n\nConstraints\n\n2 \\leq N \\leq 600\n\nN-1 \\leq M \\leq \\frac{N(N-1)}{2}\n\ns_i < t_i\n\nIf i != j, (s_i, t_i) \\neq (s_j, t_j). (Added 21:23 JST)\n\nFor every v = 1, 2, ..., N-1, there exists i such that v = s_i.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\ns_1 t_1\n:\ns_M t_M\n\nOutput\n\nPrint the value of E when Aoki makes a choice that minimizes E.\nYour output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}.\n\nSample Input 1\n\n4 6\n1 4\n2 3\n1 3\n1 2\n3 4\n2 4\n\nSample Output 1\n\n1.5000000000\n\nIf Aoki blocks the passage from Room 1 to Room 2, Takahashi will go along the path 1 → 3 → 4 with probability \\frac{1}{2} and 1 → 4 with probability \\frac{1}{2}. E = 1.5 here, and this is the minimum possible value of E.\n\nSample Input 2\n\n3 2\n1 2\n2 3\n\nSample Output 2\n\n2.0000000000\n\nBlocking any one passage makes Takahashi unable to reach Room N, so Aoki cannot block a passage.\n\nSample Input 3\n\n10 33\n3 7\n5 10\n8 9\n1 10\n4 6\n2 5\n1 7\n6 10\n1 4\n1 3\n8 10\n1 5\n2 6\n6 9\n5 6\n5 8\n3 6\n4 8\n2 7\n2 9\n6 7\n1 2\n5 9\n6 8\n9 10\n3 9\n7 8\n4 5\n2 10\n5 7\n3 5\n4 7\n4 9\n\nSample Output 3\n\n3.0133333333", "sample_input": "4 6\n1 4\n2 3\n1 3\n1 2\n3 4\n2 4\n"}, "reference_outputs": ["1.5000000000\n"], "source_document_id": "p02884", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere is a cave consisting of N rooms and M one-directional passages. The rooms are numbered 1 through N.\n\nTakahashi is now in Room 1, and Room N has the exit. The i-th passage connects Room s_i and Room t_i (s_i < t_i) and can only be traversed in the direction from Room s_i to Room t_i. It is known that, for each room except Room N, there is at least one passage going from that room.\n\nTakahashi will escape from the cave. Each time he reaches a room (assume that he has reached Room 1 at the beginning), he will choose a passage uniformly at random from the ones going from that room and take that passage.\n\nAoki, a friend of Takahashi's, can block one of the passages (or do nothing) before Takahashi leaves Room 1. However, it is not allowed to block a passage so that Takahashi is potentially unable to reach Room N.\n\nLet E be the expected number of passages Takahashi takes before he reaches Room N. Find the value of E when Aoki makes a choice that minimizes E.\n\nConstraints\n\n2 \\leq N \\leq 600\n\nN-1 \\leq M \\leq \\frac{N(N-1)}{2}\n\ns_i < t_i\n\nIf i != j, (s_i, t_i) \\neq (s_j, t_j). (Added 21:23 JST)\n\nFor every v = 1, 2, ..., N-1, there exists i such that v = s_i.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\ns_1 t_1\n:\ns_M t_M\n\nOutput\n\nPrint the value of E when Aoki makes a choice that minimizes E.\nYour output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}.\n\nSample Input 1\n\n4 6\n1 4\n2 3\n1 3\n1 2\n3 4\n2 4\n\nSample Output 1\n\n1.5000000000\n\nIf Aoki blocks the passage from Room 1 to Room 2, Takahashi will go along the path 1 → 3 → 4 with probability \\frac{1}{2} and 1 → 4 with probability \\frac{1}{2}. E = 1.5 here, and this is the minimum possible value of E.\n\nSample Input 2\n\n3 2\n1 2\n2 3\n\nSample Output 2\n\n2.0000000000\n\nBlocking any one passage makes Takahashi unable to reach Room N, so Aoki cannot block a passage.\n\nSample Input 3\n\n10 33\n3 7\n5 10\n8 9\n1 10\n4 6\n2 5\n1 7\n6 10\n1 4\n1 3\n8 10\n1 5\n2 6\n6 9\n5 6\n5 8\n3 6\n4 8\n2 7\n2 9\n6 7\n1 2\n5 9\n6 8\n9 10\n3 9\n7 8\n4 5\n2 10\n5 7\n3 5\n4 7\n4 9\n\nSample Output 3\n\n3.0133333333", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1349, "cpu_time_ms": 2111, "memory_kb": 125224}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s650525639", "group_id": "codeNet:p02885", "input_text": "object Main extends App {\n\n val Array(a, b) = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n\n\n def solve() = {\n val ans = a - (2 * b)\n Math.max(ans, 0)\n }\n\n println(solve)\n\n}", "language": "Scala", "metadata": {"date": 1572194493, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s650525639.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s650525639", "user_id": "u947008426"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "object Main extends App {\n\n val Array(a, b) = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n\n\n def solve() = {\n val ans = a - (2 * b)\n Math.max(ans, 0)\n }\n\n println(solve)\n\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 331, "memory_kb": 27080}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s387136208", "group_id": "codeNet:p02885", "input_text": "object Main extends App {\n val input = readLine.split(\" \").map(_.toInt)\n val a = input(0)\n val b = input(1)\n val rest = a - (b * 2)\n val result = if (rest < 0) 0 else rest\n println(result) \n}", "language": "Scala", "metadata": {"date": 1571534354, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s387136208.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s387136208", "user_id": "u755165056"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "object Main extends App {\n val input = readLine.split(\" \").map(_.toInt)\n val a = input(0)\n val b = input(1)\n val rest = a - (b * 2)\n val result = if (rest < 0) 0 else rest\n println(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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 323, "memory_kb": 25412}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s301927517", "group_id": "codeNet:p02886", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val _ :: list = List.fill(sc.nextInt())(sc.nextInt()).tails.toList.reverse\n println(list.map { case x :: xs => x * xs.sum }.sum)\n}\n", "language": "Scala", "metadata": {"date": 1596592916, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s301927517.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s301927517", "user_id": "u737111725"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val _ :: list = List.fill(sc.nextInt())(sc.nextInt()).tails.toList.reverse\n println(list.map { case x :: xs => x * xs.sum }.sum)\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 521, "memory_kb": 55484}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s043146978", "group_id": "codeNet:p02886", "input_text": "object Main extends App {\n val input1 = readInt\n val input2 = readLine\n val N = input1\n val d_i = input2.split(\" \").map(_.toInt)\n val s = d_i.sum\n val result = d_i.foldLeft(0)((l, r) => l + (s - r) * r)\n println(result)\n}", "language": "Scala", "metadata": {"date": 1573758889, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s043146978.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s043146978", "user_id": "u817495853"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "object Main extends App {\n val input1 = readInt\n val input2 = readLine\n val N = input1\n val d_i = input2.split(\" \").map(_.toInt)\n val s = d_i.sum\n val result = d_i.foldLeft(0)((l, r) => l + (s - r) * r)\n println(result)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 331, "memory_kb": 25524}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s261335040", "group_id": "codeNet:p02888", "input_text": "object Main extends App {\n val garbage = scala.io.StdIn.readLine\n val branches = scala.io.StdIn.readLine.split(\" \").map(_.toInt).toSeq\n\n val answer = branches.combinations(3).count { case Seq(a, b, c) =>\n a < b + c && b < c + a && c < a + b\n }\n\n println(answer)\n}", "language": "Scala", "metadata": {"date": 1585608304, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s261335040.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s261335040", "user_id": "u102400818"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main extends App {\n val garbage = scala.io.StdIn.readLine\n val branches = scala.io.StdIn.readLine.split(\" \").map(_.toInt).toSeq\n\n val answer = branches.combinations(3).count { case Seq(a, b, c) =>\n a < b + c && b < c + a && c < a + b\n }\n\n println(answer)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 116068}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s287214844", "group_id": "codeNet:p02888", "input_text": "object Main extends App {\n val n = readInt\n val input = readLine.split(\" \").map(_.toInt).sorted\n var ans = 0\n for(i <- 0 until n) {\n for(j <- i + 1 until n) {\n var ab = input(i) + input(j)\n \tfor(k <- j + 1 until n) {\n if(input(k) < ab)\n ans += 1\n }\n }\n }\n println(ans) \n}\n", "language": "Scala", "metadata": {"date": 1571614304, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s287214844.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s287214844", "user_id": "u755165056"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main extends App {\n val n = readInt\n val input = readLine.split(\" \").map(_.toInt).sorted\n var ans = 0\n for(i <- 0 until n) {\n for(j <- i + 1 until n) {\n var ab = input(i) + input(j)\n \tfor(k <- j + 1 until n) {\n if(input(k) < ab)\n ans += 1\n }\n }\n }\n println(ans) \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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 45364}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s071548452", "group_id": "codeNet:p02889", "input_text": "import java.io.PrintWriter\n\nobject Scanner {\n private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0\n @inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126\n @inline private def hasNextByte(): Boolean =\n if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else { true }\n @inline private def hasNext(): Boolean = {\n while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1\n hasNextByte()\n }\n @inline private def readByte(): Byte =\n if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else { -1 }\n def next(): String = {\n if(!hasNext()) ???\n val sb = new StringBuilder; var b = readByte()\n while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }\n sb.toString\n }\n def nextInt(): Int = {\n val n = nextLong()\n if (n < Int.MinValue || Int.MaxValue < n) ???\n n.toInt\n }\n def nextLong(): Long = {\n if(!hasNext()) ???\n var minus = false; var b = readByte()\n if (b == '-') { minus = true; b = readByte() }\n def go (b: Byte, n: Long = 0): Long =\n if ('0' <= b && b <= '9') { go(readByte(), n * 10 + b - '0') }\n else if (minus) { -n } else { n }\n go(b)\n }\n def nextDouble(): Double = next.toDouble\n}\n\nobject OutPut {\n def print(f:PrintWriter => Unit): Unit = {\n val pw: PrintWriter = new java.io.PrintWriter(System.out)\n //pw.println(\"\")\n f(pw)\n pw.flush()\n }\n}\nobject MyDataFormat {\n def double(x: Double, precision: Int): String = {\n var num = x\n val sb = new StringBuilder\n if (num < 0) {\n sb.append(\"-\")\n num = -num\n }\n num += Math.pow(10, -precision) / 2\n sb.append(num.toLong)\n sb.append(\".\")\n num -= num.toLong\n (0 until precision).foreach(i => {\n num *= 10\n sb.append(num.toInt)\n num -= num.toInt\n })\n sb.toString\n }\n\n def array2(arr: scala.collection.mutable.ArrayBuffer[scala.collection.mutable.ArrayBuffer[Int]], x: Int, y: Int): Option[Int] = {\n try { Some(arr(x)(y)) } catch {\n case _: Exception => None\n }\n }\n}\n\nobject Loop {\n @inline def rep(n: Int, f: => Unit): Unit = { var c = 0; while (c < n) { f; c += 1 } }\n @inline def rep(n: Int, f: Int => Unit): Unit = { var c = 0; while (c < n) { f(c); c += 1 } }\n}\n\nobject Search {\n def find(data: Array[Int], key: Int): Option[Int] = {\n val res = java.util.Arrays.binarySearch(data, key)\n if (res >= 0) Some(res) else None\n }\n}\n\nobject WarshallFloyd {\n def run(n: Int, vectorMap: Array[Array[Int]]): Array[Array[Int]] = {\n Loop.rep(n, k => {\n Loop.rep(n, i => {\n Loop.rep(n, j => {\n val a = vectorMap(i)(j)\n\n val b = vectorMap(i)(k)\n val c = vectorMap(k)(j)\n val distance = Math.min(a, b + c)\n vectorMap(i)(j) = distance\n })\n })\n })\n vectorMap\n }\n}\n\nobject Main extends App {\n val INF = 1001001001\n val n, m, l = Scanner.nextInt()\n\n val data: Array[Array[Int]] = Array.fill(m, 3)(Scanner.nextInt())\n val q = Scanner.nextInt()\n val test: Array[Array[Int]] = Array.fill(q, 2)(Scanner.nextInt())\n\n val distanceArray: Array[Array[Int]] = Array.fill[Int](n, n)(INF)\n Loop.rep(n, i => distanceArray(i)(i) = 0)\n data.map { a =>\n distanceArray(a(0) - 1)(a(1) - 1) = a(2)\n distanceArray(a(1) - 1)(a(0) - 1) = a(2)\n }\n val tidyDistanceVector = WarshallFloyd.run(n, distanceArray)\n\n val fuelArray: Array[Array[Int]] = Array.fill[Int](n, n)(INF)\n Loop.rep(n, i => fuelArray(i)(i) = 1)\n Loop.rep(n, x => Loop.rep(n, y => { if (tidyDistanceVector(x)(y) <= l) fuelArray(x)(y) = 1 }))\n\n val tidyFuelVector = WarshallFloyd.run(n, fuelArray)\n\n test.foreach { q =>\n val x = q(0) - 1\n val y = q(1) - 1\n val fuelReplenishmentTimes = tidyFuelVector(x)(y)\n println(if (fuelReplenishmentTimes >= INF) -1 else fuelReplenishmentTimes - 1)\n }\n}", "language": "Scala", "metadata": {"date": 1573885927, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02889.html", "problem_id": "p02889", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02889/input.txt", "sample_output_relpath": "derived/input_output/data/p02889/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02889/Scala/s071548452.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s071548452", "user_id": "u817495853"}, "prompt_components": {"gold_output": "0\n1\n", "input_to_evaluate": "import java.io.PrintWriter\n\nobject Scanner {\n private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0\n @inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126\n @inline private def hasNextByte(): Boolean =\n if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else { true }\n @inline private def hasNext(): Boolean = {\n while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1\n hasNextByte()\n }\n @inline private def readByte(): Byte =\n if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else { -1 }\n def next(): String = {\n if(!hasNext()) ???\n val sb = new StringBuilder; var b = readByte()\n while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }\n sb.toString\n }\n def nextInt(): Int = {\n val n = nextLong()\n if (n < Int.MinValue || Int.MaxValue < n) ???\n n.toInt\n }\n def nextLong(): Long = {\n if(!hasNext()) ???\n var minus = false; var b = readByte()\n if (b == '-') { minus = true; b = readByte() }\n def go (b: Byte, n: Long = 0): Long =\n if ('0' <= b && b <= '9') { go(readByte(), n * 10 + b - '0') }\n else if (minus) { -n } else { n }\n go(b)\n }\n def nextDouble(): Double = next.toDouble\n}\n\nobject OutPut {\n def print(f:PrintWriter => Unit): Unit = {\n val pw: PrintWriter = new java.io.PrintWriter(System.out)\n //pw.println(\"\")\n f(pw)\n pw.flush()\n }\n}\nobject MyDataFormat {\n def double(x: Double, precision: Int): String = {\n var num = x\n val sb = new StringBuilder\n if (num < 0) {\n sb.append(\"-\")\n num = -num\n }\n num += Math.pow(10, -precision) / 2\n sb.append(num.toLong)\n sb.append(\".\")\n num -= num.toLong\n (0 until precision).foreach(i => {\n num *= 10\n sb.append(num.toInt)\n num -= num.toInt\n })\n sb.toString\n }\n\n def array2(arr: scala.collection.mutable.ArrayBuffer[scala.collection.mutable.ArrayBuffer[Int]], x: Int, y: Int): Option[Int] = {\n try { Some(arr(x)(y)) } catch {\n case _: Exception => None\n }\n }\n}\n\nobject Loop {\n @inline def rep(n: Int, f: => Unit): Unit = { var c = 0; while (c < n) { f; c += 1 } }\n @inline def rep(n: Int, f: Int => Unit): Unit = { var c = 0; while (c < n) { f(c); c += 1 } }\n}\n\nobject Search {\n def find(data: Array[Int], key: Int): Option[Int] = {\n val res = java.util.Arrays.binarySearch(data, key)\n if (res >= 0) Some(res) else None\n }\n}\n\nobject WarshallFloyd {\n def run(n: Int, vectorMap: Array[Array[Int]]): Array[Array[Int]] = {\n Loop.rep(n, k => {\n Loop.rep(n, i => {\n Loop.rep(n, j => {\n val a = vectorMap(i)(j)\n\n val b = vectorMap(i)(k)\n val c = vectorMap(k)(j)\n val distance = Math.min(a, b + c)\n vectorMap(i)(j) = distance\n })\n })\n })\n vectorMap\n }\n}\n\nobject Main extends App {\n val INF = 1001001001\n val n, m, l = Scanner.nextInt()\n\n val data: Array[Array[Int]] = Array.fill(m, 3)(Scanner.nextInt())\n val q = Scanner.nextInt()\n val test: Array[Array[Int]] = Array.fill(q, 2)(Scanner.nextInt())\n\n val distanceArray: Array[Array[Int]] = Array.fill[Int](n, n)(INF)\n Loop.rep(n, i => distanceArray(i)(i) = 0)\n data.map { a =>\n distanceArray(a(0) - 1)(a(1) - 1) = a(2)\n distanceArray(a(1) - 1)(a(0) - 1) = a(2)\n }\n val tidyDistanceVector = WarshallFloyd.run(n, distanceArray)\n\n val fuelArray: Array[Array[Int]] = Array.fill[Int](n, n)(INF)\n Loop.rep(n, i => fuelArray(i)(i) = 1)\n Loop.rep(n, x => Loop.rep(n, y => { if (tidyDistanceVector(x)(y) <= l) fuelArray(x)(y) = 1 }))\n\n val tidyFuelVector = WarshallFloyd.run(n, fuelArray)\n\n test.foreach { q =>\n val x = q(0) - 1\n val y = q(1) - 1\n val fuelReplenishmentTimes = tidyFuelVector(x)(y)\n println(if (fuelReplenishmentTimes >= INF) -1 else fuelReplenishmentTimes - 1)\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N towns numbered 1 to N and M roads. The i-th road connects Town A_i and Town B_i bidirectionally and has a length of C_i.\n\nTakahashi will travel between these towns by car, passing through these roads. The fuel tank of his car can contain at most L liters of fuel, and one liter of fuel is consumed for each unit distance traveled. When visiting a town while traveling, he can full the tank (or choose not to do so). Travel that results in the tank becoming empty halfway on the road cannot be done.\n\nProcess the following Q queries:\n\nThe tank is now full. Find the minimum number of times he needs to full his tank while traveling from Town s_i to Town t_i. If Town t_i is unreachable, print -1.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 300\n\n0 \\leq M \\leq \\frac{N(N-1)}{2}\n\n1 \\leq L \\leq 10^9\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\n\\left(A_i, B_i\\right) \\neq \\left(A_j, B_j\\right) (if i \\neq j)\n\n\\left(A_i, B_i\\right) \\neq \\left(B_j, A_j\\right) (if i \\neq j)\n\n1 \\leq C_i \\leq 10^9\n\n1 \\leq Q \\leq N\\left(N-1\\right)\n\n1 \\leq s_i, t_i \\leq N\n\ns_i \\neq t_i\n\n\\left(s_i, t_i\\right) \\neq \\left(s_j, t_j\\right) (if i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M L\nA_1 B_1 C_1\n:\nA_M B_M C_M\nQ\ns_1 t_1\n:\ns_Q t_Q\n\nOutput\n\nPrint Q lines.\n\nThe i-th line should contain the minimum number of times the tank needs to be fulled while traveling from Town s_i to Town t_i. If Town t_i is unreachable, the line should contain -1 instead.\n\nSample Input 1\n\n3 2 5\n1 2 3\n2 3 3\n2\n3 2\n1 3\n\nSample Output 1\n\n0\n1\n\nTo travel from Town 3 to Town 2, we can use the second road to reach Town 2 without fueling the tank on the way.\n\nTo travel from Town 1 to Town 3, we can first use the first road to get to Town 2, full the tank, and use the second road to reach Town 3.\n\nSample Input 2\n\n4 0 1\n1\n2 1\n\nSample Output 2\n\n-1\n\nThere may be no road at all.\n\nSample Input 3\n\n5 4 4\n1 2 2\n2 3 2\n3 4 3\n4 5 2\n20\n2 1\n3 1\n4 1\n5 1\n1 2\n3 2\n4 2\n5 2\n1 3\n2 3\n4 3\n5 3\n1 4\n2 4\n3 4\n5 4\n1 5\n2 5\n3 5\n4 5\n\nSample Output 3\n\n0\n0\n1\n2\n0\n0\n1\n2\n0\n0\n0\n1\n1\n1\n0\n0\n2\n2\n1\n0", "sample_input": "3 2 5\n1 2 3\n2 3 3\n2\n3 2\n1 3\n"}, "reference_outputs": ["0\n1\n"], "source_document_id": "p02889", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N towns numbered 1 to N and M roads. The i-th road connects Town A_i and Town B_i bidirectionally and has a length of C_i.\n\nTakahashi will travel between these towns by car, passing through these roads. The fuel tank of his car can contain at most L liters of fuel, and one liter of fuel is consumed for each unit distance traveled. When visiting a town while traveling, he can full the tank (or choose not to do so). Travel that results in the tank becoming empty halfway on the road cannot be done.\n\nProcess the following Q queries:\n\nThe tank is now full. Find the minimum number of times he needs to full his tank while traveling from Town s_i to Town t_i. If Town t_i is unreachable, print -1.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 300\n\n0 \\leq M \\leq \\frac{N(N-1)}{2}\n\n1 \\leq L \\leq 10^9\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\n\\left(A_i, B_i\\right) \\neq \\left(A_j, B_j\\right) (if i \\neq j)\n\n\\left(A_i, B_i\\right) \\neq \\left(B_j, A_j\\right) (if i \\neq j)\n\n1 \\leq C_i \\leq 10^9\n\n1 \\leq Q \\leq N\\left(N-1\\right)\n\n1 \\leq s_i, t_i \\leq N\n\ns_i \\neq t_i\n\n\\left(s_i, t_i\\right) \\neq \\left(s_j, t_j\\right) (if i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M L\nA_1 B_1 C_1\n:\nA_M B_M C_M\nQ\ns_1 t_1\n:\ns_Q t_Q\n\nOutput\n\nPrint Q lines.\n\nThe i-th line should contain the minimum number of times the tank needs to be fulled while traveling from Town s_i to Town t_i. If Town t_i is unreachable, the line should contain -1 instead.\n\nSample Input 1\n\n3 2 5\n1 2 3\n2 3 3\n2\n3 2\n1 3\n\nSample Output 1\n\n0\n1\n\nTo travel from Town 3 to Town 2, we can use the second road to reach Town 2 without fueling the tank on the way.\n\nTo travel from Town 1 to Town 3, we can first use the first road to get to Town 2, full the tank, and use the second road to reach Town 3.\n\nSample Input 2\n\n4 0 1\n1\n2 1\n\nSample Output 2\n\n-1\n\nThere may be no road at all.\n\nSample Input 3\n\n5 4 4\n1 2 2\n2 3 2\n3 4 3\n4 5 2\n20\n2 1\n3 1\n4 1\n5 1\n1 2\n3 2\n4 2\n5 2\n1 3\n2 3\n4 3\n5 3\n1 4\n2 4\n3 4\n5 4\n1 5\n2 5\n3 5\n4 5\n\nSample Output 3\n\n0\n0\n1\n2\n0\n0\n1\n2\n0\n0\n0\n1\n1\n1\n0\n0\n2\n2\n1\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3827, "cpu_time_ms": 1245, "memory_kb": 48828}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s874222892", "group_id": "codeNet:p02889", "input_text": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\nimport scala.collection.mutable.{Map, Queue, PriorityQueue}\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val N, M, L = in.next().toInt\n val graph = Array.fill[List[(Int, Int)]](N+1)(Nil) // (node, dist)\n\n for (_ <- 1 to M) {\n val a, b, c = in.next().toInt\n if(c <= L) {\n graph(a) = (b, c) :: graph(a)\n graph(b) = (a, c) :: graph(b)\n }\n }\n\n def lte(a: (Int, Int), b: (Int, Int)): Boolean = { // <= 小さい方が強い\n if (a._1 != b._1)\n a._1 <= b._1\n else\n a._2 <= b._2\n \n }\n\n // \n val ans = Array.ofDim[Long](N+1, N+1)\n for (y <- 1 to N)\n for (x <- 1 to N)\n ans(y)(x) = -1\n\n val done = new Array[Boolean](N+1)\n\n for (s <- 1 to N) {\n // init\n for (i <- 1 to N) {\n done(i) = false\n }\n\n // prepare\n\n\n // calc\n val pq = new PriorityQueue[((Int, Int), Int)]\n pq.enqueue(((0, -L), s))\n\n while(!pq.isEmpty) {\n println(pq)\n val ((cnt, _rest), node) = pq.dequeue()\n val rest = -_rest\n if (!done(node)) {\n done(node) = true\n ans(s)(node) = cnt\n for (((jinode: Int), dist) <- graph(node) if !done(jinode)) {\n val next =\n if (rest >= dist)\n (cnt, -(rest-dist))\n else\n (cnt+1, -(L-dist))\n pq.enqueue((next, jinode))\n }\n }\n }\n\n }\n\n \n //\n val Q = in.next().toInt\n for (_ <- 1 to Q) {\n val s, t = in.next().toInt\n pw.println(ans(s)(t))\n }\n pw.flush()\n}\n\n\nclass InputReader(stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream))\n private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n", "language": "Scala", "metadata": {"date": 1571539054, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02889.html", "problem_id": "p02889", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02889/input.txt", "sample_output_relpath": "derived/input_output/data/p02889/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02889/Scala/s874222892.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s874222892", "user_id": "u098968285"}, "prompt_components": {"gold_output": "0\n1\n", "input_to_evaluate": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\nimport scala.collection.mutable.{Map, Queue, PriorityQueue}\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val N, M, L = in.next().toInt\n val graph = Array.fill[List[(Int, Int)]](N+1)(Nil) // (node, dist)\n\n for (_ <- 1 to M) {\n val a, b, c = in.next().toInt\n if(c <= L) {\n graph(a) = (b, c) :: graph(a)\n graph(b) = (a, c) :: graph(b)\n }\n }\n\n def lte(a: (Int, Int), b: (Int, Int)): Boolean = { // <= 小さい方が強い\n if (a._1 != b._1)\n a._1 <= b._1\n else\n a._2 <= b._2\n \n }\n\n // \n val ans = Array.ofDim[Long](N+1, N+1)\n for (y <- 1 to N)\n for (x <- 1 to N)\n ans(y)(x) = -1\n\n val done = new Array[Boolean](N+1)\n\n for (s <- 1 to N) {\n // init\n for (i <- 1 to N) {\n done(i) = false\n }\n\n // prepare\n\n\n // calc\n val pq = new PriorityQueue[((Int, Int), Int)]\n pq.enqueue(((0, -L), s))\n\n while(!pq.isEmpty) {\n println(pq)\n val ((cnt, _rest), node) = pq.dequeue()\n val rest = -_rest\n if (!done(node)) {\n done(node) = true\n ans(s)(node) = cnt\n for (((jinode: Int), dist) <- graph(node) if !done(jinode)) {\n val next =\n if (rest >= dist)\n (cnt, -(rest-dist))\n else\n (cnt+1, -(L-dist))\n pq.enqueue((next, jinode))\n }\n }\n }\n\n }\n\n \n //\n val Q = in.next().toInt\n for (_ <- 1 to Q) {\n val s, t = in.next().toInt\n pw.println(ans(s)(t))\n }\n pw.flush()\n}\n\n\nclass InputReader(stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream))\n private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N towns numbered 1 to N and M roads. The i-th road connects Town A_i and Town B_i bidirectionally and has a length of C_i.\n\nTakahashi will travel between these towns by car, passing through these roads. The fuel tank of his car can contain at most L liters of fuel, and one liter of fuel is consumed for each unit distance traveled. When visiting a town while traveling, he can full the tank (or choose not to do so). Travel that results in the tank becoming empty halfway on the road cannot be done.\n\nProcess the following Q queries:\n\nThe tank is now full. Find the minimum number of times he needs to full his tank while traveling from Town s_i to Town t_i. If Town t_i is unreachable, print -1.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 300\n\n0 \\leq M \\leq \\frac{N(N-1)}{2}\n\n1 \\leq L \\leq 10^9\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\n\\left(A_i, B_i\\right) \\neq \\left(A_j, B_j\\right) (if i \\neq j)\n\n\\left(A_i, B_i\\right) \\neq \\left(B_j, A_j\\right) (if i \\neq j)\n\n1 \\leq C_i \\leq 10^9\n\n1 \\leq Q \\leq N\\left(N-1\\right)\n\n1 \\leq s_i, t_i \\leq N\n\ns_i \\neq t_i\n\n\\left(s_i, t_i\\right) \\neq \\left(s_j, t_j\\right) (if i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M L\nA_1 B_1 C_1\n:\nA_M B_M C_M\nQ\ns_1 t_1\n:\ns_Q t_Q\n\nOutput\n\nPrint Q lines.\n\nThe i-th line should contain the minimum number of times the tank needs to be fulled while traveling from Town s_i to Town t_i. If Town t_i is unreachable, the line should contain -1 instead.\n\nSample Input 1\n\n3 2 5\n1 2 3\n2 3 3\n2\n3 2\n1 3\n\nSample Output 1\n\n0\n1\n\nTo travel from Town 3 to Town 2, we can use the second road to reach Town 2 without fueling the tank on the way.\n\nTo travel from Town 1 to Town 3, we can first use the first road to get to Town 2, full the tank, and use the second road to reach Town 3.\n\nSample Input 2\n\n4 0 1\n1\n2 1\n\nSample Output 2\n\n-1\n\nThere may be no road at all.\n\nSample Input 3\n\n5 4 4\n1 2 2\n2 3 2\n3 4 3\n4 5 2\n20\n2 1\n3 1\n4 1\n5 1\n1 2\n3 2\n4 2\n5 2\n1 3\n2 3\n4 3\n5 3\n1 4\n2 4\n3 4\n5 4\n1 5\n2 5\n3 5\n4 5\n\nSample Output 3\n\n0\n0\n1\n2\n0\n0\n1\n2\n0\n0\n0\n1\n1\n1\n0\n0\n2\n2\n1\n0", "sample_input": "3 2 5\n1 2 3\n2 3 3\n2\n3 2\n1 3\n"}, "reference_outputs": ["0\n1\n"], "source_document_id": "p02889", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N towns numbered 1 to N and M roads. The i-th road connects Town A_i and Town B_i bidirectionally and has a length of C_i.\n\nTakahashi will travel between these towns by car, passing through these roads. The fuel tank of his car can contain at most L liters of fuel, and one liter of fuel is consumed for each unit distance traveled. When visiting a town while traveling, he can full the tank (or choose not to do so). Travel that results in the tank becoming empty halfway on the road cannot be done.\n\nProcess the following Q queries:\n\nThe tank is now full. Find the minimum number of times he needs to full his tank while traveling from Town s_i to Town t_i. If Town t_i is unreachable, print -1.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 300\n\n0 \\leq M \\leq \\frac{N(N-1)}{2}\n\n1 \\leq L \\leq 10^9\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\n\\left(A_i, B_i\\right) \\neq \\left(A_j, B_j\\right) (if i \\neq j)\n\n\\left(A_i, B_i\\right) \\neq \\left(B_j, A_j\\right) (if i \\neq j)\n\n1 \\leq C_i \\leq 10^9\n\n1 \\leq Q \\leq N\\left(N-1\\right)\n\n1 \\leq s_i, t_i \\leq N\n\ns_i \\neq t_i\n\n\\left(s_i, t_i\\right) \\neq \\left(s_j, t_j\\right) (if i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M L\nA_1 B_1 C_1\n:\nA_M B_M C_M\nQ\ns_1 t_1\n:\ns_Q t_Q\n\nOutput\n\nPrint Q lines.\n\nThe i-th line should contain the minimum number of times the tank needs to be fulled while traveling from Town s_i to Town t_i. If Town t_i is unreachable, the line should contain -1 instead.\n\nSample Input 1\n\n3 2 5\n1 2 3\n2 3 3\n2\n3 2\n1 3\n\nSample Output 1\n\n0\n1\n\nTo travel from Town 3 to Town 2, we can use the second road to reach Town 2 without fueling the tank on the way.\n\nTo travel from Town 1 to Town 3, we can first use the first road to get to Town 2, full the tank, and use the second road to reach Town 3.\n\nSample Input 2\n\n4 0 1\n1\n2 1\n\nSample Output 2\n\n-1\n\nThere may be no road at all.\n\nSample Input 3\n\n5 4 4\n1 2 2\n2 3 2\n3 4 3\n4 5 2\n20\n2 1\n3 1\n4 1\n5 1\n1 2\n3 2\n4 2\n5 2\n1 3\n2 3\n4 3\n5 3\n1 4\n2 4\n3 4\n5 4\n1 5\n2 5\n3 5\n4 5\n\nSample Output 3\n\n0\n0\n1\n2\n0\n0\n1\n2\n0\n0\n0\n1\n1\n1\n0\n0\n2\n2\n1\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1985, "cpu_time_ms": 2115, "memory_kb": 187144}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s450636892", "group_id": "codeNet:p02897", "input_text": "object Main {\n import java.io.{BufferedReader, InputStream, InputStreamReader}\n import java.util.StringTokenizer\n import scala.reflect.ClassTag\n\n def main(args: Array[String]): Unit = {\n val out = new java.io.PrintWriter(System.out)\n new Main(out, new InputReader(System.in)).solve()\n out.flush()\n }\n\n private[this] val oj = System.getenv(\"ATCODER_DEBUG\") == null\n @inline private final def DEBUG(f: => Unit): Unit = {\n if (!oj){ f }\n }\n @inline private final def debug(as: Array[Boolean]): Unit = if (!oj){ debug(as.map(x => if(x) \"1\" else \"0\").mkString) }\n @inline private final def debug(as: Array[Int]): Unit = if (!oj){ debug(as.mkString(\" \")) }\n @inline private final def debug(as: Array[Long]): Unit =if (!oj){ debug(as.mkString(\" \")) }\n @inline private final def debugDim(m: Array[Array[Long]]): Unit = if (!oj){\n REP(m.length) { i =>\n debug(m(i))\n }\n }\n @inline private final def debugDimFlip(m: Array[Array[Long]]): Unit = if (!oj){\n REP(m(0).length) { j =>\n REP(m.length) { i =>\n System.err.print(m(i)(j))\n System.err.print(\" \")\n }\n System.err.println()\n }\n }\n @inline private final def debug(s: => String): Unit = DEBUG {\n System.err.println(s)\n }\n @inline private final def debugL(num: => Long): Unit = DEBUG {\n System.err.println(num)\n }\n private def isDebug[A](debug: => A, online: => A): A = {\n if (oj) online else debug\n }\n\n class InputReader(val stream: InputStream) {\n private[this] val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private[this] var tokenizer: StringTokenizer = _\n\n @inline private[this] final def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = Integer.parseInt(next())\n def nextLong(): Long = java.lang.Long.parseLong(next())\n def nextChar(): Char = next().charAt(0)\n\n def ni(): Int = nextInt()\n def nl(): Long = nextLong()\n def nc(): Char = nextChar()\n def ns(): String = next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n }\n\n @inline private final def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n @inline private final def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n @inline private final def TO(from: Int, to: Int)(f: Int => Unit): Unit = {\n REP(to - from + 1, from)(f)\n }\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n def cumSum(as: Array[Int]): Array[Long] = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n\nclass Main(out: java.io.PrintWriter, sc: Main.InputReader) {\n import sc._\n import Main._\n import java.util.Arrays.sort\n\n import scala.collection.mutable\n import math.{abs, max, min}\n import mutable.ArrayBuffer\n\n // toIntとか+7とかするならvalにしろ\n final private[this] val MOD = 1000000007\n\n def solve(): Unit = {\n val n = ni()\n if (n % 2 == 0) out.println(\"0.5\")\n else out.println(f\"${((n/2).toDouble+1)/n}%.9f\")\n }\n}", "language": "Scala", "metadata": {"date": 1569718988, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s450636892.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s450636892", "user_id": "u460609472"}, "prompt_components": {"gold_output": "0.5000000000\n", "input_to_evaluate": "object Main {\n import java.io.{BufferedReader, InputStream, InputStreamReader}\n import java.util.StringTokenizer\n import scala.reflect.ClassTag\n\n def main(args: Array[String]): Unit = {\n val out = new java.io.PrintWriter(System.out)\n new Main(out, new InputReader(System.in)).solve()\n out.flush()\n }\n\n private[this] val oj = System.getenv(\"ATCODER_DEBUG\") == null\n @inline private final def DEBUG(f: => Unit): Unit = {\n if (!oj){ f }\n }\n @inline private final def debug(as: Array[Boolean]): Unit = if (!oj){ debug(as.map(x => if(x) \"1\" else \"0\").mkString) }\n @inline private final def debug(as: Array[Int]): Unit = if (!oj){ debug(as.mkString(\" \")) }\n @inline private final def debug(as: Array[Long]): Unit =if (!oj){ debug(as.mkString(\" \")) }\n @inline private final def debugDim(m: Array[Array[Long]]): Unit = if (!oj){\n REP(m.length) { i =>\n debug(m(i))\n }\n }\n @inline private final def debugDimFlip(m: Array[Array[Long]]): Unit = if (!oj){\n REP(m(0).length) { j =>\n REP(m.length) { i =>\n System.err.print(m(i)(j))\n System.err.print(\" \")\n }\n System.err.println()\n }\n }\n @inline private final def debug(s: => String): Unit = DEBUG {\n System.err.println(s)\n }\n @inline private final def debugL(num: => Long): Unit = DEBUG {\n System.err.println(num)\n }\n private def isDebug[A](debug: => A, online: => A): A = {\n if (oj) online else debug\n }\n\n class InputReader(val stream: InputStream) {\n private[this] val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private[this] var tokenizer: StringTokenizer = _\n\n @inline private[this] final def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = Integer.parseInt(next())\n def nextLong(): Long = java.lang.Long.parseLong(next())\n def nextChar(): Char = next().charAt(0)\n\n def ni(): Int = nextInt()\n def nl(): Long = nextLong()\n def nc(): Char = nextChar()\n def ns(): String = next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n }\n\n @inline private final def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n @inline private final def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n @inline private final def TO(from: Int, to: Int)(f: Int => Unit): Unit = {\n REP(to - from + 1, from)(f)\n }\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n def cumSum(as: Array[Int]): Array[Long] = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n\nclass Main(out: java.io.PrintWriter, sc: Main.InputReader) {\n import sc._\n import Main._\n import java.util.Arrays.sort\n\n import scala.collection.mutable\n import math.{abs, max, min}\n import mutable.ArrayBuffer\n\n // toIntとか+7とかするならvalにしろ\n final private[this] val MOD = 1000000007\n\n def solve(): Unit = {\n val n = ni()\n if (n % 2 == 0) out.println(\"0.5\")\n else out.println(f\"${((n/2).toDouble+1)/n}%.9f\")\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4085, "cpu_time_ms": 341, "memory_kb": 25664}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s180418595", "group_id": "codeNet:p02898", "input_text": "import scala.math._\n\nobject Main extends App {\n\n val YES = \"YES\"\n val Yes = \"Yes\"\n val NO = \"NO\"\n val No = \"No\"\n\n val input: Array[Array[Int]] = Array.ofDim(6, 6000000)\n ///////////////////////////////////////////\n\n val sc = new java.util.Scanner(System.in)\n val n, k = sc.nextInt\n val t = List.fill(n)(sc.nextInt)\n\n val ans = t.foldLeft(0){ case (acc, i) => if (k <= i) acc + 1 else acc}\n println(ans)\n\n ///////////////////////////////////////////\n\n def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =\n Iterator.iterate(start)(_ + step).takeWhile(_ <= end)\n\n def lcm(a :Int, b :Int): Int =\n a / gcd(a, b) * b\n\n def lcm(a :Long, b :Long): Long =\n a / gcd(a, b) * b\n\n def gcd(a: Int, b: Int): Int =\n if (b == 0) a else gcd(b, a % b)\n\n def gcd(a: Long, b: Long): Long =\n if (b == 0) a else gcd(b, a % b)\n\n def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =\n a.get(key) match {\n case Some(v) => a.updated(key, f(value, v))\n case _ => a + (key -> value)\n }\n}", "language": "Scala", "metadata": {"date": 1575338033, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02898.html", "problem_id": "p02898", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02898/input.txt", "sample_output_relpath": "derived/input_output/data/p02898/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02898/Scala/s180418595.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s180418595", "user_id": "u040380439"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.math._\n\nobject Main extends App {\n\n val YES = \"YES\"\n val Yes = \"Yes\"\n val NO = \"NO\"\n val No = \"No\"\n\n val input: Array[Array[Int]] = Array.ofDim(6, 6000000)\n ///////////////////////////////////////////\n\n val sc = new java.util.Scanner(System.in)\n val n, k = sc.nextInt\n val t = List.fill(n)(sc.nextInt)\n\n val ans = t.foldLeft(0){ case (acc, i) => if (k <= i) acc + 1 else acc}\n println(ans)\n\n ///////////////////////////////////////////\n\n def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =\n Iterator.iterate(start)(_ + step).takeWhile(_ <= end)\n\n def lcm(a :Int, b :Int): Int =\n a / gcd(a, b) * b\n\n def lcm(a :Long, b :Long): Long =\n a / gcd(a, b) * b\n\n def gcd(a: Int, b: Int): Int =\n if (b == 0) a else gcd(b, a % b)\n\n def gcd(a: Long, b: Long): Long =\n if (b == 0) a else gcd(b, a % b)\n\n def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =\n a.get(key) match {\n case Some(v) => a.updated(key, f(value, v))\n case _ => a + (key -> value)\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nN friends of Takahashi has come to a theme park.\n\nTo ride the most popular roller coaster in the park, you must be at least K centimeters tall.\n\nThe i-th friend is h_i centimeters tall.\n\nHow many of the Takahashi's friends can ride the roller coaster?\n\nConstraints\n\n1 \\le N \\le 10^5\n\n1 \\le K \\le 500\n\n1 \\le h_i \\le 500\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nh_1 h_2 \\ldots h_N\n\nOutput\n\nPrint the number of people among the Takahashi's friends who can ride the roller coaster.\n\nSample Input 1\n\n4 150\n150 140 100 200\n\nSample Output 1\n\n2\n\nTwo of them can ride the roller coaster: the first and fourth friends.\n\nSample Input 2\n\n1 500\n499\n\nSample Output 2\n\n0\n\nSample Input 3\n\n5 1\n100 200 300 400 500\n\nSample Output 3\n\n5", "sample_input": "4 150\n150 140 100 200\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02898", "source_text": "Score : 200 points\n\nProblem Statement\n\nN friends of Takahashi has come to a theme park.\n\nTo ride the most popular roller coaster in the park, you must be at least K centimeters tall.\n\nThe i-th friend is h_i centimeters tall.\n\nHow many of the Takahashi's friends can ride the roller coaster?\n\nConstraints\n\n1 \\le N \\le 10^5\n\n1 \\le K \\le 500\n\n1 \\le h_i \\le 500\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nh_1 h_2 \\ldots h_N\n\nOutput\n\nPrint the number of people among the Takahashi's friends who can ride the roller coaster.\n\nSample Input 1\n\n4 150\n150 140 100 200\n\nSample Output 1\n\n2\n\nTwo of them can ride the roller coaster: the first and fourth friends.\n\nSample Input 2\n\n1 500\n499\n\nSample Output 2\n\n0\n\nSample Input 3\n\n5 1\n100 200 300 400 500\n\nSample Output 3\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1037, "cpu_time_ms": 777, "memory_kb": 194304}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s448482797", "group_id": "codeNet:p02899", "input_text": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val n = sc.nextInt()\n var a: Seq[(Int, Int)] = Seq()\n for (i <- 0 until n) {\n a :+= (sc.nextInt(), i + 1)\n }\n a = a.sorted\n for (ans <- a) {\n print(ans._2)\n print(\" \")\n }\n println()\n }\n}", "language": "Scala", "metadata": {"date": 1586370004, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s448482797.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s448482797", "user_id": "u602865659"}, "prompt_components": {"gold_output": "3 1 2\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val n = sc.nextInt()\n var a: Seq[(Int, Int)] = Seq()\n for (i <- 0 until n) {\n a :+= (sc.nextInt(), i + 1)\n }\n a = a.sorted\n for (ans <- a) {\n print(ans._2)\n print(\" \")\n }\n println()\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 115828}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s353430117", "group_id": "codeNet:p02900", "input_text": "import java.io.{BufferedReader, InputStreamReader}\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val in = new BufferedReader(new InputStreamReader(System.in))\n val Array(a, b) = in.readLine().split(\"\\\\s+\").map(_.toInt)\n\n System.out.println((prime(a).toSet & prime(b).toSet).size)\n }\n\n\n def prime(n: Int): List[Int] = {\n def _prime(n: Int, ps: List[Int]): List[Int] = {\n (2 to n).find(n % _ == 0) match {\n case Some(p) => _prime(n / p, p :: ps)\n case None => n :: ps\n }\n }\n\n _prime(n, Nil)\n }\n}\n", "language": "Scala", "metadata": {"date": 1569729139, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s353430117.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s353430117", "user_id": "u178269371"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.{BufferedReader, InputStreamReader}\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val in = new BufferedReader(new InputStreamReader(System.in))\n val Array(a, b) = in.readLine().split(\"\\\\s+\").map(_.toInt)\n\n System.out.println((prime(a).toSet & prime(b).toSet).size)\n }\n\n\n def prime(n: Int): List[Int] = {\n def _prime(n: Int, ps: List[Int]): List[Int] = {\n (2 to n).find(n % _ == 0) match {\n case Some(p) => _prime(n / p, p :: ps)\n case None => n :: ps\n }\n }\n\n _prime(n, Nil)\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 551, "cpu_time_ms": 328, "memory_kb": 25544}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s260137005", "group_id": "codeNet:p02900", "input_text": "import java.util.Scanner\n\nobject Main extends App{\n val sc = new Scanner(System.in)\n\n val a = sc.nextLong\n val b = sc.nextLong\n\n val g = gcd(a,b)\n val sqrtG = Math.sqrt(g).ceil.toLong\n\n val res =\n g match {\n case 1 => 1\n case 2 => 2\n case 3 => 2\n case gg => {\n val temp = loop( (gg, Vector(1), 2) )._2\n temp.size\n }\n }\n\n println(res)\n\n\n def gcd(a: Long, b: Long): Long ={\n (a,b) match{\n case (x,y) if y == 0 => x\n case (x,y) if x < y => gcd(y, x)\n case (x,y) => gcd(y, x % y)\n }\n }\n\n def loop( tuple: (Long, Vector[Long], Long)): (Long, Vector[Long], Long) = {\n val (n, vec, diviser) = tuple\n if( n == 1 || diviser > sqrtG) (n, vec, diviser)\n else {\n def divLoop(num: Long, d: Long): Long =\n if(num % d != 0) num else divLoop(num / d, d)\n\n val newN = divLoop(n, diviser)\n val newVec = if(newN == n) vec else vec :+ diviser\n\n loop((newN, newVec, diviser + 1))\n }\n }\n\n\n\n}", "language": "Scala", "metadata": {"date": 1569721800, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s260137005.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s260137005", "user_id": "u829407811"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App{\n val sc = new Scanner(System.in)\n\n val a = sc.nextLong\n val b = sc.nextLong\n\n val g = gcd(a,b)\n val sqrtG = Math.sqrt(g).ceil.toLong\n\n val res =\n g match {\n case 1 => 1\n case 2 => 2\n case 3 => 2\n case gg => {\n val temp = loop( (gg, Vector(1), 2) )._2\n temp.size\n }\n }\n\n println(res)\n\n\n def gcd(a: Long, b: Long): Long ={\n (a,b) match{\n case (x,y) if y == 0 => x\n case (x,y) if x < y => gcd(y, x)\n case (x,y) => gcd(y, x % y)\n }\n }\n\n def loop( tuple: (Long, Vector[Long], Long)): (Long, Vector[Long], Long) = {\n val (n, vec, diviser) = tuple\n if( n == 1 || diviser > sqrtG) (n, vec, diviser)\n else {\n def divLoop(num: Long, d: Long): Long =\n if(num % d != 0) num else divLoop(num / d, d)\n\n val newN = divLoop(n, diviser)\n val newVec = if(newN == n) vec else vec :+ diviser\n\n loop((newN, newVec, diviser + 1))\n }\n }\n\n\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 996, "cpu_time_ms": 411, "memory_kb": 48396}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s793011795", "group_id": "codeNet:p02901", "input_text": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\nimport scala.collection.mutable.{Map, Queue, PriorityQueue}\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val N, M = in.next().toInt\n val a = new Array[Int](M+1)\n val b = new Array[Int](M+1)\n val c = Array.ofDim[Int](M+1, N+1)\n for (i <- 1 to M) {\n val _a, _b = in.next().toInt\n a(i) = _a; b(i) = _b\n for (k <- 1 to _b) {\n c(i)(k) = in.next().toInt\n }\n }\n\n\n //\n def toKey(lst: Array[Boolean]): Int = {\n var res = 0\n for (i <- 1 to N) {\n if(lst(i)) {\n res += 1 << (i-1)\n }\n }\n res\n }\n\n def toArray(key: Int): Array[Boolean] = {\n val res = new Array[Boolean](N+1)\n res(0) = true\n\n var i = 1\n var k = key\n while (k > 0) {\n if(k%2 == 1)\n res(i) = true\n k /= 2\n i += 1\n }\n\n res\n }\n\n //var hash = Map[String, Int]() // (opened, price)\n val imax = Int.MaxValue\n var hash = Array.fill[Int](1< 0) {\n if(k%2 == 1)\n res(i) = true\n k /= 2\n i += 1\n }\n\n res\n }\n\n //var hash = Map[String, Int]() // (opened, price)\n val imax = Int.MaxValue\n var hash = Array.fill[Int](1< \"Cloudy\", \"Cloudy\" -> \"Rainy\", \"Rainy\" -> \"Sunny\")(sc.next()))\n}\n", "language": "Scala", "metadata": {"date": 1596136762, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s368521313.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s368521313", "user_id": "u737111725"}, "prompt_components": {"gold_output": "Cloudy\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n println(Map(\"Sunny\" -> \"Cloudy\", \"Cloudy\" -> \"Rainy\", \"Rainy\" -> \"Sunny\")(sc.next()))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 495, "memory_kb": 55304}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s233537499", "group_id": "codeNet:p02909", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n val s = StdIn.readLine()\n\n if (s == \"Sunny\") println(\"Cloudy\")\n else if (s == \"Cloudy\") println(\"Rainy\")\n else if (s == \"Rainy\") println(\"Sunny\")\n\n}\n \n\n", "language": "Scala", "metadata": {"date": 1568595876, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s233537499.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s233537499", "user_id": "u258933429"}, "prompt_components": {"gold_output": "Cloudy\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n val s = StdIn.readLine()\n\n if (s == \"Sunny\") println(\"Cloudy\")\n else if (s == \"Cloudy\") println(\"Rainy\")\n else if (s == \"Rainy\") println(\"Sunny\")\n\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 342, "memory_kb": 25288}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s697265880", "group_id": "codeNet:p02910", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val (even, odd) = sc.next().zipWithIndex.partition { case (_, i) => i % 2 == 0 }\n val ((evenSteps, _), (oddSteps, _)) = (even.unzip, odd.unzip)\n println(if (evenSteps.contains('L') || oddSteps.contains('R')) \"No\" else \"Yes\")\n}\n", "language": "Scala", "metadata": {"date": 1596594981, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s697265880.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s697265880", "user_id": "u737111725"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val (even, odd) = sc.next().zipWithIndex.partition { case (_, i) => i % 2 == 0 }\n val ((evenSteps, _), (oddSteps, _)) = (even.unzip, odd.unzip)\n println(if (evenSteps.contains('L') || oddSteps.contains('R')) \"No\" else \"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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 506, "memory_kb": 55456}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s598752314", "group_id": "codeNet:p02910", "input_text": "\nobject Main extends App {\n\n val s = scala.io.StdIn.readLine()\n\n def solve(): String = {\n for(i <- 0 until s.length) {\n if (i % 2 == 0) {\n if(s(i) == 'L') return \"No\"\n } else {\n if(s(i) == 'R') return \"No\"\n }\n }\n return \"Yes\"\n }\n\n println(solve)\n\n}", "language": "Scala", "metadata": {"date": 1571019540, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s598752314.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s598752314", "user_id": "u947008426"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "\nobject Main extends App {\n\n val s = scala.io.StdIn.readLine()\n\n def solve(): String = {\n for(i <- 0 until s.length) {\n if (i % 2 == 0) {\n if(s(i) == 'L') return \"No\"\n } else {\n if(s(i) == 'R') return \"No\"\n }\n }\n return \"Yes\"\n }\n\n println(solve)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 290, "cpu_time_ms": 330, "memory_kb": 25424}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s868102631", "group_id": "codeNet:p02910", "input_text": "import java.io.{BufferedReader, InputStreamReader}\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val steps = new BufferedReader(new InputStreamReader(System.in)).readLine().toCharArray\n\n System.out.println(\n if (steps.zipWithIndex.forall { case (step, index) =>\n index % 2 == 0 && Array('R', 'U', 'D').contains(step) || index % 2 == 1 && Array('L', 'U', 'D').contains(step)\n }) {\n \"Yes\"\n } else {\n \"No\"\n }\n )\n }\n}\n", "language": "Scala", "metadata": {"date": 1569385294, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s868102631.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s868102631", "user_id": "u178269371"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.io.{BufferedReader, InputStreamReader}\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val steps = new BufferedReader(new InputStreamReader(System.in)).readLine().toCharArray\n\n System.out.println(\n if (steps.zipWithIndex.forall { case (step, index) =>\n index % 2 == 0 && Array('R', 'U', 'D').contains(step) || index % 2 == 1 && Array('L', 'U', 'D').contains(step)\n }) {\n \"Yes\"\n } else {\n \"No\"\n }\n )\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 333, "memory_kb": 25544}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s297795737", "group_id": "codeNet:p02911", "input_text": "object Main extends App {\t\n val in = readLine.split(\" \").map(_.toInt)\n val order = for(_ <- 1 to in(2)) yield readLine.toInt\n val participant = List.fill(in(0))(in(1))\n val answer = participant.zipWithIndex.map{case(num, idx) => {\n \tval score = order.filter(_ != idx + 1).length\n num - score\n }}\n answer.foreach{num => if(num > 0) println(\"Yes\") else println(\"No\")}\n}", "language": "Scala", "metadata": {"date": 1568601206, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s297795737.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s297795737", "user_id": "u190068878"}, "prompt_components": {"gold_output": "No\nNo\nYes\nNo\nNo\nNo\n", "input_to_evaluate": "object Main extends App {\t\n val in = readLine.split(\" \").map(_.toInt)\n val order = for(_ <- 1 to in(2)) yield readLine.toInt\n val participant = List.fill(in(0))(in(1))\n val answer = participant.zipWithIndex.map{case(num, idx) => {\n \tval score = order.filter(_ != idx + 1).length\n num - score\n }}\n answer.foreach{num => if(num > 0) println(\"Yes\") else println(\"No\")}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 120868}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s850526250", "group_id": "codeNet:p02915", "input_text": "object Main extends App {\n val n = readInt\n println(n * n * n)\n}", "language": "Scala", "metadata": {"date": 1568351126, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s850526250.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s850526250", "user_id": "u782685137"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "object Main extends App {\n val n = readInt\n println(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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 66, "cpu_time_ms": 324, "memory_kb": 25428}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s520419902", "group_id": "codeNet:p02916", "input_text": "object Main extends App {\n\t// your code goes here\n\tval num = io.StdIn.readLine().toInt\n\tval order = io.StdIn.readLine().split(\" \").map(_.toInt)\n\tval manzoku = io.StdIn.readLine().split(\" \").map(_.toInt)\n\tval up = io.StdIn.readLine().split(\" \").map(_.toInt)\n\tval (t, _) = order.foldLeft((0, num))((t, o) => { \n\t\tval u = if(t._2 + 1 == o){up(t._2 - 1)}else{0}\n\t\t(t._1 + manzoku(o -1 ) + u, o) })\n\tprintln(t)\n}", "language": "Scala", "metadata": {"date": 1567907550, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s520419902.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s520419902", "user_id": "u186602385"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "object Main extends App {\n\t// your code goes here\n\tval num = io.StdIn.readLine().toInt\n\tval order = io.StdIn.readLine().split(\" \").map(_.toInt)\n\tval manzoku = io.StdIn.readLine().split(\" \").map(_.toInt)\n\tval up = io.StdIn.readLine().split(\" \").map(_.toInt)\n\tval (t, _) = order.foldLeft((0, num))((t, o) => { \n\t\tval u = if(t._2 + 1 == o){up(t._2 - 1)}else{0}\n\t\t(t._1 + manzoku(o -1 ) + u, o) })\n\tprintln(t)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 324, "memory_kb": 25528}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s770372420", "group_id": "codeNet:p02917", "input_text": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val A = Array.fill(sc.nextInt() - 1)(sc.nextLong())\n println((A :+ 0L).sliding(2).map(a => Math.min(a(0), a(1))).sum + A.head + A.last)\n }\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def calc(A: Array[Long]): Array[String] = {\n if (A.length == 0) Array.fill(0)(\"\")\n else {\n val last = A.zipWithIndex.map(x => (x._1 - x._2, x._1)).takeWhile(x => x._1 == A.head).last._2\n if (last == A.head) \"%d\".format(A.head) +: calc(A.zipWithIndex.map(x => (x._1 - x._2, x._1)).dropWhile(x => x._1 == A.head).map(x => x._2))\n else \"%d-%d\".format(A.head, last) +: calc(A.zipWithIndex.map(x => (x._1 - x._2, x._1)).dropWhile(x => x._1 == A.head).map(x => x._2))\n }\n }\n\n var memo: Map[(Long, Long), Long] = Map[(Long, Long), Long]()\n\n\n def recursive2(X: Set[Long], Y: Stream[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n\n def check(i: Int, X: String): Long = {\n if (X == \"\") 0 else check(i, X.tail) * i + X.head.toString.toLong\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def primeFactors(i: Long): List[Long] = primeFactors_(i, 1).sorted\n\n\n def primeFactors_(i: Long, j: Long): List[Long] = {\n if (j * j > i) List.empty else if (i % j == 0) primeFactors_(i, j + 1) ++ List[Long](j, i / j) else primeFactors_(i, j + 1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n}\n", "language": "Scala", "metadata": {"date": 1567992686, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s770372420.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s770372420", "user_id": "u779353743"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val A = Array.fill(sc.nextInt() - 1)(sc.nextLong())\n println((A :+ 0L).sliding(2).map(a => Math.min(a(0), a(1))).sum + A.head + A.last)\n }\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def calc(A: Array[Long]): Array[String] = {\n if (A.length == 0) Array.fill(0)(\"\")\n else {\n val last = A.zipWithIndex.map(x => (x._1 - x._2, x._1)).takeWhile(x => x._1 == A.head).last._2\n if (last == A.head) \"%d\".format(A.head) +: calc(A.zipWithIndex.map(x => (x._1 - x._2, x._1)).dropWhile(x => x._1 == A.head).map(x => x._2))\n else \"%d-%d\".format(A.head, last) +: calc(A.zipWithIndex.map(x => (x._1 - x._2, x._1)).dropWhile(x => x._1 == A.head).map(x => x._2))\n }\n }\n\n var memo: Map[(Long, Long), Long] = Map[(Long, Long), Long]()\n\n\n def recursive2(X: Set[Long], Y: Stream[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n\n def check(i: Int, X: String): Long = {\n if (X == \"\") 0 else check(i, X.tail) * i + X.head.toString.toLong\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def primeFactors(i: Long): List[Long] = primeFactors_(i, 1).sorted\n\n\n def primeFactors_(i: Long, j: Long): List[Long] = {\n if (j * j > i) List.empty else if (i % j == 0) primeFactors_(i, j + 1) ++ List[Long](j, i / j) else primeFactors_(i, j + 1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6679, "cpu_time_ms": 335, "memory_kb": 25420}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s338302564", "group_id": "codeNet:p02919", "input_text": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\nimport scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val N = in.next().toInt\n val P = new Array[Int](N+1)\n val indexMap = new Array[Int](N+1)\n for (i <- 1 to N) {\n P(i) = in.next().toInt\n indexMap(P(i)) = i\n }\n\n //\n val bit = new BIT(N+1)\n bit.add(N+1, 1)\n\n // 条件を満たす最大の値を返す\n def binarySearchMax(_min: Int, _max: Int, n: Int): Int = {\n def check(i: Int): Boolean = bit.sum(i) <= n\n\n def func(min: Int, max: Int): Int = {\n val mid: Int = (max + min) / 2\n (max - min) match{\n case 0 | 1 =>\n check(max) match{\n case true => max\n case false => min\n }\n case _ =>\n (check(mid)) match{\n case true => func(mid, max)\n case false => func(min, mid)\n }\n }\n }\n\n func(_min, _max)\n }\n\n // 条件を満たす最小の値を返す\n def binarySearchMin(_min: Int, _max: Int, n: Int): Int = {\n def check(i: Int): Boolean = bit.sum(i) >= n\n\n def func(min: Int, max: Int): Int = {\n val mid: Int = (max + min) / 2\n (max - min) match{\n case 0 | 1 =>\n check(min) match{\n case true => min\n case false => max\n }\n case _ =>\n (check(mid)) match{\n case true => func(min, mid)\n case false => func(mid, max)\n }\n }\n }\n\n func(_min, _max)\n }\n\n var ans = 0\n for (k <- (1 to N).reverse) {\n val i = indexMap(k)\n\n if (k < N) {\n val now = bit.sum(i)\n val l1 = binarySearchMin(0, i, now)\n val r1 = binarySearchMin(i, N+1, now+1)\n\n // println(s\"$k: $i\")\n if (now > 0) { // 左に自分より大きい値が存在する\n val l2 = if (bit.sum(1) < now) binarySearchMin(0, i, now-1) else 0\n val l = l1 - l2\n val r = (r1-1) - (i-1)\n val hoge = (l * r) * k\n\n ans += hoge\n }\n if (bit.sum(N) > now) { // 右に自分より大きい値が存在する\n val r2 = if (bit.sum(N) >= now+2) binarySearchMin(i, N, now+2) else N+1\n val l = i - l1\n val r = r2 - r1\n // println(s\"r1: $r1, r2: $r2, r: $r\")\n val hoge = (l * r) * k\n //println(hoge)\n //println(l, r)\n ans += hoge\n }\n }\n\n bit.add(i, 1)\n }\n\n println(ans)\n}\n\n// [1, n]\n// n is num of element\nclass BIT(n: Int) {\n val ar = new Array[Int](n+1)\n\n // sum of [1, i]\n def sum(i: Int): Int = {\n def func(i: Int, res: Int): Int = {\n if(i <= 0) res\n else func(i - (i & -i), res + ar(i))\n }\n func(i, 0)\n }\n\n // add x to i-th element\n def add(i: Int, x: Int): Unit = {\n def func(i: Int): Unit = {\n if(i <= n) {\n ar(i) += x\n func(i + (i & -i))\n }\n }\n func(i)\n }\n}\n\n\nobject Sub {\n def print2DimArray[A](mat: Array[Array[A]]): Unit = {\n mat.foreach(lin => println(lin.deep))\n }\n}\n\nclass InputReader(stream: InputStream) {\n private[this] val reader = new BufferedReader(new InputStreamReader(stream))\n private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n", "language": "Scala", "metadata": {"date": 1584727153, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02919.html", "problem_id": "p02919", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02919/input.txt", "sample_output_relpath": "derived/input_output/data/p02919/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02919/Scala/s338302564.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s338302564", "user_id": "u098968285"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\nimport scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val N = in.next().toInt\n val P = new Array[Int](N+1)\n val indexMap = new Array[Int](N+1)\n for (i <- 1 to N) {\n P(i) = in.next().toInt\n indexMap(P(i)) = i\n }\n\n //\n val bit = new BIT(N+1)\n bit.add(N+1, 1)\n\n // 条件を満たす最大の値を返す\n def binarySearchMax(_min: Int, _max: Int, n: Int): Int = {\n def check(i: Int): Boolean = bit.sum(i) <= n\n\n def func(min: Int, max: Int): Int = {\n val mid: Int = (max + min) / 2\n (max - min) match{\n case 0 | 1 =>\n check(max) match{\n case true => max\n case false => min\n }\n case _ =>\n (check(mid)) match{\n case true => func(mid, max)\n case false => func(min, mid)\n }\n }\n }\n\n func(_min, _max)\n }\n\n // 条件を満たす最小の値を返す\n def binarySearchMin(_min: Int, _max: Int, n: Int): Int = {\n def check(i: Int): Boolean = bit.sum(i) >= n\n\n def func(min: Int, max: Int): Int = {\n val mid: Int = (max + min) / 2\n (max - min) match{\n case 0 | 1 =>\n check(min) match{\n case true => min\n case false => max\n }\n case _ =>\n (check(mid)) match{\n case true => func(min, mid)\n case false => func(mid, max)\n }\n }\n }\n\n func(_min, _max)\n }\n\n var ans = 0\n for (k <- (1 to N).reverse) {\n val i = indexMap(k)\n\n if (k < N) {\n val now = bit.sum(i)\n val l1 = binarySearchMin(0, i, now)\n val r1 = binarySearchMin(i, N+1, now+1)\n\n // println(s\"$k: $i\")\n if (now > 0) { // 左に自分より大きい値が存在する\n val l2 = if (bit.sum(1) < now) binarySearchMin(0, i, now-1) else 0\n val l = l1 - l2\n val r = (r1-1) - (i-1)\n val hoge = (l * r) * k\n\n ans += hoge\n }\n if (bit.sum(N) > now) { // 右に自分より大きい値が存在する\n val r2 = if (bit.sum(N) >= now+2) binarySearchMin(i, N, now+2) else N+1\n val l = i - l1\n val r = r2 - r1\n // println(s\"r1: $r1, r2: $r2, r: $r\")\n val hoge = (l * r) * k\n //println(hoge)\n //println(l, r)\n ans += hoge\n }\n }\n\n bit.add(i, 1)\n }\n\n println(ans)\n}\n\n// [1, n]\n// n is num of element\nclass BIT(n: Int) {\n val ar = new Array[Int](n+1)\n\n // sum of [1, i]\n def sum(i: Int): Int = {\n def func(i: Int, res: Int): Int = {\n if(i <= 0) res\n else func(i - (i & -i), res + ar(i))\n }\n func(i, 0)\n }\n\n // add x to i-th element\n def add(i: Int, x: Int): Unit = {\n def func(i: Int): Unit = {\n if(i <= n) {\n ar(i) += x\n func(i + (i & -i))\n }\n }\n func(i)\n }\n}\n\n\nobject Sub {\n def print2DimArray[A](mat: Array[Array[A]]): Unit = {\n mat.foreach(lin => println(lin.deep))\n }\n}\n\nclass InputReader(stream: InputStream) {\n private[this] val reader = new BufferedReader(new InputStreamReader(stream))\n private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n", "problem_context": "Score: 500 points\n\nProblem Statement\n\nGiven is a permutation P of \\{1, 2, \\ldots, N\\}.\n\nFor a pair (L, R) (1 \\le L \\lt R \\le N), let X_{L, R} be the second largest value among P_L, P_{L+1}, \\ldots, P_R.\n\nFind \\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L+1}^{N} X_{L,R}.\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le P_i \\le N\n\nP_i \\neq P_j (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 P_2 \\ldots P_N\n\nOutput\n\nPrint \\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L+1}^{N} X_{L,R}.\n\nSample Input 1\n\n3\n2 3 1\n\nSample Output 1\n\n5\n\nX_{1, 2} = 2, X_{1, 3} = 2, and X_{2, 3} = 1, so the sum is 2 + 2 + 1 = 5.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\n30\n\nSample Input 3\n\n8\n8 2 7 3 4 5 6 1\n\nSample Output 3\n\n136", "sample_input": "3\n2 3 1\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02919", "source_text": "Score: 500 points\n\nProblem Statement\n\nGiven is a permutation P of \\{1, 2, \\ldots, N\\}.\n\nFor a pair (L, R) (1 \\le L \\lt R \\le N), let X_{L, R} be the second largest value among P_L, P_{L+1}, \\ldots, P_R.\n\nFind \\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L+1}^{N} X_{L,R}.\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le P_i \\le N\n\nP_i \\neq P_j (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 P_2 \\ldots P_N\n\nOutput\n\nPrint \\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L+1}^{N} X_{L,R}.\n\nSample Input 1\n\n3\n2 3 1\n\nSample Output 1\n\n5\n\nX_{1, 2} = 2, X_{1, 3} = 2, and X_{2, 3} = 1, so the sum is 2 + 2 + 1 = 5.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\n30\n\nSample Input 3\n\n8\n8 2 7 3 4 5 6 1\n\nSample Output 3\n\n136", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3472, "cpu_time_ms": 673, "memory_kb": 37556}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s598148039", "group_id": "codeNet:p02921", "input_text": "object Main extends App{\n val Array(a,b) = scala.io.StdIn.readLine.split(\" \").map(_.toDouble)\n println(((b-1)/(a-1)).ceil.toInt)\n}\n", "language": "Scala", "metadata": {"date": 1588394337, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s598148039.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s598148039", "user_id": "u104354966"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App{\n val Array(a,b) = scala.io.StdIn.readLine.split(\" \").map(_.toDouble)\n println(((b-1)/(a-1)).ceil.toInt)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 322, "memory_kb": 27336}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s672738519", "group_id": "codeNet:p02922", "input_text": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val A, B = sc.nextLong()\n println(if (B == 1) 1 else (B - 2) / (A - 1) + 1)\n }\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def calc(A: Array[Long]): Array[String] = {\n if (A.length == 0) Array.fill(0)(\"\")\n else {\n val last = A.zipWithIndex.map(x => (x._1 - x._2, x._1)).takeWhile(x => x._1 == A.head).last._2\n if (last == A.head) \"%d\".format(A.head) +: calc(A.zipWithIndex.map(x => (x._1 - x._2, x._1)).dropWhile(x => x._1 == A.head).map(x => x._2))\n else \"%d-%d\".format(A.head, last) +: calc(A.zipWithIndex.map(x => (x._1 - x._2, x._1)).dropWhile(x => x._1 == A.head).map(x => x._2))\n }\n }\n\n var memo: Map[(Long, Long), Long] = Map[(Long, Long), Long]()\n\n\n def recursive2(X: Set[Long], Y: Stream[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n\n def check(i: Int, X: String): Long = {\n if (X == \"\") 0 else check(i, X.tail) * i + X.head.toString.toLong\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def primeFactors(i: Long): List[Long] = primeFactors_(i, 1).sorted\n\n\n def primeFactors_(i: Long, j: Long): List[Long] = {\n if (j * j > i) List.empty else if (i % j == 0) primeFactors_(i, j + 1) ++ List[Long](j, i / j) else primeFactors_(i, j + 1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n}\n", "language": "Scala", "metadata": {"date": 1567718508, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s672738519.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s672738519", "user_id": "u779353743"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val A, B = sc.nextLong()\n println(if (B == 1) 1 else (B - 2) / (A - 1) + 1)\n }\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def calc(A: Array[Long]): Array[String] = {\n if (A.length == 0) Array.fill(0)(\"\")\n else {\n val last = A.zipWithIndex.map(x => (x._1 - x._2, x._1)).takeWhile(x => x._1 == A.head).last._2\n if (last == A.head) \"%d\".format(A.head) +: calc(A.zipWithIndex.map(x => (x._1 - x._2, x._1)).dropWhile(x => x._1 == A.head).map(x => x._2))\n else \"%d-%d\".format(A.head, last) +: calc(A.zipWithIndex.map(x => (x._1 - x._2, x._1)).dropWhile(x => x._1 == A.head).map(x => x._2))\n }\n }\n\n var memo: Map[(Long, Long), Long] = Map[(Long, Long), Long]()\n\n\n def recursive2(X: Set[Long], Y: Stream[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n\n def check(i: Int, X: String): Long = {\n if (X == \"\") 0 else check(i, X.tail) * i + X.head.toString.toLong\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def primeFactors(i: Long): List[Long] = primeFactors_(i, 1).sorted\n\n\n def primeFactors_(i: Long, j: Long): List[Long] = {\n if (j * j > i) List.empty else if (i % j == 0) primeFactors_(i, j + 1) ++ List[Long](j, i / j) else primeFactors_(i, j + 1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6619, "cpu_time_ms": 330, "memory_kb": 25408}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s714296823", "group_id": "codeNet:p02923", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val x :: xs = List.fill(sc.nextInt())(sc.nextInt())\n val (_, _, max) = xs.foldLeft((x, 0, 0)) {\n case ((step, count, max), next) if next <= step =>\n (next, count + 1, max.max(count + 1))\n case ((_, _, max), next) =>\n (next, 0, max)\n }\n println(max)\n}", "language": "Scala", "metadata": {"date": 1593550167, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02923.html", "problem_id": "p02923", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02923/input.txt", "sample_output_relpath": "derived/input_output/data/p02923/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02923/Scala/s714296823.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s714296823", "user_id": "u737111725"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val x :: xs = List.fill(sc.nextInt())(sc.nextInt())\n val (_, _, max) = xs.foldLeft((x, 0, 0)) {\n case ((step, count, max), next) if next <= step =>\n (next, count + 1, max.max(count + 1))\n case ((_, _, max), next) =>\n (next, 0, max)\n }\n println(max)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N squares arranged in a row from left to right.\n\nThe height of the i-th square from the left is H_i.\n\nYou will land on a square of your choice, then repeat moving to the adjacent square on the right as long as the height of the next square is not greater than that of the current square.\n\nFind the maximum number of times you can move.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq H_i \\leq 10^9\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 maximum number of times you can move.\n\nSample Input 1\n\n5\n10 4 8 7 3\n\nSample Output 1\n\n2\n\nBy landing on the third square from the left, you can move to the right twice.\n\nSample Input 2\n\n7\n4 4 5 6 6 5 5\n\nSample Output 2\n\n3\n\nBy landing on the fourth square from the left, you can move to the right three times.\n\nSample Input 3\n\n4\n1 2 3 4\n\nSample Output 3\n\n0", "sample_input": "5\n10 4 8 7 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02923", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N squares arranged in a row from left to right.\n\nThe height of the i-th square from the left is H_i.\n\nYou will land on a square of your choice, then repeat moving to the adjacent square on the right as long as the height of the next square is not greater than that of the current square.\n\nFind the maximum number of times you can move.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq H_i \\leq 10^9\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 maximum number of times you can move.\n\nSample Input 1\n\n5\n10 4 8 7 3\n\nSample Output 1\n\n2\n\nBy landing on the third square from the left, you can move to the right twice.\n\nSample Input 2\n\n7\n4 4 5 6 6 5 5\n\nSample Output 2\n\n3\n\nBy landing on the fourth square from the left, you can move to the right three times.\n\nSample Input 3\n\n4\n1 2 3 4\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 818, "memory_kb": 62740}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s340156927", "group_id": "codeNet:p02924", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextLong\n val nn = n - 1\n// def ModSum(n: Long): AnyVal = {\n // val nn = (n - 1)\n // (1 + nn) * nn / 2\n // }\n\n println((1 + nn) * nn / 2)\n}", "language": "Scala", "metadata": {"date": 1567368640, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s340156927.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s340156927", "user_id": "u727347518"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextLong\n val nn = n - 1\n// def ModSum(n: Long): AnyVal = {\n // val nn = (n - 1)\n // (1 + nn) * nn / 2\n // }\n\n println((1 + nn) * nn / 2)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nFor an integer N, we will choose a permutation \\{P_1, P_2, ..., P_N\\} of \\{1, 2, ..., N\\}.\n\nThen, for each i=1,2,...,N, let M_i be the remainder when i is divided by P_i.\n\nFind the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\nConstraints\n\nN is an integer satisfying 1 \\leq N \\leq 10^9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n1\n\nWhen the permutation \\{P_1, P_2\\} = \\{2, 1\\} is chosen, M_1 + M_2 = 1 + 0 = 1.\n\nSample Input 2\n\n13\n\nSample Output 2\n\n78\n\nSample Input 3\n\n1\n\nSample Output 3\n\n0", "sample_input": "2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02924", "source_text": "Score : 400 points\n\nProblem Statement\n\nFor an integer N, we will choose a permutation \\{P_1, P_2, ..., P_N\\} of \\{1, 2, ..., N\\}.\n\nThen, for each i=1,2,...,N, let M_i be the remainder when i is divided by P_i.\n\nFind the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\nConstraints\n\nN is an integer satisfying 1 \\leq N \\leq 10^9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum possible value of M_1 + M_2 + \\cdots + M_N.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n1\n\nWhen the permutation \\{P_1, P_2\\} = \\{2, 1\\} is chosen, M_1 + M_2 = 1 + 0 = 1.\n\nSample Input 2\n\n13\n\nSample Output 2\n\n78\n\nSample Input 3\n\n1\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 365, "memory_kb": 27200}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s430082361", "group_id": "codeNet:p02925", "input_text": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\nimport scala.collection.mutable.{Map, Queue, Set}\n\nobject Main extends App {\n private[this] val in = new InputReader(System.in)\n private[this] val pw = new PrintWriter(System.out)\n\n private[this] val N = in.next().toInt\n\n //\n @inline private[this] final def getInd(p: (Int, Int)): Int = {\n val (x, y) = p\n (x-1) * N + (y-1)\n }\n\n private[this] val depend = Array.fill[Set[(Int, Int)]](N*N)(Set())\n private[this] val degree = new Array[Int](N*N)\n\n \n // fill depend and degree\n private[this] var pre = (0, 0)\n\n for (a <- 1 to N; b <- 1 to N-1) {\n val now = in.next().toInt\n var s = a; var t = now\n if (a > now) {\n s = now; t = a\n }\n\n val key = s->t\n if(b == 1) {\n pre = key\n }\n else {\n val hoge = getInd(pre)\n if (!depend(hoge)(key)) {\n depend(hoge) += (key)\n degree(getInd(key)) += 1\n }\n pre = key\n }\n }\n\n // throw new RuntimeException(\"hogeee\")\n\n private[this] var sum = N * (N-1) / 2\n private[this] var stack = List[(Int, Int)]()\n for (a <- 1 to N; b <- a+1 to N) {\n val key = a->b\n val value = degree(getInd(key))\n if (value == 0) {\n stack = (key) :: stack\n }\n }\n\n\n private[this] var ans = 0\n while(!stack.isEmpty) {\n ans += 1\n var nexts = List[(Int, Int)]()\n for (key <- stack) {\n sum -= 1\n for (v <- depend(getInd(key))) {\n val ind = getInd(v)\n if (degree(ind) == 1)\n nexts = v :: nexts\n else\n degree(ind) -= 1\n }\n }\n stack = nexts\n }\n\n if (sum > 0)\n ans = -1\n\n println(ans)\n}\n\n\nclass InputReader(stream: InputStream) {\n private[this] val reader = new BufferedReader(new InputStreamReader(stream))\n private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n @inline def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n", "language": "Scala", "metadata": {"date": 1567816114, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02925.html", "problem_id": "p02925", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02925/input.txt", "sample_output_relpath": "derived/input_output/data/p02925/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02925/Scala/s430082361.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s430082361", "user_id": "u098968285"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\nimport scala.collection.mutable.{Map, Queue, Set}\n\nobject Main extends App {\n private[this] val in = new InputReader(System.in)\n private[this] val pw = new PrintWriter(System.out)\n\n private[this] val N = in.next().toInt\n\n //\n @inline private[this] final def getInd(p: (Int, Int)): Int = {\n val (x, y) = p\n (x-1) * N + (y-1)\n }\n\n private[this] val depend = Array.fill[Set[(Int, Int)]](N*N)(Set())\n private[this] val degree = new Array[Int](N*N)\n\n \n // fill depend and degree\n private[this] var pre = (0, 0)\n\n for (a <- 1 to N; b <- 1 to N-1) {\n val now = in.next().toInt\n var s = a; var t = now\n if (a > now) {\n s = now; t = a\n }\n\n val key = s->t\n if(b == 1) {\n pre = key\n }\n else {\n val hoge = getInd(pre)\n if (!depend(hoge)(key)) {\n depend(hoge) += (key)\n degree(getInd(key)) += 1\n }\n pre = key\n }\n }\n\n // throw new RuntimeException(\"hogeee\")\n\n private[this] var sum = N * (N-1) / 2\n private[this] var stack = List[(Int, Int)]()\n for (a <- 1 to N; b <- a+1 to N) {\n val key = a->b\n val value = degree(getInd(key))\n if (value == 0) {\n stack = (key) :: stack\n }\n }\n\n\n private[this] var ans = 0\n while(!stack.isEmpty) {\n ans += 1\n var nexts = List[(Int, Int)]()\n for (key <- stack) {\n sum -= 1\n for (v <- depend(getInd(key))) {\n val ind = getInd(v)\n if (degree(ind) == 1)\n nexts = v :: nexts\n else\n degree(ind) -= 1\n }\n }\n stack = nexts\n }\n\n if (sum > 0)\n ans = -1\n\n println(ans)\n}\n\n\nclass InputReader(stream: InputStream) {\n private[this] val reader = new BufferedReader(new InputStreamReader(stream))\n private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n @inline def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nN players will participate in a tennis tournament. We will call them Player 1, Player 2, \\ldots, Player N.\n\nThe tournament is round-robin format, and there will be N(N-1)/2 matches in total.\nIs it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required.\n\nEach player plays at most one matches in a day.\n\nEach player i (1 \\leq i \\leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} in this order.\n\nConstraints\n\n3 \\leq N \\leq 1000\n\n1 \\leq A_{i, j} \\leq N\n\nA_{i, j} \\neq i\n\nA_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} \\ldots A_{1, N-1}\nA_{2, 1} A_{2, 2} \\ldots A_{2, N-1}\n:\nA_{N, 1} A_{N, 2} \\ldots A_{N, N-1}\n\nOutput\n\nIf it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print -1.\n\nSample Input 1\n\n3\n2 3\n1 3\n1 2\n\nSample Output 1\n\n3\n\nAll the conditions can be satisfied if the matches are scheduled for three days as follows:\n\nDay 1: Player 1 vs Player 2\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\nSample Input 2\n\n4\n2 3 4\n1 3 4\n4 1 2\n3 1 2\n\nSample Output 2\n\n4\n\nAll the conditions can be satisfied if the matches are scheduled for four days as follows:\n\nDay 1: Player 1 vs Player 2, Player 3 vs Player 4\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 1 vs Player 4, Player 2 vs Player 3\n\nDay 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\nSample Input 3\n\n3\n2 3\n3 1\n1 2\n\nSample Output 3\n\n-1\n\nAny scheduling of the matches violates some condition.", "sample_input": "3\n2 3\n1 3\n1 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02925", "source_text": "Score : 500 points\n\nProblem Statement\n\nN players will participate in a tennis tournament. We will call them Player 1, Player 2, \\ldots, Player N.\n\nThe tournament is round-robin format, and there will be N(N-1)/2 matches in total.\nIs it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required.\n\nEach player plays at most one matches in a day.\n\nEach player i (1 \\leq i \\leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} in this order.\n\nConstraints\n\n3 \\leq N \\leq 1000\n\n1 \\leq A_{i, j} \\leq N\n\nA_{i, j} \\neq i\n\nA_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} \\ldots A_{1, N-1}\nA_{2, 1} A_{2, 2} \\ldots A_{2, N-1}\n:\nA_{N, 1} A_{N, 2} \\ldots A_{N, N-1}\n\nOutput\n\nIf it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print -1.\n\nSample Input 1\n\n3\n2 3\n1 3\n1 2\n\nSample Output 1\n\n3\n\nAll the conditions can be satisfied if the matches are scheduled for three days as follows:\n\nDay 1: Player 1 vs Player 2\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\nSample Input 2\n\n4\n2 3 4\n1 3 4\n4 1 2\n3 1 2\n\nSample Output 2\n\n4\n\nAll the conditions can be satisfied if the matches are scheduled for four days as follows:\n\nDay 1: Player 1 vs Player 2, Player 3 vs Player 4\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 1 vs Player 4, Player 2 vs Player 3\n\nDay 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\nSample Input 3\n\n3\n2 3\n3 1\n1 2\n\nSample Output 3\n\n-1\n\nAny scheduling of the matches violates some condition.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2049, "cpu_time_ms": 2119, "memory_kb": 308840}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s287543286", "group_id": "codeNet:p02925", "input_text": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\nimport scala.collection.mutable.{Map, Queue, Set}\n\nobject Main extends App {\n private[this] val in = new InputReader(System.in)\n private[this] val pw = new PrintWriter(System.out)\n\n private[this] val N = in.next().toInt\n\n //\n @inline private[this] final def getInd(p: (Int, Int)): Int = {\n val (x, y) = p\n (x-1) * N + (y-1)\n }\n\n private[this] val depend = Array.fill[Set[(Int, Int)]](N*N)(Set())\n private[this] val degree = new Array[Int](N*N)\n\n \n // fill depend and degree\n private[this] var pre = (0, 0)\n\n for (a <- 1 to N; b <- 1 to N-1) {\n val now = in.next().toInt\n val s = a min now\n val t = a max now\n\n val key = s->t\n if(b == 1) {\n pre = key\n }\n else {\n if (!depend(getInd(pre))(key)) {\n depend(getInd(pre)) += (key)\n degree(getInd(key)) += 1\n }\n pre = key\n }\n }\n\n // throw new RuntimeException(\"hogeee\")\n\n private[this] var sum = N * (N-1) / 2\n private[this] var stack = List[(Int, Int)]()\n for (a <- 1 to N; b <- a+1 to N) {\n val key = a->b\n val value = degree(getInd(key))\n if (value == 0) {\n stack = (key) :: stack\n }\n }\n\n\n private[this] var ans = 0\n while(!stack.isEmpty) {\n ans += 1\n var nexts = List[(Int, Int)]()\n for (key <- stack) {\n sum -= 1\n for (v <- depend(getInd(key))) {\n val ind = getInd(v)\n if (degree(ind) == 1)\n nexts = v :: nexts\n else\n degree(ind) -= 1\n }\n }\n stack = nexts\n }\n\n if (sum > 0)\n ans = -1\n\n println(ans)\n}\n\n\nclass InputReader(stream: InputStream) {\n private[this] val reader = new BufferedReader(new InputStreamReader(stream))\n private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n", "language": "Scala", "metadata": {"date": 1567815450, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02925.html", "problem_id": "p02925", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02925/input.txt", "sample_output_relpath": "derived/input_output/data/p02925/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02925/Scala/s287543286.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s287543286", "user_id": "u098968285"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\nimport scala.collection.mutable.{Map, Queue, Set}\n\nobject Main extends App {\n private[this] val in = new InputReader(System.in)\n private[this] val pw = new PrintWriter(System.out)\n\n private[this] val N = in.next().toInt\n\n //\n @inline private[this] final def getInd(p: (Int, Int)): Int = {\n val (x, y) = p\n (x-1) * N + (y-1)\n }\n\n private[this] val depend = Array.fill[Set[(Int, Int)]](N*N)(Set())\n private[this] val degree = new Array[Int](N*N)\n\n \n // fill depend and degree\n private[this] var pre = (0, 0)\n\n for (a <- 1 to N; b <- 1 to N-1) {\n val now = in.next().toInt\n val s = a min now\n val t = a max now\n\n val key = s->t\n if(b == 1) {\n pre = key\n }\n else {\n if (!depend(getInd(pre))(key)) {\n depend(getInd(pre)) += (key)\n degree(getInd(key)) += 1\n }\n pre = key\n }\n }\n\n // throw new RuntimeException(\"hogeee\")\n\n private[this] var sum = N * (N-1) / 2\n private[this] var stack = List[(Int, Int)]()\n for (a <- 1 to N; b <- a+1 to N) {\n val key = a->b\n val value = degree(getInd(key))\n if (value == 0) {\n stack = (key) :: stack\n }\n }\n\n\n private[this] var ans = 0\n while(!stack.isEmpty) {\n ans += 1\n var nexts = List[(Int, Int)]()\n for (key <- stack) {\n sum -= 1\n for (v <- depend(getInd(key))) {\n val ind = getInd(v)\n if (degree(ind) == 1)\n nexts = v :: nexts\n else\n degree(ind) -= 1\n }\n }\n stack = nexts\n }\n\n if (sum > 0)\n ans = -1\n\n println(ans)\n}\n\n\nclass InputReader(stream: InputStream) {\n private[this] val reader = new BufferedReader(new InputStreamReader(stream))\n private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nN players will participate in a tennis tournament. We will call them Player 1, Player 2, \\ldots, Player N.\n\nThe tournament is round-robin format, and there will be N(N-1)/2 matches in total.\nIs it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required.\n\nEach player plays at most one matches in a day.\n\nEach player i (1 \\leq i \\leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} in this order.\n\nConstraints\n\n3 \\leq N \\leq 1000\n\n1 \\leq A_{i, j} \\leq N\n\nA_{i, j} \\neq i\n\nA_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} \\ldots A_{1, N-1}\nA_{2, 1} A_{2, 2} \\ldots A_{2, N-1}\n:\nA_{N, 1} A_{N, 2} \\ldots A_{N, N-1}\n\nOutput\n\nIf it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print -1.\n\nSample Input 1\n\n3\n2 3\n1 3\n1 2\n\nSample Output 1\n\n3\n\nAll the conditions can be satisfied if the matches are scheduled for three days as follows:\n\nDay 1: Player 1 vs Player 2\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\nSample Input 2\n\n4\n2 3 4\n1 3 4\n4 1 2\n3 1 2\n\nSample Output 2\n\n4\n\nAll the conditions can be satisfied if the matches are scheduled for four days as follows:\n\nDay 1: Player 1 vs Player 2, Player 3 vs Player 4\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 1 vs Player 4, Player 2 vs Player 3\n\nDay 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\nSample Input 3\n\n3\n2 3\n3 1\n1 2\n\nSample Output 3\n\n-1\n\nAny scheduling of the matches violates some condition.", "sample_input": "3\n2 3\n1 3\n1 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02925", "source_text": "Score : 500 points\n\nProblem Statement\n\nN players will participate in a tennis tournament. We will call them Player 1, Player 2, \\ldots, Player N.\n\nThe tournament is round-robin format, and there will be N(N-1)/2 matches in total.\nIs it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required.\n\nEach player plays at most one matches in a day.\n\nEach player i (1 \\leq i \\leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} in this order.\n\nConstraints\n\n3 \\leq N \\leq 1000\n\n1 \\leq A_{i, j} \\leq N\n\nA_{i, j} \\neq i\n\nA_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} \\ldots A_{1, N-1}\nA_{2, 1} A_{2, 2} \\ldots A_{2, N-1}\n:\nA_{N, 1} A_{N, 2} \\ldots A_{N, N-1}\n\nOutput\n\nIf it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print -1.\n\nSample Input 1\n\n3\n2 3\n1 3\n1 2\n\nSample Output 1\n\n3\n\nAll the conditions can be satisfied if the matches are scheduled for three days as follows:\n\nDay 1: Player 1 vs Player 2\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\nSample Input 2\n\n4\n2 3 4\n1 3 4\n4 1 2\n3 1 2\n\nSample Output 2\n\n4\n\nAll the conditions can be satisfied if the matches are scheduled for four days as follows:\n\nDay 1: Player 1 vs Player 2, Player 3 vs Player 4\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 1 vs Player 4, Player 2 vs Player 3\n\nDay 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\nSample Input 3\n\n3\n2 3\n3 1\n1 2\n\nSample Output 3\n\n-1\n\nAny scheduling of the matches violates some condition.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1997, "cpu_time_ms": 2115, "memory_kb": 307116}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s858714135", "group_id": "codeNet:p02934", "input_text": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n println(1.0 / Array.fill(sc.nextInt())(sc.nextLong()).map(i => 1.0 / i).sum)\n }\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def calc(A: Array[Long]): Array[String] = {\n if (A.length == 0) Array.fill(0)(\"\")\n else {\n val last = A.zipWithIndex.map(x => (x._1 - x._2, x._1)).takeWhile(x => x._1 == A.head).last._2\n if (last == A.head) \"%d\".format(A.head) +: calc(A.zipWithIndex.map(x => (x._1 - x._2, x._1)).dropWhile(x => x._1 == A.head).map(x => x._2))\n else \"%d-%d\".format(A.head, last) +: calc(A.zipWithIndex.map(x => (x._1 - x._2, x._1)).dropWhile(x => x._1 == A.head).map(x => x._2))\n }\n }\n\n var memo: Map[(Long, Long), Long] = Map[(Long, Long), Long]()\n\n\n def recursive2(X: Set[Long], Y: Stream[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n\n def check(i: Int, X: String): Long = {\n if (X == \"\") 0 else check(i, X.tail) * i + X.head.toString.toLong\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def primeFactors(i: Long): List[Long] = primeFactors_(i, 1).sorted\n\n\n def primeFactors_(i: Long, j: Long): List[Long] = {\n if (j * j > i) List.empty else if (i % j == 0) primeFactors_(i, j + 1) ++ List[Long](j, i / j) else primeFactors_(i, j + 1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n}\n", "language": "Scala", "metadata": {"date": 1566271084, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s858714135.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s858714135", "user_id": "u779353743"}, "prompt_components": {"gold_output": "7.5\n", "input_to_evaluate": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n println(1.0 / Array.fill(sc.nextInt())(sc.nextLong()).map(i => 1.0 / i).sum)\n }\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def calc(A: Array[Long]): Array[String] = {\n if (A.length == 0) Array.fill(0)(\"\")\n else {\n val last = A.zipWithIndex.map(x => (x._1 - x._2, x._1)).takeWhile(x => x._1 == A.head).last._2\n if (last == A.head) \"%d\".format(A.head) +: calc(A.zipWithIndex.map(x => (x._1 - x._2, x._1)).dropWhile(x => x._1 == A.head).map(x => x._2))\n else \"%d-%d\".format(A.head, last) +: calc(A.zipWithIndex.map(x => (x._1 - x._2, x._1)).dropWhile(x => x._1 == A.head).map(x => x._2))\n }\n }\n\n var memo: Map[(Long, Long), Long] = Map[(Long, Long), Long]()\n\n\n def recursive2(X: Set[Long], Y: Stream[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n\n def check(i: Int, X: String): Long = {\n if (X == \"\") 0 else check(i, X.tail) * i + X.head.toString.toLong\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def primeFactors(i: Long): List[Long] = primeFactors_(i, 1).sorted\n\n\n def primeFactors_(i: Long, j: Long): List[Long] = {\n if (j * j > i) List.empty else if (i % j == 0) primeFactors_(i, j + 1) ++ List[Long](j, i / j) else primeFactors_(i, j + 1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6617, "cpu_time_ms": 339, "memory_kb": 27460}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s662092585", "group_id": "codeNet:p02935", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val n = sc.nextInt\n val vs = Seq.fill(n)(sc.nextInt).sorted\n\n val res = vs.sorted.tail.foldLeft(vs.sorted.head.toDouble){case (tmp, acc) =>\n (tmp + acc) / 2\n }\n\n\n\n println(res)\n\n\n}\n", "language": "Scala", "metadata": {"date": 1575847611, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s662092585.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s662092585", "user_id": "u829407811"}, "prompt_components": {"gold_output": "3.5\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val n = sc.nextInt\n val vs = Seq.fill(n)(sc.nextInt).sorted\n\n val res = vs.sorted.tail.foldLeft(vs.sorted.head.toDouble){case (tmp, acc) =>\n (tmp + acc) / 2\n }\n\n\n\n println(res)\n\n\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 346, "memory_kb": 27192}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s102588871", "group_id": "codeNet:p02945", "input_text": "\nimport java.util.Scanner\n\nobject Main {\n\n def read(): (Int, Int) = {\n val sc: Scanner = new Scanner(System.in)\n val a, b = sc.nextInt\n sc.close()\n (a, b)\n }\n\n\n def solve(a: Int,b: Int): Int = {\n Seq(a+b, a-b, a*b).max\n }\n\n\n def main(args: Array[String]): Unit = {\n val (a, b) = read()\n println(solve(a, b))\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1567051371, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s102588871.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s102588871", "user_id": "u947008426"}, "prompt_components": {"gold_output": "-10\n", "input_to_evaluate": "\nimport java.util.Scanner\n\nobject Main {\n\n def read(): (Int, Int) = {\n val sc: Scanner = new Scanner(System.in)\n val a, b = sc.nextInt\n sc.close()\n (a, b)\n }\n\n\n def solve(a: Int,b: Int): Int = {\n Seq(a+b, a-b, a*b).max\n }\n\n\n def main(args: Array[String]): Unit = {\n val (a, b) = read()\n println(solve(a, b))\n }\n\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 348, "memory_kb": 25536}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s024201162", "group_id": "codeNet:p02945", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val a, b = sc.nextInt\n\n val result = List(a + b, a - b, a * b).max\n println(result)\n}", "language": "Scala", "metadata": {"date": 1565486132, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s024201162.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s024201162", "user_id": "u727347518"}, "prompt_components": {"gold_output": "-10\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val a, b = sc.nextInt\n\n val result = List(a + b, a - b, a * b).max\n println(result)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 347, "memory_kb": 27216}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s159613639", "group_id": "codeNet:p02946", "input_text": "object Main {\n import java.io.{BufferedReader, InputStream, InputStreamReader}\n import java.util.StringTokenizer\n import scala.reflect.ClassTag\n\n def main(args: Array[String]): Unit = {\n val out = new java.io.PrintWriter(System.out)\n new Main(out, new InputReader(System.in)).solve()\n out.flush()\n }\n\n private val oj = System.getenv(\"ATCODER_DEBUG\") == null\n def DEBUG(f: => Unit): Unit = {\n if (!oj){ f }\n }\n def debug(as: Array[Boolean]): Unit = if (!oj){ debug(as.map(x => if(x) \"1\" else \"0\").mkString) }\n def debug(as: Array[Int]): Unit = if (!oj){ debug(as.mkString(\" \")) }\n def debug(as: Array[Long]): Unit =if (!oj){ debug(as.mkString(\" \")) }\n def debugDim(m: Array[Array[Long]]): Unit = if (!oj){\n REP(m.length) { i =>\n debug(m(i))\n }\n }\n def debugDimFlip(m: Array[Array[Long]]): Unit = if (!oj){\n REP(m(0).length) { j =>\n REP(m.length) { i =>\n System.err.print(m(i)(j))\n System.err.print(\" \")\n }\n System.err.println()\n }\n }\n def debug(s: => String): Unit = DEBUG {\n System.err.println(s)\n }\n def debugL(num: => Long): Unit = DEBUG {\n System.err.println(num)\n }\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = Integer.parseInt(next())\n def nextLong(): Long = java.lang.Long.parseLong(next())\n def nextChar(): Char = next().charAt(0)\n\n def ni(): Int = nextInt()\n def nl(): Long = nextLong()\n def nc(): Char = nextChar()\n def ns(): String = next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n }\n\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n def TO(from: Int, to: Int)(f: Int => Unit): Unit = {\n REP(to - from + 1, from) { i =>\n f(i)\n }\n }\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n def cumSum(as: Array[Int]): Array[Long] = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n\nclass Main(out: java.io.PrintWriter, sc: Main.InputReader) {\n import sc._\n import Main._\n import java.util.Arrays.sort\n\n import scala.collection.mutable\n import math.{abs, max, min}\n import mutable.ArrayBuffer\n\n // toIntとか+7とかするならvalにしろ\n @inline private def MOD = 1000000007\n\n def solve(): Unit = {\n val K, X = ni()\n out.println(map(K * 2 - 1, X - K + 1)(identity).mkString(\" \"))\n }\n}", "language": "Scala", "metadata": {"date": 1565485377, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02946.html", "problem_id": "p02946", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02946/input.txt", "sample_output_relpath": "derived/input_output/data/p02946/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02946/Scala/s159613639.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s159613639", "user_id": "u460609472"}, "prompt_components": {"gold_output": "5 6 7 8 9\n", "input_to_evaluate": "object Main {\n import java.io.{BufferedReader, InputStream, InputStreamReader}\n import java.util.StringTokenizer\n import scala.reflect.ClassTag\n\n def main(args: Array[String]): Unit = {\n val out = new java.io.PrintWriter(System.out)\n new Main(out, new InputReader(System.in)).solve()\n out.flush()\n }\n\n private val oj = System.getenv(\"ATCODER_DEBUG\") == null\n def DEBUG(f: => Unit): Unit = {\n if (!oj){ f }\n }\n def debug(as: Array[Boolean]): Unit = if (!oj){ debug(as.map(x => if(x) \"1\" else \"0\").mkString) }\n def debug(as: Array[Int]): Unit = if (!oj){ debug(as.mkString(\" \")) }\n def debug(as: Array[Long]): Unit =if (!oj){ debug(as.mkString(\" \")) }\n def debugDim(m: Array[Array[Long]]): Unit = if (!oj){\n REP(m.length) { i =>\n debug(m(i))\n }\n }\n def debugDimFlip(m: Array[Array[Long]]): Unit = if (!oj){\n REP(m(0).length) { j =>\n REP(m.length) { i =>\n System.err.print(m(i)(j))\n System.err.print(\" \")\n }\n System.err.println()\n }\n }\n def debug(s: => String): Unit = DEBUG {\n System.err.println(s)\n }\n def debugL(num: => Long): Unit = DEBUG {\n System.err.println(num)\n }\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = Integer.parseInt(next())\n def nextLong(): Long = java.lang.Long.parseLong(next())\n def nextChar(): Char = next().charAt(0)\n\n def ni(): Int = nextInt()\n def nl(): Long = nextLong()\n def nc(): Char = nextChar()\n def ns(): String = next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n }\n\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n def TO(from: Int, to: Int)(f: Int => Unit): Unit = {\n REP(to - from + 1, from) { i =>\n f(i)\n }\n }\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n def cumSum(as: Array[Int]): Array[Long] = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n\nclass Main(out: java.io.PrintWriter, sc: Main.InputReader) {\n import sc._\n import Main._\n import java.util.Arrays.sort\n\n import scala.collection.mutable\n import math.{abs, max, min}\n import mutable.ArrayBuffer\n\n // toIntとか+7とかするならvalにしろ\n @inline private def MOD = 1000000007\n\n def solve(): Unit = {\n val K, X = ni()\n out.println(map(K * 2 - 1, X - K + 1)(identity).mkString(\" \"))\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are 2000001 stones placed on a number line. The coordinates of these stones are -1000000, -999999, -999998, \\ldots, 999999, 1000000.\n\nAmong them, some K consecutive stones are painted black, and the others are painted white.\n\nAdditionally, we know that the stone at coordinate X is painted black.\n\nPrint all coordinates that potentially contain a stone painted black, in ascending order.\n\nConstraints\n\n1 \\leq K \\leq 100\n\n0 \\leq X \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK X\n\nOutput\n\nPrint all coordinates that potentially contain a stone painted black, in ascending order, with spaces in between.\n\nSample Input 1\n\n3 7\n\nSample Output 1\n\n5 6 7 8 9\n\nWe know that there are three stones painted black, and the stone at coordinate 7 is painted black. There are three possible cases:\n\nThe three stones painted black are placed at coordinates 5, 6, and 7.\n\nThe three stones painted black are placed at coordinates 6, 7, and 8.\n\nThe three stones painted black are placed at coordinates 7, 8, and 9.\n\nThus, five coordinates potentially contain a stone painted black: 5, 6, 7, 8, and 9.\n\nSample Input 2\n\n4 0\n\nSample Output 2\n\n-3 -2 -1 0 1 2 3\n\nNegative coordinates can also contain a stone painted black.\n\nSample Input 3\n\n1 100\n\nSample Output 3\n\n100", "sample_input": "3 7\n"}, "reference_outputs": ["5 6 7 8 9\n"], "source_document_id": "p02946", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are 2000001 stones placed on a number line. The coordinates of these stones are -1000000, -999999, -999998, \\ldots, 999999, 1000000.\n\nAmong them, some K consecutive stones are painted black, and the others are painted white.\n\nAdditionally, we know that the stone at coordinate X is painted black.\n\nPrint all coordinates that potentially contain a stone painted black, in ascending order.\n\nConstraints\n\n1 \\leq K \\leq 100\n\n0 \\leq X \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK X\n\nOutput\n\nPrint all coordinates that potentially contain a stone painted black, in ascending order, with spaces in between.\n\nSample Input 1\n\n3 7\n\nSample Output 1\n\n5 6 7 8 9\n\nWe know that there are three stones painted black, and the stone at coordinate 7 is painted black. There are three possible cases:\n\nThe three stones painted black are placed at coordinates 5, 6, and 7.\n\nThe three stones painted black are placed at coordinates 6, 7, and 8.\n\nThe three stones painted black are placed at coordinates 7, 8, and 9.\n\nThus, five coordinates potentially contain a stone painted black: 5, 6, 7, 8, and 9.\n\nSample Input 2\n\n4 0\n\nSample Output 2\n\n-3 -2 -1 0 1 2 3\n\nNegative coordinates can also contain a stone painted black.\n\nSample Input 3\n\n1 100\n\nSample Output 3\n\n100", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3699, "cpu_time_ms": 322, "memory_kb": 27180}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s938531967", "group_id": "codeNet:p02947", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val groupCounts = Seq.fill(sc.nextInt())(sc.next()).map(_.sorted).groupBy(identity).mapValues(_.size.toLong).values\n println(groupCounts.foldLeft(0L)((acc, i) => acc + i * (i - 1L) / 2L))\n}", "language": "Scala", "metadata": {"date": 1589769084, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s938531967.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s938531967", "user_id": "u737111725"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val groupCounts = Seq.fill(sc.nextInt())(sc.next()).map(_.sorted).groupBy(identity).mapValues(_.size.toLong).values\n println(groupCounts.foldLeft(0L)((acc, i) => acc + i * (i - 1L) / 2L))\n}", "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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 262, "cpu_time_ms": 1743, "memory_kb": 118452}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s758404981", "group_id": "codeNet:p02947", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val groupCounts = Seq.fill(sc.nextInt())(sc.next()).map(_.sorted).groupBy(identity).values.map(_.size)\n println(groupCounts.foldLeft(0L)((acc, i) => acc + i * (i - 1) / 2))\n}", "language": "Scala", "metadata": {"date": 1589768468, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s758404981.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s758404981", "user_id": "u737111725"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val groupCounts = Seq.fill(sc.nextInt())(sc.next()).map(_.sorted).groupBy(identity).values.map(_.size)\n println(groupCounts.foldLeft(0L)((acc, i) => acc + i * (i - 1) / 2))\n}", "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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1681, "memory_kb": 117212}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s932888540", "group_id": "codeNet:p02947", "input_text": "object Main extends App {\n var n = readInt\n var ss = Range(0,n).map(t=>readLine.split(\"\").sorted.mkString(\"\"))\n val words = collection.mutable.Map[String,Int]()\n ss.foreach{s=>\n words += s -> (words.getOrElse(s,0)+1)\n }\n println(words.values.foldLeft(0l)((a,x)=>a+x*(x-1)/2))\n}", "language": "Scala", "metadata": {"date": 1565631319, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s932888540.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s932888540", "user_id": "u782685137"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main extends App {\n var n = readInt\n var ss = Range(0,n).map(t=>readLine.split(\"\").sorted.mkString(\"\"))\n val words = collection.mutable.Map[String,Int]()\n ss.foreach{s=>\n words += s -> (words.getOrElse(s,0)+1)\n }\n println(words.values.foldLeft(0l)((a,x)=>a+x*(x-1)/2))\n}", "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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1316, "memory_kb": 89480}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s730865962", "group_id": "codeNet:p02947", "input_text": "object Main extends App {\n var a = readInt\n var b = Array.tabulate(a)(i => (readLine).sorted)\n var sum = 0L\n for(i <- 0 until a - 1;j <- i+1 until a) {\n if(b(i) == b(j)) {\n sum = sum + 1\n }\n }\n print(sum)\n}", "language": "Scala", "metadata": {"date": 1565488955, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s730865962.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s730865962", "user_id": "u533688845"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main extends App {\n var a = readInt\n var b = Array.tabulate(a)(i => (readLine).sorted)\n var sum = 0L\n for(i <- 0 until a - 1;j <- i+1 until a) {\n if(b(i) == b(j)) {\n sum = sum + 1\n }\n }\n print(sum)\n}", "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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 223, "cpu_time_ms": 2111, "memory_kb": 48300}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s342296692", "group_id": "codeNet:p02948", "input_text": "import scala.collection.mutable.PriorityQueue\n\ncase class fuckingJob(days : Int , money : Int)\n\nobject Main extends App{\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt() //job\n val m = sc.nextInt() //day\n var mwhile = m - 1\n val ab : PriorityQueue[fuckingJob] = PriorityQueue()(Ordering.by(_.money))\n var ans = 0\n\n for (i <- 0 until n) {\n val a = sc.nextInt()\n val b = sc.nextInt()\n ab.enqueue(fuckingJob(a,b))\n }\n\n while(mwhile >= 0 && ab.nonEmpty){\n val wara = ab.dequeue()\n if(wara.days <= mwhile+1){\n ans += wara.money\n mwhile = mwhile - 1\n }\n \n }\n \n println(ans)\n}", "language": "Scala", "metadata": {"date": 1565730192, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s342296692.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s342296692", "user_id": "u287800514"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import scala.collection.mutable.PriorityQueue\n\ncase class fuckingJob(days : Int , money : Int)\n\nobject Main extends App{\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt() //job\n val m = sc.nextInt() //day\n var mwhile = m - 1\n val ab : PriorityQueue[fuckingJob] = PriorityQueue()(Ordering.by(_.money))\n var ans = 0\n\n for (i <- 0 until n) {\n val a = sc.nextInt()\n val b = sc.nextInt()\n ab.enqueue(fuckingJob(a,b))\n }\n\n while(mwhile >= 0 && ab.nonEmpty){\n val wara = ab.dequeue()\n if(wara.days <= mwhile+1){\n ans += wara.money\n mwhile = mwhile - 1\n }\n \n }\n \n println(ans)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1004, "memory_kb": 111496}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s799327198", "group_id": "codeNet:p02951", "input_text": "object Main{\n\ndef main(args: Array[String]): Unit = {\n val arr1 = io.StdIn.readLine().split(' ')\n val a = arr1(0).toInt\n val b = arr1(1).toInt\n val c = arr1(2).toInt\n \n if (a - b >= c) println(0) else println(c - (a - b) )\n}\n}\n", "language": "Scala", "metadata": {"date": 1564967043, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s799327198.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s799327198", "user_id": "u173561231"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main{\n\ndef main(args: Array[String]): Unit = {\n val arr1 = io.StdIn.readLine().split(' ')\n val a = arr1(0).toInt\n val b = arr1(1).toInt\n val c = arr1(2).toInt\n \n if (a - b >= c) println(0) else println(c - (a - b) )\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 325, "memory_kb": 25376}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s558889994", "group_id": "codeNet:p02957", "input_text": "import scala.io.StdIn._\nobject Main extends App {\n val Array(a, b) = readLine.split(\" \").map(_.toInt)\n println(if ((a + b) % 2 == 1) \"IMPOSSIBLE\" else (a + b) / 2)\n}", "language": "Scala", "metadata": {"date": 1575039520, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s558889994.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s558889994", "user_id": "u132324749"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import scala.io.StdIn._\nobject Main extends App {\n val Array(a, b) = readLine.split(\" \").map(_.toInt)\n println(if ((a + b) % 2 == 1) \"IMPOSSIBLE\" else (a + b) / 2)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 326, "memory_kb": 25512}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s099106163", "group_id": "codeNet:p02959", "input_text": "import java.util.Scanner\n\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val n = sc.nextInt()\n \n var ans = 0\n \n val enemies = new Array[Int](n + 1)\n for (i <- enemies.indices) {\n enemies(i) = sc.nextInt()\n }\n \n val hero = new Array[Int](n)\n for (i <- hero.indices) {\n hero(i) = sc.nextInt()\n \n }\n \n for (i <- hero.indices) {\n if (hero(i) <= enemies(i)) {\n ans += hero(i)\n } else {\n hero(i) -= enemies(i)\n ans += enemies(i) + math.min(enemies(i + 1), hero(i))\n }\n }\n \n println(ans)\n }\n \n def printArray[T](arr: Array[T]): Unit = {\n for (i <- arr.indices) {\n print(s\"${arr(i)} \")\n }\n println()\n }\n}", "language": "Scala", "metadata": {"date": 1586738282, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s099106163.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s099106163", "user_id": "u336949031"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import java.util.Scanner\n\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val n = sc.nextInt()\n \n var ans = 0\n \n val enemies = new Array[Int](n + 1)\n for (i <- enemies.indices) {\n enemies(i) = sc.nextInt()\n }\n \n val hero = new Array[Int](n)\n for (i <- hero.indices) {\n hero(i) = sc.nextInt()\n \n }\n \n for (i <- hero.indices) {\n if (hero(i) <= enemies(i)) {\n ans += hero(i)\n } else {\n hero(i) -= enemies(i)\n ans += enemies(i) + math.min(enemies(i + 1), hero(i))\n }\n }\n \n println(ans)\n }\n \n def printArray[T](arr: Array[T]): Unit = {\n for (i <- arr.indices) {\n print(s\"${arr(i)} \")\n }\n println()\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 760, "cpu_time_ms": 761, "memory_kb": 70456}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s597876606", "group_id": "codeNet:p02960", "input_text": "import scala.io.StdIn._\nobject Main extends App {\n val Mod = 1000000007\n val s = readLine\n\n def dp(rems: Array[Long], digit: Char): Array[Long] = {\n val ret = new Array[Long](13)\n val is = if (digit == '?') (0 to 9) else Seq((digit - '0').toInt)\n for {\n i <- is\n j <- (0 to 12)\n } {\n ret((j * 10 + i) % 13) += rems(j)\n ret((j * 10 + i) % 13) %= Mod\n }\n ret\n }\n\n val init = s.head match {\n case '?' => Array.tabulate(13)(i => if (i < 10) 1L else 0L)\n case c => Array.tabulate(13)(i => if (i == c - '0') 1L else 0L)\n }\n\n val result = s.tail.foldLeft(init){(z, d) => dp(z, d)}\n println(result(5))\n}", "language": "Scala", "metadata": {"date": 1574975019, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s597876606.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s597876606", "user_id": "u132324749"}, "prompt_components": {"gold_output": "768\n", "input_to_evaluate": "import scala.io.StdIn._\nobject Main extends App {\n val Mod = 1000000007\n val s = readLine\n\n def dp(rems: Array[Long], digit: Char): Array[Long] = {\n val ret = new Array[Long](13)\n val is = if (digit == '?') (0 to 9) else Seq((digit - '0').toInt)\n for {\n i <- is\n j <- (0 to 12)\n } {\n ret((j * 10 + i) % 13) += rems(j)\n ret((j * 10 + i) % 13) %= Mod\n }\n ret\n }\n\n val init = s.head match {\n case '?' => Array.tabulate(13)(i => if (i < 10) 1L else 0L)\n case c => Array.tabulate(13)(i => if (i == c - '0') 1L else 0L)\n }\n\n val result = s.tail.foldLeft(init){(z, d) => dp(z, d)}\n println(result(5))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 647, "cpu_time_ms": 672, "memory_kb": 46892}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s711400939", "group_id": "codeNet:p02969", "input_text": "object Main extends App {\n\n val r = scala.io.StdIn.readInt()\n\n\n def solve(): Int = {\n 3 * r * r\n }\n\n println(solve)\n\n}\n", "language": "Scala", "metadata": {"date": 1571195743, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s711400939.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s711400939", "user_id": "u947008426"}, "prompt_components": {"gold_output": "48\n", "input_to_evaluate": "object Main extends App {\n\n val r = scala.io.StdIn.readInt()\n\n\n def solve(): Int = {\n 3 * r * r\n }\n\n println(solve)\n\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 321, "memory_kb": 25548}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s902905643", "group_id": "codeNet:p02969", "input_text": "import scala.io.StdIn\nobject Main extends App {\n val r = StdIn.readLine().toInt\n println(r * r * 3)\n}\n", "language": "Scala", "metadata": {"date": 1566955884, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s902905643.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s902905643", "user_id": "u407005073"}, "prompt_components": {"gold_output": "48\n", "input_to_evaluate": "import scala.io.StdIn\nobject Main extends App {\n val r = StdIn.readLine().toInt\n println(r * r * 3)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 104, "cpu_time_ms": 334, "memory_kb": 27320}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s492566424", "group_id": "codeNet:p02969", "input_text": "\nimport java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val r = sc.nextInt()\n\n println(3 * r * r)\n}\n", "language": "Scala", "metadata": {"date": 1563671122, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s492566424.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s492566424", "user_id": "u726872801"}, "prompt_components": {"gold_output": "48\n", "input_to_evaluate": "\nimport java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val r = sc.nextInt()\n\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 352, "memory_kb": 27332}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s221286607", "group_id": "codeNet:p02970", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n, d = sc.nextFloat\n sc.close()\n\n println(Math.ceil(n / ((d * 2) + 1)).toInt)\n }\n}", "language": "Scala", "metadata": {"date": 1563679050, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s221286607.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s221286607", "user_id": "u889604426"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n, d = sc.nextFloat\n sc.close()\n\n println(Math.ceil(n / ((d * 2) + 1)).toInt)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 346, "memory_kb": 27332}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s261601639", "group_id": "codeNet:p02970", "input_text": "import scala.io.StdIn\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n val Array(n, d) = StdIn.readLine().split(' ').map(_.toInt)\n val range = 2 * d + 1\n val remain = if (n % range == 0) 0 else 1\n val ans = n / range + remain\n println(ans)\n }\n\n}", "language": "Scala", "metadata": {"date": 1563673181, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s261601639.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s261601639", "user_id": "u252817963"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n val Array(n, d) = StdIn.readLine().split(' ').map(_.toInt)\n val range = 2 * d + 1\n val remain = if (n % range == 0) 0 else 1\n val ans = n / range + remain\n println(ans)\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 271, "cpu_time_ms": 326, "memory_kb": 25544}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s018681004", "group_id": "codeNet:p02971", "input_text": "object Main extends App {\n val n = io.StdIn.readInt\n val as = for (_ <- 1 to n) yield io.StdIn.readInt\n \n for (count <- 0 until n) {\n val deleted = as.take(count) ++ as.drop(count).tail\n println(deleted.max)\n }\n}", "language": "Scala", "metadata": {"date": 1592738712, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s018681004.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s018681004", "user_id": "u104354966"}, "prompt_components": {"gold_output": "4\n3\n4\n", "input_to_evaluate": "object Main extends App {\n val n = io.StdIn.readInt\n val as = for (_ <- 1 to n) yield io.StdIn.readInt\n \n for (count <- 0 until n) {\n val deleted = as.take(count) ++ as.drop(count).tail\n println(deleted.max)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 223, "cpu_time_ms": 2206, "memory_kb": 54772}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s052945208", "group_id": "codeNet:p02971", "input_text": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val A = Array.fill(sc.nextInt())(sc.nextLong())\n val B = A.zipWithIndex.sortWith((a, b) => a._1 > b._1)\n A.indices.foreach(i => println(if (B.head._2 == i) B.drop(1).head._1 else B.head._1))\n }\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def calc(A: Array[Long]): Array[String] = {\n if (A.length == 0) Array.fill(0)(\"\")\n else {\n val last = A.zipWithIndex.map(x => (x._1 - x._2, x._1)).takeWhile(x => x._1 == A.head).last._2\n if (last == A.head) \"%d\".format(A.head) +: calc(A.zipWithIndex.map(x => (x._1 - x._2, x._1)).dropWhile(x => x._1 == A.head).map(x => x._2))\n else \"%d-%d\".format(A.head, last) +: calc(A.zipWithIndex.map(x => (x._1 - x._2, x._1)).dropWhile(x => x._1 == A.head).map(x => x._2))\n }\n }\n\n var memo: Map[(Long, Long), Long] = Map[(Long, Long), Long]()\n\n def recursive(xyz: Array[(Long, Long, Long)], M: Long): Long = {\n if (xyz.isEmpty) M else {\n val head = xyz.head\n if (head._1 == 0) {\n if (head._2 == M)\n recursive(xyz.tail, head._3)\n else if (head._3 == M)\n recursive(xyz.tail, head._2)\n else\n recursive(xyz.tail, M)\n } else {\n if (head._2 == M)\n recursive(xyz.tail, head._3)\n else\n recursive(xyz.tail, M)\n }\n }\n }\n\n def recursive2(X: Set[Long], Y: Stream[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n\n def check(s: String): Boolean = {\n s.isEmpty ||\n s.startsWith(\"dream\") && check(s.drop(5)) ||\n s.startsWith(\"dreamer\") && check(s.drop(7)) ||\n s.startsWith(\"erase\") && check(s.drop(5)) ||\n s.startsWith(\"eraser\") && check(s.drop(6))\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def primeFactors(i: Long): List[Long] = primeFactors_(i, 1).sorted\n\n\n def primeFactors_(i: Long, j: Long): List[Long] = {\n if (j * j > i) List.empty else if (i % j == 0) primeFactors_(i, j + 1) ++ List[Long](j, i / j) else primeFactors_(i, j + 1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n}\n", "language": "Scala", "metadata": {"date": 1563679898, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s052945208.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s052945208", "user_id": "u779353743"}, "prompt_components": {"gold_output": "4\n3\n4\n", "input_to_evaluate": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val A = Array.fill(sc.nextInt())(sc.nextLong())\n val B = A.zipWithIndex.sortWith((a, b) => a._1 > b._1)\n A.indices.foreach(i => println(if (B.head._2 == i) B.drop(1).head._1 else B.head._1))\n }\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def calc(A: Array[Long]): Array[String] = {\n if (A.length == 0) Array.fill(0)(\"\")\n else {\n val last = A.zipWithIndex.map(x => (x._1 - x._2, x._1)).takeWhile(x => x._1 == A.head).last._2\n if (last == A.head) \"%d\".format(A.head) +: calc(A.zipWithIndex.map(x => (x._1 - x._2, x._1)).dropWhile(x => x._1 == A.head).map(x => x._2))\n else \"%d-%d\".format(A.head, last) +: calc(A.zipWithIndex.map(x => (x._1 - x._2, x._1)).dropWhile(x => x._1 == A.head).map(x => x._2))\n }\n }\n\n var memo: Map[(Long, Long), Long] = Map[(Long, Long), Long]()\n\n def recursive(xyz: Array[(Long, Long, Long)], M: Long): Long = {\n if (xyz.isEmpty) M else {\n val head = xyz.head\n if (head._1 == 0) {\n if (head._2 == M)\n recursive(xyz.tail, head._3)\n else if (head._3 == M)\n recursive(xyz.tail, head._2)\n else\n recursive(xyz.tail, M)\n } else {\n if (head._2 == M)\n recursive(xyz.tail, head._3)\n else\n recursive(xyz.tail, M)\n }\n }\n }\n\n def recursive2(X: Set[Long], Y: Stream[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n\n def check(s: String): Boolean = {\n s.isEmpty ||\n s.startsWith(\"dream\") && check(s.drop(5)) ||\n s.startsWith(\"dreamer\") && check(s.drop(7)) ||\n s.startsWith(\"erase\") && check(s.drop(5)) ||\n s.startsWith(\"eraser\") && check(s.drop(6))\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def primeFactors(i: Long): List[Long] = primeFactors_(i, 1).sorted\n\n\n def primeFactors_(i: Long, j: Long): List[Long] = {\n if (j * j > i) List.empty else if (i % j == 0) primeFactors_(i, j + 1) ++ List[Long](j, i / j) else primeFactors_(i, j + 1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 7357, "cpu_time_ms": 2111, "memory_kb": 93084}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s431771468", "group_id": "codeNet:p02971", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val a = Seq.fill(n)(sc.nextInt)\n\n val max = a.max\n for (i <- (0 to n - 1)) {\n if (a(i) == max) {\n val tmp = a.splitAt(i)\n println((tmp._1 ++ tmp._2.tail).max)\n } else {\n print(max)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1563674071, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s431771468.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s431771468", "user_id": "u015315385"}, "prompt_components": {"gold_output": "4\n3\n4\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val a = Seq.fill(n)(sc.nextInt)\n\n val max = a.max\n for (i <- (0 to n - 1)) {\n if (a(i) == max) {\n val tmp = a.splitAt(i)\n println((tmp._1 ++ tmp._2.tail).max)\n } else {\n print(max)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 308, "cpu_time_ms": 2111, "memory_kb": 124712}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s323915018", "group_id": "codeNet:p02971", "input_text": "object Main extends App {\n val n = io.StdIn.readInt\n val as = (1 to n).map{ _ => io.StdIn.readInt }\n (1 to n)\n .foreach(i => {\n val mx = as.zipWithIndex\n .filter { case (_, ix) => (ix + 1) != i }\n .map{ case (a, _) => a }\n .max\n println(mx)\n })\n}\n", "language": "Scala", "metadata": {"date": 1563673487, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s323915018.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s323915018", "user_id": "u669917064"}, "prompt_components": {"gold_output": "4\n3\n4\n", "input_to_evaluate": "object Main extends App {\n val n = io.StdIn.readInt\n val as = (1 to n).map{ _ => io.StdIn.readInt }\n (1 to n)\n .foreach(i => {\n val mx = as.zipWithIndex\n .filter { case (_, ix) => (ix + 1) != i }\n .map{ case (a, _) => a }\n .max\n println(mx)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 287, "cpu_time_ms": 2111, "memory_kb": 147364}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s101787423", "group_id": "codeNet:p02971", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val N = sc.nextInt\n val A = List.fill(N)(sc.nextInt)\n sc.close()\n\n if (A.distinct.length == 1) {\n A.foreach(println)\n } else {\n A.foreach(d => println(A.filter(_ != d).max))\n }\n }\n}", "language": "Scala", "metadata": {"date": 1563673171, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s101787423.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s101787423", "user_id": "u889604426"}, "prompt_components": {"gold_output": "4\n3\n4\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val N = sc.nextInt\n val A = List.fill(N)(sc.nextInt)\n sc.close()\n\n if (A.distinct.length == 1) {\n A.foreach(println)\n } else {\n A.foreach(d => println(A.filter(_ != d).max))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 125780}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s747417503", "group_id": "codeNet:p02972", "input_text": "import scala.io.StdIn._\nobject Main extends App {\n val n = readInt\n val as = 0 +: readLine.split(\" \").map(_.toInt)\n val ans = new Array[Int](n + 1)\n\n (n to 1 by -1).foreach {i =>\n val cnt = (i * 2 to n by i).count(j => ans(j) == 1)\n ans(i) = (cnt & 1) ^ as(i)\n }\n val is = ans.zipWithIndex.collect{case (a, i) if a == 1 => i}\n println(is.size)\n println(is.mkString(\" \"))\n}", "language": "Scala", "metadata": {"date": 1575043868, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s747417503.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s747417503", "user_id": "u132324749"}, "prompt_components": {"gold_output": "1\n1\n", "input_to_evaluate": "import scala.io.StdIn._\nobject Main extends App {\n val n = readInt\n val as = 0 +: readLine.split(\" \").map(_.toInt)\n val ans = new Array[Int](n + 1)\n\n (n to 1 by -1).foreach {i =>\n val cnt = (i * 2 to n by i).count(j => ans(j) == 1)\n ans(i) = (cnt & 1) ^ as(i)\n }\n val is = ans.zipWithIndex.collect{case (a, i) if a == 1 => i}\n println(is.size)\n println(is.mkString(\" \"))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1035, "memory_kb": 95824}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s143585750", "group_id": "codeNet:p02972", "input_text": "\nobject Main {\n\n def printArray(arr: Array[Int]): Unit =\n println(arr.mkString(\"\\n\"))\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n // 1以上N以下の任意の整数iについて, iの倍数が書かれた箱に入っている\n // ボールの個数の和を2で割った余りがa_iである\n\n val N = sc.nextInt()\n val A = Array.fill(N)(sc.nextInt() match {\n case 1 => true\n case 0 => false\n })\n\n // 言い換えると, 1以上,N以下の任意のiについて\n // iの倍数の個数を2で割った余りがa_iであるかどうか\n val B = new Array[Boolean](N)\n var i = N\n while (i > 0) {\n var j = i + 1\n var s = false\n if (i <= N * 2)\n while (j <= N) {\n if (j % i == 0)\n s ^= A(j-1)\n j += 1\n }\n if (s != A(i-1))\n B(i-1) = true\n i -= 1\n }\n val boxes = B.zipWithIndex.filter(_._1)\n val M = boxes.length\n val results = boxes.map(_._2 + 1).mkString(\" \")\n println(M)\n if (M != 0)\n println(results)\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1563854875, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s143585750.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s143585750", "user_id": "u891387249"}, "prompt_components": {"gold_output": "1\n1\n", "input_to_evaluate": "\nobject Main {\n\n def printArray(arr: Array[Int]): Unit =\n println(arr.mkString(\"\\n\"))\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n // 1以上N以下の任意の整数iについて, iの倍数が書かれた箱に入っている\n // ボールの個数の和を2で割った余りがa_iである\n\n val N = sc.nextInt()\n val A = Array.fill(N)(sc.nextInt() match {\n case 1 => true\n case 0 => false\n })\n\n // 言い換えると, 1以上,N以下の任意のiについて\n // iの倍数の個数を2で割った余りがa_iであるかどうか\n val B = new Array[Boolean](N)\n var i = N\n while (i > 0) {\n var j = i + 1\n var s = false\n if (i <= N * 2)\n while (j <= N) {\n if (j % i == 0)\n s ^= A(j-1)\n j += 1\n }\n if (s != A(i-1))\n B(i-1) = true\n i -= 1\n }\n val boxes = B.zipWithIndex.filter(_._1)\n val M = boxes.length\n val results = boxes.map(_._2 + 1).mkString(\" \")\n println(M)\n if (M != 0)\n println(results)\n }\n\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1096, "cpu_time_ms": 2111, "memory_kb": 67668}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s713843962", "group_id": "codeNet:p02972", "input_text": "object Main extends App {\n val n = scala.io.StdIn.readLine.toInt\n val a = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\n var data = Set.empty[Int]\n\n var cnt = n\n while (cnt >= 1) {\n val array_cnt = cnt - 1\n // 偶数 or 奇数\n val odd = data.count { a => a % cnt == 0 } % 2 == 0\n\n if (odd && a(array_cnt) == 0) {\n // 偶数 & 求めるのも偶数\n //何もしない\n } else if (odd && a(array_cnt) == 1) {\n // 偶数 & 求めるのは奇数\n data += cnt\n } else if (!odd && a(array_cnt) == 0) {\n // 奇数 & 求めるのは偶数\n data += cnt\n } else if (!odd && a(array_cnt) == 1) {\n // 奇数 & 求めるのは奇数\n // なにもしない\n }\n cnt -= 1\n }\n\n println(data.size)\n if(data.nonEmpty) {\n println(data.mkString(\" \"))\n }\n}\n", "language": "Scala", "metadata": {"date": 1563672432, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s713843962.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s713843962", "user_id": "u654455149"}, "prompt_components": {"gold_output": "1\n1\n", "input_to_evaluate": "object Main extends App {\n val n = scala.io.StdIn.readLine.toInt\n val a = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\n var data = Set.empty[Int]\n\n var cnt = n\n while (cnt >= 1) {\n val array_cnt = cnt - 1\n // 偶数 or 奇数\n val odd = data.count { a => a % cnt == 0 } % 2 == 0\n\n if (odd && a(array_cnt) == 0) {\n // 偶数 & 求めるのも偶数\n //何もしない\n } else if (odd && a(array_cnt) == 1) {\n // 偶数 & 求めるのは奇数\n data += cnt\n } else if (!odd && a(array_cnt) == 0) {\n // 奇数 & 求めるのは偶数\n data += cnt\n } else if (!odd && a(array_cnt) == 1) {\n // 奇数 & 求めるのは奇数\n // なにもしない\n }\n cnt -= 1\n }\n\n println(data.size)\n if(data.nonEmpty) {\n println(data.mkString(\" \"))\n }\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 818, "cpu_time_ms": 2111, "memory_kb": 50928}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s980247338", "group_id": "codeNet:p02975", "input_text": "object Main {\n def main(args: Array[String]) = {\n\n val sc = new java.util.Scanner(System.in)\n val N = sc.nextInt\n val I = List.fill(N)(sc.nextInt)\n sc.close()\n\n (0 until I.length - 2).forall(i => (I(i) ^ I(i + 1)) == I(i + 2)) match {\n case true => println(\"Yes\")\n case _ => println(\"No\")\n }\n }\n}", "language": "Scala", "metadata": {"date": 1563161178, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s980247338.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s980247338", "user_id": "u889604426"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]) = {\n\n val sc = new java.util.Scanner(System.in)\n val N = sc.nextInt\n val I = List.fill(N)(sc.nextInt)\n sc.close()\n\n (0 until I.length - 2).forall(i => (I(i) ^ I(i + 1)) == I(i + 2)) match {\n case true => println(\"Yes\")\n case _ => println(\"No\")\n }\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 54292}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s782866349", "group_id": "codeNet:p02976", "input_text": "object Main {\n import java.io.{BufferedReader, InputStream, InputStreamReader}\n import java.util.StringTokenizer\n import scala.reflect.ClassTag\n\n def main(args: Array[String]): Unit = {\n val out = new java.io.PrintWriter(System.out)\n new Main(out, new InputReader(System.in)).solve()\n out.flush()\n }\n\n private val oj = System.getenv(\"ATCODER_DEBUG\") == null\n def DEBUG(f: => Unit): Unit = {\n if (!oj){ f }\n }\n def debug(as: Array[Boolean]): Unit = if (!oj){ debug(as.map(x => if(x) \"1\" else \"0\").mkString) }\n def debug(as: Array[Int]): Unit = if (!oj){ debug(as.mkString(\" \")) }\n def debug(as: Array[Long]): Unit =if (!oj){ debug(as.mkString(\" \")) }\n def debugDim(m: Array[Array[Long]]): Unit = if (!oj){\n REP(m.length) { i =>\n debug(m(i))\n }\n }\n def debugDimFlip(m: Array[Array[Long]]): Unit = if (!oj){\n REP(m(0).length) { j =>\n REP(m.length) { i =>\n System.err.print(m(i)(j))\n System.err.print(\" \")\n }\n System.err.println()\n }\n }\n def debug(s: => String): Unit = DEBUG {\n System.err.println(s)\n }\n def debugL(num: => Long): Unit = DEBUG {\n System.err.println(num)\n }\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = Integer.parseInt(next())\n def nextLong(): Long = java.lang.Long.parseLong(next())\n def nextChar(): Char = next().charAt(0)\n\n def ni(): Int = nextInt()\n def nl(): Long = nextLong()\n def nc(): Char = nextChar()\n def ns(): String = next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n }\n\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n def TO(from: Int, to: Int)(f: Int => Unit): Unit = {\n REP(to - from + 1, from) { i =>\n f(i)\n }\n }\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n def cumSum(as: Array[Int]): Array[Long] = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n\nclass Main(out: java.io.PrintWriter, sc: Main.InputReader) {\n import sc._\n import Main._\n import java.util.Arrays.sort\n\n import scala.collection.mutable\n import math.{abs, max, min}\n import mutable.ArrayBuffer\n\n // toIntとか+7とかするならvalにしろ\n @inline private def MOD = 1000000007\n\n case class Edge(i: Int, a: Int, b: Int) {\n def oppo(v: Int) = if (a == v) b else a\n }\n case class Entry(v: Int, deg: Int) extends Comparable[Entry] {\n override def compareTo(o: Entry): Int = Integer.compare(deg, o.deg)\n }\n\n def solve2(): Boolean = {\n val N, M = ni()\n if (M % 2 == 1) return false\n\n val deg = Array.ofDim[Int](N)\n val E = Array.ofDim[Edge](M)\n val g = Array.fill[mutable.Set[Int]](N)(mutable.Set()) //edge番号\n REP(M) { i =>\n val a, b = ni() - 1\n E(i) = Edge(i, a, b)\n deg(a) += 1\n deg(b) += 1\n g(a) += i\n g(b) += i\n }\n\n val q = new java.util.PriorityQueue[Entry]\n def addEntry(v: Int): Unit = {\n if (deg(v) > 1) q.add(Entry(v, deg(v)))\n }\n\n debug(deg)\n\n REP(N) { i =>\n addEntry(i)\n }\n\n val ans = ArrayBuffer[(Int, Int)]()\n\n // v -> e1, v -> e2\n def outward2(v: Int, e1: Edge): Unit = {\n g(v).remove(e1.i)\n g(E(e1.i).oppo(v)).remove(e1.i)\n val e2 = E(g(v).head)\n g(v).remove(e2.i)\n g(E(e2.i).oppo(v)).remove(e2.i)\n\n debug(s\"outward2($v) e1:$e1 e2:$e2\")\n\n deg(v) -= 2\n deg(e1.oppo(v)) -= 1\n deg(e2.oppo(v)) -= 1\n\n addEntry(v)\n addEntry(e1.oppo(v))\n addEntry(e2.oppo(v))\n\n ans += v -> e1.oppo(v)\n ans += v -> e2.oppo(v)\n }\n\n // e1 -> v -> e2\n// def passOver(v: Int): Unit = {\n// val e1 = E(g(v).head)\n// g(v).remove(e1.i)\n// g(E(e1.i).oppo(v)).remove(e1.i)\n// val e2 = E(g(v).head)\n// g(v).remove(e2.i)\n// g(E(e2.i).oppo(v)).remove(e2.i)\n//\n// debug(s\"passOver($v) e1:$e1 e2:$e2\")\n//\n// deg(v) -= 2\n// deg(e1.oppo(v)) -= 1\n// deg(e2.oppo(v)) -= 1\n//\n// addEntry(v)\n// addEntry(e1.oppo(v))\n// addEntry(e2.oppo(v))\n//\n// ans += e1.oppo(v) -> v\n// ans += v -> e2.oppo(v)\n// }\n\n while(!q.isEmpty) {\n val e = q.poll()\n if (deg(e.v) == e.deg) {\n e.deg match {\n// case 1 =>\n// val edge = E(g(e.v).head)\n// val u = edge.oppo(e.v)\n// outward2(u, edge)\n\n case _ =>\n outward2(e.v, E(g(e.v).head))\n\n// case 3 =>\n// passOver(e.v)\n }\n }\n }\n\n assert(ans.length == M)\n REP(M) { i =>\n val e = ans(i)\n out.println(s\"${e._1+1} ${e._2+1}\")\n }\n\n true\n }\n\n def solve(): Unit = {\n if (!solve2()) out.println(-1)\n }\n}", "language": "Scala", "metadata": {"date": 1563161924, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02976.html", "problem_id": "p02976", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02976/input.txt", "sample_output_relpath": "derived/input_output/data/p02976/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02976/Scala/s782866349.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s782866349", "user_id": "u460609472"}, "prompt_components": {"gold_output": "1 2\n1 4\n3 2\n3 4\n", "input_to_evaluate": "object Main {\n import java.io.{BufferedReader, InputStream, InputStreamReader}\n import java.util.StringTokenizer\n import scala.reflect.ClassTag\n\n def main(args: Array[String]): Unit = {\n val out = new java.io.PrintWriter(System.out)\n new Main(out, new InputReader(System.in)).solve()\n out.flush()\n }\n\n private val oj = System.getenv(\"ATCODER_DEBUG\") == null\n def DEBUG(f: => Unit): Unit = {\n if (!oj){ f }\n }\n def debug(as: Array[Boolean]): Unit = if (!oj){ debug(as.map(x => if(x) \"1\" else \"0\").mkString) }\n def debug(as: Array[Int]): Unit = if (!oj){ debug(as.mkString(\" \")) }\n def debug(as: Array[Long]): Unit =if (!oj){ debug(as.mkString(\" \")) }\n def debugDim(m: Array[Array[Long]]): Unit = if (!oj){\n REP(m.length) { i =>\n debug(m(i))\n }\n }\n def debugDimFlip(m: Array[Array[Long]]): Unit = if (!oj){\n REP(m(0).length) { j =>\n REP(m.length) { i =>\n System.err.print(m(i)(j))\n System.err.print(\" \")\n }\n System.err.println()\n }\n }\n def debug(s: => String): Unit = DEBUG {\n System.err.println(s)\n }\n def debugL(num: => Long): Unit = DEBUG {\n System.err.println(num)\n }\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = Integer.parseInt(next())\n def nextLong(): Long = java.lang.Long.parseLong(next())\n def nextChar(): Char = next().charAt(0)\n\n def ni(): Int = nextInt()\n def nl(): Long = nextLong()\n def nc(): Char = nextChar()\n def ns(): String = next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n }\n\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n def TO(from: Int, to: Int)(f: Int => Unit): Unit = {\n REP(to - from + 1, from) { i =>\n f(i)\n }\n }\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n def cumSum(as: Array[Int]): Array[Long] = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n\nclass Main(out: java.io.PrintWriter, sc: Main.InputReader) {\n import sc._\n import Main._\n import java.util.Arrays.sort\n\n import scala.collection.mutable\n import math.{abs, max, min}\n import mutable.ArrayBuffer\n\n // toIntとか+7とかするならvalにしろ\n @inline private def MOD = 1000000007\n\n case class Edge(i: Int, a: Int, b: Int) {\n def oppo(v: Int) = if (a == v) b else a\n }\n case class Entry(v: Int, deg: Int) extends Comparable[Entry] {\n override def compareTo(o: Entry): Int = Integer.compare(deg, o.deg)\n }\n\n def solve2(): Boolean = {\n val N, M = ni()\n if (M % 2 == 1) return false\n\n val deg = Array.ofDim[Int](N)\n val E = Array.ofDim[Edge](M)\n val g = Array.fill[mutable.Set[Int]](N)(mutable.Set()) //edge番号\n REP(M) { i =>\n val a, b = ni() - 1\n E(i) = Edge(i, a, b)\n deg(a) += 1\n deg(b) += 1\n g(a) += i\n g(b) += i\n }\n\n val q = new java.util.PriorityQueue[Entry]\n def addEntry(v: Int): Unit = {\n if (deg(v) > 1) q.add(Entry(v, deg(v)))\n }\n\n debug(deg)\n\n REP(N) { i =>\n addEntry(i)\n }\n\n val ans = ArrayBuffer[(Int, Int)]()\n\n // v -> e1, v -> e2\n def outward2(v: Int, e1: Edge): Unit = {\n g(v).remove(e1.i)\n g(E(e1.i).oppo(v)).remove(e1.i)\n val e2 = E(g(v).head)\n g(v).remove(e2.i)\n g(E(e2.i).oppo(v)).remove(e2.i)\n\n debug(s\"outward2($v) e1:$e1 e2:$e2\")\n\n deg(v) -= 2\n deg(e1.oppo(v)) -= 1\n deg(e2.oppo(v)) -= 1\n\n addEntry(v)\n addEntry(e1.oppo(v))\n addEntry(e2.oppo(v))\n\n ans += v -> e1.oppo(v)\n ans += v -> e2.oppo(v)\n }\n\n // e1 -> v -> e2\n// def passOver(v: Int): Unit = {\n// val e1 = E(g(v).head)\n// g(v).remove(e1.i)\n// g(E(e1.i).oppo(v)).remove(e1.i)\n// val e2 = E(g(v).head)\n// g(v).remove(e2.i)\n// g(E(e2.i).oppo(v)).remove(e2.i)\n//\n// debug(s\"passOver($v) e1:$e1 e2:$e2\")\n//\n// deg(v) -= 2\n// deg(e1.oppo(v)) -= 1\n// deg(e2.oppo(v)) -= 1\n//\n// addEntry(v)\n// addEntry(e1.oppo(v))\n// addEntry(e2.oppo(v))\n//\n// ans += e1.oppo(v) -> v\n// ans += v -> e2.oppo(v)\n// }\n\n while(!q.isEmpty) {\n val e = q.poll()\n if (deg(e.v) == e.deg) {\n e.deg match {\n// case 1 =>\n// val edge = E(g(e.v).head)\n// val u = edge.oppo(e.v)\n// outward2(u, edge)\n\n case _ =>\n outward2(e.v, E(g(e.v).head))\n\n// case 3 =>\n// passOver(e.v)\n }\n }\n }\n\n assert(ans.length == M)\n REP(M) { i =>\n val e = ans(i)\n out.println(s\"${e._1+1} ${e._2+1}\")\n }\n\n true\n }\n\n def solve(): Unit = {\n if (!solve2()) out.println(-1)\n }\n}", "problem_context": "Score : 700 points\n\nProblem Statement\n\nYou are given a simple connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N, and the i-th edge connects Vertex A_i and Vertex B_i.\nTakahashi will assign one of the two possible directions to each of the edges in the graph to make a directed graph.\nDetermine if it is possible to make a directed graph with an even number of edges going out from every vertex. If the answer is yes, construct one such graph.\n\nNotes\n\nAn undirected graph is said to be simple when it contains no self-loops or multiple edges.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\nN-1 \\leq M \\leq 10^5\n\n1 \\leq A_i,B_i \\leq N (1\\leq i\\leq M)\n\nThe given graph is simple and connected.\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 it is impossible to assign directions\b to satisfy the requirement, print -1.\nOtherwise, print an assignment of directions that satisfies the requirement, in the following format:\n\nC_1 D_1\n:\nC_M D_M\n\nHere each pair (C_i, D_i) means that there is an edge directed from Vertex C_i to Vertex D_i. The edges may be printed in any order.\n\nSample Input 1\n\n4 4\n1 2\n2 3\n3 4\n4 1\n\nSample Output 1\n\n1 2\n1 4\n3 2\n3 4\n\nAfter this assignment of directions, Vertex 1 and 3 will each have two outgoing edges, and Vertex 2 and 4 will each have zero outgoing edges.\n\nSample Input 2\n\n5 5\n1 2\n2 3\n3 4\n2 5\n4 5\n\nSample Output 2\n\n-1", "sample_input": "4 4\n1 2\n2 3\n3 4\n4 1\n"}, "reference_outputs": ["1 2\n1 4\n3 2\n3 4\n"], "source_document_id": "p02976", "source_text": "Score : 700 points\n\nProblem Statement\n\nYou are given a simple connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N, and the i-th edge connects Vertex A_i and Vertex B_i.\nTakahashi will assign one of the two possible directions to each of the edges in the graph to make a directed graph.\nDetermine if it is possible to make a directed graph with an even number of edges going out from every vertex. If the answer is yes, construct one such graph.\n\nNotes\n\nAn undirected graph is said to be simple when it contains no self-loops or multiple edges.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\nN-1 \\leq M \\leq 10^5\n\n1 \\leq A_i,B_i \\leq N (1\\leq i\\leq M)\n\nThe given graph is simple and connected.\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 it is impossible to assign directions\b to satisfy the requirement, print -1.\nOtherwise, print an assignment of directions that satisfies the requirement, in the following format:\n\nC_1 D_1\n:\nC_M D_M\n\nHere each pair (C_i, D_i) means that there is an edge directed from Vertex C_i to Vertex D_i. The edges may be printed in any order.\n\nSample Input 1\n\n4 4\n1 2\n2 3\n3 4\n4 1\n\nSample Output 1\n\n1 2\n1 4\n3 2\n3 4\n\nAfter this assignment of directions, Vertex 1 and 3 will each have two outgoing edges, and Vertex 2 and 4 will each have zero outgoing edges.\n\nSample Input 2\n\n5 5\n1 2\n2 3\n3 4\n2 5\n4 5\n\nSample Output 2\n\n-1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5994, "cpu_time_ms": 1253, "memory_kb": 97620}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s969639051", "group_id": "codeNet:p02977", "input_text": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\nimport scala.collection.mutable.Map\nimport scala.collection.mutable.Queue\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val N = in.next().toInt\n\n var ans = List((1, 2), (2, 3), (N+3, 1), (N+2, N+3), (N+1, N+2))\n if (N <= 2)\n println(\"No\")\n else {\n for (i <- 4 until N by 2) {\n ans = (i, 1) :: (i+1, i) :: (N+i+1, 1) :: (N+i, N+i+1) :: ans\n }\n\n var flag = false\n if (N % 2 == 0) {\n breakable {\n for (i <- 2 to N-1 if (i ^ (N+1)) < N) {\n ans = (i, N) :: (i ^ (N+1), N+N) :: ans\n flag = true\n break\n }\n }\n }\n else\n flag = true\n\n if(flag) {\n pw.println(\"Yes\")\n ans.foreach { case (a, b) => pw.println(s\"$a $b\") }\n }\n else\n pw.println(\"No\")\n\n pw.flush()\n }\n\n}\n\n\nclass InputReader(stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream))\n private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n", "language": "Scala", "metadata": {"date": 1563580055, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02977.html", "problem_id": "p02977", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02977/input.txt", "sample_output_relpath": "derived/input_output/data/p02977/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02977/Scala/s969639051.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s969639051", "user_id": "u098968285"}, "prompt_components": {"gold_output": "Yes\n1 2\n2 3\n3 4\n4 5\n5 6\n", "input_to_evaluate": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\nimport scala.collection.mutable.Map\nimport scala.collection.mutable.Queue\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val N = in.next().toInt\n\n var ans = List((1, 2), (2, 3), (N+3, 1), (N+2, N+3), (N+1, N+2))\n if (N <= 2)\n println(\"No\")\n else {\n for (i <- 4 until N by 2) {\n ans = (i, 1) :: (i+1, i) :: (N+i+1, 1) :: (N+i, N+i+1) :: ans\n }\n\n var flag = false\n if (N % 2 == 0) {\n breakable {\n for (i <- 2 to N-1 if (i ^ (N+1)) < N) {\n ans = (i, N) :: (i ^ (N+1), N+N) :: ans\n flag = true\n break\n }\n }\n }\n else\n flag = true\n\n if(flag) {\n pw.println(\"Yes\")\n ans.foreach { case (a, b) => pw.println(s\"$a $b\") }\n }\n else\n pw.println(\"No\")\n\n pw.flush()\n }\n\n}\n\n\nclass InputReader(stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream))\n private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nYou are given an integer N. Determine if there exists a tree with 2N vertices numbered 1 to 2N satisfying the following condition, and show one such tree if the answer is yes.\n\nAssume that, for each integer i between 1 and N (inclusive), Vertex i and N+i have the weight i. Then, for each integer i between 1 and N, the bitwise XOR of the weights of the vertices on the path between Vertex i and N+i (including themselves) is i.\n\nConstraints\n\nN is an integer.\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\nIf there exists a tree satisfying the condition in the statement, print Yes; otherwise, print No.\nThen, if such a tree exists, print the 2N-1 edges of such a tree in the subsequent 2N-1 lines, in the following format:\n\na_{1} b_{1}\n\\vdots\na_{2N-1} b_{2N-1}\n\nHere each pair (a_i, b_i) means that there is an edge connecting Vertex a_i and b_i. The edges may be printed in any order.\n\nSample Input 1\n\n3\n\nSample Output 1\n\nYes\n1 2\n2 3\n3 4\n4 5\n5 6\n\nThe sample output represents the following graph:\n\nSample Input 2\n\n1\n\nSample Output 2\n\nNo\n\nThere is no tree satisfying the condition.", "sample_input": "3\n"}, "reference_outputs": ["Yes\n1 2\n2 3\n3 4\n4 5\n5 6\n"], "source_document_id": "p02977", "source_text": "Score : 700 points\n\nProblem Statement\n\nYou are given an integer N. Determine if there exists a tree with 2N vertices numbered 1 to 2N satisfying the following condition, and show one such tree if the answer is yes.\n\nAssume that, for each integer i between 1 and N (inclusive), Vertex i and N+i have the weight i. Then, for each integer i between 1 and N, the bitwise XOR of the weights of the vertices on the path between Vertex i and N+i (including themselves) is i.\n\nConstraints\n\nN is an integer.\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\nIf there exists a tree satisfying the condition in the statement, print Yes; otherwise, print No.\nThen, if such a tree exists, print the 2N-1 edges of such a tree in the subsequent 2N-1 lines, in the following format:\n\na_{1} b_{1}\n\\vdots\na_{2N-1} b_{2N-1}\n\nHere each pair (a_i, b_i) means that there is an edge connecting Vertex a_i and b_i. The edges may be printed in any order.\n\nSample Input 1\n\n3\n\nSample Output 1\n\nYes\n1 2\n2 3\n3 4\n4 5\n5 6\n\nThe sample output represents the following graph:\n\nSample Input 2\n\n1\n\nSample Output 2\n\nNo\n\nThere is no tree satisfying the condition.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1289, "cpu_time_ms": 767, "memory_kb": 73284}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s000556532", "group_id": "codeNet:p02981", "input_text": "import java.util.Scanner\n\nobject Main {\n\n def solve(sc: Scanner): String = {\n val (n, a, b) = (sc.nextInt(), sc.nextInt(), sc.nextInt())\n\n (if (n * a > b) b else n * a).toString\n }\n\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val writer = new java.io.PrintWriter(System.out)\n writer.println(solve(sc))\n writer.flush()\n }\n\n private def debug(x: Any): Unit = {\n if (System.getenv(\"LOCAL_DEBUG\") != null) println(x)\n }\n}\n", "language": "Scala", "metadata": {"date": 1562547777, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s000556532.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s000556532", "user_id": "u088326922"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n\n def solve(sc: Scanner): String = {\n val (n, a, b) = (sc.nextInt(), sc.nextInt(), sc.nextInt())\n\n (if (n * a > b) b else n * a).toString\n }\n\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val writer = new java.io.PrintWriter(System.out)\n writer.println(solve(sc))\n writer.flush()\n }\n\n private def debug(x: Any): Unit = {\n if (System.getenv(\"LOCAL_DEBUG\") != null) println(x)\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 353, "memory_kb": 27688}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s111896018", "group_id": "codeNet:p02981", "input_text": "import scala.math._\n\nobject Main extends App {\n\n val YES = \"YES\"\n val Yes = \"Yes\"\n val NO = \"NO\"\n val No = \"No\"\n ///////////////////////////////////////////\n\n val sc = new java.util.Scanner(System.in)\n val n, a, b = sc.nextInt\n// val list = List.fill(3)(sc.nextInt)\n\n val ans = min(a * n, b)\n\n println(ans)\n\n ///////////////////////////////////////////\n\n def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =\n Iterator.iterate(start)(_ + step).takeWhile(_ <= end)\n\n def lcm(a :Int, b :Int): Int =\n a / gcd(a, b) * b\n\n def lcm(a :Long, b :Long): Long =\n a / gcd(a, b) * b\n\n def gcd(a: Int, b: Int): Int =\n if (b == 0) a else gcd(b, a % b)\n\n def gcd(a: Long, b: Long): Long =\n if (b == 0) a else gcd(b, a % b)\n\n def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =\n a.get(key) match {\n case Some(v) => a.updated(key, f(value, v))\n case _ => a + (key -> value)\n }\n}", "language": "Scala", "metadata": {"date": 1562547733, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s111896018.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s111896018", "user_id": "u040380439"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import scala.math._\n\nobject Main extends App {\n\n val YES = \"YES\"\n val Yes = \"Yes\"\n val NO = \"NO\"\n val No = \"No\"\n ///////////////////////////////////////////\n\n val sc = new java.util.Scanner(System.in)\n val n, a, b = sc.nextInt\n// val list = List.fill(3)(sc.nextInt)\n\n val ans = min(a * n, b)\n\n println(ans)\n\n ///////////////////////////////////////////\n\n def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =\n Iterator.iterate(start)(_ + step).takeWhile(_ <= end)\n\n def lcm(a :Int, b :Int): Int =\n a / gcd(a, b) * b\n\n def lcm(a :Long, b :Long): Long =\n a / gcd(a, b) * b\n\n def gcd(a: Int, b: Int): Int =\n if (b == 0) a else gcd(b, a % b)\n\n def gcd(a: Long, b: Long): Long =\n if (b == 0) a else gcd(b, a % b)\n\n def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =\n a.get(key) match {\n case Some(v) => a.updated(key, f(value, v))\n case _ => a + (key -> value)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 355, "memory_kb": 27348}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s135153517", "group_id": "codeNet:p02982", "input_text": "import java.util.Scanner\n\n\n\nobject Main {\n\n def read(): (Int, Int, IndexedSeq[IndexedSeq[Int]]) = {\n val sc = new Scanner(System.in)\n val n, d = sc.nextInt()\n val x: IndexedSeq[IndexedSeq[Int]] = IndexedSeq.fill(n, d)(sc.nextInt())\n (n, d, x)\n }\n\n def dist(y: IndexedSeq[Int], z: IndexedSeq[Int]): Double = {\n Math.sqrt((y,z).zipped.map((yi, zi) => Math.pow(yi - zi, 2)).sum)\n }\n\n def solve(n: Int, x: IndexedSeq[IndexedSeq[Int]]): Int = {\n (for {\n i <- 0 until n - 1\n j <- i + 1 until n\n } yield {\n val y = x(i)\n val z = x(j)\n val d = dist(y, z)\n d % 1 == 0\n }).count(identity)\n }\n\n def main(args: Array[String]) = {\n val (n, d, x) = read()\n println(solve(n, x))\n }\n\n}", "language": "Scala", "metadata": {"date": 1562649515, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s135153517.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s135153517", "user_id": "u947008426"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.Scanner\n\n\n\nobject Main {\n\n def read(): (Int, Int, IndexedSeq[IndexedSeq[Int]]) = {\n val sc = new Scanner(System.in)\n val n, d = sc.nextInt()\n val x: IndexedSeq[IndexedSeq[Int]] = IndexedSeq.fill(n, d)(sc.nextInt())\n (n, d, x)\n }\n\n def dist(y: IndexedSeq[Int], z: IndexedSeq[Int]): Double = {\n Math.sqrt((y,z).zipped.map((yi, zi) => Math.pow(yi - zi, 2)).sum)\n }\n\n def solve(n: Int, x: IndexedSeq[IndexedSeq[Int]]): Int = {\n (for {\n i <- 0 until n - 1\n j <- i + 1 until n\n } yield {\n val y = x(i)\n val z = x(j)\n val d = dist(y, z)\n d % 1 == 0\n }).count(identity)\n }\n\n def main(args: Array[String]) = {\n val (n, d, x) = read()\n println(solve(n, x))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 737, "cpu_time_ms": 348, "memory_kb": 27336}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s676679461", "group_id": "codeNet:p02984", "input_text": "import java.util.Scanner\n\n\nobject Main {\n\n def read() = {\n val sc = new Scanner(System.in)\n val n = sc.nextInt()\n val a = IndexedSeq.fill(n)(sc.nextLong())\n (n, a)\n }\n\n def solve(n: Int, a: IndexedSeq[Long]): Long = {\n val as0 = IndexedSeq.concat(0 until n by 2, 1 until n by 2, 0 until n by 2, 1 until n by 2).map(a)\n val as1 = IndexedSeq.concat(1 until n by 2, 0 until n by 2, 1 until n by 2, 0 until n by 2).map(a)\n val cumAS0 = as0.scanLeft(0L)(_ + _)\n val cumAS1 = as1.scanLeft(0L)(_ + _)\n val sum = a.sum\n val y0 = IndexedSeq.tabulate(n / 2 + 1)(i =>\n sum/2 - (cumAS0(i + n / 2 + 1) - cumAS0(i + 1))\n )\n val y1 = IndexedSeq.tabulate(n / 2)(i =>\n sum/2 - (cumAS1(i + n / 2 + 1) - cumAS1(i + 1))\n )\n print(y0((n-1)/2) * 2)\n print(\" \")\n for(i<- 0 until n-1){\n if(i %2 == 0){\n print(y0(i/2)*2)\n } else{\n print(y1(i/2)*2)\n }\n print(\" \")\n }\n println()\n 0\n }\n\n def main(args: Array[String]): Unit = {\n val (n, a) = read()\n solve(n, a)\n }\n}", "language": "Scala", "metadata": {"date": 1562550601, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02984.html", "problem_id": "p02984", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02984/input.txt", "sample_output_relpath": "derived/input_output/data/p02984/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02984/Scala/s676679461.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s676679461", "user_id": "u494788559"}, "prompt_components": {"gold_output": "4 0 4\n", "input_to_evaluate": "import java.util.Scanner\n\n\nobject Main {\n\n def read() = {\n val sc = new Scanner(System.in)\n val n = sc.nextInt()\n val a = IndexedSeq.fill(n)(sc.nextLong())\n (n, a)\n }\n\n def solve(n: Int, a: IndexedSeq[Long]): Long = {\n val as0 = IndexedSeq.concat(0 until n by 2, 1 until n by 2, 0 until n by 2, 1 until n by 2).map(a)\n val as1 = IndexedSeq.concat(1 until n by 2, 0 until n by 2, 1 until n by 2, 0 until n by 2).map(a)\n val cumAS0 = as0.scanLeft(0L)(_ + _)\n val cumAS1 = as1.scanLeft(0L)(_ + _)\n val sum = a.sum\n val y0 = IndexedSeq.tabulate(n / 2 + 1)(i =>\n sum/2 - (cumAS0(i + n / 2 + 1) - cumAS0(i + 1))\n )\n val y1 = IndexedSeq.tabulate(n / 2)(i =>\n sum/2 - (cumAS1(i + n / 2 + 1) - cumAS1(i + 1))\n )\n print(y0((n-1)/2) * 2)\n print(\" \")\n for(i<- 0 until n-1){\n if(i %2 == 0){\n print(y0(i/2)*2)\n } else{\n print(y1(i/2)*2)\n }\n print(\" \")\n }\n println()\n 0\n }\n\n def main(args: Array[String]): Unit = {\n val (n, a) = read()\n solve(n, a)\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an odd number.\n\nBetween these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \\leq i \\leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).\n\nWhen Mountain i (1 \\leq i \\leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).\n\nOne day, each of the mountains received a non-negative even number of liters of rain.\n\nAs a result, Dam i (1 \\leq i \\leq N) accumulated a total of A_i liters of water.\n\nFind the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 10^5-1\n\nN is an odd number.\n\n0 \\leq A_i \\leq 10^9\n\nThe situation represented by input can occur when each of the mountains receives a non-negative even number of liters of rain.\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 representing the number of liters of rain Mountain 1, Mountain 2, ..., Mountain N received, in this order.\n\nSample Input 1\n\n3\n2 2 4\n\nSample Output 1\n\n4 0 4\n\nIf we assume Mountain 1, 2, and 3 received 4, 0, and 4 liters of rain, respectively, it is consistent with this input, as follows:\n\nDam 1 should have accumulated \\frac{4}{2} + \\frac{0}{2} = 2 liters of water.\n\nDam 2 should have accumulated \\frac{0}{2} + \\frac{4}{2} = 2 liters of water.\n\nDam 3 should have accumulated \\frac{4}{2} + \\frac{4}{2} = 4 liters of water.\n\nSample Input 2\n\n5\n3 8 7 5 5\n\nSample Output 2\n\n2 4 12 2 8\n\nSample Input 3\n\n3\n1000000000 1000000000 0\n\nSample Output 3\n\n0 2000000000 0", "sample_input": "3\n2 2 4\n"}, "reference_outputs": ["4 0 4\n"], "source_document_id": "p02984", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an odd number.\n\nBetween these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \\leq i \\leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).\n\nWhen Mountain i (1 \\leq i \\leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).\n\nOne day, each of the mountains received a non-negative even number of liters of rain.\n\nAs a result, Dam i (1 \\leq i \\leq N) accumulated a total of A_i liters of water.\n\nFind the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 10^5-1\n\nN is an odd number.\n\n0 \\leq A_i \\leq 10^9\n\nThe situation represented by input can occur when each of the mountains receives a non-negative even number of liters of rain.\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 representing the number of liters of rain Mountain 1, Mountain 2, ..., Mountain N received, in this order.\n\nSample Input 1\n\n3\n2 2 4\n\nSample Output 1\n\n4 0 4\n\nIf we assume Mountain 1, 2, and 3 received 4, 0, and 4 liters of rain, respectively, it is consistent with this input, as follows:\n\nDam 1 should have accumulated \\frac{4}{2} + \\frac{0}{2} = 2 liters of water.\n\nDam 2 should have accumulated \\frac{0}{2} + \\frac{4}{2} = 2 liters of water.\n\nDam 3 should have accumulated \\frac{4}{2} + \\frac{4}{2} = 4 liters of water.\n\nSample Input 2\n\n5\n3 8 7 5 5\n\nSample Output 2\n\n2 4 12 2 8\n\nSample Input 3\n\n3\n1000000000 1000000000 0\n\nSample Output 3\n\n0 2000000000 0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1051, "cpu_time_ms": 1981, "memory_kb": 101128}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s741637008", "group_id": "codeNet:p02987", "input_text": "object Main {\n\tdef main(args: Array[String]): Unit = {\n\t\tval len = io.StdIn.readInt()\n\t\tval numsAsStr = io.StdIn.readLine().split(\" \")\n\t\tval numsAry = new Array[Int](len)\n\t\t\n\t\tfor (str <- numsAsStr) {\n\t\t\tnumsAry(numsAsStr.indexOf(str)) = str.toInt\n\t\t}\n\t\t\n\t\tvar count = 0\n\t\t\n\t\tfor (num <- 0 until len - 2) {\n\t\t\tif (returnBoolean(Array(numsAry(num), numsAry(num + 1), numsAry(num + 2)))) count += 1\n\t\t}\n\t\t\n\t\tprintln(count)\n\t}\n\t\n\tdef returnBoolean(array: Array[Int]): Boolean = {\n\t\tarray(1) == array.sortWith((x: Int, y: Int) => x < y)(1)\n\t}\n}", "language": "Scala", "metadata": {"date": 1563654784, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s741637008.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s741637008", "user_id": "u123715847"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main {\n\tdef main(args: Array[String]): Unit = {\n\t\tval len = io.StdIn.readInt()\n\t\tval numsAsStr = io.StdIn.readLine().split(\" \")\n\t\tval numsAry = new Array[Int](len)\n\t\t\n\t\tfor (str <- numsAsStr) {\n\t\t\tnumsAry(numsAsStr.indexOf(str)) = str.toInt\n\t\t}\n\t\t\n\t\tvar count = 0\n\t\t\n\t\tfor (num <- 0 until len - 2) {\n\t\t\tif (returnBoolean(Array(numsAry(num), numsAry(num + 1), numsAry(num + 2)))) count += 1\n\t\t}\n\t\t\n\t\tprintln(count)\n\t}\n\t\n\tdef returnBoolean(array: Array[Int]): Boolean = {\n\t\tarray(1) == array.sortWith((x: Int, y: Int) => x < y)(1)\n\t}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 540, "cpu_time_ms": 340, "memory_kb": 27196}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s112670065", "group_id": "codeNet:p02987", "input_text": "object Main {\n def main(args:Array[String]) = {\n /* 文字列を読み込み、空白で分割して配列にし、Int型にする */\n val in = readLine.split(\"\")\n val retn = if( 2 == in.filter(_ == in(0)).size == in.filter(_ == in(1)).size == in.filter(_ == in(2)).size ){\n \"Yes\"\n } else{\n \"No\"\n }\n println (retn)\n }\n}", "language": "Scala", "metadata": {"date": 1562037355, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s112670065.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s112670065", "user_id": "u100418016"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main {\n def main(args:Array[String]) = {\n /* 文字列を読み込み、空白で分割して配列にし、Int型にする */\n val in = readLine.split(\"\")\n val retn = if( 2 == in.filter(_ == in(0)).size == in.filter(_ == in(1)).size == in.filter(_ == in(2)).size ){\n \"Yes\"\n } else{\n \"No\"\n }\n println (retn)\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 328, "memory_kb": 27336}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s188178525", "group_id": "codeNet:p02987", "input_text": "\nimport scala.io.StdIn\n\nobject Main extends App {\n\n val s = StdIn.readLine.sorted\n if (s.charAt(0) == s.charAt(1) && s.charAt(2) == s.charAt(3) && s.charAt(1) != s.charAt(2)) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}\n", "language": "Scala", "metadata": {"date": 1561870687, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s188178525.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s188178525", "user_id": "u726872801"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "\nimport scala.io.StdIn\n\nobject Main extends App {\n\n val s = StdIn.readLine.sorted\n if (s.charAt(0) == s.charAt(1) && s.charAt(2) == s.charAt(3) && s.charAt(1) != s.charAt(2)) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 331, "memory_kb": 25416}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s872683228", "group_id": "codeNet:p02988", "input_text": "import scala.io.StdIn._\nobject Main extends App {\n val n = readInt\n val ds = readLine.split(\" \").map(_.toInt)\n println(ds.sliding(3).count{case Array(l, m, r) => (l - m) * (r - m) < 0})\n}", "language": "Scala", "metadata": {"date": 1575319799, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s872683228.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s872683228", "user_id": "u132324749"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.io.StdIn._\nobject Main extends App {\n val n = readInt\n val ds = readLine.split(\" \").map(_.toInt)\n println(ds.sliding(3).count{case Array(l, m, r) => (l - m) * (r - m) < 0})\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 336, "memory_kb": 25540}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s057046166", "group_id": "codeNet:p02988", "input_text": "object Main extends App {\n var get = readInt\n var list = readLine.split(\" \")\n var sum = 0\n var i = 0\n while(i < get-2){\n var count = List(list(i),list(i+1),list(i+2)).sorted\n if(list(i+1)==count(1)){\n if(count(0)!=count(1)&&count(1)!=count(2)){\n sum = sum + 1\n }\n }\n i= i + 1\n }\n println(sum)\n}", "language": "Scala", "metadata": {"date": 1561862043, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s057046166.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s057046166", "user_id": "u533688845"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n var get = readInt\n var list = readLine.split(\" \")\n var sum = 0\n var i = 0\n while(i < get-2){\n var count = List(list(i),list(i+1),list(i+2)).sorted\n if(list(i+1)==count(1)){\n if(count(0)!=count(1)&&count(1)!=count(2)){\n sum = sum + 1\n }\n }\n i= i + 1\n }\n println(sum)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 329, "memory_kb": 27204}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s005631424", "group_id": "codeNet:p02988", "input_text": "import scala.math._\n\nobject Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val p = List.fill(n)(sc.nextInt)\n\n val ans = p.foldLeft((0, (None, None, None)): (Int, (Option[Int], Option[Int], Option[Int])))((acc, v) => {\n val current = (acc._2._2, acc._2._3, Some(v))\n current match {\n case (Some(v1), Some(v2), Some(v3)) =>\n if ((v1 < v2 && v2 < v3) || (v3 < v2 && v2 < v1)) (acc._1 + 1, current)\n else (acc._1, current)\n case _ =>\n (0, current)\n }\n }\n )._1\n\n println(ans)\n\n ///////////////////////////////////////////\n\n def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =\n Iterator.iterate(start)(_ + step).takeWhile(_ <= end)\n\n def lcm(a :Int, b :Int): Int =\n a / gcd(a, b) * b\n\n def lcm(a :Long, b :Long): Long =\n a / gcd(a, b) * b\n\n def gcd(a: Int, b: Int): Int =\n if (b == 0) a else gcd(b, a % b)\n\n def gcd(a: Long, b: Long): Long =\n if (b == 0) a else gcd(b, a % b)\n}", "language": "Scala", "metadata": {"date": 1561859826, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s005631424.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s005631424", "user_id": "u040380439"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.math._\n\nobject Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val p = List.fill(n)(sc.nextInt)\n\n val ans = p.foldLeft((0, (None, None, None)): (Int, (Option[Int], Option[Int], Option[Int])))((acc, v) => {\n val current = (acc._2._2, acc._2._3, Some(v))\n current match {\n case (Some(v1), Some(v2), Some(v3)) =>\n if ((v1 < v2 && v2 < v3) || (v3 < v2 && v2 < v1)) (acc._1 + 1, current)\n else (acc._1, current)\n case _ =>\n (0, current)\n }\n }\n )._1\n\n println(ans)\n\n ///////////////////////////////////////////\n\n def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =\n Iterator.iterate(start)(_ + step).takeWhile(_ <= end)\n\n def lcm(a :Int, b :Int): Int =\n a / gcd(a, b) * b\n\n def lcm(a :Long, b :Long): Long =\n a / gcd(a, b) * b\n\n def gcd(a: Int, b: Int): Int =\n if (b == 0) a else gcd(b, a % b)\n\n def gcd(a: Long, b: Long): Long =\n if (b == 0) a else gcd(b, a % b)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1005, "cpu_time_ms": 345, "memory_kb": 25780}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s595390297", "group_id": "codeNet:p02988", "input_text": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val n = sc.nextInt()\n val p = Array.fill(n)(sc.nextInt())\n val count = p.sliding(3, 1).count { case Array(a, b, c) =>\n if ((b >= a && b < c) || (b >= c && b < a)) true\n else false\n }\n println(count)\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1561856863, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s595390297.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s595390297", "user_id": "u891387249"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val n = sc.nextInt()\n val p = Array.fill(n)(sc.nextInt())\n val count = p.sliding(3, 1).count { case Array(a, b, c) =>\n if ((b >= a && b < c) || (b >= c && b < a)) true\n else false\n }\n println(count)\n }\n\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 381, "memory_kb": 25668}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s022144696", "group_id": "codeNet:p02990", "input_text": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val N, K = sc.nextInt()\n\n // K個の青いボールを回収するために高橋君がちょうどi回操作をする必要がある時\n // 青いボールの置き方と赤いボールの置き方は独立して考えられる\n // N - K個の赤いボールを一列に並べて, N - K + 1個の隙間のどこに青いボールをK個置くかを考える\n // すると, N - K + 1個の隙間から i 個選ぶ選び方は {N-K+1}_C_i 通り\n // その隙間を選んだ後に, 各隙間に何個ボールを入れるかを考えるので\n // K 個のボールの隙間 K - 1 個の中から i - 1 個選ぶのは\n // {K-1}_C_{i-1} 通りあるので, それぞれの掛け合わせで\n // {N-K+1}_C_i * {K-1}_C_{i-1} となる\n\n def solve(N: Int, K: Int): IndexedSeq[BigInt] = {\n val MAX: Long = Math.pow(10, 9).toLong + 7\n val nCr = Array.fill(N+1, K+1)(BigInt(0L))\n (0 to K).foreach(i => nCr(i)(i) = 1L)\n (0 to N).foreach(i => {nCr(i)(0) = 1L; nCr(i)(1) = i})\n def combinations(n: Int, r: Int): BigInt = {\n if (n >= 0 && r >= 0) {\n if (nCr(n)(r) > 0) nCr(n)(r)\n else {\n nCr(n)(r) = combinations(n-1, r-1) + combinations(n-1, r)\n nCr(n)(r)\n }\n } else 0\n }\n combinations(N, K)\n for {\n i <- 1 to K\n } yield (nCr(N-K+1)(i) * nCr(K-1)(i-1)) % MAX\n }\n\n println(solve(N, K).mkString(\"\\n\"))\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1577558665, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02990.html", "problem_id": "p02990", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02990/input.txt", "sample_output_relpath": "derived/input_output/data/p02990/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02990/Scala/s022144696.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s022144696", "user_id": "u891387249"}, "prompt_components": {"gold_output": "3\n6\n1\n", "input_to_evaluate": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val N, K = sc.nextInt()\n\n // K個の青いボールを回収するために高橋君がちょうどi回操作をする必要がある時\n // 青いボールの置き方と赤いボールの置き方は独立して考えられる\n // N - K個の赤いボールを一列に並べて, N - K + 1個の隙間のどこに青いボールをK個置くかを考える\n // すると, N - K + 1個の隙間から i 個選ぶ選び方は {N-K+1}_C_i 通り\n // その隙間を選んだ後に, 各隙間に何個ボールを入れるかを考えるので\n // K 個のボールの隙間 K - 1 個の中から i - 1 個選ぶのは\n // {K-1}_C_{i-1} 通りあるので, それぞれの掛け合わせで\n // {N-K+1}_C_i * {K-1}_C_{i-1} となる\n\n def solve(N: Int, K: Int): IndexedSeq[BigInt] = {\n val MAX: Long = Math.pow(10, 9).toLong + 7\n val nCr = Array.fill(N+1, K+1)(BigInt(0L))\n (0 to K).foreach(i => nCr(i)(i) = 1L)\n (0 to N).foreach(i => {nCr(i)(0) = 1L; nCr(i)(1) = i})\n def combinations(n: Int, r: Int): BigInt = {\n if (n >= 0 && r >= 0) {\n if (nCr(n)(r) > 0) nCr(n)(r)\n else {\n nCr(n)(r) = combinations(n-1, r-1) + combinations(n-1, r)\n nCr(n)(r)\n }\n } else 0\n }\n combinations(N, K)\n for {\n i <- 1 to K\n } yield (nCr(N-K+1)(i) * nCr(K-1)(i-1)) % MAX\n }\n\n println(solve(N, K).mkString(\"\\n\"))\n }\n\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are K blue balls and N-K red balls. The balls of the same color cannot be distinguished. Snuke and Takahashi are playing with these balls.\n\nFirst, Snuke will arrange the N balls in a row from left to right.\n\nThen, Takahashi will collect only the K blue balls. In one move, he can collect any number of consecutive blue balls. He will collect all the blue balls in the fewest moves possible.\n\nHow many ways are there for Snuke to arrange the N balls in a row so that Takahashi will need exactly i moves to collect all the blue balls? Compute this number modulo 10^9+7 for each i such that 1 \\leq i \\leq K.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 2000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint K lines. The i-th line (1 \\leq i \\leq K) should contain the number of ways to arrange the N balls so that Takahashi will need exactly i moves to collect all the blue balls, modulo 10^9+7.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n3\n6\n1\n\nThere are three ways to arrange the balls so that Takahashi will need exactly one move: (B, B, B, R, R), (R, B, B, B, R), and (R, R, B, B, B). (R and B stands for red and blue, respectively).\n\nThere are six ways to arrange the balls so that Takahashi will need exactly two moves: (B, B, R, B, R), (B, B, R, R, B), (R, B, B, R, B), (R, B, R, B, B), (B, R, B, B, R), and (B, R, R, B, B).\n\nThere is one way to arrange the balls so that Takahashi will need exactly three moves: (B, R, B, R, B).\n\nSample Input 2\n\n2000 3\n\nSample Output 2\n\n1998\n3990006\n327341989\n\nBe sure to print the numbers of arrangements modulo 10^9+7.", "sample_input": "5 3\n"}, "reference_outputs": ["3\n6\n1\n"], "source_document_id": "p02990", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are K blue balls and N-K red balls. The balls of the same color cannot be distinguished. Snuke and Takahashi are playing with these balls.\n\nFirst, Snuke will arrange the N balls in a row from left to right.\n\nThen, Takahashi will collect only the K blue balls. In one move, he can collect any number of consecutive blue balls. He will collect all the blue balls in the fewest moves possible.\n\nHow many ways are there for Snuke to arrange the N balls in a row so that Takahashi will need exactly i moves to collect all the blue balls? Compute this number modulo 10^9+7 for each i such that 1 \\leq i \\leq K.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 2000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint K lines. The i-th line (1 \\leq i \\leq K) should contain the number of ways to arrange the N balls so that Takahashi will need exactly i moves to collect all the blue balls, modulo 10^9+7.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n3\n6\n1\n\nThere are three ways to arrange the balls so that Takahashi will need exactly one move: (B, B, B, R, R), (R, B, B, B, R), and (R, R, B, B, B). (R and B stands for red and blue, respectively).\n\nThere are six ways to arrange the balls so that Takahashi will need exactly two moves: (B, B, R, B, R), (B, B, R, R, B), (R, B, B, R, B), (R, B, R, B, B), (B, R, B, B, R), and (B, R, R, B, B).\n\nThere is one way to arrange the balls so that Takahashi will need exactly three moves: (B, R, B, R, B).\n\nSample Input 2\n\n2000 3\n\nSample Output 2\n\n1998\n3990006\n327341989\n\nBe sure to print the numbers of arrangements modulo 10^9+7.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1554, "cpu_time_ms": 1601, "memory_kb": 266276}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s823120223", "group_id": "codeNet:p02991", "input_text": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\nimport scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val N, M = in.next().toInt\n val graph = Array.fill[List[Int]](N+1)(Nil)\n for (_ <- 1 to M) {\n val u, v = in.next().toInt\n graph(u) = v :: graph(u)\n }\n val S, T = in.next().toInt\n\n //\n val q = new Queue[(Int, Int)]() // (moveNum, node)\n val dp = new Array[Boolean](N+1)\n\n q.enqueue((0, S))\n\n var ans = -1\n breakable {\n while (!q.isEmpty) {\n val (cost, now) = q.dequeue\n\n if (now == T) {\n ans = cost\n break\n }\n\n dp(now) = true\n var set = Set[Int]()\n set += now\n\n for (i <- 0 to 3) {\n val nextSet = Set[Int]()\n for (e <- set) {\n if (i == 3 || i == 1) {\n if (!dp(e)) {\n q.enqueue((cost+1, e))\n dp(e) = true\n }\n }\n\n if (i < 3) {\n for (e2 <- graph(e))\n nextSet += e2\n }\n }\n\n set = nextSet\n }\n }\n }\n\n println(ans)\n\n}\n\nobject Sub {\n def print2DimArray[A](mat: Array[Array[A]]): Unit = {\n mat.foreach(lin => println(lin.deep))\n }\n}\n\nclass InputReader(stream: InputStream) {\n private[this] val reader = new BufferedReader(new InputStreamReader(stream))\n private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n", "language": "Scala", "metadata": {"date": 1576542279, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02991.html", "problem_id": "p02991", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02991/input.txt", "sample_output_relpath": "derived/input_output/data/p02991/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02991/Scala/s823120223.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s823120223", "user_id": "u098968285"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\nimport scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val N, M = in.next().toInt\n val graph = Array.fill[List[Int]](N+1)(Nil)\n for (_ <- 1 to M) {\n val u, v = in.next().toInt\n graph(u) = v :: graph(u)\n }\n val S, T = in.next().toInt\n\n //\n val q = new Queue[(Int, Int)]() // (moveNum, node)\n val dp = new Array[Boolean](N+1)\n\n q.enqueue((0, S))\n\n var ans = -1\n breakable {\n while (!q.isEmpty) {\n val (cost, now) = q.dequeue\n\n if (now == T) {\n ans = cost\n break\n }\n\n dp(now) = true\n var set = Set[Int]()\n set += now\n\n for (i <- 0 to 3) {\n val nextSet = Set[Int]()\n for (e <- set) {\n if (i == 3 || i == 1) {\n if (!dp(e)) {\n q.enqueue((cost+1, e))\n dp(e) = true\n }\n }\n\n if (i < 3) {\n for (e2 <- graph(e))\n nextSet += e2\n }\n }\n\n set = nextSet\n }\n }\n }\n\n println(ans)\n\n}\n\nobject Sub {\n def print2DimArray[A](mat: Array[Array[A]]): Unit = {\n mat.foreach(lin => println(lin.deep))\n }\n}\n\nclass InputReader(stream: InputStream) {\n private[this] val reader = new BufferedReader(new InputStreamReader(stream))\n private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nKen loves ken-ken-pa (Japanese version of hopscotch). Today, he will play it on a directed graph G.\nG consists of N vertices numbered 1 to N, and M edges. The i-th edge points from Vertex u_i to Vertex v_i.\n\nFirst, Ken stands on Vertex S. He wants to reach Vertex T by repeating ken-ken-pa. In one ken-ken-pa, he does the following exactly three times: follow an edge pointing from the vertex on which he is standing.\n\nDetermine if he can reach Vertex T by repeating ken-ken-pa. If the answer is yes, find the minimum number of ken-ken-pa needed to reach Vertex T. Note that visiting Vertex T in the middle of a ken-ken-pa does not count as reaching Vertex T by repeating ken-ken-pa.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n0 \\leq M \\leq \\min(10^5, N (N-1))\n\n1 \\leq u_i, v_i \\leq N(1 \\leq i \\leq M)\n\nu_i \\neq v_i (1 \\leq i \\leq M)\n\nIf i \\neq j, (u_i, v_i) \\neq (u_j, v_j).\n\n1 \\leq S, T \\leq N\n\nS \\neq T\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nu_1 v_1\n:\nu_M v_M\nS T\n\nOutput\n\nIf Ken cannot reach Vertex T from Vertex S by repeating ken-ken-pa, print -1.\nIf he can, print the minimum number of ken-ken-pa needed to reach vertex T.\n\nSample Input 1\n\n4 4\n1 2\n2 3\n3 4\n4 1\n1 3\n\nSample Output 1\n\n2\n\nKen can reach Vertex 3 from Vertex 1 in two ken-ken-pa, as follows: 1 \\rightarrow 2 \\rightarrow 3 \\rightarrow 4 in the first ken-ken-pa, then 4 \\rightarrow 1 \\rightarrow 2 \\rightarrow 3 in the second ken-ken-pa. This is the minimum number of ken-ken-pa needed.\n\nSample Input 2\n\n3 3\n1 2\n2 3\n3 1\n1 2\n\nSample Output 2\n\n-1\n\nAny number of ken-ken-pa will bring Ken back to Vertex 1, so he cannot reach Vertex 2, though he can pass through it in the middle of a ken-ken-pa.\n\nSample Input 3\n\n2 0\n1 2\n\nSample Output 3\n\n-1\n\nVertex S and Vertex T may be disconnected.\n\nSample Input 4\n\n6 8\n1 2\n2 3\n3 4\n4 5\n5 1\n1 4\n1 5\n4 6\n1 6\n\nSample Output 4\n\n2", "sample_input": "4 4\n1 2\n2 3\n3 4\n4 1\n1 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02991", "source_text": "Score : 500 points\n\nProblem Statement\n\nKen loves ken-ken-pa (Japanese version of hopscotch). Today, he will play it on a directed graph G.\nG consists of N vertices numbered 1 to N, and M edges. The i-th edge points from Vertex u_i to Vertex v_i.\n\nFirst, Ken stands on Vertex S. He wants to reach Vertex T by repeating ken-ken-pa. In one ken-ken-pa, he does the following exactly three times: follow an edge pointing from the vertex on which he is standing.\n\nDetermine if he can reach Vertex T by repeating ken-ken-pa. If the answer is yes, find the minimum number of ken-ken-pa needed to reach Vertex T. Note that visiting Vertex T in the middle of a ken-ken-pa does not count as reaching Vertex T by repeating ken-ken-pa.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n0 \\leq M \\leq \\min(10^5, N (N-1))\n\n1 \\leq u_i, v_i \\leq N(1 \\leq i \\leq M)\n\nu_i \\neq v_i (1 \\leq i \\leq M)\n\nIf i \\neq j, (u_i, v_i) \\neq (u_j, v_j).\n\n1 \\leq S, T \\leq N\n\nS \\neq T\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nu_1 v_1\n:\nu_M v_M\nS T\n\nOutput\n\nIf Ken cannot reach Vertex T from Vertex S by repeating ken-ken-pa, print -1.\nIf he can, print the minimum number of ken-ken-pa needed to reach vertex T.\n\nSample Input 1\n\n4 4\n1 2\n2 3\n3 4\n4 1\n1 3\n\nSample Output 1\n\n2\n\nKen can reach Vertex 3 from Vertex 1 in two ken-ken-pa, as follows: 1 \\rightarrow 2 \\rightarrow 3 \\rightarrow 4 in the first ken-ken-pa, then 4 \\rightarrow 1 \\rightarrow 2 \\rightarrow 3 in the second ken-ken-pa. This is the minimum number of ken-ken-pa needed.\n\nSample Input 2\n\n3 3\n1 2\n2 3\n3 1\n1 2\n\nSample Output 2\n\n-1\n\nAny number of ken-ken-pa will bring Ken back to Vertex 1, so he cannot reach Vertex 2, though he can pass through it in the middle of a ken-ken-pa.\n\nSample Input 3\n\n2 0\n1 2\n\nSample Output 3\n\n-1\n\nVertex S and Vertex T may be disconnected.\n\nSample Input 4\n\n6 8\n1 2\n2 3\n3 4\n4 5\n5 1\n1 4\n1 5\n4 6\n1 6\n\nSample Output 4\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1692, "cpu_time_ms": 2111, "memory_kb": 123888}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s178278913", "group_id": "codeNet:p02991", "input_text": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.collection.mutable\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val N, M = sc.nextInt()\n val B = Array.fill(N * 3)(Long.MaxValue / 6)\n val A = Array.fill(N * 3)(Array.fill(0)(0))\n Array.fill(M)(((sc.nextInt() - 1) * 3, (sc.nextInt() - 1) * 3))\n .foreach(x => {\n A(x._1) :+= x._2 + 1\n A(x._1 + 1) :+= x._2 + 2\n A(x._1 + 2) :+= x._2\n })\n val S, T = (sc.nextInt() - 1) * 3\n B(S) = 0\n val que = new mutable.PriorityQueue[(Int, Int)]()\n que.enqueue((0, S))\n\n while (que.nonEmpty) {\n val now = que.dequeue()\n if (now._1 == B(now._2)) {\n for (nextPoint <- A(now._2)) {\n if (B(nextPoint) > now._1 + 1) {\n B(nextPoint) = now._1 + 1\n que.enqueue((now._1 + 1, nextPoint))\n }\n }\n }\n }\n println(if (B(T + 2) == Long.MaxValue / 6) -1 else B(T + 2))\n }\n\n def time(s: String): Int =\n s.substring(0, 2).toInt * 60 + s.substring(3, 5).toInt\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def calc(A: Array[Long]): Array[String] = {\n if (A.length == 0) Array.fill(0)(\"\")\n else {\n val last = A.zipWithIndex.map(x => (x._1 - x._2, x._1)).takeWhile(x => x._1 == A.head).last._2\n if (last == A.head) \"%d\".format(A.head) +: calc(A.zipWithIndex.map(x => (x._1 - x._2, x._1)).dropWhile(x => x._1 == A.head).map(x => x._2))\n else \"%d-%d\".format(A.head, last) +: calc(A.zipWithIndex.map(x => (x._1 - x._2, x._1)).dropWhile(x => x._1 == A.head).map(x => x._2))\n }\n }\n\n var memo: Map[(Long, Long), Long] = Map[(Long, Long), Long]()\n\n\n def recursive2(X: Set[Long], Y: Stream[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n\n def check(i: Int, X: String): Long = {\n if (X == \"\") 0 else check(i, X.tail) * i + X.head.toString.toLong\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n @scala.annotation.tailrec\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def primeFactors(i: Long): List[Long] = primeFactors_(i, 1).sorted\n\n\n def primeFactors_(i: Long, j: Long): List[Long] = {\n if (j * j > i) List.empty else if (i % j == 0) primeFactors_(i, j + 1) ++ List[Long](j, i / j) else primeFactors_(i, j + 1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n}\n", "language": "Scala", "metadata": {"date": 1568673316, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02991.html", "problem_id": "p02991", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02991/input.txt", "sample_output_relpath": "derived/input_output/data/p02991/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02991/Scala/s178278913.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s178278913", "user_id": "u779353743"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.collection.mutable\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val N, M = sc.nextInt()\n val B = Array.fill(N * 3)(Long.MaxValue / 6)\n val A = Array.fill(N * 3)(Array.fill(0)(0))\n Array.fill(M)(((sc.nextInt() - 1) * 3, (sc.nextInt() - 1) * 3))\n .foreach(x => {\n A(x._1) :+= x._2 + 1\n A(x._1 + 1) :+= x._2 + 2\n A(x._1 + 2) :+= x._2\n })\n val S, T = (sc.nextInt() - 1) * 3\n B(S) = 0\n val que = new mutable.PriorityQueue[(Int, Int)]()\n que.enqueue((0, S))\n\n while (que.nonEmpty) {\n val now = que.dequeue()\n if (now._1 == B(now._2)) {\n for (nextPoint <- A(now._2)) {\n if (B(nextPoint) > now._1 + 1) {\n B(nextPoint) = now._1 + 1\n que.enqueue((now._1 + 1, nextPoint))\n }\n }\n }\n }\n println(if (B(T + 2) == Long.MaxValue / 6) -1 else B(T + 2))\n }\n\n def time(s: String): Int =\n s.substring(0, 2).toInt * 60 + s.substring(3, 5).toInt\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def calc(A: Array[Long]): Array[String] = {\n if (A.length == 0) Array.fill(0)(\"\")\n else {\n val last = A.zipWithIndex.map(x => (x._1 - x._2, x._1)).takeWhile(x => x._1 == A.head).last._2\n if (last == A.head) \"%d\".format(A.head) +: calc(A.zipWithIndex.map(x => (x._1 - x._2, x._1)).dropWhile(x => x._1 == A.head).map(x => x._2))\n else \"%d-%d\".format(A.head, last) +: calc(A.zipWithIndex.map(x => (x._1 - x._2, x._1)).dropWhile(x => x._1 == A.head).map(x => x._2))\n }\n }\n\n var memo: Map[(Long, Long), Long] = Map[(Long, Long), Long]()\n\n\n def recursive2(X: Set[Long], Y: Stream[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n\n def check(i: Int, X: String): Long = {\n if (X == \"\") 0 else check(i, X.tail) * i + X.head.toString.toLong\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n @scala.annotation.tailrec\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def primeFactors(i: Long): List[Long] = primeFactors_(i, 1).sorted\n\n\n def primeFactors_(i: Long, j: Long): List[Long] = {\n if (j * j > i) List.empty else if (i % j == 0) primeFactors_(i, j + 1) ++ List[Long](j, i / j) else primeFactors_(i, j + 1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nKen loves ken-ken-pa (Japanese version of hopscotch). Today, he will play it on a directed graph G.\nG consists of N vertices numbered 1 to N, and M edges. The i-th edge points from Vertex u_i to Vertex v_i.\n\nFirst, Ken stands on Vertex S. He wants to reach Vertex T by repeating ken-ken-pa. In one ken-ken-pa, he does the following exactly three times: follow an edge pointing from the vertex on which he is standing.\n\nDetermine if he can reach Vertex T by repeating ken-ken-pa. If the answer is yes, find the minimum number of ken-ken-pa needed to reach Vertex T. Note that visiting Vertex T in the middle of a ken-ken-pa does not count as reaching Vertex T by repeating ken-ken-pa.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n0 \\leq M \\leq \\min(10^5, N (N-1))\n\n1 \\leq u_i, v_i \\leq N(1 \\leq i \\leq M)\n\nu_i \\neq v_i (1 \\leq i \\leq M)\n\nIf i \\neq j, (u_i, v_i) \\neq (u_j, v_j).\n\n1 \\leq S, T \\leq N\n\nS \\neq T\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nu_1 v_1\n:\nu_M v_M\nS T\n\nOutput\n\nIf Ken cannot reach Vertex T from Vertex S by repeating ken-ken-pa, print -1.\nIf he can, print the minimum number of ken-ken-pa needed to reach vertex T.\n\nSample Input 1\n\n4 4\n1 2\n2 3\n3 4\n4 1\n1 3\n\nSample Output 1\n\n2\n\nKen can reach Vertex 3 from Vertex 1 in two ken-ken-pa, as follows: 1 \\rightarrow 2 \\rightarrow 3 \\rightarrow 4 in the first ken-ken-pa, then 4 \\rightarrow 1 \\rightarrow 2 \\rightarrow 3 in the second ken-ken-pa. This is the minimum number of ken-ken-pa needed.\n\nSample Input 2\n\n3 3\n1 2\n2 3\n3 1\n1 2\n\nSample Output 2\n\n-1\n\nAny number of ken-ken-pa will bring Ken back to Vertex 1, so he cannot reach Vertex 2, though he can pass through it in the middle of a ken-ken-pa.\n\nSample Input 3\n\n2 0\n1 2\n\nSample Output 3\n\n-1\n\nVertex S and Vertex T may be disconnected.\n\nSample Input 4\n\n6 8\n1 2\n2 3\n3 4\n4 5\n5 1\n1 4\n1 5\n4 6\n1 6\n\nSample Output 4\n\n2", "sample_input": "4 4\n1 2\n2 3\n3 4\n4 1\n1 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02991", "source_text": "Score : 500 points\n\nProblem Statement\n\nKen loves ken-ken-pa (Japanese version of hopscotch). Today, he will play it on a directed graph G.\nG consists of N vertices numbered 1 to N, and M edges. The i-th edge points from Vertex u_i to Vertex v_i.\n\nFirst, Ken stands on Vertex S. He wants to reach Vertex T by repeating ken-ken-pa. In one ken-ken-pa, he does the following exactly three times: follow an edge pointing from the vertex on which he is standing.\n\nDetermine if he can reach Vertex T by repeating ken-ken-pa. If the answer is yes, find the minimum number of ken-ken-pa needed to reach Vertex T. Note that visiting Vertex T in the middle of a ken-ken-pa does not count as reaching Vertex T by repeating ken-ken-pa.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n0 \\leq M \\leq \\min(10^5, N (N-1))\n\n1 \\leq u_i, v_i \\leq N(1 \\leq i \\leq M)\n\nu_i \\neq v_i (1 \\leq i \\leq M)\n\nIf i \\neq j, (u_i, v_i) \\neq (u_j, v_j).\n\n1 \\leq S, T \\leq N\n\nS \\neq T\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nu_1 v_1\n:\nu_M v_M\nS T\n\nOutput\n\nIf Ken cannot reach Vertex T from Vertex S by repeating ken-ken-pa, print -1.\nIf he can, print the minimum number of ken-ken-pa needed to reach vertex T.\n\nSample Input 1\n\n4 4\n1 2\n2 3\n3 4\n4 1\n1 3\n\nSample Output 1\n\n2\n\nKen can reach Vertex 3 from Vertex 1 in two ken-ken-pa, as follows: 1 \\rightarrow 2 \\rightarrow 3 \\rightarrow 4 in the first ken-ken-pa, then 4 \\rightarrow 1 \\rightarrow 2 \\rightarrow 3 in the second ken-ken-pa. This is the minimum number of ken-ken-pa needed.\n\nSample Input 2\n\n3 3\n1 2\n2 3\n3 1\n1 2\n\nSample Output 2\n\n-1\n\nAny number of ken-ken-pa will bring Ken back to Vertex 1, so he cannot reach Vertex 2, though he can pass through it in the middle of a ken-ken-pa.\n\nSample Input 3\n\n2 0\n1 2\n\nSample Output 3\n\n-1\n\nVertex S and Vertex T may be disconnected.\n\nSample Input 4\n\n6 8\n1 2\n2 3\n3 4\n4 5\n5 1\n1 4\n1 5\n4 6\n1 6\n\nSample Output 4\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 7490, "cpu_time_ms": 2111, "memory_kb": 145116}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s265059000", "group_id": "codeNet:p02991", "input_text": "object Main {\n import java.io.{BufferedReader, InputStream, InputStreamReader}\n import java.util.StringTokenizer\n import scala.reflect.ClassTag\n\n def main(args: Array[String]): Unit = {\n val out = new java.io.PrintWriter(System.out)\n new Main(out, new InputReader(System.in)).solve()\n out.flush()\n }\n\n private val oj = System.getenv(\"ATCODER_DEBUG\") == null\n def DEBUG(f: => Unit): Unit = {\n if (!oj){ f }\n }\n def debug(as: Array[Boolean]): Unit = if (!oj){ debug(as.map(x => if(x) \"1\" else \"0\").mkString) }\n def debug(as: Array[Int]): Unit = if (!oj){ debug(as.mkString(\" \")) }\n def debug(as: Array[Long]): Unit =if (!oj){ debug(as.mkString(\" \")) }\n def debugDim(m: Array[Array[Int]]): Unit = if (!oj){\n REP(m.length) { i =>\n debug(m(i))\n }\n }\n def debugDimFlip(m: Array[Array[Long]]): Unit = if (!oj){\n REP(m(0).length) { j =>\n REP(m.length) { i =>\n System.err.print(m(i)(j))\n System.err.print(\" \")\n }\n System.err.println()\n }\n }\n def debug(s: => String): Unit = DEBUG {\n System.err.println(s)\n }\n def debugL(num: => Long): Unit = DEBUG {\n System.err.println(num)\n }\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = Integer.parseInt(next())\n def nextLong(): Long = java.lang.Long.parseLong(next())\n def nextChar(): Char = next().charAt(0)\n\n def ni(): Int = nextInt()\n def nl(): Long = nextLong()\n def nc(): Char = nextChar()\n def ns(): String = next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n }\n\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n def TO(from: Int, to: Int)(f: Int => Unit): Unit = {\n REP(to - from + 1, from) { i =>\n f(i)\n }\n }\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n def cumSum(as: Array[Int]): Array[Long] = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n\nclass Main(out: java.io.PrintWriter, sc: Main.InputReader) extends Runnable {\n import sc._\n import Main._\n import java.util.Arrays.sort\n\n import scala.collection.mutable\n import math.{abs, max, min}\n import mutable.ArrayBuffer\n\n // toIntとか+7とかするならvalにしろ\n @inline private def MOD = 1000000007\n\n\n override def run(): Unit = {\n val N, M = ni()\n val (to, from) = na2(M, -1) // 方向が逆\n val g = packDGraph(N, from, to)\n val S, T = ni() - 1\n\n val INF = 1e9.toInt\n val INF2 = 2e9.toInt + 10\n val dp = Array.fill[Int](N, 3)(INF2)\n val visit = Array.ofDim[Boolean](N, 3)\n dp(S)(0) = 0\n def dfs(v: Int, m: Int): Int = {\n if (visit(v)(m)) INF\n else {\n if (dp(v)(m) == INF2) {\n visit(v)(m) = true\n var res = INF\n REP(g(v).length) { i =>\n val u = g(v)(i)\n val add = if (m == 1) 1 else 0\n res = min(res, dfs(u, (3 + m - 1) % 3) + add)\n }\n dp(v)(m) = res\n visit(v)(m) = false\n }\n dp(v)(m)\n }\n }\n\n REP(3) { i =>\n dfs(T, 0)\n }\n\n val ans = if (dp(T)(0) == INF) -1 else dp(T)(0)\n out.println(ans)\n }\n\n def packDGraph(n: Int, from: Array[Int], to: Array[Int]): Array[Array[Int]] = {\n val t = new Array[Array[Int]](n)\n val p = new Array[Int](n)\n val m = from.length\n REP(m)(i => p(from(i)) += 1)\n REP(n)(i => t(i) = new Array(p(i)))\n REP_r(m) { i => // 順序維持する\n p(from(i)) -= 1\n t(from(i))(p(from(i))) = to(i)\n }\n t\n }\n\n def solve(): Unit = {\n val th = new Thread(null, this, \"solve\", 1 << 26)\n th.start()\n th.join()\n }\n}", "language": "Scala", "metadata": {"date": 1561861286, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02991.html", "problem_id": "p02991", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02991/input.txt", "sample_output_relpath": "derived/input_output/data/p02991/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02991/Scala/s265059000.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s265059000", "user_id": "u460609472"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main {\n import java.io.{BufferedReader, InputStream, InputStreamReader}\n import java.util.StringTokenizer\n import scala.reflect.ClassTag\n\n def main(args: Array[String]): Unit = {\n val out = new java.io.PrintWriter(System.out)\n new Main(out, new InputReader(System.in)).solve()\n out.flush()\n }\n\n private val oj = System.getenv(\"ATCODER_DEBUG\") == null\n def DEBUG(f: => Unit): Unit = {\n if (!oj){ f }\n }\n def debug(as: Array[Boolean]): Unit = if (!oj){ debug(as.map(x => if(x) \"1\" else \"0\").mkString) }\n def debug(as: Array[Int]): Unit = if (!oj){ debug(as.mkString(\" \")) }\n def debug(as: Array[Long]): Unit =if (!oj){ debug(as.mkString(\" \")) }\n def debugDim(m: Array[Array[Int]]): Unit = if (!oj){\n REP(m.length) { i =>\n debug(m(i))\n }\n }\n def debugDimFlip(m: Array[Array[Long]]): Unit = if (!oj){\n REP(m(0).length) { j =>\n REP(m.length) { i =>\n System.err.print(m(i)(j))\n System.err.print(\" \")\n }\n System.err.println()\n }\n }\n def debug(s: => String): Unit = DEBUG {\n System.err.println(s)\n }\n def debugL(num: => Long): Unit = DEBUG {\n System.err.println(num)\n }\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = Integer.parseInt(next())\n def nextLong(): Long = java.lang.Long.parseLong(next())\n def nextChar(): Char = next().charAt(0)\n\n def ni(): Int = nextInt()\n def nl(): Long = nextLong()\n def nc(): Char = nextChar()\n def ns(): String = next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n }\n\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n def TO(from: Int, to: Int)(f: Int => Unit): Unit = {\n REP(to - from + 1, from) { i =>\n f(i)\n }\n }\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n def cumSum(as: Array[Int]): Array[Long] = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n\nclass Main(out: java.io.PrintWriter, sc: Main.InputReader) extends Runnable {\n import sc._\n import Main._\n import java.util.Arrays.sort\n\n import scala.collection.mutable\n import math.{abs, max, min}\n import mutable.ArrayBuffer\n\n // toIntとか+7とかするならvalにしろ\n @inline private def MOD = 1000000007\n\n\n override def run(): Unit = {\n val N, M = ni()\n val (to, from) = na2(M, -1) // 方向が逆\n val g = packDGraph(N, from, to)\n val S, T = ni() - 1\n\n val INF = 1e9.toInt\n val INF2 = 2e9.toInt + 10\n val dp = Array.fill[Int](N, 3)(INF2)\n val visit = Array.ofDim[Boolean](N, 3)\n dp(S)(0) = 0\n def dfs(v: Int, m: Int): Int = {\n if (visit(v)(m)) INF\n else {\n if (dp(v)(m) == INF2) {\n visit(v)(m) = true\n var res = INF\n REP(g(v).length) { i =>\n val u = g(v)(i)\n val add = if (m == 1) 1 else 0\n res = min(res, dfs(u, (3 + m - 1) % 3) + add)\n }\n dp(v)(m) = res\n visit(v)(m) = false\n }\n dp(v)(m)\n }\n }\n\n REP(3) { i =>\n dfs(T, 0)\n }\n\n val ans = if (dp(T)(0) == INF) -1 else dp(T)(0)\n out.println(ans)\n }\n\n def packDGraph(n: Int, from: Array[Int], to: Array[Int]): Array[Array[Int]] = {\n val t = new Array[Array[Int]](n)\n val p = new Array[Int](n)\n val m = from.length\n REP(m)(i => p(from(i)) += 1)\n REP(n)(i => t(i) = new Array(p(i)))\n REP_r(m) { i => // 順序維持する\n p(from(i)) -= 1\n t(from(i))(p(from(i))) = to(i)\n }\n t\n }\n\n def solve(): Unit = {\n val th = new Thread(null, this, \"solve\", 1 << 26)\n th.start()\n th.join()\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nKen loves ken-ken-pa (Japanese version of hopscotch). Today, he will play it on a directed graph G.\nG consists of N vertices numbered 1 to N, and M edges. The i-th edge points from Vertex u_i to Vertex v_i.\n\nFirst, Ken stands on Vertex S. He wants to reach Vertex T by repeating ken-ken-pa. In one ken-ken-pa, he does the following exactly three times: follow an edge pointing from the vertex on which he is standing.\n\nDetermine if he can reach Vertex T by repeating ken-ken-pa. If the answer is yes, find the minimum number of ken-ken-pa needed to reach Vertex T. Note that visiting Vertex T in the middle of a ken-ken-pa does not count as reaching Vertex T by repeating ken-ken-pa.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n0 \\leq M \\leq \\min(10^5, N (N-1))\n\n1 \\leq u_i, v_i \\leq N(1 \\leq i \\leq M)\n\nu_i \\neq v_i (1 \\leq i \\leq M)\n\nIf i \\neq j, (u_i, v_i) \\neq (u_j, v_j).\n\n1 \\leq S, T \\leq N\n\nS \\neq T\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nu_1 v_1\n:\nu_M v_M\nS T\n\nOutput\n\nIf Ken cannot reach Vertex T from Vertex S by repeating ken-ken-pa, print -1.\nIf he can, print the minimum number of ken-ken-pa needed to reach vertex T.\n\nSample Input 1\n\n4 4\n1 2\n2 3\n3 4\n4 1\n1 3\n\nSample Output 1\n\n2\n\nKen can reach Vertex 3 from Vertex 1 in two ken-ken-pa, as follows: 1 \\rightarrow 2 \\rightarrow 3 \\rightarrow 4 in the first ken-ken-pa, then 4 \\rightarrow 1 \\rightarrow 2 \\rightarrow 3 in the second ken-ken-pa. This is the minimum number of ken-ken-pa needed.\n\nSample Input 2\n\n3 3\n1 2\n2 3\n3 1\n1 2\n\nSample Output 2\n\n-1\n\nAny number of ken-ken-pa will bring Ken back to Vertex 1, so he cannot reach Vertex 2, though he can pass through it in the middle of a ken-ken-pa.\n\nSample Input 3\n\n2 0\n1 2\n\nSample Output 3\n\n-1\n\nVertex S and Vertex T may be disconnected.\n\nSample Input 4\n\n6 8\n1 2\n2 3\n3 4\n4 5\n5 1\n1 4\n1 5\n4 6\n1 6\n\nSample Output 4\n\n2", "sample_input": "4 4\n1 2\n2 3\n3 4\n4 1\n1 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02991", "source_text": "Score : 500 points\n\nProblem Statement\n\nKen loves ken-ken-pa (Japanese version of hopscotch). Today, he will play it on a directed graph G.\nG consists of N vertices numbered 1 to N, and M edges. The i-th edge points from Vertex u_i to Vertex v_i.\n\nFirst, Ken stands on Vertex S. He wants to reach Vertex T by repeating ken-ken-pa. In one ken-ken-pa, he does the following exactly three times: follow an edge pointing from the vertex on which he is standing.\n\nDetermine if he can reach Vertex T by repeating ken-ken-pa. If the answer is yes, find the minimum number of ken-ken-pa needed to reach Vertex T. Note that visiting Vertex T in the middle of a ken-ken-pa does not count as reaching Vertex T by repeating ken-ken-pa.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n0 \\leq M \\leq \\min(10^5, N (N-1))\n\n1 \\leq u_i, v_i \\leq N(1 \\leq i \\leq M)\n\nu_i \\neq v_i (1 \\leq i \\leq M)\n\nIf i \\neq j, (u_i, v_i) \\neq (u_j, v_j).\n\n1 \\leq S, T \\leq N\n\nS \\neq T\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nu_1 v_1\n:\nu_M v_M\nS T\n\nOutput\n\nIf Ken cannot reach Vertex T from Vertex S by repeating ken-ken-pa, print -1.\nIf he can, print the minimum number of ken-ken-pa needed to reach vertex T.\n\nSample Input 1\n\n4 4\n1 2\n2 3\n3 4\n4 1\n1 3\n\nSample Output 1\n\n2\n\nKen can reach Vertex 3 from Vertex 1 in two ken-ken-pa, as follows: 1 \\rightarrow 2 \\rightarrow 3 \\rightarrow 4 in the first ken-ken-pa, then 4 \\rightarrow 1 \\rightarrow 2 \\rightarrow 3 in the second ken-ken-pa. This is the minimum number of ken-ken-pa needed.\n\nSample Input 2\n\n3 3\n1 2\n2 3\n3 1\n1 2\n\nSample Output 2\n\n-1\n\nAny number of ken-ken-pa will bring Ken back to Vertex 1, so he cannot reach Vertex 2, though he can pass through it in the middle of a ken-ken-pa.\n\nSample Input 3\n\n2 0\n1 2\n\nSample Output 3\n\n-1\n\nVertex S and Vertex T may be disconnected.\n\nSample Input 4\n\n6 8\n1 2\n2 3\n3 4\n4 5\n5 1\n1 4\n1 5\n4 6\n1 6\n\nSample Output 4\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4944, "cpu_time_ms": 817, "memory_kb": 106968}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s211525005", "group_id": "codeNet:p02993", "input_text": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val s = in.readLine.toCharArray\n val ans = if(s(0) != s(1) && s(1) != s(2) && s(2) != s(3)) \"Goog\" else \"Bad\"\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1561251842, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s211525005.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s211525005", "user_id": "u217010036"}, "prompt_components": {"gold_output": "Bad\n", "input_to_evaluate": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val s = in.readLine.toCharArray\n val ans = if(s(0) != s(1) && s(1) != s(2) && s(2) != s(3)) \"Goog\" else \"Bad\"\n println(ans)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 186, "cpu_time_ms": 328, "memory_kb": 25500}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s946853124", "group_id": "codeNet:p03000", "input_text": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]) {\n if (args.length > 0 && args(0) == \"TEST\") {\n println(test())\n } else {\n val input = io.Source.stdin.getLines().mkString(\"\\n\")\n println(solve(input).trim())\n }\n }\n\n def solve(input: String): String = {\n val s: Scanner = new Scanner(input)\n val n,x = s.nextInt\n List.fill(n)(s.nextInt).scan(0)(_ + _).count(_ <= x).toString\n }\n\n val tests = List(\n \"\"\"3 6\n |3 4 5\"\"\".stripMargin -> \"\"\"2\"\"\",\n \"\"\"4 9\n |3 3 3 3\"\"\".stripMargin -> \"\"\"4\"\"\"\n )\n\n def test(): String = tests.map { case (i, o) => (i.trim(), o.trim()) }\n .zipWithIndex.map {\n case ((input, outputExpect), i) =>\n val output = solve(input).trim()\n val tnum = i + 1\n s\"test$tnum:\" + (\n if (output == outputExpect) \"Passed\"\n else s\"Failed\\nexpect:\\n$outputExpect\\noutput:\\n$output\")\n }\n .mkString(\"\\n\")\n}", "language": "Scala", "metadata": {"date": 1560813179, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03000.html", "problem_id": "p03000", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03000/input.txt", "sample_output_relpath": "derived/input_output/data/p03000/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03000/Scala/s946853124.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s946853124", "user_id": "u334087399"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]) {\n if (args.length > 0 && args(0) == \"TEST\") {\n println(test())\n } else {\n val input = io.Source.stdin.getLines().mkString(\"\\n\")\n println(solve(input).trim())\n }\n }\n\n def solve(input: String): String = {\n val s: Scanner = new Scanner(input)\n val n,x = s.nextInt\n List.fill(n)(s.nextInt).scan(0)(_ + _).count(_ <= x).toString\n }\n\n val tests = List(\n \"\"\"3 6\n |3 4 5\"\"\".stripMargin -> \"\"\"2\"\"\",\n \"\"\"4 9\n |3 3 3 3\"\"\".stripMargin -> \"\"\"4\"\"\"\n )\n\n def test(): String = tests.map { case (i, o) => (i.trim(), o.trim()) }\n .zipWithIndex.map {\n case ((input, outputExpect), i) =>\n val output = solve(input).trim()\n val tnum = i + 1\n s\"test$tnum:\" + (\n if (output == outputExpect) \"Passed\"\n else s\"Failed\\nexpect:\\n$outputExpect\\noutput:\\n$output\")\n }\n .mkString(\"\\n\")\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA ball will bounce along a number line, making N + 1 bounces. It will make the first bounce at coordinate D_1 = 0, and the i-th bounce (2 \\leq i \\leq N+1) at coordinate D_i = D_{i-1} + L_{i-1}.\n\nHow many times will the ball make a bounce where the coordinate is at most X?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 100\n\n1 \\leq X \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nL_1 L_2 ... L_{N-1} L_N\n\nOutput\n\nPrint the number of times the ball will make a bounce where the coordinate is at most X.\n\nSample Input 1\n\n3 6\n3 4 5\n\nSample Output 1\n\n2\n\nThe ball will make a bounce at the coordinates 0, 3, 7 and 12, among which two are less than or equal to 6.\n\nSample Input 2\n\n4 9\n3 3 3 3\n\nSample Output 2\n\n4\n\nThe ball will make a bounce at the coordinates 0, 3, 6, 9 and 12, among which four are less than or equal to 9.", "sample_input": "3 6\n3 4 5\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03000", "source_text": "Score : 200 points\n\nProblem Statement\n\nA ball will bounce along a number line, making N + 1 bounces. It will make the first bounce at coordinate D_1 = 0, and the i-th bounce (2 \\leq i \\leq N+1) at coordinate D_i = D_{i-1} + L_{i-1}.\n\nHow many times will the ball make a bounce where the coordinate is at most X?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 100\n\n1 \\leq X \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nL_1 L_2 ... L_{N-1} L_N\n\nOutput\n\nPrint the number of times the ball will make a bounce where the coordinate is at most X.\n\nSample Input 1\n\n3 6\n3 4 5\n\nSample Output 1\n\n2\n\nThe ball will make a bounce at the coordinates 0, 3, 7 and 12, among which two are less than or equal to 6.\n\nSample Input 2\n\n4 9\n3 3 3 3\n\nSample Output 2\n\n4\n\nThe ball will make a bounce at the coordinates 0, 3, 6, 9 and 12, among which four are less than or equal to 9.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 923, "cpu_time_ms": 351, "memory_kb": 27320}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s788155506", "group_id": "codeNet:p03000", "input_text": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val n, x = in.nextInt\n\n def count(position: Int, times: Int): Int =\n if (position <= x && times <= n)\n count(position + in.nextInt, times + 1)\n else\n times - 1\n\n val answer = count(0, 1)\n\n println(answer)\n}\n", "language": "Scala", "metadata": {"date": 1560715512, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03000.html", "problem_id": "p03000", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03000/input.txt", "sample_output_relpath": "derived/input_output/data/p03000/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03000/Scala/s788155506.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s788155506", "user_id": "u991539345"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val n, x = in.nextInt\n\n def count(position: Int, times: Int): Int =\n if (position <= x && times <= n)\n count(position + in.nextInt, times + 1)\n else\n times - 1\n\n val answer = count(0, 1)\n\n println(answer)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA ball will bounce along a number line, making N + 1 bounces. It will make the first bounce at coordinate D_1 = 0, and the i-th bounce (2 \\leq i \\leq N+1) at coordinate D_i = D_{i-1} + L_{i-1}.\n\nHow many times will the ball make a bounce where the coordinate is at most X?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 100\n\n1 \\leq X \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nL_1 L_2 ... L_{N-1} L_N\n\nOutput\n\nPrint the number of times the ball will make a bounce where the coordinate is at most X.\n\nSample Input 1\n\n3 6\n3 4 5\n\nSample Output 1\n\n2\n\nThe ball will make a bounce at the coordinates 0, 3, 7 and 12, among which two are less than or equal to 6.\n\nSample Input 2\n\n4 9\n3 3 3 3\n\nSample Output 2\n\n4\n\nThe ball will make a bounce at the coordinates 0, 3, 6, 9 and 12, among which four are less than or equal to 9.", "sample_input": "3 6\n3 4 5\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03000", "source_text": "Score : 200 points\n\nProblem Statement\n\nA ball will bounce along a number line, making N + 1 bounces. It will make the first bounce at coordinate D_1 = 0, and the i-th bounce (2 \\leq i \\leq N+1) at coordinate D_i = D_{i-1} + L_{i-1}.\n\nHow many times will the ball make a bounce where the coordinate is at most X?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 100\n\n1 \\leq X \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nL_1 L_2 ... L_{N-1} L_N\n\nOutput\n\nPrint the number of times the ball will make a bounce where the coordinate is at most X.\n\nSample Input 1\n\n3 6\n3 4 5\n\nSample Output 1\n\n2\n\nThe ball will make a bounce at the coordinates 0, 3, 7 and 12, among which two are less than or equal to 6.\n\nSample Input 2\n\n4 9\n3 3 3 3\n\nSample Output 2\n\n4\n\nThe ball will make a bounce at the coordinates 0, 3, 6, 9 and 12, among which four are less than or equal to 9.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 300, "cpu_time_ms": 348, "memory_kb": 25528}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s310480810", "group_id": "codeNet:p03003", "input_text": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n\n val MOD = 1e9.toLong + 7\n val N, M = in.next().toInt\n val S = new Array[Int](N+1)\n val T = new Array[Int](M+1)\n for (i <- 1 to N)\n S(i) = in.next().toInt\n for (i <- 1 to M)\n T(i) = in.next().toInt\n\n //\n val imos = Array.ofDim[Long](N+1, M+1)\n val dp = Array.ofDim[Long](N+1, M+1)\n for (n <- 1 to N) {\n for (m <- 1 to M) {\n if (S(n) == T(m)) {\n dp(n)(m) = imos(n-1)(m-1) + 1\n dp(n)(m) %= MOD\n }\n\n imos(n)(m) = imos(n-1)(m) + imos(n)(m-1) - imos(n-1)(m-1)\n if (imos(n)(m) < 0)\n imos(n)(m) += MOD\n imos(n)(m) %= MOD\n imos(n)(m) += dp(n)(m)\n imos(n)(m) %= MOD\n }\n }\n\n\n var ans = 0L\n for (n <- 1 to N)\n for (m <- 1 to M) {\n ans += dp(n)(m)\n ans %= MOD\n }\n\n println((ans + 1) % MOD)\n}\n\n\nclass InputReader(stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream))\n private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n", "language": "Scala", "metadata": {"date": 1560743749, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03003.html", "problem_id": "p03003", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03003/input.txt", "sample_output_relpath": "derived/input_output/data/p03003/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03003/Scala/s310480810.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s310480810", "user_id": "u098968285"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n\n val MOD = 1e9.toLong + 7\n val N, M = in.next().toInt\n val S = new Array[Int](N+1)\n val T = new Array[Int](M+1)\n for (i <- 1 to N)\n S(i) = in.next().toInt\n for (i <- 1 to M)\n T(i) = in.next().toInt\n\n //\n val imos = Array.ofDim[Long](N+1, M+1)\n val dp = Array.ofDim[Long](N+1, M+1)\n for (n <- 1 to N) {\n for (m <- 1 to M) {\n if (S(n) == T(m)) {\n dp(n)(m) = imos(n-1)(m-1) + 1\n dp(n)(m) %= MOD\n }\n\n imos(n)(m) = imos(n-1)(m) + imos(n)(m-1) - imos(n-1)(m-1)\n if (imos(n)(m) < 0)\n imos(n)(m) += MOD\n imos(n)(m) %= MOD\n imos(n)(m) += dp(n)(m)\n imos(n)(m) %= MOD\n }\n }\n\n\n var ans = 0L\n for (n <- 1 to N)\n for (m <- 1 to M) {\n ans += dp(n)(m)\n ans %= MOD\n }\n\n println((ans + 1) % MOD)\n}\n\n\nclass InputReader(stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream))\n private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive).\n\nIn how many pairs of a subsequence of S and a subsequence of T do the two subsequences are the same in content?\n\nHere the subsequence of A is a sequence obtained by removing zero or more elements from A and concatenating the remaining elements without changing the order.\n\nFor both S and T, we distinguish two subsequences if the sets of the indices of the removed elements are different, even if the subsequences are the same in content.\n\nSince the answer can be tremendous, print the number modulo 10^9+7.\n\nConstraints\n\n1 \\leq N, M \\leq 2 \\times 10^3\n\nThe length of S is N.\n\nThe length of T is M.\n\n1 \\leq S_i, T_i \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nS_1 S_2 ... S_{N-1} S_{N}\nT_1 T_2 ... T_{M-1} T_{M}\n\nOutput\n\nPrint the number of pairs of a subsequence of S and a subsequence of T such that the subsequences are the same in content, modulo 10^9+7.\n\nSample Input 1\n\n2 2\n1 3\n3 1\n\nSample Output 1\n\n3\n\nS has four subsequences: (), (1), (3), (1, 3).\n\nT has four subsequences: (), (3), (1), (3, 1).\n\nThere are 1 \\times 1 pair of subsequences in which the subsequences are both (), 1 \\times 1 pair of subsequences in which the subsequences are both (1), and 1 \\times 1 pair of subsequences in which the subsequences are both (3), for a total of three pairs.\n\nSample Input 2\n\n2 2\n1 1\n1 1\n\nSample Output 2\n\n6\n\nS has four subsequences: (), (1), (1), (1, 1).\n\nT has four subsequences: (), (1), (1), (1, 1).\n\nThere are 1 \\times 1 pair of subsequences in which the subsequences are both (), 2 \\times 2 pairs of subsequences in which the subsequences are both (1), and 1 \\times 1 pair of subsequences in which the subsequences are both (1,1), for a total of six pairs.\nNote again that we distinguish two subsequences if the sets of the indices of the removed elements are different, even if the subsequences are the same in content.\n\nSample Input 3\n\n4 4\n3 4 5 6\n3 4 5 6\n\nSample Output 3\n\n16\n\nSample Input 4\n\n10 9\n9 6 5 7 5 9 8 5 6 7\n8 6 8 5 5 7 9 9 7\n\nSample Output 4\n\n191\n\nSample Input 5\n\n20 20\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n\nSample Output 5\n\n846527861\n\nBe sure to print the number modulo 10^9+7.", "sample_input": "2 2\n1 3\n3 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03003", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive).\n\nIn how many pairs of a subsequence of S and a subsequence of T do the two subsequences are the same in content?\n\nHere the subsequence of A is a sequence obtained by removing zero or more elements from A and concatenating the remaining elements without changing the order.\n\nFor both S and T, we distinguish two subsequences if the sets of the indices of the removed elements are different, even if the subsequences are the same in content.\n\nSince the answer can be tremendous, print the number modulo 10^9+7.\n\nConstraints\n\n1 \\leq N, M \\leq 2 \\times 10^3\n\nThe length of S is N.\n\nThe length of T is M.\n\n1 \\leq S_i, T_i \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nS_1 S_2 ... S_{N-1} S_{N}\nT_1 T_2 ... T_{M-1} T_{M}\n\nOutput\n\nPrint the number of pairs of a subsequence of S and a subsequence of T such that the subsequences are the same in content, modulo 10^9+7.\n\nSample Input 1\n\n2 2\n1 3\n3 1\n\nSample Output 1\n\n3\n\nS has four subsequences: (), (1), (3), (1, 3).\n\nT has four subsequences: (), (3), (1), (3, 1).\n\nThere are 1 \\times 1 pair of subsequences in which the subsequences are both (), 1 \\times 1 pair of subsequences in which the subsequences are both (1), and 1 \\times 1 pair of subsequences in which the subsequences are both (3), for a total of three pairs.\n\nSample Input 2\n\n2 2\n1 1\n1 1\n\nSample Output 2\n\n6\n\nS has four subsequences: (), (1), (1), (1, 1).\n\nT has four subsequences: (), (1), (1), (1, 1).\n\nThere are 1 \\times 1 pair of subsequences in which the subsequences are both (), 2 \\times 2 pairs of subsequences in which the subsequences are both (1), and 1 \\times 1 pair of subsequences in which the subsequences are both (1,1), for a total of six pairs.\nNote again that we distinguish two subsequences if the sets of the indices of the removed elements are different, even if the subsequences are the same in content.\n\nSample Input 3\n\n4 4\n3 4 5 6\n3 4 5 6\n\nSample Output 3\n\n16\n\nSample Input 4\n\n10 9\n9 6 5 7 5 9 8 5 6 7\n8 6 8 5 5 7 9 9 7\n\nSample Output 4\n\n191\n\nSample Input 5\n\n20 20\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n\nSample Output 5\n\n846527861\n\nBe sure to print the number modulo 10^9+7.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1344, "cpu_time_ms": 769, "memory_kb": 113616}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s593544668", "group_id": "codeNet:p03004", "input_text": "import scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.io.StdIn._\nobject Main extends App {\n val MAX = 200000000.0\n val MIN = -MAX\n val n = readInt()\n val coordinates = mutable.Map[Char, List[Coordinate]]().withDefaultValue(Nil)\n for (_ ← 0 until n) {\n val Array(x, y, d) = readLine.trim.split(' ')\n coordinates(d.head) ::= Coordinate(x.toDouble, y.toDouble)\n }\n val constMinX = List('U', 'D').flatMap(coordinates).minByOption(_.x).map(_.x).getOrElse(MAX)\n val constMaxX = List('U', 'D').flatMap(coordinates).maxByOption(_.x).map(_.x).getOrElse(MIN)\n val constMinY = List('L', 'R').flatMap(coordinates).minByOption(_.y).map(_.y).getOrElse(MAX)\n val constMaxY = List('L', 'R').flatMap(coordinates).maxByOption(_.y).map(_.y).getOrElse(MIN)\n val minUp = coordinates('U').minByOption(_.y).map(_.y).getOrElse(MAX)\n val maxUp = coordinates('U').maxByOption(_.y).map(_.y).getOrElse(MIN)\n val minDown = coordinates('D').minByOption(_.y).map(_.y).getOrElse(MAX)\n val maxDown = coordinates('D').maxByOption(_.y).map(_.y).getOrElse(MIN)\n val minRight = coordinates('R').minByOption(_.x).map(_.x).getOrElse(MAX)\n val maxRight = coordinates('R').maxByOption(_.x).map(_.x).getOrElse(MIN)\n val minLeft = coordinates('L').minByOption(_.x).map(_.x).getOrElse(MAX)\n val maxLeft = coordinates('L').maxByOption(_.x).map(_.x).getOrElse(MIN)\n\n val changeTime = List(0, constMinY - minUp, minDown - constMinY, constMinX - minRight, minLeft - constMinX, constMaxY - maxUp, maxDown - constMaxY, constMaxX - maxRight, maxLeft - constMaxX, (minDown - minUp) / 2, (maxDown - maxUp) / 2, (minLeft - minRight) / 2, (maxLeft - maxRight) / 2).filter(_ >= 0)\n\n println(\n \"%.15f\".format(changeTime.map{t ⇒\n val minX = List(constMinX, minRight + t, minLeft - t).min\n val maxX = List(constMaxX, maxRight + t, maxLeft - t).max\n val minY = List(constMinY, minUp + t, minDown - t).min\n val maxY = List(constMaxY, maxUp + t, maxDown - t).max\n (maxX - minX) * (maxY - minY)\n }.min)\n )\n\n implicit class Scope[T](val receiver: T) extends AnyVal {\n def let[A](@inline func: T ⇒ A): A = func(receiver)\n def tap(@inline func: T ⇒ Unit): T = {\n func(receiver)\n receiver\n }\n }\n implicit class Wrap[T](val receiver: List[T]) extends AnyVal {\n def minByOption[A: Ordering](@inline keySelector: T ⇒ A): Option[T] = {\n receiver match {\n case Nil ⇒ None\n case _ ⇒ Some(receiver.minBy(keySelector))\n }\n }\n def maxByOption[A: Ordering](@inline keySelector: T ⇒ A): Option[T] = {\n receiver match {\n case Nil ⇒ None\n case _ ⇒ Some(receiver.maxBy(keySelector))\n }\n }\n }\n}\ncase class Coordinate(x: Double, y: Double)", "language": "Scala", "metadata": {"date": 1585848743, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03004.html", "problem_id": "p03004", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03004/input.txt", "sample_output_relpath": "derived/input_output/data/p03004/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03004/Scala/s593544668.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s593544668", "user_id": "u419330815"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "import scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.io.StdIn._\nobject Main extends App {\n val MAX = 200000000.0\n val MIN = -MAX\n val n = readInt()\n val coordinates = mutable.Map[Char, List[Coordinate]]().withDefaultValue(Nil)\n for (_ ← 0 until n) {\n val Array(x, y, d) = readLine.trim.split(' ')\n coordinates(d.head) ::= Coordinate(x.toDouble, y.toDouble)\n }\n val constMinX = List('U', 'D').flatMap(coordinates).minByOption(_.x).map(_.x).getOrElse(MAX)\n val constMaxX = List('U', 'D').flatMap(coordinates).maxByOption(_.x).map(_.x).getOrElse(MIN)\n val constMinY = List('L', 'R').flatMap(coordinates).minByOption(_.y).map(_.y).getOrElse(MAX)\n val constMaxY = List('L', 'R').flatMap(coordinates).maxByOption(_.y).map(_.y).getOrElse(MIN)\n val minUp = coordinates('U').minByOption(_.y).map(_.y).getOrElse(MAX)\n val maxUp = coordinates('U').maxByOption(_.y).map(_.y).getOrElse(MIN)\n val minDown = coordinates('D').minByOption(_.y).map(_.y).getOrElse(MAX)\n val maxDown = coordinates('D').maxByOption(_.y).map(_.y).getOrElse(MIN)\n val minRight = coordinates('R').minByOption(_.x).map(_.x).getOrElse(MAX)\n val maxRight = coordinates('R').maxByOption(_.x).map(_.x).getOrElse(MIN)\n val minLeft = coordinates('L').minByOption(_.x).map(_.x).getOrElse(MAX)\n val maxLeft = coordinates('L').maxByOption(_.x).map(_.x).getOrElse(MIN)\n\n val changeTime = List(0, constMinY - minUp, minDown - constMinY, constMinX - minRight, minLeft - constMinX, constMaxY - maxUp, maxDown - constMaxY, constMaxX - maxRight, maxLeft - constMaxX, (minDown - minUp) / 2, (maxDown - maxUp) / 2, (minLeft - minRight) / 2, (maxLeft - maxRight) / 2).filter(_ >= 0)\n\n println(\n \"%.15f\".format(changeTime.map{t ⇒\n val minX = List(constMinX, minRight + t, minLeft - t).min\n val maxX = List(constMaxX, maxRight + t, maxLeft - t).max\n val minY = List(constMinY, minUp + t, minDown - t).min\n val maxY = List(constMaxY, maxUp + t, maxDown - t).max\n (maxX - minX) * (maxY - minY)\n }.min)\n )\n\n implicit class Scope[T](val receiver: T) extends AnyVal {\n def let[A](@inline func: T ⇒ A): A = func(receiver)\n def tap(@inline func: T ⇒ Unit): T = {\n func(receiver)\n receiver\n }\n }\n implicit class Wrap[T](val receiver: List[T]) extends AnyVal {\n def minByOption[A: Ordering](@inline keySelector: T ⇒ A): Option[T] = {\n receiver match {\n case Nil ⇒ None\n case _ ⇒ Some(receiver.minBy(keySelector))\n }\n }\n def maxByOption[A: Ordering](@inline keySelector: T ⇒ A): Option[T] = {\n receiver match {\n case Nil ⇒ None\n case _ ⇒ Some(receiver.maxBy(keySelector))\n }\n }\n }\n}\ncase class Coordinate(x: Double, y: Double)", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere are N points in a two-dimensional plane. The initial coordinates of the i-th point are (x_i, y_i). Now, each point starts moving at a speed of 1 per second, in a direction parallel to the x- or y- axis. You are given a character d_i that represents the specific direction in which the i-th point moves, as follows:\n\nIf d_i = R, the i-th point moves in the positive x direction;\n\nIf d_i = L, the i-th point moves in the negative x direction;\n\nIf d_i = U, the i-th point moves in the positive y direction;\n\nIf d_i = D, the i-th point moves in the negative y direction.\n\nYou can stop all the points at some moment of your choice after they start moving (including the moment they start moving).\nThen, let x_{max} and x_{min} be the maximum and minimum among the x-coordinates of the N points, respectively. Similarly, let y_{max} and y_{min} be the maximum and minimum among the y-coordinates of the N points, respectively.\n\nFind the minimum possible value of (x_{max} - x_{min}) \\times (y_{max} - y_{min}) and print it.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n-10^8 \\leq x_i,\\ y_i \\leq 10^8\n\nx_i and y_i are integers.\n\nd_i is R, L, U, or D.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1 d_1\nx_2 y_2 d_2\n.\n.\n.\nx_N y_N d_N\n\nOutput\n\nPrint the minimum possible value of (x_{max} - x_{min}) \\times (y_{max} - y_{min}).\n\nThe output will be considered correct when its absolute or relative error from the judge's output is at most 10^{-9}.\n\nSample Input 1\n\n2\n0 3 D\n3 0 L\n\nSample Output 1\n\n0\n\nAfter three seconds, the two points will meet at the origin. The value in question will be 0 at that moment.\n\nSample Input 2\n\n5\n-7 -10 U\n7 -6 U\n-8 7 D\n-3 3 D\n0 -6 R\n\nSample Output 2\n\n97.5\n\nThe answer may not be an integer.\n\nSample Input 3\n\n20\n6 -10 R\n-4 -9 U\n9 6 D\n-3 -2 R\n0 7 D\n4 5 D\n10 -10 U\n-1 -8 U\n10 -6 D\n8 -5 U\n6 4 D\n0 3 D\n7 9 R\n9 -4 R\n3 10 D\n1 9 U\n1 -6 U\n9 -8 R\n6 7 D\n7 -3 D\n\nSample Output 3\n\n273", "sample_input": "2\n0 3 D\n3 0 L\n"}, "reference_outputs": ["0\n"], "source_document_id": "p03004", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere are N points in a two-dimensional plane. The initial coordinates of the i-th point are (x_i, y_i). Now, each point starts moving at a speed of 1 per second, in a direction parallel to the x- or y- axis. You are given a character d_i that represents the specific direction in which the i-th point moves, as follows:\n\nIf d_i = R, the i-th point moves in the positive x direction;\n\nIf d_i = L, the i-th point moves in the negative x direction;\n\nIf d_i = U, the i-th point moves in the positive y direction;\n\nIf d_i = D, the i-th point moves in the negative y direction.\n\nYou can stop all the points at some moment of your choice after they start moving (including the moment they start moving).\nThen, let x_{max} and x_{min} be the maximum and minimum among the x-coordinates of the N points, respectively. Similarly, let y_{max} and y_{min} be the maximum and minimum among the y-coordinates of the N points, respectively.\n\nFind the minimum possible value of (x_{max} - x_{min}) \\times (y_{max} - y_{min}) and print it.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n-10^8 \\leq x_i,\\ y_i \\leq 10^8\n\nx_i and y_i are integers.\n\nd_i is R, L, U, or D.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1 d_1\nx_2 y_2 d_2\n.\n.\n.\nx_N y_N d_N\n\nOutput\n\nPrint the minimum possible value of (x_{max} - x_{min}) \\times (y_{max} - y_{min}).\n\nThe output will be considered correct when its absolute or relative error from the judge's output is at most 10^{-9}.\n\nSample Input 1\n\n2\n0 3 D\n3 0 L\n\nSample Output 1\n\n0\n\nAfter three seconds, the two points will meet at the origin. The value in question will be 0 at that moment.\n\nSample Input 2\n\n5\n-7 -10 U\n7 -6 U\n-8 7 D\n-3 3 D\n0 -6 R\n\nSample Output 2\n\n97.5\n\nThe answer may not be an integer.\n\nSample Input 3\n\n20\n6 -10 R\n-4 -9 U\n9 6 D\n-3 -2 R\n0 7 D\n4 5 D\n10 -10 U\n-1 -8 U\n10 -6 D\n8 -5 U\n6 4 D\n0 3 D\n7 9 R\n9 -4 R\n3 10 D\n1 9 U\n1 -6 U\n9 -8 R\n6 7 D\n7 -3 D\n\nSample Output 3\n\n273", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2740, "cpu_time_ms": 1180, "memory_kb": 78684}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s432552410", "group_id": "codeNet:p03004", "input_text": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\nimport scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}\n\ncase class Pos(x: Long, y: Long, dir: String) {\n\n // calc (x, y)\n def calc(t: Double): (Double, Double) = {\n dir match {\n case \"R\" => (x+t, y)\n case \"L\" => (x-t, y)\n case \"U\" => (x, y+t)\n case \"D\" => (x, y-t)\n }\n }\n}\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val N = in.next().toInt\n val p = new Array[Pos](N+1)\n\n for (i <- 1 to N) {\n val x, y = in.next().toLong\n val d = in.next()\n\n p(i) = Pos(x, y, d)\n }\n\n\n //\n def check(n: Double): Double = {\n import Math.{max, min}\n\n var xmax = -2e8\n var ymax = -2e8\n var xmin = 2e8\n var ymin = 2e8\n\n for (i <- 1 to N) {\n val (x, y) = p(i).calc(n)\n\n xmax = max(xmax, x)\n ymax = max(ymax, y)\n xmin = min(xmin, x)\n ymin = min(ymin, y)\n }\n\n (xmax - xmin) * (ymax - ymin)\n }\n\n // 下に凸のグラフの最小値\n def ternarySearch(small: Double, big: Double): Double = {\n val END = 5e-3 // 5e-9\n val VOL = 1e-3 // 1e-9 // (END / 2) より小さい\n def func(small: Double, big: Double): Double = {\n val midl = (big + small) / 2\n val midr = midl + VOL\n if (big - small < END) big\n else {\n if (check(midl) >= check(midr))\n func(midl, big)\n else\n func(small, midr)\n }\n }\n func(small, big)\n }\n\n val time = ternarySearch(0, 1e9)\n val ans = check((time * 10).round / 10.0)\n\n println(ans)\n}\n\nobject Sub {\n def print2DimArray[A](mat: Array[Array[A]]): Unit = {\n mat.foreach(lin => println(lin.deep))\n }\n}\n\nclass InputReader(stream: InputStream) {\n private[this] val reader = new BufferedReader(new InputStreamReader(stream))\n private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n", "language": "Scala", "metadata": {"date": 1575952881, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03004.html", "problem_id": "p03004", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03004/input.txt", "sample_output_relpath": "derived/input_output/data/p03004/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03004/Scala/s432552410.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s432552410", "user_id": "u098968285"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\nimport scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}\n\ncase class Pos(x: Long, y: Long, dir: String) {\n\n // calc (x, y)\n def calc(t: Double): (Double, Double) = {\n dir match {\n case \"R\" => (x+t, y)\n case \"L\" => (x-t, y)\n case \"U\" => (x, y+t)\n case \"D\" => (x, y-t)\n }\n }\n}\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val N = in.next().toInt\n val p = new Array[Pos](N+1)\n\n for (i <- 1 to N) {\n val x, y = in.next().toLong\n val d = in.next()\n\n p(i) = Pos(x, y, d)\n }\n\n\n //\n def check(n: Double): Double = {\n import Math.{max, min}\n\n var xmax = -2e8\n var ymax = -2e8\n var xmin = 2e8\n var ymin = 2e8\n\n for (i <- 1 to N) {\n val (x, y) = p(i).calc(n)\n\n xmax = max(xmax, x)\n ymax = max(ymax, y)\n xmin = min(xmin, x)\n ymin = min(ymin, y)\n }\n\n (xmax - xmin) * (ymax - ymin)\n }\n\n // 下に凸のグラフの最小値\n def ternarySearch(small: Double, big: Double): Double = {\n val END = 5e-3 // 5e-9\n val VOL = 1e-3 // 1e-9 // (END / 2) より小さい\n def func(small: Double, big: Double): Double = {\n val midl = (big + small) / 2\n val midr = midl + VOL\n if (big - small < END) big\n else {\n if (check(midl) >= check(midr))\n func(midl, big)\n else\n func(small, midr)\n }\n }\n func(small, big)\n }\n\n val time = ternarySearch(0, 1e9)\n val ans = check((time * 10).round / 10.0)\n\n println(ans)\n}\n\nobject Sub {\n def print2DimArray[A](mat: Array[Array[A]]): Unit = {\n mat.foreach(lin => println(lin.deep))\n }\n}\n\nclass InputReader(stream: InputStream) {\n private[this] val reader = new BufferedReader(new InputStreamReader(stream))\n private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere are N points in a two-dimensional plane. The initial coordinates of the i-th point are (x_i, y_i). Now, each point starts moving at a speed of 1 per second, in a direction parallel to the x- or y- axis. You are given a character d_i that represents the specific direction in which the i-th point moves, as follows:\n\nIf d_i = R, the i-th point moves in the positive x direction;\n\nIf d_i = L, the i-th point moves in the negative x direction;\n\nIf d_i = U, the i-th point moves in the positive y direction;\n\nIf d_i = D, the i-th point moves in the negative y direction.\n\nYou can stop all the points at some moment of your choice after they start moving (including the moment they start moving).\nThen, let x_{max} and x_{min} be the maximum and minimum among the x-coordinates of the N points, respectively. Similarly, let y_{max} and y_{min} be the maximum and minimum among the y-coordinates of the N points, respectively.\n\nFind the minimum possible value of (x_{max} - x_{min}) \\times (y_{max} - y_{min}) and print it.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n-10^8 \\leq x_i,\\ y_i \\leq 10^8\n\nx_i and y_i are integers.\n\nd_i is R, L, U, or D.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1 d_1\nx_2 y_2 d_2\n.\n.\n.\nx_N y_N d_N\n\nOutput\n\nPrint the minimum possible value of (x_{max} - x_{min}) \\times (y_{max} - y_{min}).\n\nThe output will be considered correct when its absolute or relative error from the judge's output is at most 10^{-9}.\n\nSample Input 1\n\n2\n0 3 D\n3 0 L\n\nSample Output 1\n\n0\n\nAfter three seconds, the two points will meet at the origin. The value in question will be 0 at that moment.\n\nSample Input 2\n\n5\n-7 -10 U\n7 -6 U\n-8 7 D\n-3 3 D\n0 -6 R\n\nSample Output 2\n\n97.5\n\nThe answer may not be an integer.\n\nSample Input 3\n\n20\n6 -10 R\n-4 -9 U\n9 6 D\n-3 -2 R\n0 7 D\n4 5 D\n10 -10 U\n-1 -8 U\n10 -6 D\n8 -5 U\n6 4 D\n0 3 D\n7 9 R\n9 -4 R\n3 10 D\n1 9 U\n1 -6 U\n9 -8 R\n6 7 D\n7 -3 D\n\nSample Output 3\n\n273", "sample_input": "2\n0 3 D\n3 0 L\n"}, "reference_outputs": ["0\n"], "source_document_id": "p03004", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere are N points in a two-dimensional plane. The initial coordinates of the i-th point are (x_i, y_i). Now, each point starts moving at a speed of 1 per second, in a direction parallel to the x- or y- axis. You are given a character d_i that represents the specific direction in which the i-th point moves, as follows:\n\nIf d_i = R, the i-th point moves in the positive x direction;\n\nIf d_i = L, the i-th point moves in the negative x direction;\n\nIf d_i = U, the i-th point moves in the positive y direction;\n\nIf d_i = D, the i-th point moves in the negative y direction.\n\nYou can stop all the points at some moment of your choice after they start moving (including the moment they start moving).\nThen, let x_{max} and x_{min} be the maximum and minimum among the x-coordinates of the N points, respectively. Similarly, let y_{max} and y_{min} be the maximum and minimum among the y-coordinates of the N points, respectively.\n\nFind the minimum possible value of (x_{max} - x_{min}) \\times (y_{max} - y_{min}) and print it.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n-10^8 \\leq x_i,\\ y_i \\leq 10^8\n\nx_i and y_i are integers.\n\nd_i is R, L, U, or D.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1 d_1\nx_2 y_2 d_2\n.\n.\n.\nx_N y_N d_N\n\nOutput\n\nPrint the minimum possible value of (x_{max} - x_{min}) \\times (y_{max} - y_{min}).\n\nThe output will be considered correct when its absolute or relative error from the judge's output is at most 10^{-9}.\n\nSample Input 1\n\n2\n0 3 D\n3 0 L\n\nSample Output 1\n\n0\n\nAfter three seconds, the two points will meet at the origin. The value in question will be 0 at that moment.\n\nSample Input 2\n\n5\n-7 -10 U\n7 -6 U\n-8 7 D\n-3 3 D\n0 -6 R\n\nSample Output 2\n\n97.5\n\nThe answer may not be an integer.\n\nSample Input 3\n\n20\n6 -10 R\n-4 -9 U\n9 6 D\n-3 -2 R\n0 7 D\n4 5 D\n10 -10 U\n-1 -8 U\n10 -6 D\n8 -5 U\n6 4 D\n0 3 D\n7 9 R\n9 -4 R\n3 10 D\n1 9 U\n1 -6 U\n9 -8 R\n6 7 D\n7 -3 D\n\nSample Output 3\n\n273", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2120, "cpu_time_ms": 867, "memory_kb": 116496}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s541059773", "group_id": "codeNet:p03006", "input_text": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n // p, q の重複の数が一番多い時、その重複の個数だけコスト0になる\n val N = sc.nextInt()\n val P: IndexedSeq[(Long, Long)] =\n (0 until N) map { i =>\n val x, y = sc.nextLong()\n (x, y)\n }\n\n val (_, cost0) = P.sliding(2).map { slide =>\n val bp = slide(0)\n val np = slide(1)\n val (bx, by) = bp\n val (nx, ny) = np\n (nx - bx, ny - by)\n }. toList. groupBy(identity). mapValues(_.size). maxBy(_._2)\n\n println(N - cost0)\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1561175377, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s541059773.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s541059773", "user_id": "u891387249"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n // p, q の重複の数が一番多い時、その重複の個数だけコスト0になる\n val N = sc.nextInt()\n val P: IndexedSeq[(Long, Long)] =\n (0 until N) map { i =>\n val x, y = sc.nextLong()\n (x, y)\n }\n\n val (_, cost0) = P.sliding(2).map { slide =>\n val bp = slide(0)\n val np = slide(1)\n val (bx, by) = bp\n val (nx, ny) = np\n (nx - bx, ny - by)\n }. toList. groupBy(identity). mapValues(_.size). maxBy(_._2)\n\n println(N - cost0)\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 614, "cpu_time_ms": 362, "memory_kb": 27200}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s964878529", "group_id": "codeNet:p03006", "input_text": "import scala.io.{StdIn => in}\nimport scala.collection.{mutable => mu}\n\nobject Main extends App {\n import MapHelper._\n\n val n = in.readInt\n val pb = Iterator.continually(in.readLine)\n .take(n)\n .map(_.split(\" \").map(_.toLong))\n .toArray\n\n val px = pb.sortWith((x, y) => {\n if(x(0) != y(0)) {\n x(0) > y(0)\n } else {\n x(1) > y(1)\n }\n })\n val py = pb.sortWith((x, y) => {\n if(x(1) != y(1)) {\n x(1) > y(1)\n } else {\n x(0) > y(0)\n }\n })\n val mapX = mu.HashMap.empty[(Long,Long),Long]\n val mapY = mu.HashMap.empty[(Long,Long),Long]\n\n for(i <- 0 until n-1) {\n val x = px(i)(0) - px(i+1)(0)\n val y = px(i)(1) - px(i+1)(1)\n mapX.addOrUpdate((x,y),1)\n }\n val mX = if(mapX.isEmpty) 0 else mapX.maxBy(m => m._2)._2\n // println(mX)\n for(i <- 0 until n-1) {\n val x = py(i)(0) - py(i+1)(0)\n val y = py(i)(1) - py(i+1)(1)\n mapY.addOrUpdate((x,y),1)\n }\n val mY = if(mapY.isEmpty) 0 else mapY.maxBy(m => m._2)._2\n // println(mY)\n\n val t = mX max mY\n\n val ans = n - t\n println(ans)\n\n object MapHelper {\n implicit class AddOrUpdate[A](map:mu.HashMap[(Long,Long),Long]) {\n def addOrUpdate(key:(Long,Long), value:Long):mu.HashMap[(Long,Long),Long] =\n {\n if(map.contains(key)) map(key) += value\n else map += (key -> value)\n map\n }\n }\n }\n}", "language": "Scala", "metadata": {"date": 1560657801, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s964878529.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s964878529", "user_id": "u217010036"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import scala.io.{StdIn => in}\nimport scala.collection.{mutable => mu}\n\nobject Main extends App {\n import MapHelper._\n\n val n = in.readInt\n val pb = Iterator.continually(in.readLine)\n .take(n)\n .map(_.split(\" \").map(_.toLong))\n .toArray\n\n val px = pb.sortWith((x, y) => {\n if(x(0) != y(0)) {\n x(0) > y(0)\n } else {\n x(1) > y(1)\n }\n })\n val py = pb.sortWith((x, y) => {\n if(x(1) != y(1)) {\n x(1) > y(1)\n } else {\n x(0) > y(0)\n }\n })\n val mapX = mu.HashMap.empty[(Long,Long),Long]\n val mapY = mu.HashMap.empty[(Long,Long),Long]\n\n for(i <- 0 until n-1) {\n val x = px(i)(0) - px(i+1)(0)\n val y = px(i)(1) - px(i+1)(1)\n mapX.addOrUpdate((x,y),1)\n }\n val mX = if(mapX.isEmpty) 0 else mapX.maxBy(m => m._2)._2\n // println(mX)\n for(i <- 0 until n-1) {\n val x = py(i)(0) - py(i+1)(0)\n val y = py(i)(1) - py(i+1)(1)\n mapY.addOrUpdate((x,y),1)\n }\n val mY = if(mapY.isEmpty) 0 else mapY.maxBy(m => m._2)._2\n // println(mY)\n\n val t = mX max mY\n\n val ans = n - t\n println(ans)\n\n object MapHelper {\n implicit class AddOrUpdate[A](map:mu.HashMap[(Long,Long),Long]) {\n def addOrUpdate(key:(Long,Long), value:Long):mu.HashMap[(Long,Long),Long] =\n {\n if(map.contains(key)) map(key) += value\n else map += (key -> value)\n map\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 336, "memory_kb": 27184}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s425338825", "group_id": "codeNet:p03011", "input_text": "object Main{\n\tdef main(args:Array[String]){\n\t\tval s = new java.util.Scanner(System.in)\n\t\tval a,b,c=s.nextInt\n\t\tprintln(math.min(a+b,math.min(b+c,c+a)))\n\t}\n}\n", "language": "Scala", "metadata": {"date": 1560128515, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03011.html", "problem_id": "p03011", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03011/input.txt", "sample_output_relpath": "derived/input_output/data/p03011/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03011/Scala/s425338825.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s425338825", "user_id": "u059234158"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "object Main{\n\tdef main(args:Array[String]){\n\t\tval s = new java.util.Scanner(System.in)\n\t\tval a,b,c=s.nextInt\n\t\tprintln(math.min(a+b,math.min(b+c,c+a)))\n\t}\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are three airports A, B and C, and flights between each pair of airports in both directions.\n\nA one-way flight between airports A and B takes P hours, a one-way flight between airports B and C takes Q hours, and a one-way flight between airports C and A takes R hours.\n\nConsider a route where we start at one of the airports, fly to another airport and then fly to the other airport.\n\nWhat is the minimum possible sum of the flight times?\n\nConstraints\n\n1 \\leq P,Q,R \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nP Q R\n\nOutput\n\nPrint the minimum possible sum of the flight times.\n\nSample Input 1\n\n1 3 4\n\nSample Output 1\n\n4\n\nThe sum of the flight times in the route A \\rightarrow B \\rightarrow C: 1 + 3 = 4 hours\n\nThe sum of the flight times in the route A \\rightarrow C \\rightarrow C: 4 + 3 = 7 hours\n\nThe sum of the flight times in the route B \\rightarrow A \\rightarrow C: 1 + 4 = 5 hours\n\nThe sum of the flight times in the route B \\rightarrow C \\rightarrow A: 3 + 4 = 7 hours\n\nThe sum of the flight times in the route C \\rightarrow A \\rightarrow B: 4 + 1 = 5 hours\n\nThe sum of the flight times in the route C \\rightarrow B \\rightarrow A: 3 + 1 = 4 hours\n\nThe minimum of these is 4 hours.\n\nSample Input 2\n\n3 2 3\n\nSample Output 2\n\n5", "sample_input": "1 3 4\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03011", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are three airports A, B and C, and flights between each pair of airports in both directions.\n\nA one-way flight between airports A and B takes P hours, a one-way flight between airports B and C takes Q hours, and a one-way flight between airports C and A takes R hours.\n\nConsider a route where we start at one of the airports, fly to another airport and then fly to the other airport.\n\nWhat is the minimum possible sum of the flight times?\n\nConstraints\n\n1 \\leq P,Q,R \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nP Q R\n\nOutput\n\nPrint the minimum possible sum of the flight times.\n\nSample Input 1\n\n1 3 4\n\nSample Output 1\n\n4\n\nThe sum of the flight times in the route A \\rightarrow B \\rightarrow C: 1 + 3 = 4 hours\n\nThe sum of the flight times in the route A \\rightarrow C \\rightarrow C: 4 + 3 = 7 hours\n\nThe sum of the flight times in the route B \\rightarrow A \\rightarrow C: 1 + 4 = 5 hours\n\nThe sum of the flight times in the route B \\rightarrow C \\rightarrow A: 3 + 4 = 7 hours\n\nThe sum of the flight times in the route C \\rightarrow A \\rightarrow B: 4 + 1 = 5 hours\n\nThe sum of the flight times in the route C \\rightarrow B \\rightarrow A: 3 + 1 = 4 hours\n\nThe minimum of these is 4 hours.\n\nSample Input 2\n\n3 2 3\n\nSample Output 2\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 350, "memory_kb": 25892}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s943808846", "group_id": "codeNet:p03013", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n solve\n }\n\n def solve(): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n, m = sc.nextInt\n val stairs = Array.fill[Boolean](n + 1)(true)\n for (i <- 0 until m) {\n val a = sc.nextInt\n stairs(a) = false\n }\n\n val mod = 1000000007\n val dp = Array.fill[Int](n + 1)(0)\n dp(0) = 1\n for (i <- 0 to n) {\n for (j <- 1 to 2) {\n val next = i + j\n if (next <= n && stairs(next) == true) {\n dp(next) += dp(i)\n dp(next) = dp(next) % mod\n }\n }\n\n }\n println(dp(n))\n }\n}\n", "language": "Scala", "metadata": {"date": 1580180986, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03013.html", "problem_id": "p03013", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03013/input.txt", "sample_output_relpath": "derived/input_output/data/p03013/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03013/Scala/s943808846.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s943808846", "user_id": "u433254839"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n solve\n }\n\n def solve(): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n, m = sc.nextInt\n val stairs = Array.fill[Boolean](n + 1)(true)\n for (i <- 0 until m) {\n val a = sc.nextInt\n stairs(a) = false\n }\n\n val mod = 1000000007\n val dp = Array.fill[Int](n + 1)(0)\n dp(0) = 1\n for (i <- 0 to n) {\n for (j <- 1 to 2) {\n val next = i + j\n if (next <= n && stairs(next) == true) {\n dp(next) += dp(i)\n dp(next) = dp(next) % mod\n }\n }\n\n }\n println(dp(n))\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step.\nHe can climb up one or two steps at a time.\n\nHowever, the treads of the a_1-th, a_2-th, a_3-th, \\ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.\n\nHow many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps?\nFind the count modulo 1\\ 000\\ 000\\ 007.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq N-1\n\n1 \\leq a_1 < a_2 < ... < a_M \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1\na_2\n.\n.\n.\na_M\n\nOutput\n\nPrint the number of ways to climb up the stairs under the condition, modulo 1\\ 000\\ 000\\ 007.\n\nSample Input 1\n\n6 1\n3\n\nSample Output 1\n\n4\n\nThere are four ways to climb up the stairs, as follows:\n\n0 \\to 1 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 1 \\to 2 \\to 4 \\to 6\n\n0 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 2 \\to 4 \\to 6\n\nSample Input 2\n\n10 2\n4\n5\n\nSample Output 2\n\n0\n\nThere may be no way to climb up the stairs without setting foot on the broken steps.\n\nSample Input 3\n\n100 5\n1\n23\n45\n67\n89\n\nSample Output 3\n\n608200469\n\nBe sure to print the count modulo 1\\ 000\\ 000\\ 007.", "sample_input": "6 1\n3\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03013", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step.\nHe can climb up one or two steps at a time.\n\nHowever, the treads of the a_1-th, a_2-th, a_3-th, \\ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.\n\nHow many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps?\nFind the count modulo 1\\ 000\\ 000\\ 007.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq N-1\n\n1 \\leq a_1 < a_2 < ... < a_M \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1\na_2\n.\n.\n.\na_M\n\nOutput\n\nPrint the number of ways to climb up the stairs under the condition, modulo 1\\ 000\\ 000\\ 007.\n\nSample Input 1\n\n6 1\n3\n\nSample Output 1\n\n4\n\nThere are four ways to climb up the stairs, as follows:\n\n0 \\to 1 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 1 \\to 2 \\to 4 \\to 6\n\n0 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 2 \\to 4 \\to 6\n\nSample Input 2\n\n10 2\n4\n5\n\nSample Output 2\n\n0\n\nThere may be no way to climb up the stairs without setting foot on the broken steps.\n\nSample Input 3\n\n100 5\n1\n23\n45\n67\n89\n\nSample Output 3\n\n608200469\n\nBe sure to print the count modulo 1\\ 000\\ 000\\ 007.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 736, "memory_kb": 51848}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s436129091", "group_id": "codeNet:p03013", "input_text": "import java.util.Scanner\n\nobject MyMath {\n\n def mpow(m: Long)(b: Long, e: Long): Long = {\n def doMpow(r: Long, b: Long, e: Long): Long = {\n if (e == 0) r\n else {\n val r1 = if ((e & 1) == 1) (r * b) % m else r\n doMpow(r1, (b * b) % m, e >> 1)\n }\n }\n doMpow(1, b, e)\n }\n\n def mfact(m: Long)(n: Long, nend: Long = 1): Long = {\n def doMfact(n: Long, r: Long): Long = {\n if (n < nend) r\n else doMfact(n - 1, (r * n) % m)\n }\n doMfact(n, 1)\n }\n\n def mconb(m: Long)(n: Long, k: Long): Long = {\n def pow: (Long, Long) => Long = mpow(m)\n def fact: (Long, Long) => Long = mfact(m)\n\n (fact(n, n - k + 1) * pow(fact(k, 1), m - 2)) % m\n }\n\n}\n\nobject Main {\n def main(args: Array[String]) {\n if (args.length > 0 && args(0) == \"TEST\") {\n println(test())\n } else {\n val input = io.Source.stdin.getLines().mkString(\"\\n\")\n println(solve(input).trim())\n }\n }\n\n val mod = 1000000007L\n def comb: (Long, Long) => Long = MyMath.mconb(mod)\n\n def calcSteps(stairs: Long, twoSteps: Long): Long = comb(stairs - twoSteps, twoSteps)\n def calcPatterns(stairs: Long): Long = {\n if (stairs < 0) 0\n else {\n var sum: Long = 0\n (0L to stairs / 2).foreach(twoSteps => sum = (sum + calcSteps(stairs, twoSteps)) % mod)\n sum\n }\n }\n\n def solve(input: String): String = {\n val s: Scanner = new Scanner(input)\n val n, m = s.nextInt\n var aprev = -1L\n var p = 1L\n var a = 0L\n for (_ <- 1 to m) {\n a = s.nextInt\n p = (p * calcPatterns(a - 2 - aprev)) % mod\n aprev = a\n }\n p = (p * calcPatterns((n + 1) - 2 - aprev)) % mod\n p.toString\n }\n\n val tests = List(\n \"\"\"6 1\n |3\n \"\"\".stripMargin -> \"\"\"4\"\"\",\n \"\"\"10 2\n |4\n |5\n \"\"\".stripMargin -> \"\"\"0\"\"\",\n \"\"\"100 5\n |1\n |23\n |45\n |67\n |89\n \"\"\".stripMargin -> \"\"\"608200469\"\"\"\n )\n\n def test(): String = tests.map { case (i, o) => (i.trim(), o.trim()) }\n .zipWithIndex.map {\n case ((input, outputExpect), i) =>\n val output = solve(input).trim()\n val tnum = i + 1\n s\"test$tnum:\" + (\n if (output == outputExpect) \"Passed\"\n else s\"Failed\\nexpect:\\n$outputExpect\\noutput:\\n$output\")\n }\n .mkString(\"\\n\")\n}", "language": "Scala", "metadata": {"date": 1560311562, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03013.html", "problem_id": "p03013", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03013/input.txt", "sample_output_relpath": "derived/input_output/data/p03013/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03013/Scala/s436129091.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s436129091", "user_id": "u334087399"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.Scanner\n\nobject MyMath {\n\n def mpow(m: Long)(b: Long, e: Long): Long = {\n def doMpow(r: Long, b: Long, e: Long): Long = {\n if (e == 0) r\n else {\n val r1 = if ((e & 1) == 1) (r * b) % m else r\n doMpow(r1, (b * b) % m, e >> 1)\n }\n }\n doMpow(1, b, e)\n }\n\n def mfact(m: Long)(n: Long, nend: Long = 1): Long = {\n def doMfact(n: Long, r: Long): Long = {\n if (n < nend) r\n else doMfact(n - 1, (r * n) % m)\n }\n doMfact(n, 1)\n }\n\n def mconb(m: Long)(n: Long, k: Long): Long = {\n def pow: (Long, Long) => Long = mpow(m)\n def fact: (Long, Long) => Long = mfact(m)\n\n (fact(n, n - k + 1) * pow(fact(k, 1), m - 2)) % m\n }\n\n}\n\nobject Main {\n def main(args: Array[String]) {\n if (args.length > 0 && args(0) == \"TEST\") {\n println(test())\n } else {\n val input = io.Source.stdin.getLines().mkString(\"\\n\")\n println(solve(input).trim())\n }\n }\n\n val mod = 1000000007L\n def comb: (Long, Long) => Long = MyMath.mconb(mod)\n\n def calcSteps(stairs: Long, twoSteps: Long): Long = comb(stairs - twoSteps, twoSteps)\n def calcPatterns(stairs: Long): Long = {\n if (stairs < 0) 0\n else {\n var sum: Long = 0\n (0L to stairs / 2).foreach(twoSteps => sum = (sum + calcSteps(stairs, twoSteps)) % mod)\n sum\n }\n }\n\n def solve(input: String): String = {\n val s: Scanner = new Scanner(input)\n val n, m = s.nextInt\n var aprev = -1L\n var p = 1L\n var a = 0L\n for (_ <- 1 to m) {\n a = s.nextInt\n p = (p * calcPatterns(a - 2 - aprev)) % mod\n aprev = a\n }\n p = (p * calcPatterns((n + 1) - 2 - aprev)) % mod\n p.toString\n }\n\n val tests = List(\n \"\"\"6 1\n |3\n \"\"\".stripMargin -> \"\"\"4\"\"\",\n \"\"\"10 2\n |4\n |5\n \"\"\".stripMargin -> \"\"\"0\"\"\",\n \"\"\"100 5\n |1\n |23\n |45\n |67\n |89\n \"\"\".stripMargin -> \"\"\"608200469\"\"\"\n )\n\n def test(): String = tests.map { case (i, o) => (i.trim(), o.trim()) }\n .zipWithIndex.map {\n case ((input, outputExpect), i) =>\n val output = solve(input).trim()\n val tnum = i + 1\n s\"test$tnum:\" + (\n if (output == outputExpect) \"Passed\"\n else s\"Failed\\nexpect:\\n$outputExpect\\noutput:\\n$output\")\n }\n .mkString(\"\\n\")\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step.\nHe can climb up one or two steps at a time.\n\nHowever, the treads of the a_1-th, a_2-th, a_3-th, \\ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.\n\nHow many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps?\nFind the count modulo 1\\ 000\\ 000\\ 007.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq N-1\n\n1 \\leq a_1 < a_2 < ... < a_M \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1\na_2\n.\n.\n.\na_M\n\nOutput\n\nPrint the number of ways to climb up the stairs under the condition, modulo 1\\ 000\\ 000\\ 007.\n\nSample Input 1\n\n6 1\n3\n\nSample Output 1\n\n4\n\nThere are four ways to climb up the stairs, as follows:\n\n0 \\to 1 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 1 \\to 2 \\to 4 \\to 6\n\n0 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 2 \\to 4 \\to 6\n\nSample Input 2\n\n10 2\n4\n5\n\nSample Output 2\n\n0\n\nThere may be no way to climb up the stairs without setting foot on the broken steps.\n\nSample Input 3\n\n100 5\n1\n23\n45\n67\n89\n\nSample Output 3\n\n608200469\n\nBe sure to print the count modulo 1\\ 000\\ 000\\ 007.", "sample_input": "6 1\n3\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03013", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step.\nHe can climb up one or two steps at a time.\n\nHowever, the treads of the a_1-th, a_2-th, a_3-th, \\ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.\n\nHow many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps?\nFind the count modulo 1\\ 000\\ 000\\ 007.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq N-1\n\n1 \\leq a_1 < a_2 < ... < a_M \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1\na_2\n.\n.\n.\na_M\n\nOutput\n\nPrint the number of ways to climb up the stairs under the condition, modulo 1\\ 000\\ 000\\ 007.\n\nSample Input 1\n\n6 1\n3\n\nSample Output 1\n\n4\n\nThere are four ways to climb up the stairs, as follows:\n\n0 \\to 1 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 1 \\to 2 \\to 4 \\to 6\n\n0 \\to 2 \\to 4 \\to 5 \\to 6\n\n0 \\to 2 \\to 4 \\to 6\n\nSample Input 2\n\n10 2\n4\n5\n\nSample Output 2\n\n0\n\nThere may be no way to climb up the stairs without setting foot on the broken steps.\n\nSample Input 3\n\n100 5\n1\n23\n45\n67\n89\n\nSample Output 3\n\n608200469\n\nBe sure to print the count modulo 1\\ 000\\ 000\\ 007.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2261, "cpu_time_ms": 2111, "memory_kb": 55356}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s580604310", "group_id": "codeNet:p03014", "input_text": "object Main {\n\n object Scanner {\n private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0\n @inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126\n @inline private def hasNextByte(): Boolean =\n if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else { true }\n @inline private def hasNext(): Boolean = {\n while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1\n hasNextByte()\n }\n @inline private def readByte(): Byte =\n if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else { -1 }\n def next(): String = {\n if(!hasNext()) ???\n val sb = new StringBuilder; var b = readByte()\n while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }\n sb.toString\n }\n def nextInt(): Int = {\n val n = nextLong()\n if (n < Int.MinValue || Int.MaxValue < n) ???\n n.toInt\n }\n def nextLong(): Long = {\n if(!hasNext()) ???\n var minus = false; var b = readByte()\n if (b == '-') { minus = true; b = readByte() }\n def go (b: Byte, n: Long = 0): Long =\n if ('0' <= b && b <= '9') { go(readByte(), n * 10 + b - '0') }\n else if (minus) { -n } else { n }\n go(b)\n }\n def nextDouble(): Double = next.toDouble\n }\n\n def main(args: Array[String]): Unit = {\n val H, W = Scanner.nextInt()\n val S = Array.fill(H)(Scanner.next())\n val dp = Array.fill[Short](H, W, 2)(-1) // 未計算の場合-1, dp(i)(j)(0) 縦の数 dp(i)(j)(1)横の数\n var i = 0\n while (i < H) {\n var j = 0\n while (j < W) {\n if (S(i)(j) == '.') { // 障害物ではない場合\n if (dp(i)(j)(0) == -1) { // 縦方向未計算の場合のみ計算\n var di = 0\n while (i + di < H && S(i+di)(j) == '.') { // 障害物に当たるか壁に当たるかまで\n di += 1\n }\n var dii = 0\n val hoge = (di - 1).toShort\n while (dii < di) {\n dp(i+dii)(j)(0) = hoge\n dii += 1\n }\n }\n if (dp(i)(j)(1) == -1) { // 横方向未計算の場合のみ計算\n var dj = 0\n while (j + dj < W && S(i)(j+dj) == '.') { // 障害物に当たるか壁に当たるかまで\n dj += 1\n }\n var djj = 0\n val hoge = (dj - 1).toShort\n while (djj < dj) {\n dp(i)(j+djj)(1) = hoge\n djj += 1\n }\n }\n }\n j += 1\n }\n i += 1\n }\n\n var max = 0\n i = 0\n while (i < H) {\n var j = 0\n while (j < W) {\n if (S(i)(j) == '.') { // 障害物ではない場合\n max = Math.max(max, dp(i)(j)(0) + dp(i)(j)(1) + 1)\n }\n j += 1\n }\n i += 1\n }\n println(max)\n }\n\n}\n\n", "language": "Scala", "metadata": {"date": 1560138203, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03014.html", "problem_id": "p03014", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03014/input.txt", "sample_output_relpath": "derived/input_output/data/p03014/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03014/Scala/s580604310.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s580604310", "user_id": "u891387249"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "object Main {\n\n object Scanner {\n private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0\n @inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126\n @inline private def hasNextByte(): Boolean =\n if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else { true }\n @inline private def hasNext(): Boolean = {\n while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1\n hasNextByte()\n }\n @inline private def readByte(): Byte =\n if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else { -1 }\n def next(): String = {\n if(!hasNext()) ???\n val sb = new StringBuilder; var b = readByte()\n while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }\n sb.toString\n }\n def nextInt(): Int = {\n val n = nextLong()\n if (n < Int.MinValue || Int.MaxValue < n) ???\n n.toInt\n }\n def nextLong(): Long = {\n if(!hasNext()) ???\n var minus = false; var b = readByte()\n if (b == '-') { minus = true; b = readByte() }\n def go (b: Byte, n: Long = 0): Long =\n if ('0' <= b && b <= '9') { go(readByte(), n * 10 + b - '0') }\n else if (minus) { -n } else { n }\n go(b)\n }\n def nextDouble(): Double = next.toDouble\n }\n\n def main(args: Array[String]): Unit = {\n val H, W = Scanner.nextInt()\n val S = Array.fill(H)(Scanner.next())\n val dp = Array.fill[Short](H, W, 2)(-1) // 未計算の場合-1, dp(i)(j)(0) 縦の数 dp(i)(j)(1)横の数\n var i = 0\n while (i < H) {\n var j = 0\n while (j < W) {\n if (S(i)(j) == '.') { // 障害物ではない場合\n if (dp(i)(j)(0) == -1) { // 縦方向未計算の場合のみ計算\n var di = 0\n while (i + di < H && S(i+di)(j) == '.') { // 障害物に当たるか壁に当たるかまで\n di += 1\n }\n var dii = 0\n val hoge = (di - 1).toShort\n while (dii < di) {\n dp(i+dii)(j)(0) = hoge\n dii += 1\n }\n }\n if (dp(i)(j)(1) == -1) { // 横方向未計算の場合のみ計算\n var dj = 0\n while (j + dj < W && S(i)(j+dj) == '.') { // 障害物に当たるか壁に当たるかまで\n dj += 1\n }\n var djj = 0\n val hoge = (dj - 1).toShort\n while (djj < dj) {\n dp(i)(j+djj)(1) = hoge\n djj += 1\n }\n }\n }\n j += 1\n }\n i += 1\n }\n\n var max = 0\n i = 0\n while (i < H) {\n var j = 0\n while (j < W) {\n if (S(i)(j) == '.') { // 障害物ではない場合\n max = Math.max(max, dp(i)(j)(0) + dp(i)(j)(1) + 1)\n }\n j += 1\n }\n i += 1\n }\n println(max)\n }\n\n}\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere is a grid with H horizontal rows and W vertical columns, and there are obstacles on some of the squares.\n\nSnuke is going to choose one of the squares not occupied by an obstacle and place a lamp on it.\nThe lamp placed on the square will emit straight beams of light in four cardinal directions: up, down, left, and right.\nIn each direction, the beam will continue traveling until it hits a square occupied by an obstacle or it hits the border of the grid. It will light all the squares on the way, including the square on which the lamp is placed, but not the square occupied by an obstacle.\n\nSnuke wants to maximize the number of squares lighted by the lamp.\n\nYou are given H strings S_i (1 \\leq i \\leq H), each of length W. If the j-th character (1 \\leq j \\leq W) of S_i is #, there is an obstacle on the square at the i-th row from the top and the j-th column from the left; if that character is ., there is no obstacle on that square.\n\nFind the maximum possible number of squares lighted by the lamp.\n\nConstraints\n\n1 \\leq H \\leq 2,000\n\n1 \\leq W \\leq 2,000\n\nS_i is a string of length W consisting of # and ..\n\n. occurs at least once in one of the strings S_i (1 \\leq i \\leq H).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nS_1\n:\nS_H\n\nOutput\n\nPrint the maximum possible number of squares lighted by the lamp.\n\nSample Input 1\n\n4 6\n#..#..\n.....#\n....#.\n#.#...\n\nSample Output 1\n\n8\n\nIf Snuke places the lamp on the square at the second row from the top and the second column from the left, it will light the following squares: the first through fifth squares from the left in the second row, and the first through fourth squares from the top in the second column, for a total of eight squares.\n\nSample Input 2\n\n8 8\n..#...#.\n....#...\n##......\n..###..#\n...#..#.\n##....#.\n#...#...\n###.#..#\n\nSample Output 2\n\n13", "sample_input": "4 6\n#..#..\n.....#\n....#.\n#.#...\n"}, "reference_outputs": ["8\n"], "source_document_id": "p03014", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere is a grid with H horizontal rows and W vertical columns, and there are obstacles on some of the squares.\n\nSnuke is going to choose one of the squares not occupied by an obstacle and place a lamp on it.\nThe lamp placed on the square will emit straight beams of light in four cardinal directions: up, down, left, and right.\nIn each direction, the beam will continue traveling until it hits a square occupied by an obstacle or it hits the border of the grid. It will light all the squares on the way, including the square on which the lamp is placed, but not the square occupied by an obstacle.\n\nSnuke wants to maximize the number of squares lighted by the lamp.\n\nYou are given H strings S_i (1 \\leq i \\leq H), each of length W. If the j-th character (1 \\leq j \\leq W) of S_i is #, there is an obstacle on the square at the i-th row from the top and the j-th column from the left; if that character is ., there is no obstacle on that square.\n\nFind the maximum possible number of squares lighted by the lamp.\n\nConstraints\n\n1 \\leq H \\leq 2,000\n\n1 \\leq W \\leq 2,000\n\nS_i is a string of length W consisting of # and ..\n\n. occurs at least once in one of the strings S_i (1 \\leq i \\leq H).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nS_1\n:\nS_H\n\nOutput\n\nPrint the maximum possible number of squares lighted by the lamp.\n\nSample Input 1\n\n4 6\n#..#..\n.....#\n....#.\n#.#...\n\nSample Output 1\n\n8\n\nIf Snuke places the lamp on the square at the second row from the top and the second column from the left, it will light the following squares: the first through fifth squares from the left in the second row, and the first through fourth squares from the top in the second column, for a total of eight squares.\n\nSample Input 2\n\n8 8\n..#...#.\n....#...\n##......\n..###..#\n...#..#.\n##....#.\n#...#...\n###.#..#\n\nSample Output 2\n\n13", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2838, "cpu_time_ms": 1979, "memory_kb": 212976}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s636945727", "group_id": "codeNet:p03017", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n val Array(n, a, b, c, d) = StdIn.readLine().split(\" \").map(_.toInt)\n val S = StdIn.readLine()\n\n def solve(s : String, a: Int, b: Int, c: Int, d: Int ): String = {\n val s1 = s.slice(a, c)\n val s2 = s.slice(b, d)\n\n if (s1.contains(\"##\")) \n return \"No\"\n\n if (s2.contains(\"##\")) \n return \"No\"\n\n if (s(c -1) == '#' || s(d -1) == '#')\n return \"No\"\n\n if (s.length() == 4)\n return \"Yes\"\n\n if (d < c) {\n if (s(b) == '.') {\n if (a + 1 == b || s(b - 2) == '.') {\n return \"Yes\"\n }\n }\n if (! s1.contains(\"...\")) \n return \"No\"\n }\n\n \"Yes\"\n }\n\n println(solve(S, a, b, c, d))\n}\n \n\n", "language": "Scala", "metadata": {"date": 1559527320, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s636945727.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s636945727", "user_id": "u258933429"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n val Array(n, a, b, c, d) = StdIn.readLine().split(\" \").map(_.toInt)\n val S = StdIn.readLine()\n\n def solve(s : String, a: Int, b: Int, c: Int, d: Int ): String = {\n val s1 = s.slice(a, c)\n val s2 = s.slice(b, d)\n\n if (s1.contains(\"##\")) \n return \"No\"\n\n if (s2.contains(\"##\")) \n return \"No\"\n\n if (s(c -1) == '#' || s(d -1) == '#')\n return \"No\"\n\n if (s.length() == 4)\n return \"Yes\"\n\n if (d < c) {\n if (s(b) == '.') {\n if (a + 1 == b || s(b - 2) == '.') {\n return \"Yes\"\n }\n }\n if (! s1.contains(\"...\")) \n return \"No\"\n }\n\n \"Yes\"\n }\n\n println(solve(S, a, b, c, d))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 368, "memory_kb": 29420}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s522883338", "group_id": "codeNet:p03017", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n val Array(n, a, b, c, d) = StdIn.readLine().split(\" \").map(_.toInt)\n val S = StdIn.readLine()\n\n def solve(s : String, a: Int, b: Int, c: Int, d: Int ): String = {\n val s1 = s.slice(a - 1, c)\n val s2 = s.slice(b - 1, d)\n\n if (s1.contains(\"##\")) \n return \"No\"\n\n if (s2.contains(\"##\")) \n return \"No\"\n\n if (d < c) {\n if (s(b) == '.') {\n if (a + 1 == b || s(b - 2) == '.') {\n return \"Yes\"\n }\n }\n if (! s1.contains(\"...\")) \n return \"No\"\n }\n\n \"Yes\"\n }\n\n println(solve(S, a, b, c, d))\n}\n \n\n", "language": "Scala", "metadata": {"date": 1559526356, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s522883338.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s522883338", "user_id": "u258933429"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n val Array(n, a, b, c, d) = StdIn.readLine().split(\" \").map(_.toInt)\n val S = StdIn.readLine()\n\n def solve(s : String, a: Int, b: Int, c: Int, d: Int ): String = {\n val s1 = s.slice(a - 1, c)\n val s2 = s.slice(b - 1, d)\n\n if (s1.contains(\"##\")) \n return \"No\"\n\n if (s2.contains(\"##\")) \n return \"No\"\n\n if (d < c) {\n if (s(b) == '.') {\n if (a + 1 == b || s(b - 2) == '.') {\n return \"Yes\"\n }\n }\n if (! s1.contains(\"...\")) \n return \"No\"\n }\n\n \"Yes\"\n }\n\n println(solve(S, a, b, c, d))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 615, "cpu_time_ms": 370, "memory_kb": 29428}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s551776898", "group_id": "codeNet:p03017", "input_text": "object Main extends App {\n val in = scala.io.Source.stdin.getLines.toSeq\n val ls = in.head.split(' ').map(_.toInt)\n val S = in.tail.head\n val N = ls(0)\n val A = ls(1)\n val B = ls(2)\n val C = ls(3)\n val D = ls(4)\n private def func(s:String, a:Int, b:Int):Boolean = {\n val sub = s.slice(a, b)\n sub.contains(\"##\")\n }\n if(func(S, A, C) || func(S, B, D)) println(\"No\")\n else if(D < C && !S.contains(\"...\")) println(\"No\")\n else println(\"Yes\")\n}\n", "language": "Scala", "metadata": {"date": 1559525555, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s551776898.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s551776898", "user_id": "u699236457"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n val in = scala.io.Source.stdin.getLines.toSeq\n val ls = in.head.split(' ').map(_.toInt)\n val S = in.tail.head\n val N = ls(0)\n val A = ls(1)\n val B = ls(2)\n val C = ls(3)\n val D = ls(4)\n private def func(s:String, a:Int, b:Int):Boolean = {\n val sub = s.slice(a, b)\n sub.contains(\"##\")\n }\n if(func(S, A, C) || func(S, B, D)) println(\"No\")\n else if(D < C && !S.contains(\"...\")) println(\"No\")\n else println(\"Yes\")\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 372, "memory_kb": 29324}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s395917562", "group_id": "codeNet:p03019", "input_text": "object Main {\n import java.io.{BufferedReader, InputStream, InputStreamReader}\n import java.util.StringTokenizer\n import scala.reflect.ClassTag\n\n def main(args: Array[String]): Unit = {\n val out = new java.io.PrintWriter(System.out)\n new Main(out, new InputReader(System.in)).solve()\n out.flush()\n }\n\n private val oj = System.getenv(\"ATCODER_DEBUG\") == null\n def DEBUG(f: => Unit): Unit = {\n if (!oj){ f }\n }\n def debug(as: Array[Boolean]): Unit = if (!oj){ debug(as.map(x => if(x) \"1\" else \"0\").mkString) }\n def debug(as: Array[Int]): Unit = if (!oj){ debug(as.mkString(\" \")) }\n def debug(as: Array[Long]): Unit =if (!oj){ debug(as.mkString(\" \")) }\n def debugDim(m: Array[Array[Long]]): Unit = if (!oj){\n REP(m.length) { i =>\n debug(m(i))\n }\n }\n def debugDimFlip(m: Array[Array[Long]]): Unit = if (!oj){\n REP(m(0).length) { j =>\n REP(m.length) { i =>\n System.err.print(m(i)(j))\n System.err.print(\" \")\n }\n System.err.println()\n }\n }\n def debug(s: => String): Unit = DEBUG {\n System.err.println(s)\n }\n def debugL(num: => Long): Unit = DEBUG {\n System.err.println(num)\n }\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = Integer.parseInt(next())\n def nextLong(): Long = java.lang.Long.parseLong(next())\n def nextChar(): Char = next().charAt(0)\n\n def ni(): Int = nextInt()\n def nl(): Long = nextLong()\n def nc(): Char = nextChar()\n def ns(): String = next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n }\n\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n def TO(from: Int, to: Int)(f: Int => Unit): Unit = {\n REP(to - from + 1, from) { i =>\n f(i)\n }\n }\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n def cumSum(as: Array[Int]): Array[Long] = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n\ncase class Question(b: Int, l: Int, u: Int)\ncase class Entry(i: Int, v: Long)\ncase class Val(i: Int, v: Long)\n\nclass Main(out: java.io.PrintWriter, sc: Main.InputReader) {\n import sc._\n import Main._\n import java.util.Arrays.sort\n\n import scala.collection.mutable\n import math.{abs, max, min}\n import mutable.ArrayBuffer\n\n // toIntとか+7とかするならvalにしろ\n @inline private def MOD = 1000000007\n\n def solve(): Unit = {\n import java.util.Comparator\n val N, X = ni()\n\n var sum = 0L\n\n val forX = Array.ofDim[Val](N)\n val questions = Array.ofDim[Question](N)\n\n REP(N) { i =>\n val b, l, u = ni()\n forX(i) = Val(i, l.toLong * b + (X - b).toLong * u)\n questions(i) = Question(b, l, u)\n sum += b.toLong * l\n }\n\n debug(s\"sum:$sum\")\n\n sort(forX, new Comparator[Val] {\n override def compare(o1: Val, o2: Val): Int = -java.lang.Long.compare(o1.v, o2.v)\n })\n\n val forXSum = Array.ofDim[Long](N + 1)\n REP(N) { i =>\n forXSum(i + 1) = forXSum(i) + forX(i).v\n }\n\n debug(forX.mkString(\" \"))\n debug(forXSum)\n\n def test(a: Long): Boolean = {\n val p = (a / X).toInt\n val cnt = a % X\n val needs = sum - forXSum(min(N, p))\n\n debug(s\"a: $a p:$p cnt:$cnt needs:$needs\")\n\n if (needs <= 0) true\n else if (cnt == 0) false\n else {\n var mx: Entry = null\n TO(p, N - 1) { ii =>\n val i = forX(ii).i\n val q = questions(i)\n val entry = if (needs <= q.b) {\n Entry(i, q.l)\n } else {\n val v = q.b.toLong * q.l + cnt.toLong * q.u\n Entry(i, v)\n }\n if (mx == null || entry.v > mx.v) mx = entry\n }\n\n val e = mx\n debug(s\"cnt:$cnt\")\n if (cnt <= questions(e.i).b) {\n needs <= questions(e.i).l.toLong * cnt\n } else {\n val cntL = questions(e.i).b\n val cntU = cnt - cntL\n debug(s\"cntL:$cntL cntU:$cntU\")\n needs <= questions(e.i).l.toLong * cntL + questions(e.i).u.toLong * cntU\n }\n }\n }\n\n val ans = findMin(test, 0L, sum)\n out.println(ans)\n }\n\n /**\n * 単調増加\n * (l, h] 方式\n */\n def findMin(f: Long => Boolean, min: Long, max: Long): Long = {\n var l = min - 1\n var h = max\n while(h - l > 1) {\n val x = (h + l) / 2\n if (f(x)) h = x\n else l = x\n }\n h\n }\n}", "language": "Scala", "metadata": {"date": 1559531812, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03019.html", "problem_id": "p03019", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03019/input.txt", "sample_output_relpath": "derived/input_output/data/p03019/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03019/Scala/s395917562.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s395917562", "user_id": "u460609472"}, "prompt_components": {"gold_output": "115\n", "input_to_evaluate": "object Main {\n import java.io.{BufferedReader, InputStream, InputStreamReader}\n import java.util.StringTokenizer\n import scala.reflect.ClassTag\n\n def main(args: Array[String]): Unit = {\n val out = new java.io.PrintWriter(System.out)\n new Main(out, new InputReader(System.in)).solve()\n out.flush()\n }\n\n private val oj = System.getenv(\"ATCODER_DEBUG\") == null\n def DEBUG(f: => Unit): Unit = {\n if (!oj){ f }\n }\n def debug(as: Array[Boolean]): Unit = if (!oj){ debug(as.map(x => if(x) \"1\" else \"0\").mkString) }\n def debug(as: Array[Int]): Unit = if (!oj){ debug(as.mkString(\" \")) }\n def debug(as: Array[Long]): Unit =if (!oj){ debug(as.mkString(\" \")) }\n def debugDim(m: Array[Array[Long]]): Unit = if (!oj){\n REP(m.length) { i =>\n debug(m(i))\n }\n }\n def debugDimFlip(m: Array[Array[Long]]): Unit = if (!oj){\n REP(m(0).length) { j =>\n REP(m.length) { i =>\n System.err.print(m(i)(j))\n System.err.print(\" \")\n }\n System.err.println()\n }\n }\n def debug(s: => String): Unit = DEBUG {\n System.err.println(s)\n }\n def debugL(num: => Long): Unit = DEBUG {\n System.err.println(num)\n }\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = Integer.parseInt(next())\n def nextLong(): Long = java.lang.Long.parseLong(next())\n def nextChar(): Char = next().charAt(0)\n\n def ni(): Int = nextInt()\n def nl(): Long = nextLong()\n def nc(): Char = nextChar()\n def ns(): String = next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n }\n\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n def TO(from: Int, to: Int)(f: Int => Unit): Unit = {\n REP(to - from + 1, from) { i =>\n f(i)\n }\n }\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n def cumSum(as: Array[Int]): Array[Long] = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n\ncase class Question(b: Int, l: Int, u: Int)\ncase class Entry(i: Int, v: Long)\ncase class Val(i: Int, v: Long)\n\nclass Main(out: java.io.PrintWriter, sc: Main.InputReader) {\n import sc._\n import Main._\n import java.util.Arrays.sort\n\n import scala.collection.mutable\n import math.{abs, max, min}\n import mutable.ArrayBuffer\n\n // toIntとか+7とかするならvalにしろ\n @inline private def MOD = 1000000007\n\n def solve(): Unit = {\n import java.util.Comparator\n val N, X = ni()\n\n var sum = 0L\n\n val forX = Array.ofDim[Val](N)\n val questions = Array.ofDim[Question](N)\n\n REP(N) { i =>\n val b, l, u = ni()\n forX(i) = Val(i, l.toLong * b + (X - b).toLong * u)\n questions(i) = Question(b, l, u)\n sum += b.toLong * l\n }\n\n debug(s\"sum:$sum\")\n\n sort(forX, new Comparator[Val] {\n override def compare(o1: Val, o2: Val): Int = -java.lang.Long.compare(o1.v, o2.v)\n })\n\n val forXSum = Array.ofDim[Long](N + 1)\n REP(N) { i =>\n forXSum(i + 1) = forXSum(i) + forX(i).v\n }\n\n debug(forX.mkString(\" \"))\n debug(forXSum)\n\n def test(a: Long): Boolean = {\n val p = (a / X).toInt\n val cnt = a % X\n val needs = sum - forXSum(min(N, p))\n\n debug(s\"a: $a p:$p cnt:$cnt needs:$needs\")\n\n if (needs <= 0) true\n else if (cnt == 0) false\n else {\n var mx: Entry = null\n TO(p, N - 1) { ii =>\n val i = forX(ii).i\n val q = questions(i)\n val entry = if (needs <= q.b) {\n Entry(i, q.l)\n } else {\n val v = q.b.toLong * q.l + cnt.toLong * q.u\n Entry(i, v)\n }\n if (mx == null || entry.v > mx.v) mx = entry\n }\n\n val e = mx\n debug(s\"cnt:$cnt\")\n if (cnt <= questions(e.i).b) {\n needs <= questions(e.i).l.toLong * cnt\n } else {\n val cntL = questions(e.i).b\n val cntU = cnt - cntL\n debug(s\"cntL:$cntL cntU:$cntU\")\n needs <= questions(e.i).l.toLong * cntL + questions(e.i).u.toLong * cntU\n }\n }\n }\n\n val ans = findMin(test, 0L, sum)\n out.println(ans)\n }\n\n /**\n * 単調増加\n * (l, h] 方式\n */\n def findMin(f: Long => Boolean, min: Long, max: Long): Long = {\n var l = min - 1\n var h = max\n while(h - l > 1) {\n val x = (h + l) / 2\n if (f(x)) h = x\n else l = x\n }\n h\n }\n}", "problem_context": "Score : 800 points\n\nProblem Statement\n\nTakahashi and Aoki will take N exams numbered 1 to N.\nThey have decided to compete in these exams.\nThe winner will be determined as follows:\n\nFor each exam i, Takahashi decides its importance c_i, which must be an integer between l_i and u_i (inclusive).\n\nLet A be \\sum_{i=1}^{N} c_i \\times (Takahashi's score on Exam i), and B be \\sum_{i=1}^{N} c_i \\times (Aoki's score on Exam i). Takahashi wins if A \\geq B, and Aoki wins if A < B.\n\nTakahashi knows that Aoki will score b_i on Exam i, with his supernatural power.\n\nTakahashi himself, on the other hand, will score 0 on all the exams without studying more. For each hour of study, he can increase his score on some exam by 1. (He can only study for an integer number of hours.)\nHowever, he cannot score more than X on an exam, since the perfect score for all the exams is X.\n\nPrint the minimum number of study hours required for Takahashi to win.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq X \\leq 10^5\n\n0 \\leq b_i \\leq X (1 \\leq i \\leq N)\n\n1 \\leq l_i \\leq u_i \\leq 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 X\nb_1 l_1 u_1\nb_2 l_2 u_2\n:\nb_N l_N u_N\n\nOutput\n\nPrint the minimum number of study hours required for Takahashi to win.\n\nSample Input 1\n\n2 100\n85 2 3\n60 1 1\n\nSample Output 1\n\n115\n\nOne optimal strategy is as follows:\n\nChoose c_1 = 3, c_2 = 1.\n\nStudy to score 100 on Exam 1 and 15 on Exam 2.\n\nThen, A = 3 \\times 100 + 1 \\times 15 = 315, B = 3 \\times 85 + 1 \\times 60 = 315 and Takahashi will win.\n\nSample Input 2\n\n2 100\n85 2 3\n60 10 10\n\nSample Output 2\n\n77\n\nSample Input 3\n\n1 100000\n31415 2718 2818\n\nSample Output 3\n\n31415\n\nSample Input 4\n\n10 1000\n451 4593 6263\n324 310 6991\n378 1431 7068\n71 1757 9218\n204 3676 4328\n840 6221 9080\n684 1545 8511\n709 5467 8674\n862 6504 9835\n283 4965 9980\n\nSample Output 4\n\n2540", "sample_input": "2 100\n85 2 3\n60 1 1\n"}, "reference_outputs": ["115\n"], "source_document_id": "p03019", "source_text": "Score : 800 points\n\nProblem Statement\n\nTakahashi and Aoki will take N exams numbered 1 to N.\nThey have decided to compete in these exams.\nThe winner will be determined as follows:\n\nFor each exam i, Takahashi decides its importance c_i, which must be an integer between l_i and u_i (inclusive).\n\nLet A be \\sum_{i=1}^{N} c_i \\times (Takahashi's score on Exam i), and B be \\sum_{i=1}^{N} c_i \\times (Aoki's score on Exam i). Takahashi wins if A \\geq B, and Aoki wins if A < B.\n\nTakahashi knows that Aoki will score b_i on Exam i, with his supernatural power.\n\nTakahashi himself, on the other hand, will score 0 on all the exams without studying more. For each hour of study, he can increase his score on some exam by 1. (He can only study for an integer number of hours.)\nHowever, he cannot score more than X on an exam, since the perfect score for all the exams is X.\n\nPrint the minimum number of study hours required for Takahashi to win.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq X \\leq 10^5\n\n0 \\leq b_i \\leq X (1 \\leq i \\leq N)\n\n1 \\leq l_i \\leq u_i \\leq 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 X\nb_1 l_1 u_1\nb_2 l_2 u_2\n:\nb_N l_N u_N\n\nOutput\n\nPrint the minimum number of study hours required for Takahashi to win.\n\nSample Input 1\n\n2 100\n85 2 3\n60 1 1\n\nSample Output 1\n\n115\n\nOne optimal strategy is as follows:\n\nChoose c_1 = 3, c_2 = 1.\n\nStudy to score 100 on Exam 1 and 15 on Exam 2.\n\nThen, A = 3 \\times 100 + 1 \\times 15 = 315, B = 3 \\times 85 + 1 \\times 60 = 315 and Takahashi will win.\n\nSample Input 2\n\n2 100\n85 2 3\n60 10 10\n\nSample Output 2\n\n77\n\nSample Input 3\n\n1 100000\n31415 2718 2818\n\nSample Output 3\n\n31415\n\nSample Input 4\n\n10 1000\n451 4593 6263\n324 310 6991\n378 1431 7068\n71 1757 9218\n204 3676 4328\n840 6221 9080\n684 1545 8511\n709 5467 8674\n862 6504 9835\n283 4965 9980\n\nSample Output 4\n\n2540", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5670, "cpu_time_ms": 1012, "memory_kb": 62028}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s739407875", "group_id": "codeNet:p03023", "input_text": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n println(180 * (sc.nextLong() - 2))\n }\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def calc(N: Long, R: Long, M: Long): Double = {\n math.sqrt(R * R - (R * 2 * ((M * 1.0 / N) - 0.5)) * (R * 2 * ((M * 1.0 / N) - 0.5))) * 2\n }\n\n var memo: Map[(Long, Long), Long] = Map[(Long, Long), Long]()\n\n def recursive(input: Long): Long = {\n if (input < 10) input else input % 10 + recursive(input / 10)\n }\n\n def recursive2(X: Set[Long], Y: Stream[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n\n def check(s: String): Boolean = {\n if (s == \"0\") true\n else s(0) != '0' && 0 <= s.toInt && s.toInt <= 255\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def primeFactors(i: Long): List[Long] = primeFactors_(i, 1).sorted\n\n\n def primeFactors_(i: Long, j: Long): List[Long] = {\n if (j * j > i) List.empty else if (i % j == 0) primeFactors_(i, j + 1) ++ List[Long](j, i / j) else primeFactors_(i, j + 1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n}\n", "language": "Scala", "metadata": {"date": 1559928830, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03023.html", "problem_id": "p03023", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03023/input.txt", "sample_output_relpath": "derived/input_output/data/p03023/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03023/Scala/s739407875.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s739407875", "user_id": "u779353743"}, "prompt_components": {"gold_output": "180\n", "input_to_evaluate": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n println(180 * (sc.nextLong() - 2))\n }\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def calc(N: Long, R: Long, M: Long): Double = {\n math.sqrt(R * R - (R * 2 * ((M * 1.0 / N) - 0.5)) * (R * 2 * ((M * 1.0 / N) - 0.5))) * 2\n }\n\n var memo: Map[(Long, Long), Long] = Map[(Long, Long), Long]()\n\n def recursive(input: Long): Long = {\n if (input < 10) input else input % 10 + recursive(input / 10)\n }\n\n def recursive2(X: Set[Long], Y: Stream[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n\n def check(s: String): Boolean = {\n if (s == \"0\") true\n else s(0) != '0' && 0 <= s.toInt && s.toInt <= 255\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def primeFactors(i: Long): List[Long] = primeFactors_(i, 1).sorted\n\n\n def primeFactors_(i: Long, j: Long): List[Long] = {\n if (j * j > i) List.empty else if (i % j == 0) primeFactors_(i, j + 1) ++ List[Long](j, i / j) else primeFactors_(i, j + 1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides.\n\nPrint the answer in degrees, but do not print units.\n\nConstraints\n\n3 \\leq N \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint an integer representing the sum of the interior angles of a regular polygon with N sides.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n180\n\nThe sum of the interior angles of a regular triangle is 180 degrees.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n17640", "sample_input": "3\n"}, "reference_outputs": ["180\n"], "source_document_id": "p03023", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides.\n\nPrint the answer in degrees, but do not print units.\n\nConstraints\n\n3 \\leq N \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint an integer representing the sum of the interior angles of a regular polygon with N sides.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n180\n\nThe sum of the interior angles of a regular triangle is 180 degrees.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n17640", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6339, "cpu_time_ms": 328, "memory_kb": 25544}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s952305024", "group_id": "codeNet:p03023", "input_text": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val N = sc.nextInt()\n println((N - 2) * 180)\n }\n\n}", "language": "Scala", "metadata": {"date": 1559437280, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03023.html", "problem_id": "p03023", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03023/input.txt", "sample_output_relpath": "derived/input_output/data/p03023/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03023/Scala/s952305024.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s952305024", "user_id": "u891387249"}, "prompt_components": {"gold_output": "180\n", "input_to_evaluate": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val N = sc.nextInt()\n println((N - 2) * 180)\n }\n\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides.\n\nPrint the answer in degrees, but do not print units.\n\nConstraints\n\n3 \\leq N \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint an integer representing the sum of the interior angles of a regular polygon with N sides.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n180\n\nThe sum of the interior angles of a regular triangle is 180 degrees.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n17640", "sample_input": "3\n"}, "reference_outputs": ["180\n"], "source_document_id": "p03023", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides.\n\nPrint the answer in degrees, but do not print units.\n\nConstraints\n\n3 \\leq N \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint an integer representing the sum of the interior angles of a regular polygon with N sides.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n180\n\nThe sum of the interior angles of a regular triangle is 180 degrees.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n17640", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 357, "memory_kb": 25808}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s884950949", "group_id": "codeNet:p03030", "input_text": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val n = in.nextInt\n val r = List.fill(n)(in.next -> in.nextInt)\n\n r.zipWithIndex\n .sortWith(\n (x, y) =>\n if (x._1._1 == y._1._1) {\n x._1._2 >= y._1._2\n } else if (x._1._1 <= y._1._1) {\n true\n } else {\n false\n }\n )\n .map(_._2 + 1)\n .foreach(println)\n}\n", "language": "Scala", "metadata": {"date": 1559515201, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s884950949.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s884950949", "user_id": "u991539345"}, "prompt_components": {"gold_output": "3\n4\n6\n1\n5\n2\n", "input_to_evaluate": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val n = in.nextInt\n val r = List.fill(n)(in.next -> in.nextInt)\n\n r.zipWithIndex\n .sortWith(\n (x, y) =>\n if (x._1._1 == y._1._1) {\n x._1._2 >= y._1._2\n } else if (x._1._1 <= y._1._1) {\n true\n } else {\n false\n }\n )\n .map(_._2 + 1)\n .foreach(println)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 352, "memory_kb": 25536}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s474836138", "group_id": "codeNet:p03030", "input_text": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val n = in.nextInt\n val r = List.fill(n)(in.next -> in.nextInt).zipWithIndex\n\n r.sortWith((x, y) => {\n if (x._1._1 == y._1._1) {\n x._1._2 >= y._1._2\n } else if (x._1._1 <= y._1._1) {\n true\n } else {\n false\n }\n })\n .map(_._2 + 1)\n .foreach(println)\n}\n", "language": "Scala", "metadata": {"date": 1559514712, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s474836138.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s474836138", "user_id": "u991539345"}, "prompt_components": {"gold_output": "3\n4\n6\n1\n5\n2\n", "input_to_evaluate": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val n = in.nextInt\n val r = List.fill(n)(in.next -> in.nextInt).zipWithIndex\n\n r.sortWith((x, y) => {\n if (x._1._1 == y._1._1) {\n x._1._2 >= y._1._2\n } else if (x._1._1 <= y._1._1) {\n true\n } else {\n false\n }\n })\n .map(_._2 + 1)\n .foreach(println)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 376, "cpu_time_ms": 355, "memory_kb": 25776}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s962825167", "group_id": "codeNet:p03030", "input_text": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n\n def solve(sc: => Scanner): Unit = {\n println(Array.fill(sc.nextInt())((sc.next(), sc.nextLong()))\n .zipWithIndex\n .sortWith((a, b) => if (a._1._1 == b._1._1) a._1._2 > b._1._2 else a._1._1 < b._1._1)\n .map(a => a._2 + 1).mkString(\"\\n\"))\n }\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def calc(N: Long, R: Long, M: Long): Double = {\n math.sqrt(R * R - (R * 2 * ((M * 1.0 / N) - 0.5)) * (R * 2 * ((M * 1.0 / N) - 0.5))) * 2\n }\n\n var memo: Map[(Long, Long), Long] = Map[(Long, Long), Long]()\n\n def recursive(input: Long): Long = {\n if (input < 10) input else input % 10 + recursive(input / 10)\n }\n\n def recursive2(X: Set[Long], Y: Stream[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n\n def check(s: String): Boolean = {\n if (s == \"0\") true\n else s(0) != '0' && 0 <= s.toInt && s.toInt <= 255\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def primeFactors(i: Long): List[Long] = primeFactors_(i, 1).sorted\n\n\n def primeFactors_(i: Long, j: Long): List[Long] = {\n if (j * j > i) List.empty else if (i % j == 0) primeFactors_(i, j + 1) ++ List[Long](j, i / j) else primeFactors_(i, j + 1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n}\n", "language": "Scala", "metadata": {"date": 1559272392, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s962825167.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s962825167", "user_id": "u779353743"}, "prompt_components": {"gold_output": "3\n4\n6\n1\n5\n2\n", "input_to_evaluate": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n\n def solve(sc: => Scanner): Unit = {\n println(Array.fill(sc.nextInt())((sc.next(), sc.nextLong()))\n .zipWithIndex\n .sortWith((a, b) => if (a._1._1 == b._1._1) a._1._2 > b._1._2 else a._1._1 < b._1._1)\n .map(a => a._2 + 1).mkString(\"\\n\"))\n }\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def calc(N: Long, R: Long, M: Long): Double = {\n math.sqrt(R * R - (R * 2 * ((M * 1.0 / N) - 0.5)) * (R * 2 * ((M * 1.0 / N) - 0.5))) * 2\n }\n\n var memo: Map[(Long, Long), Long] = Map[(Long, Long), Long]()\n\n def recursive(input: Long): Long = {\n if (input < 10) input else input % 10 + recursive(input / 10)\n }\n\n def recursive2(X: Set[Long], Y: Stream[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n\n def check(s: String): Boolean = {\n if (s == \"0\") true\n else s(0) != '0' && 0 <= s.toInt && s.toInt <= 255\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def primeFactors(i: Long): List[Long] = primeFactors_(i, 1).sorted\n\n\n def primeFactors_(i: Long, j: Long): List[Long] = {\n if (j * j > i) List.empty else if (i % j == 0) primeFactors_(i, j + 1) ++ List[Long](j, i / j) else primeFactors_(i, j + 1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6520, "cpu_time_ms": 335, "memory_kb": 25552}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s762210302", "group_id": "codeNet:p03032", "input_text": "import java.util.Scanner\n\n\nobject Main {\n\n def read() = {\n val sc = new Scanner(System.in)\n val n, k = sc.nextInt()\n val v = IndexedSeq.fill(n)(sc.nextInt())\n (n, k, v)\n }\n\n def solve(n: Int, k: Int, v: IndexedSeq[Int]): Int = {\n\n (for (deqTimes <- 0 to k; deqRightTimes <- 0 to deqTimes) yield {\n // 右側から何回撮るか\n val deqLeftTimes = deqTimes - deqRightTimes\n // [0, l), [n-r, n)\n val deqLeft = (0 until deqLeftTimes).map(v)\n val deqRight = (n - deqRightTimes until n).map(v)\n val deq = IndexedSeq.concat(deqLeft, deqRight).sorted\n\n val enqTimes = k - deqTimes\n // 負のやつ捨てる\n val result = deq.zipWithIndex.map {\n case (v, i) => if (i < enqTimes && v < 0) 0 else v\n }.sum\n result\n }).max\n }\n\n def main(args: Array[String]): Unit = {\n val (n, k, v) = read()\n println(solve(n, k, v))\n }\n}", "language": "Scala", "metadata": {"date": 1558921514, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s762210302.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s762210302", "user_id": "u494788559"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "import java.util.Scanner\n\n\nobject Main {\n\n def read() = {\n val sc = new Scanner(System.in)\n val n, k = sc.nextInt()\n val v = IndexedSeq.fill(n)(sc.nextInt())\n (n, k, v)\n }\n\n def solve(n: Int, k: Int, v: IndexedSeq[Int]): Int = {\n\n (for (deqTimes <- 0 to k; deqRightTimes <- 0 to deqTimes) yield {\n // 右側から何回撮るか\n val deqLeftTimes = deqTimes - deqRightTimes\n // [0, l), [n-r, n)\n val deqLeft = (0 until deqLeftTimes).map(v)\n val deqRight = (n - deqRightTimes until n).map(v)\n val deq = IndexedSeq.concat(deqLeft, deqRight).sorted\n\n val enqTimes = k - deqTimes\n // 負のやつ捨てる\n val result = deq.zipWithIndex.map {\n case (v, i) => if (i < enqTimes && v < 0) 0 else v\n }.sum\n result\n }).max\n }\n\n def main(args: Array[String]): Unit = {\n val (n, k, v) = read()\n println(solve(n, k, v))\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 904, "cpu_time_ms": 604, "memory_kb": 37204}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s299380273", "group_id": "codeNet:p03034", "input_text": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\nimport scala.collection.mutable.{Map, Stack, Queue, PriorityQueue}\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val N = in.next().toInt\n val s = new Array[Int](N)\n for (i <- 0 until N)\n s(i) = in.next().toInt\n\n\n //\n var ans = 0L\n for (c <- 1 to N-2) { // c := A - B\n var score = 0L\n\n val dp = new Array[Boolean](N)\n dp(0) = true; dp(N-1) = true\n\n var x = 1\n breakable {\n while (true) {\n if (x*c >= N)\n break\n\n if (dp(x*c))\n break\n dp(x*c) = true\n\n if (dp((N-1)-x*c))\n break\n dp((N-1)-x*c) = true\n\n score += s(x*c)\n score += s((N-1)-x*c)\n\n ans = Math.max(ans, score)\n\n x += 1\n }\n }\n }\n\n println(ans)\n}\n\n\nclass InputReader(stream: InputStream) {\n private[this] val reader = new BufferedReader(new InputStreamReader(stream))\n private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n\nobject Sub {\n def print2DimArray[A](mat: Array[Array[A]]): Unit = {\n mat.foreach(lin => println(lin.deep))\n }\n}\n", "language": "Scala", "metadata": {"date": 1574477494, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03034.html", "problem_id": "p03034", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03034/input.txt", "sample_output_relpath": "derived/input_output/data/p03034/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03034/Scala/s299380273.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s299380273", "user_id": "u098968285"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\nimport scala.collection.mutable.{Map, Stack, Queue, PriorityQueue}\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val N = in.next().toInt\n val s = new Array[Int](N)\n for (i <- 0 until N)\n s(i) = in.next().toInt\n\n\n //\n var ans = 0L\n for (c <- 1 to N-2) { // c := A - B\n var score = 0L\n\n val dp = new Array[Boolean](N)\n dp(0) = true; dp(N-1) = true\n\n var x = 1\n breakable {\n while (true) {\n if (x*c >= N)\n break\n\n if (dp(x*c))\n break\n dp(x*c) = true\n\n if (dp((N-1)-x*c))\n break\n dp((N-1)-x*c) = true\n\n score += s(x*c)\n score += s((N-1)-x*c)\n\n ans = Math.max(ans, score)\n\n x += 1\n }\n }\n }\n\n println(ans)\n}\n\n\nclass InputReader(stream: InputStream) {\n private[this] val reader = new BufferedReader(new InputStreamReader(stream))\n private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n\nobject Sub {\n def print2DimArray[A](mat: Array[Array[A]]): Unit = {\n mat.foreach(lin => println(lin.deep))\n }\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere is an infinitely large pond, which we consider as a number line.\nIn this pond, there are N lotuses floating at coordinates 0, 1, 2, ..., N-2 and N-1.\nOn the lotus at coordinate i, an integer s_i is written.\n\nYou are standing on the lotus at coordinate 0. You will play a game that proceeds as follows:\n\n1. Choose positive integers A and B. Your score is initially 0.\n\n2. Let x be your current coordinate, and y = x+A. The lotus at coordinate x disappears, and you move to coordinate y.\n\nIf y = N-1, the game ends.\n\nIf y \\neq N-1 and there is a lotus floating at coordinate y, your score increases by s_y.\n\nIf y \\neq N-1 and there is no lotus floating at coordinate y, you drown. Your score decreases by 10^{100} points, and the game ends.\n\n3. Let x be your current coordinate, and y = x-B. The lotus at coordinate x disappears, and you move to coordinate y.\n\nIf y = N-1, the game ends.\n\nIf y \\neq N-1 and there is a lotus floating at coordinate y, your score increases by s_y.\n\nIf y \\neq N-1 and there is no lotus floating at coordinate y, you drown. Your score decreases by 10^{100} points, and the game ends.\n\n4. Go back to step 2.\n\nYou want to end the game with as high a score as possible.\nWhat is the score obtained by the optimal choice of A and B?\n\nConstraints\n\n3 \\leq N \\leq 10^5\n\n-10^9 \\leq s_i \\leq 10^9\n\ns_0=s_{N-1}=0\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_0 s_1 ...... s_{N-1}\n\nOutput\n\nPrint the score obtained by the optimal choice of A and B.\n\nSample Input 1\n\n5\n0 2 5 1 0\n\nSample Output 1\n\n3\n\nIf you choose A = 3 and B = 2, the game proceeds as follows:\n\nMove to coordinate 0 + 3 = 3. Your score increases by s_3 = 1.\n\nMove to coordinate 3 - 2 = 1. Your score increases by s_1 = 2.\n\nMove to coordinate 1 + 3 = 4. The game ends with a score of 3.\n\nThere is no way to end the game with a score of 4 or higher, so the answer is 3. Note that you cannot land the lotus at coordinate 2 without drowning later.\n\nSample Input 2\n\n6\n0 10 -7 -4 -13 0\n\nSample Output 2\n\n0\n\nThe optimal strategy here is to land the final lotus immediately by choosing A = 5 (the value of B does not matter).\n\nSample Input 3\n\n11\n0 -4 0 -99 31 14 -15 -39 43 18 0\n\nSample Output 3\n\n59", "sample_input": "5\n0 2 5 1 0\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03034", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere is an infinitely large pond, which we consider as a number line.\nIn this pond, there are N lotuses floating at coordinates 0, 1, 2, ..., N-2 and N-1.\nOn the lotus at coordinate i, an integer s_i is written.\n\nYou are standing on the lotus at coordinate 0. You will play a game that proceeds as follows:\n\n1. Choose positive integers A and B. Your score is initially 0.\n\n2. Let x be your current coordinate, and y = x+A. The lotus at coordinate x disappears, and you move to coordinate y.\n\nIf y = N-1, the game ends.\n\nIf y \\neq N-1 and there is a lotus floating at coordinate y, your score increases by s_y.\n\nIf y \\neq N-1 and there is no lotus floating at coordinate y, you drown. Your score decreases by 10^{100} points, and the game ends.\n\n3. Let x be your current coordinate, and y = x-B. The lotus at coordinate x disappears, and you move to coordinate y.\n\nIf y = N-1, the game ends.\n\nIf y \\neq N-1 and there is a lotus floating at coordinate y, your score increases by s_y.\n\nIf y \\neq N-1 and there is no lotus floating at coordinate y, you drown. Your score decreases by 10^{100} points, and the game ends.\n\n4. Go back to step 2.\n\nYou want to end the game with as high a score as possible.\nWhat is the score obtained by the optimal choice of A and B?\n\nConstraints\n\n3 \\leq N \\leq 10^5\n\n-10^9 \\leq s_i \\leq 10^9\n\ns_0=s_{N-1}=0\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_0 s_1 ...... s_{N-1}\n\nOutput\n\nPrint the score obtained by the optimal choice of A and B.\n\nSample Input 1\n\n5\n0 2 5 1 0\n\nSample Output 1\n\n3\n\nIf you choose A = 3 and B = 2, the game proceeds as follows:\n\nMove to coordinate 0 + 3 = 3. Your score increases by s_3 = 1.\n\nMove to coordinate 3 - 2 = 1. Your score increases by s_1 = 2.\n\nMove to coordinate 1 + 3 = 4. The game ends with a score of 3.\n\nThere is no way to end the game with a score of 4 or higher, so the answer is 3. Note that you cannot land the lotus at coordinate 2 without drowning later.\n\nSample Input 2\n\n6\n0 10 -7 -4 -13 0\n\nSample Output 2\n\n0\n\nThe optimal strategy here is to land the final lotus immediately by choosing A = 5 (the value of B does not matter).\n\nSample Input 3\n\n11\n0 -4 0 -99 31 14 -15 -39 43 18 0\n\nSample Output 3\n\n59", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1812, "memory_kb": 116732}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s963502461", "group_id": "codeNet:p03035", "input_text": "object Main extends App {\n\n val Array(n, m) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n var a: Array[Int] = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\n (1 to m).foreach { _ =>\n val Array(b, c) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n val cc: Array[Int] = Array.fill(b)(c)\n a ++= cc\n }\n\n println(a.sorted.takeRight(n).map(_.toLong).sum)\n}", "language": "Scala", "metadata": {"date": 1558907939, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s963502461.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s963502461", "user_id": "u654455149"}, "prompt_components": {"gold_output": "100\n", "input_to_evaluate": "object Main extends App {\n\n val Array(n, m) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n var a: Array[Int] = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\n (1 to m).foreach { _ =>\n val Array(b, c) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n val cc: Array[Int] = Array.fill(b)(c)\n a ++= cc\n }\n\n println(a.sorted.takeRight(n).map(_.toLong).sum)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 327, "memory_kb": 25420}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s447193393", "group_id": "codeNet:p03036", "input_text": "object Main extends App {\n val (r, d, x) = scala.io.StdIn.readLine.split(' ').map(_.toInt) match { case Array(ir, id, ix) => (ir, id, ix) }\n\n (1 to 10).foldLeft(Seq.empty[Int])((results, i) => results :+ (r * results.lastOption.getOrElse(x) - d)).foreach(println)\n}\n", "language": "Scala", "metadata": {"date": 1558838304, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s447193393.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s447193393", "user_id": "u991539345"}, "prompt_components": {"gold_output": "30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n", "input_to_evaluate": "object Main extends App {\n val (r, d, x) = scala.io.StdIn.readLine.split(' ').map(_.toInt) match { case Array(ir, id, ix) => (ir, id, ix) }\n\n (1 to 10).foldLeft(Seq.empty[Int])((results, i) => results :+ (r * results.lastOption.getOrElse(x) - d)).foreach(println)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 353, "memory_kb": 27076}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s508522803", "group_id": "codeNet:p03036", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val r = sc.nextInt\n val D = sc.nextInt\n val x2000 = sc.nextInt\n calc(1, x2000, r, D)\n }\n\n def calc(count: Int, x: Int, r: Int, D: Int): Int = count match {\n case count if count > 10 => x\n case _ => {\n val result = r * x - D\n println(result)\n calc(count + 1, result, r, D)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1558834000, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s508522803.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s508522803", "user_id": "u889604426"}, "prompt_components": {"gold_output": "30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val r = sc.nextInt\n val D = sc.nextInt\n val x2000 = sc.nextInt\n calc(1, x2000, r, D)\n }\n\n def calc(count: Int, x: Int, r: Int, D: Int): Int = count match {\n case count if count > 10 => x\n case _ => {\n val result = r * x - D\n println(result)\n calc(count + 1, result, r, D)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 355, "memory_kb": 25908}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s690175644", "group_id": "codeNet:p03037", "input_text": "object Main extends App {\n\n val sc = new java.util.Scanner(System.in) \n val n, m = sc.nextInt()\n val g = Array.fill(m)((sc.nextInt() to sc.nextInt()).toSet)\n val ans = g.foldLeft((1 to n).toSet)((x, y) => x & y)\n println(ans.size)\n}", "language": "Scala", "metadata": {"date": 1598832599, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s690175644.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s690175644", "user_id": "u396472025"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n\n val sc = new java.util.Scanner(System.in) \n val n, m = sc.nextInt()\n val g = Array.fill(m)((sc.nextInt() to sc.nextInt()).toSet)\n val ans = g.foldLeft((1 to n).toSet)((x, y) => x & y)\n println(ans.size)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2205, "memory_kb": 275032}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s375745753", "group_id": "codeNet:p03037", "input_text": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val Array(n, m) = in.readLine.split(\" \").map(_.toInt)\n\n val (l, r) = Iterator.continually(in.readLine)\n .take(m)\n .map(_.split(\" \").map(_.toInt))\n .foldLeft(0, n) { (acc , e) =>\n (acc._1 max e(0), acc._2 min e(1))\n }\n\n val ans = (r - l + 1) max 0\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1575749580, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s375745753.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s375745753", "user_id": "u217010036"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val Array(n, m) = in.readLine.split(\" \").map(_.toInt)\n\n val (l, r) = Iterator.continually(in.readLine)\n .take(m)\n .map(_.split(\" \").map(_.toInt))\n .foldLeft(0, n) { (acc , e) =>\n (acc._1 max e(0), acc._2 min e(1))\n }\n\n val ans = (r - l + 1) max 0\n println(ans)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 780, "memory_kb": 44944}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s301356971", "group_id": "codeNet:p03037", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val N = sc.nextInt\n val M = sc.nextInt\n val L = new Array[Int](M)\n val R = new Array[Int](M)\n for (i <- 0 until M) {\n L(i) = sc.nextInt\n R(i) = sc.nextInt\n }\n\n val maxL = L.max\n val minR = R.min\n\n val ans =\n if (maxL <= minR) {\n minR - maxL + 1\n } else {\n 0\n }\n\n println(ans)\n }\n}", "language": "Scala", "metadata": {"date": 1561085932, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s301356971.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s301356971", "user_id": "u743229067"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val N = sc.nextInt\n val M = sc.nextInt\n val L = new Array[Int](M)\n val R = new Array[Int](M)\n for (i <- 0 until M) {\n L(i) = sc.nextInt\n R(i) = sc.nextInt\n }\n\n val maxL = L.max\n val minR = R.min\n\n val ans =\n if (maxL <= minR) {\n minR - maxL + 1\n } else {\n 0\n }\n\n println(ans)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 785, "memory_kb": 70948}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s909249897", "group_id": "codeNet:p03037", "input_text": "object Main {\n\n import java.util.Scanner\n\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val writer = new java.io.PrintWriter(System.out)\n writer.println(solve(sc))\n writer.flush()\n }\n\n def solve(sc: Scanner): String = {\n val (n, m) = (sc.nextInt(), sc.nextInt())\n val gates = IndexedSeq.fill(m)((sc.nextInt(), sc.nextInt()))\n debug(n, m, gates)\n\n val leftMax = gates.map { case (l, _) => l }.max\n val rightMin = gates.map { case (_, r) => r }.min\n (if (leftMax > rightMin) 0 else rightMin - leftMax + 1).toString\n }\n\n private def debug(x: Any): Unit = {\n if (System.getenv(\"LOCAL_DEBUG\") != null) println(x)\n }\n}\n", "language": "Scala", "metadata": {"date": 1558843370, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s909249897.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s909249897", "user_id": "u088326922"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main {\n\n import java.util.Scanner\n\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val writer = new java.io.PrintWriter(System.out)\n writer.println(solve(sc))\n writer.flush()\n }\n\n def solve(sc: Scanner): String = {\n val (n, m) = (sc.nextInt(), sc.nextInt())\n val gates = IndexedSeq.fill(m)((sc.nextInt(), sc.nextInt()))\n debug(n, m, gates)\n\n val leftMax = gates.map { case (l, _) => l }.max\n val rightMin = gates.map { case (_, r) => r }.min\n (if (leftMax > rightMin) 0 else rightMin - leftMax + 1).toString\n }\n\n private def debug(x: Any): Unit = {\n if (System.getenv(\"LOCAL_DEBUG\") != null) println(x)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 937, "memory_kb": 76624}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s912368323", "group_id": "codeNet:p03038", "input_text": "object Main extends App {\n\n val Array(n, m) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n var a: Array[Long] = scala.io.StdIn.readLine.split(\" \").map(_.toLong).sorted\n\n val bc = (1 to m).map { _ =>\n val Array(b, c) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\n (b, c.toLong)\n }.sortWith((o1, o2) => o1._2 > o2._2)\n\n var inx = 0\n bc.foreach { bbcc =>\n var cnt = bbcc._1\n val cc = bbcc._2\n while (cnt > 0 && inx < a.length && a(inx) < cc) {\n a.update(inx, cc)\n inx += 1\n cnt -= 1\n }\n // println(a.deep)\n }\n println(a.sum)\n}", "language": "Scala", "metadata": {"date": 1558909117, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s912368323.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s912368323", "user_id": "u654455149"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "object Main extends App {\n\n val Array(n, m) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n var a: Array[Long] = scala.io.StdIn.readLine.split(\" \").map(_.toLong).sorted\n\n val bc = (1 to m).map { _ =>\n val Array(b, c) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\n (b, c.toLong)\n }.sortWith((o1, o2) => o1._2 > o2._2)\n\n var inx = 0\n bc.foreach { bbcc =>\n var cnt = bbcc._1\n val cc = bbcc._2\n while (cnt > 0 && inx < a.length && a(inx) < cc) {\n a.update(inx, cc)\n inx += 1\n cnt -= 1\n }\n // println(a.deep)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 576, "cpu_time_ms": 1609, "memory_kb": 78692}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s998491874", "group_id": "codeNet:p03038", "input_text": "// import scala.io.{StdIn => in}\nimport java.io._\nimport scala.collection.{mutable => mu}\n\nobject Main extends App {\n import MapHelper._\n\n val in = new BufferedReader(new InputStreamReader(System.in))\n val Array(n, m) = in.readLine.split(\" \").map(_.toInt)\n val map = mu.HashMap.empty[Long,Int]\n\n in.readLine.split(\" \").map(_.toLong).foreach(map.addOrUpdate(_,1))\n Iterator.continually(in.readLine)\n .take(m)\n .map(_.split(\" \").map(_.toInt))\n .foreach(e => map.addOrUpdate(e(1), e(0)))\n\n val keys = map.keys.toArray.sorted(Ordering[Long].reverse)\n def rec(acc:Long, cnt:Int, i:Int):Long = {\n val v = keys(i)\n val p = map(keys(i))\n if(cnt + p >= n) acc + v * (n - cnt)\n else rec(acc + v * p, cnt + p, i + 1)\n }\n\n val ans = rec(0, 0, 0)\n println(ans)\n\n object MapHelper {\n implicit class AddOrUpdate[A](map:mu.HashMap[Long,Int]) {\n def addOrUpdate(key:Long, value:Int):mu.HashMap[Long,Int] =\n {\n if(map.contains(key)) map(key) += value\n else map += (key -> value)\n map\n }\n }\n }\n}", "language": "Scala", "metadata": {"date": 1558849390, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s998491874.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s998491874", "user_id": "u217010036"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "// import scala.io.{StdIn => in}\nimport java.io._\nimport scala.collection.{mutable => mu}\n\nobject Main extends App {\n import MapHelper._\n\n val in = new BufferedReader(new InputStreamReader(System.in))\n val Array(n, m) = in.readLine.split(\" \").map(_.toInt)\n val map = mu.HashMap.empty[Long,Int]\n\n in.readLine.split(\" \").map(_.toLong).foreach(map.addOrUpdate(_,1))\n Iterator.continually(in.readLine)\n .take(m)\n .map(_.split(\" \").map(_.toInt))\n .foreach(e => map.addOrUpdate(e(1), e(0)))\n\n val keys = map.keys.toArray.sorted(Ordering[Long].reverse)\n def rec(acc:Long, cnt:Int, i:Int):Long = {\n val v = keys(i)\n val p = map(keys(i))\n if(cnt + p >= n) acc + v * (n - cnt)\n else rec(acc + v * p, cnt + p, i + 1)\n }\n\n val ans = rec(0, 0, 0)\n println(ans)\n\n object MapHelper {\n implicit class AddOrUpdate[A](map:mu.HashMap[Long,Int]) {\n def addOrUpdate(key:Long, value:Int):mu.HashMap[Long,Int] =\n {\n if(map.contains(key)) map(key) += value\n else map += (key -> value)\n map\n }\n }\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1438, "memory_kb": 98216}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s497922155", "group_id": "codeNet:p03038", "input_text": "object Main extends App {\n\n val Array(n, m) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n var a = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\n (1 to m).foreach { _ =>\n val Array(b, c) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n (1 to b).foreach { _ =>\n a = a :+ c\n }\n }\n\n println(a.sorted.takeRight(n).map(_.toLong).sum)\n\n}", "language": "Scala", "metadata": {"date": 1558838603, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s497922155.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s497922155", "user_id": "u654455149"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "object Main extends App {\n\n val Array(n, m) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n var a = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\n (1 to m).foreach { _ =>\n val Array(b, c) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n (1 to b).foreach { _ =>\n a = a :+ c\n }\n }\n\n println(a.sorted.takeRight(n).map(_.toLong).sum)\n\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 127212}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s699130355", "group_id": "codeNet:p03038", "input_text": "import scala.io.{StdIn => in}\nimport scala.collection.{mutable => mu}\n\nobject Main extends App {\n import MapHelper._\n\n val Array(n, m) = in.readLine.split(\" \").map(_.toInt)\n val a = in.readLine.split(\" \").map(_.toLong)\n val map = mu.HashMap.empty[Long,Int]\n\n a.foreach { i =>\n map.addOrUpdate(i, 1)\n }\n\n Iterator.continually(in.readLine)\n .take(m)\n .map(_.split(\" \").map(_.toInt))\n .foreach { e =>\n map.addOrUpdate(e(1),e(0))\n }\n \n var i = 0\n var cnt = 0\n var acc = 0L\n val keys = map.keys.toArray.sorted(Ordering[Long].reverse)\n val end = keys.size\n while(cnt <= n) {\n cnt += map(keys(i))\n // println(keys(i) + \" \" + map(keys(i)))\n if(cnt <= n) acc += keys(i) * map(keys(i))\n else if(cnt > n) acc += keys(i) *(map(keys(i)) - (cnt - n))\n i += 1\n }\n val ans = acc\n println(ans)\n\n object MapHelper {\n implicit class AddOrUpdate[A](map:mu.HashMap[Long,Int]) {\n def addOrUpdate(key:Long, value:Int):mu.HashMap[Long,Int] =\n {\n if(map.contains(key)) map(key) += value\n else map += (key -> value)\n map\n }\n }\n }\n}", "language": "Scala", "metadata": {"date": 1558838173, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s699130355.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s699130355", "user_id": "u217010036"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "import scala.io.{StdIn => in}\nimport scala.collection.{mutable => mu}\n\nobject Main extends App {\n import MapHelper._\n\n val Array(n, m) = in.readLine.split(\" \").map(_.toInt)\n val a = in.readLine.split(\" \").map(_.toLong)\n val map = mu.HashMap.empty[Long,Int]\n\n a.foreach { i =>\n map.addOrUpdate(i, 1)\n }\n\n Iterator.continually(in.readLine)\n .take(m)\n .map(_.split(\" \").map(_.toInt))\n .foreach { e =>\n map.addOrUpdate(e(1),e(0))\n }\n \n var i = 0\n var cnt = 0\n var acc = 0L\n val keys = map.keys.toArray.sorted(Ordering[Long].reverse)\n val end = keys.size\n while(cnt <= n) {\n cnt += map(keys(i))\n // println(keys(i) + \" \" + map(keys(i)))\n if(cnt <= n) acc += keys(i) * map(keys(i))\n else if(cnt > n) acc += keys(i) *(map(keys(i)) - (cnt - n))\n i += 1\n }\n val ans = acc\n println(ans)\n\n object MapHelper {\n implicit class AddOrUpdate[A](map:mu.HashMap[Long,Int]) {\n def addOrUpdate(key:Long, value:Int):mu.HashMap[Long,Int] =\n {\n if(map.contains(key)) map(key) += value\n else map += (key -> value)\n map\n }\n }\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1494, "memory_kb": 98096}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s121934185", "group_id": "codeNet:p03038", "input_text": "import java.util.Scanner\n\nimport scala.annotation.tailrec\n\nobject Main {\n def main(args: Array[String]) = {\n val sc = new Scanner(System.in)\n val N, M = sc.nextInt()\n val As = List.fill(N)(sc.nextLong)\n val l = List.fill(M, 2)(sc.nextLong).map(a => (a.head.toInt, a.tail.head))\n\n val r = l.foldLeft(As){\n case (pre, (num, v))=>\n val s = pre.sorted\n val (less, remain) = s.splitAt(num)\n less.map(a => if (a < v) v else a) ::: remain\n }\n\n println(r.sum)\n }\n}", "language": "Scala", "metadata": {"date": 1558836303, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s121934185.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s121934185", "user_id": "u775137545"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.annotation.tailrec\n\nobject Main {\n def main(args: Array[String]) = {\n val sc = new Scanner(System.in)\n val N, M = sc.nextInt()\n val As = List.fill(N)(sc.nextLong)\n val l = List.fill(M, 2)(sc.nextLong).map(a => (a.head.toInt, a.tail.head))\n\n val r = l.foldLeft(As){\n case (pre, (num, v))=>\n val s = pre.sorted\n val (less, remain) = s.splitAt(num)\n less.map(a => if (a < v) v else a) ::: remain\n }\n\n println(r.sum)\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 158480}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s302453264", "group_id": "codeNet:p03041", "input_text": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n\n def solve(sc: => Scanner): Unit = {\n val _, K = sc.nextInt()\n val S = sc.next()\n println(S.take(K - 1) + S.charAt(K - 1).toLower + S.drop(K))\n }\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def calc(N: Long, R: Long, M: Long): Double = {\n math.sqrt(R * R - (R * 2 * ((M * 1.0 / N) - 0.5)) * (R * 2 * ((M * 1.0 / N) - 0.5))) * 2\n }\n\n var memo: Map[(Long, Long), Long] = Map[(Long, Long), Long]()\n\n def recursive(input: Long): Long = {\n if (input < 10) input else input % 10 + recursive(input / 10)\n }\n\n def recursive2(X: Set[Long], Y: Stream[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n\n def check(s: String): Boolean = {\n if (s == \"0\") true\n else s(0) != '0' && 0 <= s.toInt && s.toInt <= 255\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def primeFactors(i: Long): List[Long] = primeFactors_(i, 1).sorted\n\n\n def primeFactors_(i: Long, j: Long): List[Long] = {\n if (j * j > i) List.empty else if (i % j == 0) primeFactors_(i, j + 1) ++ List[Long](j, i / j) else primeFactors_(i, j + 1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n}\n", "language": "Scala", "metadata": {"date": 1558700807, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s302453264.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s302453264", "user_id": "u779353743"}, "prompt_components": {"gold_output": "aBC\n", "input_to_evaluate": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n\n def solve(sc: => Scanner): Unit = {\n val _, K = sc.nextInt()\n val S = sc.next()\n println(S.take(K - 1) + S.charAt(K - 1).toLower + S.drop(K))\n }\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def calc(N: Long, R: Long, M: Long): Double = {\n math.sqrt(R * R - (R * 2 * ((M * 1.0 / N) - 0.5)) * (R * 2 * ((M * 1.0 / N) - 0.5))) * 2\n }\n\n var memo: Map[(Long, Long), Long] = Map[(Long, Long), Long]()\n\n def recursive(input: Long): Long = {\n if (input < 10) input else input % 10 + recursive(input / 10)\n }\n\n def recursive2(X: Set[Long], Y: Stream[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n\n def check(s: String): Boolean = {\n if (s == \"0\") true\n else s(0) != '0' && 0 <= s.toInt && s.toInt <= 255\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def primeFactors(i: Long): List[Long] = primeFactors_(i, 1).sorted\n\n\n def primeFactors_(i: Long, j: Long): List[Long] = {\n if (j * j > i) List.empty else if (i % j == 0) primeFactors_(i, j + 1) ++ List[Long](j, i / j) else primeFactors_(i, j + 1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6416, "cpu_time_ms": 336, "memory_kb": 25544}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s253610723", "group_id": "codeNet:p03041", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val nk = sc.nextLine().split(\" \")\n val s = sc.nextLine()\n val t = nk(1).toInt-1\n\n println(s.updated(t, s(t).toUpper))\n }\n}\n", "language": "Scala", "metadata": {"date": 1558316217, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s253610723.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s253610723", "user_id": "u309467047"}, "prompt_components": {"gold_output": "aBC\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val nk = sc.nextLine().split(\" \")\n val s = sc.nextLine()\n val t = nk(1).toInt-1\n\n println(s.updated(t, s(t).toUpper))\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 347, "memory_kb": 25928}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s522681746", "group_id": "codeNet:p03041", "input_text": "object Main {\n\n def main(args: Array[String]): Unit = {\n import scala.io.StdIn._\n\n val Array(n, k) = readLine().split(\" \").map(_.toInt)\n val S = readLine()\n println(S.updated(k-1, S(k-1).toLower))\n }\n\n}", "language": "Scala", "metadata": {"date": 1558314235, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s522681746.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s522681746", "user_id": "u891387249"}, "prompt_components": {"gold_output": "aBC\n", "input_to_evaluate": "object Main {\n\n def main(args: Array[String]): Unit = {\n import scala.io.StdIn._\n\n val Array(n, k) = readLine().split(\" \").map(_.toInt)\n val S = readLine()\n println(S.updated(k-1, S(k-1).toLower))\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 216, "cpu_time_ms": 321, "memory_kb": 25536}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s292876806", "group_id": "codeNet:p03042", "input_text": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val N = sc.nextInt()\n val X: Int = N % 100;\n val Y: Int = N / 100;\n\n println(if (calc(X, Y) && calc(Y, X)) \"AMBIGUOUS\" else if (calc(X, Y)) \"YYMM\" else if (calc(Y, X)) \"MMYY\" else \"NA\")\n }\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def calc(S: Int, T: Int): Boolean = {\n S match {\n case 1 => 1 <= T && T <= 31\n case 2 => 1 <= T && T <= 29\n case 3 => 1 <= T && T <= 31\n case 4 => 1 <= T && T <= 30\n case 5 => 1 <= T && T <= 31\n case 6 => 1 <= T && T <= 30\n case 7 => 1 <= T && T <= 31\n case 8 => 1 <= T && T <= 31\n case 9 => 1 <= T && T <= 30\n case 10 => 1 <= T && T <= 31\n case 11 => 1 <= T && T <= 30\n case 12 => 1 <= T && T <= 31\n case _ => false\n }\n }\n\n var memo: Map[(Long, Long), Long] = Map[(Long, Long), Long]()\n\n def recursive(n: Long, k: Long): Long = {\n\n if (n == 1) k else recursive(n - 1, k) * k % 1000000007L\n }\n\n def recursive2(X: Set[Long], Y: Stream[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n\n def check(s: String): Boolean = {\n if (s == \"0\") true\n else s(0) != '0' && 0 <= s.toInt && s.toInt <= 255\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def primeFactors(i: Long): List[Long] = primeFactors_(i, 1).sorted\n\n\n def primeFactors_(i: Long, j: Long): List[Long] = {\n if (j * j > i) List.empty else if (i % j == 0) primeFactors_(i, j + 1) ++ List[Long](j, i / j) else primeFactors_(i, j + 1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n}\n", "language": "Scala", "metadata": {"date": 1560996784, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s292876806.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s292876806", "user_id": "u779353743"}, "prompt_components": {"gold_output": "YYMM\n", "input_to_evaluate": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val N = sc.nextInt()\n val X: Int = N % 100;\n val Y: Int = N / 100;\n\n println(if (calc(X, Y) && calc(Y, X)) \"AMBIGUOUS\" else if (calc(X, Y)) \"YYMM\" else if (calc(Y, X)) \"MMYY\" else \"NA\")\n }\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def calc(S: Int, T: Int): Boolean = {\n S match {\n case 1 => 1 <= T && T <= 31\n case 2 => 1 <= T && T <= 29\n case 3 => 1 <= T && T <= 31\n case 4 => 1 <= T && T <= 30\n case 5 => 1 <= T && T <= 31\n case 6 => 1 <= T && T <= 30\n case 7 => 1 <= T && T <= 31\n case 8 => 1 <= T && T <= 31\n case 9 => 1 <= T && T <= 30\n case 10 => 1 <= T && T <= 31\n case 11 => 1 <= T && T <= 30\n case 12 => 1 <= T && T <= 31\n case _ => false\n }\n }\n\n var memo: Map[(Long, Long), Long] = Map[(Long, Long), Long]()\n\n def recursive(n: Long, k: Long): Long = {\n\n if (n == 1) k else recursive(n - 1, k) * k % 1000000007L\n }\n\n def recursive2(X: Set[Long], Y: Stream[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n\n def check(s: String): Boolean = {\n if (s == \"0\") true\n else s(0) != '0' && 0 <= s.toInt && s.toInt <= 255\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def primeFactors(i: Long): List[Long] = primeFactors_(i, 1).sorted\n\n\n def primeFactors_(i: Long, j: Long): List[Long] = {\n if (j * j > i) List.empty else if (i % j == 0) primeFactors_(i, j + 1) ++ List[Long](j, i / j) else primeFactors_(i, j + 1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6850, "cpu_time_ms": 333, "memory_kb": 27212}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s135980593", "group_id": "codeNet:p03042", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val array = Array(\"YYMM\", \"MMYY\", \"AMBIGUOUS\", \"NA\")\n val sc = new java.util.Scanner(System.in)\n val nk = sc.nextLine()\n val f = nk.substring(0, 2)\n val l = nk.substring(2, 4)\n val fb = f.toInt >= 1 && f.toInt < 13\n val lb = l.toInt >= 1 && l.toInt < 13\n\n if (fb && lb) { println(array(2)) }\n else if (!fb && !lb){ println(array(3)) }\n else if (!fb && lb) { println(array(0)) }\n else if (fb && !lb) { println(array(1)) }\n }\n}", "language": "Scala", "metadata": {"date": 1558317565, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s135980593.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s135980593", "user_id": "u309467047"}, "prompt_components": {"gold_output": "YYMM\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val array = Array(\"YYMM\", \"MMYY\", \"AMBIGUOUS\", \"NA\")\n val sc = new java.util.Scanner(System.in)\n val nk = sc.nextLine()\n val f = nk.substring(0, 2)\n val l = nk.substring(2, 4)\n val fb = f.toInt >= 1 && f.toInt < 13\n val lb = l.toInt >= 1 && l.toInt < 13\n\n if (fb && lb) { println(array(2)) }\n else if (!fb && !lb){ println(array(3)) }\n else if (!fb && lb) { println(array(0)) }\n else if (fb && !lb) { println(array(1)) }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 343, "memory_kb": 25676}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s035522405", "group_id": "codeNet:p03044", "input_text": "import scala.collection.mutable.HashMap\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val N = sc.nextInt\n case class Edge(to: Int, d: Int)\n val tree = new HashMap[Int, Array[Edge]]()\n for (i <- 0 until N - 1) {\n val u = sc.nextInt - 1\n val v = sc.nextInt - 1\n val w = sc.nextInt\n if (tree.contains(u)) {\n tree(u) :+= Edge(v, w)\n } else {\n tree += u -> Array(Edge(v, w))\n }\n if (tree.contains(v)) {\n tree(v) :+= Edge(u, w)\n } else {\n tree += v -> Array(Edge(u, w))\n }\n }\n\n val colorMap = new HashMap[Int, Int]()\n\n def dfs(node: Int, depth: Int): Unit = {\n if (colorMap.contains(node)) {\n return\n } else {\n colorMap += node -> depth % 2\n }\n for (connected <- tree(node)) {\n dfs(connected.to, depth + connected.d)\n }\n }\n\n dfs(0, 0)\n\n for (i <- 0 until N) {\n println(colorMap(i))\n }\n }\n\n\n}", "language": "Scala", "metadata": {"date": 1561232234, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s035522405.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s035522405", "user_id": "u743229067"}, "prompt_components": {"gold_output": "0\n0\n1\n", "input_to_evaluate": "import scala.collection.mutable.HashMap\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val N = sc.nextInt\n case class Edge(to: Int, d: Int)\n val tree = new HashMap[Int, Array[Edge]]()\n for (i <- 0 until N - 1) {\n val u = sc.nextInt - 1\n val v = sc.nextInt - 1\n val w = sc.nextInt\n if (tree.contains(u)) {\n tree(u) :+= Edge(v, w)\n } else {\n tree += u -> Array(Edge(v, w))\n }\n if (tree.contains(v)) {\n tree(v) :+= Edge(u, w)\n } else {\n tree += v -> Array(Edge(u, w))\n }\n }\n\n val colorMap = new HashMap[Int, Int]()\n\n def dfs(node: Int, depth: Int): Unit = {\n if (colorMap.contains(node)) {\n return\n } else {\n colorMap += node -> depth % 2\n }\n for (connected <- tree(node)) {\n dfs(connected.to, depth + connected.d)\n }\n }\n\n dfs(0, 0)\n\n for (i <- 0 until N) {\n println(colorMap(i))\n }\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1001, "cpu_time_ms": 2119, "memory_kb": 127096}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s839605766", "group_id": "codeNet:p03044", "input_text": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val N = sc.nextInt()\n\n val distance = Array.fill(N, N)(-1L)\n\n (0 until N - 1).map { _ =>\n val u, v = sc.nextInt()\n val w = sc.nextLong()\n (u - 1, v - 1, w % 2)\n } foreach { e =>\n val (u, v, w) = e\n distance(u)(v) = w.toLong\n distance(v)(u) = w.toLong\n }\n\n val visited = new Array[Boolean](N)\n val color = new Array[Int](N)\n\n// def dfs(u: Int): Unit =\n// if (!visited(u)) {\n// visited(u) = true\n// (0 until N) foreach { v =>\n// if (distance(u)(v) == 0) {\n// color(v) = color(u)\n// dfs(v)\n// } else if (distance(u)(v) == 1) {\n// color(v) = 1 - color(u)\n// dfs(v)\n// }\n// }\n// }\n//\n// dfs(0)\n color.foreach(println)\n }\n\n}", "language": "Scala", "metadata": {"date": 1559198092, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s839605766.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s839605766", "user_id": "u891387249"}, "prompt_components": {"gold_output": "0\n0\n1\n", "input_to_evaluate": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val N = sc.nextInt()\n\n val distance = Array.fill(N, N)(-1L)\n\n (0 until N - 1).map { _ =>\n val u, v = sc.nextInt()\n val w = sc.nextLong()\n (u - 1, v - 1, w % 2)\n } foreach { e =>\n val (u, v, w) = e\n distance(u)(v) = w.toLong\n distance(v)(u) = w.toLong\n }\n\n val visited = new Array[Boolean](N)\n val color = new Array[Int](N)\n\n// def dfs(u: Int): Unit =\n// if (!visited(u)) {\n// visited(u) = true\n// (0 until N) foreach { v =>\n// if (distance(u)(v) == 0) {\n// color(v) = color(u)\n// dfs(v)\n// } else if (distance(u)(v) == 1) {\n// color(v) = 1 - color(u)\n// dfs(v)\n// }\n// }\n// }\n//\n// dfs(0)\n color.foreach(println)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 680, "memory_kb": 296004}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s890989293", "group_id": "codeNet:p03044", "input_text": "import java.util.Scanner\n\nimport scala.collection.mutable.ArrayBuffer\n\n\nobject Main {\n\n // u: from\n // v: to\n case class Edge(u: Int, v: Int, w: Long)\n\n def read() = {\n val sc = new Scanner(System.in)\n val n = sc.nextInt()\n val edges = IndexedSeq.fill(n-1)(Edge(sc.nextInt(), sc.nextInt(), sc.nextInt()))\n (n, edges)\n }\n\n def solve(n:Int, edges:IndexedSeq[Edge]): IndexedSeq[Int] = {\n val nextList = IndexedSeq.fill(n+1)(ArrayBuffer.empty[Edge])\n for(edge <- edges){\n val from = edge.u\n val to = edge.v\n nextList(from).append(edge)\n nextList(to).append(Edge(to, from, edge.w))\n }\n val visited = Array.fill(n+1)(false)\n // 1から\n visited(1) = true\n val open: java.util.Queue[Int] = new java.util.ArrayDeque[Int]()\n //add, remove\n open.add(1)\n //白:false ,黒:true\n val colors = Array.fill(n+1)(true)\n colors(1) = false\n\n\n while(!open.isEmpty){\n val current = open.remove()\n for(edge <- nextList(current)){\n val next = edge.v\n if(!visited(next)) {\n val w = edge.w\n if (w % 2 == 0) {\n colors(next) = colors(current)\n } else {\n colors(next) = !colors(current)\n }\n visited(next) = true\n open.add(next)\n }\n }\n }\n colors.takeRight(n).map(p => if(p) 1 else 0)\n }\n\n def main(args: Array[String]): Unit = {\n val (n, edges) = read()\n //println(solve(n, edges))\n solve(n,edges).foreach(println)\n }\n}", "language": "Scala", "metadata": {"date": 1558317166, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s890989293.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s890989293", "user_id": "u494788559"}, "prompt_components": {"gold_output": "0\n0\n1\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.collection.mutable.ArrayBuffer\n\n\nobject Main {\n\n // u: from\n // v: to\n case class Edge(u: Int, v: Int, w: Long)\n\n def read() = {\n val sc = new Scanner(System.in)\n val n = sc.nextInt()\n val edges = IndexedSeq.fill(n-1)(Edge(sc.nextInt(), sc.nextInt(), sc.nextInt()))\n (n, edges)\n }\n\n def solve(n:Int, edges:IndexedSeq[Edge]): IndexedSeq[Int] = {\n val nextList = IndexedSeq.fill(n+1)(ArrayBuffer.empty[Edge])\n for(edge <- edges){\n val from = edge.u\n val to = edge.v\n nextList(from).append(edge)\n nextList(to).append(Edge(to, from, edge.w))\n }\n val visited = Array.fill(n+1)(false)\n // 1から\n visited(1) = true\n val open: java.util.Queue[Int] = new java.util.ArrayDeque[Int]()\n //add, remove\n open.add(1)\n //白:false ,黒:true\n val colors = Array.fill(n+1)(true)\n colors(1) = false\n\n\n while(!open.isEmpty){\n val current = open.remove()\n for(edge <- nextList(current)){\n val next = edge.v\n if(!visited(next)) {\n val w = edge.w\n if (w % 2 == 0) {\n colors(next) = colors(current)\n } else {\n colors(next) = !colors(current)\n }\n visited(next) = true\n open.add(next)\n }\n }\n }\n colors.takeRight(n).map(p => if(p) 1 else 0)\n }\n\n def main(args: Array[String]): Unit = {\n val (n, edges) = read()\n //println(solve(n, edges))\n solve(n,edges).foreach(println)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1497, "cpu_time_ms": 1776, "memory_kb": 118980}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s318908973", "group_id": "codeNet:p03045", "input_text": "import java.util.Scanner\n\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n\n class UnionFind(val n: Int) {\n\n sealed trait Node\n\n final case class Root(count: Int, rank: Int) extends Node\n\n final case class NonRoot(parentIndex: Int) extends Node\n\n // TODO ArrayBufferではなくArrayでいいはず\n private val nodes: ArrayBuffer[Node] = ArrayBuffer.fill(n)(Root(count = 1, rank = 0))\n\n private def rootNode(index: Int): (Int, Root) = {\n nodes(index) match {\n case root: Root => (index, root) // nodes(index) == root\n case nonRoot: NonRoot =>\n val (rootIndex, root) = rootNode(nonRoot.parentIndex)\n nodes(index) = NonRoot(parentIndex = rootIndex) // 経路圧縮\n (rootIndex, root)\n }\n }\n\n def numComponents(): Int = nodes.count(p = node => node.isInstanceOf[Root])\n\n private def root(index: Int): Int = rootNode(index)._1\n\n def sameCount(x: Int): Int = rootNode(x)._2.count\n\n def same(x: Int, y: Int): Boolean = root(x) == root(y)\n\n\n def unite(x: Int, y: Int): Unit = {\n if (same(x, y)) return\n\n val (xRootIndex, xRoot) = rootNode(x)\n val (yRootIndex, yRoot) = rootNode(y)\n\n if (xRoot.rank < yRoot.rank) {\n // xRootの親をyRootとする\n nodes(xRootIndex) = NonRoot(parentIndex = yRootIndex)\n nodes(yRootIndex) = yRoot.copy(count = xRoot.count + yRoot.count)\n } else {\n // yRootの親をxRootとする\n nodes(yRootIndex) = NonRoot(parentIndex = xRootIndex)\n val nextXRootRank = xRoot.rank + (if (xRoot.rank == yRoot.rank) 1 else 0)\n nodes(xRootIndex) = Root(count = xRoot.count + yRoot.count, rank = nextXRootRank)\n }\n }\n\n }\n\n case class Magic(x: Int, y: Int, z: Long)\n\n case class NextInfo(v: Int, w: Long)\n\n def read() = {\n val sc = new Scanner(System.in)\n val n, m = sc.nextInt()\n // 0-index化\n val magics = IndexedSeq.fill(m)(\n Magic(sc.nextInt() - 1, sc.nextInt() - 1, sc.nextLong()))\n (n, m, magics)\n }\n\n\n def solve(n: Int, m: Int, magics: IndexedSeq[Magic]): Int = {\n val uf = new UnionFind(n)\n for (magic <- magics) {\n uf.unite(magic.x, magic.y)\n }\n uf.numComponents()\n }\n\n def main(args: Array[String]): Unit = {\n val (n, m, magics) = read()\n val result = solve(n, m, magics)\n println(result)\n }\n}", "language": "Scala", "metadata": {"date": 1584844846, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s318908973.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s318908973", "user_id": "u494788559"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n\n class UnionFind(val n: Int) {\n\n sealed trait Node\n\n final case class Root(count: Int, rank: Int) extends Node\n\n final case class NonRoot(parentIndex: Int) extends Node\n\n // TODO ArrayBufferではなくArrayでいいはず\n private val nodes: ArrayBuffer[Node] = ArrayBuffer.fill(n)(Root(count = 1, rank = 0))\n\n private def rootNode(index: Int): (Int, Root) = {\n nodes(index) match {\n case root: Root => (index, root) // nodes(index) == root\n case nonRoot: NonRoot =>\n val (rootIndex, root) = rootNode(nonRoot.parentIndex)\n nodes(index) = NonRoot(parentIndex = rootIndex) // 経路圧縮\n (rootIndex, root)\n }\n }\n\n def numComponents(): Int = nodes.count(p = node => node.isInstanceOf[Root])\n\n private def root(index: Int): Int = rootNode(index)._1\n\n def sameCount(x: Int): Int = rootNode(x)._2.count\n\n def same(x: Int, y: Int): Boolean = root(x) == root(y)\n\n\n def unite(x: Int, y: Int): Unit = {\n if (same(x, y)) return\n\n val (xRootIndex, xRoot) = rootNode(x)\n val (yRootIndex, yRoot) = rootNode(y)\n\n if (xRoot.rank < yRoot.rank) {\n // xRootの親をyRootとする\n nodes(xRootIndex) = NonRoot(parentIndex = yRootIndex)\n nodes(yRootIndex) = yRoot.copy(count = xRoot.count + yRoot.count)\n } else {\n // yRootの親をxRootとする\n nodes(yRootIndex) = NonRoot(parentIndex = xRootIndex)\n val nextXRootRank = xRoot.rank + (if (xRoot.rank == yRoot.rank) 1 else 0)\n nodes(xRootIndex) = Root(count = xRoot.count + yRoot.count, rank = nextXRootRank)\n }\n }\n\n }\n\n case class Magic(x: Int, y: Int, z: Long)\n\n case class NextInfo(v: Int, w: Long)\n\n def read() = {\n val sc = new Scanner(System.in)\n val n, m = sc.nextInt()\n // 0-index化\n val magics = IndexedSeq.fill(m)(\n Magic(sc.nextInt() - 1, sc.nextInt() - 1, sc.nextLong()))\n (n, m, magics)\n }\n\n\n def solve(n: Int, m: Int, magics: IndexedSeq[Magic]): Int = {\n val uf = new UnionFind(n)\n for (magic <- magics) {\n uf.unite(magic.x, magic.y)\n }\n uf.numComponents()\n }\n\n def main(args: Array[String]): Unit = {\n val (n, m, magics) = read()\n val result = solve(n, m, magics)\n println(result)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2346, "cpu_time_ms": 1082, "memory_kb": 112332}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s376819505", "group_id": "codeNet:p03048", "input_text": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val Array(r, g, b, n) = in.readLine.split(\" \").map(_.toInt)\n\n var cnt = 0\n for {\n i <- 0 to n/r\n j <- 0 to n/g\n k = n - r*i - g*j\n if 0 <= k\n } {\n if(k == 0 && r*i + g*j == n) {\n cnt += 1\n debug(i,j,k)\n }\n else if(k%b == 0 && (r*i + g*j + k) == n) {\n cnt += 1\n debug(i,j,k)\n }\n }\n\n val ans = cnt\n println(ans)\n\n def debug(any:Any*):Unit = {\n if(this.getClass.toString != \"class Main$\")\n println(any.mkString(\" \"))\n }\n}", "language": "Scala", "metadata": {"date": 1557626288, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s376819505.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s376819505", "user_id": "u217010036"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val Array(r, g, b, n) = in.readLine.split(\" \").map(_.toInt)\n\n var cnt = 0\n for {\n i <- 0 to n/r\n j <- 0 to n/g\n k = n - r*i - g*j\n if 0 <= k\n } {\n if(k == 0 && r*i + g*j == n) {\n cnt += 1\n debug(i,j,k)\n }\n else if(k%b == 0 && (r*i + g*j + k) == n) {\n cnt += 1\n debug(i,j,k)\n }\n }\n\n val ans = cnt\n println(ans)\n\n def debug(any:Any*):Unit = {\n if(this.getClass.toString != \"class Main$\")\n println(any.mkString(\" \"))\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 987, "memory_kb": 118632}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s986572139", "group_id": "codeNet:p03049", "input_text": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val in = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n val n = in.readLine().toInt\n val ss = Array.fill(n) {\n in.readLine()\n }\n\n var count = ss.foldLeft(0) {\n case (acc, s) => acc + s.foldLeft((0, false)) {\n case ((acc, stat), c) => if (c == 'A') {\n (acc, true)\n } else if (stat && c == 'B') {\n (acc + 1, false)\n } else {\n (acc, false)\n }\n }._1\n }\n\n var ab = ss.count(s => s.startsWith(\"B\") && s.endsWith(\"A\"))\n var a = ss.count(s => !s.startsWith(\"B\") && s.endsWith(\"A\"))\n var b = ss.count(s => s.startsWith(\"B\") && !s.endsWith(\"A\"))\n var continuous = true\n\n while (continuous) {\n if (a > 0 && ab > 0) {\n val diff = Math.min(ab, a)\n ab -= diff\n count += diff\n } else if (b > 0 && ab > 0) {\n val diff = Math.min(ab, b)\n ab -= diff\n count += diff\n } else if (ab > 1) {\n count += ab / 2\n ab = ab % 2\n } else if (a > 0 && b > 0) {\n val diff = Math.min(a, b)\n a -= diff\n b -= diff\n count += diff\n } else {\n continuous = false\n }\n }\n\n out.println(count)\n\n out.flush()\n }\n}\n", "language": "Scala", "metadata": {"date": 1585969532, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03049.html", "problem_id": "p03049", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03049/input.txt", "sample_output_relpath": "derived/input_output/data/p03049/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03049/Scala/s986572139.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s986572139", "user_id": "u178269371"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val in = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n val n = in.readLine().toInt\n val ss = Array.fill(n) {\n in.readLine()\n }\n\n var count = ss.foldLeft(0) {\n case (acc, s) => acc + s.foldLeft((0, false)) {\n case ((acc, stat), c) => if (c == 'A') {\n (acc, true)\n } else if (stat && c == 'B') {\n (acc + 1, false)\n } else {\n (acc, false)\n }\n }._1\n }\n\n var ab = ss.count(s => s.startsWith(\"B\") && s.endsWith(\"A\"))\n var a = ss.count(s => !s.startsWith(\"B\") && s.endsWith(\"A\"))\n var b = ss.count(s => s.startsWith(\"B\") && !s.endsWith(\"A\"))\n var continuous = true\n\n while (continuous) {\n if (a > 0 && ab > 0) {\n val diff = Math.min(ab, a)\n ab -= diff\n count += diff\n } else if (b > 0 && ab > 0) {\n val diff = Math.min(ab, b)\n ab -= diff\n count += diff\n } else if (ab > 1) {\n count += ab / 2\n ab = ab % 2\n } else if (a > 0 && b > 0) {\n val diff = Math.min(a, b)\n a -= diff\n b -= diff\n count += diff\n } else {\n continuous = false\n }\n }\n\n out.println(count)\n\n out.flush()\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nSnuke has N strings. The i-th string is s_i.\n\nLet us concatenate these strings into one string after arranging them in some order.\nFind the maximum possible number of occurrences of AB in the resulting string.\n\nConstraints\n\n1 \\leq N \\leq 10^{4}\n\n2 \\leq |s_i| \\leq 10\n\ns_i consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\n\\vdots\ns_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\nABCA\nXBAZ\nBAD\n\nSample Output 1\n\n2\n\nFor example, if we concatenate ABCA, BAD and XBAZ in this order, the resulting string ABCABADXBAZ has two occurrences of AB.\n\nSample Input 2\n\n9\nBEWPVCRWH\nZZNQYIJX\nBAVREA\nPA\nHJMYITEOX\nBCJHMRMNK\nBP\nQVFABZ\nPRGKSPUNA\n\nSample Output 2\n\n4\n\nSample Input 3\n\n7\nRABYBBE\nJOZ\nBMHQUVA\nBPA\nISU\nMCMABAOBHZ\nSZMEHMA\n\nSample Output 3\n\n4", "sample_input": "3\nABCA\nXBAZ\nBAD\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03049", "source_text": "Score : 400 points\n\nProblem Statement\n\nSnuke has N strings. The i-th string is s_i.\n\nLet us concatenate these strings into one string after arranging them in some order.\nFind the maximum possible number of occurrences of AB in the resulting string.\n\nConstraints\n\n1 \\leq N \\leq 10^{4}\n\n2 \\leq |s_i| \\leq 10\n\ns_i consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\n\\vdots\ns_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\nABCA\nXBAZ\nBAD\n\nSample Output 1\n\n2\n\nFor example, if we concatenate ABCA, BAD and XBAZ in this order, the resulting string ABCABADXBAZ has two occurrences of AB.\n\nSample Input 2\n\n9\nBEWPVCRWH\nZZNQYIJX\nBAVREA\nPA\nHJMYITEOX\nBCJHMRMNK\nBP\nQVFABZ\nPRGKSPUNA\n\nSample Output 2\n\n4\n\nSample Input 3\n\n7\nRABYBBE\nJOZ\nBMHQUVA\nBPA\nISU\nMCMABAOBHZ\nSZMEHMA\n\nSample Output 3\n\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1422, "cpu_time_ms": 542, "memory_kb": 32584}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s231794519", "group_id": "codeNet:p03049", "input_text": "object Main extends App {\n val in = scala.io.Source.stdin.getLines.toSeq\n val ls = in.tail\n val sub = ls.foldLeft(0L){ (a,e) =>\n val tmp = (0 until e.size-1).count(j => (e(j)=='A' && e(j+1)=='B'))\n //println(tmp)\n a + tmp\n }\n val fb = ls.count(_.head == 'B')\n val la = ls.count(_.last == 'A')\n val ret = sub + Math.min(fb, la)\n println(ret)\n}\n", "language": "Scala", "metadata": {"date": 1557626589, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03049.html", "problem_id": "p03049", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03049/input.txt", "sample_output_relpath": "derived/input_output/data/p03049/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03049/Scala/s231794519.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s231794519", "user_id": "u699236457"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n val in = scala.io.Source.stdin.getLines.toSeq\n val ls = in.tail\n val sub = ls.foldLeft(0L){ (a,e) =>\n val tmp = (0 until e.size-1).count(j => (e(j)=='A' && e(j+1)=='B'))\n //println(tmp)\n a + tmp\n }\n val fb = ls.count(_.head == 'B')\n val la = ls.count(_.last == 'A')\n val ret = sub + Math.min(fb, la)\n println(ret)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nSnuke has N strings. The i-th string is s_i.\n\nLet us concatenate these strings into one string after arranging them in some order.\nFind the maximum possible number of occurrences of AB in the resulting string.\n\nConstraints\n\n1 \\leq N \\leq 10^{4}\n\n2 \\leq |s_i| \\leq 10\n\ns_i consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\n\\vdots\ns_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\nABCA\nXBAZ\nBAD\n\nSample Output 1\n\n2\n\nFor example, if we concatenate ABCA, BAD and XBAZ in this order, the resulting string ABCABADXBAZ has two occurrences of AB.\n\nSample Input 2\n\n9\nBEWPVCRWH\nZZNQYIJX\nBAVREA\nPA\nHJMYITEOX\nBCJHMRMNK\nBP\nQVFABZ\nPRGKSPUNA\n\nSample Output 2\n\n4\n\nSample Input 3\n\n7\nRABYBBE\nJOZ\nBMHQUVA\nBPA\nISU\nMCMABAOBHZ\nSZMEHMA\n\nSample Output 3\n\n4", "sample_input": "3\nABCA\nXBAZ\nBAD\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03049", "source_text": "Score : 400 points\n\nProblem Statement\n\nSnuke has N strings. The i-th string is s_i.\n\nLet us concatenate these strings into one string after arranging them in some order.\nFind the maximum possible number of occurrences of AB in the resulting string.\n\nConstraints\n\n1 \\leq N \\leq 10^{4}\n\n2 \\leq |s_i| \\leq 10\n\ns_i consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\n\\vdots\ns_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\nABCA\nXBAZ\nBAD\n\nSample Output 1\n\n2\n\nFor example, if we concatenate ABCA, BAD and XBAZ in this order, the resulting string ABCABADXBAZ has two occurrences of AB.\n\nSample Input 2\n\n9\nBEWPVCRWH\nZZNQYIJX\nBAVREA\nPA\nHJMYITEOX\nBCJHMRMNK\nBP\nQVFABZ\nPRGKSPUNA\n\nSample Output 2\n\n4\n\nSample Input 3\n\n7\nRABYBBE\nJOZ\nBMHQUVA\nBPA\nISU\nMCMABAOBHZ\nSZMEHMA\n\nSample Output 3\n\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 360, "cpu_time_ms": 576, "memory_kb": 32308}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s524963730", "group_id": "codeNet:p03062", "input_text": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n //nextLineとnextを同時に使ったら死ぬ\n val sc = new Scanner(System.in)\n val n = sc.nextInt()\n val as = Array.fill(n)(sc.nextLong())\n\n val absArray = as.map(math.abs)\n val absMin = absArray.min\n val amountOfNegative = as.count(_ < 0)\n\n val ans = if (amountOfNegative % 2 == 0) {\n absArray.sum\n } else {\n absArray.sum - absMin * 2\n }\n\n println(ans)\n }\n\n def debug(args: Any*): Unit = {\n Console.err.println(args.mkString(\" \"))\n }\n}\n", "language": "Scala", "metadata": {"date": 1588126122, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s524963730.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s524963730", "user_id": "u336949031"}, "prompt_components": {"gold_output": "19\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n //nextLineとnextを同時に使ったら死ぬ\n val sc = new Scanner(System.in)\n val n = sc.nextInt()\n val as = Array.fill(n)(sc.nextLong())\n\n val absArray = as.map(math.abs)\n val absMin = absArray.min\n val amountOfNegative = as.count(_ < 0)\n\n val ans = if (amountOfNegative % 2 == 0) {\n absArray.sum\n } else {\n absArray.sum - absMin * 2\n }\n\n println(ans)\n }\n\n def debug(args: Any*): Unit = {\n Console.err.println(args.mkString(\" \"))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 572, "cpu_time_ms": 833, "memory_kb": 66484}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s019150416", "group_id": "codeNet:p03063", "input_text": "import scala.io.StdIn._\n\nobject Main extends App {\n val n = readInt\n val s = readLine.toString\n if (s.count(_ == '#') == 0)\n println(0)\n val ns = s.substring(s.indexOf('#'), s.length - 1)\n println(ns.count(_ == '.'))\n}", "language": "Scala", "metadata": {"date": 1559964056, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03063.html", "problem_id": "p03063", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03063/input.txt", "sample_output_relpath": "derived/input_output/data/p03063/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03063/Scala/s019150416.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s019150416", "user_id": "u689562091"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main extends App {\n val n = readInt\n val s = readLine.toString\n if (s.count(_ == '#') == 0)\n println(0)\n val ns = s.substring(s.indexOf('#'), s.length - 1)\n println(ns.count(_ == '.'))\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": "p03063", "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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 226, "cpu_time_ms": 423, "memory_kb": 29320}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s832055604", "group_id": "codeNet:p03063", "input_text": "object Main extends App {\n var a = readInt\n var get = readLine\n var sum = 0\n var check = 0\n if(a!=0){\n for(i <- 0 to get.size - 1){\n if(get(i) == '#') {\n check = 1\n } else if (check == 1 && get(i) != '#'){\n sum = sum + 1\n } else {\n check = 0\n }\n }\n }\n println(sum)\n}", "language": "Scala", "metadata": {"date": 1555813436, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03063.html", "problem_id": "p03063", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03063/input.txt", "sample_output_relpath": "derived/input_output/data/p03063/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03063/Scala/s832055604.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s832055604", "user_id": "u533688845"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main extends App {\n var a = readInt\n var get = readLine\n var sum = 0\n var check = 0\n if(a!=0){\n for(i <- 0 to get.size - 1){\n if(get(i) == '#') {\n check = 1\n } else if (check == 1 && get(i) != '#'){\n sum = sum + 1\n } else {\n check = 0\n }\n }\n }\n println(sum)\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": "p03063", "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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 302, "cpu_time_ms": 366, "memory_kb": 29288}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s116529863", "group_id": "codeNet:p03063", "input_text": "object Main{\n\tdef main(args:Array[String]){\n\t\tval s = new java.util.Scanner(System.in)\n\t\tval n = s.nextInt\n\t\tval t = s.next\n\t\tval b,w = Array.fill(n+2)(0)\n\n\t\tfor(i <- 0 to n - 1)\n\t\t\tb(i+1) = b(i) + (if(t.charAt(i) == '#') 1 else 0)\n\t\tfor(i <- n-1 to 0 by -1)\n\t\t\tw(i+1) = w(i+2) + (if(t.charAt(i) == '.') 1 else 0)\n\n\n//\t\tprintln(b.mkString(\" \"))\n//\t\tprintln(w.mkString(\" \"))\n\n\t\tprintln((0 to n).map(i=>b(i)+w(i+1)).min)\n\t}\n}", "language": "Scala", "metadata": {"date": 1555811473, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03063.html", "problem_id": "p03063", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03063/input.txt", "sample_output_relpath": "derived/input_output/data/p03063/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03063/Scala/s116529863.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s116529863", "user_id": "u059234158"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main{\n\tdef main(args:Array[String]){\n\t\tval s = new java.util.Scanner(System.in)\n\t\tval n = s.nextInt\n\t\tval t = s.next\n\t\tval b,w = Array.fill(n+2)(0)\n\n\t\tfor(i <- 0 to n - 1)\n\t\t\tb(i+1) = b(i) + (if(t.charAt(i) == '#') 1 else 0)\n\t\tfor(i <- n-1 to 0 by -1)\n\t\t\tw(i+1) = w(i+2) + (if(t.charAt(i) == '.') 1 else 0)\n\n\n//\t\tprintln(b.mkString(\" \"))\n//\t\tprintln(w.mkString(\" \"))\n\n\t\tprintln((0 to n).map(i=>b(i)+w(i+1)).min)\n\t}\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": "p03063", "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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 580, "memory_kb": 40308}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s745693042", "group_id": "codeNet:p03063", "input_text": "object Main{\n\tdef main(args:Array[String]){\n\t\tval s = new java.util.Scanner(System.in)\n\t\ts.nextInt\n\t\tval v = s.next\n\n\t\t//println(v.replaceFirst(\"^\\\\.+\",\"\"))\n\t\t//println(v.replaceFirst(\"#+$\",\"\"))\n\t\tprintln(math.min(\n\t\t\tv.replaceFirst(\"^\\\\.*\",\"\").toCharArray.count('.' ==),\n\t\t\tv.reverse.replaceFirst(\"^#*\",\"\").toCharArray.count('#' ==)\n\t\t))\n\t}\n}\n", "language": "Scala", "metadata": {"date": 1555810090, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03063.html", "problem_id": "p03063", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03063/input.txt", "sample_output_relpath": "derived/input_output/data/p03063/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03063/Scala/s745693042.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s745693042", "user_id": "u059234158"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main{\n\tdef main(args:Array[String]){\n\t\tval s = new java.util.Scanner(System.in)\n\t\ts.nextInt\n\t\tval v = s.next\n\n\t\t//println(v.replaceFirst(\"^\\\\.+\",\"\"))\n\t\t//println(v.replaceFirst(\"#+$\",\"\"))\n\t\tprintln(math.min(\n\t\t\tv.replaceFirst(\"^\\\\.*\",\"\").toCharArray.count('.' ==),\n\t\t\tv.reverse.replaceFirst(\"^#*\",\"\").toCharArray.count('#' ==)\n\t\t))\n\t}\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": "p03063", "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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 576, "memory_kb": 33124}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s925432428", "group_id": "codeNet:p03063", "input_text": "object Main extends App {\n var a = readInt\n var get = readLine\n var sum = 0\n var check = 0\n for(i <- 0 until get.size){\n if(get(i) == '#') {\n check = 1\n } else if (check == 1 && get(i) != '#'){\n sum = sum + 1\n } else {\n check = 0\n }\n }\n println(sum)\n}", "language": "Scala", "metadata": {"date": 1555810073, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03063.html", "problem_id": "p03063", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03063/input.txt", "sample_output_relpath": "derived/input_output/data/p03063/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03063/Scala/s925432428.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s925432428", "user_id": "u533688845"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main extends App {\n var a = readInt\n var get = readLine\n var sum = 0\n var check = 0\n for(i <- 0 until get.size){\n if(get(i) == '#') {\n check = 1\n } else if (check == 1 && get(i) != '#'){\n sum = sum + 1\n } else {\n check = 0\n }\n }\n println(sum)\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": "p03063", "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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 412, "memory_kb": 31196}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s330625509", "group_id": "codeNet:p03067", "input_text": "import scala.io._\nobject Main extends App {\n val Array(a, b, c) = StdIn.readLine.split(\" \").map(_.toInt)\n println(if ((a > c && c > b) || (a < c && c < b)) \"Yes\" else \"No\")\n}", "language": "Scala", "metadata": {"date": 1555809255, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03067.html", "problem_id": "p03067", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03067/input.txt", "sample_output_relpath": "derived/input_output/data/p03067/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03067/Scala/s330625509.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s330625509", "user_id": "u132324749"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.io._\nobject Main extends App {\n val Array(a, b, c) = StdIn.readLine.split(\" \").map(_.toInt)\n println(if ((a > c && c > b) || (a < c && c < b)) \"Yes\" else \"No\")\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively.\nPrint Yes if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print No otherwise.\n\nConstraints\n\n0\\leq A,B,C\\leq 100\n\nA, B and C are distinct integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint Yes if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print No otherwise.\n\nSample Input 1\n\n3 8 5\n\nSample Output 1\n\nYes\n\nWe pass the coordinate 5 on the straight way from the house at coordinate 3 to the house at coordinate 8.\n\nSample Input 2\n\n7 3 1\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n10 2 4\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n31 41 59\n\nSample Output 4\n\nNo", "sample_input": "3 8 5\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03067", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively.\nPrint Yes if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print No otherwise.\n\nConstraints\n\n0\\leq A,B,C\\leq 100\n\nA, B and C are distinct integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint Yes if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print No otherwise.\n\nSample Input 1\n\n3 8 5\n\nSample Output 1\n\nYes\n\nWe pass the coordinate 5 on the straight way from the house at coordinate 3 to the house at coordinate 8.\n\nSample Input 2\n\n7 3 1\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n10 2 4\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n31 41 59\n\nSample Output 4\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 331, "memory_kb": 26948}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s982725483", "group_id": "codeNet:p03067", "input_text": "import scala.io.StdIn\n\n\nobject Main extends App {\n\n val Array(a, b, c) = StdIn.readLine().split(\" \").map(_.toInt)\n\n def solve(A: Int, B: Int, C: Int): String = {\n if (a < c & b > c) {\n \"Yes\"\n } else if (a > c & b < c) {\n \"Yes\"\n } else {\n \"No\"\n }\n }\n\n println(solve(a, b, c))\n}\n \n\n\n", "language": "Scala", "metadata": {"date": 1555809107, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03067.html", "problem_id": "p03067", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03067/input.txt", "sample_output_relpath": "derived/input_output/data/p03067/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03067/Scala/s982725483.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s982725483", "user_id": "u258933429"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.io.StdIn\n\n\nobject Main extends App {\n\n val Array(a, b, c) = StdIn.readLine().split(\" \").map(_.toInt)\n\n def solve(A: Int, B: Int, C: Int): String = {\n if (a < c & b > c) {\n \"Yes\"\n } else if (a > c & b < c) {\n \"Yes\"\n } else {\n \"No\"\n }\n }\n\n println(solve(a, b, c))\n}\n \n\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively.\nPrint Yes if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print No otherwise.\n\nConstraints\n\n0\\leq A,B,C\\leq 100\n\nA, B and C are distinct integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint Yes if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print No otherwise.\n\nSample Input 1\n\n3 8 5\n\nSample Output 1\n\nYes\n\nWe pass the coordinate 5 on the straight way from the house at coordinate 3 to the house at coordinate 8.\n\nSample Input 2\n\n7 3 1\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n10 2 4\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n31 41 59\n\nSample Output 4\n\nNo", "sample_input": "3 8 5\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03067", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively.\nPrint Yes if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print No otherwise.\n\nConstraints\n\n0\\leq A,B,C\\leq 100\n\nA, B and C are distinct integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint Yes if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print No otherwise.\n\nSample Input 1\n\n3 8 5\n\nSample Output 1\n\nYes\n\nWe pass the coordinate 5 on the straight way from the house at coordinate 3 to the house at coordinate 8.\n\nSample Input 2\n\n7 3 1\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n10 2 4\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n31 41 59\n\nSample Output 4\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 325, "memory_kb": 25516}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s207941388", "group_id": "codeNet:p03068", "input_text": "object Main extends App {\n var n = scala.io.StdIn.readInt()\n var s = scala.io.StdIn.readLine()\n var k = scala.io.StdIn.readInt()\n\n val word = s.charAt(k - 1)\n val answer = s.map { c =>\n if (c == word) {\n c\n } else {\n \"*\"\n }\n }.mkString\n print(answer)\n}", "language": "Scala", "metadata": {"date": 1555809301, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03068.html", "problem_id": "p03068", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03068/input.txt", "sample_output_relpath": "derived/input_output/data/p03068/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03068/Scala/s207941388.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s207941388", "user_id": "u105921924"}, "prompt_components": {"gold_output": "*rr*r\n", "input_to_evaluate": "object Main extends App {\n var n = scala.io.StdIn.readInt()\n var s = scala.io.StdIn.readLine()\n var k = scala.io.StdIn.readInt()\n\n val word = s.charAt(k - 1)\n val answer = s.map { c =>\n if (c == word) {\n c\n } else {\n \"*\"\n }\n }.mkString\n print(answer)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of lowercase English letters, and an integer K.\nPrint the string obtained by replacing every character in S that differs from the K-th character of S, with *.\n\nConstraints\n\n1 \\leq K \\leq N\\leq 10\n\nS is a string of length N consisting of lowercase English letters.\n\nN and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\nK\n\nOutput\n\nPrint the string obtained by replacing every character in S that differs from the K-th character of S, with *.\n\nSample Input 1\n\n5\nerror\n2\n\nSample Output 1\n\n*rr*r\n\nThe second character of S is r. When we replace every character in error that differs from r with *, we get the string *rr*r.\n\nSample Input 2\n\n6\neleven\n5\n\nSample Output 2\n\ne*e*e*\n\nSample Input 3\n\n9\neducation\n7\n\nSample Output 3\n\n******i**", "sample_input": "5\nerror\n2\n"}, "reference_outputs": ["*rr*r\n"], "source_document_id": "p03068", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of lowercase English letters, and an integer K.\nPrint the string obtained by replacing every character in S that differs from the K-th character of S, with *.\n\nConstraints\n\n1 \\leq K \\leq N\\leq 10\n\nS is a string of length N consisting of lowercase English letters.\n\nN and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\nK\n\nOutput\n\nPrint the string obtained by replacing every character in S that differs from the K-th character of S, with *.\n\nSample Input 1\n\n5\nerror\n2\n\nSample Output 1\n\n*rr*r\n\nThe second character of S is r. When we replace every character in error that differs from r with *, we get the string *rr*r.\n\nSample Input 2\n\n6\neleven\n5\n\nSample Output 2\n\ne*e*e*\n\nSample Input 3\n\n9\neducation\n7\n\nSample Output 3\n\n******i**", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 349, "memory_kb": 25548}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s525876654", "group_id": "codeNet:p03069", "input_text": "import java.util.Collections\n\nimport scala.io.StdIn\n\nobject Main {\n def main(args: Array[String]) = {\n val N = StdIn.readInt\n val S = StdIn.readLine\n var whites = S.count(c => c == '.')\n var blacks = S.count(c => c == '#')\n\n var wCnt = 0\n var bCnt = 0\n var ans = Int.MaxValue\n for(i <- 0 until N) {\n if (S.charAt(i) == '.') {\n wCnt += 1\n }\n if (S.charAt(i) == '#') {\n bCnt += 1\n }\n ans = Math.min(ans, (whites - wCnt) + bCnt)\n }\n println(ans)\n\n }\n}\n", "language": "Scala", "metadata": {"date": 1589286305, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s525876654.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s525876654", "user_id": "u516438812"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.Collections\n\nimport scala.io.StdIn\n\nobject Main {\n def main(args: Array[String]) = {\n val N = StdIn.readInt\n val S = StdIn.readLine\n var whites = S.count(c => c == '.')\n var blacks = S.count(c => c == '#')\n\n var wCnt = 0\n var bCnt = 0\n var ans = Int.MaxValue\n for(i <- 0 until N) {\n if (S.charAt(i) == '.') {\n wCnt += 1\n }\n if (S.charAt(i) == '#') {\n bCnt += 1\n }\n ans = Math.min(ans, (whites - wCnt) + bCnt)\n }\n println(ans)\n\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 520, "cpu_time_ms": 441, "memory_kb": 31080}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s401818818", "group_id": "codeNet:p03069", "input_text": "object Main extends App {\n var n = scala.io.StdIn.readInt()\n var s = scala.io.StdIn.readLine()\n\n val firstIndexSharp = s.indexOf(\"#\")\n if(firstIndexSharp < 0) {\n print(0)\n } else {\n val countTarget = s.substring(firstIndexSharp, n)\n val whiteCount = countTarget.count(_ == '.')\n\n val lastIndexComma = countTarget.lastIndexOf(\".\")\n val countTarget2 = countTarget.substring(lastIndexComma + 1)\n var blackCount = countTarget2.count(_ == '#')\n\n if (whiteCount > blackCount) {\n print(blackCount)\n } else {\n print(whiteCount)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1555811323, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s401818818.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s401818818", "user_id": "u105921924"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main extends App {\n var n = scala.io.StdIn.readInt()\n var s = scala.io.StdIn.readLine()\n\n val firstIndexSharp = s.indexOf(\"#\")\n if(firstIndexSharp < 0) {\n print(0)\n } else {\n val countTarget = s.substring(firstIndexSharp, n)\n val whiteCount = countTarget.count(_ == '.')\n\n val lastIndexComma = countTarget.lastIndexOf(\".\")\n val countTarget2 = countTarget.substring(lastIndexComma + 1)\n var blackCount = countTarget2.count(_ == '#')\n\n if (whiteCount > blackCount) {\n print(blackCount)\n } else {\n print(whiteCount)\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 570, "cpu_time_ms": 406, "memory_kb": 31056}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s199806847", "group_id": "codeNet:p03071", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n var button_size = io.StdIn.readLine().split(\" \").map{_.toInt}\n var total_coin = 0\n\n (0 until 2).foreach { i =>\n if(button_size(0) > button_size(1)) {\n total_coin += button_size(0)\n button_size(0) -= 1\n }\n else {\n total_coin += button_size(1)\n button_size(1) -= 1\n }\n }\n println(total_coin)\n }\n}", "language": "Scala", "metadata": {"date": 1577439239, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s199806847.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s199806847", "user_id": "u888177577"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n var button_size = io.StdIn.readLine().split(\" \").map{_.toInt}\n var total_coin = 0\n\n (0 until 2).foreach { i =>\n if(button_size(0) > button_size(1)) {\n total_coin += button_size(0)\n button_size(0) -= 1\n }\n else {\n total_coin += button_size(1)\n button_size(1) -= 1\n }\n }\n println(total_coin)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 329, "memory_kb": 27204}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s504833566", "group_id": "codeNet:p03071", "input_text": "\nimport java.util.Scanner\n\nobject Main extends App {\n\n val sc = new Scanner(System.in)\n\n val a, b = sc.nextInt()\n\n if (a == b) {\n println(a + b)\n } else {\n val m = math.max(a, b)\n println(2 * m - 1)\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1555247656, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s504833566.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s504833566", "user_id": "u726872801"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "\nimport java.util.Scanner\n\nobject Main extends App {\n\n val sc = new Scanner(System.in)\n\n val a, b = sc.nextInt()\n\n if (a == b) {\n println(a + b)\n } else {\n val m = math.max(a, b)\n println(2 * m - 1)\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 338, "memory_kb": 27212}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s811779665", "group_id": "codeNet:p03073", "input_text": "object Main {\n\n // 隣り合うタイルの色を異なる色にする\n // 以下の4通りにする タイルの枚数は10^5,\n // S^2回で10^10なので不可,\n // SlogSなら10^6なので間に合う\n // 0101...01|0\n // 1010...10|1\n // 一回舐めて、最初が黒のパターンと最初が白のパターンで何回変更するかを調べる\n // O(2n)\n\n val Black = '0'\n val White = '1'\n\n def main(args: Array[String]): Unit = {\n import scala.io.StdIn._\n val S: List[Char] = readLine().toList\n\n // 最小を調べる\n def solve(): Int = {\n def change(color: Char): Char =\n if (color == Black) White else Black\n\n // 前が0なら今回は1にして,前が1なら今回は0にする\n @scala.annotation.tailrec\n def count(lst: List[Char], before: Char, acm: Int): Int =\n if (lst.isEmpty) acm\n else if (before == lst.head) count(lst.tail, change(lst.head), acm + 1)\n else count(lst.tail, lst.head, acm)\n\n Math.min(count(S.tail, S.head, 0), count(S.tail, change(S.head), 1))\n }\n\n println(solve())\n }\n\n}", "language": "Scala", "metadata": {"date": 1557272587, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03073.html", "problem_id": "p03073", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03073/input.txt", "sample_output_relpath": "derived/input_output/data/p03073/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03073/Scala/s811779665.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s811779665", "user_id": "u891387249"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main {\n\n // 隣り合うタイルの色を異なる色にする\n // 以下の4通りにする タイルの枚数は10^5,\n // S^2回で10^10なので不可,\n // SlogSなら10^6なので間に合う\n // 0101...01|0\n // 1010...10|1\n // 一回舐めて、最初が黒のパターンと最初が白のパターンで何回変更するかを調べる\n // O(2n)\n\n val Black = '0'\n val White = '1'\n\n def main(args: Array[String]): Unit = {\n import scala.io.StdIn._\n val S: List[Char] = readLine().toList\n\n // 最小を調べる\n def solve(): Int = {\n def change(color: Char): Char =\n if (color == Black) White else Black\n\n // 前が0なら今回は1にして,前が1なら今回は0にする\n @scala.annotation.tailrec\n def count(lst: List[Char], before: Char, acm: Int): Int =\n if (lst.isEmpty) acm\n else if (before == lst.head) count(lst.tail, change(lst.head), acm + 1)\n else count(lst.tail, lst.head, acm)\n\n Math.min(count(S.tail, S.head, 0), count(S.tail, change(S.head), 1))\n }\n\n println(solve())\n }\n\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nN tiles are arranged in a row from left to right. The initial color of each tile is represented by a string S of length N.\n\nThe i-th tile from the left is painted black if the i-th character of S is 0, and painted white if that character is 1.\n\nYou want to repaint some of the tiles black or white, so that any two adjacent tiles have different colors.\n\nAt least how many tiles need to be repainted to satisfy the condition?\n\nConstraints\n\n1 \\leq |S| \\leq 10^5\n\nS_i is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum number of tiles that need to be repainted to satisfy the condition.\n\nSample Input 1\n\n000\n\nSample Output 1\n\n1\n\nThe condition can be satisfied by repainting the middle tile white.\n\nSample Input 2\n\n10010010\n\nSample Output 2\n\n3\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "sample_input": "000\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03073", "source_text": "Score : 300 points\n\nProblem Statement\n\nN tiles are arranged in a row from left to right. The initial color of each tile is represented by a string S of length N.\n\nThe i-th tile from the left is painted black if the i-th character of S is 0, and painted white if that character is 1.\n\nYou want to repaint some of the tiles black or white, so that any two adjacent tiles have different colors.\n\nAt least how many tiles need to be repainted to satisfy the condition?\n\nConstraints\n\n1 \\leq |S| \\leq 10^5\n\nS_i is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum number of tiles that need to be repainted to satisfy the condition.\n\nSample Input 1\n\n000\n\nSample Output 1\n\n1\n\nThe condition can be satisfied by repainting the middle tile white.\n\nSample Input 2\n\n10010010\n\nSample Output 2\n\n3\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1092, "cpu_time_ms": 421, "memory_kb": 31492}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s183939457", "group_id": "codeNet:p03074", "input_text": "import scala.io.StdIn\nimport scala.math._\nimport scala.collection.mutable.ArrayBuffer\n\n\nobject Main {\n\n class Zero(var l: Int, var r: Int) {\n override def toString: String = s\"[$l,$r]\"\n }\n\n def main(args: Array[String]): Unit = {\n val Array(n: Int, k: Int) = StdIn.readLine.split(\" \").map(_.toInt)\n val as = StdIn.readLine.map(_ == '1')\n\n val B = ArrayBuffer[Zero]()\n B += new Zero(-1, -1) // Sentinel\n B += new Zero(-1, -1)\n\n REP(n) { i =>\n if (!as(i)) {\n if (B.last.l == -1) B.last.l = i\n B.last.r = i\n } else if (B.last.l != -1) {\n B += new Zero(-1, -1)\n }\n }\n if (B.last.l != -1) B += new Zero(-1, -1)\n B.last.l = n\n B.last.r = n\n\n debug(B.mkString(\" \"))\n\n var ans = 0\n REP(B.length - 1) { l =>\n val r = min(l + k + 1, B.length - 1)\n val len = B(r).l - 1 - (B(l).r + 1) + 1\n ans = max(ans, len)\n }\n println(ans)\n\n debug(n, k)\n as.foreach {i => debugNoNewline(i, \"\")}\n }\n\n def DEBUG(f: => Unit): Unit = {\n if (false) { f }\n }\n\n def debug(something: Any): Unit = DEBUG {\n System.err.println(something)\n }\n def debugNoNewline(something: Any): Unit = DEBUG {\n System.err.print(something)\n }\n\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while (i < N) { f(i); i += 1 }\n }\n\n}", "language": "Scala", "metadata": {"date": 1557955912, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s183939457.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s183939457", "user_id": "u055459962"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import scala.io.StdIn\nimport scala.math._\nimport scala.collection.mutable.ArrayBuffer\n\n\nobject Main {\n\n class Zero(var l: Int, var r: Int) {\n override def toString: String = s\"[$l,$r]\"\n }\n\n def main(args: Array[String]): Unit = {\n val Array(n: Int, k: Int) = StdIn.readLine.split(\" \").map(_.toInt)\n val as = StdIn.readLine.map(_ == '1')\n\n val B = ArrayBuffer[Zero]()\n B += new Zero(-1, -1) // Sentinel\n B += new Zero(-1, -1)\n\n REP(n) { i =>\n if (!as(i)) {\n if (B.last.l == -1) B.last.l = i\n B.last.r = i\n } else if (B.last.l != -1) {\n B += new Zero(-1, -1)\n }\n }\n if (B.last.l != -1) B += new Zero(-1, -1)\n B.last.l = n\n B.last.r = n\n\n debug(B.mkString(\" \"))\n\n var ans = 0\n REP(B.length - 1) { l =>\n val r = min(l + k + 1, B.length - 1)\n val len = B(r).l - 1 - (B(l).r + 1) + 1\n ans = max(ans, len)\n }\n println(ans)\n\n debug(n, k)\n as.foreach {i => debugNoNewline(i, \"\")}\n }\n\n def DEBUG(f: => Unit): Unit = {\n if (false) { f }\n }\n\n def debug(something: Any): Unit = DEBUG {\n System.err.println(something)\n }\n def debugNoNewline(something: Any): Unit = DEBUG {\n System.err.print(something)\n }\n\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while (i < N) { f(i); i += 1 }\n }\n\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1361, "cpu_time_ms": 1170, "memory_kb": 57848}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s182762535", "group_id": "codeNet:p03075", "input_text": "import java.util.Scanner\n\nimport scala.annotation.tailrec\n\nobject Main {\n def main(args: Array[String]) = {\n val sc = new Scanner(System.in)\n val antennas = List.fill(5)(sc.nextInt)\n val k = sc.nextInt()\n\n val isAccess = antennas.combinations(2).map{\n case List(a, b) => b - a\n }.forall(_ <= k)\n if (isAccess) println(\"Yay!\") else println(\":(\")\n }\n}\n", "language": "Scala", "metadata": {"date": 1554578169, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03075.html", "problem_id": "p03075", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03075/input.txt", "sample_output_relpath": "derived/input_output/data/p03075/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03075/Scala/s182762535.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s182762535", "user_id": "u775137545"}, "prompt_components": {"gold_output": "Yay!\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.annotation.tailrec\n\nobject Main {\n def main(args: Array[String]) = {\n val sc = new Scanner(System.in)\n val antennas = List.fill(5)(sc.nextInt)\n val k = sc.nextInt()\n\n val isAccess = antennas.combinations(2).map{\n case List(a, b) => b - a\n }.forall(_ <= k)\n if (isAccess) println(\"Yay!\") else println(\":(\")\n }\n}\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nIn AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.\n\nTwo antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.\n\nDetermine if there exists a pair of antennas that cannot communicate directly.\n\nHere, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.\n\nConstraints\n\na, b, c, d, e and k are integers between 0 and 123 (inclusive).\n\na < b < c < d < e\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\nb\nc\nd\ne\nk\n\nOutput\n\nPrint :( if there exists a pair of antennas that cannot communicate directly, and print Yay! if there is no such pair.\n\nSample Input 1\n\n1\n2\n4\n8\n9\n15\n\nSample Output 1\n\nYay!\n\nIn this case, there is no pair of antennas that cannot communicate directly, because:\n\nthe distance between A and B is 2 - 1 = 1\n\nthe distance between A and C is 4 - 1 = 3\n\nthe distance between A and D is 8 - 1 = 7\n\nthe distance between A and E is 9 - 1 = 8\n\nthe distance between B and C is 4 - 2 = 2\n\nthe distance between B and D is 8 - 2 = 6\n\nthe distance between B and E is 9 - 2 = 7\n\nthe distance between C and D is 8 - 4 = 4\n\nthe distance between C and E is 9 - 4 = 5\n\nthe distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is Yay!.\n\nSample Input 2\n\n15\n18\n26\n35\n36\n18\n\nSample Output 2\n\n:(\n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and exceeds 18, so they cannot communicate directly.\nThus, the correct output is :(.", "sample_input": "1\n2\n4\n8\n9\n15\n"}, "reference_outputs": ["Yay!\n"], "source_document_id": "p03075", "source_text": "Score: 100 points\n\nProblem Statement\n\nIn AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.\n\nTwo antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.\n\nDetermine if there exists a pair of antennas that cannot communicate directly.\n\nHere, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.\n\nConstraints\n\na, b, c, d, e and k are integers between 0 and 123 (inclusive).\n\na < b < c < d < e\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\nb\nc\nd\ne\nk\n\nOutput\n\nPrint :( if there exists a pair of antennas that cannot communicate directly, and print Yay! if there is no such pair.\n\nSample Input 1\n\n1\n2\n4\n8\n9\n15\n\nSample Output 1\n\nYay!\n\nIn this case, there is no pair of antennas that cannot communicate directly, because:\n\nthe distance between A and B is 2 - 1 = 1\n\nthe distance between A and C is 4 - 1 = 3\n\nthe distance between A and D is 8 - 1 = 7\n\nthe distance between A and E is 9 - 1 = 8\n\nthe distance between B and C is 4 - 2 = 2\n\nthe distance between B and D is 8 - 2 = 6\n\nthe distance between B and E is 9 - 2 = 7\n\nthe distance between C and D is 8 - 4 = 4\n\nthe distance between C and E is 9 - 4 = 5\n\nthe distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is Yay!.\n\nSample Input 2\n\n15\n18\n26\n35\n36\n18\n\nSample Output 2\n\n:(\n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and exceeds 18, so they cannot communicate directly.\nThus, the correct output is :(.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 366, "memory_kb": 25820}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s588870193", "group_id": "codeNet:p03075", "input_text": "object Main extends App {\n\n val a = io.StdIn.readLine.toInt\n val b = io.StdIn.readLine.toInt\n val c = io.StdIn.readLine.toInt\n val d = io.StdIn.readLine.toInt\n val e = io.StdIn.readLine.toInt\n val k = io.StdIn.readLine.toInt\n\n val s = Seq(a,b,c,d,e)\n\n var isNG = false\n for (i <- 0 until s.size ; j <- i+1 until s.size) {\n if (s(j) - s(i) > k) isNG = true\n }\n\n if (isNG)\n println(\":(\")\n else\n println(\"Yay!\")\n}\n", "language": "Scala", "metadata": {"date": 1554577797, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03075.html", "problem_id": "p03075", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03075/input.txt", "sample_output_relpath": "derived/input_output/data/p03075/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03075/Scala/s588870193.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s588870193", "user_id": "u620456020"}, "prompt_components": {"gold_output": "Yay!\n", "input_to_evaluate": "object Main extends App {\n\n val a = io.StdIn.readLine.toInt\n val b = io.StdIn.readLine.toInt\n val c = io.StdIn.readLine.toInt\n val d = io.StdIn.readLine.toInt\n val e = io.StdIn.readLine.toInt\n val k = io.StdIn.readLine.toInt\n\n val s = Seq(a,b,c,d,e)\n\n var isNG = false\n for (i <- 0 until s.size ; j <- i+1 until s.size) {\n if (s(j) - s(i) > k) isNG = true\n }\n\n if (isNG)\n println(\":(\")\n else\n println(\"Yay!\")\n}\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nIn AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.\n\nTwo antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.\n\nDetermine if there exists a pair of antennas that cannot communicate directly.\n\nHere, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.\n\nConstraints\n\na, b, c, d, e and k are integers between 0 and 123 (inclusive).\n\na < b < c < d < e\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\nb\nc\nd\ne\nk\n\nOutput\n\nPrint :( if there exists a pair of antennas that cannot communicate directly, and print Yay! if there is no such pair.\n\nSample Input 1\n\n1\n2\n4\n8\n9\n15\n\nSample Output 1\n\nYay!\n\nIn this case, there is no pair of antennas that cannot communicate directly, because:\n\nthe distance between A and B is 2 - 1 = 1\n\nthe distance between A and C is 4 - 1 = 3\n\nthe distance between A and D is 8 - 1 = 7\n\nthe distance between A and E is 9 - 1 = 8\n\nthe distance between B and C is 4 - 2 = 2\n\nthe distance between B and D is 8 - 2 = 6\n\nthe distance between B and E is 9 - 2 = 7\n\nthe distance between C and D is 8 - 4 = 4\n\nthe distance between C and E is 9 - 4 = 5\n\nthe distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is Yay!.\n\nSample Input 2\n\n15\n18\n26\n35\n36\n18\n\nSample Output 2\n\n:(\n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and exceeds 18, so they cannot communicate directly.\nThus, the correct output is :(.", "sample_input": "1\n2\n4\n8\n9\n15\n"}, "reference_outputs": ["Yay!\n"], "source_document_id": "p03075", "source_text": "Score: 100 points\n\nProblem Statement\n\nIn AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.\n\nTwo antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.\n\nDetermine if there exists a pair of antennas that cannot communicate directly.\n\nHere, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.\n\nConstraints\n\na, b, c, d, e and k are integers between 0 and 123 (inclusive).\n\na < b < c < d < e\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\nb\nc\nd\ne\nk\n\nOutput\n\nPrint :( if there exists a pair of antennas that cannot communicate directly, and print Yay! if there is no such pair.\n\nSample Input 1\n\n1\n2\n4\n8\n9\n15\n\nSample Output 1\n\nYay!\n\nIn this case, there is no pair of antennas that cannot communicate directly, because:\n\nthe distance between A and B is 2 - 1 = 1\n\nthe distance between A and C is 4 - 1 = 3\n\nthe distance between A and D is 8 - 1 = 7\n\nthe distance between A and E is 9 - 1 = 8\n\nthe distance between B and C is 4 - 2 = 2\n\nthe distance between B and D is 8 - 2 = 6\n\nthe distance between B and E is 9 - 2 = 7\n\nthe distance between C and D is 8 - 4 = 4\n\nthe distance between C and E is 9 - 4 = 5\n\nthe distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is Yay!.\n\nSample Input 2\n\n15\n18\n26\n35\n36\n18\n\nSample Output 2\n\n:(\n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and exceeds 18, so they cannot communicate directly.\nThus, the correct output is :(.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 321, "memory_kb": 27072}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s622704074", "group_id": "codeNet:p03076", "input_text": "import scala.math.ceil\n\nobject Main extends App {\n\n val sc = new java.util.Scanner(System.in) \n val t = Array.fill(5)(sc.nextInt())\n val last = t.map(x => x % 10).filter(x => x != 0).min\n val up = t.map(x => (ceil(x.toDouble / 10) * 10).toInt).sum\n println(up - (10 - last))\n}", "language": "Scala", "metadata": {"date": 1598903491, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s622704074.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s622704074", "user_id": "u396472025"}, "prompt_components": {"gold_output": "215\n", "input_to_evaluate": "import scala.math.ceil\n\nobject Main extends App {\n\n val sc = new java.util.Scanner(System.in) \n val t = Array.fill(5)(sc.nextInt())\n val last = t.map(x => x % 10).filter(x => x != 0).min\n val up = t.map(x => (ceil(x.toDouble / 10) * 10).toInt).sum\n println(up - (10 - last))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 281, "cpu_time_ms": 513, "memory_kb": 55848}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s592205976", "group_id": "codeNet:p03076", "input_text": "import scala.io.StdIn._\n\nobject Main extends App {\n\n val D = Array.fill(5)(readInt())\n\n def solve() = {\n val lastDishIndex = D.zipWithIndex.collect {\n case (minutes, i) if minutes % 10 != 0 => (minutes % 10, i)\n }.sortBy(_._1).map(_._2).headOption\n lastDishIndex match {\n case None => D.sum\n case Some(idx) => {\n D.zipWithIndex.foldLeft(0) { case (acc, (minutes, i)) =>\n if(i == idx) acc + D(i)\n else acc + D(i) + losTime(D(i))\n }\n }\n }\n }\n\n def losTime(t: Int): Int = {\n if(t % 10 == 0) 0\n else 10 - (t % 10)\n }\n\n println(solve())\n\n}\n\n", "language": "Scala", "metadata": {"date": 1595539234, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s592205976.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s592205976", "user_id": "u947008426"}, "prompt_components": {"gold_output": "215\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main extends App {\n\n val D = Array.fill(5)(readInt())\n\n def solve() = {\n val lastDishIndex = D.zipWithIndex.collect {\n case (minutes, i) if minutes % 10 != 0 => (minutes % 10, i)\n }.sortBy(_._1).map(_._2).headOption\n lastDishIndex match {\n case None => D.sum\n case Some(idx) => {\n D.zipWithIndex.foldLeft(0) { case (acc, (minutes, i)) =>\n if(i == idx) acc + D(i)\n else acc + D(i) + losTime(D(i))\n }\n }\n }\n }\n\n def losTime(t: Int): Int = {\n if(t % 10 == 0) 0\n else 10 - (t % 10)\n }\n\n println(solve())\n\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 493, "memory_kb": 54920}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s110553826", "group_id": "codeNet:p03076", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n var cuisine_list = Vector.empty[Int]\n cuisine_list = cuisine_list :+ io.StdIn.readInt()\n cuisine_list = cuisine_list :+ io.StdIn.readInt()\n cuisine_list = cuisine_list :+ io.StdIn.readInt()\n cuisine_list = cuisine_list :+ io.StdIn.readInt()\n cuisine_list = cuisine_list :+ io.StdIn.readInt()\n var sum_time = 0\n var min_last_time = 100\n\n (0 until cuisine_list.length).foreach { i =>\n val last_time = cuisine_list(i)%10\n if(last_time < min_last_time && last_time != 0) min_last_time = last_time\n sum_time += (cuisine_list(i)/10.0 + 0.9).toInt*10\n }\n if(min_last_time == 100) min_last_time = 0\n println(sum_time - 10 + min_last_time)\n\n }\n}", "language": "Scala", "metadata": {"date": 1577150017, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s110553826.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s110553826", "user_id": "u888177577"}, "prompt_components": {"gold_output": "215\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n var cuisine_list = Vector.empty[Int]\n cuisine_list = cuisine_list :+ io.StdIn.readInt()\n cuisine_list = cuisine_list :+ io.StdIn.readInt()\n cuisine_list = cuisine_list :+ io.StdIn.readInt()\n cuisine_list = cuisine_list :+ io.StdIn.readInt()\n cuisine_list = cuisine_list :+ io.StdIn.readInt()\n var sum_time = 0\n var min_last_time = 100\n\n (0 until cuisine_list.length).foreach { i =>\n val last_time = cuisine_list(i)%10\n if(last_time < min_last_time && last_time != 0) min_last_time = last_time\n sum_time += (cuisine_list(i)/10.0 + 0.9).toInt*10\n }\n if(min_last_time == 100) min_last_time = 0\n println(sum_time - 10 + min_last_time)\n\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 317, "memory_kb": 25420}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s112179594", "group_id": "codeNet:p03076", "input_text": "import java.util.Scanner\n\nobject Main {\n val sc = new Scanner(System.in)\n def main(args: Array[String]): Unit = {\n val ts = List.fill(5)(sc.nextInt)\n val rm = ts.map(_ % 10).filter(_ != 0)\n val r = if(rm.nonEmpty) rm.min else 0\n\n val res = ts.map(t => (t+ 9)/10 * 10).sum - 10 + r\n\n println(res)\n\n }\n}", "language": "Scala", "metadata": {"date": 1554577987, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s112179594.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s112179594", "user_id": "u829407811"}, "prompt_components": {"gold_output": "215\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n val sc = new Scanner(System.in)\n def main(args: Array[String]): Unit = {\n val ts = List.fill(5)(sc.nextInt)\n val rm = ts.map(_ % 10).filter(_ != 0)\n val r = if(rm.nonEmpty) rm.min else 0\n\n val res = ts.map(t => (t+ 9)/10 * 10).sum - 10 + r\n\n println(res)\n\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 320, "cpu_time_ms": 352, "memory_kb": 26024}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s969665630", "group_id": "codeNet:p03077", "input_text": "object Main extends App {\n var count = readLong\n var a = List(readLong,readLong,readLong,readLong,readLong)\n if(count % a.min != 0)\n \tprintln(count / a.min + 5)\n else\n \tprintln(count / a.min + 4)\n}", "language": "Scala", "metadata": {"date": 1554591071, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03077.html", "problem_id": "p03077", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03077/input.txt", "sample_output_relpath": "derived/input_output/data/p03077/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03077/Scala/s969665630.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s969665630", "user_id": "u533688845"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "object Main extends App {\n var count = readLong\n var a = List(readLong,readLong,readLong,readLong,readLong)\n if(count % a.min != 0)\n \tprintln(count / a.min + 5)\n else\n \tprintln(count / a.min + 4)\n}", "problem_context": "Score: 300 points\n\nProblem Statement\n\nIn 2028 and after a continuous growth, AtCoder Inc. finally built an empire with six cities (City 1, 2, 3, 4, 5, 6)!\n\nThere are five means of transport in this empire:\n\nTrain: travels from City 1 to 2 in one minute. A train can occupy at most A people.\n\nBus: travels from City 2 to 3 in one minute. A bus can occupy at most B people.\n\nTaxi: travels from City 3 to 4 in one minute. A taxi can occupy at most C people.\n\nAirplane: travels from City 4 to 5 in one minute. An airplane can occupy at most D people.\n\nShip: travels from City 5 to 6 in one minute. A ship can occupy at most E people.\n\nFor each of them, one vehicle leaves the city at each integer time (time 0, 1, 2, ...).\n\nThere is a group of N people at City 1, and they all want to go to City 6.\n\nAt least how long does it take for all of them to reach there?\nYou can ignore the time needed to transfer.\n\nConstraints\n\n1 \\leq N, A, B, C, D, E \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the minimum time required for all of the people to reach City 6, in minutes.\n\nSample Input 1\n\n5\n3\n2\n4\n3\n5\n\nSample Output 1\n\n7\n\nOne possible way to travel is as follows.\nFirst, there are N = 5 people at City 1, as shown in the following image:\n\nIn the first minute, three people travels from City 1 to City 2 by train. Note that a train can only occupy at most three people.\n\nIn the second minute, the remaining two people travels from City 1 to City 2 by train, and two of the three people who were already at City 2 travels to City 3 by bus. Note that a bus can only occupy at most two people.\n\nIn the third minute, two people travels from City 2 to City 3 by train, and another two people travels from City 3 to City 4 by taxi.\n\nFrom then on, if they continue traveling without stopping until they reach City 6, all of them can reach there in seven minutes.\n\nThere is no way for them to reach City 6 in 6 minutes or less.\n\nSample Input 2\n\n10\n123\n123\n123\n123\n123\n\nSample Output 2\n\n5\n\nAll kinds of vehicles can occupy N = 10 people at a time.\nThus, if they continue traveling without stopping until they reach City 6, all of them can reach there in five minutes.\n\nSample Input 3\n\n10000000007\n2\n3\n5\n7\n11\n\nSample Output 3\n\n5000000008\n\nNote that the input or output may not fit into a 32-bit integer type.", "sample_input": "5\n3\n2\n4\n3\n5\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03077", "source_text": "Score: 300 points\n\nProblem Statement\n\nIn 2028 and after a continuous growth, AtCoder Inc. finally built an empire with six cities (City 1, 2, 3, 4, 5, 6)!\n\nThere are five means of transport in this empire:\n\nTrain: travels from City 1 to 2 in one minute. A train can occupy at most A people.\n\nBus: travels from City 2 to 3 in one minute. A bus can occupy at most B people.\n\nTaxi: travels from City 3 to 4 in one minute. A taxi can occupy at most C people.\n\nAirplane: travels from City 4 to 5 in one minute. An airplane can occupy at most D people.\n\nShip: travels from City 5 to 6 in one minute. A ship can occupy at most E people.\n\nFor each of them, one vehicle leaves the city at each integer time (time 0, 1, 2, ...).\n\nThere is a group of N people at City 1, and they all want to go to City 6.\n\nAt least how long does it take for all of them to reach there?\nYou can ignore the time needed to transfer.\n\nConstraints\n\n1 \\leq N, A, B, C, D, E \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the minimum time required for all of the people to reach City 6, in minutes.\n\nSample Input 1\n\n5\n3\n2\n4\n3\n5\n\nSample Output 1\n\n7\n\nOne possible way to travel is as follows.\nFirst, there are N = 5 people at City 1, as shown in the following image:\n\nIn the first minute, three people travels from City 1 to City 2 by train. Note that a train can only occupy at most three people.\n\nIn the second minute, the remaining two people travels from City 1 to City 2 by train, and two of the three people who were already at City 2 travels to City 3 by bus. Note that a bus can only occupy at most two people.\n\nIn the third minute, two people travels from City 2 to City 3 by train, and another two people travels from City 3 to City 4 by taxi.\n\nFrom then on, if they continue traveling without stopping until they reach City 6, all of them can reach there in seven minutes.\n\nThere is no way for them to reach City 6 in 6 minutes or less.\n\nSample Input 2\n\n10\n123\n123\n123\n123\n123\n\nSample Output 2\n\n5\n\nAll kinds of vehicles can occupy N = 10 people at a time.\nThus, if they continue traveling without stopping until they reach City 6, all of them can reach there in five minutes.\n\nSample Input 3\n\n10000000007\n2\n3\n5\n7\n11\n\nSample Output 3\n\n5000000008\n\nNote that the input or output may not fit into a 32-bit integer type.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 203, "cpu_time_ms": 353, "memory_kb": 25288}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s630905008", "group_id": "codeNet:p03077", "input_text": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]) {\n val result = solve(new Scanner(System.in))\n if (result.length > 0) println(result)\n }\n\n def solve(in: String): String = solve(new Scanner(in))\n\n def solve(sc: Scanner): String = {\n val N = sc.nextLong\n val ABCDE = Array.fill(5)(sc.nextInt)\n\n val min = ABCDE.min\n val minIdx = ABCDE.indexOf(min)\n val a = ((N + (min - 1)) / min) + (4 - minIdx) + minIdx\n a.toString\n }\n}\n", "language": "Scala", "metadata": {"date": 1554579643, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03077.html", "problem_id": "p03077", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03077/input.txt", "sample_output_relpath": "derived/input_output/data/p03077/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03077/Scala/s630905008.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s630905008", "user_id": "u297767059"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]) {\n val result = solve(new Scanner(System.in))\n if (result.length > 0) println(result)\n }\n\n def solve(in: String): String = solve(new Scanner(in))\n\n def solve(sc: Scanner): String = {\n val N = sc.nextLong\n val ABCDE = Array.fill(5)(sc.nextInt)\n\n val min = ABCDE.min\n val minIdx = ABCDE.indexOf(min)\n val a = ((N + (min - 1)) / min) + (4 - minIdx) + minIdx\n a.toString\n }\n}\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nIn 2028 and after a continuous growth, AtCoder Inc. finally built an empire with six cities (City 1, 2, 3, 4, 5, 6)!\n\nThere are five means of transport in this empire:\n\nTrain: travels from City 1 to 2 in one minute. A train can occupy at most A people.\n\nBus: travels from City 2 to 3 in one minute. A bus can occupy at most B people.\n\nTaxi: travels from City 3 to 4 in one minute. A taxi can occupy at most C people.\n\nAirplane: travels from City 4 to 5 in one minute. An airplane can occupy at most D people.\n\nShip: travels from City 5 to 6 in one minute. A ship can occupy at most E people.\n\nFor each of them, one vehicle leaves the city at each integer time (time 0, 1, 2, ...).\n\nThere is a group of N people at City 1, and they all want to go to City 6.\n\nAt least how long does it take for all of them to reach there?\nYou can ignore the time needed to transfer.\n\nConstraints\n\n1 \\leq N, A, B, C, D, E \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the minimum time required for all of the people to reach City 6, in minutes.\n\nSample Input 1\n\n5\n3\n2\n4\n3\n5\n\nSample Output 1\n\n7\n\nOne possible way to travel is as follows.\nFirst, there are N = 5 people at City 1, as shown in the following image:\n\nIn the first minute, three people travels from City 1 to City 2 by train. Note that a train can only occupy at most three people.\n\nIn the second minute, the remaining two people travels from City 1 to City 2 by train, and two of the three people who were already at City 2 travels to City 3 by bus. Note that a bus can only occupy at most two people.\n\nIn the third minute, two people travels from City 2 to City 3 by train, and another two people travels from City 3 to City 4 by taxi.\n\nFrom then on, if they continue traveling without stopping until they reach City 6, all of them can reach there in seven minutes.\n\nThere is no way for them to reach City 6 in 6 minutes or less.\n\nSample Input 2\n\n10\n123\n123\n123\n123\n123\n\nSample Output 2\n\n5\n\nAll kinds of vehicles can occupy N = 10 people at a time.\nThus, if they continue traveling without stopping until they reach City 6, all of them can reach there in five minutes.\n\nSample Input 3\n\n10000000007\n2\n3\n5\n7\n11\n\nSample Output 3\n\n5000000008\n\nNote that the input or output may not fit into a 32-bit integer type.", "sample_input": "5\n3\n2\n4\n3\n5\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03077", "source_text": "Score: 300 points\n\nProblem Statement\n\nIn 2028 and after a continuous growth, AtCoder Inc. finally built an empire with six cities (City 1, 2, 3, 4, 5, 6)!\n\nThere are five means of transport in this empire:\n\nTrain: travels from City 1 to 2 in one minute. A train can occupy at most A people.\n\nBus: travels from City 2 to 3 in one minute. A bus can occupy at most B people.\n\nTaxi: travels from City 3 to 4 in one minute. A taxi can occupy at most C people.\n\nAirplane: travels from City 4 to 5 in one minute. An airplane can occupy at most D people.\n\nShip: travels from City 5 to 6 in one minute. A ship can occupy at most E people.\n\nFor each of them, one vehicle leaves the city at each integer time (time 0, 1, 2, ...).\n\nThere is a group of N people at City 1, and they all want to go to City 6.\n\nAt least how long does it take for all of them to reach there?\nYou can ignore the time needed to transfer.\n\nConstraints\n\n1 \\leq N, A, B, C, D, E \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the minimum time required for all of the people to reach City 6, in minutes.\n\nSample Input 1\n\n5\n3\n2\n4\n3\n5\n\nSample Output 1\n\n7\n\nOne possible way to travel is as follows.\nFirst, there are N = 5 people at City 1, as shown in the following image:\n\nIn the first minute, three people travels from City 1 to City 2 by train. Note that a train can only occupy at most three people.\n\nIn the second minute, the remaining two people travels from City 1 to City 2 by train, and two of the three people who were already at City 2 travels to City 3 by bus. Note that a bus can only occupy at most two people.\n\nIn the third minute, two people travels from City 2 to City 3 by train, and another two people travels from City 3 to City 4 by taxi.\n\nFrom then on, if they continue traveling without stopping until they reach City 6, all of them can reach there in seven minutes.\n\nThere is no way for them to reach City 6 in 6 minutes or less.\n\nSample Input 2\n\n10\n123\n123\n123\n123\n123\n\nSample Output 2\n\n5\n\nAll kinds of vehicles can occupy N = 10 people at a time.\nThus, if they continue traveling without stopping until they reach City 6, all of them can reach there in five minutes.\n\nSample Input 3\n\n10000000007\n2\n3\n5\n7\n11\n\nSample Output 3\n\n5000000008\n\nNote that the input or output may not fit into a 32-bit integer type.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 472, "cpu_time_ms": 368, "memory_kb": 26056}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s655463545", "group_id": "codeNet:p03078", "input_text": "import scala.collection.mutable.ArrayBuffer\n\nobject Scanner {\n private val buf = new Array[Byte](1024);\n private var ptr = 0;\n private var len = 0\n\n @inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126\n\n @inline private def hasNextByte(): Boolean =\n if (ptr >= len) {\n ptr = 0; len = System.in.read(buf); len > 0\n } else {\n true\n }\n\n @inline private def hasNext(): Boolean = {\n while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1\n hasNextByte()\n }\n\n @inline private def readByte(): Byte =\n if (hasNextByte()) {\n val res = buf(ptr); ptr += 1; res\n } else {\n -1\n }\n\n def next(): String = {\n if (!hasNext()) ???\n val sb = new StringBuilder;\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.append(b.toChar); b = readByte()\n }\n sb.toString\n }\n\n def nextInt(): Int = {\n val n = nextLong()\n if (n < Int.MinValue || Int.MaxValue < n) ???\n n.toInt\n }\n\n def nextLong(): Long = {\n if (!hasNext()) ???\n var minus = false;\n var b = readByte()\n if (b == '-') {\n minus = true; b = readByte()\n }\n\n def go(b: Byte, n: Long = 0): Long =\n if ('0' <= b && b <= '9') {\n go(readByte(), n * 10 + b - '0')\n }\n else if (minus) {\n -n\n } else {\n n\n }\n\n go(b)\n }\n\n def nextDouble(): Double = next.toDouble\n}\n\nobject Main extends App {\n val x = Scanner.nextInt()\n val y = Scanner.nextInt()\n val z = Scanner.nextInt()\n val k = Scanner.nextInt()\n\n val a = Array.fill(x)(Scanner.nextLong()).sorted.reverse\n val b = Array.fill(y)(Scanner.nextLong()).sorted.reverse\n val c = Array.fill(z)(Scanner.nextLong()).sorted.reverse\n\n val input = Array(a,b,c).sortBy(_.length).reverse\n\n var i1 = 0\n var i2 = 0\n var i0 = 0\n\n var answerArray = new ArrayBuffer[Long]\n var min = Long.MaxValue\n\n while(i0=input(2).length){\n i2 = 0\n i1 = i1 + 1\n }\n if (i1>=input(1).length){\n i1 = 0\n i0 = i0 + 1\n }\n }\n answerArray = answerArray.sortBy(_*(-1))\n val pw = new java.io.PrintWriter(System.out)\n answerArray.foreach(i=>pw.println(i))\n pw.flush()\n}", "language": "Scala", "metadata": {"date": 1557187938, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s655463545.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s655463545", "user_id": "u387147818"}, "prompt_components": {"gold_output": "19\n17\n15\n14\n13\n12\n10\n8\n", "input_to_evaluate": "import scala.collection.mutable.ArrayBuffer\n\nobject Scanner {\n private val buf = new Array[Byte](1024);\n private var ptr = 0;\n private var len = 0\n\n @inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126\n\n @inline private def hasNextByte(): Boolean =\n if (ptr >= len) {\n ptr = 0; len = System.in.read(buf); len > 0\n } else {\n true\n }\n\n @inline private def hasNext(): Boolean = {\n while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1\n hasNextByte()\n }\n\n @inline private def readByte(): Byte =\n if (hasNextByte()) {\n val res = buf(ptr); ptr += 1; res\n } else {\n -1\n }\n\n def next(): String = {\n if (!hasNext()) ???\n val sb = new StringBuilder;\n var b = readByte()\n while (isPrintableChar(b)) {\n sb.append(b.toChar); b = readByte()\n }\n sb.toString\n }\n\n def nextInt(): Int = {\n val n = nextLong()\n if (n < Int.MinValue || Int.MaxValue < n) ???\n n.toInt\n }\n\n def nextLong(): Long = {\n if (!hasNext()) ???\n var minus = false;\n var b = readByte()\n if (b == '-') {\n minus = true; b = readByte()\n }\n\n def go(b: Byte, n: Long = 0): Long =\n if ('0' <= b && b <= '9') {\n go(readByte(), n * 10 + b - '0')\n }\n else if (minus) {\n -n\n } else {\n n\n }\n\n go(b)\n }\n\n def nextDouble(): Double = next.toDouble\n}\n\nobject Main extends App {\n val x = Scanner.nextInt()\n val y = Scanner.nextInt()\n val z = Scanner.nextInt()\n val k = Scanner.nextInt()\n\n val a = Array.fill(x)(Scanner.nextLong()).sorted.reverse\n val b = Array.fill(y)(Scanner.nextLong()).sorted.reverse\n val c = Array.fill(z)(Scanner.nextLong()).sorted.reverse\n\n val input = Array(a,b,c).sortBy(_.length).reverse\n\n var i1 = 0\n var i2 = 0\n var i0 = 0\n\n var answerArray = new ArrayBuffer[Long]\n var min = Long.MaxValue\n\n while(i0=input(2).length){\n i2 = 0\n i1 = i1 + 1\n }\n if (i1>=input(1).length){\n i1 = 0\n i0 = i0 + 1\n }\n }\n answerArray = answerArray.sortBy(_*(-1))\n val pw = new java.io.PrintWriter(System.out)\n answerArray.foreach(i=>pw.println(i))\n pw.flush()\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2552, "cpu_time_ms": 2111, "memory_kb": 117000}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s714419165", "group_id": "codeNet:p03081", "input_text": "import scala.io.{StdIn => in}\nimport scala.collection.{mutable => mu}\nimport scala.annotation.tailrec\n\nobject Main extends App {\n val Array(n, q) = in.readLine.split(\" \").map(_.toInt)\n val s = in.readLine\n val op = Iterator.continually(in.readLine)\n .take(q)\n .map(_.split(' ').map(_.head))\n .toArray\n\n def evalute(pos:Int):Int = {\n def rec(pos:Int, cnt:Int):Int = {\n if(pos < 0 || n <= pos || cnt == q) pos match{\n case p if p < 0 => 0\n case p if 0 <= p && p < n => 1\n case p if n <= p => 2\n }\n else if(s(pos) == op(cnt)(0)) {\n if(op(cnt)(1) == 'L') rec(pos-1, cnt+1)\n else rec(pos+1, cnt+1)\n }\n else rec(pos, cnt+1)\n }\n rec(pos,0)\n }\n \n def binarySearch(x:Int):Int = {\n var left = 0\n var right = n\n\n @tailrec\n def loop(left:Int, right:Int):Int = {\n if(right - left < 2) left\n else {\n val mid = (left + right) / 2\n if(evalute(mid) <= x) loop(mid,right)\n else loop(left, mid)\n }\n }\n loop(left, right)\n }\n\n val l = binarySearch(0)\n val r = binarySearch(1)\n debug(l,r)\n val ans = r - l\n println(ans)\n\n def debug(any:Any*):Unit = {\n if(this.getClass.toString != \"class Main$\")\n println(any.mkString(\" \"))\n }\n}", "language": "Scala", "metadata": {"date": 1557503778, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s714419165.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s714419165", "user_id": "u217010036"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.io.{StdIn => in}\nimport scala.collection.{mutable => mu}\nimport scala.annotation.tailrec\n\nobject Main extends App {\n val Array(n, q) = in.readLine.split(\" \").map(_.toInt)\n val s = in.readLine\n val op = Iterator.continually(in.readLine)\n .take(q)\n .map(_.split(' ').map(_.head))\n .toArray\n\n def evalute(pos:Int):Int = {\n def rec(pos:Int, cnt:Int):Int = {\n if(pos < 0 || n <= pos || cnt == q) pos match{\n case p if p < 0 => 0\n case p if 0 <= p && p < n => 1\n case p if n <= p => 2\n }\n else if(s(pos) == op(cnt)(0)) {\n if(op(cnt)(1) == 'L') rec(pos-1, cnt+1)\n else rec(pos+1, cnt+1)\n }\n else rec(pos, cnt+1)\n }\n rec(pos,0)\n }\n \n def binarySearch(x:Int):Int = {\n var left = 0\n var right = n\n\n @tailrec\n def loop(left:Int, right:Int):Int = {\n if(right - left < 2) left\n else {\n val mid = (left + right) / 2\n if(evalute(mid) <= x) loop(mid,right)\n else loop(left, mid)\n }\n }\n loop(left, right)\n }\n\n val l = binarySearch(0)\n val r = binarySearch(1)\n debug(l,r)\n val ans = r - l\n println(ans)\n\n def debug(any:Any*):Unit = {\n if(this.getClass.toString != \"class Main$\")\n println(any.mkString(\" \"))\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 944, "memory_kb": 61984}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s153935508", "group_id": "codeNet:p03085", "input_text": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val b = sc.next()\n\n if (b == \"A\") {\n println(\"T\")\n return\n }\n if (b == \"C\") {\n println(\"G\")\n return\n }\n if (b == \"G\") {\n println(\"C\")\n return\n }\n println(\"A\")\n }\n}", "language": "Scala", "metadata": {"date": 1564065731, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s153935508.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s153935508", "user_id": "u042365947"}, "prompt_components": {"gold_output": "T\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val b = sc.next()\n\n if (b == \"A\") {\n println(\"T\")\n return\n }\n if (b == \"C\") {\n println(\"G\")\n return\n }\n if (b == \"G\") {\n println(\"C\")\n return\n }\n println(\"A\")\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 333, "memory_kb": 25388}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s312489531", "group_id": "codeNet:p03085", "input_text": "class Main {\n def main(args: Array[String]): Unit = {\n val out = io.StdIn.readLine.map {\n _.toString count {\n Set('A', 'C', 'G', 'T').contains(_)\n }\n }\n println(out.head)\n }\n}", "language": "Scala", "metadata": {"date": 1555924397, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s312489531.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s312489531", "user_id": "u629133942"}, "prompt_components": {"gold_output": "T\n", "input_to_evaluate": "class Main {\n def main(args: Array[String]): Unit = {\n val out = io.StdIn.readLine.map {\n _.toString count {\n Set('A', 'C', 'G', 'T').contains(_)\n }\n }\n println(out.head)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 207, "cpu_time_ms": 317, "memory_kb": 25408}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s040238538", "group_id": "codeNet:p03087", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n val Array(n, q) = StdIn.readLine().split(\" \").map(_.toInt)\n val s = StdIn.readLine()\n val lrs = for {\n _ <- 0 until q\n } yield {\n val Array(l, r) = StdIn.readLine().split(\" \").map(_.toInt)\n\n (l, r)\n }\n\n lrs\n .map { case (l, r) =>\n \"AC\".r.findAllIn(s.substring(l - 1, r)).size\n }\n .foreach(println)\n}\n", "language": "Scala", "metadata": {"date": 1553770577, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s040238538.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s040238538", "user_id": "u709766662"}, "prompt_components": {"gold_output": "2\n0\n3\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n val Array(n, q) = StdIn.readLine().split(\" \").map(_.toInt)\n val s = StdIn.readLine()\n val lrs = for {\n _ <- 0 until q\n } yield {\n val Array(l, r) = StdIn.readLine().split(\" \").map(_.toInt)\n\n (l, r)\n }\n\n lrs\n .map { case (l, r) =>\n \"AC\".r.findAllIn(s.substring(l - 1, r)).size\n }\n .foreach(println)\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 122880}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s067378759", "group_id": "codeNet:p03087", "input_text": "object Main {\n val sc = new java.util.Scanner(System.in)\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val N = sc.nextInt\n val Q = sc.nextInt\n val S = sc.next\n val list = Array.fill(Q, 2)(sc.nextInt)\n\n list.foreach{ case Array(l, r) =>\n val sub = S.substring(l-1, r)\n var count = 0\n for (i <- 0 until sub.length - 1) {\n val l: String = sub.charAt(i).toString + sub.charAt(i + 1).toString\n if(l == \"AC\"){\n count = count + 1\n }\n }\n println(count)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1553458711, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s067378759.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s067378759", "user_id": "u780562181"}, "prompt_components": {"gold_output": "2\n0\n3\n", "input_to_evaluate": "object Main {\n val sc = new java.util.Scanner(System.in)\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val N = sc.nextInt\n val Q = sc.nextInt\n val S = sc.next\n val list = Array.fill(Q, 2)(sc.nextInt)\n\n list.foreach{ case Array(l, r) =>\n val sub = S.substring(l-1, r)\n var count = 0\n for (i <- 0 until sub.length - 1) {\n val l: String = sub.charAt(i).toString + sub.charAt(i + 1).toString\n if(l == \"AC\"){\n count = count + 1\n }\n }\n println(count)\n }\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 123936}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s042954666", "group_id": "codeNet:p03088", "input_text": "import java.util.Scanner\n\nimport scala.collection.mutable\n\n\nobject Main {\n\n case class ResidueRing(private val input: Long) {\n val representative: Long = ((input % ResidueRing.mod) + ResidueRing.mod) % ResidueRing.mod\n\n def +(that: ResidueRing): ResidueRing = ResidueRing(this.representative + that.representative)\n\n def -(that: ResidueRing): ResidueRing = ResidueRing(this.representative - that.representative)\n\n def *(that: ResidueRing): ResidueRing = ResidueRing(this.representative * that.representative)\n\n def unary_- : ResidueRing = ResidueRing(-this.representative)\n\n }\n\n object ResidueRing {\n val mod: Long = (1e9 + 7).toLong\n val _0: ResidueRing = ResidueRing(0)\n val _1: ResidueRing = ResidueRing(1)\n }\n\n\n def read() = {\n val sc = new Scanner(System.in)\n val n = sc.nextInt()\n n\n }\n\n\n def solve(n: Int): Long = {\n // 過去3文字分記憶しておけばいい\n val alphabets = \"ATGC\"\n val stateList: IndexedSeq[String] =\n for (c1 <- alphabets;\n c2 <- alphabets;\n c3 <- alphabets) yield IndexedSeq(c1, c2, c3).mkString\n\n\n def transition(state: String, alphabet: Char): Option[String] = {\n (state(0), state(1), state(2), alphabet) match {\n case (_, 'A', 'G', 'C')\n | (_, 'G', 'A', 'C')\n | (_, 'A', 'C', 'G')\n | ('A', _, 'G', 'C')\n | ('A', 'G', _, 'C') => None\n case _ => Some(IndexedSeq(state(1), state(2), alphabet).mkString)\n }\n }\n\n val mapAll0: mutable.Map[String, ResidueRing] = mutable.Map.empty\n for (state <- stateList) {\n mapAll0.+=((state, ResidueRing._0))\n }\n val dp: Array[mutable.Map[String, ResidueRing]] = Array.fill(n + 1)(mapAll0.clone)\n\n dp(0)(\"TTT\") += ResidueRing._1\n for (i <- 0 until n) {\n for (state <- stateList) {\n for (alphabet <- alphabets) {\n val next = transition(state, alphabet)\n next match {\n case Some(nextState) => dp(i + 1)(nextState) += dp(i)(state)\n case None =>\n }\n\n }\n }\n }\n val result = dp.last.values.foldLeft(ResidueRing._0)(_ + _)\n result.representative\n }\n\n\n def main(args: Array[String]): Unit = {\n val n = read()\n println(solve(n))\n }\n}", "language": "Scala", "metadata": {"date": 1555608945, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s042954666.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s042954666", "user_id": "u494788559"}, "prompt_components": {"gold_output": "61\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.collection.mutable\n\n\nobject Main {\n\n case class ResidueRing(private val input: Long) {\n val representative: Long = ((input % ResidueRing.mod) + ResidueRing.mod) % ResidueRing.mod\n\n def +(that: ResidueRing): ResidueRing = ResidueRing(this.representative + that.representative)\n\n def -(that: ResidueRing): ResidueRing = ResidueRing(this.representative - that.representative)\n\n def *(that: ResidueRing): ResidueRing = ResidueRing(this.representative * that.representative)\n\n def unary_- : ResidueRing = ResidueRing(-this.representative)\n\n }\n\n object ResidueRing {\n val mod: Long = (1e9 + 7).toLong\n val _0: ResidueRing = ResidueRing(0)\n val _1: ResidueRing = ResidueRing(1)\n }\n\n\n def read() = {\n val sc = new Scanner(System.in)\n val n = sc.nextInt()\n n\n }\n\n\n def solve(n: Int): Long = {\n // 過去3文字分記憶しておけばいい\n val alphabets = \"ATGC\"\n val stateList: IndexedSeq[String] =\n for (c1 <- alphabets;\n c2 <- alphabets;\n c3 <- alphabets) yield IndexedSeq(c1, c2, c3).mkString\n\n\n def transition(state: String, alphabet: Char): Option[String] = {\n (state(0), state(1), state(2), alphabet) match {\n case (_, 'A', 'G', 'C')\n | (_, 'G', 'A', 'C')\n | (_, 'A', 'C', 'G')\n | ('A', _, 'G', 'C')\n | ('A', 'G', _, 'C') => None\n case _ => Some(IndexedSeq(state(1), state(2), alphabet).mkString)\n }\n }\n\n val mapAll0: mutable.Map[String, ResidueRing] = mutable.Map.empty\n for (state <- stateList) {\n mapAll0.+=((state, ResidueRing._0))\n }\n val dp: Array[mutable.Map[String, ResidueRing]] = Array.fill(n + 1)(mapAll0.clone)\n\n dp(0)(\"TTT\") += ResidueRing._1\n for (i <- 0 until n) {\n for (state <- stateList) {\n for (alphabet <- alphabets) {\n val next = transition(state, alphabet)\n next match {\n case Some(nextState) => dp(i + 1)(nextState) += dp(i)(state)\n case None =>\n }\n\n }\n }\n }\n val result = dp.last.values.foldLeft(ResidueRing._0)(_ + _)\n result.representative\n }\n\n\n def main(args: Array[String]): Unit = {\n val n = read()\n println(solve(n))\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given an integer N. Find the number of strings of length N that satisfy the following conditions, modulo 10^9+7:\n\nThe string does not contain characters other than A, C, G and T.\n\nThe string does not contain AGC as a substring.\n\nThe condition above cannot be violated by swapping two adjacent characters once.\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\n3 \\leq N \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of strings of length N that satisfy the following conditions, modulo 10^9+7.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n61\n\nThere are 4^3 = 64 strings of length 3 that do not contain characters other than A, C, G and T. Among them, only AGC, ACG and GAC violate the condition, so the answer is 64 - 3 = 61.\n\nSample Input 2\n\n4\n\nSample Output 2\n\n230\n\nSample Input 3\n\n100\n\nSample Output 3\n\n388130742\n\nBe sure to print the number of strings modulo 10^9+7.", "sample_input": "3\n"}, "reference_outputs": ["61\n"], "source_document_id": "p03088", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given an integer N. Find the number of strings of length N that satisfy the following conditions, modulo 10^9+7:\n\nThe string does not contain characters other than A, C, G and T.\n\nThe string does not contain AGC as a substring.\n\nThe condition above cannot be violated by swapping two adjacent characters once.\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\n3 \\leq N \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of strings of length N that satisfy the following conditions, modulo 10^9+7.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n61\n\nThere are 4^3 = 64 strings of length 3 that do not contain characters other than A, C, G and T. Among them, only AGC, ACG and GAC violate the condition, so the answer is 64 - 3 = 61.\n\nSample Input 2\n\n4\n\nSample Output 2\n\n230\n\nSample Input 3\n\n100\n\nSample Output 3\n\n388130742\n\nBe sure to print the number of strings modulo 10^9+7.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2256, "cpu_time_ms": 802, "memory_kb": 41016}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s236992363", "group_id": "codeNet:p03101", "input_text": "import java.util.Scanner\n\nobject Main{\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n\n val Array(totalH, totalW) = sc.nextLine.split(\" \").map(_.toInt)\n val Array(h, w) = sc.nextLine.split(\" \").map(_.toInt)\n val totalTiles: Int = totalH * totalW\n println(totalTiles - (h * totalW + w * totalH - h * w))\n }\n}", "language": "Scala", "metadata": {"date": 1556755282, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s236992363.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s236992363", "user_id": "u629133942"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main{\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n\n val Array(totalH, totalW) = sc.nextLine.split(\" \").map(_.toInt)\n val Array(h, w) = sc.nextLine.split(\" \").map(_.toInt)\n val totalTiles: Int = totalH * totalW\n println(totalTiles - (h * totalW + w * totalH - h * w))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 360, "cpu_time_ms": 361, "memory_kb": 25924}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s973024743", "group_id": "codeNet:p03103", "input_text": "object Main extends App {\n import scala.io.StdIn._\n val Array(n, m) = readLine().split(\" \").map(_.toInt)\n val a = new Array[Long](n)\n val map = scala.collection.mutable.HashMap[Long,Long]()\n for(i <- (0 until(n))) {\n val Array(aa, bb) = readLine().split(\" \").map(_.toInt)\n a(i) = aa\n map(aa) = if(map.contains(aa)) map(aa) + bb else bb\n }\n val aA = a.sorted\n var ans = 0L\n var ind = 0\n for(i <- (1 to m)){\n if(map(aA(ind)) == 0){\n ind += 1\n }\n ans += aA(ind)\n map(aA(ind)) -= 1\n }\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1593727292, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s973024743.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s973024743", "user_id": "u759091915"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "object Main extends App {\n import scala.io.StdIn._\n val Array(n, m) = readLine().split(\" \").map(_.toInt)\n val a = new Array[Long](n)\n val map = scala.collection.mutable.HashMap[Long,Long]()\n for(i <- (0 until(n))) {\n val Array(aa, bb) = readLine().split(\" \").map(_.toInt)\n a(i) = aa\n map(aa) = if(map.contains(aa)) map(aa) + bb else bb\n }\n val aA = a.sorted\n var ans = 0L\n var ind = 0\n for(i <- (1 to m)){\n if(map(aA(ind)) == 0){\n ind += 1\n }\n ans += aA(ind)\n map(aA(ind)) -= 1\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 534, "cpu_time_ms": 869, "memory_kb": 68656}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s041207341", "group_id": "codeNet:p03103", "input_text": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n val Array(n, m) = sc.nextLine.split(\" \").map(_.toInt)\n val sortedInput = List.fill(n, 2)(sc.nextLong).sortBy(_.head)\n\n @annotation.tailrec\n def go(m: Long, i: Int, acc: Long): Long = {\n if (m == 0) acc\n else {\n if (m > sortedInput(i)(1)) go(m - sortedInput(i)(1), i + 1, acc + sortedInput(i).head * sortedInput(i)(1))\n else go(0, 0, acc + m * sortedInput(i).head)\n }\n }\n\n println(go(m, 0, 0))\n\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1557049709, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s041207341.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s041207341", "user_id": "u629133942"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n val Array(n, m) = sc.nextLine.split(\" \").map(_.toInt)\n val sortedInput = List.fill(n, 2)(sc.nextLong).sortBy(_.head)\n\n @annotation.tailrec\n def go(m: Long, i: Int, acc: Long): Long = {\n if (m == 0) acc\n else {\n if (m > sortedInput(i)(1)) go(m - sortedInput(i)(1), i + 1, acc + sortedInput(i).head * sortedInput(i)(1))\n else go(0, 0, acc + m * sortedInput(i).head)\n }\n }\n\n println(go(m, 0, 0))\n\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 576, "cpu_time_ms": 2111, "memory_kb": 119964}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s233232248", "group_id": "codeNet:p03106", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val A, B, K = sc.nextInt()\n println(100.to(1, -1).filter(i => A % i == 0 && B % i == 0)(K - 1))\n}\n", "language": "Scala", "metadata": {"date": 1598775717, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03106.html", "problem_id": "p03106", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03106/input.txt", "sample_output_relpath": "derived/input_output/data/p03106/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03106/Scala/s233232248.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s233232248", "user_id": "u737111725"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val A, B, K = sc.nextInt()\n println(100.to(1, -1).filter(i => A % i == 0 && B % i == 0)(K - 1))\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given positive integers A and B.\n\nFind the K-th largest positive integer that divides both A and B.\n\nThe input guarantees that there exists such a number.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 100\n\nThe K-th largest positive integer that divides both A and B exists.\n\nK \\geq 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the K-th largest positive integer that divides both A and B.\n\nSample Input 1\n\n8 12 2\n\nSample Output 1\n\n2\n\nThree positive integers divides both 8 and 12: 1, 2 and 4.\nAmong them, the second largest is 2.\n\nSample Input 2\n\n100 50 4\n\nSample Output 2\n\n5\n\nSample Input 3\n\n1 1 1\n\nSample Output 3\n\n1", "sample_input": "8 12 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03106", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given positive integers A and B.\n\nFind the K-th largest positive integer that divides both A and B.\n\nThe input guarantees that there exists such a number.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 100\n\nThe K-th largest positive integer that divides both A and B exists.\n\nK \\geq 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the K-th largest positive integer that divides both A and B.\n\nSample Input 1\n\n8 12 2\n\nSample Output 1\n\n2\n\nThree positive integers divides both 8 and 12: 1, 2 and 4.\nAmong them, the second largest is 2.\n\nSample Input 2\n\n100 50 4\n\nSample Output 2\n\n5\n\nSample Input 3\n\n1 1 1\n\nSample Output 3\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 501, "memory_kb": 55288}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s801384272", "group_id": "codeNet:p03106", "input_text": "object Main extends App {\n\n val Seq(a,b,k) = scala.io.StdIn.readLine().map(_.toInt)\n\n def solve(): Int = {\n (1 to Math.min(a, b)).filter { i =>\n a % i == 0 && b % i == 0\n }reverse(k-1)\n }\n\n\n\n println(solve)\n\n}", "language": "Scala", "metadata": {"date": 1583362676, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03106.html", "problem_id": "p03106", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03106/input.txt", "sample_output_relpath": "derived/input_output/data/p03106/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03106/Scala/s801384272.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s801384272", "user_id": "u947008426"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n\n val Seq(a,b,k) = scala.io.StdIn.readLine().map(_.toInt)\n\n def solve(): Int = {\n (1 to Math.min(a, b)).filter { i =>\n a % i == 0 && b % i == 0\n }reverse(k-1)\n }\n\n\n\n println(solve)\n\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given positive integers A and B.\n\nFind the K-th largest positive integer that divides both A and B.\n\nThe input guarantees that there exists such a number.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 100\n\nThe K-th largest positive integer that divides both A and B exists.\n\nK \\geq 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the K-th largest positive integer that divides both A and B.\n\nSample Input 1\n\n8 12 2\n\nSample Output 1\n\n2\n\nThree positive integers divides both 8 and 12: 1, 2 and 4.\nAmong them, the second largest is 2.\n\nSample Input 2\n\n100 50 4\n\nSample Output 2\n\n5\n\nSample Input 3\n\n1 1 1\n\nSample Output 3\n\n1", "sample_input": "8 12 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03106", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given positive integers A and B.\n\nFind the K-th largest positive integer that divides both A and B.\n\nThe input guarantees that there exists such a number.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 100\n\nThe K-th largest positive integer that divides both A and B exists.\n\nK \\geq 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the K-th largest positive integer that divides both A and B.\n\nSample Input 1\n\n8 12 2\n\nSample Output 1\n\n2\n\nThree positive integers divides both 8 and 12: 1, 2 and 4.\nAmong them, the second largest is 2.\n\nSample Input 2\n\n100 50 4\n\nSample Output 2\n\n5\n\nSample Input 3\n\n1 1 1\n\nSample Output 3\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 329, "memory_kb": 27300}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s862114957", "group_id": "codeNet:p03106", "input_text": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val A, B, K = sc.nextInt()\n println(Util.getPermutation(1).take(math.max(A, B)).filter(i => A % i == 0 && B % i == 0).sorted.reverse(K - 1))\n }\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def calc(N: Long, R: Long, M: Long): Double = {\n math.sqrt(R * R - (R * 2 * ((M * 1.0 / N) - 0.5)) * (R * 2 * ((M * 1.0 / N) - 0.5))) * 2\n }\n\n def recursive(sc: => Scanner, n: Long): Unit = {\n\n }\n\n def recursive2(X: Set[Long], Y: Stream[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n\n def check(s: String): Boolean = {\n if (s == \"0\") true\n else s(0) != '0' && 0 <= s.toInt && s.toInt <= 255\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def primeFactors(i: Long): List[Long] = primeFactors_(i, 1).sorted\n\n\n def primeFactors_(i: Long, j: Long): List[Long] = {\n if (j * j > i) List.empty else if (i % j == 0) primeFactors_(i, j + 1) ++ List[Long](j, i / j) else primeFactors_(i, j + 1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n}", "language": "Scala", "metadata": {"date": 1551821233, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03106.html", "problem_id": "p03106", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03106/input.txt", "sample_output_relpath": "derived/input_output/data/p03106/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03106/Scala/s862114957.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s862114957", "user_id": "u779353743"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val A, B, K = sc.nextInt()\n println(Util.getPermutation(1).take(math.max(A, B)).filter(i => A % i == 0 && B % i == 0).sorted.reverse(K - 1))\n }\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def calc(N: Long, R: Long, M: Long): Double = {\n math.sqrt(R * R - (R * 2 * ((M * 1.0 / N) - 0.5)) * (R * 2 * ((M * 1.0 / N) - 0.5))) * 2\n }\n\n def recursive(sc: => Scanner, n: Long): Unit = {\n\n }\n\n def recursive2(X: Set[Long], Y: Stream[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n\n def check(s: String): Boolean = {\n if (s == \"0\") true\n else s(0) != '0' && 0 <= s.toInt && s.toInt <= 255\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def primeFactors(i: Long): List[Long] = primeFactors_(i, 1).sorted\n\n\n def primeFactors_(i: Long, j: Long): List[Long] = {\n if (j * j > i) List.empty else if (i % j == 0) primeFactors_(i, j + 1) ++ List[Long](j, i / j) else primeFactors_(i, j + 1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given positive integers A and B.\n\nFind the K-th largest positive integer that divides both A and B.\n\nThe input guarantees that there exists such a number.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 100\n\nThe K-th largest positive integer that divides both A and B exists.\n\nK \\geq 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the K-th largest positive integer that divides both A and B.\n\nSample Input 1\n\n8 12 2\n\nSample Output 1\n\n2\n\nThree positive integers divides both 8 and 12: 1, 2 and 4.\nAmong them, the second largest is 2.\n\nSample Input 2\n\n100 50 4\n\nSample Output 2\n\n5\n\nSample Input 3\n\n1 1 1\n\nSample Output 3\n\n1", "sample_input": "8 12 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03106", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given positive integers A and B.\n\nFind the K-th largest positive integer that divides both A and B.\n\nThe input guarantees that there exists such a number.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 100\n\nThe K-th largest positive integer that divides both A and B exists.\n\nK \\geq 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the K-th largest positive integer that divides both A and B.\n\nSample Input 1\n\n8 12 2\n\nSample Output 1\n\n2\n\nThree positive integers divides both 8 and 12: 1, 2 and 4.\nAmong them, the second largest is 2.\n\nSample Input 2\n\n100 50 4\n\nSample Output 2\n\n5\n\nSample Input 3\n\n1 1 1\n\nSample Output 3\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6329, "cpu_time_ms": 367, "memory_kb": 26836}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s151873806", "group_id": "codeNet:p03106", "input_text": "object Main extends App {\n val in = scala.io.Source.stdin.getLines.toSeq\n val ls = in.map(_.split(' ').map(_.toInt).toIndexedSeq).head\n val A = ls(0)\n val B = ls(1)\n val K = ls(2)\n var count = 0\n var i=Math.min(A,B)\n while(count{inputstring(x).toInt - 48})\n val count = inputlist.sum\n val ans = List(count,inputlist.size - count).min * 2\n println(ans)\n}\n", "language": "Scala", "metadata": {"date": 1551646225, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s363215887.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s363215887", "user_id": "u875245411"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "object Main extends App{\n val sc = new java.util.Scanner(System.in)\n val inputstring = sc.next\n val inputlist = List.tabulate(inputstring.size)(x=>{inputstring(x).toInt - 48})\n val count = inputlist.sum\n val ans = List(count,inputlist.size - count).min * 2\n println(ans)\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 279, "cpu_time_ms": 510, "memory_kb": 33816}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s236095517", "group_id": "codeNet:p03107", "input_text": "\nobject Main extends App {\n /* このあたりはmemoに初期値として登録しておく\n if (ss.length <= 1) {\n memo = memo + (ss -> ss)\n ss\n } else if (ss.length == 2) {\n if (ss == \"01\" || ss == \"10\") {\n memo = memo + (ss -> ss)\n \"\"\n } else {\n ss\n }\n }\n */\n var memo: Map[String, String] = Map(\"\" -> \"\", \"0\" -> \"0\", \"1\" -> \"1\", \"01\" -> \"\", \"10\" -> \"\", \"00\" -> \"00\", \"11\" -> \"11\")\n\n val s = scala.io.StdIn.readLine\n\n def check(ss: String): String = {\n memo.get(ss) match {\n case Some(sss) => sss\n case None =>\n if (ss.forall(_ == '0') || ss.forall(_ == '1')) {\n memo = memo + (ss -> ss)\n return ss\n }\n\n var ans = ss\n (0 until ss.length - 1).foreach { i =>\n // println(s\"${s}: ${i}\")\n if (ss(i) != ss(i + 1)) {\n val tmp = check(ss.substring(0, i) + ss.substring(i + 2))\n if (tmp.length < ans.length) {\n ans = tmp\n }\n }\n }\n memo = memo + (ss -> ans)\n\n ans\n\n }\n\n }\n\n println(s.length - check(s).length)\n}\n", "language": "Scala", "metadata": {"date": 1551645497, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s236095517.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s236095517", "user_id": "u654455149"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "\nobject Main extends App {\n /* このあたりはmemoに初期値として登録しておく\n if (ss.length <= 1) {\n memo = memo + (ss -> ss)\n ss\n } else if (ss.length == 2) {\n if (ss == \"01\" || ss == \"10\") {\n memo = memo + (ss -> ss)\n \"\"\n } else {\n ss\n }\n }\n */\n var memo: Map[String, String] = Map(\"\" -> \"\", \"0\" -> \"0\", \"1\" -> \"1\", \"01\" -> \"\", \"10\" -> \"\", \"00\" -> \"00\", \"11\" -> \"11\")\n\n val s = scala.io.StdIn.readLine\n\n def check(ss: String): String = {\n memo.get(ss) match {\n case Some(sss) => sss\n case None =>\n if (ss.forall(_ == '0') || ss.forall(_ == '1')) {\n memo = memo + (ss -> ss)\n return ss\n }\n\n var ans = ss\n (0 until ss.length - 1).foreach { i =>\n // println(s\"${s}: ${i}\")\n if (ss(i) != ss(i + 1)) {\n val tmp = check(ss.substring(0, i) + ss.substring(i + 2))\n if (tmp.length < ans.length) {\n ans = tmp\n }\n }\n }\n memo = memo + (ss -> ans)\n\n ans\n\n }\n\n }\n\n println(s.length - check(s).length)\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1602, "memory_kb": 303224}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s626396809", "group_id": "codeNet:p03107", "input_text": "import java.util.Scanner\n\n\nobject Main {\n def read() = {\n val sc = new Scanner(System.in)\n val cubes = sc.next()\n cubes\n }\n\n def solve(cubes: String) :Int ={\n var cubesTest = cubes\n while(true){\n val beforeLen = cubesTest.length\n cubesTest = cubesTest.replace(\"01\", \"\")\n cubesTest = cubesTest.replace(\"10\", \"\")\n val afterLen = cubesTest.length\n if(beforeLen == afterLen) return cubes.length - afterLen\n }\n -1\n }\n\n\n def main(args: Array[String]): Unit = {\n val cubes = read()\n println(solve(cubes))\n }\n}", "language": "Scala", "metadata": {"date": 1551645448, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s626396809.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s626396809", "user_id": "u494788559"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.Scanner\n\n\nobject Main {\n def read() = {\n val sc = new Scanner(System.in)\n val cubes = sc.next()\n cubes\n }\n\n def solve(cubes: String) :Int ={\n var cubesTest = cubes\n while(true){\n val beforeLen = cubesTest.length\n cubesTest = cubesTest.replace(\"01\", \"\")\n cubesTest = cubesTest.replace(\"10\", \"\")\n val afterLen = cubesTest.length\n if(beforeLen == afterLen) return cubes.length - afterLen\n }\n -1\n }\n\n\n def main(args: Array[String]): Unit = {\n val cubes = read()\n println(solve(cubes))\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 114564}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s491652354", "group_id": "codeNet:p03108", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n, m = sc.nextInt\n val bs = Array.fill(m)((sc.nextInt - 1, sc.nextInt - 1)).reverse\n val uf = new UnionFind(n)\n\n val result = bs.scanLeft(n.toLong * (n - 1) / 2){(z, b) =>\n if (uf.find(b._1) != uf.find(b._2)) {\n val inconvenience = uf.size(b._1).toLong * uf.size(b._2)\n uf.union(b._1, b._2)\n z - inconvenience\n } else z\n }.reverse.tail\n\n println(result.mkString(\"\\n\"))\n}\n\nclass UnionFind(nodes: Int) {\n val parents = Array.tabulate(nodes)(identity)\n val sizes = Array.fill(nodes)(1)\n\n // @scala.annotation.tailrec\n /** @retrun (root, rank) */\n def findWithRank(x: Int, rank: Int = 0): (Int, Int) = {\n parents(x) match {\n case p if x == p => (p, rank)\n case p => {\n val (newRoot, newRank) = findWithRank(p, rank + 1)\n parents(x) = newRoot\n (newRoot, newRank)\n }\n }\n }\n\n def find(x: Int): Int = {\n parents(x) match {\n case p if x == p => p\n case p => {\n val newRoot = find(p)\n parents(x) = newRoot\n newRoot\n }\n }\n }\n\n def size(x: Int) = sizes(find(x))\n\n def union(x: Int, y: Int): Int = {\n val (xRoot, xRank) = findWithRank(x)\n val (yRoot, yRank) = findWithRank(y)\n val newRoot = if (xRank < yRank) yRoot else xRoot\n if (xRoot != yRoot) {\n parents(xRoot) = newRoot\n parents(yRoot) = newRoot\n sizes(newRoot) = sizes(xRoot) + sizes(yRoot)\n }\n parents(x) = newRoot\n parents(y) = newRoot\n newRoot\n }\n}", "language": "Scala", "metadata": {"date": 1576682321, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s491652354.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s491652354", "user_id": "u132324749"}, "prompt_components": {"gold_output": "0\n0\n4\n5\n6\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n, m = sc.nextInt\n val bs = Array.fill(m)((sc.nextInt - 1, sc.nextInt - 1)).reverse\n val uf = new UnionFind(n)\n\n val result = bs.scanLeft(n.toLong * (n - 1) / 2){(z, b) =>\n if (uf.find(b._1) != uf.find(b._2)) {\n val inconvenience = uf.size(b._1).toLong * uf.size(b._2)\n uf.union(b._1, b._2)\n z - inconvenience\n } else z\n }.reverse.tail\n\n println(result.mkString(\"\\n\"))\n}\n\nclass UnionFind(nodes: Int) {\n val parents = Array.tabulate(nodes)(identity)\n val sizes = Array.fill(nodes)(1)\n\n // @scala.annotation.tailrec\n /** @retrun (root, rank) */\n def findWithRank(x: Int, rank: Int = 0): (Int, Int) = {\n parents(x) match {\n case p if x == p => (p, rank)\n case p => {\n val (newRoot, newRank) = findWithRank(p, rank + 1)\n parents(x) = newRoot\n (newRoot, newRank)\n }\n }\n }\n\n def find(x: Int): Int = {\n parents(x) match {\n case p if x == p => p\n case p => {\n val newRoot = find(p)\n parents(x) = newRoot\n newRoot\n }\n }\n }\n\n def size(x: Int) = sizes(find(x))\n\n def union(x: Int, y: Int): Int = {\n val (xRoot, xRank) = findWithRank(x)\n val (yRoot, yRank) = findWithRank(y)\n val newRoot = if (xRank < yRank) yRoot else xRoot\n if (xRoot != yRoot) {\n parents(xRoot) = newRoot\n parents(yRoot) = newRoot\n sizes(newRoot) = sizes(xRoot) + sizes(yRoot)\n }\n parents(x) = newRoot\n parents(y) = newRoot\n newRoot\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1531, "cpu_time_ms": 1133, "memory_kb": 90596}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s173262553", "group_id": "codeNet:p03108", "input_text": "object Main {\n\n class UnionFind(par: Array[Int]) {\n\n def union(x: Int, y: Int): Boolean = {\n val rx = root(x)\n val ry = root(y)\n if (rx != ry) {\n if (size(rx) < size(ry)) {\n par(ry) += par(rx)\n par(rx) = ry\n } else {\n par(rx) += par(ry)\n par(ry) = rx\n }\n true\n } else false\n }\n\n def root(x: Int): Int =\n if (par(x) < 0) x\n else {\n par(x) = root(par(x))\n par(x)\n }\n\n def size(x: Int): Int =\n -par(root(x))\n\n }\n\n object UnionFind {\n\n def apply(n: Int): UnionFind =\n new UnionFind(Array.fill(n)(-1))\n\n }\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val N, M = sc.nextInt()\n // 辺をつなぐ処理は簡単、しかし切り離す行為は簡単ではない\n\n case class Bridge(from: Int, to: Int)\n\n val Bridges = new Array[Bridge](M)\n (0 until M) foreach { i =>\n val a, b = sc.nextInt()\n Bridges(i) = Bridge(a-1, b-1)\n }\n\n // 全ての橋が壊れている状態\n // この時の不便さは?\n // 連結!\n // 繋いだ時, 始点から繋がっている数 * 終点から繋がっている数\n // BとCがもともと繋がっていた場合には(同じグループの場合には不便さは変わらない\n // BとCがもともと繋がっていない場合には、快適さが上がる。\n // この橋が落ちた時には, 片方のグループの島と, 片方のグループの島の組み合わせが断絶されることになるので\n // この組み合わせの数だけ不便になることになる。\n // つまり, 始点から繋がっている数 * 終点から繋がっている数\n val unionFind = UnionFind.apply(N)\n val res = new Array[Long](M)\n res(M-1) = N*(N-1)/2\n\n var i = M - 1\n while (i > 0) {\n val Bridge(a, b) = Bridges(i)\n if (unionFind.root(a) != unionFind.root(b)) {\n res(i-1) = res(i) - unionFind.size(a).toLong * unionFind.size(b).toLong\n unionFind.union(a, b)\n } else {\n res(i-1) = res(i)\n }\n i -= 1\n }\n\n println(res.mkString(\"\\n\"))\n }\n\n}", "language": "Scala", "metadata": {"date": 1565889955, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s173262553.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s173262553", "user_id": "u891387249"}, "prompt_components": {"gold_output": "0\n0\n4\n5\n6\n", "input_to_evaluate": "object Main {\n\n class UnionFind(par: Array[Int]) {\n\n def union(x: Int, y: Int): Boolean = {\n val rx = root(x)\n val ry = root(y)\n if (rx != ry) {\n if (size(rx) < size(ry)) {\n par(ry) += par(rx)\n par(rx) = ry\n } else {\n par(rx) += par(ry)\n par(ry) = rx\n }\n true\n } else false\n }\n\n def root(x: Int): Int =\n if (par(x) < 0) x\n else {\n par(x) = root(par(x))\n par(x)\n }\n\n def size(x: Int): Int =\n -par(root(x))\n\n }\n\n object UnionFind {\n\n def apply(n: Int): UnionFind =\n new UnionFind(Array.fill(n)(-1))\n\n }\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val N, M = sc.nextInt()\n // 辺をつなぐ処理は簡単、しかし切り離す行為は簡単ではない\n\n case class Bridge(from: Int, to: Int)\n\n val Bridges = new Array[Bridge](M)\n (0 until M) foreach { i =>\n val a, b = sc.nextInt()\n Bridges(i) = Bridge(a-1, b-1)\n }\n\n // 全ての橋が壊れている状態\n // この時の不便さは?\n // 連結!\n // 繋いだ時, 始点から繋がっている数 * 終点から繋がっている数\n // BとCがもともと繋がっていた場合には(同じグループの場合には不便さは変わらない\n // BとCがもともと繋がっていない場合には、快適さが上がる。\n // この橋が落ちた時には, 片方のグループの島と, 片方のグループの島の組み合わせが断絶されることになるので\n // この組み合わせの数だけ不便になることになる。\n // つまり, 始点から繋がっている数 * 終点から繋がっている数\n val unionFind = UnionFind.apply(N)\n val res = new Array[Long](M)\n res(M-1) = N*(N-1)/2\n\n var i = M - 1\n while (i > 0) {\n val Bridge(a, b) = Bridges(i)\n if (unionFind.root(a) != unionFind.root(b)) {\n res(i-1) = res(i) - unionFind.size(a).toLong * unionFind.size(b).toLong\n unionFind.union(a, b)\n } else {\n res(i-1) = res(i)\n }\n i -= 1\n }\n\n println(res.mkString(\"\\n\"))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2190, "cpu_time_ms": 983, "memory_kb": 77460}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s613532084", "group_id": "codeNet:p03108", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val s = new Main()\n s.solve()\n s.out.flush()\n }\n}\n\nclass Main {\n import java.io._\n import java.util.StringTokenizer\n\n import scala.collection.mutable\n import scala.util.Sorting\n import math.{abs, max, min}\n import mutable.{ArrayBuffer, ListBuffer}\n import scala.reflect.ClassTag\n\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n\n def solve(): Unit = {\n val N, M = ni()\n val (from, to) = na2(M, -1)\n var cnt = N.toLong * (N - 1) / 2\n val uf = new UnionFind(N)\n val set = Array.ofDim[mutable.Set[Int]](N)\n REP(N) { i =>\n set(i) = mutable.Set(i)\n }\n\n debug(set.mkString(\" \"))\n\n def merge(id1: Int, id2: Int): mutable.Set[Int] = {\n val s1 = set(id1)\n val s2 = set(id2)\n if (s1.size > s2.size) {\n s1 ++= s2\n s1\n } else {\n s2 ++= s1\n s2\n }\n }\n\n val ans = ArrayBuffer[Long]()\n REP_r(M) { i =>\n ans += cnt\n\n val id1 = uf.find(from(i))\n val id2 = uf.find(to(i))\n\n if (id1 != id2) {\n cnt -= set(id1).size.toLong * set(id2).size\n val merged = merge(id1, id2)\n uf.unite(from(i), to(i))\n set(id1) = merged\n }\n// debug(set.mkString(\" \"))\n }\n\n ans.reverse.foreach(out.println)\n }\n\n class UnionFind(val n: Int) {\n private val par = Array.ofDim[Int](n)\n par.indices foreach (i => par(i) = i)\n private val rank = Array.ofDim[Int](n)\n\n def find(x: Int): Int = {\n val stack = ListBuffer[Int]()\n def step(x: Int): Int = {\n if (par(x) == x) x\n else {\n stack += x\n step(par(x))\n }\n }\n\n val res = step(x)\n stack foreach (i => par(i) = res)\n res\n }\n\n def unite(x: Int, y: Int): Unit = {\n val x1 = find(x)\n val y1 = find(y)\n if (x1 != y1) {\n if (rank(x1) < rank(y)) {\n par(x1) = y1\n } else {\n par(y1) = x1\n if (rank(x1) == rank(y1)) rank(x1) += 1\n }\n }\n }\n }\n\n def debug(as: Array[Boolean]): Unit = {\n System.err.println(as.map(x => if(x) \"1\" else \"0\").mkString)\n }\n\n def debug(as: Array[Int]): Unit = {\n System.err.println(as.mkString(\" \"))\n }\n\n def debug(as: Array[Long]): Unit = {\n System.err.println(as.mkString(\" \"))\n }\n\n def debug(s: String): Unit = {\n System.err.println(s)\n }\n\n def debug(num: Long): Unit = {\n System.err.println(num)\n }\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next().toInt\n def nextLong(): Long = next().toLong\n def nextChar(): Char = next().charAt(0)\n }\n val sc = new InputReader(System.in)\n def ni(): Int = sc.nextInt()\n def nl(): Long = sc.nextLong()\n def nc(): Char = sc.nextChar()\n def ns(): String = sc.next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n\n def cumSum(as: Array[Int]) = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n", "language": "Scala", "metadata": {"date": 1551644697, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s613532084.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s613532084", "user_id": "u460609472"}, "prompt_components": {"gold_output": "0\n0\n4\n5\n6\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val s = new Main()\n s.solve()\n s.out.flush()\n }\n}\n\nclass Main {\n import java.io._\n import java.util.StringTokenizer\n\n import scala.collection.mutable\n import scala.util.Sorting\n import math.{abs, max, min}\n import mutable.{ArrayBuffer, ListBuffer}\n import scala.reflect.ClassTag\n\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n\n def solve(): Unit = {\n val N, M = ni()\n val (from, to) = na2(M, -1)\n var cnt = N.toLong * (N - 1) / 2\n val uf = new UnionFind(N)\n val set = Array.ofDim[mutable.Set[Int]](N)\n REP(N) { i =>\n set(i) = mutable.Set(i)\n }\n\n debug(set.mkString(\" \"))\n\n def merge(id1: Int, id2: Int): mutable.Set[Int] = {\n val s1 = set(id1)\n val s2 = set(id2)\n if (s1.size > s2.size) {\n s1 ++= s2\n s1\n } else {\n s2 ++= s1\n s2\n }\n }\n\n val ans = ArrayBuffer[Long]()\n REP_r(M) { i =>\n ans += cnt\n\n val id1 = uf.find(from(i))\n val id2 = uf.find(to(i))\n\n if (id1 != id2) {\n cnt -= set(id1).size.toLong * set(id2).size\n val merged = merge(id1, id2)\n uf.unite(from(i), to(i))\n set(id1) = merged\n }\n// debug(set.mkString(\" \"))\n }\n\n ans.reverse.foreach(out.println)\n }\n\n class UnionFind(val n: Int) {\n private val par = Array.ofDim[Int](n)\n par.indices foreach (i => par(i) = i)\n private val rank = Array.ofDim[Int](n)\n\n def find(x: Int): Int = {\n val stack = ListBuffer[Int]()\n def step(x: Int): Int = {\n if (par(x) == x) x\n else {\n stack += x\n step(par(x))\n }\n }\n\n val res = step(x)\n stack foreach (i => par(i) = res)\n res\n }\n\n def unite(x: Int, y: Int): Unit = {\n val x1 = find(x)\n val y1 = find(y)\n if (x1 != y1) {\n if (rank(x1) < rank(y)) {\n par(x1) = y1\n } else {\n par(y1) = x1\n if (rank(x1) == rank(y1)) rank(x1) += 1\n }\n }\n }\n }\n\n def debug(as: Array[Boolean]): Unit = {\n System.err.println(as.map(x => if(x) \"1\" else \"0\").mkString)\n }\n\n def debug(as: Array[Int]): Unit = {\n System.err.println(as.mkString(\" \"))\n }\n\n def debug(as: Array[Long]): Unit = {\n System.err.println(as.mkString(\" \"))\n }\n\n def debug(s: String): Unit = {\n System.err.println(s)\n }\n\n def debug(num: Long): Unit = {\n System.err.println(num)\n }\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next().toInt\n def nextLong(): Long = next().toLong\n def nextChar(): Char = next().charAt(0)\n }\n val sc = new InputReader(System.in)\n def ni(): Int = sc.nextInt()\n def nl(): Long = sc.nextLong()\n def nc(): Char = sc.nextChar()\n def ns(): String = sc.next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n\n def cumSum(as: Array[Int]) = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4421, "cpu_time_ms": 1573, "memory_kb": 109136}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s902557885", "group_id": "codeNet:p03110", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n println {\n List.fill(sc.nextInt())(sc.nextDouble() -> sc.next()).map {\n case (d, \"BTC\") => d * 380000.0\n case (d, _) => d\n }.sum\n }\n}\n", "language": "Scala", "metadata": {"date": 1598775977, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s902557885.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s902557885", "user_id": "u737111725"}, "prompt_components": {"gold_output": "48000.0\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n println {\n List.fill(sc.nextInt())(sc.nextDouble() -> sc.next()).map {\n case (d, \"BTC\") => d * 380000.0\n case (d, _) => d\n }.sum\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 223, "cpu_time_ms": 507, "memory_kb": 55716}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s872474321", "group_id": "codeNet:p03111", "input_text": "import scala.math.abs\nobject Main extends App {\n val in = new java.util.Scanner(System.in)\n val n, A, B, C = in.nextInt\n val ls = Array.fill(n)(in.nextInt)\n\n def dfs(i: Int, a: Int, b: Int, c: Int): Int = {\n if (i == n) {\n if (a == 0 || b == 0 || c == 0) 100000000\n else abs(A - a) + abs(B - b) + abs(C -c) - 30\n } else {\n Array(\n dfs(i + 1, ls(i) + a, b, c) + 10,\n dfs(i + 1, a, ls(i) + b, c) + 10,\n dfs(i + 1, a, b, ls(i) + c) + 10,\n dfs(i + 1, a, b, c)).min\n }\n }\n\n println(dfs(0, 0, 0, 0))\n}", "language": "Scala", "metadata": {"date": 1576766659, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s872474321.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s872474321", "user_id": "u132324749"}, "prompt_components": {"gold_output": "23\n", "input_to_evaluate": "import scala.math.abs\nobject Main extends App {\n val in = new java.util.Scanner(System.in)\n val n, A, B, C = in.nextInt\n val ls = Array.fill(n)(in.nextInt)\n\n def dfs(i: Int, a: Int, b: Int, c: Int): Int = {\n if (i == n) {\n if (a == 0 || b == 0 || c == 0) 100000000\n else abs(A - a) + abs(B - b) + abs(C -c) - 30\n } else {\n Array(\n dfs(i + 1, ls(i) + a, b, c) + 10,\n dfs(i + 1, a, ls(i) + b, c) + 10,\n dfs(i + 1, a, b, ls(i) + c) + 10,\n dfs(i + 1, a, b, c)).min\n }\n }\n\n println(dfs(0, 0, 0, 0))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 471, "memory_kb": 32912}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s895599070", "group_id": "codeNet:p03125", "input_text": "object Main extends App {\n io.StdIn.readLine.split(\" \").map(_.toInt) match {\n case Array(a, b) if b % a == 0 => println(a + b)\n case Array(a, b) => println(b - a)\n }\n}\n", "language": "Scala", "metadata": {"date": 1582142275, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s895599070.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s895599070", "user_id": "u518641666"}, "prompt_components": {"gold_output": "16\n", "input_to_evaluate": "object Main extends App {\n io.StdIn.readLine.split(\" \").map(_.toInt) match {\n case Array(a, b) if b % a == 0 => println(a + b)\n case Array(a, b) => println(b - a)\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 325, "memory_kb": 27340}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s397034694", "group_id": "codeNet:p03127", "input_text": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val n = in.nextInt\n val as = Array.fill(n)(in.nextInt)\n def gcd(l: Int, r: Int): Int = if (r == 0) l else gcd(r, (l % r))\n println(as.reduceLeft(gcd))\n}", "language": "Scala", "metadata": {"date": 1577392252, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s397034694.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s397034694", "user_id": "u132324749"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val n = in.nextInt\n val as = Array.fill(n)(in.nextInt)\n def gcd(l: Int, r: Int): Int = if (r == 0) l else gcd(r, (l % r))\n println(as.reduceLeft(gcd))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 712, "memory_kb": 52540}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s273477130", "group_id": "codeNet:p03127", "input_text": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val n = in.readInt\n val ms = in.readLine.split(\" \").map(_.toInt).sorted\n\n val dMin = ms./:(Int.MaxValue)((acc,i) => {\n val v = i % acc\n (math.min(acc, if(v!=0) v else acc))\n })\n\n // println(dMin)\n\n val res = if(dMin == 1) 1\n else ms./:(Int.MaxValue)((acc,i) => {\n val v = i % dMin\n val s = if(v != 0) v else acc\n math.min(acc,s)\n })\n\n val min = math.min(dMin,res)\n\n // println(min)\n\n val ans = math.min(ms.head,min)\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1550373030, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s273477130.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s273477130", "user_id": "u217010036"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val n = in.readInt\n val ms = in.readLine.split(\" \").map(_.toInt).sorted\n\n val dMin = ms./:(Int.MaxValue)((acc,i) => {\n val v = i % acc\n (math.min(acc, if(v!=0) v else acc))\n })\n\n // println(dMin)\n\n val res = if(dMin == 1) 1\n else ms./:(Int.MaxValue)((acc,i) => {\n val v = i % dMin\n val s = if(v != 0) v else acc\n math.min(acc,s)\n })\n\n val min = math.min(dMin,res)\n\n // println(min)\n\n val ans = math.min(ms.head,min)\n println(ans)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 518, "cpu_time_ms": 710, "memory_kb": 43000}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s264460362", "group_id": "codeNet:p03128", "input_text": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val N, M = sc.nextInt()\n val A = Array.fill(M)(sc.nextInt())\n val MatchOf = Array(0, 2, 5, 5, 4, 5, 6, 3, 7, 6)\n\n // i本のマッチ棒を使って作れる整数の中で最大のもの\n // 整数の中で最大のものは, 大きい数順に並べることになる\n // 明らかに, 既に付いている先頭の文字列よりも小さいものが来た場合\n // 最大になることはないので捨てる\n val dp = Array.fill(N+1)(\"\")\n\n var i = 0\n while (i < M) {\n val matches = MatchOf(A(i))\n dp(matches) = \"\" + A(i)\n i += 1\n }\n\n i = 1\n while (i <= N) {\n if (dp(i).nonEmpty) {\n var j = 0\n while (j < M) {\n val matches = MatchOf(A(j))\n if (i + matches <= N) {\n val newValue = dp(i) + A(j)\n if (dp(i + matches).nonEmpty) {\n if (newValue.length == dp(i + matches).length) {\n if (newValue > dp(i + matches))\n dp(i + matches) = newValue\n } else if (newValue.length > dp(i + matches).length) {\n dp(i + matches) = newValue\n }\n } else {\n dp(i + matches) = newValue\n }\n }\n j += 1\n }\n }\n i += 1\n }\n\n println(dp(N))\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1566165941, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03128.html", "problem_id": "p03128", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03128/input.txt", "sample_output_relpath": "derived/input_output/data/p03128/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03128/Scala/s264460362.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s264460362", "user_id": "u891387249"}, "prompt_components": {"gold_output": "777773\n", "input_to_evaluate": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val N, M = sc.nextInt()\n val A = Array.fill(M)(sc.nextInt())\n val MatchOf = Array(0, 2, 5, 5, 4, 5, 6, 3, 7, 6)\n\n // i本のマッチ棒を使って作れる整数の中で最大のもの\n // 整数の中で最大のものは, 大きい数順に並べることになる\n // 明らかに, 既に付いている先頭の文字列よりも小さいものが来た場合\n // 最大になることはないので捨てる\n val dp = Array.fill(N+1)(\"\")\n\n var i = 0\n while (i < M) {\n val matches = MatchOf(A(i))\n dp(matches) = \"\" + A(i)\n i += 1\n }\n\n i = 1\n while (i <= N) {\n if (dp(i).nonEmpty) {\n var j = 0\n while (j < M) {\n val matches = MatchOf(A(j))\n if (i + matches <= N) {\n val newValue = dp(i) + A(j)\n if (dp(i + matches).nonEmpty) {\n if (newValue.length == dp(i + matches).length) {\n if (newValue > dp(i + matches))\n dp(i + matches) = newValue\n } else if (newValue.length > dp(i + matches).length) {\n dp(i + matches) = newValue\n }\n } else {\n dp(i + matches) = newValue\n }\n }\n j += 1\n }\n }\n i += 1\n }\n\n println(dp(N))\n }\n\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nFind the largest integer that can be formed with exactly N matchsticks, under the following conditions:\n\nEvery digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \\leq A_i \\leq 9).\n\nThe number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectively.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^4\n\n1 \\leq M \\leq 9\n\n1 \\leq A_i \\leq 9\n\nA_i are all different.\n\nThere exists an integer that can be formed by exactly N matchsticks under the conditions.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_M\n\nOutput\n\nPrint the largest integer that can be formed with exactly N matchsticks under the conditions in the problem statement.\n\nSample Input 1\n\n20 4\n3 7 8 4\n\nSample Output 1\n\n777773\n\nThe integer 777773 can be formed with 3 + 3 + 3 + 3 + 3 + 5 = 20 matchsticks, and this is the largest integer that can be formed by 20 matchsticks under the conditions.\n\nSample Input 2\n\n101 9\n9 8 7 6 5 4 3 2 1\n\nSample Output 2\n\n71111111111111111111111111111111111111111111111111\n\nThe output may not fit into a 64-bit integer type.\n\nSample Input 3\n\n15 3\n5 4 6\n\nSample Output 3\n\n654", "sample_input": "20 4\n3 7 8 4\n"}, "reference_outputs": ["777773\n"], "source_document_id": "p03128", "source_text": "Score : 400 points\n\nProblem Statement\n\nFind the largest integer that can be formed with exactly N matchsticks, under the following conditions:\n\nEvery digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \\leq A_i \\leq 9).\n\nThe number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectively.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^4\n\n1 \\leq M \\leq 9\n\n1 \\leq A_i \\leq 9\n\nA_i are all different.\n\nThere exists an integer that can be formed by exactly N matchsticks under the conditions.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_M\n\nOutput\n\nPrint the largest integer that can be formed with exactly N matchsticks under the conditions in the problem statement.\n\nSample Input 1\n\n20 4\n3 7 8 4\n\nSample Output 1\n\n777773\n\nThe integer 777773 can be formed with 3 + 3 + 3 + 3 + 3 + 5 = 20 matchsticks, and this is the largest integer that can be formed by 20 matchsticks under the conditions.\n\nSample Input 2\n\n101 9\n9 8 7 6 5 4 3 2 1\n\nSample Output 2\n\n71111111111111111111111111111111111111111111111111\n\nThe output may not fit into a 64-bit integer type.\n\nSample Input 3\n\n15 3\n5 4 6\n\nSample Output 3\n\n654", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1405, "cpu_time_ms": 909, "memory_kb": 169880}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s763718081", "group_id": "codeNet:p03128", "input_text": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\nimport scala.collection.mutable.{Map, Queue, PriorityQueue}\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val N, M = in.next().toInt\n val A = new Array[Int](M)\n for (i <- 0 until M)\n A(i) = in.next().toInt\n\n //\n val map = Map(\n 1 -> 2, 2 -> 5, 3 -> 5,\n 4 -> 4, 5 -> 5, 6 -> 6,\n 7 -> 3, 8 -> 7, 9 -> 6\n )\n\n\n val dp = new Array[Int](N+1)\n val init = -1\n for (i <- 0 to N)\n dp(i) = init\n\n dp(0) = 0\n for (i <- 1 to N) {\n for (e <- A) {\n val diff = i - map(e)\n if (diff >= 0) {\n if (dp(i) == 0)\n dp(i) = dp(diff) + 1\n else\n dp(i) = Math.max(dp(i), dp(diff) + 1)\n }\n }\n }\n\n var now = N\n var ans = \"\"\n while (now > 0) {\n breakable {\n for (i <- (1 to 9).reverse) {\n val diff = now - map(i)\n if (A.contains(i) && diff >= 0) {\n if (dp(diff) == dp(now) - 1) {\n now = diff\n ans += i.toString\n break\n }\n }\n }\n }\n }\n\n println(ans)\n}\n\n\nclass InputReader(stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream))\n private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n", "language": "Scala", "metadata": {"date": 1565061566, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03128.html", "problem_id": "p03128", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03128/input.txt", "sample_output_relpath": "derived/input_output/data/p03128/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03128/Scala/s763718081.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s763718081", "user_id": "u098968285"}, "prompt_components": {"gold_output": "777773\n", "input_to_evaluate": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\nimport scala.collection.mutable.{Map, Queue, PriorityQueue}\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val N, M = in.next().toInt\n val A = new Array[Int](M)\n for (i <- 0 until M)\n A(i) = in.next().toInt\n\n //\n val map = Map(\n 1 -> 2, 2 -> 5, 3 -> 5,\n 4 -> 4, 5 -> 5, 6 -> 6,\n 7 -> 3, 8 -> 7, 9 -> 6\n )\n\n\n val dp = new Array[Int](N+1)\n val init = -1\n for (i <- 0 to N)\n dp(i) = init\n\n dp(0) = 0\n for (i <- 1 to N) {\n for (e <- A) {\n val diff = i - map(e)\n if (diff >= 0) {\n if (dp(i) == 0)\n dp(i) = dp(diff) + 1\n else\n dp(i) = Math.max(dp(i), dp(diff) + 1)\n }\n }\n }\n\n var now = N\n var ans = \"\"\n while (now > 0) {\n breakable {\n for (i <- (1 to 9).reverse) {\n val diff = now - map(i)\n if (A.contains(i) && diff >= 0) {\n if (dp(diff) == dp(now) - 1) {\n now = diff\n ans += i.toString\n break\n }\n }\n }\n }\n }\n\n println(ans)\n}\n\n\nclass InputReader(stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream))\n private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nFind the largest integer that can be formed with exactly N matchsticks, under the following conditions:\n\nEvery digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \\leq A_i \\leq 9).\n\nThe number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectively.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^4\n\n1 \\leq M \\leq 9\n\n1 \\leq A_i \\leq 9\n\nA_i are all different.\n\nThere exists an integer that can be formed by exactly N matchsticks under the conditions.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_M\n\nOutput\n\nPrint the largest integer that can be formed with exactly N matchsticks under the conditions in the problem statement.\n\nSample Input 1\n\n20 4\n3 7 8 4\n\nSample Output 1\n\n777773\n\nThe integer 777773 can be formed with 3 + 3 + 3 + 3 + 3 + 5 = 20 matchsticks, and this is the largest integer that can be formed by 20 matchsticks under the conditions.\n\nSample Input 2\n\n101 9\n9 8 7 6 5 4 3 2 1\n\nSample Output 2\n\n71111111111111111111111111111111111111111111111111\n\nThe output may not fit into a 64-bit integer type.\n\nSample Input 3\n\n15 3\n5 4 6\n\nSample Output 3\n\n654", "sample_input": "20 4\n3 7 8 4\n"}, "reference_outputs": ["777773\n"], "source_document_id": "p03128", "source_text": "Score : 400 points\n\nProblem Statement\n\nFind the largest integer that can be formed with exactly N matchsticks, under the following conditions:\n\nEvery digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \\leq A_i \\leq 9).\n\nThe number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectively.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^4\n\n1 \\leq M \\leq 9\n\n1 \\leq A_i \\leq 9\n\nA_i are all different.\n\nThere exists an integer that can be formed by exactly N matchsticks under the conditions.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_M\n\nOutput\n\nPrint the largest integer that can be formed with exactly N matchsticks under the conditions in the problem statement.\n\nSample Input 1\n\n20 4\n3 7 8 4\n\nSample Output 1\n\n777773\n\nThe integer 777773 can be formed with 3 + 3 + 3 + 3 + 3 + 5 = 20 matchsticks, and this is the largest integer that can be formed by 20 matchsticks under the conditions.\n\nSample Input 2\n\n101 9\n9 8 7 6 5 4 3 2 1\n\nSample Output 2\n\n71111111111111111111111111111111111111111111111111\n\nThe output may not fit into a 64-bit integer type.\n\nSample Input 3\n\n15 3\n5 4 6\n\nSample Output 3\n\n654", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1513, "cpu_time_ms": 592, "memory_kb": 63428}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s759633640", "group_id": "codeNet:p03128", "input_text": "import scala.io.StdIn.readLine\n\nobject Main{\n def main(args : Array[String]): Unit ={\n val Array(n, m) : Array[Int] = readLine().split(' ').map(_.toInt)\n val can : Array[Int] = readLine().split(' ').map(_.toInt)\n val SLV = new SOLVE(n, can)\n println(SLV.solve(n))\n }\n}\n\nclass SOLVE(private val n : Int, private val can : Array[Int]){\n val COST : Array[Int] = Array(0, 2, 5, 5, 4, 5, 6, 3, 7, 6)\n val DP : Array[BigInt] = Array.fill(n + 10)(-1)\n DP(0) = 0\n def solve(k : Int): BigInt ={\n if(DP(k) != -1) DP(k)\n else{\n for(ele <- can){\n val idx = k - COST(ele)\n if(idx >= 0) if(DP(k) < ele + 10 * solve(idx)) DP(k) = ele + 10 * solve(idx)\n }\n }\n DP(k)\n }\n}", "language": "Scala", "metadata": {"date": 1550456970, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03128.html", "problem_id": "p03128", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03128/input.txt", "sample_output_relpath": "derived/input_output/data/p03128/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03128/Scala/s759633640.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s759633640", "user_id": "u394853232"}, "prompt_components": {"gold_output": "777773\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main{\n def main(args : Array[String]): Unit ={\n val Array(n, m) : Array[Int] = readLine().split(' ').map(_.toInt)\n val can : Array[Int] = readLine().split(' ').map(_.toInt)\n val SLV = new SOLVE(n, can)\n println(SLV.solve(n))\n }\n}\n\nclass SOLVE(private val n : Int, private val can : Array[Int]){\n val COST : Array[Int] = Array(0, 2, 5, 5, 4, 5, 6, 3, 7, 6)\n val DP : Array[BigInt] = Array.fill(n + 10)(-1)\n DP(0) = 0\n def solve(k : Int): BigInt ={\n if(DP(k) != -1) DP(k)\n else{\n for(ele <- can){\n val idx = k - COST(ele)\n if(idx >= 0) if(DP(k) < ele + 10 * solve(idx)) DP(k) = ele + 10 * solve(idx)\n }\n }\n DP(k)\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nFind the largest integer that can be formed with exactly N matchsticks, under the following conditions:\n\nEvery digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \\leq A_i \\leq 9).\n\nThe number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectively.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^4\n\n1 \\leq M \\leq 9\n\n1 \\leq A_i \\leq 9\n\nA_i are all different.\n\nThere exists an integer that can be formed by exactly N matchsticks under the conditions.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_M\n\nOutput\n\nPrint the largest integer that can be formed with exactly N matchsticks under the conditions in the problem statement.\n\nSample Input 1\n\n20 4\n3 7 8 4\n\nSample Output 1\n\n777773\n\nThe integer 777773 can be formed with 3 + 3 + 3 + 3 + 3 + 5 = 20 matchsticks, and this is the largest integer that can be formed by 20 matchsticks under the conditions.\n\nSample Input 2\n\n101 9\n9 8 7 6 5 4 3 2 1\n\nSample Output 2\n\n71111111111111111111111111111111111111111111111111\n\nThe output may not fit into a 64-bit integer type.\n\nSample Input 3\n\n15 3\n5 4 6\n\nSample Output 3\n\n654", "sample_input": "20 4\n3 7 8 4\n"}, "reference_outputs": ["777773\n"], "source_document_id": "p03128", "source_text": "Score : 400 points\n\nProblem Statement\n\nFind the largest integer that can be formed with exactly N matchsticks, under the following conditions:\n\nEvery digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \\leq A_i \\leq 9).\n\nThe number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectively.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^4\n\n1 \\leq M \\leq 9\n\n1 \\leq A_i \\leq 9\n\nA_i are all different.\n\nThere exists an integer that can be formed by exactly N matchsticks under the conditions.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_M\n\nOutput\n\nPrint the largest integer that can be formed with exactly N matchsticks under the conditions in the problem statement.\n\nSample Input 1\n\n20 4\n3 7 8 4\n\nSample Output 1\n\n777773\n\nThe integer 777773 can be formed with 3 + 3 + 3 + 3 + 3 + 5 = 20 matchsticks, and this is the largest integer that can be formed by 20 matchsticks under the conditions.\n\nSample Input 2\n\n101 9\n9 8 7 6 5 4 3 2 1\n\nSample Output 2\n\n71111111111111111111111111111111111111111111111111\n\nThe output may not fit into a 64-bit integer type.\n\nSample Input 3\n\n15 3\n5 4 6\n\nSample Output 3\n\n654", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 633, "memory_kb": 55028}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s313765341", "group_id": "codeNet:p03129", "input_text": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\nimport java.lang\n\nimport scala.annotation.tailrec\nimport scala.collection.mutable.ArrayBuffer\nimport scala.reflect.ClassTag\n\nobject Main {\n def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {\n converter(in.readLine)\n }\n\n def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {\n get[String].split(\"\\\\s+\").map[T](converter)\n }\n\n implicit val idConverter: String => String = s => s\n implicit val intConverter: String => Int = s => Integer.parseInt(s)\n implicit val longConverter: String => Long = s => lang.Long.parseLong(s)\n\n def get[T1, T2](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2\n ): (T1, T2) = {\n getArray[String] match {\n case Array(v1, v2) => (converter1(v1), converter2(v2))\n }\n }\n\n def get[T1, T2, T3](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3\n ): (T1, T2, T3) = {\n getArray[String] match {\n case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))\n }\n }\n\n def get[T1, T2, T3, T4](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3,\n converter4: String => T4\n ): (T1, T2, T3, T4) = {\n getArray[String] match {\n case Array(v1, v2, v3, v4) => (converter1(v1), converter2(v2), converter3(v3), converter4(v4))\n }\n }\n\n implicit class TimesInt(val n: Int) {\n def times(f: Int => Unit): Unit = {\n for (i <- 0 until n) {\n f(i)\n }\n }\n }\n\n def primes(n: Long): ArrayBuffer[Long] = {\n val buf = ArrayBuffer.empty[Long]\n val s = Math.sqrt(n).toInt\n\n var v = n\n for (i <- 2 to s) {\n if (v == 1 || v == 0) {\n return buf\n } else {\n while (v % i == 0) {\n buf.append(i)\n v /= i\n }\n }\n }\n if (v > s) {\n buf.append(v)\n }\n buf\n }\n\n def divisors(n: Int): ArrayBuffer[Int] = {\n val buf = ArrayBuffer.empty[Int]\n val s = Math.sqrt(n).toInt\n\n for (i <- 1 to s) {\n if (n % i == 0) {\n buf.append(i)\n if (i != n / i) {\n buf.append(n / i)\n }\n }\n }\n buf\n }\n\n @tailrec\n def gcd(a: Long, b: Long): Long = {\n val reminder = a % b\n if (reminder == 0) {\n b\n } else {\n gcd(b, reminder)\n }\n }\n\n def lcm(a: Long, b: Long): Long = {\n a / gcd(a, b) * b\n }\n\n def toBitArray(n: Int, width: Int): Array[Boolean] = {\n val buf = ArrayBuffer.fill(width)(false)\n\n @tailrec\n def inner(n: Int, i: Int): Array[Boolean] = {\n buf(i) = (n & 1) == 0\n if (i == 0) {\n buf.toArray\n } else {\n inner(n / 2, i - 1)\n }\n }\n\n inner(n, width - 1)\n }\n\n def modpow(n: Long, p: Long, m: Long): Long = {\n @tailrec\n def inner(n: Long, p: Long, acc: Long): Long = {\n if (p == 0) {\n acc\n } else if ((p & 1) == 0) {\n inner(n * n % m, p >> 1, acc)\n } else {\n inner(n * n % m, p >> 1, acc * n % m)\n }\n }\n\n inner(n % m, p, 1)\n }\n\n def main(args: Array[String]): Unit = {\n implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n val (n, k) = get[Int, Int]\n\n out.println(\n if (n >= k * 2 - 1) {\n \"YES\"\n } else {\n \"NO\"\n }\n )\n\n out.flush()\n }\n}", "language": "Scala", "metadata": {"date": 1593830773, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s313765341.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s313765341", "user_id": "u178269371"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\nimport java.lang\n\nimport scala.annotation.tailrec\nimport scala.collection.mutable.ArrayBuffer\nimport scala.reflect.ClassTag\n\nobject Main {\n def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {\n converter(in.readLine)\n }\n\n def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {\n get[String].split(\"\\\\s+\").map[T](converter)\n }\n\n implicit val idConverter: String => String = s => s\n implicit val intConverter: String => Int = s => Integer.parseInt(s)\n implicit val longConverter: String => Long = s => lang.Long.parseLong(s)\n\n def get[T1, T2](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2\n ): (T1, T2) = {\n getArray[String] match {\n case Array(v1, v2) => (converter1(v1), converter2(v2))\n }\n }\n\n def get[T1, T2, T3](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3\n ): (T1, T2, T3) = {\n getArray[String] match {\n case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))\n }\n }\n\n def get[T1, T2, T3, T4](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3,\n converter4: String => T4\n ): (T1, T2, T3, T4) = {\n getArray[String] match {\n case Array(v1, v2, v3, v4) => (converter1(v1), converter2(v2), converter3(v3), converter4(v4))\n }\n }\n\n implicit class TimesInt(val n: Int) {\n def times(f: Int => Unit): Unit = {\n for (i <- 0 until n) {\n f(i)\n }\n }\n }\n\n def primes(n: Long): ArrayBuffer[Long] = {\n val buf = ArrayBuffer.empty[Long]\n val s = Math.sqrt(n).toInt\n\n var v = n\n for (i <- 2 to s) {\n if (v == 1 || v == 0) {\n return buf\n } else {\n while (v % i == 0) {\n buf.append(i)\n v /= i\n }\n }\n }\n if (v > s) {\n buf.append(v)\n }\n buf\n }\n\n def divisors(n: Int): ArrayBuffer[Int] = {\n val buf = ArrayBuffer.empty[Int]\n val s = Math.sqrt(n).toInt\n\n for (i <- 1 to s) {\n if (n % i == 0) {\n buf.append(i)\n if (i != n / i) {\n buf.append(n / i)\n }\n }\n }\n buf\n }\n\n @tailrec\n def gcd(a: Long, b: Long): Long = {\n val reminder = a % b\n if (reminder == 0) {\n b\n } else {\n gcd(b, reminder)\n }\n }\n\n def lcm(a: Long, b: Long): Long = {\n a / gcd(a, b) * b\n }\n\n def toBitArray(n: Int, width: Int): Array[Boolean] = {\n val buf = ArrayBuffer.fill(width)(false)\n\n @tailrec\n def inner(n: Int, i: Int): Array[Boolean] = {\n buf(i) = (n & 1) == 0\n if (i == 0) {\n buf.toArray\n } else {\n inner(n / 2, i - 1)\n }\n }\n\n inner(n, width - 1)\n }\n\n def modpow(n: Long, p: Long, m: Long): Long = {\n @tailrec\n def inner(n: Long, p: Long, acc: Long): Long = {\n if (p == 0) {\n acc\n } else if ((p & 1) == 0) {\n inner(n * n % m, p >> 1, acc)\n } else {\n inner(n * n % m, p >> 1, acc * n % m)\n }\n }\n\n inner(n % m, p, 1)\n }\n\n def main(args: Array[String]): Unit = {\n implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n val (n, k) = get[Int, Int]\n\n out.println(\n if (n >= k * 2 - 1) {\n \"YES\"\n } else {\n \"NO\"\n }\n )\n\n out.flush()\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3847, "cpu_time_ms": 487, "memory_kb": 57028}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s769020687", "group_id": "codeNet:p03136", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val list = List.fill(n)(sc.nextInt)\n if(list.max < list.sum - list.max){\n println(\"Yes\")\n }\n else{\n println(\"No\")\n }\n }\n}", "language": "Scala", "metadata": {"date": 1549251852, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03136.html", "problem_id": "p03136", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03136/input.txt", "sample_output_relpath": "derived/input_output/data/p03136/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03136/Scala/s769020687.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s769020687", "user_id": "u340881840"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val list = List.fill(n)(sc.nextInt)\n if(list.max < list.sum - list.max){\n println(\"Yes\")\n }\n else{\n println(\"No\")\n }\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nDetermine if an N-sided polygon (not necessarily convex) with sides of length L_1, L_2, ..., L_N can be drawn in a two-dimensional plane.\n\nYou can use the following theorem:\n\nTheorem: an N-sided polygon satisfying the condition can be drawn if and only if the longest side is strictly shorter than the sum of the lengths of the other N-1 sides.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 10\n\n1 \\leq L_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_N\n\nOutput\n\nIf an N-sided polygon satisfying the condition can be drawn, print Yes; otherwise, print No.\n\nSample Input 1\n\n4\n3 8 5 1\n\nSample Output 1\n\nYes\n\nSince 8 < 9 = 3 + 5 + 1, it follows from the theorem that such a polygon can be drawn on a plane.\n\nSample Input 2\n\n4\n3 8 4 1\n\nSample Output 2\n\nNo\n\nSince 8 \\geq 8 = 3 + 4 + 1, it follows from the theorem that such a polygon cannot be drawn on a plane.\n\nSample Input 3\n\n10\n1 8 10 5 8 12 34 100 11 3\n\nSample Output 3\n\nNo", "sample_input": "4\n3 8 5 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03136", "source_text": "Score : 200 points\n\nProblem Statement\n\nDetermine if an N-sided polygon (not necessarily convex) with sides of length L_1, L_2, ..., L_N can be drawn in a two-dimensional plane.\n\nYou can use the following theorem:\n\nTheorem: an N-sided polygon satisfying the condition can be drawn if and only if the longest side is strictly shorter than the sum of the lengths of the other N-1 sides.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 10\n\n1 \\leq L_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_N\n\nOutput\n\nIf an N-sided polygon satisfying the condition can be drawn, print Yes; otherwise, print No.\n\nSample Input 1\n\n4\n3 8 5 1\n\nSample Output 1\n\nYes\n\nSince 8 < 9 = 3 + 5 + 1, it follows from the theorem that such a polygon can be drawn on a plane.\n\nSample Input 2\n\n4\n3 8 4 1\n\nSample Output 2\n\nNo\n\nSince 8 \\geq 8 = 3 + 4 + 1, it follows from the theorem that such a polygon cannot be drawn on a plane.\n\nSample Input 3\n\n10\n1 8 10 5 8 12 34 100 11 3\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 345, "memory_kb": 25536}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s696253785", "group_id": "codeNet:p03137", "input_text": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val n, m = in.nextInt\n val xs = Array.fill(m)(in.nextInt).sorted\n val spaces = xs.zip(xs.tail).map(s => s._2 - s._1)\n println(spaces.sorted.reverse.drop(n - 1).sum)\n}", "language": "Scala", "metadata": {"date": 1577474681, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03137.html", "problem_id": "p03137", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03137/input.txt", "sample_output_relpath": "derived/input_output/data/p03137/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03137/Scala/s696253785.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s696253785", "user_id": "u132324749"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val n, m = in.nextInt\n val xs = Array.fill(m)(in.nextInt).sorted\n val spaces = xs.zip(xs.tail).map(s => s._2 - s._1)\n println(spaces.sorted.reverse.drop(n - 1).sum)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe will play a one-player game using a number line and N pieces.\n\nFirst, we place each of these pieces at some integer coordinate.\n\nHere, multiple pieces can be placed at the same coordinate.\n\nOur objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:\n\nMove: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.\n\nNote that the coordinates where we initially place the pieces are already regarded as visited.\n\nFind the minimum number of moves required to achieve the objective.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n-10^5 \\leq X_i \\leq 10^5\n\nX_1, X_2, ..., X_M are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 X_2 ... X_M\n\nOutput\n\nFind the minimum number of moves required to achieve the objective.\n\nSample Input 1\n\n2 5\n10 12 1 2 14\n\nSample Output 1\n\n5\n\nThe objective can be achieved in five moves as follows, and this is the minimum number of moves required.\n\nInitially, put the two pieces at coordinates 1 and 10.\n\nMove the piece at coordinate 1 to 2.\n\nMove the piece at coordinate 10 to 11.\n\nMove the piece at coordinate 11 to 12.\n\nMove the piece at coordinate 12 to 13.\n\nMove the piece at coordinate 13 to 14.\n\nSample Input 2\n\n3 7\n-10 -3 0 9 -100 2 17\n\nSample Output 2\n\n19\n\nSample Input 3\n\n100 1\n-100000\n\nSample Output 3\n\n0", "sample_input": "2 5\n10 12 1 2 14\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03137", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe will play a one-player game using a number line and N pieces.\n\nFirst, we place each of these pieces at some integer coordinate.\n\nHere, multiple pieces can be placed at the same coordinate.\n\nOur objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:\n\nMove: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.\n\nNote that the coordinates where we initially place the pieces are already regarded as visited.\n\nFind the minimum number of moves required to achieve the objective.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n-10^5 \\leq X_i \\leq 10^5\n\nX_1, X_2, ..., X_M are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 X_2 ... X_M\n\nOutput\n\nFind the minimum number of moves required to achieve the objective.\n\nSample Input 1\n\n2 5\n10 12 1 2 14\n\nSample Output 1\n\n5\n\nThe objective can be achieved in five moves as follows, and this is the minimum number of moves required.\n\nInitially, put the two pieces at coordinates 1 and 10.\n\nMove the piece at coordinate 1 to 2.\n\nMove the piece at coordinate 10 to 11.\n\nMove the piece at coordinate 11 to 12.\n\nMove the piece at coordinate 12 to 13.\n\nMove the piece at coordinate 13 to 14.\n\nSample Input 2\n\n3 7\n-10 -3 0 9 -100 2 17\n\nSample Output 2\n\n19\n\nSample Input 3\n\n100 1\n-100000\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1024, "memory_kb": 64296}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s034311383", "group_id": "codeNet:p03137", "input_text": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n\n def solve(sc: => Scanner): Unit = {\n val N, M = sc.nextInt()\n println(if (N < M) Array.fill(M)(sc.nextLong()).sorted.sliding(2).map(a => a(1) - a(0)).toArray.sorted.reverse.drop(N - 1).sum else 0)\n }\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def calc(N: Long, R: Long, M: Long): Double = {\n math.sqrt(R * R - (R * 2 * ((M * 1.0 / N) - 0.5)) * (R * 2 * ((M * 1.0 / N) - 0.5))) * 2\n }\n\n def recursive(A: Array[Long]): Long = {\n val B = A.dropWhile(x => x == 0)\n if (B.length == 0) 0 else {\n recursive(B.takeWhile(x => x != 0).map(i => i - 1)) + recursive(B.dropWhile(x => x != 0)) + 1\n }\n }\n\n def recursive2(X: Set[Long], Y: Stream[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n\n def check(s: String): Boolean = {\n if (s == \"0\") true\n else s(0) != '0' && 0 <= s.toInt && s.toInt <= 255\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n}", "language": "Scala", "metadata": {"date": 1549509328, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03137.html", "problem_id": "p03137", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03137/input.txt", "sample_output_relpath": "derived/input_output/data/p03137/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03137/Scala/s034311383.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s034311383", "user_id": "u779353743"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n\n def solve(sc: => Scanner): Unit = {\n val N, M = sc.nextInt()\n println(if (N < M) Array.fill(M)(sc.nextLong()).sorted.sliding(2).map(a => a(1) - a(0)).toArray.sorted.reverse.drop(N - 1).sum else 0)\n }\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def calc(N: Long, R: Long, M: Long): Double = {\n math.sqrt(R * R - (R * 2 * ((M * 1.0 / N) - 0.5)) * (R * 2 * ((M * 1.0 / N) - 0.5))) * 2\n }\n\n def recursive(A: Array[Long]): Long = {\n val B = A.dropWhile(x => x == 0)\n if (B.length == 0) 0 else {\n recursive(B.takeWhile(x => x != 0).map(i => i - 1)) + recursive(B.dropWhile(x => x != 0)) + 1\n }\n }\n\n def recursive2(X: Set[Long], Y: Stream[Long]): Long = if (X.contains(Y.head)) X.size else recursive2(X + Y.head, Y.tail)\n\n def check(s: String): Boolean = {\n if (s == \"0\") true\n else s(0) != '0' && 0 <= s.toInt && s.toInt <= 255\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe will play a one-player game using a number line and N pieces.\n\nFirst, we place each of these pieces at some integer coordinate.\n\nHere, multiple pieces can be placed at the same coordinate.\n\nOur objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:\n\nMove: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.\n\nNote that the coordinates where we initially place the pieces are already regarded as visited.\n\nFind the minimum number of moves required to achieve the objective.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n-10^5 \\leq X_i \\leq 10^5\n\nX_1, X_2, ..., X_M are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 X_2 ... X_M\n\nOutput\n\nFind the minimum number of moves required to achieve the objective.\n\nSample Input 1\n\n2 5\n10 12 1 2 14\n\nSample Output 1\n\n5\n\nThe objective can be achieved in five moves as follows, and this is the minimum number of moves required.\n\nInitially, put the two pieces at coordinates 1 and 10.\n\nMove the piece at coordinate 1 to 2.\n\nMove the piece at coordinate 10 to 11.\n\nMove the piece at coordinate 11 to 12.\n\nMove the piece at coordinate 12 to 13.\n\nMove the piece at coordinate 13 to 14.\n\nSample Input 2\n\n3 7\n-10 -3 0 9 -100 2 17\n\nSample Output 2\n\n19\n\nSample Input 3\n\n100 1\n-100000\n\nSample Output 3\n\n0", "sample_input": "2 5\n10 12 1 2 14\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03137", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe will play a one-player game using a number line and N pieces.\n\nFirst, we place each of these pieces at some integer coordinate.\n\nHere, multiple pieces can be placed at the same coordinate.\n\nOur objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:\n\nMove: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.\n\nNote that the coordinates where we initially place the pieces are already regarded as visited.\n\nFind the minimum number of moves required to achieve the objective.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n-10^5 \\leq X_i \\leq 10^5\n\nX_1, X_2, ..., X_M are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 X_2 ... X_M\n\nOutput\n\nFind the minimum number of moves required to achieve the objective.\n\nSample Input 1\n\n2 5\n10 12 1 2 14\n\nSample Output 1\n\n5\n\nThe objective can be achieved in five moves as follows, and this is the minimum number of moves required.\n\nInitially, put the two pieces at coordinates 1 and 10.\n\nMove the piece at coordinate 1 to 2.\n\nMove the piece at coordinate 10 to 11.\n\nMove the piece at coordinate 11 to 12.\n\nMove the piece at coordinate 12 to 13.\n\nMove the piece at coordinate 13 to 14.\n\nSample Input 2\n\n3 7\n-10 -3 0 9 -100 2 17\n\nSample Output 2\n\n19\n\nSample Input 3\n\n100 1\n-100000\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6256, "cpu_time_ms": 1285, "memory_kb": 54320}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s292080398", "group_id": "codeNet:p03142", "input_text": "import scala.collection.mutable\nobject Main extends App {\n import scala.io.StdIn._\n\n val Array(n, m) = readLine.trim.split(' ').map(_.toInt)\n val inEdgeCount = Array.tabulate(n){_ ⇒ 0}\n val edges = Array.tabulate(n){_ ⇒ Nil: List[Int]}\n for (_ ← 1 until n + m){\n val Array(a, b) = readLine.trim.split(' ').map(_.toInt - 1)\n inEdgeCount(b) += 1\n edges(a) ::= b\n }\n val root = inEdgeCount.indexWhere(_ == 0)\n println(bfs(root).mkString(\"\\n\"))\n def bfs(root: Int): Array[Int] = {\n val prevs = Array.tabulate(n){_ ⇒ 0}\n val queue = mutable.Queue[Int](root)\n while(queue.nonEmpty){\n val top = queue.dequeue()\n for (next ← edges(top)) {\n queue.enqueue(next)\n prevs(next) = top + 1\n }\n }\n prevs\n }\n}", "language": "Scala", "metadata": {"date": 1548642933, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03142.html", "problem_id": "p03142", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03142/input.txt", "sample_output_relpath": "derived/input_output/data/p03142/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03142/Scala/s292080398.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s292080398", "user_id": "u419330815"}, "prompt_components": {"gold_output": "0\n1\n2\n", "input_to_evaluate": "import scala.collection.mutable\nobject Main extends App {\n import scala.io.StdIn._\n\n val Array(n, m) = readLine.trim.split(' ').map(_.toInt)\n val inEdgeCount = Array.tabulate(n){_ ⇒ 0}\n val edges = Array.tabulate(n){_ ⇒ Nil: List[Int]}\n for (_ ← 1 until n + m){\n val Array(a, b) = readLine.trim.split(' ').map(_.toInt - 1)\n inEdgeCount(b) += 1\n edges(a) ::= b\n }\n val root = inEdgeCount.indexWhere(_ == 0)\n println(bfs(root).mkString(\"\\n\"))\n def bfs(root: Int): Array[Int] = {\n val prevs = Array.tabulate(n){_ ⇒ 0}\n val queue = mutable.Queue[Int](root)\n while(queue.nonEmpty){\n val top = queue.dequeue()\n for (next ← edges(top)) {\n queue.enqueue(next)\n prevs(next) = top + 1\n }\n }\n prevs\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere is a rooted tree (see Notes) with N vertices numbered 1 to N.\nEach of the vertices, except the root, has a directed edge coming from its parent.\nNote that the root may not be Vertex 1.\n\nTakahashi has added M new directed edges to this graph.\nEach of these M edges, u \\rightarrow v, extends from some vertex u to its descendant v.\n\nYou are given the directed graph with N vertices and N-1+M edges after Takahashi added edges.\nMore specifically, you are given N-1+M pairs of integers, (A_1, B_1), ..., (A_{N-1+M}, B_{N-1+M}), which represent that the i-th edge extends from Vertex A_i to Vertex B_i.\n\nRestore the original rooted tree.\n\nNotes\n\nFor \"tree\" and other related terms in graph theory, see the article in Wikipedia, for example.\n\nConstraints\n\n3 \\leq N\n\n1 \\leq M\n\nN + M \\leq 10^5\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\nIf i \\neq j, (A_i, B_i) \\neq (A_j, B_j).\n\nThe graph in input can be obtained by adding M edges satisfying the condition in the problem statement to a rooted tree with N vertices.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n:\nA_{N-1+M} B_{N-1+M}\n\nOutput\n\nPrint N lines.\nIn the i-th line, print 0 if Vertex i is the root of the original tree, and otherwise print the integer representing the parent of Vertex i in the original tree.\n\nNote that it can be shown that the original tree is uniquely determined.\n\nSample Input 1\n\n3 1\n1 2\n1 3\n2 3\n\nSample Output 1\n\n0\n1\n2\n\nThe graph in this input is shown below:\n\nIt can be seen that this graph is obtained by adding the edge 1 \\rightarrow 3 to the rooted tree 1 \\rightarrow 2 \\rightarrow 3.\n\nSample Input 2\n\n6 3\n2 1\n2 3\n4 1\n4 2\n6 1\n2 6\n4 6\n6 5\n\nSample Output 2\n\n6\n4\n2\n0\n6\n2", "sample_input": "3 1\n1 2\n1 3\n2 3\n"}, "reference_outputs": ["0\n1\n2\n"], "source_document_id": "p03142", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere is a rooted tree (see Notes) with N vertices numbered 1 to N.\nEach of the vertices, except the root, has a directed edge coming from its parent.\nNote that the root may not be Vertex 1.\n\nTakahashi has added M new directed edges to this graph.\nEach of these M edges, u \\rightarrow v, extends from some vertex u to its descendant v.\n\nYou are given the directed graph with N vertices and N-1+M edges after Takahashi added edges.\nMore specifically, you are given N-1+M pairs of integers, (A_1, B_1), ..., (A_{N-1+M}, B_{N-1+M}), which represent that the i-th edge extends from Vertex A_i to Vertex B_i.\n\nRestore the original rooted tree.\n\nNotes\n\nFor \"tree\" and other related terms in graph theory, see the article in Wikipedia, for example.\n\nConstraints\n\n3 \\leq N\n\n1 \\leq M\n\nN + M \\leq 10^5\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\nIf i \\neq j, (A_i, B_i) \\neq (A_j, B_j).\n\nThe graph in input can be obtained by adding M edges satisfying the condition in the problem statement to a rooted tree with N vertices.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n:\nA_{N-1+M} B_{N-1+M}\n\nOutput\n\nPrint N lines.\nIn the i-th line, print 0 if Vertex i is the root of the original tree, and otherwise print the integer representing the parent of Vertex i in the original tree.\n\nNote that it can be shown that the original tree is uniquely determined.\n\nSample Input 1\n\n3 1\n1 2\n1 3\n2 3\n\nSample Output 1\n\n0\n1\n2\n\nThe graph in this input is shown below:\n\nIt can be seen that this graph is obtained by adding the edge 1 \\rightarrow 3 to the rooted tree 1 \\rightarrow 2 \\rightarrow 3.\n\nSample Input 2\n\n6 3\n2 1\n2 3\n4 1\n4 2\n6 1\n2 6\n4 6\n6 5\n\nSample Output 2\n\n6\n4\n2\n0\n6\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 765, "cpu_time_ms": 2119, "memory_kb": 180640}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s697636418", "group_id": "codeNet:p03143", "input_text": "import scala.collection.mutable\nobject Main extends App {\n import scala.io.StdIn._\n\n val Array(n, m) = readLine.trim.split(' ').map(_.toInt)\n val vertexs = readLine.trim.split(' ').map(_.toLong)\n val union = vertexs.map(w ⇒ new UnionFindTree(w))\n val nodes = Array.tabulate(n){_ ⇒ Nil: List[(Int, Long)]}\n val edges = Array.tabulate(m){_ ⇒\n val Array(a, b, y) = readLine.trim.split(' ').map(_.toInt)\n nodes(a - 1) ::= (b - 1, y)\n nodes(b - 1) ::= (a - 1, y)\n Edge(a - 1, b - 1, y)\n }.sortBy(_.weight)\n val needNotRemove = Array.tabulate(m){_ ⇒ false}\n for (i ← edges.indices){\n union(edges(i).from).merge(union(edges(i).to))\n if (union(edges(i).from).weight >= edges(i).weight) {\n needNotRemove(i) = true\n }\n }\n val max = Array.tabulate(n){_ ⇒ 0L}\n val queue = mutable.Queue[Int]()\n for (i ← needNotRemove.indices if needNotRemove(i)){\n val weight = edges(i).weight\n if (max(edges(i).from) < weight) {\n queue.enqueue(edges(i).from)\n max(edges(i).from) = weight\n while (queue.nonEmpty) {\n val top = queue.dequeue()\n for ((to, w) ← nodes(top) if w <= weight && max(to) < weight) {\n max(to) = weight\n queue.enqueue(to)\n }\n }\n }\n }\n\n println(edges.count(e ⇒ max(e.from) < e.weight || max(e.to) < e.weight))\n\n case class Edge(from: Int, to: Int, weight: Long)\n class UnionFindTree(private var mWeight: Long){\n private var mParent: Option[UnionFindTree] = None\n private var mSize: Int = 1\n private def parent: UnionFindTree = {\n mParent.map{_.parent} match {\n case None ⇒ this\n case c@Some(p) ⇒\n mParent = c\n p\n }\n }\n def weight: Long = parent.mWeight\n def size: Int = parent.mSize\n def isTop: Boolean = mParent.isEmpty\n def isSameUnion(that: UnionFindTree): Boolean = {\n parent == that.parent\n }\n def merge(that: UnionFindTree): Unit = {\n if (!isSameUnion(that)){\n val p = parent\n val tp = that.parent\n if (p.mSize > tp.mSize){\n tp.mParent = Some(p)\n p.mSize += tp.mSize\n p.mWeight += tp.mWeight\n }else {\n p.mParent = Some(tp)\n tp.mSize += p.mSize\n tp.mWeight += p.mWeight\n }\n }\n }\n }\n}", "language": "Scala", "metadata": {"date": 1548646144, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03143.html", "problem_id": "p03143", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03143/input.txt", "sample_output_relpath": "derived/input_output/data/p03143/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03143/Scala/s697636418.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s697636418", "user_id": "u419330815"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.collection.mutable\nobject Main extends App {\n import scala.io.StdIn._\n\n val Array(n, m) = readLine.trim.split(' ').map(_.toInt)\n val vertexs = readLine.trim.split(' ').map(_.toLong)\n val union = vertexs.map(w ⇒ new UnionFindTree(w))\n val nodes = Array.tabulate(n){_ ⇒ Nil: List[(Int, Long)]}\n val edges = Array.tabulate(m){_ ⇒\n val Array(a, b, y) = readLine.trim.split(' ').map(_.toInt)\n nodes(a - 1) ::= (b - 1, y)\n nodes(b - 1) ::= (a - 1, y)\n Edge(a - 1, b - 1, y)\n }.sortBy(_.weight)\n val needNotRemove = Array.tabulate(m){_ ⇒ false}\n for (i ← edges.indices){\n union(edges(i).from).merge(union(edges(i).to))\n if (union(edges(i).from).weight >= edges(i).weight) {\n needNotRemove(i) = true\n }\n }\n val max = Array.tabulate(n){_ ⇒ 0L}\n val queue = mutable.Queue[Int]()\n for (i ← needNotRemove.indices if needNotRemove(i)){\n val weight = edges(i).weight\n if (max(edges(i).from) < weight) {\n queue.enqueue(edges(i).from)\n max(edges(i).from) = weight\n while (queue.nonEmpty) {\n val top = queue.dequeue()\n for ((to, w) ← nodes(top) if w <= weight && max(to) < weight) {\n max(to) = weight\n queue.enqueue(to)\n }\n }\n }\n }\n\n println(edges.count(e ⇒ max(e.from) < e.weight || max(e.to) < e.weight))\n\n case class Edge(from: Int, to: Int, weight: Long)\n class UnionFindTree(private var mWeight: Long){\n private var mParent: Option[UnionFindTree] = None\n private var mSize: Int = 1\n private def parent: UnionFindTree = {\n mParent.map{_.parent} match {\n case None ⇒ this\n case c@Some(p) ⇒\n mParent = c\n p\n }\n }\n def weight: Long = parent.mWeight\n def size: Int = parent.mSize\n def isTop: Boolean = mParent.isEmpty\n def isSameUnion(that: UnionFindTree): Boolean = {\n parent == that.parent\n }\n def merge(that: UnionFindTree): Unit = {\n if (!isSameUnion(that)){\n val p = parent\n val tp = that.parent\n if (p.mSize > tp.mSize){\n tp.mParent = Some(p)\n p.mSize += tp.mSize\n p.mWeight += tp.mWeight\n }else {\n p.mParent = Some(tp)\n tp.mSize += p.mSize\n tp.mWeight += p.mWeight\n }\n }\n }\n }\n}", "problem_context": "Score : 800 points\n\nProblem Statement\n\nThere is a connected undirected graph with N vertices and M edges.\nThe vertices are numbered 1 to N, and the edges are numbered 1 to M.\nAlso, each of these vertices and edges has a specified weight.\nVertex i has a weight of X_i; Edge i has a weight of Y_i and connects Vertex A_i and B_i.\n\nWe would like to remove zero or more edges so that the following condition is satisfied:\n\nFor each edge that is not removed, the sum of the weights of the vertices in the connected component containing that edge, is greater than or equal to the weight of that edge.\n\nFind the minimum number of edges that need to be removed.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nN-1 \\leq M \\leq 10^5\n\n1 \\leq X_i \\leq 10^9\n\n1 \\leq A_i < B_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\n(A_i,B_i) \\neq (A_j,B_j) (i \\neq j)\n\nThe given graph is connected.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 X_2 ... X_N\nA_1 B_1 Y_1\nA_2 B_2 Y_2\n:\nA_M B_M Y_M\n\nOutput\n\nFind the minimum number of edges that need to be removed.\n\nSample Input 1\n\n4 4\n2 3 5 7\n1 2 7\n1 3 9\n2 3 12\n3 4 18\n\nSample Output 1\n\n2\n\nAssume that we removed Edge 3 and 4.\nIn this case, the connected component containing Edge 1 contains Vertex 1, 2 and 3, and the sum of the weights of these vertices is 2+3+5=10.\nThe weight of Edge 1 is 7, so the condition is satisfied for Edge 1.\nSimilarly, it can be seen that the condition is also satisfied for Edge 2.\nThus, a graph satisfying the condition can be obtained by removing two edges.\n\nThe condition cannot be satisfied by removing one or less edges, so the answer is 2.\n\nSample Input 2\n\n6 10\n4 4 1 1 1 7\n3 5 19\n2 5 20\n4 5 8\n1 6 16\n2 3 9\n3 6 16\n3 4 1\n2 6 20\n2 4 19\n1 2 9\n\nSample Output 2\n\n4\n\nSample Input 3\n\n10 9\n81 16 73 7 2 61 86 38 90 28\n6 8 725\n3 10 12\n1 4 558\n4 9 615\n5 6 942\n8 9 918\n2 7 720\n4 7 292\n7 10 414\n\nSample Output 3\n\n8", "sample_input": "4 4\n2 3 5 7\n1 2 7\n1 3 9\n2 3 12\n3 4 18\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03143", "source_text": "Score : 800 points\n\nProblem Statement\n\nThere is a connected undirected graph with N vertices and M edges.\nThe vertices are numbered 1 to N, and the edges are numbered 1 to M.\nAlso, each of these vertices and edges has a specified weight.\nVertex i has a weight of X_i; Edge i has a weight of Y_i and connects Vertex A_i and B_i.\n\nWe would like to remove zero or more edges so that the following condition is satisfied:\n\nFor each edge that is not removed, the sum of the weights of the vertices in the connected component containing that edge, is greater than or equal to the weight of that edge.\n\nFind the minimum number of edges that need to be removed.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nN-1 \\leq M \\leq 10^5\n\n1 \\leq X_i \\leq 10^9\n\n1 \\leq A_i < B_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\n(A_i,B_i) \\neq (A_j,B_j) (i \\neq j)\n\nThe given graph is connected.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 X_2 ... X_N\nA_1 B_1 Y_1\nA_2 B_2 Y_2\n:\nA_M B_M Y_M\n\nOutput\n\nFind the minimum number of edges that need to be removed.\n\nSample Input 1\n\n4 4\n2 3 5 7\n1 2 7\n1 3 9\n2 3 12\n3 4 18\n\nSample Output 1\n\n2\n\nAssume that we removed Edge 3 and 4.\nIn this case, the connected component containing Edge 1 contains Vertex 1, 2 and 3, and the sum of the weights of these vertices is 2+3+5=10.\nThe weight of Edge 1 is 7, so the condition is satisfied for Edge 1.\nSimilarly, it can be seen that the condition is also satisfied for Edge 2.\nThus, a graph satisfying the condition can be obtained by removing two edges.\n\nThe condition cannot be satisfied by removing one or less edges, so the answer is 2.\n\nSample Input 2\n\n6 10\n4 4 1 1 1 7\n3 5 19\n2 5 20\n4 5 8\n1 6 16\n2 3 9\n3 6 16\n3 4 1\n2 6 20\n2 4 19\n1 2 9\n\nSample Output 2\n\n4\n\nSample Input 3\n\n10 9\n81 16 73 7 2 61 86 38 90 28\n6 8 725\n3 10 12\n1 4 558\n4 9 615\n5 6 942\n8 9 918\n2 7 720\n4 7 292\n7 10 414\n\nSample Output 3\n\n8", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2294, "cpu_time_ms": 2111, "memory_kb": 150596}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s957667450", "group_id": "codeNet:p03146", "input_text": "object Main extends App {\n var s = scala.io.StdIn.readInt()\n var seqInt = Seq(s)\n\n def nextJudge(i: Int): Unit = {\n var nextInt = 0\n if(i % 2 == 0) {\n nextInt = i / 2\n } else {\n nextInt = 3 * i + 1\n }\n seqInt.find(_ == nextInt).fold\n {seqInt :+= nextInt\n nextJudge(nextInt)\n }\n {_=> println(seqInt.size + 1)}\n }\n nextJudge(s)\n}", "language": "Scala", "metadata": {"date": 1548131352, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s957667450.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s957667450", "user_id": "u105921924"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "object Main extends App {\n var s = scala.io.StdIn.readInt()\n var seqInt = Seq(s)\n\n def nextJudge(i: Int): Unit = {\n var nextInt = 0\n if(i % 2 == 0) {\n nextInt = i / 2\n } else {\n nextInt = 3 * i + 1\n }\n seqInt.find(_ == nextInt).fold\n {seqInt :+= nextInt\n nextJudge(nextInt)\n }\n {_=> println(seqInt.size + 1)}\n }\n nextJudge(s)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 359, "memory_kb": 25376}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s770561393", "group_id": "codeNet:p03147", "input_text": "import java.util.Scanner\n\nimport scala.annotation.tailrec\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val n = sc.nextInt\n val hl = Seq.fill(n)(sc.nextInt)\n\n\n val res = cntLoop(hl)\n println(res)\n\n @tailrec\n def cntLoop(list: Seq[Int] , cnt: Int = 0): Int = {\n if (list.forall(_ == 0) ) cnt\n else cntLoop(elementMinusOne(list), cnt + separate(list).size)\n }\n\n @tailrec\n def separate(list: Seq[Int], lists: Seq[Seq[Int]] = Seq.empty): Seq[Seq[Int]] = {\n list match {\n case Nil => lists\n case nonEmpty => {\n val target = nonEmpty.dropWhile(_ == 0)\n val (take, drop) = target.span(_ > 0)\n val next = drop.dropWhile(_ == 0)\n separate(next, lists :+ take)\n }\n }\n }\n\n def elementMinusOne(list: Seq[Int]): Seq[Int] = {\n list.map{\n case 0 => 0\n case e => e - 1\n }\n }\n}", "language": "Scala", "metadata": {"date": 1576569731, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s770561393.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s770561393", "user_id": "u829407811"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.annotation.tailrec\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val n = sc.nextInt\n val hl = Seq.fill(n)(sc.nextInt)\n\n\n val res = cntLoop(hl)\n println(res)\n\n @tailrec\n def cntLoop(list: Seq[Int] , cnt: Int = 0): Int = {\n if (list.forall(_ == 0) ) cnt\n else cntLoop(elementMinusOne(list), cnt + separate(list).size)\n }\n\n @tailrec\n def separate(list: Seq[Int], lists: Seq[Seq[Int]] = Seq.empty): Seq[Seq[Int]] = {\n list match {\n case Nil => lists\n case nonEmpty => {\n val target = nonEmpty.dropWhile(_ == 0)\n val (take, drop) = target.span(_ > 0)\n val next = drop.dropWhile(_ == 0)\n separate(next, lists :+ take)\n }\n }\n }\n\n def elementMinusOne(list: Seq[Int]): Seq[Int] = {\n list.map{\n case 0 => 0\n case e => e - 1\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 860, "cpu_time_ms": 458, "memory_kb": 30648}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s910453896", "group_id": "codeNet:p03149", "input_text": "object Main {\n import java.util.Scanner\n\n def readStrings(n: Int)(implicit sc: Scanner): Array[String] = Array.fill(n) { sc.next() }\n def readInts(n: Int)(implicit sc: Scanner): Array[Int] = Array.fill(n) { sc.nextInt() }\n def readLongs(n: Int)(implicit sc: Scanner): Array[Long] = Array.fill(n) { sc.nextLong() }\n def readLineStrings(implicit sc: Scanner): Array[String] = sc.nextLine().split(' ')\n def readLineInts(implicit sc: Scanner): Array[Int] = readLineStrings.map(_.toInt)\n def readLineLongs(implicit sc: Scanner): Array[Long] = readLineStrings.map(_.toLong)\n\n def main(args: Array[String]): Unit = solve(new Scanner(System.in))\n\n def solve(implicit sc: Scanner): Unit = {\n val N = readLineInts\n if(Seq(1, 7, 9, 4).map(n => N.count(_ == n) == 1).forall(identity)) {\n println(\"YES\")\n } else {\n println(\"NO\")\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1547418130, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03149.html", "problem_id": "p03149", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03149/input.txt", "sample_output_relpath": "derived/input_output/data/p03149/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03149/Scala/s910453896.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s910453896", "user_id": "u909304507"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "object Main {\n import java.util.Scanner\n\n def readStrings(n: Int)(implicit sc: Scanner): Array[String] = Array.fill(n) { sc.next() }\n def readInts(n: Int)(implicit sc: Scanner): Array[Int] = Array.fill(n) { sc.nextInt() }\n def readLongs(n: Int)(implicit sc: Scanner): Array[Long] = Array.fill(n) { sc.nextLong() }\n def readLineStrings(implicit sc: Scanner): Array[String] = sc.nextLine().split(' ')\n def readLineInts(implicit sc: Scanner): Array[Int] = readLineStrings.map(_.toInt)\n def readLineLongs(implicit sc: Scanner): Array[Long] = readLineStrings.map(_.toLong)\n\n def main(args: Array[String]): Unit = solve(new Scanner(System.in))\n\n def solve(implicit sc: Scanner): Unit = {\n val N = readLineInts\n if(Seq(1, 7, 9, 4).map(n => N.count(_ == n) == 1).forall(identity)) {\n println(\"YES\")\n } else {\n println(\"NO\")\n }\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits \"1974\".\n\nConstraints\n\n0 \\leq N_1, N_2, N_3, N_4 \\leq 9\n\nN_1, N_2, N_3 and N_4 are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN_1 N_2 N_3 N_4\n\nOutput\n\nIf N_1, N_2, N_3 and N_4 can be arranged into the sequence of digits \"1974\", print YES; if they cannot, print NO.\n\nSample Input 1\n\n1 7 9 4\n\nSample Output 1\n\nYES\n\nWe can get 1974 by swapping N_2 and N_3.\n\nSample Input 2\n\n1 9 7 4\n\nSample Output 2\n\nYES\n\nWe already have 1974 before doing anything.\n\nSample Input 3\n\n1 2 9 1\n\nSample Output 3\n\nNO\n\nSample Input 4\n\n4 9 0 8\n\nSample Output 4\n\nNO", "sample_input": "1 7 9 4\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03149", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits \"1974\".\n\nConstraints\n\n0 \\leq N_1, N_2, N_3, N_4 \\leq 9\n\nN_1, N_2, N_3 and N_4 are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN_1 N_2 N_3 N_4\n\nOutput\n\nIf N_1, N_2, N_3 and N_4 can be arranged into the sequence of digits \"1974\", print YES; if they cannot, print NO.\n\nSample Input 1\n\n1 7 9 4\n\nSample Output 1\n\nYES\n\nWe can get 1974 by swapping N_2 and N_3.\n\nSample Input 2\n\n1 9 7 4\n\nSample Output 2\n\nYES\n\nWe already have 1974 before doing anything.\n\nSample Input 3\n\n1 2 9 1\n\nSample Output 3\n\nNO\n\nSample Input 4\n\n4 9 0 8\n\nSample Output 4\n\nNO", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 856, "cpu_time_ms": 353, "memory_kb": 27340}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s837908269", "group_id": "codeNet:p03149", "input_text": "object Main{\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val list = List.fill(4)(sc.nextInt).sorted\n if(List(1,4,7,9) == list){\n println(\"YES\")\n }\n else{\n println(\"NO\")\n }\n}\n}", "language": "Scala", "metadata": {"date": 1547411844, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03149.html", "problem_id": "p03149", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03149/input.txt", "sample_output_relpath": "derived/input_output/data/p03149/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03149/Scala/s837908269.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s837908269", "user_id": "u340881840"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "object Main{\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val list = List.fill(4)(sc.nextInt).sorted\n if(List(1,4,7,9) == list){\n println(\"YES\")\n }\n else{\n println(\"NO\")\n }\n}\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits \"1974\".\n\nConstraints\n\n0 \\leq N_1, N_2, N_3, N_4 \\leq 9\n\nN_1, N_2, N_3 and N_4 are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN_1 N_2 N_3 N_4\n\nOutput\n\nIf N_1, N_2, N_3 and N_4 can be arranged into the sequence of digits \"1974\", print YES; if they cannot, print NO.\n\nSample Input 1\n\n1 7 9 4\n\nSample Output 1\n\nYES\n\nWe can get 1974 by swapping N_2 and N_3.\n\nSample Input 2\n\n1 9 7 4\n\nSample Output 2\n\nYES\n\nWe already have 1974 before doing anything.\n\nSample Input 3\n\n1 2 9 1\n\nSample Output 3\n\nNO\n\nSample Input 4\n\n4 9 0 8\n\nSample Output 4\n\nNO", "sample_input": "1 7 9 4\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03149", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits \"1974\".\n\nConstraints\n\n0 \\leq N_1, N_2, N_3, N_4 \\leq 9\n\nN_1, N_2, N_3 and N_4 are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN_1 N_2 N_3 N_4\n\nOutput\n\nIf N_1, N_2, N_3 and N_4 can be arranged into the sequence of digits \"1974\", print YES; if they cannot, print NO.\n\nSample Input 1\n\n1 7 9 4\n\nSample Output 1\n\nYES\n\nWe can get 1974 by swapping N_2 and N_3.\n\nSample Input 2\n\n1 9 7 4\n\nSample Output 2\n\nYES\n\nWe already have 1974 before doing anything.\n\nSample Input 3\n\n1 2 9 1\n\nSample Output 3\n\nNO\n\nSample Input 4\n\n4 9 0 8\n\nSample Output 4\n\nNO", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 356, "memory_kb": 25916}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s988543906", "group_id": "codeNet:p03149", "input_text": "object Main extends App {\n\n import scala.io.StdIn._\n val numbers = readLine.trim.split(' ').map(_.toInt)\n println(\n if (List(1, 9, 7, 4).forall(i ⇒ numbers.contains(i))) \"YES\"\n else \"NO\"\n )\n implicit class Extension[T](value :T){\n @inline\n def let[A](@inline func: T ⇒ A): A = func(value)\n @inline\n def also(@inline func: T ⇒ Unit): T = {func(value); value}\n }\n}", "language": "Scala", "metadata": {"date": 1547409690, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03149.html", "problem_id": "p03149", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03149/input.txt", "sample_output_relpath": "derived/input_output/data/p03149/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03149/Scala/s988543906.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s988543906", "user_id": "u419330815"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "object Main extends App {\n\n import scala.io.StdIn._\n val numbers = readLine.trim.split(' ').map(_.toInt)\n println(\n if (List(1, 9, 7, 4).forall(i ⇒ numbers.contains(i))) \"YES\"\n else \"NO\"\n )\n implicit class Extension[T](value :T){\n @inline\n def let[A](@inline func: T ⇒ A): A = func(value)\n @inline\n def also(@inline func: T ⇒ Unit): T = {func(value); value}\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits \"1974\".\n\nConstraints\n\n0 \\leq N_1, N_2, N_3, N_4 \\leq 9\n\nN_1, N_2, N_3 and N_4 are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN_1 N_2 N_3 N_4\n\nOutput\n\nIf N_1, N_2, N_3 and N_4 can be arranged into the sequence of digits \"1974\", print YES; if they cannot, print NO.\n\nSample Input 1\n\n1 7 9 4\n\nSample Output 1\n\nYES\n\nWe can get 1974 by swapping N_2 and N_3.\n\nSample Input 2\n\n1 9 7 4\n\nSample Output 2\n\nYES\n\nWe already have 1974 before doing anything.\n\nSample Input 3\n\n1 2 9 1\n\nSample Output 3\n\nNO\n\nSample Input 4\n\n4 9 0 8\n\nSample Output 4\n\nNO", "sample_input": "1 7 9 4\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03149", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits \"1974\".\n\nConstraints\n\n0 \\leq N_1, N_2, N_3, N_4 \\leq 9\n\nN_1, N_2, N_3 and N_4 are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN_1 N_2 N_3 N_4\n\nOutput\n\nIf N_1, N_2, N_3 and N_4 can be arranged into the sequence of digits \"1974\", print YES; if they cannot, print NO.\n\nSample Input 1\n\n1 7 9 4\n\nSample Output 1\n\nYES\n\nWe can get 1974 by swapping N_2 and N_3.\n\nSample Input 2\n\n1 9 7 4\n\nSample Output 2\n\nYES\n\nWe already have 1974 before doing anything.\n\nSample Input 3\n\n1 2 9 1\n\nSample Output 3\n\nNO\n\nSample Input 4\n\n4 9 0 8\n\nSample Output 4\n\nNO", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 392, "cpu_time_ms": 327, "memory_kb": 25544}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s032294773", "group_id": "codeNet:p03152", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val s = new Main()\n s.solve()\n s.out.flush()\n }\n}\n\nclass Main {\n import java.io._\n import java.util.StringTokenizer\n\n import scala.collection.mutable\n import scala.util.Sorting\n import math.{abs, max, min}\n import mutable.{ArrayBuffer, ListBuffer}\n import scala.reflect.ClassTag\n\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n\n /**\n * @param tpe 0: row, 1: col, 2, どっちも\n */\n case class Restriction(tpe: Int, v: Int)\n\n def solve(): Unit = {\n val N, M = ni()\n val A = na(N)\n val B = na(M)\n\n val inRow = A.toSet\n val inCol = B.toSet\n val restrictions = ArrayBuffer[Restriction]()\n\n REP(N) { i =>\n val tpe = if (inCol.contains(A(i))) 2 else 0\n restrictions += Restriction(tpe, A(i))\n }\n\n REP(M) { i =>\n if (!inRow.contains(B(i))) restrictions += Restriction(1, B(i))\n }\n\n // vの降順でそーとしてある\n var ans = 1L\n var cur = N * M + 1\n val R = restrictions.sortBy(_.v).reverse\n\n def calc(): Long = {\n var r, c = 0\n\n // cur+1からuntil手前までシミュレートする\n def place(until: Int): Boolean = {\n var i = cur - 1\n while (i > until) {\n val alreadyPlaced = N * M - i\n val free = r * c - alreadyPlaced\n if (free <= 0) return false\n ans = ans * free % MOD\n i -= 1\n }\n\n true\n }\n\n REP(R.length) { i =>\n R(i).tpe match {\n // row\n case 0 =>\n if (!place(R(i).v)) return 0\n ans = (ans * c) % MOD\n cur = R(i).v\n r += 1\n\n // col\n case 1 =>\n if (!place(R(i).v)) return 0\n ans = (ans * r) % MOD\n cur = R(i).v\n c += 1\n\n // どっちも\n case 2 =>\n if (!place(R(i).v)) return 0\n cur = R(i).v\n c += 1\n r += 1\n }\n }\n\n place(0)\n\n ans\n }\n\n def validate(X: Array[Int]) = {\n X.max == N * M && X.groupBy(identity).values.forall(_.length == 1)\n }\n\n if (validate(A) && validate(B)) {\n out.println(calc())\n } else {\n out.println(0)\n }\n }\n \n\n def debug(as: Array[Boolean]): Unit = {\n System.err.println(as.map(x => if(x) \"1\" else \"0\").mkString)\n }\n\n def debug(as: Array[Int]): Unit = {\n System.err.println(as.mkString(\" \"))\n }\n\n def debug(as: Array[Long]): Unit = {\n System.err.println(as.mkString(\" \"))\n }\n\n def debug(s: String): Unit = {\n System.err.println(s)\n }\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next().toInt\n def nextLong(): Long = next().toLong\n def nextChar(): Char = next().charAt(0)\n }\n val sc = new InputReader(System.in)\n def ni(): Int = sc.nextInt()\n def nl(): Long = sc.nextLong()\n def nc(): Char = sc.nextChar()\n def ns(): String = sc.next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n\n def cumSum(as: Array[Int]) = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}", "language": "Scala", "metadata": {"date": 1547415898, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03152.html", "problem_id": "p03152", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03152/input.txt", "sample_output_relpath": "derived/input_output/data/p03152/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03152/Scala/s032294773.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s032294773", "user_id": "u460609472"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val s = new Main()\n s.solve()\n s.out.flush()\n }\n}\n\nclass Main {\n import java.io._\n import java.util.StringTokenizer\n\n import scala.collection.mutable\n import scala.util.Sorting\n import math.{abs, max, min}\n import mutable.{ArrayBuffer, ListBuffer}\n import scala.reflect.ClassTag\n\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n\n /**\n * @param tpe 0: row, 1: col, 2, どっちも\n */\n case class Restriction(tpe: Int, v: Int)\n\n def solve(): Unit = {\n val N, M = ni()\n val A = na(N)\n val B = na(M)\n\n val inRow = A.toSet\n val inCol = B.toSet\n val restrictions = ArrayBuffer[Restriction]()\n\n REP(N) { i =>\n val tpe = if (inCol.contains(A(i))) 2 else 0\n restrictions += Restriction(tpe, A(i))\n }\n\n REP(M) { i =>\n if (!inRow.contains(B(i))) restrictions += Restriction(1, B(i))\n }\n\n // vの降順でそーとしてある\n var ans = 1L\n var cur = N * M + 1\n val R = restrictions.sortBy(_.v).reverse\n\n def calc(): Long = {\n var r, c = 0\n\n // cur+1からuntil手前までシミュレートする\n def place(until: Int): Boolean = {\n var i = cur - 1\n while (i > until) {\n val alreadyPlaced = N * M - i\n val free = r * c - alreadyPlaced\n if (free <= 0) return false\n ans = ans * free % MOD\n i -= 1\n }\n\n true\n }\n\n REP(R.length) { i =>\n R(i).tpe match {\n // row\n case 0 =>\n if (!place(R(i).v)) return 0\n ans = (ans * c) % MOD\n cur = R(i).v\n r += 1\n\n // col\n case 1 =>\n if (!place(R(i).v)) return 0\n ans = (ans * r) % MOD\n cur = R(i).v\n c += 1\n\n // どっちも\n case 2 =>\n if (!place(R(i).v)) return 0\n cur = R(i).v\n c += 1\n r += 1\n }\n }\n\n place(0)\n\n ans\n }\n\n def validate(X: Array[Int]) = {\n X.max == N * M && X.groupBy(identity).values.forall(_.length == 1)\n }\n\n if (validate(A) && validate(B)) {\n out.println(calc())\n } else {\n out.println(0)\n }\n }\n \n\n def debug(as: Array[Boolean]): Unit = {\n System.err.println(as.map(x => if(x) \"1\" else \"0\").mkString)\n }\n\n def debug(as: Array[Int]): Unit = {\n System.err.println(as.mkString(\" \"))\n }\n\n def debug(as: Array[Long]): Unit = {\n System.err.println(as.mkString(\" \"))\n }\n\n def debug(s: String): Unit = {\n System.err.println(s)\n }\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next().toInt\n def nextLong(): Long = next().toLong\n def nextChar(): Char = next().charAt(0)\n }\n val sc = new InputReader(System.in)\n def ni(): Int = sc.nextInt()\n def nl(): Long = sc.nextLong()\n def nc(): Char = sc.nextChar()\n def ns(): String = sc.next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n\n def cumSum(as: Array[Int]) = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nConsider writing each of the integers from 1 to N \\times M in a grid with N rows and M columns, without duplicates.\nTakahashi thinks it is not fun enough, and he will write the numbers under the following conditions:\n\nThe largest among the values in the i-th row (1 \\leq i \\leq N) is A_i.\n\nThe largest among the values in the j-th column (1 \\leq j \\leq M) is B_j.\n\nFor him, find the number of ways to write the numbers under these conditions, modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n1 \\leq M \\leq 1000\n\n1 \\leq A_i \\leq N \\times M\n\n1 \\leq B_j \\leq N \\times M\n\nA_i and B_j are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_{N}\nB_1 B_2 ... B_{M}\n\nOutput\n\nPrint the number of ways to write the numbers under the conditions, modulo 10^9 + 7.\n\nSample Input 1\n\n2 2\n4 3\n3 4\n\nSample Output 1\n\n2\n\n(A_1, A_2) = (4, 3) and (B_1, B_2) = (3, 4). In this case, there are two ways to write the numbers, as follows:\n\n1 in (1, 1), 4 in (1, 2), 3 in (2, 1) and 2 in (2, 2).\n\n2 in (1, 1), 4 in (1, 2), 3 in (2, 1) and 1 in (2, 2).\n\nHere, (i, j) denotes the square at the i-th row and the j-th column.\n\nSample Input 2\n\n3 3\n5 9 7\n3 6 9\n\nSample Output 2\n\n0\n\nSince there is no way to write the numbers under the condition, 0 should be printed.\n\nSample Input 3\n\n2 2\n4 4\n4 4\n\nSample Output 3\n\n0\n\nSample Input 4\n\n14 13\n158 167 181 147 178 151 179 182 176 169 180 129 175 168\n181 150 178 179 167 180 176 169 182 177 175 159 173\n\nSample Output 4\n\n343772227", "sample_input": "2 2\n4 3\n3 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03152", "source_text": "Score : 500 points\n\nProblem Statement\n\nConsider writing each of the integers from 1 to N \\times M in a grid with N rows and M columns, without duplicates.\nTakahashi thinks it is not fun enough, and he will write the numbers under the following conditions:\n\nThe largest among the values in the i-th row (1 \\leq i \\leq N) is A_i.\n\nThe largest among the values in the j-th column (1 \\leq j \\leq M) is B_j.\n\nFor him, find the number of ways to write the numbers under these conditions, modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n1 \\leq M \\leq 1000\n\n1 \\leq A_i \\leq N \\times M\n\n1 \\leq B_j \\leq N \\times M\n\nA_i and B_j are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_{N}\nB_1 B_2 ... B_{M}\n\nOutput\n\nPrint the number of ways to write the numbers under the conditions, modulo 10^9 + 7.\n\nSample Input 1\n\n2 2\n4 3\n3 4\n\nSample Output 1\n\n2\n\n(A_1, A_2) = (4, 3) and (B_1, B_2) = (3, 4). In this case, there are two ways to write the numbers, as follows:\n\n1 in (1, 1), 4 in (1, 2), 3 in (2, 1) and 2 in (2, 2).\n\n2 in (1, 1), 4 in (1, 2), 3 in (2, 1) and 1 in (2, 2).\n\nHere, (i, j) denotes the square at the i-th row and the j-th column.\n\nSample Input 2\n\n3 3\n5 9 7\n3 6 9\n\nSample Output 2\n\n0\n\nSince there is no way to write the numbers under the condition, 0 should be printed.\n\nSample Input 3\n\n2 2\n4 4\n4 4\n\nSample Output 3\n\n0\n\nSample Input 4\n\n14 13\n158 167 181 147 178 151 179 182 176 169 180 129 175 168\n181 150 178 179 167 180 176 169 182 177 175 159 173\n\nSample Output 4\n\n343772227", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4560, "cpu_time_ms": 499, "memory_kb": 30760}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s951714443", "group_id": "codeNet:p03153", "input_text": "\nobject Main extends App {\n\n import scala.io.StdIn._\n\n val Array(n, d) = readLine.trim.split(' ').map(_.toInt)\n val cities = readLine.trim.split(' ').map(_.toLong).zipWithIndex\n println(minCost(cities.reverse.toList))\n def minCost(cities: List[(Long, Int)]): Long = {\n def sub(list: List[(Long, Int)], current: Long, result: Long = 0): Long = {\n list match {\n case (a, b)::t if a + b * d > current ⇒ sub(t, current, current + a - b * d + result)\n case (a, b)::t ⇒ sub(t, a + b * d, current + a - b * d + result)\n case Nil ⇒ result\n }\n }\n sub(cities.tail, cities.head.let{case (a, b) ⇒ a + b * d})\n }\n\n class UnionFindTree{\n private var mParent: Option[UnionFindTree] = None\n private var mSize: Int = 1\n private def parent: UnionFindTree = {\n mParent.map{_.parent} match {\n case None ⇒ this\n case c@Some(p) ⇒\n mParent = c\n p\n }\n }\n def isSameUnion(that: UnionFindTree): Boolean = {\n parent == that.parent\n }\n def merge(that: UnionFindTree): Unit = {\n if (!isSameUnion(that)){\n val p = parent\n val tp = that.parent\n if (p.mSize > tp.mSize){\n tp.mParent = Some(p)\n p.mSize += tp.mSize\n }else {\n p.mParent = Some(tp)\n tp.mSize += p.mSize\n }\n }\n }\n }\n implicit class Extension[T](value :T){\n @inline\n def let[A](@inline func: T ⇒ A): A = func(value)\n @inline\n def also(@inline func: T ⇒ Unit): T = {func(value); value}\n }\n}", "language": "Scala", "metadata": {"date": 1547416724, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03153.html", "problem_id": "p03153", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03153/input.txt", "sample_output_relpath": "derived/input_output/data/p03153/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03153/Scala/s951714443.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s951714443", "user_id": "u419330815"}, "prompt_components": {"gold_output": "106\n", "input_to_evaluate": "\nobject Main extends App {\n\n import scala.io.StdIn._\n\n val Array(n, d) = readLine.trim.split(' ').map(_.toInt)\n val cities = readLine.trim.split(' ').map(_.toLong).zipWithIndex\n println(minCost(cities.reverse.toList))\n def minCost(cities: List[(Long, Int)]): Long = {\n def sub(list: List[(Long, Int)], current: Long, result: Long = 0): Long = {\n list match {\n case (a, b)::t if a + b * d > current ⇒ sub(t, current, current + a - b * d + result)\n case (a, b)::t ⇒ sub(t, a + b * d, current + a - b * d + result)\n case Nil ⇒ result\n }\n }\n sub(cities.tail, cities.head.let{case (a, b) ⇒ a + b * d})\n }\n\n class UnionFindTree{\n private var mParent: Option[UnionFindTree] = None\n private var mSize: Int = 1\n private def parent: UnionFindTree = {\n mParent.map{_.parent} match {\n case None ⇒ this\n case c@Some(p) ⇒\n mParent = c\n p\n }\n }\n def isSameUnion(that: UnionFindTree): Boolean = {\n parent == that.parent\n }\n def merge(that: UnionFindTree): Unit = {\n if (!isSameUnion(that)){\n val p = parent\n val tp = that.parent\n if (p.mSize > tp.mSize){\n tp.mParent = Some(p)\n p.mSize += tp.mSize\n }else {\n p.mParent = Some(tp)\n tp.mSize += p.mSize\n }\n }\n }\n }\n implicit class Extension[T](value :T){\n @inline\n def let[A](@inline func: T ⇒ A): A = func(value)\n @inline\n def also(@inline func: T ⇒ Unit): T = {func(value); value}\n }\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere are N cities in Republic of AtCoder. The size of the i-th city is A_{i}.\nTakahashi would like to build N-1 bidirectional roads connecting two cities so that any city can be reached from any other city by using these roads.\n\nAssume that the cost of building a road connecting the i-th city and the j-th city is |i-j| \\times D + A_{i} + A_{j}.\nFor Takahashi, find the minimum possible total cost to achieve the objective.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq D \\leq 10^9\n\n1 \\leq A_{i} \\leq 10^9\n\nA_{i} and D are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible total cost.\n\nSample Input 1\n\n3 1\n1 100 1\n\nSample Output 1\n\n106\n\nThis cost can be achieved by, for example, building roads connecting City 1, 2 and City 1, 3.\n\nSample Input 2\n\n3 1000\n1 100 1\n\nSample Output 2\n\n2202\n\nSample Input 3\n\n6 14\n25 171 7 1 17 162\n\nSample Output 3\n\n497\n\nSample Input 4\n\n12 5\n43 94 27 3 69 99 56 25 8 15 46 8\n\nSample Output 4\n\n658", "sample_input": "3 1\n1 100 1\n"}, "reference_outputs": ["106\n"], "source_document_id": "p03153", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere are N cities in Republic of AtCoder. The size of the i-th city is A_{i}.\nTakahashi would like to build N-1 bidirectional roads connecting two cities so that any city can be reached from any other city by using these roads.\n\nAssume that the cost of building a road connecting the i-th city and the j-th city is |i-j| \\times D + A_{i} + A_{j}.\nFor Takahashi, find the minimum possible total cost to achieve the objective.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq D \\leq 10^9\n\n1 \\leq A_{i} \\leq 10^9\n\nA_{i} and D are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible total cost.\n\nSample Input 1\n\n3 1\n1 100 1\n\nSample Output 1\n\n106\n\nThis cost can be achieved by, for example, building roads connecting City 1, 2 and City 1, 3.\n\nSample Input 2\n\n3 1000\n1 100 1\n\nSample Output 2\n\n2202\n\nSample Input 3\n\n6 14\n25 171 7 1 17 162\n\nSample Output 3\n\n497\n\nSample Input 4\n\n12 5\n43 94 27 3 69 99 56 25 8 15 46 8\n\nSample Output 4\n\n658", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 877, "memory_kb": 85288}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s685139563", "group_id": "codeNet:p03155", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val s = new Main()\n s.solve()\n s.out.flush()\n }\n}\n\nclass Main {\n import java.io._\n import java.util.StringTokenizer\n\n import scala.collection.mutable\n import scala.util.Sorting\n import math.{abs, max, min}\n import mutable.{ArrayBuffer, ListBuffer}\n import scala.reflect.ClassTag\n\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n\n def solve(): Unit = {\n val N, H, W = ni()\n val ans = (N - H + 1) * (N - W + 1)\n out.println(ans)\n }\n\n\n def debug(as: Array[Boolean]): Unit = {\n System.err.println(as.map(x => if(x) \"1\" else \"0\").mkString)\n }\n\n def debug(as: Array[Int]): Unit = {\n System.err.println(as.mkString(\" \"))\n }\n\n def debug(as: Array[Long]): Unit = {\n System.err.println(as.mkString(\" \"))\n }\n\n def debug(s: String): Unit = {\n System.err.println(s)\n }\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next().toInt\n def nextLong(): Long = next().toLong\n def nextChar(): Char = next().charAt(0)\n }\n val sc = new InputReader(System.in)\n def ni(): Int = sc.nextInt()\n def nl(): Long = sc.nextLong()\n def nc(): Char = sc.nextChar()\n def ns(): String = sc.next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n\n def cumSum(as: Array[Int]) = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}", "language": "Scala", "metadata": {"date": 1547323252, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s685139563.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s685139563", "user_id": "u460609472"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val s = new Main()\n s.solve()\n s.out.flush()\n }\n}\n\nclass Main {\n import java.io._\n import java.util.StringTokenizer\n\n import scala.collection.mutable\n import scala.util.Sorting\n import math.{abs, max, min}\n import mutable.{ArrayBuffer, ListBuffer}\n import scala.reflect.ClassTag\n\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n\n def solve(): Unit = {\n val N, H, W = ni()\n val ans = (N - H + 1) * (N - W + 1)\n out.println(ans)\n }\n\n\n def debug(as: Array[Boolean]): Unit = {\n System.err.println(as.map(x => if(x) \"1\" else \"0\").mkString)\n }\n\n def debug(as: Array[Int]): Unit = {\n System.err.println(as.mkString(\" \"))\n }\n\n def debug(as: Array[Long]): Unit = {\n System.err.println(as.mkString(\" \"))\n }\n\n def debug(s: String): Unit = {\n System.err.println(s)\n }\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next().toInt\n def nextLong(): Long = next().toLong\n def nextChar(): Char = next().charAt(0)\n }\n val sc = new InputReader(System.in)\n def ni(): Int = sc.nextInt()\n def nl(): Long = sc.nextLong()\n def nc(): Char = sc.nextChar()\n def ns(): String = sc.next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n\n def cumSum(as: Array[Int]) = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2843, "cpu_time_ms": 318, "memory_kb": 25524}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s669783372", "group_id": "codeNet:p03156", "input_text": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n\n def solve(sc: => Scanner): Unit = {\n val N, A, B = sc.nextInt()\n val P = Array.fill(N)(sc.nextInt())\n println(math.min(P.count(x => x <= A), math.min(P.count(x => A < x && x <= B), P.count(x => B < x))))\n }\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def calc(N: Long, R: Long, M: Long): Double = {\n math.sqrt(R * R - (R * 2 * ((M * 1.0 / N) - 0.5)) * (R * 2 * ((M * 1.0 / N) - 0.5))) * 2\n }\n\n def recursive(N1: Long, N2: Long, M1: Long, M2: Long): Long = {\n println(N1, N2, M1, M2)\n if (N1 + N2 == 0 || M1 + M2 == 0) -1\n else recursive(math.max(0, M1 - math.max(0, N1 + N2 - M2) / 2), math.max(0, M2 - N1 - N2) + math.max(0, N1 + N2 - M2) % 2, N1, N2) + 1\n }\n\n def check(s: String): Boolean = {\n if (s == \"0\") true\n else s(0) != '0' && 0 <= s.toInt && s.toInt <= 255\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n}", "language": "Scala", "metadata": {"date": 1547495632, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s669783372.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s669783372", "user_id": "u779353743"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "//import java.util.Scanner\n\nimport java.io._\nimport java.nio.file.Files._\nimport java.nio.file.Path\nimport java.util.StringTokenizer\n\nimport scala.collection.immutable._\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator: Iterator[String] = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext: Boolean = current.hasNext\n\n @inline def next(): String = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close(): Unit = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(Node(None, treeSize = 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) =>\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n}\n\n\nobject Main {\n\n def solve(sc: => Scanner): Unit = {\n val N, A, B = sc.nextInt()\n val P = Array.fill(N)(sc.nextInt())\n println(math.min(P.count(x => x <= A), math.min(P.count(x => A < x && x <= B), P.count(x => B < x))))\n }\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def calc(N: Long, R: Long, M: Long): Double = {\n math.sqrt(R * R - (R * 2 * ((M * 1.0 / N) - 0.5)) * (R * 2 * ((M * 1.0 / N) - 0.5))) * 2\n }\n\n def recursive(N1: Long, N2: Long, M1: Long, M2: Long): Long = {\n println(N1, N2, M1, M2)\n if (N1 + N2 == 0 || M1 + M2 == 0) -1\n else recursive(math.max(0, M1 - math.max(0, N1 + N2 - M2) / 2), math.max(0, M2 - N1 - N2) + math.max(0, N1 + N2 - M2) % 2, N1, N2) + 1\n }\n\n def check(s: String): Boolean = {\n if (s == \"0\") true\n else s(0) != '0' && 0 <= s.toInt && s.toInt <= 255\n }\n\n def shift(n: Long): Long = {\n if (n == 0) 0\n else if (n == 1) 1\n else shift(n - 1) << 1\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) 0\n else unShift(n >> 1) + 1\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) gcd(j, i)\n else if (j == 0) i\n else gcd(j, i % j)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList: Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: Int =?> String = {\n case src if src >= 1 && src <= 3999 =>\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if n == 0 => cont + unitChar\n case n if n > 0 => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n\n val romanToArabic: String =?> Int = {\n case src if Option(src).exists { s => {\n s.nonEmpty && \"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase).isEmpty\n }\n } =>\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6199, "cpu_time_ms": 332, "memory_kb": 25500}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s990604054", "group_id": "codeNet:p03157", "input_text": "import scala.io.StdIn\nimport scala.annotation.tailrec\n\nobject Main extends App {\n val Array(h, w) = StdIn.readLine.split(\" \").map(_.toInt)\n val table = Iterator.continually(StdIn.readLine)\n .take(h)\n .map(_.map(ch => if(ch == '#') true else false).toArray)\n .toArray\n\n val ans = {\n val dx = Array(0, 1, 0, -1)\n val dy = Array(-1, 0, 1, 0)\n var res = 0;\n\n def f(y:Int, x:Int):Int = {\n val visit = Array.ofDim[Boolean](h,w)\n\n def dfs(ey:Int, ex:Int):Unit = {\n if(table(ey)(ex) != table(y)(x) || visit(ey)(ex)) return\n else {\n visit(ey)(ex) = true \n (0 until 4).foreach(i => {\n val y = ey + dy(i)\n val x = ex + dx(i)\n if(0 <= y && y < h && 0 <= x && x < w) {\n dfs(y, x)\n }\n })\n }\n }\n\n dfs(y, x)\n\n val a = for {\n i <- 0 until h\n j <- 0 until w\n if !table(i)(j)\n } { if(visit(i)(j)) res += 1 }\n res\n }\n\n val ret = for {\n i <- 0 until h\n j <- 0 until w\n if table(i)(j)\n } f(i,j)\n\n res\n }\n\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1547330380, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s990604054.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s990604054", "user_id": "u217010036"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import scala.io.StdIn\nimport scala.annotation.tailrec\n\nobject Main extends App {\n val Array(h, w) = StdIn.readLine.split(\" \").map(_.toInt)\n val table = Iterator.continually(StdIn.readLine)\n .take(h)\n .map(_.map(ch => if(ch == '#') true else false).toArray)\n .toArray\n\n val ans = {\n val dx = Array(0, 1, 0, -1)\n val dy = Array(-1, 0, 1, 0)\n var res = 0;\n\n def f(y:Int, x:Int):Int = {\n val visit = Array.ofDim[Boolean](h,w)\n\n def dfs(ey:Int, ex:Int):Unit = {\n if(table(ey)(ex) != table(y)(x) || visit(ey)(ex)) return\n else {\n visit(ey)(ex) = true \n (0 until 4).foreach(i => {\n val y = ey + dy(i)\n val x = ex + dx(i)\n if(0 <= y && y < h && 0 <= x && x < w) {\n dfs(y, x)\n }\n })\n }\n }\n\n dfs(y, x)\n\n val a = for {\n i <- 0 until h\n j <- 0 until w\n if !table(i)(j)\n } { if(visit(i)(j)) res += 1 }\n res\n }\n\n val ret = for {\n i <- 0 until h\n j <- 0 until w\n if table(i)(j)\n } f(i,j)\n\n res\n }\n\n println(ans)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 114796}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s918537629", "group_id": "codeNet:p03166", "input_text": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n // val ar = new Array[Int](N)\n\n val N, M = in.next().toInt\n val graph = Array.fill[List[Int]](N+1)(Nil)\n for(_ <- 1 to M) {\n val a, b = in.next().toInt\n graph(a) = b :: graph(a)\n }\n\n\n //\n val dp = Array.fill[Int](N+1)(-1)\n\n def calc(i: Int): Int = {\n if(dp(i) == -1) {\n var res = 0\n for(e <- graph(i)){\n calc(e)\n res = Math.max(res, dp(e)+1)\n }\n dp(i) = res\n }\n dp(i)\n }\n\n \n for (i <- 1 to N) {\n calc(i)\n }\n\n\n println(dp.max)\n}\n\n\nclass InputReader(stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream))\n private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n", "language": "Scala", "metadata": {"date": 1551118750, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03166.html", "problem_id": "p03166", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03166/input.txt", "sample_output_relpath": "derived/input_output/data/p03166/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03166/Scala/s918537629.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s918537629", "user_id": "u098968285"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n // val ar = new Array[Int](N)\n\n val N, M = in.next().toInt\n val graph = Array.fill[List[Int]](N+1)(Nil)\n for(_ <- 1 to M) {\n val a, b = in.next().toInt\n graph(a) = b :: graph(a)\n }\n\n\n //\n val dp = Array.fill[Int](N+1)(-1)\n\n def calc(i: Int): Int = {\n if(dp(i) == -1) {\n var res = 0\n for(e <- graph(i)){\n calc(e)\n res = Math.max(res, dp(e)+1)\n }\n dp(i) = res\n }\n dp(i)\n }\n\n \n for (i <- 1 to N) {\n calc(i)\n }\n\n\n println(dp.max)\n}\n\n\nclass InputReader(stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream))\n private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a directed graph G with N vertices and M edges.\nThe vertices are numbered 1, 2, \\ldots, N, and for each i (1 \\leq i \\leq M), the i-th directed edge goes from Vertex x_i to y_i.\nG does not contain directed cycles.\n\nFind the length of the longest directed path in G.\nHere, the length of a directed path is the number of edges in it.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq x_i, y_i \\leq N\n\nAll pairs (x_i, y_i) are distinct.\n\nG does not contain directed cycles.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nx_1 y_1\nx_2 y_2\n:\nx_M y_M\n\nOutput\n\nPrint the length of the longest directed path in G.\n\nSample Input 1\n\n4 5\n1 2\n1 3\n3 2\n2 4\n3 4\n\nSample Output 1\n\n3\n\nThe red directed path in the following figure is the longest:\n\nSample Input 2\n\n6 3\n2 3\n4 5\n5 6\n\nSample Output 2\n\n2\n\nThe red directed path in the following figure is the longest:\n\nSample Input 3\n\n5 8\n5 3\n2 3\n2 4\n5 2\n5 1\n1 4\n4 3\n1 3\n\nSample Output 3\n\n3\n\nThe red directed path in the following figure is one of the longest:", "sample_input": "4 5\n1 2\n1 3\n3 2\n2 4\n3 4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03166", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a directed graph G with N vertices and M edges.\nThe vertices are numbered 1, 2, \\ldots, N, and for each i (1 \\leq i \\leq M), the i-th directed edge goes from Vertex x_i to y_i.\nG does not contain directed cycles.\n\nFind the length of the longest directed path in G.\nHere, the length of a directed path is the number of edges in it.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq x_i, y_i \\leq N\n\nAll pairs (x_i, y_i) are distinct.\n\nG does not contain directed cycles.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nx_1 y_1\nx_2 y_2\n:\nx_M y_M\n\nOutput\n\nPrint the length of the longest directed path in G.\n\nSample Input 1\n\n4 5\n1 2\n1 3\n3 2\n2 4\n3 4\n\nSample Output 1\n\n3\n\nThe red directed path in the following figure is the longest:\n\nSample Input 2\n\n6 3\n2 3\n4 5\n5 6\n\nSample Output 2\n\n2\n\nThe red directed path in the following figure is the longest:\n\nSample Input 3\n\n5 8\n5 3\n2 3\n2 4\n5 2\n5 1\n1 4\n4 3\n1 3\n\nSample Output 3\n\n3\n\nThe red directed path in the following figure is one of the longest:", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 731, "memory_kb": 47252}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s710774867", "group_id": "codeNet:p03166", "input_text": "import scala.collection.mutable\n\nobject Main extends App {\n\n import scala.io.StdIn._\n\n val Array(n, m) = readLine.trim.split(' ').map(_.toInt)\n val edges = Array.tabulate(n){_ ⇒ Nil: List[Int]}\n val inEdge = Array.tabulate(n){_ ⇒ 0}\n for (_ ← 0 until m){\n val Array(x, y) = readLine.trim.split(' ').map(_.toInt)\n edges(x - 1) ::= y - 1\n inEdge(y - 1) += 1\n }\n val longestPath = Array.tabulate(n){_ ⇒ n}\n val queue = mutable.PriorityQueue()(Ordering.by[(Int, Int), Int](_._2).reverse)\n inEdge.indices.filter(p ⇒ inEdge(p) == 0).foreach(p ⇒ queue.enqueue((p, n)))\n while (queue.nonEmpty){\n val (top, cost) = queue.dequeue()\n if (longestPath(top) == cost) {\n for (next ← edges(top)) {\n if (longestPath(next) > cost - 1) {\n longestPath(next) = cost - 1\n queue.enqueue((next, cost - 1))\n }\n }\n }\n }\n println(n - longestPath.min)\n implicit class Extend[T](value: T){\n def also(func: T ⇒ Unit): T = {func(value); value}\n def let[A](func: T ⇒ A): A = func(value)\n }\n}", "language": "Scala", "metadata": {"date": 1546807376, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03166.html", "problem_id": "p03166", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03166/input.txt", "sample_output_relpath": "derived/input_output/data/p03166/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03166/Scala/s710774867.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s710774867", "user_id": "u419330815"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.collection.mutable\n\nobject Main extends App {\n\n import scala.io.StdIn._\n\n val Array(n, m) = readLine.trim.split(' ').map(_.toInt)\n val edges = Array.tabulate(n){_ ⇒ Nil: List[Int]}\n val inEdge = Array.tabulate(n){_ ⇒ 0}\n for (_ ← 0 until m){\n val Array(x, y) = readLine.trim.split(' ').map(_.toInt)\n edges(x - 1) ::= y - 1\n inEdge(y - 1) += 1\n }\n val longestPath = Array.tabulate(n){_ ⇒ n}\n val queue = mutable.PriorityQueue()(Ordering.by[(Int, Int), Int](_._2).reverse)\n inEdge.indices.filter(p ⇒ inEdge(p) == 0).foreach(p ⇒ queue.enqueue((p, n)))\n while (queue.nonEmpty){\n val (top, cost) = queue.dequeue()\n if (longestPath(top) == cost) {\n for (next ← edges(top)) {\n if (longestPath(next) > cost - 1) {\n longestPath(next) = cost - 1\n queue.enqueue((next, cost - 1))\n }\n }\n }\n }\n println(n - longestPath.min)\n implicit class Extend[T](value: T){\n def also(func: T ⇒ Unit): T = {func(value); value}\n def let[A](func: T ⇒ A): A = func(value)\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a directed graph G with N vertices and M edges.\nThe vertices are numbered 1, 2, \\ldots, N, and for each i (1 \\leq i \\leq M), the i-th directed edge goes from Vertex x_i to y_i.\nG does not contain directed cycles.\n\nFind the length of the longest directed path in G.\nHere, the length of a directed path is the number of edges in it.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq x_i, y_i \\leq N\n\nAll pairs (x_i, y_i) are distinct.\n\nG does not contain directed cycles.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nx_1 y_1\nx_2 y_2\n:\nx_M y_M\n\nOutput\n\nPrint the length of the longest directed path in G.\n\nSample Input 1\n\n4 5\n1 2\n1 3\n3 2\n2 4\n3 4\n\nSample Output 1\n\n3\n\nThe red directed path in the following figure is the longest:\n\nSample Input 2\n\n6 3\n2 3\n4 5\n5 6\n\nSample Output 2\n\n2\n\nThe red directed path in the following figure is the longest:\n\nSample Input 3\n\n5 8\n5 3\n2 3\n2 4\n5 2\n5 1\n1 4\n4 3\n1 3\n\nSample Output 3\n\n3\n\nThe red directed path in the following figure is one of the longest:", "sample_input": "4 5\n1 2\n1 3\n3 2\n2 4\n3 4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03166", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a directed graph G with N vertices and M edges.\nThe vertices are numbered 1, 2, \\ldots, N, and for each i (1 \\leq i \\leq M), the i-th directed edge goes from Vertex x_i to y_i.\nG does not contain directed cycles.\n\nFind the length of the longest directed path in G.\nHere, the length of a directed path is the number of edges in it.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq x_i, y_i \\leq N\n\nAll pairs (x_i, y_i) are distinct.\n\nG does not contain directed cycles.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nx_1 y_1\nx_2 y_2\n:\nx_M y_M\n\nOutput\n\nPrint the length of the longest directed path in G.\n\nSample Input 1\n\n4 5\n1 2\n1 3\n3 2\n2 4\n3 4\n\nSample Output 1\n\n3\n\nThe red directed path in the following figure is the longest:\n\nSample Input 2\n\n6 3\n2 3\n4 5\n5 6\n\nSample Output 2\n\n2\n\nThe red directed path in the following figure is the longest:\n\nSample Input 3\n\n5 8\n5 3\n2 3\n2 4\n5 2\n5 1\n1 4\n4 3\n1 3\n\nSample Output 3\n\n3\n\nThe red directed path in the following figure is one of the longest:", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 124004}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s879134501", "group_id": "codeNet:p03169", "input_text": "import scala.collection.mutable.Map\nimport scala.io.StdIn\n\nobject Main {\n val N = StdIn.readLine.toInt\n val Nd = N.toDouble\n val DP = Array.fill(N+2,N+2,N+2)(-1.0)\n\n def solve(i: Int, j: Int, k: Int): Double = {\n if (DP(i)(j)(k) >= 0.0) return DP(i)(j)(k)\n if (i+j+k == 0) return 0.0\n var res = 0.0\n if (i > 0) res = res + solve(i-1,j,k)*i\n if (j > 0) res = res + solve(i+1,j-1,k)*j\n if (k > 0) res = res + solve(i,j+1,k-1)*k\n res = res+Nd\n res = res/(i+j+k).toDouble\n DP(i)(j)(k) = res\n return res\n }\n\n def main(args: Array[String]) = {\n val N_inv = 1.0 / N.toDouble\n val INIT = Map(1 -> 0,2 -> 0,3 -> 0)\n for (i <- StdIn.readLine.split(\" \").map(_.toInt)) INIT(i) = INIT(i)+1\n println(solve(INIT(1), INIT(2), INIT(3)))\n }\n}\n", "language": "Scala", "metadata": {"date": 1562642242, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03169.html", "problem_id": "p03169", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03169/input.txt", "sample_output_relpath": "derived/input_output/data/p03169/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03169/Scala/s879134501.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s879134501", "user_id": "u895515293"}, "prompt_components": {"gold_output": "5.5\n", "input_to_evaluate": "import scala.collection.mutable.Map\nimport scala.io.StdIn\n\nobject Main {\n val N = StdIn.readLine.toInt\n val Nd = N.toDouble\n val DP = Array.fill(N+2,N+2,N+2)(-1.0)\n\n def solve(i: Int, j: Int, k: Int): Double = {\n if (DP(i)(j)(k) >= 0.0) return DP(i)(j)(k)\n if (i+j+k == 0) return 0.0\n var res = 0.0\n if (i > 0) res = res + solve(i-1,j,k)*i\n if (j > 0) res = res + solve(i+1,j-1,k)*j\n if (k > 0) res = res + solve(i,j+1,k-1)*k\n res = res+Nd\n res = res/(i+j+k).toDouble\n DP(i)(j)(k) = res\n return res\n }\n\n def main(args: Array[String]) = {\n val N_inv = 1.0 / N.toDouble\n val INIT = Map(1 -> 0,2 -> 0,3 -> 0)\n for (i <- StdIn.readLine.split(\" \").map(_.toInt)) INIT(i) = INIT(i)+1\n println(solve(INIT(1), INIT(2), INIT(3)))\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N dishes, numbered 1, 2, \\ldots, N.\nInitially, for each i (1 \\leq i \\leq N), Dish i has a_i (1 \\leq a_i \\leq 3) pieces of sushi on it.\n\nTaro will perform the following operation repeatedly until all the pieces of sushi are eaten:\n\nRoll a die that shows the numbers 1, 2, \\ldots, N with equal probabilities, and let i be the outcome. If there are some pieces of sushi on Dish i, eat one of them; if there is none, do nothing.\n\nFind the expected number of times the operation is performed before all the pieces of sushi are eaten.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 300\n\n1 \\leq a_i \\leq 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint the expected number of times the operation is performed before all the pieces of sushi are eaten.\nThe output is considered correct when the relative difference is not greater than 10^{-9}.\n\nSample Input 1\n\n3\n1 1 1\n\nSample Output 1\n\n5.5\n\nThe expected number of operations before the first piece of sushi is eaten, is 1.\nAfter that, the expected number of operations before the second sushi is eaten, is 1.5.\nAfter that, the expected number of operations before the third sushi is eaten, is 3.\nThus, the expected total number of operations is 1 + 1.5 + 3 = 5.5.\n\nSample Input 2\n\n1\n3\n\nSample Output 2\n\n3\n\nOutputs such as 3.00, 3.000000003 and 2.999999997 will also be accepted.\n\nSample Input 3\n\n2\n1 2\n\nSample Output 3\n\n4.5\n\nSample Input 4\n\n10\n1 3 2 3 3 2 3 2 1 3\n\nSample Output 4\n\n54.48064457488221", "sample_input": "3\n1 1 1\n"}, "reference_outputs": ["5.5\n"], "source_document_id": "p03169", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N dishes, numbered 1, 2, \\ldots, N.\nInitially, for each i (1 \\leq i \\leq N), Dish i has a_i (1 \\leq a_i \\leq 3) pieces of sushi on it.\n\nTaro will perform the following operation repeatedly until all the pieces of sushi are eaten:\n\nRoll a die that shows the numbers 1, 2, \\ldots, N with equal probabilities, and let i be the outcome. If there are some pieces of sushi on Dish i, eat one of them; if there is none, do nothing.\n\nFind the expected number of times the operation is performed before all the pieces of sushi are eaten.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 300\n\n1 \\leq a_i \\leq 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint the expected number of times the operation is performed before all the pieces of sushi are eaten.\nThe output is considered correct when the relative difference is not greater than 10^{-9}.\n\nSample Input 1\n\n3\n1 1 1\n\nSample Output 1\n\n5.5\n\nThe expected number of operations before the first piece of sushi is eaten, is 1.\nAfter that, the expected number of operations before the second sushi is eaten, is 1.5.\nAfter that, the expected number of operations before the third sushi is eaten, is 3.\nThus, the expected total number of operations is 1 + 1.5 + 3 = 5.5.\n\nSample Input 2\n\n1\n3\n\nSample Output 2\n\n3\n\nOutputs such as 3.00, 3.000000003 and 2.999999997 will also be accepted.\n\nSample Input 3\n\n2\n1 2\n\nSample Output 3\n\n4.5\n\nSample Input 4\n\n10\n1 3 2 3 3 2 3 2 1 3\n\nSample Output 4\n\n54.48064457488221", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 774, "cpu_time_ms": 1058, "memory_kb": 300912}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s949469333", "group_id": "codeNet:p03169", "input_text": "import scala.collection.mutable.Map\nimport scala.io.StdIn\n\nobject Main {\n def main(args: Array[String]) = {\n val N = StdIn.readLine.toInt\n val N_inv = 1.0 / N.toDouble\n val INIT = Map(1 -> 0,2 -> 0,3 -> 0)\n for (i <- StdIn.readLine.split(\" \").map(_.toInt)) INIT(i) = INIT(i)+1\n val DP = Array.fill(2,N+2,N+2,N+2)(0.0)\n DP(0)(INIT(1))(INIT(2))(INIT(3)) = 1.0\n\n var cnt = 1.0\n var mean = 0.0\n for (l <- 1 until 50*N) {\n DP((l-1)%2)(0)(0)(0) = 0.0\n for {\n i <- 0 to N\n j <- 0 to N\n k <- 0 to N\n } {\n val prev = (l-1)%2\n var calc = DP(prev)(i)(j)(k)*(N-i-j-k) + DP(prev)(i+1)(j)(k)*(i+1)\n if (i > 0) calc = calc + DP(prev)(i-1)(j+1)(k)*(j+1)\n if (j > 0) calc = calc + DP(prev)(i)(j-1)(k+1)*(k+1)\n DP(l%2)(i)(j)(k) = calc*N_inv\n }\n mean = mean + DP(l%2)(0)(0)(0)*cnt\n cnt = cnt + 1.0\n }\n\n println(mean)\n }\n}\n", "language": "Scala", "metadata": {"date": 1562608310, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03169.html", "problem_id": "p03169", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03169/input.txt", "sample_output_relpath": "derived/input_output/data/p03169/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03169/Scala/s949469333.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s949469333", "user_id": "u895515293"}, "prompt_components": {"gold_output": "5.5\n", "input_to_evaluate": "import scala.collection.mutable.Map\nimport scala.io.StdIn\n\nobject Main {\n def main(args: Array[String]) = {\n val N = StdIn.readLine.toInt\n val N_inv = 1.0 / N.toDouble\n val INIT = Map(1 -> 0,2 -> 0,3 -> 0)\n for (i <- StdIn.readLine.split(\" \").map(_.toInt)) INIT(i) = INIT(i)+1\n val DP = Array.fill(2,N+2,N+2,N+2)(0.0)\n DP(0)(INIT(1))(INIT(2))(INIT(3)) = 1.0\n\n var cnt = 1.0\n var mean = 0.0\n for (l <- 1 until 50*N) {\n DP((l-1)%2)(0)(0)(0) = 0.0\n for {\n i <- 0 to N\n j <- 0 to N\n k <- 0 to N\n } {\n val prev = (l-1)%2\n var calc = DP(prev)(i)(j)(k)*(N-i-j-k) + DP(prev)(i+1)(j)(k)*(i+1)\n if (i > 0) calc = calc + DP(prev)(i-1)(j+1)(k)*(j+1)\n if (j > 0) calc = calc + DP(prev)(i)(j-1)(k+1)*(k+1)\n DP(l%2)(i)(j)(k) = calc*N_inv\n }\n mean = mean + DP(l%2)(0)(0)(0)*cnt\n cnt = cnt + 1.0\n }\n\n println(mean)\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N dishes, numbered 1, 2, \\ldots, N.\nInitially, for each i (1 \\leq i \\leq N), Dish i has a_i (1 \\leq a_i \\leq 3) pieces of sushi on it.\n\nTaro will perform the following operation repeatedly until all the pieces of sushi are eaten:\n\nRoll a die that shows the numbers 1, 2, \\ldots, N with equal probabilities, and let i be the outcome. If there are some pieces of sushi on Dish i, eat one of them; if there is none, do nothing.\n\nFind the expected number of times the operation is performed before all the pieces of sushi are eaten.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 300\n\n1 \\leq a_i \\leq 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint the expected number of times the operation is performed before all the pieces of sushi are eaten.\nThe output is considered correct when the relative difference is not greater than 10^{-9}.\n\nSample Input 1\n\n3\n1 1 1\n\nSample Output 1\n\n5.5\n\nThe expected number of operations before the first piece of sushi is eaten, is 1.\nAfter that, the expected number of operations before the second sushi is eaten, is 1.5.\nAfter that, the expected number of operations before the third sushi is eaten, is 3.\nThus, the expected total number of operations is 1 + 1.5 + 3 = 5.5.\n\nSample Input 2\n\n1\n3\n\nSample Output 2\n\n3\n\nOutputs such as 3.00, 3.000000003 and 2.999999997 will also be accepted.\n\nSample Input 3\n\n2\n1 2\n\nSample Output 3\n\n4.5\n\nSample Input 4\n\n10\n1 3 2 3 3 2 3 2 1 3\n\nSample Output 4\n\n54.48064457488221", "sample_input": "3\n1 1 1\n"}, "reference_outputs": ["5.5\n"], "source_document_id": "p03169", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N dishes, numbered 1, 2, \\ldots, N.\nInitially, for each i (1 \\leq i \\leq N), Dish i has a_i (1 \\leq a_i \\leq 3) pieces of sushi on it.\n\nTaro will perform the following operation repeatedly until all the pieces of sushi are eaten:\n\nRoll a die that shows the numbers 1, 2, \\ldots, N with equal probabilities, and let i be the outcome. If there are some pieces of sushi on Dish i, eat one of them; if there is none, do nothing.\n\nFind the expected number of times the operation is performed before all the pieces of sushi are eaten.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 300\n\n1 \\leq a_i \\leq 3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint the expected number of times the operation is performed before all the pieces of sushi are eaten.\nThe output is considered correct when the relative difference is not greater than 10^{-9}.\n\nSample Input 1\n\n3\n1 1 1\n\nSample Output 1\n\n5.5\n\nThe expected number of operations before the first piece of sushi is eaten, is 1.\nAfter that, the expected number of operations before the second sushi is eaten, is 1.5.\nAfter that, the expected number of operations before the third sushi is eaten, is 3.\nThus, the expected total number of operations is 1 + 1.5 + 3 = 5.5.\n\nSample Input 2\n\n1\n3\n\nSample Output 2\n\n3\n\nOutputs such as 3.00, 3.000000003 and 2.999999997 will also be accepted.\n\nSample Input 3\n\n2\n1 2\n\nSample Output 3\n\n4.5\n\nSample Input 4\n\n10\n1 3 2 3 3 2 3 2 1 3\n\nSample Output 4\n\n54.48064457488221", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 925, "cpu_time_ms": 1371, "memory_kb": 301228}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s468621962", "group_id": "codeNet:p03171", "input_text": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val N = in.next().toInt\n val a = new Array[Int](N+1)\n for(i <- 1 to N)\n a(i) = in.next().toInt\n\n //\n import Math.{max, min}\n val memo = Array.ofDim[Long](N+1, N+1)\n val init = Long.MaxValue\n for (a <- 0 to N; b <- 0 to N)\n memo(a)(b) = init\n\n def solve(bg: Int, ed: Int, turn: Boolean): Long = {\n if(memo(bg)(ed) != init)\n memo(bg)(ed)\n else{\n if(bg == ed) {\n memo(bg)(ed) = a(bg) * (if(turn) 1 else -1)\n memo(bg)(ed)\n }\n else {\n val left = solve(bg+1, ed, !turn)\n val right = solve(bg, ed-1, !turn)\n if(turn)\n memo(bg)(ed) = max(left + a(bg), right + a(ed))\n else\n memo(bg)(ed) = min(left - a(bg), right - a(ed))\n memo(bg)(ed)\n }\n }\n }\n\n println(solve(1, N, true))\n}\n\n\nclass InputReader(stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream))\n private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1553744926, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03171.html", "problem_id": "p03171", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03171/input.txt", "sample_output_relpath": "derived/input_output/data/p03171/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03171/Scala/s468621962.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s468621962", "user_id": "u098968285"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val N = in.next().toInt\n val a = new Array[Int](N+1)\n for(i <- 1 to N)\n a(i) = in.next().toInt\n\n //\n import Math.{max, min}\n val memo = Array.ofDim[Long](N+1, N+1)\n val init = Long.MaxValue\n for (a <- 0 to N; b <- 0 to N)\n memo(a)(b) = init\n\n def solve(bg: Int, ed: Int, turn: Boolean): Long = {\n if(memo(bg)(ed) != init)\n memo(bg)(ed)\n else{\n if(bg == ed) {\n memo(bg)(ed) = a(bg) * (if(turn) 1 else -1)\n memo(bg)(ed)\n }\n else {\n val left = solve(bg+1, ed, !turn)\n val right = solve(bg, ed-1, !turn)\n if(turn)\n memo(bg)(ed) = max(left + a(bg), right + a(ed))\n else\n memo(bg)(ed) = min(left - a(bg), right - a(ed))\n memo(bg)(ed)\n }\n }\n }\n\n println(solve(1, N, true))\n}\n\n\nclass InputReader(stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream))\n private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTaro and Jiro will play the following game against each other.\n\nInitially, they are given a sequence a = (a_1, a_2, \\ldots, a_N).\nUntil a becomes empty, the two players perform the following operation alternately, starting from Taro:\n\nRemove the element at the beginning or the end of a. The player earns x points, where x is the removed element.\n\nLet X and Y be Taro's and Jiro's total score at the end of the game, respectively.\nTaro tries to maximize X - Y, while Jiro tries to minimize X - Y.\n\nAssuming that the two players play optimally, find the resulting value of X - Y.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 3000\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint the resulting value of X - Y, assuming that the two players play optimally.\n\nSample Input 1\n\n4\n10 80 90 30\n\nSample Output 1\n\n10\n\nThe game proceeds as follows when the two players play optimally (the element being removed is written bold):\n\nTaro: (10, 80, 90, 30) → (10, 80, 90)\n\nJiro: (10, 80, 90) → (10, 80)\n\nTaro: (10, 80) → (10)\n\nJiro: (10) → ()\n\nHere, X = 30 + 80 = 110 and Y = 90 + 10 = 100.\n\nSample Input 2\n\n3\n10 100 10\n\nSample Output 2\n\n-80\n\nThe game proceeds, for example, as follows when the two players play optimally:\n\nTaro: (10, 100, 10) → (100, 10)\n\nJiro: (100, 10) → (10)\n\nTaro: (10) → ()\n\nHere, X = 10 + 10 = 20 and Y = 100.\n\nSample Input 3\n\n1\n10\n\nSample Output 3\n\n10\n\nSample Input 4\n\n10\n1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1\n\nSample Output 4\n\n4999999995\n\nThe answer may not fit into a 32-bit integer type.\n\nSample Input 5\n\n6\n4 2 9 7 1 5\n\nSample Output 5\n\n2\n\nThe game proceeds, for example, as follows when the two players play optimally:\n\nTaro: (4, 2, 9, 7, 1, 5) → (4, 2, 9, 7, 1)\n\nJiro: (4, 2, 9, 7, 1) → (2, 9, 7, 1)\n\nTaro: (2, 9, 7, 1) → (2, 9, 7)\n\nJiro: (2, 9, 7) → (2, 9)\n\nTaro: (2, 9) → (2)\n\nJiro: (2) → ()\n\nHere, X = 5 + 1 + 9 = 15 and Y = 4 + 7 + 2 = 13.", "sample_input": "4\n10 80 90 30\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03171", "source_text": "Score : 100 points\n\nProblem Statement\n\nTaro and Jiro will play the following game against each other.\n\nInitially, they are given a sequence a = (a_1, a_2, \\ldots, a_N).\nUntil a becomes empty, the two players perform the following operation alternately, starting from Taro:\n\nRemove the element at the beginning or the end of a. The player earns x points, where x is the removed element.\n\nLet X and Y be Taro's and Jiro's total score at the end of the game, respectively.\nTaro tries to maximize X - Y, while Jiro tries to minimize X - Y.\n\nAssuming that the two players play optimally, find the resulting value of X - Y.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 3000\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint the resulting value of X - Y, assuming that the two players play optimally.\n\nSample Input 1\n\n4\n10 80 90 30\n\nSample Output 1\n\n10\n\nThe game proceeds as follows when the two players play optimally (the element being removed is written bold):\n\nTaro: (10, 80, 90, 30) → (10, 80, 90)\n\nJiro: (10, 80, 90) → (10, 80)\n\nTaro: (10, 80) → (10)\n\nJiro: (10) → ()\n\nHere, X = 30 + 80 = 110 and Y = 90 + 10 = 100.\n\nSample Input 2\n\n3\n10 100 10\n\nSample Output 2\n\n-80\n\nThe game proceeds, for example, as follows when the two players play optimally:\n\nTaro: (10, 100, 10) → (100, 10)\n\nJiro: (100, 10) → (10)\n\nTaro: (10) → ()\n\nHere, X = 10 + 10 = 20 and Y = 100.\n\nSample Input 3\n\n1\n10\n\nSample Output 3\n\n10\n\nSample Input 4\n\n10\n1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1\n\nSample Output 4\n\n4999999995\n\nThe answer may not fit into a 32-bit integer type.\n\nSample Input 5\n\n6\n4 2 9 7 1 5\n\nSample Output 5\n\n2\n\nThe game proceeds, for example, as follows when the two players play optimally:\n\nTaro: (4, 2, 9, 7, 1, 5) → (4, 2, 9, 7, 1)\n\nJiro: (4, 2, 9, 7, 1) → (2, 9, 7, 1)\n\nTaro: (2, 9, 7, 1) → (2, 9, 7)\n\nJiro: (2, 9, 7) → (2, 9)\n\nTaro: (2, 9) → (2)\n\nJiro: (2) → ()\n\nHere, X = 5 + 1 + 9 = 15 and Y = 4 + 7 + 2 = 13.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1353, "cpu_time_ms": 570, "memory_kb": 112912}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s597061923", "group_id": "codeNet:p03173", "input_text": "import scala.io.Source\nimport scala.collection.mutable.Map\n\nobject Main {\n def main(args: Array[String]) = {\n val lines = Source.stdin.getLines.toStream\n val inSeq = lines.drop(1).head.split(' ').map(_.toLong)\n\n println(dp(inSeq))\n }\n\n def dp(input: Array[Long]): Long = {\n val memo = Array.ofDim[Long](input.length + 1, input.length + 1, 2)\n\n (1 to input.length).foreach { n =>\n memo(n-1)(n)(0) = input(n-1)\n memo(n-1)(n)(1) = 0\n }\n\n (2 to input.length).foreach { area =>\n (2 to area).foreach { tgLen =>\n var locMin = Long.MaxValue\n var cost = 0L\n ((area - tgLen + 1) to (area - 1)).reverse.foreach { split =>\n var cand = memo(area - tgLen)(split)(1) + memo(split)(area)(1)\n if (cand <= locMin) {\n locMin = cand\n cost = memo(area - tgLen)(split)(0) + memo(split)(area)(0)\n }\n }\n memo(area - tgLen)(area)(0) = cost\n memo(area - tgLen)(area)(1) = locMin + cost\n }\n }\n memo(0)(input.length)(1)\n }\n}\n", "language": "Scala", "metadata": {"date": 1553066942, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03173.html", "problem_id": "p03173", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03173/input.txt", "sample_output_relpath": "derived/input_output/data/p03173/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03173/Scala/s597061923.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s597061923", "user_id": "u895515293"}, "prompt_components": {"gold_output": "190\n", "input_to_evaluate": "import scala.io.Source\nimport scala.collection.mutable.Map\n\nobject Main {\n def main(args: Array[String]) = {\n val lines = Source.stdin.getLines.toStream\n val inSeq = lines.drop(1).head.split(' ').map(_.toLong)\n\n println(dp(inSeq))\n }\n\n def dp(input: Array[Long]): Long = {\n val memo = Array.ofDim[Long](input.length + 1, input.length + 1, 2)\n\n (1 to input.length).foreach { n =>\n memo(n-1)(n)(0) = input(n-1)\n memo(n-1)(n)(1) = 0\n }\n\n (2 to input.length).foreach { area =>\n (2 to area).foreach { tgLen =>\n var locMin = Long.MaxValue\n var cost = 0L\n ((area - tgLen + 1) to (area - 1)).reverse.foreach { split =>\n var cand = memo(area - tgLen)(split)(1) + memo(split)(area)(1)\n if (cand <= locMin) {\n locMin = cand\n cost = memo(area - tgLen)(split)(0) + memo(split)(area)(0)\n }\n }\n memo(area - tgLen)(area)(0) = cost\n memo(area - tgLen)(area)(1) = locMin + cost\n }\n }\n memo(0)(input.length)(1)\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N slimes lining up in a row.\nInitially, the i-th slime from the left has a size of a_i.\n\nTaro is trying to combine all the slimes into a larger slime.\nHe will perform the following operation repeatedly until there is only one slime:\n\nChoose two adjacent slimes, and combine them into a new slime. The new slime has a size of x + y, where x and y are the sizes of the slimes before combining them. Here, a cost of x + y is incurred. The positional relationship of the slimes does not change while combining slimes.\n\nFind the minimum possible total cost incurred.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 400\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint the minimum possible total cost incurred.\n\nSample Input 1\n\n4\n10 20 30 40\n\nSample Output 1\n\n190\n\nTaro should do as follows (slimes being combined are shown in bold):\n\n(10, 20, 30, 40) → (30, 30, 40)\n\n(30, 30, 40) → (60, 40)\n\n(60, 40) → (100)\n\nSample Input 2\n\n5\n10 10 10 10 10\n\nSample Output 2\n\n120\n\nTaro should do, for example, as follows:\n\n(10, 10, 10, 10, 10) → (20, 10, 10, 10)\n\n(20, 10, 10, 10) → (20, 20, 10)\n\n(20, 20, 10) → (20, 30)\n\n(20, 30) → (50)\n\nSample Input 3\n\n3\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n5000000000\n\nThe answer may not fit into a 32-bit integer type.\n\nSample Input 4\n\n6\n7 6 8 6 1 1\n\nSample Output 4\n\n68\n\nTaro should do, for example, as follows:\n\n(7, 6, 8, 6, 1, 1) → (7, 6, 8, 6, 2)\n\n(7, 6, 8, 6, 2) → (7, 6, 8, 8)\n\n(7, 6, 8, 8) → (13, 8, 8)\n\n(13, 8, 8) → (13, 16)\n\n(13, 16) → (29)", "sample_input": "4\n10 20 30 40\n"}, "reference_outputs": ["190\n"], "source_document_id": "p03173", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N slimes lining up in a row.\nInitially, the i-th slime from the left has a size of a_i.\n\nTaro is trying to combine all the slimes into a larger slime.\nHe will perform the following operation repeatedly until there is only one slime:\n\nChoose two adjacent slimes, and combine them into a new slime. The new slime has a size of x + y, where x and y are the sizes of the slimes before combining them. Here, a cost of x + y is incurred. The positional relationship of the slimes does not change while combining slimes.\n\nFind the minimum possible total cost incurred.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 400\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint the minimum possible total cost incurred.\n\nSample Input 1\n\n4\n10 20 30 40\n\nSample Output 1\n\n190\n\nTaro should do as follows (slimes being combined are shown in bold):\n\n(10, 20, 30, 40) → (30, 30, 40)\n\n(30, 30, 40) → (60, 40)\n\n(60, 40) → (100)\n\nSample Input 2\n\n5\n10 10 10 10 10\n\nSample Output 2\n\n120\n\nTaro should do, for example, as follows:\n\n(10, 10, 10, 10, 10) → (20, 10, 10, 10)\n\n(20, 10, 10, 10) → (20, 20, 10)\n\n(20, 20, 10) → (20, 30)\n\n(20, 30) → (50)\n\nSample Input 3\n\n3\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n5000000000\n\nThe answer may not fit into a 32-bit integer type.\n\nSample Input 4\n\n6\n7 6 8 6 1 1\n\nSample Output 4\n\n68\n\nTaro should do, for example, as follows:\n\n(7, 6, 8, 6, 1, 1) → (7, 6, 8, 6, 2)\n\n(7, 6, 8, 6, 2) → (7, 6, 8, 8)\n\n(7, 6, 8, 8) → (13, 8, 8)\n\n(13, 8, 8) → (13, 16)\n\n(13, 16) → (29)", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1039, "cpu_time_ms": 617, "memory_kb": 45284}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s808176752", "group_id": "codeNet:p03173", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val s = new Main()\n s.solve()\n s.out.flush()\n }\n}\n\nclass Main {\n import java.io._\n import java.util.StringTokenizer\n\n import scala.collection.mutable\n import scala.util.Sorting\n import math.{abs, max, min}\n import mutable.{ArrayBuffer, ListBuffer}\n import scala.reflect.ClassTag\n\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n\n def solve(): Unit = {\n val N = ni()\n val A = na(N)\n\n val cum = cumSum(A)\n\n // [L, R)\n val dp = Array.ofDim[Long](N, N + 1)\n REP(N, 1) { r =>\n if (r >= 2) {\n // rの2つ左から\n REP_r(r - 1) { l =>\n var v = Long.MaxValue / 2\n // k: (l, r)\n l + 1 until r foreach { k =>\n val cost = cum(r) - cum(l)\n v = min(v, dp(l)(k) + dp(k)(r) + cost)\n }\n dp(l)(r) = v\n// debug(s\"[$l,$r) $v\")\n }\n }\n }\n\n val ans = dp(0)(N)\n out.println(ans)\n }\n\n def debug(as: Array[Boolean]): Unit = {\n System.err.println(as.map(x => if(x) \"1\" else \"0\").mkString)\n }\n\n def debug(as: Array[Int]): Unit = {\n System.err.println(as.mkString(\" \"))\n }\n\n def debug(s: String): Unit = {\n System.err.println(s)\n }\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next().toInt\n def nextLong(): Long = next().toLong\n def nextChar(): Char = next().charAt(0)\n }\n val sc = new InputReader(System.in)\n def ni(): Int = sc.nextInt()\n def nl(): Long = sc.nextLong()\n def nc(): Char = sc.nextChar()\n def ns(): String = sc.next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n\n def cumSum(as: Array[Int]) = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n", "language": "Scala", "metadata": {"date": 1547000659, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03173.html", "problem_id": "p03173", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03173/input.txt", "sample_output_relpath": "derived/input_output/data/p03173/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03173/Scala/s808176752.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s808176752", "user_id": "u460609472"}, "prompt_components": {"gold_output": "190\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val s = new Main()\n s.solve()\n s.out.flush()\n }\n}\n\nclass Main {\n import java.io._\n import java.util.StringTokenizer\n\n import scala.collection.mutable\n import scala.util.Sorting\n import math.{abs, max, min}\n import mutable.{ArrayBuffer, ListBuffer}\n import scala.reflect.ClassTag\n\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n\n def solve(): Unit = {\n val N = ni()\n val A = na(N)\n\n val cum = cumSum(A)\n\n // [L, R)\n val dp = Array.ofDim[Long](N, N + 1)\n REP(N, 1) { r =>\n if (r >= 2) {\n // rの2つ左から\n REP_r(r - 1) { l =>\n var v = Long.MaxValue / 2\n // k: (l, r)\n l + 1 until r foreach { k =>\n val cost = cum(r) - cum(l)\n v = min(v, dp(l)(k) + dp(k)(r) + cost)\n }\n dp(l)(r) = v\n// debug(s\"[$l,$r) $v\")\n }\n }\n }\n\n val ans = dp(0)(N)\n out.println(ans)\n }\n\n def debug(as: Array[Boolean]): Unit = {\n System.err.println(as.map(x => if(x) \"1\" else \"0\").mkString)\n }\n\n def debug(as: Array[Int]): Unit = {\n System.err.println(as.mkString(\" \"))\n }\n\n def debug(s: String): Unit = {\n System.err.println(s)\n }\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next().toInt\n def nextLong(): Long = next().toLong\n def nextChar(): Char = next().charAt(0)\n }\n val sc = new InputReader(System.in)\n def ni(): Int = sc.nextInt()\n def nl(): Long = sc.nextLong()\n def nc(): Char = sc.nextChar()\n def ns(): String = sc.next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n\n def cumSum(as: Array[Int]) = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N slimes lining up in a row.\nInitially, the i-th slime from the left has a size of a_i.\n\nTaro is trying to combine all the slimes into a larger slime.\nHe will perform the following operation repeatedly until there is only one slime:\n\nChoose two adjacent slimes, and combine them into a new slime. The new slime has a size of x + y, where x and y are the sizes of the slimes before combining them. Here, a cost of x + y is incurred. The positional relationship of the slimes does not change while combining slimes.\n\nFind the minimum possible total cost incurred.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 400\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint the minimum possible total cost incurred.\n\nSample Input 1\n\n4\n10 20 30 40\n\nSample Output 1\n\n190\n\nTaro should do as follows (slimes being combined are shown in bold):\n\n(10, 20, 30, 40) → (30, 30, 40)\n\n(30, 30, 40) → (60, 40)\n\n(60, 40) → (100)\n\nSample Input 2\n\n5\n10 10 10 10 10\n\nSample Output 2\n\n120\n\nTaro should do, for example, as follows:\n\n(10, 10, 10, 10, 10) → (20, 10, 10, 10)\n\n(20, 10, 10, 10) → (20, 20, 10)\n\n(20, 20, 10) → (20, 30)\n\n(20, 30) → (50)\n\nSample Input 3\n\n3\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n5000000000\n\nThe answer may not fit into a 32-bit integer type.\n\nSample Input 4\n\n6\n7 6 8 6 1 1\n\nSample Output 4\n\n68\n\nTaro should do, for example, as follows:\n\n(7, 6, 8, 6, 1, 1) → (7, 6, 8, 6, 2)\n\n(7, 6, 8, 6, 2) → (7, 6, 8, 8)\n\n(7, 6, 8, 8) → (13, 8, 8)\n\n(13, 8, 8) → (13, 16)\n\n(13, 16) → (29)", "sample_input": "4\n10 20 30 40\n"}, "reference_outputs": ["190\n"], "source_document_id": "p03173", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N slimes lining up in a row.\nInitially, the i-th slime from the left has a size of a_i.\n\nTaro is trying to combine all the slimes into a larger slime.\nHe will perform the following operation repeatedly until there is only one slime:\n\nChoose two adjacent slimes, and combine them into a new slime. The new slime has a size of x + y, where x and y are the sizes of the slimes before combining them. Here, a cost of x + y is incurred. The positional relationship of the slimes does not change while combining slimes.\n\nFind the minimum possible total cost incurred.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 400\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint the minimum possible total cost incurred.\n\nSample Input 1\n\n4\n10 20 30 40\n\nSample Output 1\n\n190\n\nTaro should do as follows (slimes being combined are shown in bold):\n\n(10, 20, 30, 40) → (30, 30, 40)\n\n(30, 30, 40) → (60, 40)\n\n(60, 40) → (100)\n\nSample Input 2\n\n5\n10 10 10 10 10\n\nSample Output 2\n\n120\n\nTaro should do, for example, as follows:\n\n(10, 10, 10, 10, 10) → (20, 10, 10, 10)\n\n(20, 10, 10, 10) → (20, 20, 10)\n\n(20, 20, 10) → (20, 30)\n\n(20, 30) → (50)\n\nSample Input 3\n\n3\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n5000000000\n\nThe answer may not fit into a 32-bit integer type.\n\nSample Input 4\n\n6\n7 6 8 6 1 1\n\nSample Output 4\n\n68\n\nTaro should do, for example, as follows:\n\n(7, 6, 8, 6, 1, 1) → (7, 6, 8, 6, 2)\n\n(7, 6, 8, 6, 2) → (7, 6, 8, 8)\n\n(7, 6, 8, 8) → (13, 8, 8)\n\n(13, 8, 8) → (13, 16)\n\n(13, 16) → (29)", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3215, "cpu_time_ms": 457, "memory_kb": 32540}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s075192295", "group_id": "codeNet:p03178", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val s = new Main()\n s.solve()\n s.out.flush()\n }\n}\n\nclass Main {\n import java.io._\n import java.util.StringTokenizer\n\n import scala.collection.mutable\n import scala.util.Sorting\n import math.{abs, max, min}\n import mutable.{ArrayBuffer, ListBuffer}\n import scala.reflect.ClassTag\n\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n\n def solve(): Unit = {\n val K = ns()\n val N = K.length\n val M = ni()\n\n val dp = Array.ofDim[Long](N + 1, 2, M)\n dp(0)(0)(0) = 1\n dp(0)(1)(0) = 1\n\n REP(N, 1) { i =>\n REP(2) { less =>\n val digit = K(N - i) - '0'\n val len = if (less == 1) 10 else digit + 1\n REP(len) { d =>\n REP(M) { m =>\n val nextLess = less | (if (d < digit) 1 else 0)\n// debug(s\"$i $less $nextLess m:$m j:$d\")\n dp(i)(less)(m) += dp(i - 1)(nextLess)((M * 10 + m - d) % M)\n }\n }\n\n // まとめてやる\n REP(M) { m =>\n dp(i)(less)(m) %= MOD\n }\n\n DEBUG {\n debug(s\"i:$i less:$less\")\n debug(dp(i)(less))\n }\n }\n }\n\n val ans = dp(N)(0)(0) - 1 // 0を引く\n out.println(ans)\n }\n\n private val oj = System.getenv(\"ATCODER_DEBUG\") == null\n\n def DEBUG(f: => Unit): Unit = {\n if (!oj){ f }\n }\n\n def debug(as: Array[Boolean]): Unit = DEBUG {\n debug(as.map(x => if(x) \"1\" else \"0\").mkString)\n }\n\n def debug(as: Array[Int]): Unit = DEBUG {\n debug(as.mkString(\" \"))\n }\n\n def debug(as: Array[Long]): Unit = DEBUG {\n debug(as.mkString(\" \"))\n }\n\n def debug(s: => String): Unit = DEBUG {\n System.err.println(s)\n }\n\n def debugNum(num: => Long): Unit = DEBUG {\n System.err.println(num)\n }\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next().toInt\n def nextLong(): Long = next().toLong\n def nextChar(): Char = next().charAt(0)\n }\n val sc = new InputReader(System.in)\n def ni(): Int = sc.nextInt()\n def nl(): Long = sc.nextLong()\n def nc(): Char = sc.nextChar()\n def ns(): String = sc.next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n def TO(from: Int, to: Int)(f: Int => Unit): Unit = {\n REP(to - from + 1, from) { i =>\n f(i)\n }\n }\n\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n\n def cumSum(as: Array[Int]) = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n", "language": "Scala", "metadata": {"date": 1552966413, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03178.html", "problem_id": "p03178", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03178/input.txt", "sample_output_relpath": "derived/input_output/data/p03178/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03178/Scala/s075192295.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s075192295", "user_id": "u460609472"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val s = new Main()\n s.solve()\n s.out.flush()\n }\n}\n\nclass Main {\n import java.io._\n import java.util.StringTokenizer\n\n import scala.collection.mutable\n import scala.util.Sorting\n import math.{abs, max, min}\n import mutable.{ArrayBuffer, ListBuffer}\n import scala.reflect.ClassTag\n\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n\n def solve(): Unit = {\n val K = ns()\n val N = K.length\n val M = ni()\n\n val dp = Array.ofDim[Long](N + 1, 2, M)\n dp(0)(0)(0) = 1\n dp(0)(1)(0) = 1\n\n REP(N, 1) { i =>\n REP(2) { less =>\n val digit = K(N - i) - '0'\n val len = if (less == 1) 10 else digit + 1\n REP(len) { d =>\n REP(M) { m =>\n val nextLess = less | (if (d < digit) 1 else 0)\n// debug(s\"$i $less $nextLess m:$m j:$d\")\n dp(i)(less)(m) += dp(i - 1)(nextLess)((M * 10 + m - d) % M)\n }\n }\n\n // まとめてやる\n REP(M) { m =>\n dp(i)(less)(m) %= MOD\n }\n\n DEBUG {\n debug(s\"i:$i less:$less\")\n debug(dp(i)(less))\n }\n }\n }\n\n val ans = dp(N)(0)(0) - 1 // 0を引く\n out.println(ans)\n }\n\n private val oj = System.getenv(\"ATCODER_DEBUG\") == null\n\n def DEBUG(f: => Unit): Unit = {\n if (!oj){ f }\n }\n\n def debug(as: Array[Boolean]): Unit = DEBUG {\n debug(as.map(x => if(x) \"1\" else \"0\").mkString)\n }\n\n def debug(as: Array[Int]): Unit = DEBUG {\n debug(as.mkString(\" \"))\n }\n\n def debug(as: Array[Long]): Unit = DEBUG {\n debug(as.mkString(\" \"))\n }\n\n def debug(s: => String): Unit = DEBUG {\n System.err.println(s)\n }\n\n def debugNum(num: => Long): Unit = DEBUG {\n System.err.println(num)\n }\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next().toInt\n def nextLong(): Long = next().toLong\n def nextChar(): Char = next().charAt(0)\n }\n val sc = new InputReader(System.in)\n def ni(): Int = sc.nextInt()\n def nl(): Long = sc.nextLong()\n def nc(): Char = sc.nextChar()\n def ns(): String = sc.next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n def TO(from: Int, to: Int)(f: Int => Unit): Unit = {\n REP(to - from + 1, from) { i =>\n f(i)\n }\n }\n\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n\n def cumSum(as: Array[Int]) = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nFind the number of integers between 1 and K (inclusive) satisfying the following condition, modulo 10^9 + 7:\n\nThe sum of the digits in base ten is a multiple of D.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq K < 10^{10000}\n\n1 \\leq D \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nD\n\nOutput\n\nPrint the number of integers satisfying the condition, modulo 10^9 + 7.\n\nSample Input 1\n\n30\n4\n\nSample Output 1\n\n6\n\nThose six integers are: 4, 8, 13, 17, 22 and 26.\n\nSample Input 2\n\n1000000009\n1\n\nSample Output 2\n\n2\n\nBe sure to print the number modulo 10^9 + 7.\n\nSample Input 3\n\n98765432109876543210\n58\n\nSample Output 3\n\n635270834", "sample_input": "30\n4\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03178", "source_text": "Score : 100 points\n\nProblem Statement\n\nFind the number of integers between 1 and K (inclusive) satisfying the following condition, modulo 10^9 + 7:\n\nThe sum of the digits in base ten is a multiple of D.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq K < 10^{10000}\n\n1 \\leq D \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nD\n\nOutput\n\nPrint the number of integers satisfying the condition, modulo 10^9 + 7.\n\nSample Input 1\n\n30\n4\n\nSample Output 1\n\n6\n\nThose six integers are: 4, 8, 13, 17, 22 and 26.\n\nSample Input 2\n\n1000000009\n1\n\nSample Output 2\n\n2\n\nBe sure to print the number modulo 10^9 + 7.\n\nSample Input 3\n\n98765432109876543210\n58\n\nSample Output 3\n\n635270834", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3846, "cpu_time_ms": 626, "memory_kb": 65288}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s018754579", "group_id": "codeNet:p03186", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val A, B, C = sc.nextInt()\n println(if (C - 1 <= A + B) C + B else B * 2 + A + 1)\n}\n", "language": "Scala", "metadata": {"date": 1598800845, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03186.html", "problem_id": "p03186", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03186/input.txt", "sample_output_relpath": "derived/input_output/data/p03186/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03186/Scala/s018754579.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s018754579", "user_id": "u737111725"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val A, B, C = sc.nextInt()\n println(if (C - 1 <= A + B) C + B else B * 2 + A + 1)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison.\n\nEating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death.\nAs he wants to live, he cannot eat one in such a situation.\nEating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches.\n\nFind the maximum number of tasty cookies that Takahashi can eat.\n\nConstraints\n\n0 \\leq A,B,C \\leq 10^9\n\nA,B and C are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the maximum number of tasty cookies that Takahashi can eat.\n\nSample Input 1\n\n3 1 4\n\nSample Output 1\n\n5\n\nWe can eat all tasty cookies, in the following order:\n\nA tasty cookie containing poison\n\nAn untasty cookie containing antidotes\n\nA tasty cookie containing poison\n\nA tasty cookie containing antidotes\n\nA tasty cookie containing poison\n\nAn untasty cookie containing antidotes\n\nA tasty cookie containing poison\n\nSample Input 2\n\n5 2 9\n\nSample Output 2\n\n10\n\nSample Input 3\n\n8 8 1\n\nSample Output 3\n\n9", "sample_input": "3 1 4\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03186", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison.\n\nEating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death.\nAs he wants to live, he cannot eat one in such a situation.\nEating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches.\n\nFind the maximum number of tasty cookies that Takahashi can eat.\n\nConstraints\n\n0 \\leq A,B,C \\leq 10^9\n\nA,B and C are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the maximum number of tasty cookies that Takahashi can eat.\n\nSample Input 1\n\n3 1 4\n\nSample Output 1\n\n5\n\nWe can eat all tasty cookies, in the following order:\n\nA tasty cookie containing poison\n\nAn untasty cookie containing antidotes\n\nA tasty cookie containing poison\n\nA tasty cookie containing antidotes\n\nA tasty cookie containing poison\n\nAn untasty cookie containing antidotes\n\nA tasty cookie containing poison\n\nSample Input 2\n\n5 2 9\n\nSample Output 2\n\n10\n\nSample Input 3\n\n8 8 1\n\nSample Output 3\n\n9", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 487, "memory_kb": 55300}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s722315232", "group_id": "codeNet:p03193", "input_text": "import scala.io.StdIn\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n\n val Array(n, h, w): Array[Int] = StdIn.readLine().split(' ').map(_.toInt)\n val abs: Seq[Seq[Int]] =\n (1 to n).foldLeft(Vector(): Vector[Vector[Int]])((acc, _) =>\n acc :+ StdIn.readLine().split(' ').toVector.map(_.toInt))\n\n println(solve(h, w, abs))\n\n }\n\n def solve(h: Int, w: Int, abs: Seq[Seq[Int]]): Int = {\n\n abs.foldLeft(0)((acc, ab) => {\n val d = if (ab(0) >= h && ab(1) >= w) 1 else 0\n acc + d\n })\n\n }\n}\n", "language": "Scala", "metadata": {"date": 1560810839, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s722315232.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s722315232", "user_id": "u252817963"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n\n val Array(n, h, w): Array[Int] = StdIn.readLine().split(' ').map(_.toInt)\n val abs: Seq[Seq[Int]] =\n (1 to n).foldLeft(Vector(): Vector[Vector[Int]])((acc, _) =>\n acc :+ StdIn.readLine().split(' ').toVector.map(_.toInt))\n\n println(solve(h, w, abs))\n\n }\n\n def solve(h: Int, w: Int, abs: Seq[Seq[Int]]): Int = {\n\n abs.foldLeft(0)((acc, ab) => {\n val d = if (ab(0) >= h && ab(1) >= w) 1 else 0\n acc + d\n })\n\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 427, "memory_kb": 30704}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s151214139", "group_id": "codeNet:p03198", "input_text": "object Main extends App {\n\n import scala.io.StdIn._\n import scala.math._\n\n implicit def toWith(value: Long): NumberWithExponent = value.toWithExp\n implicit class Converter(private val value : Long){\n def toWithExp: NumberWithExponent = NumberWithExponent(value, 0)\n }\n val n = readLine.trim.toInt\n val numbers = readLine.trim.split(' ').map(_.toLong)\n val minus = minCountOfSortWithMinusTo(numbers).toList\n val plus = minCountOfSortWithPlusAfter(numbers).toList\n println(\n (0::minus).zip(plus ++ List(0)).map{case (l, r) ⇒ l + r}.min\n )\n def minCountOfSortWithMinusTo(numbers: Array[Long]): Array[Int] = {\n var list = Nil: List[MinusSortedSequence]\n numbers.map{right ⇒\n val (c, n) = addMinus(right, list)\n list = n\n c\n }.also{arr ⇒\n for (i ← 1 until arr.length){\n arr(i) += arr(i - 1)\n }\n }\n }\n def minCountOfSortWithPlusAfter(numbers: Array[Long]): Array[Int] = {\n var list = Nil: List[PlusSortedSequence]\n numbers.reverse.map{left ⇒\n val (c, n) = addPlus(left, list)\n list = n\n c\n }.also{arr ⇒\n for (i ← 1 until arr.length){\n arr(i) += arr(i - 1)\n }\n }.reverse\n }\n\n def addPlus(addLeft: Long, prev: List[PlusSortedSequence] = Nil): (Int, List[PlusSortedSequence]) = {\n prev match {\n case Nil if addLeft > 0 ⇒ (0, PlusSortedSequence(addLeft, addLeft, 1)::Nil)\n case Nil ⇒ (1, PlusSortedSequence(addLeft * -2, addLeft * -2, 1)::Nil)\n case PlusSortedSequence(left, right, length)::t if left >= addLeft && addLeft >= 0 ⇒\n if (left >= addLeft * 4) (0, PlusSortedSequence(addLeft, addLeft, 1)::prev)\n else (0, PlusSortedSequence(addLeft, right, length + 1)::t)\n case PlusSortedSequence(left, _, _)::_ if left < addLeft ⇒\n val (count, next) = increaseWhile(prev, addLeft)\n addPlus(addLeft, next).let{case (c, n) ⇒ (c + count, n)}\n case _ ⇒ addPlus(addLeft * -2, prev).let{case (c, n) ⇒ (c + 1, n)}\n }\n }\n def addMinus(addRight: Long, prev: List[MinusSortedSequence] = Nil): (Int, List[MinusSortedSequence]) = {\n prev match{\n case Nil if addRight < 0 ⇒ (0, MinusSortedSequence(addRight, addRight, 1)::Nil)\n case Nil ⇒ (1, MinusSortedSequence(addRight * -2, addRight * -2, 1)::Nil)\n case MinusSortedSequence(left, right, length)::t if right <= addRight && addRight <= 0 ⇒\n if (right <= addRight * 4) (0, MinusSortedSequence(addRight, addRight, 1)::prev)\n else (0, MinusSortedSequence(left, addRight, length + 1)::t)\n case MinusSortedSequence(_, right, _)::_ if addRight < right ⇒\n val (count, next) = decreaseWhile(prev, addRight)\n addMinus(addRight, next).let{case (c, n) ⇒ (c + count, n)}\n case _ ⇒ addMinus(addRight * -2, prev).let{case (c, n) ⇒ (c + 1, n)}\n }\n }\n def increaseWhile(list: List[PlusSortedSequence], target: NumberWithExponent): (Int, List[PlusSortedSequence]) = {\n list match {\n case h::_ if h.left < target ⇒ increaseWhile(increase(list), target).let{case (c, l) ⇒ (c + h.length * 2, l)}\n case _ ⇒ (0, list)\n }\n }\n def decreaseWhile(list: List[MinusSortedSequence], target: NumberWithExponent): (Int, List[MinusSortedSequence]) = {\n list match {\n case h::_ if h.right > target ⇒\n decreaseWhile(decrease(list), target).let{case (c, l) ⇒ (c + h.length * 2, l)}\n case _ ⇒ (0, list)\n }\n }\n def increase(list: List[PlusSortedSequence]): List[PlusSortedSequence] = {\n list match {\n case PlusSortedSequence(left, r, len1)::PlusSortedSequence(l, right, len2)::t if r.copy(exponent = r.exponent + 4) > l ⇒ PlusSortedSequence(left.copy(exponent = left.exponent + 2), right, len1 + len2)::t\n case PlusSortedSequence(left, right, length)::t ⇒ PlusSortedSequence(left.copy(exponent = left.exponent + 2), right.copy(exponent = right.exponent + 2), length)::t\n case Nil ⇒ Nil\n }\n }\n def decrease(list: List[MinusSortedSequence]): List[MinusSortedSequence] = {\n list match {\n case MinusSortedSequence(l, right, length)::MinusSortedSequence(left, r, len)::t if l.copy(exponent = l.exponent + 4) > r ⇒ MinusSortedSequence(left, right.copy(exponent = right.exponent + 2), length + len)::t\n case MinusSortedSequence(left, right, length)::t ⇒ MinusSortedSequence(left.copy(exponent = left.exponent + 2), right.copy(exponent = right.exponent + 2), length)::t\n case Nil ⇒ Nil\n }\n }\n case class PlusSortedSequence(left: NumberWithExponent, right: NumberWithExponent, length: Int)\n case class MinusSortedSequence(left: NumberWithExponent, right: NumberWithExponent, length: Int)\n case class NumberWithExponent(value: Long, exponent: Int) extends Ordered[NumberWithExponent] {\n override def compare(that: NumberWithExponent): Int = toLogWithSign.compare(that.toLogWithSign)\n private val sign: Int = math.signum(value).toInt * (if (exponent % 2 == 1) -1:Int else 1: Int)\n private val toLogWithSign: Double = (math.log(math.abs(value)) + math.log(2) * exponent) * sign\n }\n implicit class Extension[T](val value :T){\n def also(func: T ⇒ Unit): T = {\n func(value)\n value\n }\n def let[R](func: T ⇒ R): R = func(value)\n }\n}", "language": "Scala", "metadata": {"date": 1545536088, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03198.html", "problem_id": "p03198", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03198/input.txt", "sample_output_relpath": "derived/input_output/data/p03198/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03198/Scala/s151214139.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s151214139", "user_id": "u419330815"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main extends App {\n\n import scala.io.StdIn._\n import scala.math._\n\n implicit def toWith(value: Long): NumberWithExponent = value.toWithExp\n implicit class Converter(private val value : Long){\n def toWithExp: NumberWithExponent = NumberWithExponent(value, 0)\n }\n val n = readLine.trim.toInt\n val numbers = readLine.trim.split(' ').map(_.toLong)\n val minus = minCountOfSortWithMinusTo(numbers).toList\n val plus = minCountOfSortWithPlusAfter(numbers).toList\n println(\n (0::minus).zip(plus ++ List(0)).map{case (l, r) ⇒ l + r}.min\n )\n def minCountOfSortWithMinusTo(numbers: Array[Long]): Array[Int] = {\n var list = Nil: List[MinusSortedSequence]\n numbers.map{right ⇒\n val (c, n) = addMinus(right, list)\n list = n\n c\n }.also{arr ⇒\n for (i ← 1 until arr.length){\n arr(i) += arr(i - 1)\n }\n }\n }\n def minCountOfSortWithPlusAfter(numbers: Array[Long]): Array[Int] = {\n var list = Nil: List[PlusSortedSequence]\n numbers.reverse.map{left ⇒\n val (c, n) = addPlus(left, list)\n list = n\n c\n }.also{arr ⇒\n for (i ← 1 until arr.length){\n arr(i) += arr(i - 1)\n }\n }.reverse\n }\n\n def addPlus(addLeft: Long, prev: List[PlusSortedSequence] = Nil): (Int, List[PlusSortedSequence]) = {\n prev match {\n case Nil if addLeft > 0 ⇒ (0, PlusSortedSequence(addLeft, addLeft, 1)::Nil)\n case Nil ⇒ (1, PlusSortedSequence(addLeft * -2, addLeft * -2, 1)::Nil)\n case PlusSortedSequence(left, right, length)::t if left >= addLeft && addLeft >= 0 ⇒\n if (left >= addLeft * 4) (0, PlusSortedSequence(addLeft, addLeft, 1)::prev)\n else (0, PlusSortedSequence(addLeft, right, length + 1)::t)\n case PlusSortedSequence(left, _, _)::_ if left < addLeft ⇒\n val (count, next) = increaseWhile(prev, addLeft)\n addPlus(addLeft, next).let{case (c, n) ⇒ (c + count, n)}\n case _ ⇒ addPlus(addLeft * -2, prev).let{case (c, n) ⇒ (c + 1, n)}\n }\n }\n def addMinus(addRight: Long, prev: List[MinusSortedSequence] = Nil): (Int, List[MinusSortedSequence]) = {\n prev match{\n case Nil if addRight < 0 ⇒ (0, MinusSortedSequence(addRight, addRight, 1)::Nil)\n case Nil ⇒ (1, MinusSortedSequence(addRight * -2, addRight * -2, 1)::Nil)\n case MinusSortedSequence(left, right, length)::t if right <= addRight && addRight <= 0 ⇒\n if (right <= addRight * 4) (0, MinusSortedSequence(addRight, addRight, 1)::prev)\n else (0, MinusSortedSequence(left, addRight, length + 1)::t)\n case MinusSortedSequence(_, right, _)::_ if addRight < right ⇒\n val (count, next) = decreaseWhile(prev, addRight)\n addMinus(addRight, next).let{case (c, n) ⇒ (c + count, n)}\n case _ ⇒ addMinus(addRight * -2, prev).let{case (c, n) ⇒ (c + 1, n)}\n }\n }\n def increaseWhile(list: List[PlusSortedSequence], target: NumberWithExponent): (Int, List[PlusSortedSequence]) = {\n list match {\n case h::_ if h.left < target ⇒ increaseWhile(increase(list), target).let{case (c, l) ⇒ (c + h.length * 2, l)}\n case _ ⇒ (0, list)\n }\n }\n def decreaseWhile(list: List[MinusSortedSequence], target: NumberWithExponent): (Int, List[MinusSortedSequence]) = {\n list match {\n case h::_ if h.right > target ⇒\n decreaseWhile(decrease(list), target).let{case (c, l) ⇒ (c + h.length * 2, l)}\n case _ ⇒ (0, list)\n }\n }\n def increase(list: List[PlusSortedSequence]): List[PlusSortedSequence] = {\n list match {\n case PlusSortedSequence(left, r, len1)::PlusSortedSequence(l, right, len2)::t if r.copy(exponent = r.exponent + 4) > l ⇒ PlusSortedSequence(left.copy(exponent = left.exponent + 2), right, len1 + len2)::t\n case PlusSortedSequence(left, right, length)::t ⇒ PlusSortedSequence(left.copy(exponent = left.exponent + 2), right.copy(exponent = right.exponent + 2), length)::t\n case Nil ⇒ Nil\n }\n }\n def decrease(list: List[MinusSortedSequence]): List[MinusSortedSequence] = {\n list match {\n case MinusSortedSequence(l, right, length)::MinusSortedSequence(left, r, len)::t if l.copy(exponent = l.exponent + 4) > r ⇒ MinusSortedSequence(left, right.copy(exponent = right.exponent + 2), length + len)::t\n case MinusSortedSequence(left, right, length)::t ⇒ MinusSortedSequence(left.copy(exponent = left.exponent + 2), right.copy(exponent = right.exponent + 2), length)::t\n case Nil ⇒ Nil\n }\n }\n case class PlusSortedSequence(left: NumberWithExponent, right: NumberWithExponent, length: Int)\n case class MinusSortedSequence(left: NumberWithExponent, right: NumberWithExponent, length: Int)\n case class NumberWithExponent(value: Long, exponent: Int) extends Ordered[NumberWithExponent] {\n override def compare(that: NumberWithExponent): Int = toLogWithSign.compare(that.toLogWithSign)\n private val sign: Int = math.signum(value).toInt * (if (exponent % 2 == 1) -1:Int else 1: Int)\n private val toLogWithSign: Double = (math.log(math.abs(value)) + math.log(2) * exponent) * sign\n }\n implicit class Extension[T](val value :T){\n def also(func: T ⇒ Unit): T = {\n func(value)\n value\n }\n def let[R](func: T ⇒ R): R = func(value)\n }\n}", "problem_context": "Score : 800 points\n\nProblem Statement\n\nThere are N positive integers A_1, A_2, ..., A_N.\nTakahashi can perform the following operation on these integers any number of times:\n\nChoose 1 \\leq i \\leq N and multiply the value of A_i by -2.\n\nNotice that he multiplies it by minus two.\n\nHe would like to make A_1 \\leq A_2 \\leq ... \\leq A_N holds.\nFind the minimum number of operations required. If it is impossible, print -1.\n\nConstraints\n\n1 \\leq N \\leq 200000\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 answer.\n\nSample Input 1\n\n4\n3 1 4 1\n\nSample Output 1\n\n3\n\nOne possible solution is:\n\nChoose i=4 and multiply the value of A_4 by -2. A_1, A_2, A_3, A_4 are now 3, 1, 4, -2.\n\nChoose i=1 and multiply the value of A_1 by -2. A_1, A_2, A_3, A_4 are now -6, 1, 4, -2.\n\nChoose i=4 and multiply the value of A_4 by -2. A_1, A_2, A_3, A_4 are now -6, 1, 4, 4.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\n0\n\nA_1 \\leq A_2 \\leq ... \\leq A_N holds before any operation is performed.\n\nSample Input 3\n\n8\n657312726 129662684 181537270 324043958 468214806 916875077 825989291 319670097\n\nSample Output 3\n\n7", "sample_input": "4\n3 1 4 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03198", "source_text": "Score : 800 points\n\nProblem Statement\n\nThere are N positive integers A_1, A_2, ..., A_N.\nTakahashi can perform the following operation on these integers any number of times:\n\nChoose 1 \\leq i \\leq N and multiply the value of A_i by -2.\n\nNotice that he multiplies it by minus two.\n\nHe would like to make A_1 \\leq A_2 \\leq ... \\leq A_N holds.\nFind the minimum number of operations required. If it is impossible, print -1.\n\nConstraints\n\n1 \\leq N \\leq 200000\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 answer.\n\nSample Input 1\n\n4\n3 1 4 1\n\nSample Output 1\n\n3\n\nOne possible solution is:\n\nChoose i=4 and multiply the value of A_4 by -2. A_1, A_2, A_3, A_4 are now 3, 1, 4, -2.\n\nChoose i=1 and multiply the value of A_1 by -2. A_1, A_2, A_3, A_4 are now -6, 1, 4, -2.\n\nChoose i=4 and multiply the value of A_4 by -2. A_1, A_2, A_3, A_4 are now -6, 1, 4, 4.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\n0\n\nA_1 \\leq A_2 \\leq ... \\leq A_N holds before any operation is performed.\n\nSample Input 3\n\n8\n657312726 129662684 181537270 324043958 468214806 916875077 825989291 319670097\n\nSample Output 3\n\n7", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5229, "cpu_time_ms": 1797, "memory_kb": 158432}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s267452708", "group_id": "codeNet:p03200", "input_text": "object Main extends App {\n private def func(s:Array[Char]):Int = {\n var count = 0\n var last = 0\n //do{\n var i=0\n while(i < s.size){\n if(s(i)=='W'){\n last += 1\n count += (i - last + 1)\n }\n i+=1\n //println(count, i, find, s.toSeq)\n } \n //} while(false/*find*/)\n count\n }\n println(func(io.Source.stdin.getLines.toIndexedSeq.head.toCharArray))\n}\n", "language": "Scala", "metadata": {"date": 1544929483, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s267452708.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s267452708", "user_id": "u699236457"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n private def func(s:Array[Char]):Int = {\n var count = 0\n var last = 0\n //do{\n var i=0\n while(i < s.size){\n if(s(i)=='W'){\n last += 1\n count += (i - last + 1)\n }\n i+=1\n //println(count, i, find, s.toSeq)\n } \n //} while(false/*find*/)\n count\n }\n println(func(io.Source.stdin.getLines.toIndexedSeq.head.toCharArray))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 381, "memory_kb": 30968}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s100419949", "group_id": "codeNet:p03201", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val s = new Main()\n s.solve()\n s.out.flush()\n }\n}\n\nclass Main {\n import java.io._\n import java.util.StringTokenizer\n\n import scala.collection.mutable\n import scala.util.Sorting\n import math.{abs, max, min}\n import mutable.{ArrayBuffer, ListBuffer}\n import scala.reflect.ClassTag\n\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n\n def solve(): Unit = {\n val N = ni()\n val A = na(N)\n val C = mutable.Map[Int, Int]().withDefaultValue(0)\n val S = mutable.Set[Int]()\n REP(N) { i =>\n C(A(i)) = C(A(i)) + 1\n S += A(i)\n }\n\n var ans = 0\n // 大きいほうからどんよくに\n REP_r(4, 1) { k =>\n val sum = 1 << k\n S.foreach { a =>\n val b = sum - a\n if (C(a) > 0 && C(b) > 0) {\n if (a == b) {\n val cnt = C(a) / 2\n ans += cnt\n C(a) = C(a) + cnt\n } else {\n val cnt = min(C(b), C(a))\n ans += cnt\n C(a) = C(a) - 1\n C(b) = C(b) - 1\n }\n }\n }\n }\n\n out.println(ans)\n }\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next().toInt\n def nextLong(): Long = next().toLong\n def nextChar(): Char = next().charAt(0)\n }\n val sc = new InputReader(System.in)\n def ni(): Int = sc.nextInt()\n def nl(): Long = sc.nextLong()\n def nc(): Char = sc.nextChar()\n def ns(): String = sc.next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n\n def cumSum(as: Array[Int]) = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}", "language": "Scala", "metadata": {"date": 1544927827, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03201.html", "problem_id": "p03201", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03201/input.txt", "sample_output_relpath": "derived/input_output/data/p03201/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03201/Scala/s100419949.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s100419949", "user_id": "u460609472"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val s = new Main()\n s.solve()\n s.out.flush()\n }\n}\n\nclass Main {\n import java.io._\n import java.util.StringTokenizer\n\n import scala.collection.mutable\n import scala.util.Sorting\n import math.{abs, max, min}\n import mutable.{ArrayBuffer, ListBuffer}\n import scala.reflect.ClassTag\n\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n\n def solve(): Unit = {\n val N = ni()\n val A = na(N)\n val C = mutable.Map[Int, Int]().withDefaultValue(0)\n val S = mutable.Set[Int]()\n REP(N) { i =>\n C(A(i)) = C(A(i)) + 1\n S += A(i)\n }\n\n var ans = 0\n // 大きいほうからどんよくに\n REP_r(4, 1) { k =>\n val sum = 1 << k\n S.foreach { a =>\n val b = sum - a\n if (C(a) > 0 && C(b) > 0) {\n if (a == b) {\n val cnt = C(a) / 2\n ans += cnt\n C(a) = C(a) + cnt\n } else {\n val cnt = min(C(b), C(a))\n ans += cnt\n C(a) = C(a) - 1\n C(b) = C(b) - 1\n }\n }\n }\n }\n\n out.println(ans)\n }\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next().toInt\n def nextLong(): Long = next().toLong\n def nextChar(): Char = next().charAt(0)\n }\n val sc = new InputReader(System.in)\n def ni(): Int = sc.nextInt()\n def nl(): Long = sc.nextLong()\n def nc(): Char = sc.nextChar()\n def ns(): String = sc.next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n\n def cumSum(as: Array[Int]) = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nTakahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i.\nHe would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2.\nNote that a ball cannot belong to multiple pairs.\nFind the maximum possible number of pairs that can be formed.\n\nHere, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nA_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible number of pairs such that the sum of the integers written on each pair of balls is a power of 2.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n1\n\nWe can form one pair whose sum of the written numbers is 4 by pairing the first and third balls.\nNote that we cannot pair the second ball with itself.\n\nSample Input 2\n\n5\n3 11 14 5 13\n\nSample Output 2\n\n2", "sample_input": "3\n1 2 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03201", "source_text": "Score : 600 points\n\nProblem Statement\n\nTakahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i.\nHe would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2.\nNote that a ball cannot belong to multiple pairs.\nFind the maximum possible number of pairs that can be formed.\n\nHere, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nA_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible number of pairs such that the sum of the integers written on each pair of balls is a power of 2.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n1\n\nWe can form one pair whose sum of the written numbers is 4 by pairing the first and third balls.\nNote that we cannot pair the second ball with itself.\n\nSample Input 2\n\n5\n3 11 14 5 13\n\nSample Output 2\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3096, "cpu_time_ms": 1105, "memory_kb": 96864}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s711821494", "group_id": "codeNet:p03207", "input_text": "object Main {\n val sc = new java.util.Scanner(System.in)\n\n def sin(n: Int): Seq[Int] = Seq.fill(n)(sc.nextInt())\n\n def main(args: Array[String]): Unit = {\n val n = sc.nextInt()\n val p = sin(n)\n println(p.sum - p.max / 2)\n }\n}", "language": "Scala", "metadata": {"date": 1569077855, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03207.html", "problem_id": "p03207", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03207/input.txt", "sample_output_relpath": "derived/input_output/data/p03207/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03207/Scala/s711821494.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s711821494", "user_id": "u526532903"}, "prompt_components": {"gold_output": "15950\n", "input_to_evaluate": "object Main {\n val sc = new java.util.Scanner(System.in)\n\n def sin(n: Int): Seq[Int] = Seq.fill(n)(sc.nextInt())\n\n def main(args: Array[String]): Unit = {\n val n = sc.nextInt()\n val p = sin(n)\n println(p.sum - p.max / 2)\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIn some other world, today is the day before Christmas Eve.\n\nMr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \\leq i \\leq N) is p_i yen (the currency of Japan).\n\nHe has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?\n\nConstraints\n\n2 \\leq N \\leq 10\n\n100 \\leq p_i \\leq 10000\n\np_i is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1\np_2\n:\np_N\n\nOutput\n\nPrint the total amount Mr. Takaha will pay.\n\nSample Input 1\n\n3\n4980\n7980\n6980\n\nSample Output 1\n\n15950\n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 = 15950 yen.\n\nNote that outputs such as 15950.0 will be judged as Wrong Answer.\n\nSample Input 2\n\n4\n4320\n4320\n4320\n4320\n\nSample Output 2\n\n15120\n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320 + 4320 + 4320 = 15120 yen.", "sample_input": "3\n4980\n7980\n6980\n"}, "reference_outputs": ["15950\n"], "source_document_id": "p03207", "source_text": "Score : 200 points\n\nProblem Statement\n\nIn some other world, today is the day before Christmas Eve.\n\nMr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \\leq i \\leq N) is p_i yen (the currency of Japan).\n\nHe has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?\n\nConstraints\n\n2 \\leq N \\leq 10\n\n100 \\leq p_i \\leq 10000\n\np_i is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1\np_2\n:\np_N\n\nOutput\n\nPrint the total amount Mr. Takaha will pay.\n\nSample Input 1\n\n3\n4980\n7980\n6980\n\nSample Output 1\n\n15950\n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 = 15950 yen.\n\nNote that outputs such as 15950.0 will be judged as Wrong Answer.\n\nSample Input 2\n\n4\n4320\n4320\n4320\n4320\n\nSample Output 2\n\n15120\n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320 + 4320 + 4320 = 15120 yen.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 345, "memory_kb": 27332}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s165120636", "group_id": "codeNet:p03207", "input_text": "//import java.util.Scanner\n\nimport scala.collection.Searching._\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.immutable._\nimport scala.io.StdIn.readLine\n\nimport java.io._\nimport java.nio.file.{Files, Path}\nimport java.util.StringTokenizer\nimport java.util.Calendar\n\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(Files.newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext = current.hasNext\n\n @inline def next() = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close() = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(new Node(None, 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) => {\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n }\n}\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val A = Array.fill(sc.nextInt())(sc.nextLong())\n println(A.sum - A.max / 2)\n }\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def calc(N: Long, R: Long, M: Long): Double = {\n math.sqrt(R * R - (R * 2 * ((M * 1.0 / N) - 0.5)) * (R * 2 * ((M * 1.0 / N) - 0.5))) * 2\n }\n\n def recursive(S: Long, N: Long, check3: Boolean, check5: Boolean, check7: Boolean): Long = {\n if (S > N) (0) else {\n (if (check3 && check5 && check7) (1) else (0)) +\n recursive(S * 10 + 3, N, true, check5, check7) +\n recursive(S * 10 + 5, N, check3, true, check7) +\n recursive(S * 10 + 7, N, check3, check5, true)\n }\n }\n\n def check(s: String): Boolean = {\n if (s == \"0\") (true) else (s(0) != '0' && 0 <= s.toInt && s.toInt <= 255)\n }\n\n def shift(n: Long): Long = {\n if (n == 0) (0) else if (n == 1) (1) else (shift(n - 1) << 1)\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) (0) else (unShift(n >> 1) + 1)\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList(): Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: (Int) =?> String = {\n case src if (src >= 1 && src <= 3999) => {\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if (n == 0) => cont + unitChar\n case n if (n > 0) => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n }\n\n val romanToArabic: (String) =?> Int = {\n case src if (Option(src).exists { s => {\n s.nonEmpty && (\"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase) == None)\n }\n }) => {\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1544757301, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03207.html", "problem_id": "p03207", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03207/input.txt", "sample_output_relpath": "derived/input_output/data/p03207/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03207/Scala/s165120636.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s165120636", "user_id": "u779353743"}, "prompt_components": {"gold_output": "15950\n", "input_to_evaluate": "//import java.util.Scanner\n\nimport scala.collection.Searching._\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.immutable._\nimport scala.io.StdIn.readLine\n\nimport java.io._\nimport java.nio.file.{Files, Path}\nimport java.util.StringTokenizer\nimport java.util.Calendar\n\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(Files.newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext = current.hasNext\n\n @inline def next() = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close() = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(new Node(None, 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) => {\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n }\n}\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val A = Array.fill(sc.nextInt())(sc.nextLong())\n println(A.sum - A.max / 2)\n }\n\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def calc(N: Long, R: Long, M: Long): Double = {\n math.sqrt(R * R - (R * 2 * ((M * 1.0 / N) - 0.5)) * (R * 2 * ((M * 1.0 / N) - 0.5))) * 2\n }\n\n def recursive(S: Long, N: Long, check3: Boolean, check5: Boolean, check7: Boolean): Long = {\n if (S > N) (0) else {\n (if (check3 && check5 && check7) (1) else (0)) +\n recursive(S * 10 + 3, N, true, check5, check7) +\n recursive(S * 10 + 5, N, check3, true, check7) +\n recursive(S * 10 + 7, N, check3, check5, true)\n }\n }\n\n def check(s: String): Boolean = {\n if (s == \"0\") (true) else (s(0) != '0' && 0 <= s.toInt && s.toInt <= 255)\n }\n\n def shift(n: Long): Long = {\n if (n == 0) (0) else if (n == 1) (1) else (shift(n - 1) << 1)\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) (0) else (unShift(n >> 1) + 1)\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList(): Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: (Int) =?> String = {\n case src if (src >= 1 && src <= 3999) => {\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if (n == 0) => cont + unitChar\n case n if (n > 0) => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n }\n\n val romanToArabic: (String) =?> Int = {\n case src if (Option(src).exists { s => {\n s.nonEmpty && (\"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase) == None)\n }\n }) => {\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIn some other world, today is the day before Christmas Eve.\n\nMr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \\leq i \\leq N) is p_i yen (the currency of Japan).\n\nHe has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?\n\nConstraints\n\n2 \\leq N \\leq 10\n\n100 \\leq p_i \\leq 10000\n\np_i is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1\np_2\n:\np_N\n\nOutput\n\nPrint the total amount Mr. Takaha will pay.\n\nSample Input 1\n\n3\n4980\n7980\n6980\n\nSample Output 1\n\n15950\n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 = 15950 yen.\n\nNote that outputs such as 15950.0 will be judged as Wrong Answer.\n\nSample Input 2\n\n4\n4320\n4320\n4320\n4320\n\nSample Output 2\n\n15120\n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320 + 4320 + 4320 = 15120 yen.", "sample_input": "3\n4980\n7980\n6980\n"}, "reference_outputs": ["15950\n"], "source_document_id": "p03207", "source_text": "Score : 200 points\n\nProblem Statement\n\nIn some other world, today is the day before Christmas Eve.\n\nMr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \\leq i \\leq N) is p_i yen (the currency of Japan).\n\nHe has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?\n\nConstraints\n\n2 \\leq N \\leq 10\n\n100 \\leq p_i \\leq 10000\n\np_i is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1\np_2\n:\np_N\n\nOutput\n\nPrint the total amount Mr. Takaha will pay.\n\nSample Input 1\n\n3\n4980\n7980\n6980\n\nSample Output 1\n\n15950\n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 = 15950 yen.\n\nNote that outputs such as 15950.0 will be judged as Wrong Answer.\n\nSample Input 2\n\n4\n4320\n4320\n4320\n4320\n\nSample Output 2\n\n15120\n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320 + 4320 + 4320 = 15120 yen.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6315, "cpu_time_ms": 335, "memory_kb": 27212}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s169096174", "group_id": "codeNet:p03208", "input_text": "object Main extends App {\n val Array(n, k) = io.StdIn.readLine.split(\" \").map(_.toInt)\n val hs = for (_ <- 1 to n) yield io.StdIn.readInt\n\n val sorted = hs.sorted\n val tree_sets = sorted.sliding(2)\n val diffs = tree_sets.map(t => t.last-t.head)\n val result = diffs.min\n println(result)\n}", "language": "Scala", "metadata": {"date": 1593416235, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s169096174.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s169096174", "user_id": "u104354966"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n val Array(n, k) = io.StdIn.readLine.split(\" \").map(_.toInt)\n val hs = for (_ <- 1 to n) yield io.StdIn.readInt\n\n val sorted = hs.sorted\n val tree_sets = sorted.sliding(2)\n val diffs = tree_sets.map(t => t.last-t.head)\n val result = diffs.min\n println(result)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 308, "cpu_time_ms": 1109, "memory_kb": 68476}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s638383005", "group_id": "codeNet:p03208", "input_text": "object Main extends App {\n val Array(n, k) = io.StdIn.readLine.split(\" \").map(_.toInt)\n val hs = for (_ <- 1 to n) yield io.StdIn.readInt\n\n val sorted = hs.sorted\n val tree_sets = sorted.sliding(k)\n val diffs = tree_sets.map(t => t.max-t.min)\n val result = diffs.min\n println(result)\n}", "language": "Scala", "metadata": {"date": 1593415854, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s638383005.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s638383005", "user_id": "u104354966"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n val Array(n, k) = io.StdIn.readLine.split(\" \").map(_.toInt)\n val hs = for (_ <- 1 to n) yield io.StdIn.readInt\n\n val sorted = hs.sorted\n val tree_sets = sorted.sliding(k)\n val diffs = tree_sets.map(t => t.max-t.min)\n val result = diffs.min\n println(result)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2205, "memory_kb": 64664}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s818836814", "group_id": "codeNet:p03208", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val factors = scala.io.StdIn.readLine.split(\" \").map{_.toInt}\n var tree_heights = Vector[Int]()\n\n for(i <- 0 until factors(0)) {\n tree_heights = scala.io.StdIn.readInt +: tree_heights\n }\n\n val sorted_tree_heights = tree_heights.sorted\n\n var min_diff = 1000000000\n for(i <- 0 until (factors(0) - factors(1) + 1)) {\n val diff = sorted_tree_heights(i + factors(1) - 1) - sorted_tree_heights(i)\n if (diff < min_diff) min_diff = diff\n }\n println(min_diff)\n }\n}", "language": "Scala", "metadata": {"date": 1569435265, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s818836814.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s818836814", "user_id": "u888177577"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val factors = scala.io.StdIn.readLine.split(\" \").map{_.toInt}\n var tree_heights = Vector[Int]()\n\n for(i <- 0 until factors(0)) {\n tree_heights = scala.io.StdIn.readInt +: tree_heights\n }\n\n val sorted_tree_heights = tree_heights.sorted\n\n var min_diff = 1000000000\n for(i <- 0 until (factors(0) - factors(1) + 1)) {\n val diff = sorted_tree_heights(i + factors(1) - 1) - sorted_tree_heights(i)\n if (diff < min_diff) min_diff = diff\n }\n println(min_diff)\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn some other world, today is Christmas Eve.\n\nThere are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \\leq i \\leq N) is h_i meters.\n\nHe decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.\n\nMore specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?\n\nConstraints\n\n2 \\leq K < N \\leq 10^5\n\n1 \\leq h_i \\leq 10^9\n\nh_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum possible value of h_{max} - h_{min}.\n\nSample Input 1\n\n5 3\n10\n15\n11\n14\n12\n\nSample Output 1\n\n2\n\nIf we decorate the first, third and fifth trees, h_{max} = 12, h_{min} = 10 so h_{max} - h_{min} = 2. This is optimal.\n\nSample Input 2\n\n5 3\n5\n7\n5\n7\n7\n\nSample Output 2\n\n0\n\nIf we decorate the second, fourth and fifth trees, h_{max} = 7, h_{min} = 7 so h_{max} - h_{min} = 0. This is optimal.\n\nThere are not too many trees in these sample inputs, but note that there can be at most one hundred thousand trees (we just can't put a sample with a hundred thousand lines here).", "sample_input": "5 3\n10\n15\n11\n14\n12\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03208", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn some other world, today is Christmas Eve.\n\nThere are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \\leq i \\leq N) is h_i meters.\n\nHe decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.\n\nMore specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?\n\nConstraints\n\n2 \\leq K < N \\leq 10^5\n\n1 \\leq h_i \\leq 10^9\n\nh_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum possible value of h_{max} - h_{min}.\n\nSample Input 1\n\n5 3\n10\n15\n11\n14\n12\n\nSample Output 1\n\n2\n\nIf we decorate the first, third and fifth trees, h_{max} = 12, h_{min} = 10 so h_{max} - h_{min} = 2. This is optimal.\n\nSample Input 2\n\n5 3\n5\n7\n5\n7\n7\n\nSample Output 2\n\n0\n\nIf we decorate the second, fourth and fifth trees, h_{max} = 7, h_{min} = 7 so h_{max} - h_{min} = 0. This is optimal.\n\nThere are not too many trees in these sample inputs, but note that there can be at most one hundred thousand trees (we just can't put a sample with a hundred thousand lines here).", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 789, "memory_kb": 46972}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s013818660", "group_id": "codeNet:p03208", "input_text": "\nobject Main extends App {\n\n import scala.io.StdIn._\n import scala.math._\n\n val Array(n, k) = readLine.trim.split(' ').map(_.toInt)\n val heights = Array.tabulate(n){_ ⇒ readLine.trim.toInt}.sorted\n println(\n (0 to (n - k)).map{it ⇒ heights(it + k - 1) - heights(it)}.min\n )\n\n implicit class Extenion[T](val value :T){\n def also(func: T ⇒ Unit): T = {\n func(value)\n value\n }\n def let[R](func: T ⇒ R): R = func(value)\n }\n}", "language": "Scala", "metadata": {"date": 1544321738, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s013818660.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s013818660", "user_id": "u419330815"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "\nobject Main extends App {\n\n import scala.io.StdIn._\n import scala.math._\n\n val Array(n, k) = readLine.trim.split(' ').map(_.toInt)\n val heights = Array.tabulate(n){_ ⇒ readLine.trim.toInt}.sorted\n println(\n (0 to (n - k)).map{it ⇒ heights(it + k - 1) - heights(it)}.min\n )\n\n implicit class Extenion[T](val value :T){\n def also(func: T ⇒ Unit): T = {\n func(value)\n value\n }\n def let[R](func: T ⇒ R): R = func(value)\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn some other world, today is Christmas Eve.\n\nThere are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \\leq i \\leq N) is h_i meters.\n\nHe decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.\n\nMore specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?\n\nConstraints\n\n2 \\leq K < N \\leq 10^5\n\n1 \\leq h_i \\leq 10^9\n\nh_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum possible value of h_{max} - h_{min}.\n\nSample Input 1\n\n5 3\n10\n15\n11\n14\n12\n\nSample Output 1\n\n2\n\nIf we decorate the first, third and fifth trees, h_{max} = 12, h_{min} = 10 so h_{max} - h_{min} = 2. This is optimal.\n\nSample Input 2\n\n5 3\n5\n7\n5\n7\n7\n\nSample Output 2\n\n0\n\nIf we decorate the second, fourth and fifth trees, h_{max} = 7, h_{min} = 7 so h_{max} - h_{min} = 0. This is optimal.\n\nThere are not too many trees in these sample inputs, but note that there can be at most one hundred thousand trees (we just can't put a sample with a hundred thousand lines here).", "sample_input": "5 3\n10\n15\n11\n14\n12\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03208", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn some other world, today is Christmas Eve.\n\nThere are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \\leq i \\leq N) is h_i meters.\n\nHe decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.\n\nMore specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?\n\nConstraints\n\n2 \\leq K < N \\leq 10^5\n\n1 \\leq h_i \\leq 10^9\n\nh_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum possible value of h_{max} - h_{min}.\n\nSample Input 1\n\n5 3\n10\n15\n11\n14\n12\n\nSample Output 1\n\n2\n\nIf we decorate the first, third and fifth trees, h_{max} = 12, h_{min} = 10 so h_{max} - h_{min} = 2. This is optimal.\n\nSample Input 2\n\n5 3\n5\n7\n5\n7\n7\n\nSample Output 2\n\n0\n\nIf we decorate the second, fourth and fifth trees, h_{max} = 7, h_{min} = 7 so h_{max} - h_{min} = 0. This is optimal.\n\nThere are not too many trees in these sample inputs, but note that there can be at most one hundred thousand trees (we just can't put a sample with a hundred thousand lines here).", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 744, "memory_kb": 38720}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s406883589", "group_id": "codeNet:p03209", "input_text": "import scala.io.StdIn.readLine\n\nobject Main{\n def solve(n : Int, x : Long): Long ={\n if(n == 0) x\n else{\n val hSize : Long = (1.toLong << (n + 1)) - 3\n val ps : Long = (1.toLong << n) - 1\n if(x == 0) 0\n else if(x == hSize + 2) ps + 1\n else if(x == 2 * hSize + 3) 2 * ps + 1\n else if(x > hSize + 2) ps + 1 + solve(n - 1, x - hSize - 2)\n else solve(n - 1, x - 1)\n }\n }\n\n def main(args : Array[String]): Unit ={\n val Array(n, x) = readLine().split(' ')\n println(solve(n.toInt, x.toLong))\n }\n}\n", "language": "Scala", "metadata": {"date": 1544401092, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s406883589.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s406883589", "user_id": "u394853232"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main{\n def solve(n : Int, x : Long): Long ={\n if(n == 0) x\n else{\n val hSize : Long = (1.toLong << (n + 1)) - 3\n val ps : Long = (1.toLong << n) - 1\n if(x == 0) 0\n else if(x == hSize + 2) ps + 1\n else if(x == 2 * hSize + 3) 2 * ps + 1\n else if(x > hSize + 2) ps + 1 + solve(n - 1, x - hSize - 2)\n else solve(n - 1, x - 1)\n }\n }\n\n def main(args : Array[String]): Unit ={\n val Array(n, x) = readLine().split(' ')\n println(solve(n.toInt, x.toLong))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 328, "memory_kb": 25428}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s552334331", "group_id": "codeNet:p03215", "input_text": "object Main extends App {\n val input = io.Source.stdin.getLines.toIndexedSeq.map(_.split(' ').map(_.toInt).toIndexedSeq)\n val K = input(0)(1)\n //println(K)\n val in = input(1)\n //println(in)\n\n var sums=Seq[Long]()\n (0 until in.size).foreach{ i =>\n (i until in.size).foreach{ j =>\n val sub = (i to j).map(k => in(k).toLong).sum\n sums +:= sub\n } \n }\n //println(sums)\n val rs = sums.sorted.reverse\n //println(rs)\n val tk = rs.take(K)\n val and = tk.foldLeft(-1L){ (a,e)=>\n a & e\n }\n println(and)\n}\n", "language": "Scala", "metadata": {"date": 1543112186, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03215.html", "problem_id": "p03215", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03215/input.txt", "sample_output_relpath": "derived/input_output/data/p03215/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03215/Scala/s552334331.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s552334331", "user_id": "u699236457"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "object Main extends App {\n val input = io.Source.stdin.getLines.toIndexedSeq.map(_.split(' ').map(_.toInt).toIndexedSeq)\n val K = input(0)(1)\n //println(K)\n val in = input(1)\n //println(in)\n\n var sums=Seq[Long]()\n (0 until in.size).foreach{ i =>\n (i until in.size).foreach{ j =>\n val sub = (i to j).map(k => in(k).toLong).sum\n sums +:= sub\n } \n }\n //println(sums)\n val rs = sums.sorted.reverse\n //println(rs)\n val tk = rs.take(K)\n val and = tk.foldLeft(-1L){ (a,e)=>\n a & e\n }\n println(and)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nOne day, Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N.\nHe is interested in properties of the sequence a.\n\nFor a nonempty contiguous subsequence a_l, ..., a_r (1 \\leq l \\leq r \\leq N) of the sequence a, its beauty is defined as a_l + ... + a_r. Niwango-kun wants to know the maximum possible value of the bitwise AND of the beauties of K nonempty contiguous subsequences among all N(N+1)/2 nonempty contiguous subsequences. (Subsequences may share elements.)\n\nFind the maximum possible value for him.\n\nConstraints\n\n2 \\leq N \\leq 1000\n\n1 \\leq a_i \\leq 10^9\n\n1 \\leq K \\leq N(N+1)/2\n\nAll numbers given in input 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 answer.\n\nSample Input 1\n\n4 2\n2 5 2 5\n\nSample Output 1\n\n12\n\nThere are 10 nonempty contiguous subsequences of a. Let us enumerate them:\n\ncontiguous subsequences starting from the first element: \\{2\\}, \\{2, 5\\}, \\{2, 5, 2\\}, \\{2, 5, 2, 5\\}\n\ncontiguous subsequences starting from the second element: \\{5\\}, \\{5, 2\\}, \\{5, 2, 5\\}\n\ncontiguous subsequences starting from the third element: \\{2\\}, \\{2, 5\\}\n\ncontiguous subsequences starting from the fourth element: \\{5\\}\n\n(Note that even if the elements of subsequences are equal, subsequences that have different starting indices are considered to be different.)\n\nThe maximum possible bitwise AND of the beauties of two different contiguous subsequences is 12.\nThis can be achieved by choosing \\{5, 2, 5\\} (with beauty 12) and \\{2, 5, 2, 5\\} (with beauty 14).\n\nSample Input 2\n\n8 4\n9 1 8 2 7 5 6 4\n\nSample Output 2\n\n32", "sample_input": "4 2\n2 5 2 5\n"}, "reference_outputs": ["12\n"], "source_document_id": "p03215", "source_text": "Score : 400 points\n\nProblem Statement\n\nOne day, Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N.\nHe is interested in properties of the sequence a.\n\nFor a nonempty contiguous subsequence a_l, ..., a_r (1 \\leq l \\leq r \\leq N) of the sequence a, its beauty is defined as a_l + ... + a_r. Niwango-kun wants to know the maximum possible value of the bitwise AND of the beauties of K nonempty contiguous subsequences among all N(N+1)/2 nonempty contiguous subsequences. (Subsequences may share elements.)\n\nFind the maximum possible value for him.\n\nConstraints\n\n2 \\leq N \\leq 1000\n\n1 \\leq a_i \\leq 10^9\n\n1 \\leq K \\leq N(N+1)/2\n\nAll numbers given in input 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 answer.\n\nSample Input 1\n\n4 2\n2 5 2 5\n\nSample Output 1\n\n12\n\nThere are 10 nonempty contiguous subsequences of a. Let us enumerate them:\n\ncontiguous subsequences starting from the first element: \\{2\\}, \\{2, 5\\}, \\{2, 5, 2\\}, \\{2, 5, 2, 5\\}\n\ncontiguous subsequences starting from the second element: \\{5\\}, \\{5, 2\\}, \\{5, 2, 5\\}\n\ncontiguous subsequences starting from the third element: \\{2\\}, \\{2, 5\\}\n\ncontiguous subsequences starting from the fourth element: \\{5\\}\n\n(Note that even if the elements of subsequences are equal, subsequences that have different starting indices are considered to be different.)\n\nThe maximum possible bitwise AND of the beauties of two different contiguous subsequences is 12.\nThis can be achieved by choosing \\{5, 2, 5\\} (with beauty 12) and \\{2, 5, 2, 5\\} (with beauty 14).\n\nSample Input 2\n\n8 4\n9 1 8 2 7 5 6 4\n\nSample Output 2\n\n32", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 540, "cpu_time_ms": 2663, "memory_kb": 127488}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s336996981", "group_id": "codeNet:p03219", "input_text": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val X, Y = in.nextInt\n println(X + Y / 2)\n}", "language": "Scala", "metadata": {"date": 1589314043, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03219.html", "problem_id": "p03219", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03219/input.txt", "sample_output_relpath": "derived/input_output/data/p03219/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03219/Scala/s336996981.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s336996981", "user_id": "u132324749"}, "prompt_components": {"gold_output": "110\n", "input_to_evaluate": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val X, Y = in.nextInt\n println(X + Y / 2)\n}", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThere is a train going from Station A to Station B that costs X yen (the currency of Japan).\n\nAlso, there is a bus going from Station B to Station C that costs Y yen.\n\nJoisino got a special ticket. With this ticket, she can take the bus for half the fare if she travels from Station A to Station B by train and then travels from Station B to Station C by bus.\n\nHow much does it cost to travel from Station A to Station C if she uses this ticket?\n\nConstraints\n\n1 \\leq X,Y \\leq 100\n\nY is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf it costs x yen to travel from Station A to Station C, print x.\n\nSample Input 1\n\n81 58\n\nSample Output 1\n\n110\n\nThe train fare is 81 yen.\n\nThe train fare is 58 ⁄ 2=29 yen with the 50% discount.\n\nThus, it costs 110 yen to travel from Station A to Station C.\n\nSample Input 2\n\n4 54\n\nSample Output 2\n\n31", "sample_input": "81 58\n"}, "reference_outputs": ["110\n"], "source_document_id": "p03219", "source_text": "Score: 100 points\n\nProblem Statement\n\nThere is a train going from Station A to Station B that costs X yen (the currency of Japan).\n\nAlso, there is a bus going from Station B to Station C that costs Y yen.\n\nJoisino got a special ticket. With this ticket, she can take the bus for half the fare if she travels from Station A to Station B by train and then travels from Station B to Station C by bus.\n\nHow much does it cost to travel from Station A to Station C if she uses this ticket?\n\nConstraints\n\n1 \\leq X,Y \\leq 100\n\nY is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf it costs x yen to travel from Station A to Station C, print x.\n\nSample Input 1\n\n81 58\n\nSample Output 1\n\n110\n\nThe train fare is 81 yen.\n\nThe train fare is 58 ⁄ 2=29 yen with the 50% discount.\n\nThus, it costs 110 yen to travel from Station A to Station C.\n\nSample Input 2\n\n4 54\n\nSample Output 2\n\n31", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 339, "memory_kb": 25528}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s305651310", "group_id": "codeNet:p03219", "input_text": "import scala.io.StdIn\n\nobject Main {\n def main(args: Array[String]) = {\n val num = StdIn.readLine.split(\" \").toList.map(_.toInt)\n val X = num(0)\n val Y = num(1)\n\n println(X + Y / 2)\n\n }\n}\n", "language": "Scala", "metadata": {"date": 1546638661, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03219.html", "problem_id": "p03219", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03219/input.txt", "sample_output_relpath": "derived/input_output/data/p03219/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03219/Scala/s305651310.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s305651310", "user_id": "u829407811"}, "prompt_components": {"gold_output": "110\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main {\n def main(args: Array[String]) = {\n val num = StdIn.readLine.split(\" \").toList.map(_.toInt)\n val X = num(0)\n val Y = num(1)\n\n println(X + Y / 2)\n\n }\n}\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThere is a train going from Station A to Station B that costs X yen (the currency of Japan).\n\nAlso, there is a bus going from Station B to Station C that costs Y yen.\n\nJoisino got a special ticket. With this ticket, she can take the bus for half the fare if she travels from Station A to Station B by train and then travels from Station B to Station C by bus.\n\nHow much does it cost to travel from Station A to Station C if she uses this ticket?\n\nConstraints\n\n1 \\leq X,Y \\leq 100\n\nY is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf it costs x yen to travel from Station A to Station C, print x.\n\nSample Input 1\n\n81 58\n\nSample Output 1\n\n110\n\nThe train fare is 81 yen.\n\nThe train fare is 58 ⁄ 2=29 yen with the 50% discount.\n\nThus, it costs 110 yen to travel from Station A to Station C.\n\nSample Input 2\n\n4 54\n\nSample Output 2\n\n31", "sample_input": "81 58\n"}, "reference_outputs": ["110\n"], "source_document_id": "p03219", "source_text": "Score: 100 points\n\nProblem Statement\n\nThere is a train going from Station A to Station B that costs X yen (the currency of Japan).\n\nAlso, there is a bus going from Station B to Station C that costs Y yen.\n\nJoisino got a special ticket. With this ticket, she can take the bus for half the fare if she travels from Station A to Station B by train and then travels from Station B to Station C by bus.\n\nHow much does it cost to travel from Station A to Station C if she uses this ticket?\n\nConstraints\n\n1 \\leq X,Y \\leq 100\n\nY is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf it costs x yen to travel from Station A to Station C, print x.\n\nSample Input 1\n\n81 58\n\nSample Output 1\n\n110\n\nThe train fare is 81 yen.\n\nThe train fare is 58 ⁄ 2=29 yen with the 50% discount.\n\nThus, it costs 110 yen to travel from Station A to Station C.\n\nSample Input 2\n\n4 54\n\nSample Output 2\n\n31", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 324, "memory_kb": 25408}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s616295509", "group_id": "codeNet:p03220", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val candidate_num = scala.io.StdIn.readInt\n val temperatures = scala.io.StdIn.readLine.split(\" \").map{_.toInt}\n val candidate = scala.io.StdIn.readLine.split(\" \").map{_.toInt}\n var diff_min = 100000.0\n var dicision_num = 0\n\n for(i <- 0 until candidate.length) {\n val diff = Math.abs(temperatures(1) - (temperatures(0) - 0.006*candidate(i)))\n if (diff_min > diff) {\n diff_min = diff\n dicision_num = i + 1\n }\n }\n println(dicision_num)\n }\n}", "language": "Scala", "metadata": {"date": 1569211194, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03220.html", "problem_id": "p03220", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03220/input.txt", "sample_output_relpath": "derived/input_output/data/p03220/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03220/Scala/s616295509.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s616295509", "user_id": "u888177577"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val candidate_num = scala.io.StdIn.readInt\n val temperatures = scala.io.StdIn.readLine.split(\" \").map{_.toInt}\n val candidate = scala.io.StdIn.readLine.split(\" \").map{_.toInt}\n var diff_min = 100000.0\n var dicision_num = 0\n\n for(i <- 0 until candidate.length) {\n val diff = Math.abs(temperatures(1) - (temperatures(0) - 0.006*candidate(i)))\n if (diff_min > diff) {\n diff_min = diff\n dicision_num = i + 1\n }\n }\n println(dicision_num)\n }\n}", "problem_context": "Score: 200 points\n\nProblem Statement\n\nA country decides to build a palace.\n\nIn this country, the average temperature of a point at an elevation of x meters is T-x \\times 0.006 degrees Celsius.\n\nThere are N places proposed for the place. The elevation of Place i is H_i meters.\n\nAmong them, Princess Joisino orders you to select the place whose average temperature is the closest to A degrees Celsius, and build the palace there.\n\nPrint the index of the place where the palace should be built.\n\nIt is guaranteed that the solution is unique.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n0 \\leq T \\leq 50\n\n-60 \\leq A \\leq T\n\n0 \\leq H_i \\leq 10^5\n\nAll values in input are integers.\n\nThe solution is unique.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nT A\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the index of the place where the palace should be built.\n\nSample Input 1\n\n2\n12 5\n1000 2000\n\nSample Output 1\n\n1\n\nThe average temperature of Place 1 is 12-1000 \\times 0.006=6 degrees Celsius.\n\nThe average temperature of Place 2 is 12-2000 \\times 0.006=0 degrees Celsius.\n\nThus, the palace should be built at Place 1.\n\nSample Input 2\n\n3\n21 -11\n81234 94124 52141\n\nSample Output 2\n\n3", "sample_input": "2\n12 5\n1000 2000\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03220", "source_text": "Score: 200 points\n\nProblem Statement\n\nA country decides to build a palace.\n\nIn this country, the average temperature of a point at an elevation of x meters is T-x \\times 0.006 degrees Celsius.\n\nThere are N places proposed for the place. The elevation of Place i is H_i meters.\n\nAmong them, Princess Joisino orders you to select the place whose average temperature is the closest to A degrees Celsius, and build the palace there.\n\nPrint the index of the place where the palace should be built.\n\nIt is guaranteed that the solution is unique.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n0 \\leq T \\leq 50\n\n-60 \\leq A \\leq T\n\n0 \\leq H_i \\leq 10^5\n\nAll values in input are integers.\n\nThe solution is unique.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nT A\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the index of the place where the palace should be built.\n\nSample Input 1\n\n2\n12 5\n1000 2000\n\nSample Output 1\n\n1\n\nThe average temperature of Place 1 is 12-1000 \\times 0.006=6 degrees Celsius.\n\nThe average temperature of Place 2 is 12-2000 \\times 0.006=0 degrees Celsius.\n\nThus, the palace should be built at Place 1.\n\nSample Input 2\n\n3\n21 -11\n81234 94124 52141\n\nSample Output 2\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 563, "cpu_time_ms": 335, "memory_kb": 25292}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s997739418", "group_id": "codeNet:p03220", "input_text": "object Main {\n def main(args:Array[String]):Unit={\n var N = readLine.toInt\n var TA = readLine.split(\" \")\n var H = readLine.split(\" \")\n var res = -1\n var min = scala.Int.MaxValue.toDouble\n for(i <- 0 until N){\n var temp = TA(0).toInt-H(i).toInt*0.006\n var diff = scala.math.abs(TA(1).toInt-temp.toDouble)\n if(diff math.abs(t - z*0.006 - a)}\n \n\tprintln(h.indexOf(h.min) + 1)\n}", "language": "Scala", "metadata": {"date": 1542386660, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03220.html", "problem_id": "p03220", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03220/input.txt", "sample_output_relpath": "derived/input_output/data/p03220/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03220/Scala/s887601493.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s887601493", "user_id": "u675876401"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main extends App {\n\tval n = scala.io.StdIn.readInt\n\tval Array(t, a) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\tval h = scala.io.StdIn.readLine.split(\" \").map(_.toDouble).map{z => math.abs(t - z*0.006 - a)}\n \n\tprintln(h.indexOf(h.min) + 1)\n}", "problem_context": "Score: 200 points\n\nProblem Statement\n\nA country decides to build a palace.\n\nIn this country, the average temperature of a point at an elevation of x meters is T-x \\times 0.006 degrees Celsius.\n\nThere are N places proposed for the place. The elevation of Place i is H_i meters.\n\nAmong them, Princess Joisino orders you to select the place whose average temperature is the closest to A degrees Celsius, and build the palace there.\n\nPrint the index of the place where the palace should be built.\n\nIt is guaranteed that the solution is unique.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n0 \\leq T \\leq 50\n\n-60 \\leq A \\leq T\n\n0 \\leq H_i \\leq 10^5\n\nAll values in input are integers.\n\nThe solution is unique.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nT A\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the index of the place where the palace should be built.\n\nSample Input 1\n\n2\n12 5\n1000 2000\n\nSample Output 1\n\n1\n\nThe average temperature of Place 1 is 12-1000 \\times 0.006=6 degrees Celsius.\n\nThe average temperature of Place 2 is 12-2000 \\times 0.006=0 degrees Celsius.\n\nThus, the palace should be built at Place 1.\n\nSample Input 2\n\n3\n21 -11\n81234 94124 52141\n\nSample Output 2\n\n3", "sample_input": "2\n12 5\n1000 2000\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03220", "source_text": "Score: 200 points\n\nProblem Statement\n\nA country decides to build a palace.\n\nIn this country, the average temperature of a point at an elevation of x meters is T-x \\times 0.006 degrees Celsius.\n\nThere are N places proposed for the place. The elevation of Place i is H_i meters.\n\nAmong them, Princess Joisino orders you to select the place whose average temperature is the closest to A degrees Celsius, and build the palace there.\n\nPrint the index of the place where the palace should be built.\n\nIt is guaranteed that the solution is unique.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n0 \\leq T \\leq 50\n\n-60 \\leq A \\leq T\n\n0 \\leq H_i \\leq 10^5\n\nAll values in input are integers.\n\nThe solution is unique.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nT A\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the index of the place where the palace should be built.\n\nSample Input 1\n\n2\n12 5\n1000 2000\n\nSample Output 1\n\n1\n\nThe average temperature of Place 1 is 12-1000 \\times 0.006=6 degrees Celsius.\n\nThe average temperature of Place 2 is 12-2000 \\times 0.006=0 degrees Celsius.\n\nThus, the palace should be built at Place 1.\n\nSample Input 2\n\n3\n21 -11\n81234 94124 52141\n\nSample Output 2\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 255, "cpu_time_ms": 334, "memory_kb": 25408}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s269618659", "group_id": "codeNet:p03221", "input_text": "import scala.io.StdIn._\nimport scala.collection.mutable.{HashMap, ArrayBuffer}\nimport java.io.PrintWriter\nimport java.text.DecimalFormat\nimport java.util.Arrays\nobject Main extends App {\n val f = new DecimalFormat(\"000000\")\n val sr = new StdinReader\n val n, m = sr.nextInt\n val source = (1 to m).map{i => Array(sr.nextInt, sr.nextInt)}\n val map = new HashMap[Int, ArrayBuffer[Int]]\n source.foreach{case Array(p, y) => map.getOrElseUpdate(p, new ArrayBuffer[Int]) += y}\n val newMap = map.mapValues(_.sorted.toArray)\n val w = new PrintWriter(System.out)\n source.foreach {case Array(p, y) =>\n val i = Arrays.binarySearch(newMap(p), y) + 1\n w.print(f.format(p))\n w.println(f.format(i))\n }\n w.flush\n}\n\nclass StdinReader {\n val is = System.in\n val buffer = new Array[Byte](1024 * 1024)\n var size = 0\n var pos = 0\n\n private def readByte: Byte = {\n if (pos >= size) {\n pos = 0;\n size = is.read(buffer);\n }\n if (size < 0) -1\n else {\n val ret = buffer(pos)\n pos += 1\n ret\n }\n }\n\n def nextInt: Int = {\n @scala.annotation.tailrec\n def r(i: Int, reading: Boolean): Int = {\n readByte match {\n case '-' => r(i * -1, true)\n case b if '0' <= b && b <= '9' => r(i * 10 + (b - '0'), true)\n case _ => if (reading) i else r(i, false)\n }\n }\n r(0, false)\n }\n}", "language": "Scala", "metadata": {"date": 1566330298, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s269618659.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s269618659", "user_id": "u132324749"}, "prompt_components": {"gold_output": "000001000002\n000002000001\n000001000001\n", "input_to_evaluate": "import scala.io.StdIn._\nimport scala.collection.mutable.{HashMap, ArrayBuffer}\nimport java.io.PrintWriter\nimport java.text.DecimalFormat\nimport java.util.Arrays\nobject Main extends App {\n val f = new DecimalFormat(\"000000\")\n val sr = new StdinReader\n val n, m = sr.nextInt\n val source = (1 to m).map{i => Array(sr.nextInt, sr.nextInt)}\n val map = new HashMap[Int, ArrayBuffer[Int]]\n source.foreach{case Array(p, y) => map.getOrElseUpdate(p, new ArrayBuffer[Int]) += y}\n val newMap = map.mapValues(_.sorted.toArray)\n val w = new PrintWriter(System.out)\n source.foreach {case Array(p, y) =>\n val i = Arrays.binarySearch(newMap(p), y) + 1\n w.print(f.format(p))\n w.println(f.format(i))\n }\n w.flush\n}\n\nclass StdinReader {\n val is = System.in\n val buffer = new Array[Byte](1024 * 1024)\n var size = 0\n var pos = 0\n\n private def readByte: Byte = {\n if (pos >= size) {\n pos = 0;\n size = is.read(buffer);\n }\n if (size < 0) -1\n else {\n val ret = buffer(pos)\n pos += 1\n ret\n }\n }\n\n def nextInt: Int = {\n @scala.annotation.tailrec\n def r(i: Int, reading: Boolean): Int = {\n readByte match {\n case '-' => r(i * -1, true)\n case b if '0' <= b && b <= '9' => r(i * 10 + (b - '0'), true)\n case _ => if (reading) i else r(i, false)\n }\n }\n r(0, false)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1347, "cpu_time_ms": 2111, "memory_kb": 106540}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s260880752", "group_id": "codeNet:p03221", "input_text": "object Main extends App {\n\tprivate def zeros(yid: String): String = {\n\t\tval len = yid.length\n\t\tif (len == 0) \"000000\"\n\t\telse if (len == 1) \"00000\"\n\t\telse if (len == 2) \"0000\"\n\t\telse if (len == 3) \"000\"\n\t\telse if (len == 4) \"00\"\n\t\telse if (len == 5) \"0\" else \"\"\n\t}\n\n\tprivate def str(n: Long): String = {\n//\t\tval yid = Integer.toString(yindex)\n//\t\tval prey = zeros(yid)\n//\t\tval pid = Integer.toString(pgr)\n//\t\tval prep = zeros(pid)\n//\t\tprep + pid + prey + yid\n\n\t\tjava.lang.Long.toString(1000000000000L + n).substring(0,12)\n\t}\n\n\tprivate def func(lines: Seq[String]) {\n\t\tval line = lines.tail.zipWithIndex.map { case (e, gi) =>\n\t\t\tval tmp = e.split(' ').map(_.toInt).toArray\n\t\t\t(tmp(0), (tmp(1), gi))\n\t\t}\n\t\tval idMap = line.indices.map(_ => -1L).toArray\n\t\tline.groupBy(_._1).foreach { case (pgr, ylist) =>\n\t\t\tylist.toSeq.map(_._2).sortBy(_._1).map(_._2).zipWithIndex.foreach { case (gi, yindex) =>\n\t\t\t\t//val id = \"%06d%06d\".format(pgr, (yindex + 1))\n\t\t\t\t//val id = str(pgr, yindex)\n\t\t\t\t////println(gi, id)\n\t\t\t\t////idMap = idMap + (gi -> id)\n\t\t\t\t//idMap(gi) = id\n\n\t\t\t\tidMap(gi) = pgr * 1000000L + (yindex + 1)\n\t\t\t}\n\t\t}\n\t\tval pw = new java.io.PrintWriter(System.out)\n\t\tidMap.foreach(e => pw.println(str(e)))\n\t\tpw.flush()\n\t}\n\n//\tval start = System.currentTimeMillis()\n//\t//func((0 until 100).map(i => (i % 1) + \" \" + -i))\n//\tfunc((0 until 100000).map(i => (i % 1) + \" \" + i))\n//\tfunc((0 until 100000).map(i => (i % 1) + \" \" + -i))\n//\tfunc((0 until 100000).map(i => -i + \" \" + -i))\n//\tprintln(System.currentTimeMillis() - start)\n\n\tfunc(scala.io.Source.stdin.getLines.toSeq)\n}\n", "language": "Scala", "metadata": {"date": 1542067416, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s260880752.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s260880752", "user_id": "u699236457"}, "prompt_components": {"gold_output": "000001000002\n000002000001\n000001000001\n", "input_to_evaluate": "object Main extends App {\n\tprivate def zeros(yid: String): String = {\n\t\tval len = yid.length\n\t\tif (len == 0) \"000000\"\n\t\telse if (len == 1) \"00000\"\n\t\telse if (len == 2) \"0000\"\n\t\telse if (len == 3) \"000\"\n\t\telse if (len == 4) \"00\"\n\t\telse if (len == 5) \"0\" else \"\"\n\t}\n\n\tprivate def str(n: Long): String = {\n//\t\tval yid = Integer.toString(yindex)\n//\t\tval prey = zeros(yid)\n//\t\tval pid = Integer.toString(pgr)\n//\t\tval prep = zeros(pid)\n//\t\tprep + pid + prey + yid\n\n\t\tjava.lang.Long.toString(1000000000000L + n).substring(0,12)\n\t}\n\n\tprivate def func(lines: Seq[String]) {\n\t\tval line = lines.tail.zipWithIndex.map { case (e, gi) =>\n\t\t\tval tmp = e.split(' ').map(_.toInt).toArray\n\t\t\t(tmp(0), (tmp(1), gi))\n\t\t}\n\t\tval idMap = line.indices.map(_ => -1L).toArray\n\t\tline.groupBy(_._1).foreach { case (pgr, ylist) =>\n\t\t\tylist.toSeq.map(_._2).sortBy(_._1).map(_._2).zipWithIndex.foreach { case (gi, yindex) =>\n\t\t\t\t//val id = \"%06d%06d\".format(pgr, (yindex + 1))\n\t\t\t\t//val id = str(pgr, yindex)\n\t\t\t\t////println(gi, id)\n\t\t\t\t////idMap = idMap + (gi -> id)\n\t\t\t\t//idMap(gi) = id\n\n\t\t\t\tidMap(gi) = pgr * 1000000L + (yindex + 1)\n\t\t\t}\n\t\t}\n\t\tval pw = new java.io.PrintWriter(System.out)\n\t\tidMap.foreach(e => pw.println(str(e)))\n\t\tpw.flush()\n\t}\n\n//\tval start = System.currentTimeMillis()\n//\t//func((0 until 100).map(i => (i % 1) + \" \" + -i))\n//\tfunc((0 until 100000).map(i => (i % 1) + \" \" + i))\n//\tfunc((0 until 100000).map(i => (i % 1) + \" \" + -i))\n//\tfunc((0 until 100000).map(i => -i + \" \" + -i))\n//\tprintln(System.currentTimeMillis() - start)\n\n\tfunc(scala.io.Source.stdin.getLines.toSeq)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1568, "cpu_time_ms": 2119, "memory_kb": 142624}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s194008707", "group_id": "codeNet:p03221", "input_text": "object Main extends App {\n\tprivate def zeros(yid: String): String = {\n\t\tval len = yid.length\n\t\tif (len == 0) \"000000\"\n\t\telse if (len == 1) \"00000\"\n\t\telse if (len == 2) \"0000\"\n\t\telse if (len == 3) \"000\"\n\t\telse if (len == 4) \"00\"\n\t\telse if (len == 5) \"0\" else \"\"\n\t}\n\n\tprivate def str(pgr: Int, yindex: Int): String = {\n\t\t//val id = \"%06d%06d\".format(pgr, (yindex + 1))\n\t\tval yid = Integer.toString(yindex + 1)\n\t\tval prey = zeros(yid)\n\t\tval pid = Integer.toString(pgr)\n\t\tval prep = zeros(pid)\n\t\tprep + pid + prey + yid\n\t}\n\n\tprivate def func(lines: Seq[String]) {\n\t\tval line = lines.tail.zipWithIndex.map { case (e, gi) =>\n\t\t\tval tmp = e.split(' ').map(_.toInt).toArray\n\t\t\t(tmp(0), (tmp(1), gi))\n\t\t}\n\t\tval idMap = line.indices.map(_ => Array(-1, -1)).toArray\n\t\tline.groupBy(_._1).foreach { case (pgr, ylist) =>\n\t\t\tylist.toSeq.map(_._2).sortBy(_._1).map(_._2).zipWithIndex.foreach { case (gi, yindex) =>\n\t\t\t\t//val id = str(pgr, yindex)\n\t\t\t\t////println(gi, id)\n\t\t\t\t////idMap = idMap + (gi -> id)\n\t\t\t\t//idMap(gi) = id\n\n\t\t\t\tidMap(gi) = Array(pgr, yindex)\n\t\t\t}\n\t\t}\n\t\tval pw = new java.io.PrintWriter(System.out)\n\t\tidMap.foreach(e => pw.println(str(e(0), e(1))))\n\t\tpw.flush()\n\t}\n\n//\tval start = System.currentTimeMillis()\n//\t//func((0 until 100).map(i => (i % 1) + \" \" + -i))\n//\tfunc((0 until 100000).map(i => (i % 1) + \" \" + i))\n//\tfunc((0 until 100000).map(i => (i % 1) + \" \" + -i))\n//\tfunc((0 until 100000).map(i => -i + \" \" + -i))\n//\tprintln(System.currentTimeMillis() - start)\n\n\tfunc(scala.io.Source.stdin.getLines.toSeq)\n}\n", "language": "Scala", "metadata": {"date": 1542064142, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s194008707.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s194008707", "user_id": "u699236457"}, "prompt_components": {"gold_output": "000001000002\n000002000001\n000001000001\n", "input_to_evaluate": "object Main extends App {\n\tprivate def zeros(yid: String): String = {\n\t\tval len = yid.length\n\t\tif (len == 0) \"000000\"\n\t\telse if (len == 1) \"00000\"\n\t\telse if (len == 2) \"0000\"\n\t\telse if (len == 3) \"000\"\n\t\telse if (len == 4) \"00\"\n\t\telse if (len == 5) \"0\" else \"\"\n\t}\n\n\tprivate def str(pgr: Int, yindex: Int): String = {\n\t\t//val id = \"%06d%06d\".format(pgr, (yindex + 1))\n\t\tval yid = Integer.toString(yindex + 1)\n\t\tval prey = zeros(yid)\n\t\tval pid = Integer.toString(pgr)\n\t\tval prep = zeros(pid)\n\t\tprep + pid + prey + yid\n\t}\n\n\tprivate def func(lines: Seq[String]) {\n\t\tval line = lines.tail.zipWithIndex.map { case (e, gi) =>\n\t\t\tval tmp = e.split(' ').map(_.toInt).toArray\n\t\t\t(tmp(0), (tmp(1), gi))\n\t\t}\n\t\tval idMap = line.indices.map(_ => Array(-1, -1)).toArray\n\t\tline.groupBy(_._1).foreach { case (pgr, ylist) =>\n\t\t\tylist.toSeq.map(_._2).sortBy(_._1).map(_._2).zipWithIndex.foreach { case (gi, yindex) =>\n\t\t\t\t//val id = str(pgr, yindex)\n\t\t\t\t////println(gi, id)\n\t\t\t\t////idMap = idMap + (gi -> id)\n\t\t\t\t//idMap(gi) = id\n\n\t\t\t\tidMap(gi) = Array(pgr, yindex)\n\t\t\t}\n\t\t}\n\t\tval pw = new java.io.PrintWriter(System.out)\n\t\tidMap.foreach(e => pw.println(str(e(0), e(1))))\n\t\tpw.flush()\n\t}\n\n//\tval start = System.currentTimeMillis()\n//\t//func((0 until 100).map(i => (i % 1) + \" \" + -i))\n//\tfunc((0 until 100000).map(i => (i % 1) + \" \" + i))\n//\tfunc((0 until 100000).map(i => (i % 1) + \" \" + -i))\n//\tfunc((0 until 100000).map(i => -i + \" \" + -i))\n//\tprintln(System.currentTimeMillis() - start)\n\n\tfunc(scala.io.Source.stdin.getLines.toSeq)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1519, "cpu_time_ms": 2118, "memory_kb": 143908}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s326813888", "group_id": "codeNet:p03221", "input_text": "\nobject Main extends App {\n\n import scala.io.StdIn._\n\n\n val Array(n, m) = readLine.trim.split(' ').map(_.toInt)\n val prefNum = Array.tabulate(n){_ ⇒ 0}\n val id = Array.tabulate(m){_ ⇒ 1000000000000L}\n val towns = Array.tabulate(m){_ ⇒\n val Array(p, y) = readLine.trim.split(' ').map(_.toInt)\n Town(p, y)\n }.zipWithIndex.sortBy(_._1.year)\n for ((town, i) ← towns){\n prefNum(town.pref - 1) += 1\n id(i) += prefNum(town.pref - 1) + town.pref * 1000000\n }\n for (i ← id){\n println(i.toString.takeRight(12))\n }\n case class Town(pref: Int, year: Int)\n}\n", "language": "Scala", "metadata": {"date": 1541436615, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s326813888.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s326813888", "user_id": "u419330815"}, "prompt_components": {"gold_output": "000001000002\n000002000001\n000001000001\n", "input_to_evaluate": "\nobject Main extends App {\n\n import scala.io.StdIn._\n\n\n val Array(n, m) = readLine.trim.split(' ').map(_.toInt)\n val prefNum = Array.tabulate(n){_ ⇒ 0}\n val id = Array.tabulate(m){_ ⇒ 1000000000000L}\n val towns = Array.tabulate(m){_ ⇒\n val Array(p, y) = readLine.trim.split(' ').map(_.toInt)\n Town(p, y)\n }.zipWithIndex.sortBy(_._1.year)\n for ((town, i) ← towns){\n prefNum(town.pref - 1) += 1\n id(i) += prefNum(town.pref - 1) + town.pref * 1000000\n }\n for (i ← id){\n println(i.toString.takeRight(12))\n }\n case class Town(pref: Int, year: Int)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 581, "cpu_time_ms": 1968, "memory_kb": 88080}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s445104695", "group_id": "codeNet:p03221", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val s = new Main()\n s.solve()\n s.out.flush()\n }\n}\n\nclass Main {\n import java.io._\n import java.util.StringTokenizer\n\n import scala.collection.mutable\n import scala.util.Sorting\n import math.{abs, max, min}\n import mutable.{ArrayBuffer, ListBuffer}\n import scala.reflect.ClassTag\n\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n\n def solve(): Unit = {\n val N, M = ni()\n val cities = Array.ofDim[(Int, Int, Int)](M)\n rep(M) { i =>\n cities(i) = (ni() - 1, ni(), i)\n }\n Sorting.quickSort(cities)(Ordering.by(_._2))\n val cnt = Array.ofDim[Int](N)\n val num = Array.ofDim[Int](M)\n val pref = Array.ofDim[Int](M)\n rep(M) { i =>\n val p = cities(i)._1\n val c = cities(i)._3\n val id = cnt(p)\n num(c) = id\n pref(c) = p\n cnt(p) += 1\n }\n\n rep(M) { i =>\n val p = pref(i)\n val c = num(i)\n out.println(f\"${p+1}%06d${c+1}%06d\")\n }\n }\n\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next().toInt\n def nextLong(): Long = next().toLong\n def nextChar(): Char = next().charAt(0)\n }\n val sc = new InputReader(System.in)\n def ni(): Int = sc.nextInt()\n def nl(): Long = sc.nextLong()\n def nc(): Char = sc.nextChar()\n def ns(): String = sc.next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int): Array[Int] = map(n)(_ => ni())\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n rep(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n rep(n) { i =>\n rep(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n\n def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n rep(n)(i => res(i) = f(i))\n res\n }\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n rep(as.length)(i => s += as(i))\n s\n }\n\n def cumSum(as: Array[Int]) = {\n val cum = Array.ofDim[Int](as.length + 1)\n rep(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}", "language": "Scala", "metadata": {"date": 1541384007, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s445104695.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s445104695", "user_id": "u460609472"}, "prompt_components": {"gold_output": "000001000002\n000002000001\n000001000001\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val s = new Main()\n s.solve()\n s.out.flush()\n }\n}\n\nclass Main {\n import java.io._\n import java.util.StringTokenizer\n\n import scala.collection.mutable\n import scala.util.Sorting\n import math.{abs, max, min}\n import mutable.{ArrayBuffer, ListBuffer}\n import scala.reflect.ClassTag\n\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n\n def solve(): Unit = {\n val N, M = ni()\n val cities = Array.ofDim[(Int, Int, Int)](M)\n rep(M) { i =>\n cities(i) = (ni() - 1, ni(), i)\n }\n Sorting.quickSort(cities)(Ordering.by(_._2))\n val cnt = Array.ofDim[Int](N)\n val num = Array.ofDim[Int](M)\n val pref = Array.ofDim[Int](M)\n rep(M) { i =>\n val p = cities(i)._1\n val c = cities(i)._3\n val id = cnt(p)\n num(c) = id\n pref(c) = p\n cnt(p) += 1\n }\n\n rep(M) { i =>\n val p = pref(i)\n val c = num(i)\n out.println(f\"${p+1}%06d${c+1}%06d\")\n }\n }\n\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next().toInt\n def nextLong(): Long = next().toLong\n def nextChar(): Char = next().charAt(0)\n }\n val sc = new InputReader(System.in)\n def ni(): Int = sc.nextInt()\n def nl(): Long = sc.nextLong()\n def nc(): Char = sc.nextChar()\n def ns(): String = sc.next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int): Array[Int] = map(n)(_ => ni())\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n rep(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n rep(n) { i =>\n rep(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n\n def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n rep(n)(i => res(i) = f(i))\n res\n }\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n rep(as.length)(i => s += as(i))\n s\n }\n\n def cumSum(as: Array[Int]) = {\n val cum = Array.ofDim[Int](as.length + 1)\n rep(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2908, "cpu_time_ms": 1837, "memory_kb": 131420}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s432663478", "group_id": "codeNet:p03232", "input_text": "object Main {\n import java.util.Scanner\n\n def readStrings(n: Int)(implicit sc: Scanner): Array[String] = Array.fill(n) { sc.next() }\n def readInts(n: Int)(implicit sc: Scanner): Array[Int] = Array.fill(n) { sc.nextInt() }\n def readLongs(n: Int)(implicit sc: Scanner): Array[Long] = Array.fill(n) { sc.nextLong() }\n def readLineStrings(implicit sc: Scanner): Array[String] = sc.nextLine().split(' ')\n def readLineInts(implicit sc: Scanner): Array[Int] = readLineStrings.map(_.toInt)\n def readLineLongs(implicit sc: Scanner): Array[Long] = readLineStrings.map(_.toLong)\n\n def main(args: Array[String]): Unit = solve(new Scanner(System.in))\n\n def fact(n: Int): Long = if (n == 0) 1 else n * fact(n - 1)\n\n def test(arrayLength: Int): Array[Long] = {\n if (arrayLength == 0) return Array(1L)\n val base = Array.fill(arrayLength)(fact(arrayLength))\n for (i <- 0 until arrayLength) {\n val leftLength = i\n if (leftLength != 0) {\n val left = test(leftLength)\n val leftMultiplier = fact(arrayLength - 1) / fact(leftLength)\n for (j <- 0 until leftLength) {\n base(j) += left(j) * leftMultiplier\n }\n }\n\n val rightLength = arrayLength - i - 1\n if (rightLength != 0) {\n val right = test(rightLength)\n val rightMultiplier = fact(arrayLength - 1) / fact(rightLength)\n for (j <- 0 until rightLength) {\n base(j + i + 1) += right(j) * rightMultiplier\n }\n }\n }\n\n base\n }\n\n def solve(implicit sc: Scanner): Unit = {\n val N = sc.nextLine().toInt\n val A = readLineLongs\n\n println(test(N).zipWithIndex.map { case (e, i) => e * A(i) }.sum % 1000000007)\n }\n}\n", "language": "Scala", "metadata": {"date": 1539484195, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03232.html", "problem_id": "p03232", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03232/input.txt", "sample_output_relpath": "derived/input_output/data/p03232/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03232/Scala/s432663478.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s432663478", "user_id": "u909304507"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "object Main {\n import java.util.Scanner\n\n def readStrings(n: Int)(implicit sc: Scanner): Array[String] = Array.fill(n) { sc.next() }\n def readInts(n: Int)(implicit sc: Scanner): Array[Int] = Array.fill(n) { sc.nextInt() }\n def readLongs(n: Int)(implicit sc: Scanner): Array[Long] = Array.fill(n) { sc.nextLong() }\n def readLineStrings(implicit sc: Scanner): Array[String] = sc.nextLine().split(' ')\n def readLineInts(implicit sc: Scanner): Array[Int] = readLineStrings.map(_.toInt)\n def readLineLongs(implicit sc: Scanner): Array[Long] = readLineStrings.map(_.toLong)\n\n def main(args: Array[String]): Unit = solve(new Scanner(System.in))\n\n def fact(n: Int): Long = if (n == 0) 1 else n * fact(n - 1)\n\n def test(arrayLength: Int): Array[Long] = {\n if (arrayLength == 0) return Array(1L)\n val base = Array.fill(arrayLength)(fact(arrayLength))\n for (i <- 0 until arrayLength) {\n val leftLength = i\n if (leftLength != 0) {\n val left = test(leftLength)\n val leftMultiplier = fact(arrayLength - 1) / fact(leftLength)\n for (j <- 0 until leftLength) {\n base(j) += left(j) * leftMultiplier\n }\n }\n\n val rightLength = arrayLength - i - 1\n if (rightLength != 0) {\n val right = test(rightLength)\n val rightMultiplier = fact(arrayLength - 1) / fact(rightLength)\n for (j <- 0 until rightLength) {\n base(j + i + 1) += right(j) * rightMultiplier\n }\n }\n }\n\n base\n }\n\n def solve(implicit sc: Scanner): Unit = {\n val N = sc.nextLine().toInt\n val A = readLineLongs\n\n println(test(N).zipWithIndex.map { case (e, i) => e * A(i) }.sum % 1000000007)\n }\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere are N blocks arranged in a row, numbered 1 to N from left to right.\nEach block has a weight, and the weight of Block i is A_i.\nSnuke will perform the following operation on these blocks N times:\n\nChoose one block that is still not removed, and remove it.\nThe cost of this operation is the sum of the weights of the blocks that are connected to the block being removed (including itself).\nHere, two blocks x and y ( x \\leq y ) are connected when, for all z ( x \\leq z \\leq y ), Block z is still not removed.\n\nThere are N! possible orders in which Snuke removes the blocks.\nFor all of those N! orders, find the total cost of the N operations, and calculate the sum of those N! total costs.\nAs the answer can be extremely large, compute the sum modulo 10^9+7.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFor all of the N! orders, find the total cost of the N operations, and print the sum of those N! total costs, modulo 10^9+7.\n\nSample Input 1\n\n2\n1 2\n\nSample Output 1\n\n9\n\nFirst, we will consider the order \"Block 1 -> Block 2\".\nIn the first operation, the cost of the operation is 1+2=3, as Block 1 and 2 are connected.\nIn the second operation, the cost of the operation is 2, as only Block 2 remains.\nThus, the total cost of the two operations for this order is 3+2=5.\n\nThen, we will consider the order \"Block 2 -> Block 1\".\nIn the first operation, the cost of the operation is 1+2=3, as Block 1 and 2 are connected.\nIn the second operation, the cost of the operation is 1, as only Block 1 remains.\nThus, the total cost of the two operations for this order is 3+1=4.\n\nTherefore, the answer is 5+4=9.\n\nSample Input 2\n\n4\n1 1 1 1\n\nSample Output 2\n\n212\n\nSample Input 3\n\n10\n1 2 4 8 16 32 64 128 256 512\n\nSample Output 3\n\n880971923", "sample_input": "2\n1 2\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03232", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere are N blocks arranged in a row, numbered 1 to N from left to right.\nEach block has a weight, and the weight of Block i is A_i.\nSnuke will perform the following operation on these blocks N times:\n\nChoose one block that is still not removed, and remove it.\nThe cost of this operation is the sum of the weights of the blocks that are connected to the block being removed (including itself).\nHere, two blocks x and y ( x \\leq y ) are connected when, for all z ( x \\leq z \\leq y ), Block z is still not removed.\n\nThere are N! possible orders in which Snuke removes the blocks.\nFor all of those N! orders, find the total cost of the N operations, and calculate the sum of those N! total costs.\nAs the answer can be extremely large, compute the sum modulo 10^9+7.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFor all of the N! orders, find the total cost of the N operations, and print the sum of those N! total costs, modulo 10^9+7.\n\nSample Input 1\n\n2\n1 2\n\nSample Output 1\n\n9\n\nFirst, we will consider the order \"Block 1 -> Block 2\".\nIn the first operation, the cost of the operation is 1+2=3, as Block 1 and 2 are connected.\nIn the second operation, the cost of the operation is 2, as only Block 2 remains.\nThus, the total cost of the two operations for this order is 3+2=5.\n\nThen, we will consider the order \"Block 2 -> Block 1\".\nIn the first operation, the cost of the operation is 1+2=3, as Block 1 and 2 are connected.\nIn the second operation, the cost of the operation is 1, as only Block 1 remains.\nThus, the total cost of the two operations for this order is 3+1=4.\n\nTherefore, the answer is 5+4=9.\n\nSample Input 2\n\n4\n1 1 1 1\n\nSample Output 2\n\n212\n\nSample Input 3\n\n10\n1 2 4 8 16 32 64 128 256 512\n\nSample Output 3\n\n880971923", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1671, "cpu_time_ms": 644, "memory_kb": 45576}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s394760612", "group_id": "codeNet:p03241", "input_text": "object Main{\n def main(args:Array[String]):Unit={\n var n = readInt\n var m = readInt\n \n var max = m/n\n var flag = true\n for(i <- max until 0 by -1 if flag){\n if(m%i==0){\n println(i)\n flag = false\n }\n }\n }\n}", "language": "Scala", "metadata": {"date": 1543278436, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s394760612.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s394760612", "user_id": "u825805112"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main{\n def main(args:Array[String]):Unit={\n var n = readInt\n var m = readInt\n \n var max = m/n\n var flag = true\n for(i <- max until 0 by -1 if flag){\n if(m%i==0){\n println(i)\n flag = false\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 252, "cpu_time_ms": 357, "memory_kb": 27096}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s951115064", "group_id": "codeNet:p03241", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val s = new Main()\n s.solve()\n s.out.flush()\n }\n}\n\nclass Main {\n import java.io._\n import java.util.StringTokenizer\n\n import scala.collection.mutable\n import scala.util.Sorting\n import math.{abs, max, min}\n import mutable.{ArrayBuffer, ListBuffer}\n import scala.reflect.ClassTag\n\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n\n def solve(): Unit = {\n val N, M = ni()\n\n var ans = 1\n rep(math.sqrt(M).toInt, 2) { g =>\n val x = M - g.toLong * (N - 1)\n if (x > 0 && x % g == 0) ans = g\n }\n\n rep_r(math.sqrt(M).toInt, 2) { c =>\n if (M % c == 0 && c >= N) {\n ans = M / c\n }\n }\n\n out.println(ans)\n }\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next().toInt\n def nextLong(): Long = next().toLong\n def nextChar(): Char = next().charAt(0)\n }\n val sc = new InputReader(System.in)\n def ni(): Int = sc.nextInt()\n def nl(): Long = sc.nextLong()\n def nc(): Char = sc.nextChar()\n def ns(): String = sc.next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int): Array[Int] = map(n)(_ => ni())\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n\n def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n rep(n)(i => res(i) = f(i))\n res\n }\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n rep(as.length)(i => s += as(i))\n s\n }\n}", "language": "Scala", "metadata": {"date": 1538878854, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s951115064.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s951115064", "user_id": "u460609472"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val s = new Main()\n s.solve()\n s.out.flush()\n }\n}\n\nclass Main {\n import java.io._\n import java.util.StringTokenizer\n\n import scala.collection.mutable\n import scala.util.Sorting\n import math.{abs, max, min}\n import mutable.{ArrayBuffer, ListBuffer}\n import scala.reflect.ClassTag\n\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n\n def solve(): Unit = {\n val N, M = ni()\n\n var ans = 1\n rep(math.sqrt(M).toInt, 2) { g =>\n val x = M - g.toLong * (N - 1)\n if (x > 0 && x % g == 0) ans = g\n }\n\n rep_r(math.sqrt(M).toInt, 2) { c =>\n if (M % c == 0 && c >= N) {\n ans = M / c\n }\n }\n\n out.println(ans)\n }\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next().toInt\n def nextLong(): Long = next().toLong\n def nextChar(): Char = next().charAt(0)\n }\n val sc = new InputReader(System.in)\n def ni(): Int = sc.nextInt()\n def nl(): Long = sc.nextLong()\n def nc(): Char = sc.nextChar()\n def ns(): String = sc.next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int): Array[Int] = map(n)(_ => ni())\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n\n def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n rep(n)(i => res(i) = f(i))\n res\n }\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n rep(as.length)(i => s += as(i))\n s\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2120, "cpu_time_ms": 334, "memory_kb": 25520}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s532312080", "group_id": "codeNet:p03241", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val s = new Main()\n s.solve()\n s.out.flush()\n }\n}\n\nclass Main {\n import java.io._\n import java.util.StringTokenizer\n\n import scala.collection.mutable\n import scala.util.Sorting\n import math.{abs, max, min}\n import mutable.{ArrayBuffer, ListBuffer}\n import scala.reflect.ClassTag\n\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n\n def solve(): Unit = {\n val N, M = ni()\n\n var ans = 1\n rep(math.sqrt(M).toInt, 2) { g =>\n val x = M - g * (N - 1)\n if (x > 0 && x % g == 0) ans = g\n }\n\n out.println(ans)\n }\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next().toInt\n def nextLong(): Long = next().toLong\n def nextChar(): Char = next().charAt(0)\n }\n val sc = new InputReader(System.in)\n def ni(): Int = sc.nextInt()\n def nl(): Long = sc.nextLong()\n def nc(): Char = sc.nextChar()\n def ns(): String = sc.next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int): Array[Int] = map(n)(_ => ni())\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n\n def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n rep(n)(i => res(i) = f(i))\n res\n }\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n rep(as.length)(i => s += as(i))\n s\n }\n}", "language": "Scala", "metadata": {"date": 1538878235, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s532312080.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s532312080", "user_id": "u460609472"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val s = new Main()\n s.solve()\n s.out.flush()\n }\n}\n\nclass Main {\n import java.io._\n import java.util.StringTokenizer\n\n import scala.collection.mutable\n import scala.util.Sorting\n import math.{abs, max, min}\n import mutable.{ArrayBuffer, ListBuffer}\n import scala.reflect.ClassTag\n\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n\n def solve(): Unit = {\n val N, M = ni()\n\n var ans = 1\n rep(math.sqrt(M).toInt, 2) { g =>\n val x = M - g * (N - 1)\n if (x > 0 && x % g == 0) ans = g\n }\n\n out.println(ans)\n }\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next().toInt\n def nextLong(): Long = next().toLong\n def nextChar(): Char = next().charAt(0)\n }\n val sc = new InputReader(System.in)\n def ni(): Int = sc.nextInt()\n def nl(): Long = sc.nextLong()\n def nc(): Char = sc.nextChar()\n def ns(): String = sc.next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int): Array[Int] = map(n)(_ => ni())\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n\n def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n rep(n)(i => res(i) = f(i))\n res\n }\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n rep(as.length)(i => s += as(i))\n s\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2004, "cpu_time_ms": 342, "memory_kb": 27220}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s111194365", "group_id": "codeNet:p03242", "input_text": "object Main{\n def main(args:Array[String]):Unit={\n var input = readLine\n var res = \"\"\n for(i <- input){\n if(i=='1') res += '9'.toString\n else if(i=='9') res+='1'.toString\n else res+=i.toString\n }\n println(res)\n }\n}", "language": "Scala", "metadata": {"date": 1543279961, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03242.html", "problem_id": "p03242", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03242/input.txt", "sample_output_relpath": "derived/input_output/data/p03242/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03242/Scala/s111194365.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s111194365", "user_id": "u825805112"}, "prompt_components": {"gold_output": "991\n", "input_to_evaluate": "object Main{\n def main(args:Array[String]):Unit={\n var input = readLine\n var res = \"\"\n for(i <- input){\n if(i=='1') res += '9'.toString\n else if(i=='9') res+='1'.toString\n else res+=i.toString\n }\n println(res)\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nCat Snuke is learning to write characters.\nToday, he practiced writing digits 1 and 9, but he did it the other way around.\n\nYou are given a three-digit integer n written by Snuke.\nPrint the integer obtained by replacing each digit 1 with 9 and each digit 9 with 1 in n.\n\nConstraints\n\n111 \\leq n \\leq 999\n\nn is an integer consisting of digits 1 and 9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\n\nOutput\n\nPrint the integer obtained by replacing each occurrence of 1 with 9 and each occurrence of 9 with 1 in n.\n\nSample Input 1\n\n119\n\nSample Output 1\n\n991\n\nReplace the 9 in the ones place with 1, the 1 in the tens place with 9 and the 1 in the hundreds place with 9. The answer is 991.\n\nSample Input 2\n\n999\n\nSample Output 2\n\n111", "sample_input": "119\n"}, "reference_outputs": ["991\n"], "source_document_id": "p03242", "source_text": "Score : 100 points\n\nProblem Statement\n\nCat Snuke is learning to write characters.\nToday, he practiced writing digits 1 and 9, but he did it the other way around.\n\nYou are given a three-digit integer n written by Snuke.\nPrint the integer obtained by replacing each digit 1 with 9 and each digit 9 with 1 in n.\n\nConstraints\n\n111 \\leq n \\leq 999\n\nn is an integer consisting of digits 1 and 9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\n\nOutput\n\nPrint the integer obtained by replacing each occurrence of 1 with 9 and each occurrence of 9 with 1 in n.\n\nSample Input 1\n\n119\n\nSample Output 1\n\n991\n\nReplace the 9 in the ones place with 1, the 1 in the tens place with 9 and the 1 in the hundreds place with 9. The answer is 991.\n\nSample Input 2\n\n999\n\nSample Output 2\n\n111", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 324, "memory_kb": 25408}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s507914842", "group_id": "codeNet:p03243", "input_text": "object Main extends App{\n println((new java.util.Scanner(System.in).nextInt()/111).floor*111)\n}", "language": "Scala", "metadata": {"date": 1540692543, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03243.html", "problem_id": "p03243", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03243/input.txt", "sample_output_relpath": "derived/input_output/data/p03243/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03243/Scala/s507914842.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s507914842", "user_id": "u690438113"}, "prompt_components": {"gold_output": "111\n", "input_to_evaluate": "object Main extends App{\n println((new java.util.Scanner(System.in).nextInt()/111).floor*111)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nKurohashi has never participated in AtCoder Beginner Contest (ABC).\n\nThe next ABC to be held is ABC N (the N-th ABC ever held).\nKurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.\n\nWhat is the earliest ABC where Kurohashi can make his debut?\n\nConstraints\n\n100 \\leq N \\leq 999\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf the earliest ABC where Kurohashi can make his debut is ABC n, print n.\n\nSample Input 1\n\n111\n\nSample Output 1\n\n111\n\nThe next ABC to be held is ABC 111, where Kurohashi can make his debut.\n\nSample Input 2\n\n112\n\nSample Output 2\n\n222\n\nThe next ABC to be held is ABC 112, which means Kurohashi can no longer participate in ABC 111.\nAmong the ABCs where Kurohashi can make his debut, the earliest one is ABC 222.\n\nSample Input 3\n\n750\n\nSample Output 3\n\n777", "sample_input": "111\n"}, "reference_outputs": ["111\n"], "source_document_id": "p03243", "source_text": "Score : 200 points\n\nProblem Statement\n\nKurohashi has never participated in AtCoder Beginner Contest (ABC).\n\nThe next ABC to be held is ABC N (the N-th ABC ever held).\nKurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.\n\nWhat is the earliest ABC where Kurohashi can make his debut?\n\nConstraints\n\n100 \\leq N \\leq 999\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf the earliest ABC where Kurohashi can make his debut is ABC n, print n.\n\nSample Input 1\n\n111\n\nSample Output 1\n\n111\n\nThe next ABC to be held is ABC 111, where Kurohashi can make his debut.\n\nSample Input 2\n\n112\n\nSample Output 2\n\n222\n\nThe next ABC to be held is ABC 112, which means Kurohashi can no longer participate in ABC 111.\nAmong the ABCs where Kurohashi can make his debut, the earliest one is ABC 222.\n\nSample Input 3\n\n750\n\nSample Output 3\n\n777", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 96, "cpu_time_ms": 343, "memory_kb": 25668}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s491939975", "group_id": "codeNet:p03244", "input_text": "object Main extends App {\n import scala.io.StdIn.{readInt, readLine}\n val _ = readInt()\n val numbers = readLine().split(' ').map(_.toInt)\n\n val Array(first, second) = numbers.take(2)\n val tail = numbers.tail.tail\n\n val suggestedChangeSize = if (first == second) {\n 0\n } else {\n tail.zipWithIndex.count {\n case (number, i) =>\n if (i == 0) number == first\n else if (i % 2 == 0) number == first\n else number == second\n }\n }\n\n println(suggestedChangeSize)\n}", "language": "Scala", "metadata": {"date": 1598484460, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s491939975.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s491939975", "user_id": "u388106329"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main extends App {\n import scala.io.StdIn.{readInt, readLine}\n val _ = readInt()\n val numbers = readLine().split(' ').map(_.toInt)\n\n val Array(first, second) = numbers.take(2)\n val tail = numbers.tail.tail\n\n val suggestedChangeSize = if (first == second) {\n 0\n } else {\n tail.zipWithIndex.count {\n case (number, i) =>\n if (i == 0) number == first\n else if (i % 2 == 0) number == first\n else number == second\n }\n }\n\n println(suggestedChangeSize)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 497, "cpu_time_ms": 610, "memory_kb": 66676}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s584005496", "group_id": "codeNet:p03244", "input_text": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n // 偶数番目, 奇数番目の数が, それぞれ全て同じであればいい\n // かつ, どちらも異なる数\n\n val N = sc.nextInt()\n val Vm = 100000\n val OddN, EvenN = new Array[Int](Vm+1)\n\n (0 until N) foreach { i =>\n val v = sc.nextInt()\n if (i % 2 == 0) {\n EvenN(v) += 1\n } else {\n OddN(v) += 1\n }\n }\n\n // Odd(i) // i番目に出現回数が大きい数\n // OddN(Odd(i)) // i番目に出現回数の大きい数の出現回数\n\n def solve(): Int = {\n val Odd = (0 to Vm).sortBy(i => OddN(i))(Ordering.Int.reverse)\n val Even = (0 to Vm).sortBy(i => EvenN(i))(Ordering.Int.reverse)\n\n var i = 0\n var j = 0\n while (i < Vm && j < Vm) {\n val oN = OddN(Odd(i))\n val eN = EvenN(Even(j))\n\n if (oN == 0)\n return N - eN\n else if (eN == 0)\n return N - oN\n\n if (Odd(i) != Even(j)) {\n return N - oN - eN\n }\n\n if (Odd(i+1) > Even(i+1))\n i += 1\n else\n j += 1\n }\n N\n }\n println(solve())\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1562446426, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s584005496.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s584005496", "user_id": "u891387249"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n // 偶数番目, 奇数番目の数が, それぞれ全て同じであればいい\n // かつ, どちらも異なる数\n\n val N = sc.nextInt()\n val Vm = 100000\n val OddN, EvenN = new Array[Int](Vm+1)\n\n (0 until N) foreach { i =>\n val v = sc.nextInt()\n if (i % 2 == 0) {\n EvenN(v) += 1\n } else {\n OddN(v) += 1\n }\n }\n\n // Odd(i) // i番目に出現回数が大きい数\n // OddN(Odd(i)) // i番目に出現回数の大きい数の出現回数\n\n def solve(): Int = {\n val Odd = (0 to Vm).sortBy(i => OddN(i))(Ordering.Int.reverse)\n val Even = (0 to Vm).sortBy(i => EvenN(i))(Ordering.Int.reverse)\n\n var i = 0\n var j = 0\n while (i < Vm && j < Vm) {\n val oN = OddN(Odd(i))\n val eN = EvenN(Even(j))\n\n if (oN == 0)\n return N - eN\n else if (eN == 0)\n return N - oN\n\n if (Odd(i) != Even(j)) {\n return N - oN - eN\n }\n\n if (Odd(i+1) > Even(i+1))\n i += 1\n else\n j += 1\n }\n N\n }\n println(solve())\n }\n\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1203, "cpu_time_ms": 877, "memory_kb": 56960}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s994999643", "group_id": "codeNet:p03244", "input_text": "//import java.util.Scanner\n\nimport scala.collection.Searching._\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.immutable._\nimport scala.io.StdIn.readLine\n\nimport java.io._\nimport java.nio.file.{Files, Path}\nimport java.util.StringTokenizer\n\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(Files.newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext = current.hasNext\n\n @inline def next() = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close() = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(new Node(None, 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) => {\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n }\n}\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val A = Array.fill(sc.nextInt())(sc.nextLong())\n println(if (A.groupBy(i => i).size == 1) (A.size / 2) else {\n val X =\n A.zipWithIndex.filter {\n case (_, a) => a % 2 == 1\n }.map {\n case (a, _) => a\n }.groupBy(i => i).toList.sortBy {\n case (_, b) => b.size\n }.reverse\n\n val Y = A.zipWithIndex.filter {\n case (_, a) => a % 2 == 0\n }.map {\n case (a, _) => a\n }.groupBy(i => i).toList.sortBy {\n case (_, b) => b.size\n }.reverse\n\n (A.size -\n (if (X.head._1 == Y.head._1) {\n math.max(X.drop(1).head._2.size + Y.head._2.size, X.head._2.size + Y.drop(1).head._2.size)\n } else {\n X.head._2.size + Y.head._2.size\n }))\n })\n }\n\n def calc(N: Long, R: Long, M: Long): Double = {\n math.sqrt(R * R - (R * 2 * ((M * 1.0 / N) - 0.5)) * (R * 2 * ((M * 1.0 / N) - 0.5))) * 2\n }\n\n def recursive(X: Long, primeList: Stream[Long]): Long = {\n 0\n }\n\n def check(A: Long): Boolean = {\n if (A < 0) (check(-A)) else if (A % 10 == 0) (check(A / 10)) else (A < 10)\n }\n\n def shift(n: Long): Long = {\n if (n == 0) (0) else if (n == 1) (1) else (shift(n - 1) << 1)\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) (0) else (unShift(n >> 1) + 1)\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList(): Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: (Int) =?> String = {\n case src if (src >= 1 && src <= 3999) => {\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if (n == 0) => cont + unitChar\n case n if (n > 0) => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n }\n\n val romanToArabic: (String) =?> Int = {\n case src if (Option(src).exists { s => {\n s.nonEmpty && (\"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase) == None)\n }\n }) => {\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1541128493, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s994999643.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s994999643", "user_id": "u779353743"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "//import java.util.Scanner\n\nimport scala.collection.Searching._\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.immutable._\nimport scala.io.StdIn.readLine\n\nimport java.io._\nimport java.nio.file.{Files, Path}\nimport java.util.StringTokenizer\n\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(Files.newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext = current.hasNext\n\n @inline def next() = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close() = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(new Node(None, 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) => {\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n }\n}\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val A = Array.fill(sc.nextInt())(sc.nextLong())\n println(if (A.groupBy(i => i).size == 1) (A.size / 2) else {\n val X =\n A.zipWithIndex.filter {\n case (_, a) => a % 2 == 1\n }.map {\n case (a, _) => a\n }.groupBy(i => i).toList.sortBy {\n case (_, b) => b.size\n }.reverse\n\n val Y = A.zipWithIndex.filter {\n case (_, a) => a % 2 == 0\n }.map {\n case (a, _) => a\n }.groupBy(i => i).toList.sortBy {\n case (_, b) => b.size\n }.reverse\n\n (A.size -\n (if (X.head._1 == Y.head._1) {\n math.max(X.drop(1).head._2.size + Y.head._2.size, X.head._2.size + Y.drop(1).head._2.size)\n } else {\n X.head._2.size + Y.head._2.size\n }))\n })\n }\n\n def calc(N: Long, R: Long, M: Long): Double = {\n math.sqrt(R * R - (R * 2 * ((M * 1.0 / N) - 0.5)) * (R * 2 * ((M * 1.0 / N) - 0.5))) * 2\n }\n\n def recursive(X: Long, primeList: Stream[Long]): Long = {\n 0\n }\n\n def check(A: Long): Boolean = {\n if (A < 0) (check(-A)) else if (A % 10 == 0) (check(A / 10)) else (A < 10)\n }\n\n def shift(n: Long): Long = {\n if (n == 0) (0) else if (n == 1) (1) else (shift(n - 1) << 1)\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) (0) else (unShift(n >> 1) + 1)\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList(): Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: (Int) =?> String = {\n case src if (src >= 1 && src <= 3999) => {\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if (n == 0) => cont + unitChar\n case n if (n > 0) => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n }\n\n val romanToArabic: (String) =?> Int = {\n case src if (Option(src).exists { s => {\n s.nonEmpty && (\"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase) == None)\n }\n }) => {\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6582, "cpu_time_ms": 1625, "memory_kb": 134724}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s288836676", "group_id": "codeNet:p03244", "input_text": "object Main{\n def main(args: Array[String]){\n val sc=new java.util.Scanner(System.in)\n val n=sc.nextInt()\n val v=mysprit(n,sc)\n val std=v.map(x=>(List(0,0)::mysort(x,Nil)).sortBy(-_(1)).take(2)).sortBy(l=>l(0)(1)-l(1)(1))\n std match{\n case List(a:List[List[Int]],b:List[List[Int]]) if a(0)(0)==b(0)(0) => println(n-(a(1)(1)+b(0)(1)))\n case List(a:List[List[Int]],b:List[List[Int]]) => println(n-(a(0)(1)+b(0)(1)))\n }\n }\n def mysort(l:List[Int],r:List[List[Int]]) : List[List[Int]] = {\n l match{\n case Nil => r\n case x::xs => mysort(\n xs filter (_!=x),\n (x :: 1+xs.count(_==x) :: Nil) :: r\n )\n }\n }\n def mysprit(n:Int,s:java.util.Scanner):List[List[Int]] = {\n def myspritlocal(c:Int,l1:List[Int],l2:List[Int]) : List[List[Int]] ={\n c match{\n case 0 => List(l1,l2)\n case a:Int => myspritlocal(a-2,s.nextInt()::l1,s.nextInt()::l2)\n }\n }\n myspritlocal(n,Nil,Nil)\n }\n}", "language": "Scala", "metadata": {"date": 1540706646, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s288836676.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s288836676", "user_id": "u690438113"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main{\n def main(args: Array[String]){\n val sc=new java.util.Scanner(System.in)\n val n=sc.nextInt()\n val v=mysprit(n,sc)\n val std=v.map(x=>(List(0,0)::mysort(x,Nil)).sortBy(-_(1)).take(2)).sortBy(l=>l(0)(1)-l(1)(1))\n std match{\n case List(a:List[List[Int]],b:List[List[Int]]) if a(0)(0)==b(0)(0) => println(n-(a(1)(1)+b(0)(1)))\n case List(a:List[List[Int]],b:List[List[Int]]) => println(n-(a(0)(1)+b(0)(1)))\n }\n }\n def mysort(l:List[Int],r:List[List[Int]]) : List[List[Int]] = {\n l match{\n case Nil => r\n case x::xs => mysort(\n xs filter (_!=x),\n (x :: 1+xs.count(_==x) :: Nil) :: r\n )\n }\n }\n def mysprit(n:Int,s:java.util.Scanner):List[List[Int]] = {\n def myspritlocal(c:Int,l1:List[Int],l2:List[Int]) : List[List[Int]] ={\n c match{\n case 0 => List(l1,l2)\n case a:Int => myspritlocal(a-2,s.nextInt()::l1,s.nextInt()::l2)\n }\n }\n myspritlocal(n,Nil,Nil)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 965, "cpu_time_ms": 2111, "memory_kb": 125460}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s979926022", "group_id": "codeNet:p03244", "input_text": "import java.util.Scanner\n\nimport scala.collection.mutable.LinkedHashMap\n\nobject Main {\n case class SuspectedMap(key:Int , count:Int)\n implicit def tupleToName(tup: (Int, Int)): SuspectedMap = tup match {\n case (key, count) => SuspectedMap(key, count)\n }\n\n def main(args: Array[String]): Unit = {\n val scanner = new Scanner(System.in)\n val n: Int = scanner.nextInt\n val vs: List[Int] = List.fill(n)(scanner.nextInt)\n println(calc(vs))\n }\n\n def calc(nums: List[Int] ): Int ={\n val (evens, odds) = nums.zipWithIndex.partition(_._2 % 2 == 0)\n val (evensFirst, evensSecond) = take2(evens)\n val (oddsFirst, oddsSecond) = take2(odds)\n\n if (evensSecond.key == -1 && oddsSecond.key == -1){\n if (evensFirst.key != oddsFirst.key) 0\n else nums.sum / 2\n }\n else {\n if (evensFirst.key != oddsFirst.key)\n nums.sum - evensFirst.count - oddsFirst.count\n else\n countMinNumberOfRewrite(nums.sum, evensFirst.count, evensSecond.count, oddsFirst.count, oddsSecond.count)\n }\n }\n\n def take2(nums: List[(Int, Int)]): ((Int,Int),(Int,Int)) = {\n val sortedNums: Seq[(Int, Int)] = nums.map(_._1).groupBy(n => n).mapValues(_.length).toSeq.sortBy(_.count).reverse\n (sortedNums(0), try{sortedNums(1)}catch{case e :Exception => (-1, Int.MinValue)})\n }\n\n def countMinNumberOfRewrite(allNums: Int ,e1stCnt: Int, e2ndCnt: Int, o1stCnt: Int, o2ndCnt: Int): Int={\n val count1 = allNums - e1stCnt - o2ndCnt\n val count2 = allNums - e2ndCnt - o1stCnt\n count1.min(count2)\n }\n}", "language": "Scala", "metadata": {"date": 1539953830, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s979926022.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s979926022", "user_id": "u125389565"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.collection.mutable.LinkedHashMap\n\nobject Main {\n case class SuspectedMap(key:Int , count:Int)\n implicit def tupleToName(tup: (Int, Int)): SuspectedMap = tup match {\n case (key, count) => SuspectedMap(key, count)\n }\n\n def main(args: Array[String]): Unit = {\n val scanner = new Scanner(System.in)\n val n: Int = scanner.nextInt\n val vs: List[Int] = List.fill(n)(scanner.nextInt)\n println(calc(vs))\n }\n\n def calc(nums: List[Int] ): Int ={\n val (evens, odds) = nums.zipWithIndex.partition(_._2 % 2 == 0)\n val (evensFirst, evensSecond) = take2(evens)\n val (oddsFirst, oddsSecond) = take2(odds)\n\n if (evensSecond.key == -1 && oddsSecond.key == -1){\n if (evensFirst.key != oddsFirst.key) 0\n else nums.sum / 2\n }\n else {\n if (evensFirst.key != oddsFirst.key)\n nums.sum - evensFirst.count - oddsFirst.count\n else\n countMinNumberOfRewrite(nums.sum, evensFirst.count, evensSecond.count, oddsFirst.count, oddsSecond.count)\n }\n }\n\n def take2(nums: List[(Int, Int)]): ((Int,Int),(Int,Int)) = {\n val sortedNums: Seq[(Int, Int)] = nums.map(_._1).groupBy(n => n).mapValues(_.length).toSeq.sortBy(_.count).reverse\n (sortedNums(0), try{sortedNums(1)}catch{case e :Exception => (-1, Int.MinValue)})\n }\n\n def countMinNumberOfRewrite(allNums: Int ,e1stCnt: Int, e2ndCnt: Int, o1stCnt: Int, o2ndCnt: Int): Int={\n val count1 = allNums - e1stCnt - o2ndCnt\n val count2 = allNums - e2ndCnt - o1stCnt\n count1.min(count2)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1635, "cpu_time_ms": 1840, "memory_kb": 117560}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s550988949", "group_id": "codeNet:p03244", "input_text": "import java.util.Scanner\n\nimport scala.collection.mutable\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n def main(args: Array[String]) {\n val result = solve(new Scanner(System.in))\n if (result.length > 0) println(result)\n }\n\n def solve(in: String): String = solve(new Scanner(in))\n\n def solve(sc: Scanner): String = {\n val n = sc.nextInt\n val v1 = new mutable.HashMap[Int, Int]()\n val v2 = new mutable.HashMap[Int, Int]()\n for (i <- 0 until n / 2) {\n val k1 = sc.nextInt\n v1(k1) = v1.getOrElse(k1, 0) + 1\n val k2 = sc.nextInt\n v2(k2) = v2.getOrElse(k2, 0) + 1\n }\n\n val l1 = v1.toList.sortBy(_._2).reverse.take(2)\n val l2 = v2.toList.sortBy(_._2).reverse.take(2)\n if (l1(0)._1 == l2(0)._1) {\n if (l1.length > 1) {\n val m1 = n - l1(0)._2 - l2(1)._2\n val m2 = n - l1(1)._2 - l2(0)._2\n List(m1, m2).min.toString\n } else (n / 2).toString\n } else {\n (n - l1(0)._2 - l2(0)._2).toString\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1538271161, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s550988949.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s550988949", "user_id": "u297767059"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.collection.mutable\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n def main(args: Array[String]) {\n val result = solve(new Scanner(System.in))\n if (result.length > 0) println(result)\n }\n\n def solve(in: String): String = solve(new Scanner(in))\n\n def solve(sc: Scanner): String = {\n val n = sc.nextInt\n val v1 = new mutable.HashMap[Int, Int]()\n val v2 = new mutable.HashMap[Int, Int]()\n for (i <- 0 until n / 2) {\n val k1 = sc.nextInt\n v1(k1) = v1.getOrElse(k1, 0) + 1\n val k2 = sc.nextInt\n v2(k2) = v2.getOrElse(k2, 0) + 1\n }\n\n val l1 = v1.toList.sortBy(_._2).reverse.take(2)\n val l2 = v2.toList.sortBy(_._2).reverse.take(2)\n if (l1(0)._1 == l2(0)._1) {\n if (l1.length > 1) {\n val m1 = n - l1(0)._2 - l2(1)._2\n val m2 = n - l1(1)._2 - l2(0)._2\n List(m1, m2).min.toString\n } else (n / 2).toString\n } else {\n (n - l1(0)._2 - l2(0)._2).toString\n }\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 997, "cpu_time_ms": 1006, "memory_kb": 54844}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s394155017", "group_id": "codeNet:p03252", "input_text": "import scala.util.control.Breaks._\n\nobject Main extends App {\n val s = scala.io.StdIn.readLine()\n val t = scala.io.StdIn.readLine()\n\n var memo = Map[Char, Char]()\n\n breakable {\n s.zip(t)\n .foreach({\n case (x, y) =>\n if (memo.isDefinedAt(x)) {\n if (memo(x) != y) {\n println(\"No\")\n break()\n }\n } else {\n memo += (x -> y)\n }\n })\n\n if (memo.values.size == memo.values.toList.distinct.size) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1585956832, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s394155017.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s394155017", "user_id": "u393913844"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.util.control.Breaks._\n\nobject Main extends App {\n val s = scala.io.StdIn.readLine()\n val t = scala.io.StdIn.readLine()\n\n var memo = Map[Char, Char]()\n\n breakable {\n s.zip(t)\n .foreach({\n case (x, y) =>\n if (memo.isDefinedAt(x)) {\n if (memo(x) != y) {\n println(\"No\")\n break()\n }\n } else {\n memo += (x -> y)\n }\n })\n\n if (memo.values.size == memo.values.toList.distinct.size) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n }\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 567, "cpu_time_ms": 525, "memory_kb": 42148}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s795872485", "group_id": "codeNet:p03252", "input_text": "import scala.util.control.Breaks._\n\nobject Main extends App {\n val s = scala.io.StdIn.readLine()\n val t = scala.io.StdIn.readLine()\n\n var memo = Map[Char, Char]()\n var never = Map[Char, Boolean]()\n\n breakable {\n s.zip(t)\n .foreach({\n case (x, y) =>\n memo += (x -> y)\n })\n\n if (memo.values.size == memo.values.toList.distinct.size) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1585956369, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s795872485.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s795872485", "user_id": "u393913844"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.util.control.Breaks._\n\nobject Main extends App {\n val s = scala.io.StdIn.readLine()\n val t = scala.io.StdIn.readLine()\n\n var memo = Map[Char, Char]()\n var never = Map[Char, Boolean]()\n\n breakable {\n s.zip(t)\n .foreach({\n case (x, y) =>\n memo += (x -> y)\n })\n\n if (memo.values.size == memo.values.toList.distinct.size) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n }\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 436, "cpu_time_ms": 586, "memory_kb": 53348}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s901463686", "group_id": "codeNet:p03252", "input_text": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val S, T = sc.nextLine()\n val to = scala.collection.mutable.Map.empty[Char, Char]\n val res = S.zip(T).forall { case (s, t) =>\n if (to.contains(s)) {\n to(s) == t\n } else {\n to.put(s, t)\n true\n }\n }\n println(if (res) \"Yes\" else \"No\")\n }\n\n}", "language": "Scala", "metadata": {"date": 1564024058, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s901463686.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s901463686", "user_id": "u891387249"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val S, T = sc.nextLine()\n val to = scala.collection.mutable.Map.empty[Char, Char]\n val res = S.zip(T).forall { case (s, t) =>\n if (to.contains(s)) {\n to(s) == t\n } else {\n to.put(s, t)\n true\n }\n }\n println(if (res) \"Yes\" else \"No\")\n }\n\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 592, "memory_kb": 40336}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s647204672", "group_id": "codeNet:p03252", "input_text": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val s = in.readLine\n val t = in.readLine\n\n val n = 'z'-'a' + 1\n val ts = Array.fill(n)(-1)\n val tt = Array.fill(n)(-1)\n\n val isPosi = (0 until s.size).forall(i => {\n val a = s(i) - 'a'\n val b = t(i) - 'a'\n if(ts(a) != -1 || tt(b) != -1) {\n if(ts(a) != b || tt(b) != a) false\n else true\n }\n else {\n ts(a) = b\n tt(b) = a\n true\n }\n })\n\n val ans = if(isPosi) \"Yes\" else \"No\"\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1551647542, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s647204672.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s647204672", "user_id": "u217010036"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val s = in.readLine\n val t = in.readLine\n\n val n = 'z'-'a' + 1\n val ts = Array.fill(n)(-1)\n val tt = Array.fill(n)(-1)\n\n val isPosi = (0 until s.size).forall(i => {\n val a = s(i) - 'a'\n val b = t(i) - 'a'\n if(ts(a) != -1 || tt(b) != -1) {\n if(ts(a) != b || tt(b) != a) false\n else true\n }\n else {\n ts(a) = b\n tt(b) = a\n true\n }\n })\n\n val ans = if(isPosi) \"Yes\" else \"No\"\n println(ans)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 496, "cpu_time_ms": 438, "memory_kb": 31372}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s693823908", "group_id": "codeNet:p03253", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n,m = sc.nextInt\n\n val mod = 1000000007\n\n def plus(a: Long, b: Long): Long = (a+b) % mod\n def minus(a: Long, b: Long): Long = (a-b+mod) % mod\n def times(a: Long, b: Long): Long = (a*b) % mod\n\n def pow(a: Long, n: Int): Long = {\n def pow(a: Long, n: Int, res: Long): Long = {\n if (n == 0) res\n else if ((n&1) == 0) pow(times(a,a),n >> 1,res)\n else pow(times(a,a),n >> 1,times(a,res))\n }\n pow(a,n,1L)\n }\n\n def inv(a: Long): Long = pow(a,mod-2)\n def div(a: Long, b: Long): Long = times(a,inv(b))\n\n\n def factorize(n: Int): List[Int] = {\n if (n == 1) Nil\n else {\n var i = 2\n var d = 0\n while (i*i <= n && d == 0) {\n if (n % i == 0) d = i\n i += 1\n }\n if (d == 0) List(n) else d::factorize(n/d)\n }\n }\n\n if (m == 1) println(1)\n else {\n val f = factorize(m)\n val bs = f.toSet.toList.map((x: Int) => f.count(_ == x))\n\n val l = bs.max + n - 1\n\n def factTable(n: Int): IndexedSeq[Long] = {\n (1 to n).scanLeft(1L)(times(_,_))\n }\n\n val fact = factTable(l)\n\n def factInvTable(n: Int): IndexedSeq[Long] = {\n (1 to n).scanRight(inv(fact(n)))(times(_,_))\n }\n\n val factInv = factInvTable(l)\n\n def comb(n: Int, k: Int): Long = {\n times(times(fact(n), factInv(k)), factInv(n-k))\n }\n\n println(bs.map(b => comb(b+n-1, b)).reduceLeft(times(_,_)))\n }\n}\n", "language": "Scala", "metadata": {"date": 1538337280, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s693823908.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s693823908", "user_id": "u191819389"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n,m = sc.nextInt\n\n val mod = 1000000007\n\n def plus(a: Long, b: Long): Long = (a+b) % mod\n def minus(a: Long, b: Long): Long = (a-b+mod) % mod\n def times(a: Long, b: Long): Long = (a*b) % mod\n\n def pow(a: Long, n: Int): Long = {\n def pow(a: Long, n: Int, res: Long): Long = {\n if (n == 0) res\n else if ((n&1) == 0) pow(times(a,a),n >> 1,res)\n else pow(times(a,a),n >> 1,times(a,res))\n }\n pow(a,n,1L)\n }\n\n def inv(a: Long): Long = pow(a,mod-2)\n def div(a: Long, b: Long): Long = times(a,inv(b))\n\n\n def factorize(n: Int): List[Int] = {\n if (n == 1) Nil\n else {\n var i = 2\n var d = 0\n while (i*i <= n && d == 0) {\n if (n % i == 0) d = i\n i += 1\n }\n if (d == 0) List(n) else d::factorize(n/d)\n }\n }\n\n if (m == 1) println(1)\n else {\n val f = factorize(m)\n val bs = f.toSet.toList.map((x: Int) => f.count(_ == x))\n\n val l = bs.max + n - 1\n\n def factTable(n: Int): IndexedSeq[Long] = {\n (1 to n).scanLeft(1L)(times(_,_))\n }\n\n val fact = factTable(l)\n\n def factInvTable(n: Int): IndexedSeq[Long] = {\n (1 to n).scanRight(inv(fact(n)))(times(_,_))\n }\n\n val factInv = factInvTable(l)\n\n def comb(n: Int, k: Int): Long = {\n times(times(fact(n), factInv(k)), factInv(n-k))\n }\n\n println(bs.map(b => comb(b+n-1, b)).reduceLeft(times(_,_)))\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1440, "cpu_time_ms": 500, "memory_kb": 41312}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s093354406", "group_id": "codeNet:p03263", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n solve\n }\n\n def solve(): Unit = {\n val sc = new java.util.Scanner(System.in)\n val h, w = sc.nextInt\n val m = Array.fill(h, w)(0)\n for (i <- 0 until h; j <- 0 until w) {\n m(i)(j) = sc.nextInt\n }\n\n // 下右 だけでいいのかな。。。\n val DI = Array(1, 0)\n val DJ = Array(0, 1)\n\n val pw = new java.io.PrintWriter(System.out)\n for (i <- 0 until h; j <- 0 until w) {\n val n = m(i)(j)\n if (n % 2 != 0) {\n // 奇数だったら配る\n var delivered = false\n var dIndex = 0\n while (!delivered && dIndex < 2) {\n val ni = i + DI(dIndex)\n val nj = j + DJ(dIndex)\n if (ni >= 0 && ni < h && nj >= 0 && nj < w) {\n val nn = m(ni)(nj)\n pw.println(s\"${i + 1} ${j + 1} ${ni + 1} ${nj + 1}\")\n\n m(i)(j) -= 1\n m(ni)(nj) += 1\n\n delivered = true\n }\n dIndex += 1\n }\n }\n }\n\n pw.flush()\n }\n}\n", "language": "Scala", "metadata": {"date": 1581435220, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s093354406.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s093354406", "user_id": "u433254839"}, "prompt_components": {"gold_output": "3\n2 2 2 3\n1 1 1 2\n1 3 1 2\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n solve\n }\n\n def solve(): Unit = {\n val sc = new java.util.Scanner(System.in)\n val h, w = sc.nextInt\n val m = Array.fill(h, w)(0)\n for (i <- 0 until h; j <- 0 until w) {\n m(i)(j) = sc.nextInt\n }\n\n // 下右 だけでいいのかな。。。\n val DI = Array(1, 0)\n val DJ = Array(0, 1)\n\n val pw = new java.io.PrintWriter(System.out)\n for (i <- 0 until h; j <- 0 until w) {\n val n = m(i)(j)\n if (n % 2 != 0) {\n // 奇数だったら配る\n var delivered = false\n var dIndex = 0\n while (!delivered && dIndex < 2) {\n val ni = i + DI(dIndex)\n val nj = j + DJ(dIndex)\n if (ni >= 0 && ni < h && nj >= 0 && nj < w) {\n val nn = m(ni)(nj)\n pw.println(s\"${i + 1} ${j + 1} ${ni + 1} ${nj + 1}\")\n\n m(i)(j) -= 1\n m(ni)(nj) += 1\n\n delivered = true\n }\n dIndex += 1\n }\n }\n }\n\n pw.flush()\n }\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1028, "cpu_time_ms": 1337, "memory_kb": 113656}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s209298151", "group_id": "codeNet:p03265", "input_text": "// B - Ruined Square\n// https://abc108.contest.atcoder.jp/tasks/abc108_b\n\nimport scala.io.StdIn.readLine\n\nobject Main extends App {\n\n val Array(x1, y1, x2, y2) = readLine.split(\" \").map(_.toInt)\n\n val vec = (x2 - x1, y2 - y1)\n\n def nextVec(d: (Int, Int)): (Int, Int) = (-d._2, d._1)\n def add(a: (Int, Int), b: (Int, Int)): (Int, Int) = (a._1 + b._1, a._2 + b._2)\n\n val vec2 = nextVec(vec)\n val (x3, y3) = add((x2, y2), vec2)\n\n val vec3 = nextVec(vec2)\n val (x4, y4) = add((x3, y3), vec3)\n\n println(List(x3, y3, x4, y4).mkString(\" \"))\n\n}", "language": "Scala", "metadata": {"date": 1537596669, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s209298151.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s209298151", "user_id": "u212517806"}, "prompt_components": {"gold_output": "-1 1 -1 0\n", "input_to_evaluate": "// B - Ruined Square\n// https://abc108.contest.atcoder.jp/tasks/abc108_b\n\nimport scala.io.StdIn.readLine\n\nobject Main extends App {\n\n val Array(x1, y1, x2, y2) = readLine.split(\" \").map(_.toInt)\n\n val vec = (x2 - x1, y2 - y1)\n\n def nextVec(d: (Int, Int)): (Int, Int) = (-d._2, d._1)\n def add(a: (Int, Int), b: (Int, Int)): (Int, Int) = (a._1 + b._1, a._2 + b._2)\n\n val vec2 = nextVec(vec)\n val (x3, y3) = add((x2, y2), vec2)\n\n val vec3 = nextVec(vec2)\n val (x4, y4) = add((x3, y3), vec3)\n\n println(List(x3, y3, x4, y4).mkString(\" \"))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 328, "memory_kb": 25668}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s349139576", "group_id": "codeNet:p03266", "input_text": "// C - Triangular Relationship\n// https://abc108.contest.atcoder.jp/tasks/arc102_a\n\nimport scala.io.StdIn.readLine\n\nobject Main extends App {\n\n val Array(n, k) = readLine.split(\" \").map(_.toInt)\n\n val (same: Int, diff: Int) = if (k%2 == 0) {\n val same = 2 * n / k\n val diff = if (n%2 == 0) same * (same - 2) / 4\n else ((same-2)/2+1)*((same-2)/2+1) \n (same, diff)\n } else {\n val same = n / k\n val diff = same * (same - 1) / 2\n (same, diff)\n }\n\n val ans = same + (diff * 6)\n\n println(ans)\n\n}\n", "language": "Scala", "metadata": {"date": 1537776882, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s349139576.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s349139576", "user_id": "u212517806"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "// C - Triangular Relationship\n// https://abc108.contest.atcoder.jp/tasks/arc102_a\n\nimport scala.io.StdIn.readLine\n\nobject Main extends App {\n\n val Array(n, k) = readLine.split(\" \").map(_.toInt)\n\n val (same: Int, diff: Int) = if (k%2 == 0) {\n val same = 2 * n / k\n val diff = if (n%2 == 0) same * (same - 2) / 4\n else ((same-2)/2+1)*((same-2)/2+1) \n (same, diff)\n } else {\n val same = n / k\n val diff = same * (same - 1) / 2\n (same, diff)\n }\n\n val ans = same + (diff * 6)\n\n println(ans)\n\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 325, "memory_kb": 27088}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s505414118", "group_id": "codeNet:p03270", "input_text": "object Main {\n import java.io._\n import java.util.StringTokenizer\n\n import scala.collection.mutable\n import scala.util.Sorting\n import math.{abs, max, min}\n import mutable.{ArrayBuffer, ListBuffer}\n import scala.reflect.ClassTag\n\n val MOD = 998244353\n val out = new PrintWriter(System.out)\n\n def solve(): Unit = {\n val K, N = ni()\n\n def powMod(x: Int, n: Int, m: Int): Int = {\n def step(x: Long, n: Int, stack: Long): Long = {\n n match {\n case 0 => stack\n case _ => step(x * x % m, n / 2, if (n % 2 == 1) stack * x % m else stack)\n }\n }\n step(x, n, 1).toInt\n }\n\n val NN = N * 2\n val F = Array.ofDim[Long](NN + 1)\n F(0) = 1\n rep(NN) { i =>\n F(i + 1) = F(i) * (i + 1) % MOD\n }\n val I = Array.ofDim[Long](F.length)\n I(NN) = powMod(F(NN).toInt, MOD - 2, MOD)\n\n // x! = x(x-1)!\n // x!I(x!) ≡ (x-1)!I((x-1)!)\n // I((x-1)!) ≡ I(x!) * x MODがでかいので(x-1)!はMODと素\n rep_r(NN) { i =>\n I(i) = I(i + 1) * (i + 1) % MOD\n }\n\n def comb(n: Int, k: Int): Long = {\n if (n < k) 0\n else F(n) * I(n - k) % MOD * I(k) % MOD\n }\n\n def g(n: Int) = {\n if (n <= 0) 0L\n else comb(n + K - 1, K - 1)\n }\n\n rep(2 * K - 1, 2) { i =>\n val pairs = min(i / 2, (2 * K - i) / 2 + 1)\n var res = g(N)\n rep(pairs, 1) { j =>\n val sign = if ((j & 1) == 1) -1 else 1\n res += sign * comb(pairs, j) * g(N - 2 * j) % MOD\n }\n out.println((MOD + res % MOD) % MOD)\n }\n }\n\n def main(args: Array[String]): Unit = {\n solve()\n out.flush()\n }\n\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next().toInt\n def nextLong(): Long = next().toLong\n def nextChar(): Char = next().charAt(0)\n }\n val sc = new InputReader(System.in)\n def ni(): Int = sc.nextInt()\n def nl(): Long = sc.nextLong()\n def nc(): Char = sc.nextChar()\n def ns(): String = sc.next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int): Array[Int] = map(n)(_ => ni())\n def nm(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n\n def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n rep(n)(i => res(i) = f(i))\n res\n }\n\n implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {\n // todo Orderingだとboxing発生するので自作Orderを用意したい\n def maxByOpt[B: Ordering](f: A => B): Option[A] = {\n if (as.nonEmpty) Some(as.maxBy(f)) else None\n }\n\n def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {\n val map = mutable.Map.empty[K, ArrayBuffer[A]]\n rep(as.length)(i => map.getOrElseUpdate(f(as(i)), ArrayBuffer()) += as(i))\n map\n }\n\n def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {\n var sum = num.zero\n rep(as.length)(i => sum = num.plus(sum, f(as(i))))\n sum\n }\n\n def minByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {\n limit(f, ixRange)(cmp.lt)\n }\n\n def maxByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {\n limit(f, ixRange)(cmp.gt)\n }\n\n private def limit[B](f: A => B, ixRange: Range)(cmp: (B, B) => Boolean): (A, B) = {\n var limA = as(ixRange.head)\n var limB = f(limA)\n\n for (i <- ixRange.tail) {\n val a = as(i)\n val b = f(a)\n if (cmp(b, limB)) {\n limA = a\n limB = b\n }\n }\n (limA, limB)\n }\n }\n\n implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {\n def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {\n as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))\n }\n }\n}", "language": "Scala", "metadata": {"date": 1536034649, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03270.html", "problem_id": "p03270", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03270/input.txt", "sample_output_relpath": "derived/input_output/data/p03270/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03270/Scala/s505414118.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s505414118", "user_id": "u460609472"}, "prompt_components": {"gold_output": "7\n7\n4\n7\n7\n", "input_to_evaluate": "object Main {\n import java.io._\n import java.util.StringTokenizer\n\n import scala.collection.mutable\n import scala.util.Sorting\n import math.{abs, max, min}\n import mutable.{ArrayBuffer, ListBuffer}\n import scala.reflect.ClassTag\n\n val MOD = 998244353\n val out = new PrintWriter(System.out)\n\n def solve(): Unit = {\n val K, N = ni()\n\n def powMod(x: Int, n: Int, m: Int): Int = {\n def step(x: Long, n: Int, stack: Long): Long = {\n n match {\n case 0 => stack\n case _ => step(x * x % m, n / 2, if (n % 2 == 1) stack * x % m else stack)\n }\n }\n step(x, n, 1).toInt\n }\n\n val NN = N * 2\n val F = Array.ofDim[Long](NN + 1)\n F(0) = 1\n rep(NN) { i =>\n F(i + 1) = F(i) * (i + 1) % MOD\n }\n val I = Array.ofDim[Long](F.length)\n I(NN) = powMod(F(NN).toInt, MOD - 2, MOD)\n\n // x! = x(x-1)!\n // x!I(x!) ≡ (x-1)!I((x-1)!)\n // I((x-1)!) ≡ I(x!) * x MODがでかいので(x-1)!はMODと素\n rep_r(NN) { i =>\n I(i) = I(i + 1) * (i + 1) % MOD\n }\n\n def comb(n: Int, k: Int): Long = {\n if (n < k) 0\n else F(n) * I(n - k) % MOD * I(k) % MOD\n }\n\n def g(n: Int) = {\n if (n <= 0) 0L\n else comb(n + K - 1, K - 1)\n }\n\n rep(2 * K - 1, 2) { i =>\n val pairs = min(i / 2, (2 * K - i) / 2 + 1)\n var res = g(N)\n rep(pairs, 1) { j =>\n val sign = if ((j & 1) == 1) -1 else 1\n res += sign * comb(pairs, j) * g(N - 2 * j) % MOD\n }\n out.println((MOD + res % MOD) % MOD)\n }\n }\n\n def main(args: Array[String]): Unit = {\n solve()\n out.flush()\n }\n\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next().toInt\n def nextLong(): Long = next().toLong\n def nextChar(): Char = next().charAt(0)\n }\n val sc = new InputReader(System.in)\n def ni(): Int = sc.nextInt()\n def nl(): Long = sc.nextLong()\n def nc(): Char = sc.nextChar()\n def ns(): String = sc.next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int): Array[Int] = map(n)(_ => ni())\n def nm(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n\n def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n rep(n)(i => res(i) = f(i))\n res\n }\n\n implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {\n // todo Orderingだとboxing発生するので自作Orderを用意したい\n def maxByOpt[B: Ordering](f: A => B): Option[A] = {\n if (as.nonEmpty) Some(as.maxBy(f)) else None\n }\n\n def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {\n val map = mutable.Map.empty[K, ArrayBuffer[A]]\n rep(as.length)(i => map.getOrElseUpdate(f(as(i)), ArrayBuffer()) += as(i))\n map\n }\n\n def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {\n var sum = num.zero\n rep(as.length)(i => sum = num.plus(sum, f(as(i))))\n sum\n }\n\n def minByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {\n limit(f, ixRange)(cmp.lt)\n }\n\n def maxByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {\n limit(f, ixRange)(cmp.gt)\n }\n\n private def limit[B](f: A => B, ixRange: Range)(cmp: (B, B) => Boolean): (A, B) = {\n var limA = as(ixRange.head)\n var limB = f(limA)\n\n for (i <- ixRange.tail) {\n val a = as(i)\n val b = f(a)\n if (cmp(b, limB)) {\n limA = a\n limB = b\n }\n }\n (limA, limB)\n }\n }\n\n implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {\n def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {\n as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))\n }\n }\n}", "problem_context": "Score : 700 points\n\nProblem Statement\n\nTakahashi throws N dice, each having K sides with all integers from 1 to K. The dice are NOT pairwise distinguishable.\nFor each i=2,3,...,2K, find the following value modulo 998244353:\n\nThe number of combinations of N sides shown by the dice such that the sum of no two different sides is i.\n\nNote that the dice are NOT distinguishable, that is, two combinations are considered different when there exists an integer k such that the number of dice showing k is different in those two.\n\nConstraints\n\n1 \\leq K \\leq 2000\n\n2 \\leq N \\leq 2000\n\nK and N are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK N\n\nOutput\n\nPrint 2K-1 integers. The t-th of them (1\\leq t\\leq 2K-1) should be the answer for i=t+1.\n\nSample Input 1\n\n3 3\n\nSample Output 1\n\n7\n7\n4\n7\n7\n\nFor i=2, the combinations (1,2,2),(1,2,3),(1,3,3),(2,2,2),(2,2,3),(2,3,3),(3,3,3) satisfy the condition, so the answer is 7.\n\nFor i=3, the combinations (1,1,1),(1,1,3),(1,3,3),(2,2,2),(2,2,3),(2,3,3),(3,3,3) satisfy the condition, so the answer is 7.\n\nFor i=4, the combinations (1,1,1),(1,1,2),(2,3,3),(3,3,3) satisfy the condition, so the answer is 4.\n\nSample Input 2\n\n4 5\n\nSample Output 2\n\n36\n36\n20\n20\n20\n36\n36\n\nSample Input 3\n\n6 1000\n\nSample Output 3\n\n149393349\n149393349\n668669001\n668669001\n4000002\n4000002\n4000002\n668669001\n668669001\n149393349\n149393349", "sample_input": "3 3\n"}, "reference_outputs": ["7\n7\n4\n7\n7\n"], "source_document_id": "p03270", "source_text": "Score : 700 points\n\nProblem Statement\n\nTakahashi throws N dice, each having K sides with all integers from 1 to K. The dice are NOT pairwise distinguishable.\nFor each i=2,3,...,2K, find the following value modulo 998244353:\n\nThe number of combinations of N sides shown by the dice such that the sum of no two different sides is i.\n\nNote that the dice are NOT distinguishable, that is, two combinations are considered different when there exists an integer k such that the number of dice showing k is different in those two.\n\nConstraints\n\n1 \\leq K \\leq 2000\n\n2 \\leq N \\leq 2000\n\nK and N are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK N\n\nOutput\n\nPrint 2K-1 integers. The t-th of them (1\\leq t\\leq 2K-1) should be the answer for i=t+1.\n\nSample Input 1\n\n3 3\n\nSample Output 1\n\n7\n7\n4\n7\n7\n\nFor i=2, the combinations (1,2,2),(1,2,3),(1,3,3),(2,2,2),(2,2,3),(2,3,3),(3,3,3) satisfy the condition, so the answer is 7.\n\nFor i=3, the combinations (1,1,1),(1,1,3),(1,3,3),(2,2,2),(2,2,3),(2,3,3),(3,3,3) satisfy the condition, so the answer is 7.\n\nFor i=4, the combinations (1,1,1),(1,1,2),(2,3,3),(3,3,3) satisfy the condition, so the answer is 4.\n\nSample Input 2\n\n4 5\n\nSample Output 2\n\n36\n36\n20\n20\n20\n36\n36\n\nSample Input 3\n\n6 1000\n\nSample Output 3\n\n149393349\n149393349\n668669001\n668669001\n4000002\n4000002\n4000002\n668669001\n668669001\n149393349\n149393349", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4291, "cpu_time_ms": 500, "memory_kb": 25948}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s214391116", "group_id": "codeNet:p03272", "input_text": "object Main extends App {\n val ln1 = io.StdIn.readLine.split(' ').map(_.toInt)\n\n val N = ln1(0)\n val i = ln1(1)\n\n val out = (N - i) + 1\n\n println(out)\n}", "language": "Scala", "metadata": {"date": 1556414742, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03272.html", "problem_id": "p03272", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03272/input.txt", "sample_output_relpath": "derived/input_output/data/p03272/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03272/Scala/s214391116.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s214391116", "user_id": "u620456020"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main extends App {\n val ln1 = io.StdIn.readLine.split(' ').map(_.toInt)\n\n val N = ln1(0)\n val i = ln1(1)\n\n val out = (N - i) + 1\n\n println(out)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is an N-car train.\n\nYou are given an integer i. Find the value of j such that the following statement is true: \"the i-th car from the front of the train is the j-th car from the back.\"\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN i\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4 2\n\nSample Output 1\n\n3\n\nThe second car from the front of a 4-car train is the third car from the back.\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n15 11\n\nSample Output 3\n\n5", "sample_input": "4 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03272", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is an N-car train.\n\nYou are given an integer i. Find the value of j such that the following statement is true: \"the i-th car from the front of the train is the j-th car from the back.\"\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN i\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4 2\n\nSample Output 1\n\n3\n\nThe second car from the front of a 4-car train is the third car from the back.\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n15 11\n\nSample Output 3\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 342, "memory_kb": 27460}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s737713712", "group_id": "codeNet:p03274", "input_text": "import java.io.{InputStream, OutputStream, PrintStream}\nimport java.util.Scanner\n\nimport scala.annotation.tailrec\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n val solver = new Solver(System.in, System.out)\n solver.solve()\n }\n\n class Solver(in: InputStream, out: OutputStream) {\n lazy val input = new Scanner(in)\n\n lazy val output = new PrintStream(out)\n\n def solve(): Unit = {\n val Array(n, k) = input.nextLine().split(\" \").map(_.toInt)\n val xs = input.nextLine().split(\" \").map(_.toInt)\n\n output.println(\n solve(\n xs.filter(_ < 0).map(_ * -1).reverse,\n xs.filter(_ >= 0),\n k)\n )\n }\n\n def solve(lefts: Array[Int], rights: Array[Int], k: Int): Int = {\n var leftPos, rightPos = 0\n var leftIdx, rightIdx = 0\n var foundCount = 0\n\n if (rights.headOption.getOrElse(-1) == 0) {\n foundCount += 1\n }\n\n if (foundCount >= k) {\n return 0\n }\n\n 1.to(Math.pow(10, 8).toInt).foreach { i =>\n if (rights.applyOrElse(rightIdx, (_: Int) => -1) == i) {\n rightPos = i\n rightIdx += 1\n foundCount += 1\n }\n\n if (foundCount >= k) {\n val min = leftPos.min(rightPos)\n val max = leftPos.max(rightPos)\n return min * 2 + max\n }\n\n if (lefts.applyOrElse(leftIdx, (_: Int) => -1) == i) {\n leftPos = i\n leftIdx += 1\n foundCount += 1\n }\n\n if (foundCount >= k) {\n val min = leftPos.min(rightPos)\n val max = leftPos.max(rightPos)\n return min * 2 + max\n }\n }\n\n 0\n }\n\n @tailrec\n final def gcd(m: Int, n: Int): Int = {\n val (x, y) = if (m > n) (m, n) else (n, m)\n if (y != 0) gcd(y, x % y)\n else x\n }\n\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1547699256, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s737713712.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s737713712", "user_id": "u299987045"}, "prompt_components": {"gold_output": "40\n", "input_to_evaluate": "import java.io.{InputStream, OutputStream, PrintStream}\nimport java.util.Scanner\n\nimport scala.annotation.tailrec\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n val solver = new Solver(System.in, System.out)\n solver.solve()\n }\n\n class Solver(in: InputStream, out: OutputStream) {\n lazy val input = new Scanner(in)\n\n lazy val output = new PrintStream(out)\n\n def solve(): Unit = {\n val Array(n, k) = input.nextLine().split(\" \").map(_.toInt)\n val xs = input.nextLine().split(\" \").map(_.toInt)\n\n output.println(\n solve(\n xs.filter(_ < 0).map(_ * -1).reverse,\n xs.filter(_ >= 0),\n k)\n )\n }\n\n def solve(lefts: Array[Int], rights: Array[Int], k: Int): Int = {\n var leftPos, rightPos = 0\n var leftIdx, rightIdx = 0\n var foundCount = 0\n\n if (rights.headOption.getOrElse(-1) == 0) {\n foundCount += 1\n }\n\n if (foundCount >= k) {\n return 0\n }\n\n 1.to(Math.pow(10, 8).toInt).foreach { i =>\n if (rights.applyOrElse(rightIdx, (_: Int) => -1) == i) {\n rightPos = i\n rightIdx += 1\n foundCount += 1\n }\n\n if (foundCount >= k) {\n val min = leftPos.min(rightPos)\n val max = leftPos.max(rightPos)\n return min * 2 + max\n }\n\n if (lefts.applyOrElse(leftIdx, (_: Int) => -1) == i) {\n leftPos = i\n leftIdx += 1\n foundCount += 1\n }\n\n if (foundCount >= k) {\n val min = leftPos.min(rightPos)\n val max = leftPos.max(rightPos)\n return min * 2 + max\n }\n }\n\n 0\n }\n\n @tailrec\n final def gcd(m: Int, n: Int): Int = {\n val (x, y) = if (m > n) (m, n) else (n, m)\n if (y != 0) gcd(y, x % y)\n else x\n }\n\n }\n\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1975, "memory_kb": 122496}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s632050730", "group_id": "codeNet:p03274", "input_text": "// C - Candles\n// https://abc107.contest.atcoder.jp/tasks/arc101_a\n\nimport scala.io.StdIn.readLine\n\nobject Main extends App {\n\n val Array(n, k) = readLine.split(\" \").map(_.toInt)\n val xs: Array[Int] = readLine.split(\" \").map(_.toInt)\n\n val edges: List[(Int, Int)] = List.range(0, n-k).map(i => (xs(i), xs(i+k-1)))\n\n val lengths = edges.map(edge => {\n val left = edge._1\n val right = edge._2\n val ltor = Math.abs(left) + Math.abs(right - left)\n val rtol = Math.abs(right) + Math.abs(right - left)\n\n Math.min(ltor, rtol)\n })\n\n val length = if (lengths.length > 0) lengths.min else 0\n\n println(length)\n\n}", "language": "Scala", "metadata": {"date": 1536991127, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s632050730.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s632050730", "user_id": "u212517806"}, "prompt_components": {"gold_output": "40\n", "input_to_evaluate": "// C - Candles\n// https://abc107.contest.atcoder.jp/tasks/arc101_a\n\nimport scala.io.StdIn.readLine\n\nobject Main extends App {\n\n val Array(n, k) = readLine.split(\" \").map(_.toInt)\n val xs: Array[Int] = readLine.split(\" \").map(_.toInt)\n\n val edges: List[(Int, Int)] = List.range(0, n-k).map(i => (xs(i), xs(i+k-1)))\n\n val lengths = edges.map(edge => {\n val left = edge._1\n val right = edge._2\n val ltor = Math.abs(left) + Math.abs(right - left)\n val rtol = Math.abs(right) + Math.abs(right - left)\n\n Math.min(ltor, rtol)\n })\n\n val length = if (lengths.length > 0) lengths.min else 0\n\n println(length)\n\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 625, "cpu_time_ms": 671, "memory_kb": 42440}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s454974230", "group_id": "codeNet:p03274", "input_text": "object Main extends App {\n val Array(_, numFires) = io.StdIn.readLine().split(' ').map(_.toInt)\n val candles = io.StdIn.readLine().split(' ').map(_.toInt)\n\n val distanceCounter = new DistanceCounter\n println(distanceCounter.countMinDistance(candles, numFires))\n}\n\n\nclass DistanceCounter {\n \n def countMinDistance(candlePositions: Seq[Int], numFires: Int): Int = {\n var negatives: List[Int] = Nil\n var positives: List[Int] = Nil\n\n for(position <- candlePositions) {\n if (position < 0) negatives = position :: negatives\n else positives = position :: positives\n }\n positives = positives.reverse\n\n return minDistance(Nil, negatives, positives, numFires)\n\n }\n\n /**\n * 最小ルートを計算して返却\n * 末尾再帰になっていないので、大量データだとStackOverFlowが発生する。\n *\n */\n private def minDistance(routes: List[Int], negatives: Seq[Int], positives: Seq[Int], numFires: Int): Int = {\n // 火をつけたろうそくの数が要求と一致したら、距離を計算する\n if(routes.length == numFires) calcDistance(routes.reverse)\n else\n // 現在の一から右か左に行くパターンがあるので、それぞれのルートを辿る。\n // 終端まで行ったルートに関してはハズレなので、Intの最大値を返すことで正解ルートでないことを表す。\n Math.min(\n if (negatives.isEmpty) Int.MaxValue else minDistance(negatives.head :: routes , negatives.tail , positives , numFires) ,\n if (positives.isEmpty) Int.MaxValue else minDistance(positives.head :: routes , negatives , positives.tail , numFires) \n )\n }\n\n /**\n * 指定されたルートを通った時の距離を算出する\n */\n private def calcDistance(routes: Seq[Int]): Int = {\n var currentPosition = 0\n var distance = 0\n for(position <- routes) {\n distance = distance + Math.abs(position - currentPosition)\n currentPosition = position\n }\n distance\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1536264630, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s454974230.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s454974230", "user_id": "u216683960"}, "prompt_components": {"gold_output": "40\n", "input_to_evaluate": "object Main extends App {\n val Array(_, numFires) = io.StdIn.readLine().split(' ').map(_.toInt)\n val candles = io.StdIn.readLine().split(' ').map(_.toInt)\n\n val distanceCounter = new DistanceCounter\n println(distanceCounter.countMinDistance(candles, numFires))\n}\n\n\nclass DistanceCounter {\n \n def countMinDistance(candlePositions: Seq[Int], numFires: Int): Int = {\n var negatives: List[Int] = Nil\n var positives: List[Int] = Nil\n\n for(position <- candlePositions) {\n if (position < 0) negatives = position :: negatives\n else positives = position :: positives\n }\n positives = positives.reverse\n\n return minDistance(Nil, negatives, positives, numFires)\n\n }\n\n /**\n * 最小ルートを計算して返却\n * 末尾再帰になっていないので、大量データだとStackOverFlowが発生する。\n *\n */\n private def minDistance(routes: List[Int], negatives: Seq[Int], positives: Seq[Int], numFires: Int): Int = {\n // 火をつけたろうそくの数が要求と一致したら、距離を計算する\n if(routes.length == numFires) calcDistance(routes.reverse)\n else\n // 現在の一から右か左に行くパターンがあるので、それぞれのルートを辿る。\n // 終端まで行ったルートに関してはハズレなので、Intの最大値を返すことで正解ルートでないことを表す。\n Math.min(\n if (negatives.isEmpty) Int.MaxValue else minDistance(negatives.head :: routes , negatives.tail , positives , numFires) ,\n if (positives.isEmpty) Int.MaxValue else minDistance(positives.head :: routes , negatives , positives.tail , numFires) \n )\n }\n\n /**\n * 指定されたルートを通った時の距離を算出する\n */\n private def calcDistance(routes: Seq[Int]): Int = {\n var currentPosition = 0\n var distance = 0\n for(position <- routes) {\n distance = distance + Math.abs(position - currentPosition)\n currentPosition = position\n }\n distance\n }\n\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2029, "cpu_time_ms": 671, "memory_kb": 42204}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s894148012", "group_id": "codeNet:p03280", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val A, B = sc.nextInt() -1\n println(A * B)\n}\n", "language": "Scala", "metadata": {"date": 1596200369, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s894148012.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s894148012", "user_id": "u737111725"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val A, B = sc.nextInt() -1\n println(A * B)\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 479, "memory_kb": 55500}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s956727295", "group_id": "codeNet:p03281", "input_text": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val N = in.nextInt\n\n println(\n if (N < 3 * 5 * 7) 0\n else if (N < 3 * 5 * 11) 1\n else if (N < 3 * 5 * 13) 2\n else 3\n )\n}", "language": "Scala", "metadata": {"date": 1595355726, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03281.html", "problem_id": "p03281", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03281/input.txt", "sample_output_relpath": "derived/input_output/data/p03281/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03281/Scala/s956727295.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s956727295", "user_id": "u132324749"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val N = in.nextInt\n\n println(\n if (N < 3 * 5 * 7) 0\n else if (N < 3 * 5 * 11) 1\n else if (N < 3 * 5 * 13) 2\n else 3\n )\n}", "problem_context": "Score: 200 points\n\nProblem Statement\n\nThe number 105 is quite special - it is odd but still it has eight divisors.\nNow, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?\n\nConstraints\n\nN is an integer between 1 and 200 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the count.\n\nSample Input 1\n\n105\n\nSample Output 1\n\n1\n\nAmong the numbers between 1 and 105, the only number that is odd and has exactly eight divisors is 105.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n0\n\n1 has one divisor. 3, 5 and 7 are all prime and have two divisors. Thus, there is no number that satisfies the condition.", "sample_input": "105\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03281", "source_text": "Score: 200 points\n\nProblem Statement\n\nThe number 105 is quite special - it is odd but still it has eight divisors.\nNow, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?\n\nConstraints\n\nN is an integer between 1 and 200 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the count.\n\nSample Input 1\n\n105\n\nSample Output 1\n\n1\n\nAmong the numbers between 1 and 105, the only number that is odd and has exactly eight divisors is 105.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n0\n\n1 has one divisor. 3, 5 and 7 are all prime and have two divisors. Thus, there is no number that satisfies the condition.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 502, "memory_kb": 55324}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s187421648", "group_id": "codeNet:p03281", "input_text": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = println(solve(new Scanner(System.in)))\n\n def solve(in: String): String = solve(new Scanner(in))\n\n def solve(sc: Scanner): String = {\n// for (i <- 1 to 200 by 2) {\n// var cnt = 0\n// for (j <- 1 to i by 2) {\n// if (i % j == 0) cnt += 1\n// }\n// if (cnt == 8) println(i)\n// }\n\n val N = sc.nextInt\n val ans = Array(105, 135, 165, 189, 195)\n ans.count(_ <= N).toString\n }\n}\n", "language": "Scala", "metadata": {"date": 1534642496, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03281.html", "problem_id": "p03281", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03281/input.txt", "sample_output_relpath": "derived/input_output/data/p03281/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03281/Scala/s187421648.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s187421648", "user_id": "u297767059"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = println(solve(new Scanner(System.in)))\n\n def solve(in: String): String = solve(new Scanner(in))\n\n def solve(sc: Scanner): String = {\n// for (i <- 1 to 200 by 2) {\n// var cnt = 0\n// for (j <- 1 to i by 2) {\n// if (i % j == 0) cnt += 1\n// }\n// if (cnt == 8) println(i)\n// }\n\n val N = sc.nextInt\n val ans = Array(105, 135, 165, 189, 195)\n ans.count(_ <= N).toString\n }\n}\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nThe number 105 is quite special - it is odd but still it has eight divisors.\nNow, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?\n\nConstraints\n\nN is an integer between 1 and 200 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the count.\n\nSample Input 1\n\n105\n\nSample Output 1\n\n1\n\nAmong the numbers between 1 and 105, the only number that is odd and has exactly eight divisors is 105.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n0\n\n1 has one divisor. 3, 5 and 7 are all prime and have two divisors. Thus, there is no number that satisfies the condition.", "sample_input": "105\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03281", "source_text": "Score: 200 points\n\nProblem Statement\n\nThe number 105 is quite special - it is odd but still it has eight divisors.\nNow, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?\n\nConstraints\n\nN is an integer between 1 and 200 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the count.\n\nSample Input 1\n\n105\n\nSample Output 1\n\n1\n\nAmong the numbers between 1 and 105, the only number that is odd and has exactly eight divisors is 105.\n\nSample Input 2\n\n7\n\nSample Output 2\n\n0\n\n1 has one divisor. 3, 5 and 7 are all prime and have two divisors. Thus, there is no number that satisfies the condition.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 493, "cpu_time_ms": 346, "memory_kb": 25780}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s750525499", "group_id": "codeNet:p03282", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val S, K = sc.next()\n val i = S.indexWhere(_ != '1')\n println(if (i == -1 || K.toLong <= i) '1' else S(i))\n}\n", "language": "Scala", "metadata": {"date": 1593976159, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s750525499.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s750525499", "user_id": "u737111725"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val S, K = sc.next()\n val i = S.indexWhere(_ != '1')\n println(if (i == -1 || K.toLong <= i) '1' else S(i))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 183, "cpu_time_ms": 510, "memory_kb": 55400}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s051257866", "group_id": "codeNet:p03282", "input_text": "//import java.util.Scanner\n\nimport scala.collection.Searching._\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.immutable._\nimport scala.io.StdIn.readLine\n\nimport java.io._\nimport java.nio.file.{Files, Path}\nimport java.util.StringTokenizer\n\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(Files.newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext = current.hasNext\n\n @inline def next() = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close() = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(new Node(None, 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) => {\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n }\n}\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val S = sc.next()\n val N = sc.nextLong()\n println(if (S.takeWhile(_ == '1').size < N) (S.dropWhile(_ == '1').head) else ('1'))\n }\n\n def recursive(X: Long, primeList: Stream[Long]): Long = {\n val now = primeList.head\n if (X < now * now) (X) else {\n if (X % (now * now) == 0) (recursive(X / now / now, primeList))\n else if (X % now != 0) (recursive(X, primeList.tail))\n else (now * recursive(X / now, primeList.tail))\n }\n }\n\n def check(A: Long): Boolean = {\n if (A < 0) (check(-A)) else if (A % 10 == 0) (check(A / 10)) else (A < 10)\n }\n\n def shift(n: Long): Long = {\n if (n == 0) (0) else if (n == 1) (1) else (shift(n - 1) << 1)\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) (0) else (unShift(n >> 1) + 1)\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList(): Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: (Int) =?> String = {\n case src if (src >= 1 && src <= 3999) => {\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if (n == 0) => cont + unitChar\n case n if (n > 0) => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n }\n\n val romanToArabic: (String) =?> Int = {\n case src if (Option(src).exists { s => {\n s.nonEmpty && (\"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase) == None)\n }\n }) => {\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1535593786, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s051257866.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s051257866", "user_id": "u779353743"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "//import java.util.Scanner\n\nimport scala.collection.Searching._\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.immutable._\nimport scala.io.StdIn.readLine\n\nimport java.io._\nimport java.nio.file.{Files, Path}\nimport java.util.StringTokenizer\n\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/7018\n */\n\nclass Scanner(reader: LineNumberReader) extends Iterable[String] with AutoCloseable {\n def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n\n def this(reader: Reader) = this(new BufferedReader(reader))\n\n def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n\n def this(path: Path)(implicit codec: Codec) = this(Files.newBufferedReader(path, codec.charSet))\n\n def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n\n def this(str: String) = this(new StringReader(str))\n\n override def iterator = for {\n line <- Iterator.continually(reader.readLine()).takeWhile(_ != null)\n tokenizer = new StringTokenizer(line)\n tokens <- Iterator.continually(tokenizer).takeWhile(_.hasMoreTokens)\n } yield tokens.nextToken()\n\n private[this] var current = iterator\n\n def hasNext = current.hasNext\n\n @inline def next() = current.next()\n\n /**\n * This is different from Java's scanner.nextLine\n * The Java one is a misnomer since it actually travel to end of current line\n * This one actually does fetch the next line\n */\n def nextLine(): String = {\n val line = reader.readLine()\n current = iterator\n line\n }\n\n def lineNumber: Int = reader.getLineNumber\n\n def nextString(): String = next()\n\n def nextBoolean(): Boolean = next().toBoolean\n\n def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n\n def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n\n def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n\n def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n\n def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n\n def nextFloat(): Float = next().toFloat\n\n def nextDouble(): Double = next().toDouble\n\n def nextBigDecimal(): BigDecimal = BigDecimal(next())\n\n override def close() = reader.close()\n}\n\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(new Node(None, 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) => {\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n }\n}\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val S = sc.next()\n val N = sc.nextLong()\n println(if (S.takeWhile(_ == '1').size < N) (S.dropWhile(_ == '1').head) else ('1'))\n }\n\n def recursive(X: Long, primeList: Stream[Long]): Long = {\n val now = primeList.head\n if (X < now * now) (X) else {\n if (X % (now * now) == 0) (recursive(X / now / now, primeList))\n else if (X % now != 0) (recursive(X, primeList.tail))\n else (now * recursive(X / now, primeList.tail))\n }\n }\n\n def check(A: Long): Boolean = {\n if (A < 0) (check(-A)) else if (A % 10 == 0) (check(A / 10)) else (A < 10)\n }\n\n def shift(n: Long): Long = {\n if (n == 0) (0) else if (n == 1) (1) else (shift(n - 1) << 1)\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) (0) else (unShift(n >> 1) + 1)\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList(): Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: (Int) =?> String = {\n case src if (src >= 1 && src <= 3999) => {\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if (n == 0) => cont + unitChar\n case n if (n > 0) => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n }\n\n val romanToArabic: (String) =?> Int = {\n case src if (Option(src).exists { s => {\n s.nonEmpty && (\"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase) == None)\n }\n }) => {\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6051, "cpu_time_ms": 331, "memory_kb": 25420}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s131237144", "group_id": "codeNet:p03282", "input_text": "object Main extends App{\n val s = scala.io.StdIn.readLine.toList\n val t = scala.io.StdIn.readLong\n\n var i = 0\n\n while(i < s.size && s(i) == '1'){\n \ti += 1\n }\n\n println(s(i))\n}", "language": "Scala", "metadata": {"date": 1535512645, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s131237144.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s131237144", "user_id": "u675876401"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App{\n val s = scala.io.StdIn.readLine.toList\n val t = scala.io.StdIn.readLong\n\n var i = 0\n\n while(i < s.size && s(i) == '1'){\n \ti += 1\n }\n\n println(s(i))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 326, "memory_kb": 27196}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s880192318", "group_id": "codeNet:p03283", "input_text": "import java.util.Scanner\n\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n def main(args: Array[String]): Unit = println(solve(new Scanner(System.in)))\n\n def solve(in: String): String = solve(new Scanner(in))\n\n def solve(sc: Scanner): String = {\n val N = sc.nextInt\n val M = sc.nextInt\n val Q = sc.nextInt\n val LR = Array.fill(M)(sc.nextInt, sc.nextInt)\n val pq = Array.fill(Q)(sc.nextInt, sc.nextInt)\n\n val m = ArrayBuffer.fill(501)(ArrayBuffer.fill(501)(0))\n LR.foreach { case (l, r) =>\n m(l)(r) += 1\n }\n\n pq.map { case (p, q) =>\n (for (i <- p to q; j <- p to q) yield m(i)(j)).sum\n }.mkString(\"\\n\")\n }\n}\n", "language": "Scala", "metadata": {"date": 1534650106, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s880192318.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s880192318", "user_id": "u297767059"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n def main(args: Array[String]): Unit = println(solve(new Scanner(System.in)))\n\n def solve(in: String): String = solve(new Scanner(in))\n\n def solve(sc: Scanner): String = {\n val N = sc.nextInt\n val M = sc.nextInt\n val Q = sc.nextInt\n val LR = Array.fill(M)(sc.nextInt, sc.nextInt)\n val pq = Array.fill(Q)(sc.nextInt, sc.nextInt)\n\n val m = ArrayBuffer.fill(501)(ArrayBuffer.fill(501)(0))\n LR.foreach { case (l, r) =>\n m(l)(r) += 1\n }\n\n pq.map { case (p, q) =>\n (for (i <- p to q; j <- p to q) yield m(i)(j)).sum\n }.mkString(\"\\n\")\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 662, "cpu_time_ms": 3163, "memory_kb": 131768}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s800745187", "group_id": "codeNet:p03284", "input_text": "object Main extends App{\n override def main(args:Array[String])={\n var num = readLine.split(\" \").map(a => a.toInt)\n var N = num(0)\n var K = num(1)\n if(N%K==0) println(0)\n else println(1)\n }\n}", "language": "Scala", "metadata": {"date": 1534343218, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s800745187.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s800745187", "user_id": "u825805112"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main extends App{\n override def main(args:Array[String])={\n var num = readLine.split(\" \").map(a => a.toInt)\n var N = num(0)\n var K = num(1)\n if(N%K==0) println(0)\n else println(1)\n }\n}", "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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 317, "memory_kb": 25512}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s448937036", "group_id": "codeNet:p03285", "input_text": "object Main extends App{\n var a = readInt\n def b (c:Int) {\n if(c>7) {\n b(c-7)\n }\n if(c>4) {\n b(c-4)\n }\n if(c==0){\n println(\"Yes\")\n }\n if(c!=0&&c<4){\n println(\"No\")\n }\n }\n b(a)\n}", "language": "Scala", "metadata": {"date": 1562465423, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s448937036.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s448937036", "user_id": "u533688845"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App{\n var a = readInt\n def b (c:Int) {\n if(c>7) {\n b(c-7)\n }\n if(c>4) {\n b(c-4)\n }\n if(c==0){\n println(\"Yes\")\n }\n if(c!=0&&c<4){\n println(\"No\")\n }\n }\n b(a)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1234, "memory_kb": 37192}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s918519352", "group_id": "codeNet:p03285", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n val n = StdIn.readLine.toInt\n if((n % 4 == 0) || (n % 7 == 0) || (n % 11 == 0)) println(\"Yes\")\n else {\n val ans = if ((7 until n by 7).exists(i => (n - i) % 4 == 0)) \"Yes\"\n else \"No\"\n println(ans)\n }\n}", "language": "Scala", "metadata": {"date": 1541544626, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s918519352.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s918519352", "user_id": "u217010036"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n val n = StdIn.readLine.toInt\n if((n % 4 == 0) || (n % 7 == 0) || (n % 11 == 0)) println(\"Yes\")\n else {\n val ans = if ((7 until n by 7).exists(i => (n - i) % 4 == 0)) \"Yes\"\n else \"No\"\n println(ans)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 264, "cpu_time_ms": 320, "memory_kb": 27068}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s189663900", "group_id": "codeNet:p03285", "input_text": "object Main {\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n\n val n0 = n % 11\n println(\n if(n % 4 == 0 || n % 7 == 0 ) \"Yes\"\n else \"No\"\n )\n }\n}", "language": "Scala", "metadata": {"date": 1534038841, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s189663900.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s189663900", "user_id": "u710809824"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main {\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n\n val n0 = n % 11\n println(\n if(n % 4 == 0 || n % 7 == 0 ) \"Yes\"\n 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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 340, "memory_kb": 26052}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s502759362", "group_id": "codeNet:p03287", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n solve\n }\n\n def solve(): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val m = sc.nextLong\n val a = new Array[Long](n)\n for (i <- 0 until n) {\n a(i) = sc.nextLong\n }\n\n // 累積和のmodを計算\n val sum = new Array[Long](n + 1)\n for (i <- 0 until n) {\n sum(i + 1) = (sum(i) + a(i)) % m\n }\n\n // mで割った余りが等しくなる累積和の組はその差分(その間の値の合算値)がmの倍数(mで割り切れる)\n val mp = scala.collection.mutable.Map[Long, Int]()\n var ans = 0\n for (i <- sum) {\n ans += mp.get(i).getOrElse(0)\n if (mp.contains(i)) mp(i) += 1\n else mp.put(i, 1)\n }\n\n println(ans)\n }\n}\n", "language": "Scala", "metadata": {"date": 1580352715, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03287.html", "problem_id": "p03287", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03287/input.txt", "sample_output_relpath": "derived/input_output/data/p03287/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03287/Scala/s502759362.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s502759362", "user_id": "u433254839"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n solve\n }\n\n def solve(): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val m = sc.nextLong\n val a = new Array[Long](n)\n for (i <- 0 until n) {\n a(i) = sc.nextLong\n }\n\n // 累積和のmodを計算\n val sum = new Array[Long](n + 1)\n for (i <- 0 until n) {\n sum(i + 1) = (sum(i) + a(i)) % m\n }\n\n // mで割った余りが等しくなる累積和の組はその差分(その間の値の合算値)がmの倍数(mで割り切れる)\n val mp = scala.collection.mutable.Map[Long, Int]()\n var ans = 0\n for (i <- sum) {\n ans += mp.get(i).getOrElse(0)\n if (mp.contains(i)) mp(i) += 1\n else mp.put(i, 1)\n }\n\n println(ans)\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies.\n\nYou will take out the candies from some consecutive boxes and distribute them evenly to M children.\n\nSuch being the case, find the number of the pairs (l, r) that satisfy the following:\n\nl and r are both integers and satisfy 1 \\leq l \\leq r \\leq N.\n\nA_l + A_{l+1} + ... + A_r is a multiple of M.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n2 \\leq M \\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 M\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of the pairs (l, r) that satisfy the conditions.\n\nNote that the number may not fit into a 32-bit integer type.\n\nSample Input 1\n\n3 2\n4 1 5\n\nSample Output 1\n\n3\n\nThe sum A_l + A_{l+1} + ... + A_r for each pair (l, r) is as follows:\n\nSum for (1, 1): 4\n\nSum for (1, 2): 5\n\nSum for (1, 3): 10\n\nSum for (2, 2): 1\n\nSum for (2, 3): 6\n\nSum for (3, 3): 5\n\nAmong these, three are multiples of 2.\n\nSample Input 2\n\n13 17\n29 7 5 7 9 51 7 13 8 55 42 9 81\n\nSample Output 2\n\n6\n\nSample Input 3\n\n10 400000000\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n\nSample Output 3\n\n25", "sample_input": "3 2\n4 1 5\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03287", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies.\n\nYou will take out the candies from some consecutive boxes and distribute them evenly to M children.\n\nSuch being the case, find the number of the pairs (l, r) that satisfy the following:\n\nl and r are both integers and satisfy 1 \\leq l \\leq r \\leq N.\n\nA_l + A_{l+1} + ... + A_r is a multiple of M.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n2 \\leq M \\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 M\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of the pairs (l, r) that satisfy the conditions.\n\nNote that the number may not fit into a 32-bit integer type.\n\nSample Input 1\n\n3 2\n4 1 5\n\nSample Output 1\n\n3\n\nThe sum A_l + A_{l+1} + ... + A_r for each pair (l, r) is as follows:\n\nSum for (1, 1): 4\n\nSum for (1, 2): 5\n\nSum for (1, 3): 10\n\nSum for (2, 2): 1\n\nSum for (2, 3): 6\n\nSum for (3, 3): 5\n\nAmong these, three are multiples of 2.\n\nSample Input 2\n\n13 17\n29 7 5 7 9 51 7 13 8 55 42 9 81\n\nSample Output 2\n\n6\n\nSample Input 3\n\n10 400000000\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n\nSample Output 3\n\n25", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 785, "cpu_time_ms": 879, "memory_kb": 65884}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s674179091", "group_id": "codeNet:p03287", "input_text": "import java.util.Scanner\n\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n def main(args: Array[String]): Unit = println(solve(new Scanner(System.in)))\n\n def solve(in: String): String = solve(new Scanner(in))\n\n def solve(sc: Scanner): String = {\n val N = sc.nextInt\n val M = sc.nextInt\n val A = Array.fill(N)(sc.nextInt)\n\n // Ai までの累積の余りを出す\n val s = ArrayBuffer.fill(N + 1)(0)\n s(0) = 0\n var sum = 0\n for (i <- 0 until N) {\n sum += A(i)\n sum %= M\n s(i + 1) = sum\n }\n\n var ans = 0\n val r = ArrayBuffer.fill(M)(0)\n for (i <- 0 to N) {\n ans += r(s(i))\n r(s(i)) += 1\n }\n ans.toString\n }\n}\n", "language": "Scala", "metadata": {"date": 1534130076, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03287.html", "problem_id": "p03287", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03287/input.txt", "sample_output_relpath": "derived/input_output/data/p03287/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03287/Scala/s674179091.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s674179091", "user_id": "u297767059"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n def main(args: Array[String]): Unit = println(solve(new Scanner(System.in)))\n\n def solve(in: String): String = solve(new Scanner(in))\n\n def solve(sc: Scanner): String = {\n val N = sc.nextInt\n val M = sc.nextInt\n val A = Array.fill(N)(sc.nextInt)\n\n // Ai までの累積の余りを出す\n val s = ArrayBuffer.fill(N + 1)(0)\n s(0) = 0\n var sum = 0\n for (i <- 0 until N) {\n sum += A(i)\n sum %= M\n s(i + 1) = sum\n }\n\n var ans = 0\n val r = ArrayBuffer.fill(M)(0)\n for (i <- 0 to N) {\n ans += r(s(i))\n r(s(i)) += 1\n }\n ans.toString\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies.\n\nYou will take out the candies from some consecutive boxes and distribute them evenly to M children.\n\nSuch being the case, find the number of the pairs (l, r) that satisfy the following:\n\nl and r are both integers and satisfy 1 \\leq l \\leq r \\leq N.\n\nA_l + A_{l+1} + ... + A_r is a multiple of M.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n2 \\leq M \\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 M\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of the pairs (l, r) that satisfy the conditions.\n\nNote that the number may not fit into a 32-bit integer type.\n\nSample Input 1\n\n3 2\n4 1 5\n\nSample Output 1\n\n3\n\nThe sum A_l + A_{l+1} + ... + A_r for each pair (l, r) is as follows:\n\nSum for (1, 1): 4\n\nSum for (1, 2): 5\n\nSum for (1, 3): 10\n\nSum for (2, 2): 1\n\nSum for (2, 3): 6\n\nSum for (3, 3): 5\n\nAmong these, three are multiples of 2.\n\nSample Input 2\n\n13 17\n29 7 5 7 9 51 7 13 8 55 42 9 81\n\nSample Output 2\n\n6\n\nSample Input 3\n\n10 400000000\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n\nSample Output 3\n\n25", "sample_input": "3 2\n4 1 5\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03287", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N boxes arranged in a row from left to right. The i-th box from the left contains A_i candies.\n\nYou will take out the candies from some consecutive boxes and distribute them evenly to M children.\n\nSuch being the case, find the number of the pairs (l, r) that satisfy the following:\n\nl and r are both integers and satisfy 1 \\leq l \\leq r \\leq N.\n\nA_l + A_{l+1} + ... + A_r is a multiple of M.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n2 \\leq M \\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 M\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of the pairs (l, r) that satisfy the conditions.\n\nNote that the number may not fit into a 32-bit integer type.\n\nSample Input 1\n\n3 2\n4 1 5\n\nSample Output 1\n\n3\n\nThe sum A_l + A_{l+1} + ... + A_r for each pair (l, r) is as follows:\n\nSum for (1, 1): 4\n\nSum for (1, 2): 5\n\nSum for (1, 3): 10\n\nSum for (2, 2): 1\n\nSum for (2, 3): 6\n\nSum for (3, 3): 5\n\nAmong these, three are multiples of 2.\n\nSample Input 2\n\n13 17\n29 7 5 7 9 51 7 13 8 55 42 9 81\n\nSample Output 2\n\n6\n\nSample Input 3\n\n10 400000000\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n\nSample Output 3\n\n25", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 689, "cpu_time_ms": 823, "memory_kb": 66868}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s213479224", "group_id": "codeNet:p03288", "input_text": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n val r: Int = sc.nextInt()\n if (r < 1200) println(\"ABC\")\n else if (2800 <= r) println(\"AGC\")\n else println(\"ARC\")\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1557185448, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03288.html", "problem_id": "p03288", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03288/input.txt", "sample_output_relpath": "derived/input_output/data/p03288/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03288/Scala/s213479224.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s213479224", "user_id": "u629133942"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n val r: Int = sc.nextInt()\n if (r < 1200) println(\"ABC\")\n else if (2800 <= r) println(\"AGC\")\n else println(\"ARC\")\n }\n\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA programming competition site AtCode regularly holds programming contests.\n\nThe next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200.\n\nThe contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800.\n\nThe contest after the ARC is called AGC, which is rated for all contestants.\n\nTakahashi's rating on AtCode is R. What is the next contest rated for him?\n\nConstraints\n\n0 ≤ R ≤ 4208\n\nR is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR\n\nOutput\n\nPrint the name of the next contest rated for Takahashi (ABC, ARC or AGC).\n\nSample Input 1\n\n1199\n\nSample Output 1\n\nABC\n\n1199 is less than 1200, so ABC will be rated.\n\nSample Input 2\n\n1200\n\nSample Output 2\n\nARC\n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800 and ARC will be rated.\n\nSample Input 3\n\n4208\n\nSample Output 3\n\nAGC", "sample_input": "1199\n"}, "reference_outputs": ["ABC\n"], "source_document_id": "p03288", "source_text": "Score : 100 points\n\nProblem Statement\n\nA programming competition site AtCode regularly holds programming contests.\n\nThe next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200.\n\nThe contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800.\n\nThe contest after the ARC is called AGC, which is rated for all contestants.\n\nTakahashi's rating on AtCode is R. What is the next contest rated for him?\n\nConstraints\n\n0 ≤ R ≤ 4208\n\nR is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR\n\nOutput\n\nPrint the name of the next contest rated for Takahashi (ABC, ARC or AGC).\n\nSample Input 1\n\n1199\n\nSample Output 1\n\nABC\n\n1199 is less than 1200, so ABC will be rated.\n\nSample Input 2\n\n1200\n\nSample Output 2\n\nARC\n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800 and ARC will be rated.\n\nSample Input 3\n\n4208\n\nSample Output 3\n\nAGC", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 260, "cpu_time_ms": 354, "memory_kb": 25660}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s795762684", "group_id": "codeNet:p03288", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val answer = io.StdIn.readInt() match {\n case n if n < 1200 => \"ABC\"\n case n if n < 2800 => \"ARC\"\n case _ => \"AGC\"\n }\n println(answer)\n }\n}\n", "language": "Scala", "metadata": {"date": 1533517648, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03288.html", "problem_id": "p03288", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03288/input.txt", "sample_output_relpath": "derived/input_output/data/p03288/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03288/Scala/s795762684.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s795762684", "user_id": "u909304507"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val answer = io.StdIn.readInt() match {\n case n if n < 1200 => \"ABC\"\n case n if n < 2800 => \"ARC\"\n case _ => \"AGC\"\n }\n println(answer)\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA programming competition site AtCode regularly holds programming contests.\n\nThe next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200.\n\nThe contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800.\n\nThe contest after the ARC is called AGC, which is rated for all contestants.\n\nTakahashi's rating on AtCode is R. What is the next contest rated for him?\n\nConstraints\n\n0 ≤ R ≤ 4208\n\nR is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR\n\nOutput\n\nPrint the name of the next contest rated for Takahashi (ABC, ARC or AGC).\n\nSample Input 1\n\n1199\n\nSample Output 1\n\nABC\n\n1199 is less than 1200, so ABC will be rated.\n\nSample Input 2\n\n1200\n\nSample Output 2\n\nARC\n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800 and ARC will be rated.\n\nSample Input 3\n\n4208\n\nSample Output 3\n\nAGC", "sample_input": "1199\n"}, "reference_outputs": ["ABC\n"], "source_document_id": "p03288", "source_text": "Score : 100 points\n\nProblem Statement\n\nA programming competition site AtCode regularly holds programming contests.\n\nThe next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200.\n\nThe contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800.\n\nThe contest after the ARC is called AGC, which is rated for all contestants.\n\nTakahashi's rating on AtCode is R. What is the next contest rated for him?\n\nConstraints\n\n0 ≤ R ≤ 4208\n\nR is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR\n\nOutput\n\nPrint the name of the next contest rated for Takahashi (ABC, ARC or AGC).\n\nSample Input 1\n\n1199\n\nSample Output 1\n\nABC\n\n1199 is less than 1200, so ABC will be rated.\n\nSample Input 2\n\n1200\n\nSample Output 2\n\nARC\n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800 and ARC will be rated.\n\nSample Input 3\n\n4208\n\nSample Output 3\n\nAGC", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 321, "memory_kb": 27176}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s944709827", "group_id": "codeNet:p03290", "input_text": "object Main {\n\n case class Problems(i: Int, p: Int, c: Int) {\n def baseScore: Int = 100 * (i + 1)\n def fullScore: Int = baseScore * p + c\n def untilScore: Int = baseScore * (p - 1)\n def problemsOf(score: Int): Int = score / baseScore\n }\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val D, G = sc.nextInt()\n val problems: IndexedSeq[Problems] = (0 until D).map { i =>\n val p, c = sc.nextInt()\n Problems(i, p, c)\n }\n\n val INF = Int.MaxValue / 10\n\n def solve(): Int = {\n def dfs(i: Int, score: Int, unsolved: Option[Int]): Int =\n if (i < D) {\n val problem = problems(i)\n if (score + problem.fullScore <= G)\n (dfs(i+1, score + problem.fullScore, unsolved) + problem.p) min\n dfs(i+1, score, Some(i))\n else dfs(i+1, score, Some(i))\n } else {\n if (unsolved.nonEmpty) {\n val problem = problems(unsolved.get)\n if (score == G) 0\n else if (score + problem.untilScore >= G)\n problem.problemsOf(G - score)\n else INF\n } else INF\n }\n dfs(0, 0, None)\n }\n\n println(solve())\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1562299188, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s944709827.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s944709827", "user_id": "u891387249"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main {\n\n case class Problems(i: Int, p: Int, c: Int) {\n def baseScore: Int = 100 * (i + 1)\n def fullScore: Int = baseScore * p + c\n def untilScore: Int = baseScore * (p - 1)\n def problemsOf(score: Int): Int = score / baseScore\n }\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val D, G = sc.nextInt()\n val problems: IndexedSeq[Problems] = (0 until D).map { i =>\n val p, c = sc.nextInt()\n Problems(i, p, c)\n }\n\n val INF = Int.MaxValue / 10\n\n def solve(): Int = {\n def dfs(i: Int, score: Int, unsolved: Option[Int]): Int =\n if (i < D) {\n val problem = problems(i)\n if (score + problem.fullScore <= G)\n (dfs(i+1, score + problem.fullScore, unsolved) + problem.p) min\n dfs(i+1, score, Some(i))\n else dfs(i+1, score, Some(i))\n } else {\n if (unsolved.nonEmpty) {\n val problem = problems(unsolved.get)\n if (score == G) 0\n else if (score + problem.untilScore >= G)\n problem.problemsOf(G - score)\n else INF\n } else INF\n }\n dfs(0, 0, None)\n }\n\n println(solve())\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1211, "cpu_time_ms": 355, "memory_kb": 27304}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s077097945", "group_id": "codeNet:p03291", "input_text": "import java.util.Scanner\n\nobject Main {\n val MOD = 1000000007L\n\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val S = sc.next()\n\n println(solve(S))\n }\n\n def solve(S: String): String = {\n val N = S.length\n val dp = new Array[(Long, Long, Long, Long)](N + 1) // A, AB, ABC, X\n dp.update(0, (0, 0, 0, 1))\n for (i <- 1 to N) {\n if (S.charAt(i - 1) == 'A') {\n dp.update(\n i,\n (\n (dp(i - 1)._1 + dp(i - 1)._4) % MOD,\n dp(i - 1)._2,\n dp(i - 1)._3,\n dp(i - 1)._4\n )\n )\n } else if (S.charAt(i - 1) == 'B') {\n dp.update(\n i,\n (\n dp(i - 1)._1,\n (dp(i - 1)._2 + dp(i - 1)._1) % MOD,\n dp(i - 1)._3,\n dp(i - 1)._4\n )\n )\n } else if (S.charAt(i - 1) == 'C') {\n dp.update(\n i,\n (\n dp(i - 1)._1,\n dp(i - 1)._2,\n (dp(i - 1)._3 + dp(i - 1)._2) % MOD,\n dp(i - 1)._4\n )\n )\n } else if (S.charAt(i - 1) == '?') {\n dp.update(\n i,\n (\n (dp(i - 1)._1 * 3 % MOD + dp(i - 1)._4) % MOD,\n (dp(i - 1)._2 * 3 % MOD + dp(i - 1)._1) % MOD,\n (dp(i - 1)._3 * 3 % MOD + dp(i - 1)._2) % MOD,\n dp(i - 1)._4 * 3 % MOD\n )\n )\n }\n }\n dp(N)._3.toString\n }\n}", "language": "Scala", "metadata": {"date": 1564094336, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03291.html", "problem_id": "p03291", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03291/input.txt", "sample_output_relpath": "derived/input_output/data/p03291/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03291/Scala/s077097945.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s077097945", "user_id": "u042365947"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n val MOD = 1000000007L\n\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val S = sc.next()\n\n println(solve(S))\n }\n\n def solve(S: String): String = {\n val N = S.length\n val dp = new Array[(Long, Long, Long, Long)](N + 1) // A, AB, ABC, X\n dp.update(0, (0, 0, 0, 1))\n for (i <- 1 to N) {\n if (S.charAt(i - 1) == 'A') {\n dp.update(\n i,\n (\n (dp(i - 1)._1 + dp(i - 1)._4) % MOD,\n dp(i - 1)._2,\n dp(i - 1)._3,\n dp(i - 1)._4\n )\n )\n } else if (S.charAt(i - 1) == 'B') {\n dp.update(\n i,\n (\n dp(i - 1)._1,\n (dp(i - 1)._2 + dp(i - 1)._1) % MOD,\n dp(i - 1)._3,\n dp(i - 1)._4\n )\n )\n } else if (S.charAt(i - 1) == 'C') {\n dp.update(\n i,\n (\n dp(i - 1)._1,\n dp(i - 1)._2,\n (dp(i - 1)._3 + dp(i - 1)._2) % MOD,\n dp(i - 1)._4\n )\n )\n } else if (S.charAt(i - 1) == '?') {\n dp.update(\n i,\n (\n (dp(i - 1)._1 * 3 % MOD + dp(i - 1)._4) % MOD,\n (dp(i - 1)._2 * 3 % MOD + dp(i - 1)._1) % MOD,\n (dp(i - 1)._3 * 3 % MOD + dp(i - 1)._2) % MOD,\n dp(i - 1)._4 * 3 % MOD\n )\n )\n }\n }\n dp(N)._3.toString\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThe ABC number of a string T is the number of triples of integers (i, j, k) that satisfy all of the following conditions:\n\n1 ≤ i < j < k ≤ |T| (|T| is the length of T.)\n\nT_i = A (T_i is the i-th character of T from the beginning.)\n\nT_j = B\n\nT_k = C\n\nFor example, when T = ABCBC, there are three triples of integers (i, j, k) that satisfy the conditions: (1, 2, 3), (1, 2, 5), (1, 4, 5). Thus, the ABC number of T is 3.\n\nYou are given a string S. Each character of S is A, B, C or ?.\n\nLet Q be the number of occurrences of ? in S. We can make 3^Q strings by replacing each occurrence of ? in S with A, B or C. Find the sum of the ABC numbers of all these strings.\n\nThis sum can be extremely large, so print the sum modulo 10^9 + 7.\n\nConstraints\n\n3 ≤ |S| ≤ 10^5\n\nEach character of S is A, B, C or ?.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.\n\nSample Input 1\n\nA??C\n\nSample Output 1\n\n8\n\nIn this case, Q = 2, and we can make 3^Q = 9 strings by by replacing each occurrence of ? with A, B or C. The ABC number of each of these strings is as follows:\n\nAAAC: 0\n\nAABC: 2\n\nAACC: 0\n\nABAC: 1\n\nABBC: 2\n\nABCC: 2\n\nACAC: 0\n\nACBC: 1\n\nACCC: 0\n\nThe sum of these is 0 + 2 + 0 + 1 + 2 + 2 + 0 + 1 + 0 = 8, so we print 8 modulo 10^9 + 7, that is, 8.\n\nSample Input 2\n\nABCBC\n\nSample Output 2\n\n3\n\nWhen Q = 0, we print the ABC number of S itself, modulo 10^9 + 7. This string is the same as the one given as an example in the problem statement, and its ABC number is 3.\n\nSample Input 3\n\n????C?????B??????A???????\n\nSample Output 3\n\n979596887\n\nIn this case, the sum of the ABC numbers of all the 3^Q strings is 2291979612924, and we should print this number modulo 10^9 + 7, that is, 979596887.", "sample_input": "A??C\n"}, "reference_outputs": ["8\n"], "source_document_id": "p03291", "source_text": "Score : 400 points\n\nProblem Statement\n\nThe ABC number of a string T is the number of triples of integers (i, j, k) that satisfy all of the following conditions:\n\n1 ≤ i < j < k ≤ |T| (|T| is the length of T.)\n\nT_i = A (T_i is the i-th character of T from the beginning.)\n\nT_j = B\n\nT_k = C\n\nFor example, when T = ABCBC, there are three triples of integers (i, j, k) that satisfy the conditions: (1, 2, 3), (1, 2, 5), (1, 4, 5). Thus, the ABC number of T is 3.\n\nYou are given a string S. Each character of S is A, B, C or ?.\n\nLet Q be the number of occurrences of ? in S. We can make 3^Q strings by replacing each occurrence of ? in S with A, B or C. Find the sum of the ABC numbers of all these strings.\n\nThis sum can be extremely large, so print the sum modulo 10^9 + 7.\n\nConstraints\n\n3 ≤ |S| ≤ 10^5\n\nEach character of S is A, B, C or ?.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.\n\nSample Input 1\n\nA??C\n\nSample Output 1\n\n8\n\nIn this case, Q = 2, and we can make 3^Q = 9 strings by by replacing each occurrence of ? with A, B or C. The ABC number of each of these strings is as follows:\n\nAAAC: 0\n\nAABC: 2\n\nAACC: 0\n\nABAC: 1\n\nABBC: 2\n\nABCC: 2\n\nACAC: 0\n\nACBC: 1\n\nACCC: 0\n\nThe sum of these is 0 + 2 + 0 + 1 + 2 + 2 + 0 + 1 + 0 = 8, so we print 8 modulo 10^9 + 7, that is, 8.\n\nSample Input 2\n\nABCBC\n\nSample Output 2\n\n3\n\nWhen Q = 0, we print the ABC number of S itself, modulo 10^9 + 7. This string is the same as the one given as an example in the problem statement, and its ABC number is 3.\n\nSample Input 3\n\n????C?????B??????A???????\n\nSample Output 3\n\n979596887\n\nIn this case, the sum of the ABC numbers of all the 3^Q strings is 2291979612924, and we should print this number modulo 10^9 + 7, that is, 979596887.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1437, "cpu_time_ms": 493, "memory_kb": 42660}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s848491662", "group_id": "codeNet:p03292", "input_text": "object Main extends App {\n val scanner = new java.util.Scanner(System.in)\n val a = Array.fill(3)(scanner.nextInt()).sorted\n println(a(2)-a(0))\n}", "language": "Scala", "metadata": {"date": 1532221423, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03292.html", "problem_id": "p03292", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03292/input.txt", "sample_output_relpath": "derived/input_output/data/p03292/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03292/Scala/s848491662.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s848491662", "user_id": "u387147818"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "object Main extends App {\n val scanner = new java.util.Scanner(System.in)\n val a = Array.fill(3)(scanner.nextInt()).sorted\n println(a(2)-a(0))\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou have three tasks, all of which need to be completed.\n\nFirst, you can complete any one task at cost 0.\n\nThen, just after completing the i-th task, you can complete the j-th task at cost |A_j - A_i|.\n\nHere, |x| denotes the absolute value of x.\n\nFind the minimum total cost required to complete all the task.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_1, A_2, A_3 \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_1 A_2 A_3\n\nOutput\n\nPrint the minimum total cost required to complete all the task.\n\nSample Input 1\n\n1 6 3\n\nSample Output 1\n\n5\n\nWhen the tasks are completed in the following order, the total cost will be 5, which is the minimum:\n\nComplete the first task at cost 0.\n\nComplete the third task at cost 2.\n\nComplete the second task at cost 3.\n\nSample Input 2\n\n11 5 5\n\nSample Output 2\n\n6\n\nSample Input 3\n\n100 100 100\n\nSample Output 3\n\n0", "sample_input": "1 6 3\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03292", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou have three tasks, all of which need to be completed.\n\nFirst, you can complete any one task at cost 0.\n\nThen, just after completing the i-th task, you can complete the j-th task at cost |A_j - A_i|.\n\nHere, |x| denotes the absolute value of x.\n\nFind the minimum total cost required to complete all the task.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_1, A_2, A_3 \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_1 A_2 A_3\n\nOutput\n\nPrint the minimum total cost required to complete all the task.\n\nSample Input 1\n\n1 6 3\n\nSample Output 1\n\n5\n\nWhen the tasks are completed in the following order, the total cost will be 5, which is the minimum:\n\nComplete the first task at cost 0.\n\nComplete the third task at cost 2.\n\nComplete the second task at cost 3.\n\nSample Input 2\n\n11 5 5\n\nSample Output 2\n\n6\n\nSample Input 3\n\n100 100 100\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 345, "memory_kb": 25544}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s924024880", "group_id": "codeNet:p03293", "input_text": "object Main extends App{\n override def main(args:Array[String])={\n var s = readLine\n var t = readLine\n var len = s.length\n var flag = false\n if(s==t) {\n println(\"Yes\")\n flag=true\n }\n else{\n for(i <- 0 until len if !flag){\n \t\tvar res = rotation(s)\n \tif(s==t) {\n println(\"Yes\")\n flag=true\n }\n }\n }\n if(!flag) println(\"No\")\n \n }\n def rotation(s:String):String={\n var len = s.length\n return s.charAt(len-1)+s.substring(0,len)\n }\n}\n", "language": "Scala", "metadata": {"date": 1534364932, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s924024880.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s924024880", "user_id": "u825805112"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App{\n override def main(args:Array[String])={\n var s = readLine\n var t = readLine\n var len = s.length\n var flag = false\n if(s==t) {\n println(\"Yes\")\n flag=true\n }\n else{\n for(i <- 0 until len if !flag){\n \t\tvar res = rotation(s)\n \tif(s==t) {\n println(\"Yes\")\n flag=true\n }\n }\n }\n if(!flag) println(\"No\")\n \n }\n def rotation(s:String):String={\n var len = s.length\n return s.charAt(len-1)+s.substring(0,len)\n }\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 332, "memory_kb": 27192}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s992955937", "group_id": "codeNet:p03294", "input_text": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val N = in.nextInt\n val As = List.fill(N)(in.nextLong)\n println(As.sum - N)\n}", "language": "Scala", "metadata": {"date": 1592339068, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03294.html", "problem_id": "p03294", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03294/input.txt", "sample_output_relpath": "derived/input_output/data/p03294/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03294/Scala/s992955937.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s992955937", "user_id": "u132324749"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val N = in.nextInt\n val As = List.fill(N)(in.nextLong)\n println(As.sum - N)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given N positive integers a_1, a_2, ..., a_N.\n\nFor a non-negative integer m, let f(m) = (m\\ mod\\ a_1) + (m\\ mod\\ a_2) + ... + (m\\ mod\\ a_N).\n\nHere, X\\ mod\\ Y denotes the remainder of the division of X by Y.\n\nFind the maximum value of f.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 3000\n\n2 \\leq a_i \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum value of f.\n\nSample Input 1\n\n3\n3 4 6\n\nSample Output 1\n\n10\n\nf(11) = (11\\ mod\\ 3) + (11\\ mod\\ 4) + (11\\ mod\\ 6) = 10 is the maximum value of f.\n\nSample Input 2\n\n5\n7 46 11 20 11\n\nSample Output 2\n\n90\n\nSample Input 3\n\n7\n994 518 941 851 647 2 581\n\nSample Output 3\n\n4527", "sample_input": "3\n3 4 6\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03294", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given N positive integers a_1, a_2, ..., a_N.\n\nFor a non-negative integer m, let f(m) = (m\\ mod\\ a_1) + (m\\ mod\\ a_2) + ... + (m\\ mod\\ a_N).\n\nHere, X\\ mod\\ Y denotes the remainder of the division of X by Y.\n\nFind the maximum value of f.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 3000\n\n2 \\leq a_i \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum value of f.\n\nSample Input 1\n\n3\n3 4 6\n\nSample Output 1\n\n10\n\nf(11) = (11\\ mod\\ 3) + (11\\ mod\\ 4) + (11\\ mod\\ 6) = 10 is the maximum value of f.\n\nSample Input 2\n\n5\n7 46 11 20 11\n\nSample Output 2\n\n90\n\nSample Input 3\n\n7\n994 518 941 851 647 2 581\n\nSample Output 3\n\n4527", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 479, "memory_kb": 29596}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s133253150", "group_id": "codeNet:p03294", "input_text": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val N = sc.nextInt()\n val A = Array.fill(N)(BigInt(sc.nextLong()))\n\n def gcd(a: BigInt, b: BigInt): BigInt =\n if (a % b == 0L) b\n else gcd(b, a % b)\n\n def lcm(a: BigInt, b: BigInt): BigInt =\n a * (b / gcd(a, b))\n\n val LCM = A.reduce((a, b) => lcm(a, b)) - 1\n val r = A.foldLeft(BigInt(0))((b, n) => b + LCM % n)\n println(r)\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1576816286, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03294.html", "problem_id": "p03294", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03294/input.txt", "sample_output_relpath": "derived/input_output/data/p03294/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03294/Scala/s133253150.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s133253150", "user_id": "u891387249"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val N = sc.nextInt()\n val A = Array.fill(N)(BigInt(sc.nextLong()))\n\n def gcd(a: BigInt, b: BigInt): BigInt =\n if (a % b == 0L) b\n else gcd(b, a % b)\n\n def lcm(a: BigInt, b: BigInt): BigInt =\n a * (b / gcd(a, b))\n\n val LCM = A.reduce((a, b) => lcm(a, b)) - 1\n val r = A.foldLeft(BigInt(0))((b, n) => b + LCM % n)\n println(r)\n }\n\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given N positive integers a_1, a_2, ..., a_N.\n\nFor a non-negative integer m, let f(m) = (m\\ mod\\ a_1) + (m\\ mod\\ a_2) + ... + (m\\ mod\\ a_N).\n\nHere, X\\ mod\\ Y denotes the remainder of the division of X by Y.\n\nFind the maximum value of f.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 3000\n\n2 \\leq a_i \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum value of f.\n\nSample Input 1\n\n3\n3 4 6\n\nSample Output 1\n\n10\n\nf(11) = (11\\ mod\\ 3) + (11\\ mod\\ 4) + (11\\ mod\\ 6) = 10 is the maximum value of f.\n\nSample Input 2\n\n5\n7 46 11 20 11\n\nSample Output 2\n\n90\n\nSample Input 3\n\n7\n994 518 941 851 647 2 581\n\nSample Output 3\n\n4527", "sample_input": "3\n3 4 6\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03294", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given N positive integers a_1, a_2, ..., a_N.\n\nFor a non-negative integer m, let f(m) = (m\\ mod\\ a_1) + (m\\ mod\\ a_2) + ... + (m\\ mod\\ a_N).\n\nHere, X\\ mod\\ Y denotes the remainder of the division of X by Y.\n\nFind the maximum value of f.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 3000\n\n2 \\leq a_i \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum value of f.\n\nSample Input 1\n\n3\n3 4 6\n\nSample Output 1\n\n10\n\nf(11) = (11\\ mod\\ 3) + (11\\ mod\\ 4) + (11\\ mod\\ 6) = 10 is the maximum value of f.\n\nSample Input 2\n\n5\n7 46 11 20 11\n\nSample Output 2\n\n90\n\nSample Input 3\n\n7\n994 518 941 851 647 2 581\n\nSample Output 3\n\n4527", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 472, "cpu_time_ms": 820, "memory_kb": 49016}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s553652063", "group_id": "codeNet:p03295", "input_text": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val Array(n, m) = in.readLine.split(\" \").map(_.toInt)\n val req = Iterator.continually(in.readLine)\n .take(m)\n .map(_.split(\" \").map(_.toInt))\n .toArray\n .sortBy(e => e(1))\n\n def rec(cnt:Int, pos:Int, i:Int):Int = {\n if(i == m) cnt\n else if(pos < req(i)(0)) rec(cnt+1, req(i)(1)-1, i+1)\n else rec(cnt, pos, i+1)\n }\n\n val ans = rec(0,0,0)\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1554584551, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s553652063.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s553652063", "user_id": "u217010036"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val Array(n, m) = in.readLine.split(\" \").map(_.toInt)\n val req = Iterator.continually(in.readLine)\n .take(m)\n .map(_.split(\" \").map(_.toInt))\n .toArray\n .sortBy(e => e(1))\n\n def rec(cnt:Int, pos:Int, i:Int):Int = {\n if(i == m) cnt\n else if(pos < req(i)(0)) rec(cnt+1, req(i)(1)-1, i+1)\n else rec(cnt, pos, i+1)\n }\n\n val ans = rec(0,0,0)\n println(ans)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 928, "memory_kb": 66696}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s316675460", "group_id": "codeNet:p03295", "input_text": "import java.io.{InputStream, OutputStream, PrintStream}\nimport java.util.Scanner\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n val solver = new Solver(System.in, System.out)\n solver.solve()\n }\n\n class Solver(in: InputStream, out: OutputStream) {\n lazy val input = new Scanner(in)\n\n lazy val output = new PrintStream(out)\n\n def solve(): Unit = {\n val Array(n, m) = input.nextLine().split(\" \").map(_.toInt)\n val ranges =\n 1.to(m)\n .map { _ =>\n val Array(s, e) = input.nextLine().split(\" \").map(_.toInt)\n (s, e)\n }\n\n var remainingRanges = ranges\n var count = 0\n while (remainingRanges.nonEmpty) {\n val (startCounts, endCounts) = (Array.fill(n)(0), Array.fill(n)(0))\n remainingRanges.foreach { case (s, e) =>\n startCounts(s - 1) += 1\n endCounts(e - 1) += 1\n }\n\n val values = Array.fill(n)(0)\n var overlaps = 0\n 0.until(n).foreach { i =>\n overlaps += startCounts(i)\n overlaps -= endCounts(i)\n values(i) = overlaps\n }\n\n val max = values.max\n val i = values.indexOf(max)\n\n remainingRanges = remainingRanges.filterNot { case (s, e) =>\n s - 1 <= i && i < e - 1\n }\n\n count += 1\n }\n\n output.println(count)\n }\n\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1532227050, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s316675460.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s316675460", "user_id": "u299987045"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.io.{InputStream, OutputStream, PrintStream}\nimport java.util.Scanner\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n val solver = new Solver(System.in, System.out)\n solver.solve()\n }\n\n class Solver(in: InputStream, out: OutputStream) {\n lazy val input = new Scanner(in)\n\n lazy val output = new PrintStream(out)\n\n def solve(): Unit = {\n val Array(n, m) = input.nextLine().split(\" \").map(_.toInt)\n val ranges =\n 1.to(m)\n .map { _ =>\n val Array(s, e) = input.nextLine().split(\" \").map(_.toInt)\n (s, e)\n }\n\n var remainingRanges = ranges\n var count = 0\n while (remainingRanges.nonEmpty) {\n val (startCounts, endCounts) = (Array.fill(n)(0), Array.fill(n)(0))\n remainingRanges.foreach { case (s, e) =>\n startCounts(s - 1) += 1\n endCounts(e - 1) += 1\n }\n\n val values = Array.fill(n)(0)\n var overlaps = 0\n 0.until(n).foreach { i =>\n overlaps += startCounts(i)\n overlaps -= endCounts(i)\n values(i) = overlaps\n }\n\n val max = values.max\n val i = values.indexOf(max)\n\n remainingRanges = remainingRanges.filterNot { case (s, e) =>\n s - 1 <= i && i < e - 1\n }\n\n count += 1\n }\n\n output.println(count)\n }\n\n }\n\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1359, "cpu_time_ms": 2111, "memory_kb": 136372}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s021711285", "group_id": "codeNet:p03297", "input_text": "import java.io.StringReader\nimport java.nio.charset.StandardCharsets\nimport java.nio.file.{Files, Paths}\n\nimport scala.io.StdIn\nimport scala.language.higherKinds\nimport scala.reflect.ClassTag\n\nobject Main {\n import StdInScanner._\n def main(args: Array[String]): Unit = {\n val scanner = for {\n t <- readAnInt\n qs <- readLongMatrix(t)\n } yield (t, qs)\n val (t, qs) = scanner.run\n for (q <- qs) {\n println(solve(q(0), q(1), q(2), q(3)))\n }\n }\n\n def solve(a: Long, b: Long, c: Long, d: Long): String = {\n val night0 = a - b\n val diff = d - b\n if (diff < 0 || night0 < 0) \"No\"\n else if (diff == 0) {\n if (night0 < c) \"Yes\"\n else \"No\"\n }\n else {\n val n = (c - night0) / diff + 1\n val dayMin = night0 + diff * n\n if (dayMin < b) {\n \"No\"\n }\n else {\n \"Yes\"\n }\n }\n }\n}\n\n\ncase class StdInScanner[A](scan: StdIn.type => A) {\n // transform read result by \"f\"\n def map[B](f: A => B): StdInScanner[B] =\n StdInScanner(in => f(scan(in)))\n\n // run this to read A, then obtain new scanner from A using \"f\", then run the new scanner\n def flatMap[B](f: A => StdInScanner[B]): StdInScanner[B] =\n StdInScanner(in => f(scan(in)).scan(in))\n\n // run entire scanner and get result\n def run: A = scan(StdIn)\n\n // run entire scanner on the text file\n def runOnFile(filename: String): A =\n Console.withIn(Files.newBufferedReader(Paths.get(filename), StandardCharsets.UTF_8))(this.scan(StdIn))\n\n // run entire scanner on the String\n def runOnString(str: String): A =\n Console.withIn(new StringReader(str))(this.scan(StdIn))\n}\n\nobject StdInScanner {\n /* pure(read nothing) scanners */\n // read nothing, and return specified \"a\"\n def apply[A](a: A): StdInScanner[A] = StdInScanner(_ => a)\n // read nothing, and return ()\n def unit: StdInScanner[Unit] = StdInScanner(())\n\n /* read single line -> produce single value */\n // read a line\n def readALine: StdInScanner[String] = StdInScanner(s => s.readLine().trim)\n // read a line as Int\n def readAnInt: StdInScanner[Int] = StdInScanner(s => s.readInt())\n // read a line as Long\n def readALong: StdInScanner[Long] = StdInScanner(s => s.readLong())\n\n def readAPair[A, B](fa: String => A, fb: String => B): StdInScanner[(A, B)] =\n readTokens.map(v => (fa(v(0)), fb(v(1))))\n\n def readIntPair: StdInScanner[(Int, Int)] =\n readAPair(_.toInt, _.toInt)\n\n def readATriple[A, B, C](fa: String => A, fb: String => B, fc: String => C): StdInScanner[(A, B, C)] =\n readTokens.map(v => (fa(v(0)), fb(v(1)), fc(v(2))))\n\n def readIntTriple: StdInScanner[(Int, Int, Int)] =\n readATriple(_.toInt, _.toInt, _.toInt)\n\n def readTwoPairs[A, B](fa: String => A, fb: String => B): StdInScanner[((A, B), (A, B))] =\n readTokens.map(v => ((fa(v(0)), fb(v(1))), (fa(v(2)), fb(v(3)))))\n\n def readTwoIntPairs: StdInScanner[((Int, Int), (Int, Int))] =\n readTwoPairs(_.toInt, _.toInt)\n\n /* read single line -> produce multiple values */\n // read tokens from a line, then map them with \"f\"\n def readTokensWithMap[A](f: String => A): StdInScanner[Vector[A]] =\n readALine.map(_.split(\" \").toVector.map(f))\n\n def readTokens: StdInScanner[Vector[String]] =\n readTokensWithMap(identity)\n\n def readIntTokens: StdInScanner[Vector[Int]] =\n readTokensWithMap(_.toInt)\n\n def readLongTokens: StdInScanner[Vector[Long]] =\n readTokensWithMap(_.toLong)\n\n /* read multiple lines -> produce one value per line */\n def readLines(n: Int): StdInScanner[Vector[String]] =\n StdInScanner(s => Vector.fill(n)(s.readLine().trim))\n\n def readLinesWithMap[A](n: Int, f: String => A): StdInScanner[Vector[A]] =\n StdInScanner(s => Vector.fill(n)(f(s.readLine())))\n\n def readInts(n: Int): StdInScanner[Vector[Int]] =\n StdInScanner(s => Vector.fill(n)(s.readInt()))\n\n def readBigInts(n: Int): StdInScanner[Vector[BigInt]] =\n StdInScanner(s => Vector.fill(n)(BigInt(s.readLine())))\n\n def readPairs[A, B](n: Int)(fa: String => A, fb: String => B): StdInScanner[Vector[(A, B)]] =\n readLines(n).map(_.map{ line =>\n val t1 :: t2 :: _ = line.split(\" \").toList\n (fa(t1), fb(t2))\n })\n def readIntPairs(n: Int): StdInScanner[Vector[(Int, Int)]] =\n readPairs(n)(_.toInt, _.toInt)\n\n def readTriples[A, B, C](n: Int)(fa: String => A, fb: String => B, fc: String => C): StdInScanner[Vector[(A, B, C)]] =\n readLines(n).map(_.map{ line =>\n val t1 :: t2 :: t3 :: _ = line.split(\" \").toList\n (fa(t1), fb(t2), fc(t3))\n })\n\n def readIntTriples(n: Int): StdInScanner[Vector[(Int, Int, Int)]] =\n readTriples(n)(_.toInt, _.toInt, _.toInt)\n\n /* read multiple lines -> produce multiple value per line */\n // \"2D Matrix of A\" is Vector of \"Vector of A\"\n type Matrix[A] = Vector[Vector[A]]\n\n // read a table of \"rows\", then map each elements with \"f\"\n def readTableWithMap[A: ClassTag](rows: Int, f: String => A): StdInScanner[Matrix[A]] =\n readLines(rows).map{ lns =>\n lns.map(ln => ln.split(\" \").toVector.map(tkn => f(tkn)))\n }\n def readTable(rows: Int): StdInScanner[Matrix[String]] =\n readTableWithMap(rows, identity)\n\n def readIntMatrix(rows: Int): StdInScanner[Matrix[Int]] =\n readTableWithMap(rows, _.toInt)\n\n def readLongMatrix(rows: Int): StdInScanner[Matrix[Long]] =\n readTableWithMap(rows, _.toLong)\n}\n", "language": "Scala", "metadata": {"date": 1531622851, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03297.html", "problem_id": "p03297", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03297/input.txt", "sample_output_relpath": "derived/input_output/data/p03297/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03297/Scala/s021711285.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s021711285", "user_id": "u715634684"}, "prompt_components": {"gold_output": "No\nYes\nNo\nYes\nYes\nNo\nNo\nYes\nNo\nYes\nYes\nNo\nNo\nYes\n", "input_to_evaluate": "import java.io.StringReader\nimport java.nio.charset.StandardCharsets\nimport java.nio.file.{Files, Paths}\n\nimport scala.io.StdIn\nimport scala.language.higherKinds\nimport scala.reflect.ClassTag\n\nobject Main {\n import StdInScanner._\n def main(args: Array[String]): Unit = {\n val scanner = for {\n t <- readAnInt\n qs <- readLongMatrix(t)\n } yield (t, qs)\n val (t, qs) = scanner.run\n for (q <- qs) {\n println(solve(q(0), q(1), q(2), q(3)))\n }\n }\n\n def solve(a: Long, b: Long, c: Long, d: Long): String = {\n val night0 = a - b\n val diff = d - b\n if (diff < 0 || night0 < 0) \"No\"\n else if (diff == 0) {\n if (night0 < c) \"Yes\"\n else \"No\"\n }\n else {\n val n = (c - night0) / diff + 1\n val dayMin = night0 + diff * n\n if (dayMin < b) {\n \"No\"\n }\n else {\n \"Yes\"\n }\n }\n }\n}\n\n\ncase class StdInScanner[A](scan: StdIn.type => A) {\n // transform read result by \"f\"\n def map[B](f: A => B): StdInScanner[B] =\n StdInScanner(in => f(scan(in)))\n\n // run this to read A, then obtain new scanner from A using \"f\", then run the new scanner\n def flatMap[B](f: A => StdInScanner[B]): StdInScanner[B] =\n StdInScanner(in => f(scan(in)).scan(in))\n\n // run entire scanner and get result\n def run: A = scan(StdIn)\n\n // run entire scanner on the text file\n def runOnFile(filename: String): A =\n Console.withIn(Files.newBufferedReader(Paths.get(filename), StandardCharsets.UTF_8))(this.scan(StdIn))\n\n // run entire scanner on the String\n def runOnString(str: String): A =\n Console.withIn(new StringReader(str))(this.scan(StdIn))\n}\n\nobject StdInScanner {\n /* pure(read nothing) scanners */\n // read nothing, and return specified \"a\"\n def apply[A](a: A): StdInScanner[A] = StdInScanner(_ => a)\n // read nothing, and return ()\n def unit: StdInScanner[Unit] = StdInScanner(())\n\n /* read single line -> produce single value */\n // read a line\n def readALine: StdInScanner[String] = StdInScanner(s => s.readLine().trim)\n // read a line as Int\n def readAnInt: StdInScanner[Int] = StdInScanner(s => s.readInt())\n // read a line as Long\n def readALong: StdInScanner[Long] = StdInScanner(s => s.readLong())\n\n def readAPair[A, B](fa: String => A, fb: String => B): StdInScanner[(A, B)] =\n readTokens.map(v => (fa(v(0)), fb(v(1))))\n\n def readIntPair: StdInScanner[(Int, Int)] =\n readAPair(_.toInt, _.toInt)\n\n def readATriple[A, B, C](fa: String => A, fb: String => B, fc: String => C): StdInScanner[(A, B, C)] =\n readTokens.map(v => (fa(v(0)), fb(v(1)), fc(v(2))))\n\n def readIntTriple: StdInScanner[(Int, Int, Int)] =\n readATriple(_.toInt, _.toInt, _.toInt)\n\n def readTwoPairs[A, B](fa: String => A, fb: String => B): StdInScanner[((A, B), (A, B))] =\n readTokens.map(v => ((fa(v(0)), fb(v(1))), (fa(v(2)), fb(v(3)))))\n\n def readTwoIntPairs: StdInScanner[((Int, Int), (Int, Int))] =\n readTwoPairs(_.toInt, _.toInt)\n\n /* read single line -> produce multiple values */\n // read tokens from a line, then map them with \"f\"\n def readTokensWithMap[A](f: String => A): StdInScanner[Vector[A]] =\n readALine.map(_.split(\" \").toVector.map(f))\n\n def readTokens: StdInScanner[Vector[String]] =\n readTokensWithMap(identity)\n\n def readIntTokens: StdInScanner[Vector[Int]] =\n readTokensWithMap(_.toInt)\n\n def readLongTokens: StdInScanner[Vector[Long]] =\n readTokensWithMap(_.toLong)\n\n /* read multiple lines -> produce one value per line */\n def readLines(n: Int): StdInScanner[Vector[String]] =\n StdInScanner(s => Vector.fill(n)(s.readLine().trim))\n\n def readLinesWithMap[A](n: Int, f: String => A): StdInScanner[Vector[A]] =\n StdInScanner(s => Vector.fill(n)(f(s.readLine())))\n\n def readInts(n: Int): StdInScanner[Vector[Int]] =\n StdInScanner(s => Vector.fill(n)(s.readInt()))\n\n def readBigInts(n: Int): StdInScanner[Vector[BigInt]] =\n StdInScanner(s => Vector.fill(n)(BigInt(s.readLine())))\n\n def readPairs[A, B](n: Int)(fa: String => A, fb: String => B): StdInScanner[Vector[(A, B)]] =\n readLines(n).map(_.map{ line =>\n val t1 :: t2 :: _ = line.split(\" \").toList\n (fa(t1), fb(t2))\n })\n def readIntPairs(n: Int): StdInScanner[Vector[(Int, Int)]] =\n readPairs(n)(_.toInt, _.toInt)\n\n def readTriples[A, B, C](n: Int)(fa: String => A, fb: String => B, fc: String => C): StdInScanner[Vector[(A, B, C)]] =\n readLines(n).map(_.map{ line =>\n val t1 :: t2 :: t3 :: _ = line.split(\" \").toList\n (fa(t1), fb(t2), fc(t3))\n })\n\n def readIntTriples(n: Int): StdInScanner[Vector[(Int, Int, Int)]] =\n readTriples(n)(_.toInt, _.toInt, _.toInt)\n\n /* read multiple lines -> produce multiple value per line */\n // \"2D Matrix of A\" is Vector of \"Vector of A\"\n type Matrix[A] = Vector[Vector[A]]\n\n // read a table of \"rows\", then map each elements with \"f\"\n def readTableWithMap[A: ClassTag](rows: Int, f: String => A): StdInScanner[Matrix[A]] =\n readLines(rows).map{ lns =>\n lns.map(ln => ln.split(\" \").toVector.map(tkn => f(tkn)))\n }\n def readTable(rows: Int): StdInScanner[Matrix[String]] =\n readTableWithMap(rows, identity)\n\n def readIntMatrix(rows: Int): StdInScanner[Matrix[Int]] =\n readTableWithMap(rows, _.toInt)\n\n def readLongMatrix(rows: Int): StdInScanner[Matrix[Long]] =\n readTableWithMap(rows, _.toLong)\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nRingo Mart, a convenience store, sells apple juice.\n\nOn the opening day of Ringo Mart, there were A cans of juice in stock in the morning.\nSnuke buys B cans of juice here every day in the daytime.\nThen, the manager checks the number of cans of juice remaining in stock every night.\nIf there are C or less cans, D new cans will be added to the stock by the next morning.\n\nDetermine if Snuke can buy juice indefinitely, that is, there is always B or more cans of juice in stock when he attempts to buy them.\nNobody besides Snuke buy juice at this store.\n\nNote that each test case in this problem consists of T queries.\n\nConstraints\n\n1 \\leq T \\leq 300\n\n1 \\leq A, B, C, D \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT\nA_1 B_1 C_1 D_1\nA_2 B_2 C_2 D_2\n:\nA_T B_T C_T D_T\n\nIn the i-th query, A = A_i, B = B_i, C = C_i, D = D_i.\n\nOutput\n\nPrint T lines. The i-th line should contain Yes if Snuke can buy apple juice indefinitely in the i-th query; No otherwise.\n\nSample Input 1\n\n14\n9 7 5 9\n9 7 6 9\n14 10 7 12\n14 10 8 12\n14 10 9 12\n14 10 7 11\n14 10 8 11\n14 10 9 11\n9 10 5 10\n10 10 5 10\n11 10 5 10\n16 10 5 10\n1000000000000000000 17 14 999999999999999985\n1000000000000000000 17 15 999999999999999985\n\nSample Output 1\n\nNo\nYes\nNo\nYes\nYes\nNo\nNo\nYes\nNo\nYes\nYes\nNo\nNo\nYes\n\nIn the first query, the number of cans of juice in stock changes as follows: (D represents daytime and N represents night.)\n\n9\n→D 2\n→N 11\n→D 4\n→N 13\n→D 6\n→N 6\n→D x\n\nIn the second query, the number of cans of juice in stock changes as follows:\n\n9\n→D 2\n→N 11\n→D 4\n→N 13\n→D 6\n→N 15\n→D 8\n→N 8\n→D 1\n→N 10\n→D 3\n→N 12\n→D 5\n→N 14\n→D 7\n→N 7\n→D 0\n→N 9\n→D 2\n→N 11\n→D …\n\nand so on, thus Snuke can buy juice indefinitely.\n\nSample Input 2\n\n24\n1 2 3 4\n1 2 4 3\n1 3 2 4\n1 3 4 2\n1 4 2 3\n1 4 3 2\n2 1 3 4\n2 1 4 3\n2 3 1 4\n2 3 4 1\n2 4 1 3\n2 4 3 1\n3 1 2 4\n3 1 4 2\n3 2 1 4\n3 2 4 1\n3 4 1 2\n3 4 2 1\n4 1 2 3\n4 1 3 2\n4 2 1 3\n4 2 3 1\n4 3 1 2\n4 3 2 1\n\nSample Output 2\n\nNo\nNo\nNo\nNo\nNo\nNo\nYes\nYes\nNo\nNo\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo", "sample_input": "14\n9 7 5 9\n9 7 6 9\n14 10 7 12\n14 10 8 12\n14 10 9 12\n14 10 7 11\n14 10 8 11\n14 10 9 11\n9 10 5 10\n10 10 5 10\n11 10 5 10\n16 10 5 10\n1000000000000000000 17 14 999999999999999985\n1000000000000000000 17 15 999999999999999985\n"}, "reference_outputs": ["No\nYes\nNo\nYes\nYes\nNo\nNo\nYes\nNo\nYes\nYes\nNo\nNo\nYes\n"], "source_document_id": "p03297", "source_text": "Score : 600 points\n\nProblem Statement\n\nRingo Mart, a convenience store, sells apple juice.\n\nOn the opening day of Ringo Mart, there were A cans of juice in stock in the morning.\nSnuke buys B cans of juice here every day in the daytime.\nThen, the manager checks the number of cans of juice remaining in stock every night.\nIf there are C or less cans, D new cans will be added to the stock by the next morning.\n\nDetermine if Snuke can buy juice indefinitely, that is, there is always B or more cans of juice in stock when he attempts to buy them.\nNobody besides Snuke buy juice at this store.\n\nNote that each test case in this problem consists of T queries.\n\nConstraints\n\n1 \\leq T \\leq 300\n\n1 \\leq A, B, C, D \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT\nA_1 B_1 C_1 D_1\nA_2 B_2 C_2 D_2\n:\nA_T B_T C_T D_T\n\nIn the i-th query, A = A_i, B = B_i, C = C_i, D = D_i.\n\nOutput\n\nPrint T lines. The i-th line should contain Yes if Snuke can buy apple juice indefinitely in the i-th query; No otherwise.\n\nSample Input 1\n\n14\n9 7 5 9\n9 7 6 9\n14 10 7 12\n14 10 8 12\n14 10 9 12\n14 10 7 11\n14 10 8 11\n14 10 9 11\n9 10 5 10\n10 10 5 10\n11 10 5 10\n16 10 5 10\n1000000000000000000 17 14 999999999999999985\n1000000000000000000 17 15 999999999999999985\n\nSample Output 1\n\nNo\nYes\nNo\nYes\nYes\nNo\nNo\nYes\nNo\nYes\nYes\nNo\nNo\nYes\n\nIn the first query, the number of cans of juice in stock changes as follows: (D represents daytime and N represents night.)\n\n9\n→D 2\n→N 11\n→D 4\n→N 13\n→D 6\n→N 6\n→D x\n\nIn the second query, the number of cans of juice in stock changes as follows:\n\n9\n→D 2\n→N 11\n→D 4\n→N 13\n→D 6\n→N 15\n→D 8\n→N 8\n→D 1\n→N 10\n→D 3\n→N 12\n→D 5\n→N 14\n→D 7\n→N 7\n→D 0\n→N 9\n→D 2\n→N 11\n→D …\n\nand so on, thus Snuke can buy juice indefinitely.\n\nSample Input 2\n\n24\n1 2 3 4\n1 2 4 3\n1 3 2 4\n1 3 4 2\n1 4 2 3\n1 4 3 2\n2 1 3 4\n2 1 4 3\n2 3 1 4\n2 3 4 1\n2 4 1 3\n2 4 3 1\n3 1 2 4\n3 1 4 2\n3 2 1 4\n3 2 4 1\n3 4 1 2\n3 4 2 1\n4 1 2 3\n4 1 3 2\n4 2 1 3\n4 2 3 1\n4 3 1 2\n4 3 2 1\n\nSample Output 2\n\nNo\nNo\nNo\nNo\nNo\nNo\nYes\nYes\nNo\nNo\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5309, "cpu_time_ms": 375, "memory_kb": 26916}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s344625492", "group_id": "codeNet:p03297", "input_text": "import java.io._\nimport java.util.StringTokenizer\n\nimport scala.collection.mutable\nimport scala.util.Sorting\nimport math.{abs, max, min}\nimport scala.collection.mutable.{ArrayBuffer, ListBuffer}\nimport scala.reflect.ClassTag\n\nobject Main {\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n\n def solve(): Unit = {\n val sc = new InputReader(System.in)\n val N = sc.nextInt()\n rep(N) { _=>\n val a, b, c, d = sc.nextLong()\n val ok = if (a >= b && d >= b) {\n if (c + 1>= b) true\n else {\n gcd(b, d) match {\n case 1 => false\n case gcd =>\n val s = (a - b) % gcd\n val ms = c + 1\n val mx = b - 1\n val lower = ms % gcd\n val upper = mx % gcd\n\n if (lower <= upper) !(lower <= s && s <= upper)\n else !(lower <= s || s <= upper)\n }\n }\n } else false\n val ans = if (ok) \"Yes\" else \"No\"\n out.println(ans)\n }\n }\n\n\n def main(args: Array[String]): Unit = {\n solve()\n out.flush()\n }\n\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = null\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next().toInt\n def nextLong(): Long = next().toLong\n def nextChar(): Char = next().charAt(0)\n }\n def rep(n: Int)(f: Int => Unit): Unit = {\n var i = 0\n while(i < n) { f(i); i += 1 }\n }\n def rep_r(n: Int)(f: Int => Unit): Unit = {\n var i = n - 1\n while(i >= 0) { f(i); i -= 1 }\n }\n\n def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n rep(n)(i => res(i) = f(i))\n res\n }\n\n implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {\n // todo Orderingだとboxing発生するので自作Orderを用意したい\n def maxByOpt[B: Ordering](f: A => B): Option[A] = {\n if (as.nonEmpty) Some(as.maxBy(f)) else None\n }\n\n def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {\n val map = mutable.Map.empty[K, ArrayBuffer[A]]\n rep(as.length)(i => map.getOrElseUpdate(f(as(i)), ArrayBuffer()) += as(i))\n map\n }\n\n def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {\n var sum = num.zero\n rep(as.length)(i => sum = num.plus(sum, f(as(i))))\n sum\n }\n\n def minByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {\n limit(f, ixRange)(cmp.lt)\n }\n\n def maxByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {\n limit(f, ixRange)(cmp.gt)\n }\n\n private def limit[B](f: A => B, ixRange: Range)(cmp: (B, B) => Boolean): (A, B) = {\n var limA = as(ixRange.head)\n var limB = f(limA)\n\n for (i <- ixRange.tail) {\n val a = as(i)\n val b = f(a)\n if (cmp(b, limB)) {\n limA = a\n limB = b\n }\n }\n (limA, limB)\n }\n }\n\n implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {\n def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {\n as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))\n }\n }\n\n def gcd(a: Long, b: Long): Long = {\n val r = a % b\n if (r == 0) b\n else gcd(b, r)\n }\n}\n", "language": "Scala", "metadata": {"date": 1531622384, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03297.html", "problem_id": "p03297", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03297/input.txt", "sample_output_relpath": "derived/input_output/data/p03297/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03297/Scala/s344625492.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s344625492", "user_id": "u460609472"}, "prompt_components": {"gold_output": "No\nYes\nNo\nYes\nYes\nNo\nNo\nYes\nNo\nYes\nYes\nNo\nNo\nYes\n", "input_to_evaluate": "import java.io._\nimport java.util.StringTokenizer\n\nimport scala.collection.mutable\nimport scala.util.Sorting\nimport math.{abs, max, min}\nimport scala.collection.mutable.{ArrayBuffer, ListBuffer}\nimport scala.reflect.ClassTag\n\nobject Main {\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n\n def solve(): Unit = {\n val sc = new InputReader(System.in)\n val N = sc.nextInt()\n rep(N) { _=>\n val a, b, c, d = sc.nextLong()\n val ok = if (a >= b && d >= b) {\n if (c + 1>= b) true\n else {\n gcd(b, d) match {\n case 1 => false\n case gcd =>\n val s = (a - b) % gcd\n val ms = c + 1\n val mx = b - 1\n val lower = ms % gcd\n val upper = mx % gcd\n\n if (lower <= upper) !(lower <= s && s <= upper)\n else !(lower <= s || s <= upper)\n }\n }\n } else false\n val ans = if (ok) \"Yes\" else \"No\"\n out.println(ans)\n }\n }\n\n\n def main(args: Array[String]): Unit = {\n solve()\n out.flush()\n }\n\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = null\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next().toInt\n def nextLong(): Long = next().toLong\n def nextChar(): Char = next().charAt(0)\n }\n def rep(n: Int)(f: Int => Unit): Unit = {\n var i = 0\n while(i < n) { f(i); i += 1 }\n }\n def rep_r(n: Int)(f: Int => Unit): Unit = {\n var i = n - 1\n while(i >= 0) { f(i); i -= 1 }\n }\n\n def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n rep(n)(i => res(i) = f(i))\n res\n }\n\n implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {\n // todo Orderingだとboxing発生するので自作Orderを用意したい\n def maxByOpt[B: Ordering](f: A => B): Option[A] = {\n if (as.nonEmpty) Some(as.maxBy(f)) else None\n }\n\n def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {\n val map = mutable.Map.empty[K, ArrayBuffer[A]]\n rep(as.length)(i => map.getOrElseUpdate(f(as(i)), ArrayBuffer()) += as(i))\n map\n }\n\n def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {\n var sum = num.zero\n rep(as.length)(i => sum = num.plus(sum, f(as(i))))\n sum\n }\n\n def minByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {\n limit(f, ixRange)(cmp.lt)\n }\n\n def maxByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {\n limit(f, ixRange)(cmp.gt)\n }\n\n private def limit[B](f: A => B, ixRange: Range)(cmp: (B, B) => Boolean): (A, B) = {\n var limA = as(ixRange.head)\n var limB = f(limA)\n\n for (i <- ixRange.tail) {\n val a = as(i)\n val b = f(a)\n if (cmp(b, limB)) {\n limA = a\n limB = b\n }\n }\n (limA, limB)\n }\n }\n\n implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {\n def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {\n as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))\n }\n }\n\n def gcd(a: Long, b: Long): Long = {\n val r = a % b\n if (r == 0) b\n else gcd(b, r)\n }\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nRingo Mart, a convenience store, sells apple juice.\n\nOn the opening day of Ringo Mart, there were A cans of juice in stock in the morning.\nSnuke buys B cans of juice here every day in the daytime.\nThen, the manager checks the number of cans of juice remaining in stock every night.\nIf there are C or less cans, D new cans will be added to the stock by the next morning.\n\nDetermine if Snuke can buy juice indefinitely, that is, there is always B or more cans of juice in stock when he attempts to buy them.\nNobody besides Snuke buy juice at this store.\n\nNote that each test case in this problem consists of T queries.\n\nConstraints\n\n1 \\leq T \\leq 300\n\n1 \\leq A, B, C, D \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT\nA_1 B_1 C_1 D_1\nA_2 B_2 C_2 D_2\n:\nA_T B_T C_T D_T\n\nIn the i-th query, A = A_i, B = B_i, C = C_i, D = D_i.\n\nOutput\n\nPrint T lines. The i-th line should contain Yes if Snuke can buy apple juice indefinitely in the i-th query; No otherwise.\n\nSample Input 1\n\n14\n9 7 5 9\n9 7 6 9\n14 10 7 12\n14 10 8 12\n14 10 9 12\n14 10 7 11\n14 10 8 11\n14 10 9 11\n9 10 5 10\n10 10 5 10\n11 10 5 10\n16 10 5 10\n1000000000000000000 17 14 999999999999999985\n1000000000000000000 17 15 999999999999999985\n\nSample Output 1\n\nNo\nYes\nNo\nYes\nYes\nNo\nNo\nYes\nNo\nYes\nYes\nNo\nNo\nYes\n\nIn the first query, the number of cans of juice in stock changes as follows: (D represents daytime and N represents night.)\n\n9\n→D 2\n→N 11\n→D 4\n→N 13\n→D 6\n→N 6\n→D x\n\nIn the second query, the number of cans of juice in stock changes as follows:\n\n9\n→D 2\n→N 11\n→D 4\n→N 13\n→D 6\n→N 15\n→D 8\n→N 8\n→D 1\n→N 10\n→D 3\n→N 12\n→D 5\n→N 14\n→D 7\n→N 7\n→D 0\n→N 9\n→D 2\n→N 11\n→D …\n\nand so on, thus Snuke can buy juice indefinitely.\n\nSample Input 2\n\n24\n1 2 3 4\n1 2 4 3\n1 3 2 4\n1 3 4 2\n1 4 2 3\n1 4 3 2\n2 1 3 4\n2 1 4 3\n2 3 1 4\n2 3 4 1\n2 4 1 3\n2 4 3 1\n3 1 2 4\n3 1 4 2\n3 2 1 4\n3 2 4 1\n3 4 1 2\n3 4 2 1\n4 1 2 3\n4 1 3 2\n4 2 1 3\n4 2 3 1\n4 3 1 2\n4 3 2 1\n\nSample Output 2\n\nNo\nNo\nNo\nNo\nNo\nNo\nYes\nYes\nNo\nNo\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo", "sample_input": "14\n9 7 5 9\n9 7 6 9\n14 10 7 12\n14 10 8 12\n14 10 9 12\n14 10 7 11\n14 10 8 11\n14 10 9 11\n9 10 5 10\n10 10 5 10\n11 10 5 10\n16 10 5 10\n1000000000000000000 17 14 999999999999999985\n1000000000000000000 17 15 999999999999999985\n"}, "reference_outputs": ["No\nYes\nNo\nYes\nYes\nNo\nNo\nYes\nNo\nYes\nYes\nNo\nNo\nYes\n"], "source_document_id": "p03297", "source_text": "Score : 600 points\n\nProblem Statement\n\nRingo Mart, a convenience store, sells apple juice.\n\nOn the opening day of Ringo Mart, there were A cans of juice in stock in the morning.\nSnuke buys B cans of juice here every day in the daytime.\nThen, the manager checks the number of cans of juice remaining in stock every night.\nIf there are C or less cans, D new cans will be added to the stock by the next morning.\n\nDetermine if Snuke can buy juice indefinitely, that is, there is always B or more cans of juice in stock when he attempts to buy them.\nNobody besides Snuke buy juice at this store.\n\nNote that each test case in this problem consists of T queries.\n\nConstraints\n\n1 \\leq T \\leq 300\n\n1 \\leq A, B, C, D \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT\nA_1 B_1 C_1 D_1\nA_2 B_2 C_2 D_2\n:\nA_T B_T C_T D_T\n\nIn the i-th query, A = A_i, B = B_i, C = C_i, D = D_i.\n\nOutput\n\nPrint T lines. The i-th line should contain Yes if Snuke can buy apple juice indefinitely in the i-th query; No otherwise.\n\nSample Input 1\n\n14\n9 7 5 9\n9 7 6 9\n14 10 7 12\n14 10 8 12\n14 10 9 12\n14 10 7 11\n14 10 8 11\n14 10 9 11\n9 10 5 10\n10 10 5 10\n11 10 5 10\n16 10 5 10\n1000000000000000000 17 14 999999999999999985\n1000000000000000000 17 15 999999999999999985\n\nSample Output 1\n\nNo\nYes\nNo\nYes\nYes\nNo\nNo\nYes\nNo\nYes\nYes\nNo\nNo\nYes\n\nIn the first query, the number of cans of juice in stock changes as follows: (D represents daytime and N represents night.)\n\n9\n→D 2\n→N 11\n→D 4\n→N 13\n→D 6\n→N 6\n→D x\n\nIn the second query, the number of cans of juice in stock changes as follows:\n\n9\n→D 2\n→N 11\n→D 4\n→N 13\n→D 6\n→N 15\n→D 8\n→N 8\n→D 1\n→N 10\n→D 3\n→N 12\n→D 5\n→N 14\n→D 7\n→N 7\n→D 0\n→N 9\n→D 2\n→N 11\n→D …\n\nand so on, thus Snuke can buy juice indefinitely.\n\nSample Input 2\n\n24\n1 2 3 4\n1 2 4 3\n1 3 2 4\n1 3 4 2\n1 4 2 3\n1 4 3 2\n2 1 3 4\n2 1 4 3\n2 3 1 4\n2 3 4 1\n2 4 1 3\n2 4 3 1\n3 1 2 4\n3 1 4 2\n3 2 1 4\n3 2 4 1\n3 4 1 2\n3 4 2 1\n4 1 2 3\n4 1 3 2\n4 2 1 3\n4 2 3 1\n4 3 1 2\n4 3 2 1\n\nSample Output 2\n\nNo\nNo\nNo\nNo\nNo\nNo\nYes\nYes\nNo\nNo\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3454, "cpu_time_ms": 362, "memory_kb": 26516}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s467157193", "group_id": "codeNet:p03298", "input_text": "import java.util.Scanner\n\nimport scala.collection.Searching._\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.immutable._\nimport scala.io.StdIn.readLine\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(new Node(None, 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) => {\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n }\n}\n\nclass Sushi() {\n\n private case class Order(val order: Array[String])\n\n private var orders = Array.empty[(Long, Order)];\n\n def come(n: Long, a: Array[String]): Unit = {\n orders = (orders.takeWhile(_ match { case (x: Long, _) => x < n }) :+ (n, Order(a))) ++ orders.dropWhile(_ match { case (x: Long, _) => x <= n })\n }\n\n def takeout(s: String): Long = {\n orders.filter(_ match { case (_, order) => order.order.contains(s) }).headOption match {\n case Some((id, order)) => {\n come(id, order.order.takeWhile(_ != s) ++ order.order.dropWhile(_ != s).tail)\n id\n }\n case None => -1\n }\n }\n\n def leave(id: Long) = {\n orders = orders.filter(_._1 != id)\n }\n}\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val N = sc.nextInt\n val S = sc.next\n val S1 = S.take(N)\n val S2 = S.drop(N)\n val M1 = recursive(S1, \"\", \"\")\n val M2 = recursive(S2.reverse, \"\", \"\")\n val M1f = M1.filter(key => M2.keySet.contains(key._1))\n val M2f = M2.filter(key => M1f.keySet.contains(key._1))\n println(M1f.merged(M2f)({ case ((k, v1), (_, v2)) => (k, v1 * v2) }).values.sum)\n }\n\n def recursive(S: String, Left: String, Right: String): HashMap[(String, String), Long] = {\n if (S.size == 0) (HashMap((Left, Right) -> 1)) else {\n recursive(S.tail, Left + S.head, Right).merged(recursive(S.tail, Left, Right + S.head))({ case ((k, v1), (_, v2)) => (k, v1 + v2) })\n }\n }\n\n def recursive2(N: Long): String = {\n if (N == 0) (\"\") else (('a'.toInt + (N % 26)).toChar + recursive2(N / 26))\n }\n\n def check(A: Array[List[Int]]): Boolean = {\n A.map(_.size == 0).fold(true)((a, b) => a & b)\n }\n\n def shift(n: Long): Long = {\n if (n == 0) (0) else if (n == 1) (1) else (shift(n - 1) << 1)\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) (0) else (unShift(n >> 1) + 1)\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList(): Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: (Int) =?> String = {\n case src if (src >= 1 && src <= 3999) => {\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if (n == 0) => cont + unitChar\n case n if (n > 0) => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n }\n\n val romanToArabic: (String) =?> Int = {\n case src if (Option(src).exists { s => {\n s.nonEmpty && (\"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase) == None)\n }\n }) => {\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n }\n}", "language": "Scala", "metadata": {"date": 1531950429, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03298.html", "problem_id": "p03298", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03298/input.txt", "sample_output_relpath": "derived/input_output/data/p03298/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03298/Scala/s467157193.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s467157193", "user_id": "u779353743"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.collection.Searching._\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.immutable._\nimport scala.io.StdIn.readLine\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(new Node(None, 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) => {\n nodes(t).parent = Some(root(p))\n nodes(t).parent.get\n }\n }\n}\n\nclass Sushi() {\n\n private case class Order(val order: Array[String])\n\n private var orders = Array.empty[(Long, Order)];\n\n def come(n: Long, a: Array[String]): Unit = {\n orders = (orders.takeWhile(_ match { case (x: Long, _) => x < n }) :+ (n, Order(a))) ++ orders.dropWhile(_ match { case (x: Long, _) => x <= n })\n }\n\n def takeout(s: String): Long = {\n orders.filter(_ match { case (_, order) => order.order.contains(s) }).headOption match {\n case Some((id, order)) => {\n come(id, order.order.takeWhile(_ != s) ++ order.order.dropWhile(_ != s).tail)\n id\n }\n case None => -1\n }\n }\n\n def leave(id: Long) = {\n orders = orders.filter(_._1 != id)\n }\n}\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val N = sc.nextInt\n val S = sc.next\n val S1 = S.take(N)\n val S2 = S.drop(N)\n val M1 = recursive(S1, \"\", \"\")\n val M2 = recursive(S2.reverse, \"\", \"\")\n val M1f = M1.filter(key => M2.keySet.contains(key._1))\n val M2f = M2.filter(key => M1f.keySet.contains(key._1))\n println(M1f.merged(M2f)({ case ((k, v1), (_, v2)) => (k, v1 * v2) }).values.sum)\n }\n\n def recursive(S: String, Left: String, Right: String): HashMap[(String, String), Long] = {\n if (S.size == 0) (HashMap((Left, Right) -> 1)) else {\n recursive(S.tail, Left + S.head, Right).merged(recursive(S.tail, Left, Right + S.head))({ case ((k, v1), (_, v2)) => (k, v1 + v2) })\n }\n }\n\n def recursive2(N: Long): String = {\n if (N == 0) (\"\") else (('a'.toInt + (N % 26)).toChar + recursive2(N / 26))\n }\n\n def check(A: Array[List[Int]]): Boolean = {\n A.map(_.size == 0).fold(true)((a, b) => a & b)\n }\n\n def shift(n: Long): Long = {\n if (n == 0) (0) else if (n == 1) (1) else (shift(n - 1) << 1)\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) (0) else (unShift(n >> 1) + 1)\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n\nobject Util {\n def getPermutation(begin: Long = 0): Stream[Long] =\n Stream.cons(begin, getPermutation(begin + 1))\n\n def getPrimeList(): Stream[Long] =\n getPrimeListRecursive(getPermutation(begin = 2))\n\n private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)\n}\n\nobject ArabicRoman {\n\n type =?>[A, B] = PartialFunction[A, B]\n\n val codeTable = List(\n (1000, \"M\"), (900, \"CM\"), (500, \"D\"), (400, \"CD\"), (100, \"C\"),\n (90, \"XC\"), (50, \"L\"), (40, \"XL\"), (10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\"))\n\n val arabicToRoman: (Int) =?> String = {\n case src if (src >= 1 && src <= 3999) => {\n\n def convert(left: Int, cont: String = \"\", code: List[(Int, String)] = codeTable): String = {\n val (unitVal, unitChar) = code.head\n left - unitVal match {\n case n if (n == 0) => cont + unitChar\n case n if (n > 0) => convert(n, cont + unitChar, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src)\n }\n }\n\n val romanToArabic: (String) =?> Int = {\n case src if (Option(src).exists { s => {\n s.nonEmpty && (\"\"\"[^MDCLXVI]\"\"\".r.findFirstMatchIn(s.toUpperCase) == None)\n }\n }) => {\n\n def convert(left: String, cont: Int = 0, code: List[(Int, String)] = codeTable): Int = {\n val (unitVal, unitChar) = code.head\n left.splitAt(unitChar.length) match {\n case (\"\", _) => cont\n case (`unitChar`, tail) => convert(tail, cont + unitVal, code)\n case _ => convert(left, cont, code.tail)\n }\n }\n\n convert(src.toUpperCase())\n }\n }\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nYou are given a string S of length 2N consisting of lowercase English letters.\n\nThere are 2^{2N} ways to color each character in S red or blue. Among these ways, how many satisfy the following condition?\n\nThe string obtained by reading the characters painted red from left to right is equal to the string obtained by reading the characters painted blue from right to left.\n\nConstraints\n\n1 \\leq N \\leq 18\n\nThe length of S is 2N.\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of ways to paint the string that satisfy the condition.\n\nSample Input 1\n\n4\ncabaacba\n\nSample Output 1\n\n4\n\nThere are four ways to paint the string, as follows:\n\ncabaacba\n\ncabaacba\n\ncabaacba\n\ncabaacba\n\nSample Input 2\n\n11\nmippiisssisssiipsspiim\n\nSample Output 2\n\n504\n\nSample Input 3\n\n4\nabcdefgh\n\nSample Output 3\n\n0\n\nSample Input 4\n\n18\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n\nSample Output 4\n\n9075135300\n\nThe answer may not be representable as a 32-bit integer.", "sample_input": "4\ncabaacba\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03298", "source_text": "Score : 600 points\n\nProblem Statement\n\nYou are given a string S of length 2N consisting of lowercase English letters.\n\nThere are 2^{2N} ways to color each character in S red or blue. Among these ways, how many satisfy the following condition?\n\nThe string obtained by reading the characters painted red from left to right is equal to the string obtained by reading the characters painted blue from right to left.\n\nConstraints\n\n1 \\leq N \\leq 18\n\nThe length of S is 2N.\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of ways to paint the string that satisfy the condition.\n\nSample Input 1\n\n4\ncabaacba\n\nSample Output 1\n\n4\n\nThere are four ways to paint the string, as follows:\n\ncabaacba\n\ncabaacba\n\ncabaacba\n\ncabaacba\n\nSample Input 2\n\n11\nmippiisssisssiipsspiim\n\nSample Output 2\n\n504\n\nSample Input 3\n\n4\nabcdefgh\n\nSample Output 3\n\n0\n\nSample Input 4\n\n18\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n\nSample Output 4\n\n9075135300\n\nThe answer may not be representable as a 32-bit integer.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4904, "cpu_time_ms": 3171, "memory_kb": 240008}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s384008092", "group_id": "codeNet:p03305", "input_text": "import java.io.{BufferedReader, InputStream, InputStreamReader, PrintWriter}\nimport java.util.{Comparator, StringTokenizer}\n\nimport scala.collection.mutable\nimport scala.util.Sorting\nimport math.{abs, max, min}\nimport scala.collection.mutable.{ArrayBuffer, ListBuffer}\nimport scala.reflect.ClassTag\n\nobject Main {\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n def solve(): Unit = {\n val sc = new InputReader(System.in)\n val n, m = sc.nextInt()\n val s, t = sc.nextInt() - 1\n val u, v, a, b = Array.ofDim[Int](m)\n rep(m) { i =>\n u(i) = sc.nextInt() - 1\n v(i) = sc.nextInt() - 1\n a(i) = sc.nextInt()\n b(i) = sc.nextInt()\n }\n val g1 = packWUGraph(n, u, v, a)\n val g2 = packWUGraph(n, u, v, b)\n\n def dijk(g: WUGraph, start: Int): Array[Long] = {\n val d = Array.fill[Long](n)(Long.MaxValue / 2)\n case class Visit(node: Int, cost: Long) extends Comparable[Visit] {\n override def compareTo(o: Visit): Int = java.lang.Long.compare(cost, o.cost)\n }\n val queue = new java.util.PriorityQueue[Visit]()\n d(start) = 0\n queue.add(Visit(start, 0))\n\n while(!queue.isEmpty) {\n val v = queue.poll()\n if (d(v.node) == v.cost) {\n val es = g(v.node)\n es.indices foreach { i =>\n val e = es(i)\n val u = e(0)\n val c1 = e(1)\n if (d(u) > v.cost + c1) {\n d(u) = v.cost + c1\n queue.add(Visit(u, v.cost + c1))\n }\n }\n }\n }\n\n d\n }\n\n val d1 = dijk(g1, s)\n val d2 = dijk(g2, t)\n\n val money = 1e15.toLong\n val ans = map(n)(i => money - d1(i) - d2(i))\n rep_r(n - 1)(i => ans(i) = max(ans(i), ans(i + 1)))\n rep(n)(i => out.println(ans(i)))\n }\n\n\n def main(args: Array[String]): Unit = {\n solve()\n out.flush()\n }\n\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = null\n\n def next: String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next.toInt\n def nextLong(): Long = next.toLong\n def nextChar(): Char = next.charAt(0)\n }\n\n private def rep(n: Int)(f: Int => Unit): Unit = (0 until n) foreach f\n private def rep_r(n: Int)(f: Int => Unit): Unit = (0 until n).reverse foreach f\n\n private def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n (0 until n) foreach (i => res(i) = f(i))\n res\n }\n\n private implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {\n def maxByOpt[B: Ordering](f: A => B): Option[A] = {\n if (as.nonEmpty) Some(as.maxBy(f)) else None\n }\n\n def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {\n val map = mutable.Map.empty[K, ArrayBuffer[A]]\n as foreach (a => map.getOrElseUpdate(f(a), ArrayBuffer()) += a)\n map\n }\n\n def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {\n var sum = num.zero\n as foreach (a => sum = num.plus(sum, f(a)))\n sum\n }\n\n def minByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {\n limit(f, ixRange)(cmp.lt)\n }\n\n def maxByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {\n limit(f, ixRange)(cmp.gt)\n }\n\n private def limit[B](f: A => B, ixRange: Range)(cmp: (B, B) => Boolean): (A, B) = {\n var limA = as(ixRange.head)\n var limB = f(limA)\n\n for (i <- ixRange.tail) {\n val a = as(i)\n val b = f(a)\n if (cmp(b, limB)) {\n limA = a\n limB = b\n }\n }\n (limA, limB)\n }\n }\n\n private implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {\n def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {\n as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))\n }\n }\n\n type WUGraph = Array[Array[Array[Int]]]\n /**\n * uwiのぱくり\n */\n def packWUGraph(n: Int, from: Array[Int], to: Array[Int], w: Array[Int]): WUGraph = {\n val g = new Array[Array[Array[Int]]](n)\n val p = new Array[Int](n)\n val m = from.length\n rep(m)(i => p(from(i)) += 1)\n rep(m)(i => p(to(i)) += 1)\n rep(n)(i => g(i) = Array.ofDim[Int](p(i), 2))\n rep(m) { i =>\n p(from(i)) -= 1\n g(from(i))(p(from(i)))(0) = to(i)\n g(from(i))(p(from(i)))(1) = w(i)\n p(to(i)) -= 1\n g(to(i))(p(to(i)))(0) = from(i)\n g(to(i))(p(to(i)))(1) = w(i)\n }\n g\n }\n}\n", "language": "Scala", "metadata": {"date": 1531038385, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03305.html", "problem_id": "p03305", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03305/input.txt", "sample_output_relpath": "derived/input_output/data/p03305/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03305/Scala/s384008092.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s384008092", "user_id": "u460609472"}, "prompt_components": {"gold_output": "999999999999998\n999999999999989\n999999999999979\n999999999999897\n", "input_to_evaluate": "import java.io.{BufferedReader, InputStream, InputStreamReader, PrintWriter}\nimport java.util.{Comparator, StringTokenizer}\n\nimport scala.collection.mutable\nimport scala.util.Sorting\nimport math.{abs, max, min}\nimport scala.collection.mutable.{ArrayBuffer, ListBuffer}\nimport scala.reflect.ClassTag\n\nobject Main {\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n def solve(): Unit = {\n val sc = new InputReader(System.in)\n val n, m = sc.nextInt()\n val s, t = sc.nextInt() - 1\n val u, v, a, b = Array.ofDim[Int](m)\n rep(m) { i =>\n u(i) = sc.nextInt() - 1\n v(i) = sc.nextInt() - 1\n a(i) = sc.nextInt()\n b(i) = sc.nextInt()\n }\n val g1 = packWUGraph(n, u, v, a)\n val g2 = packWUGraph(n, u, v, b)\n\n def dijk(g: WUGraph, start: Int): Array[Long] = {\n val d = Array.fill[Long](n)(Long.MaxValue / 2)\n case class Visit(node: Int, cost: Long) extends Comparable[Visit] {\n override def compareTo(o: Visit): Int = java.lang.Long.compare(cost, o.cost)\n }\n val queue = new java.util.PriorityQueue[Visit]()\n d(start) = 0\n queue.add(Visit(start, 0))\n\n while(!queue.isEmpty) {\n val v = queue.poll()\n if (d(v.node) == v.cost) {\n val es = g(v.node)\n es.indices foreach { i =>\n val e = es(i)\n val u = e(0)\n val c1 = e(1)\n if (d(u) > v.cost + c1) {\n d(u) = v.cost + c1\n queue.add(Visit(u, v.cost + c1))\n }\n }\n }\n }\n\n d\n }\n\n val d1 = dijk(g1, s)\n val d2 = dijk(g2, t)\n\n val money = 1e15.toLong\n val ans = map(n)(i => money - d1(i) - d2(i))\n rep_r(n - 1)(i => ans(i) = max(ans(i), ans(i + 1)))\n rep(n)(i => out.println(ans(i)))\n }\n\n\n def main(args: Array[String]): Unit = {\n solve()\n out.flush()\n }\n\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = null\n\n def next: String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next.toInt\n def nextLong(): Long = next.toLong\n def nextChar(): Char = next.charAt(0)\n }\n\n private def rep(n: Int)(f: Int => Unit): Unit = (0 until n) foreach f\n private def rep_r(n: Int)(f: Int => Unit): Unit = (0 until n).reverse foreach f\n\n private def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n (0 until n) foreach (i => res(i) = f(i))\n res\n }\n\n private implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {\n def maxByOpt[B: Ordering](f: A => B): Option[A] = {\n if (as.nonEmpty) Some(as.maxBy(f)) else None\n }\n\n def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {\n val map = mutable.Map.empty[K, ArrayBuffer[A]]\n as foreach (a => map.getOrElseUpdate(f(a), ArrayBuffer()) += a)\n map\n }\n\n def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {\n var sum = num.zero\n as foreach (a => sum = num.plus(sum, f(a)))\n sum\n }\n\n def minByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {\n limit(f, ixRange)(cmp.lt)\n }\n\n def maxByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {\n limit(f, ixRange)(cmp.gt)\n }\n\n private def limit[B](f: A => B, ixRange: Range)(cmp: (B, B) => Boolean): (A, B) = {\n var limA = as(ixRange.head)\n var limB = f(limA)\n\n for (i <- ixRange.tail) {\n val a = as(i)\n val b = f(a)\n if (cmp(b, limB)) {\n limA = a\n limB = b\n }\n }\n (limA, limB)\n }\n }\n\n private implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {\n def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {\n as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))\n }\n }\n\n type WUGraph = Array[Array[Array[Int]]]\n /**\n * uwiのぱくり\n */\n def packWUGraph(n: Int, from: Array[Int], to: Array[Int], w: Array[Int]): WUGraph = {\n val g = new Array[Array[Array[Int]]](n)\n val p = new Array[Int](n)\n val m = from.length\n rep(m)(i => p(from(i)) += 1)\n rep(m)(i => p(to(i)) += 1)\n rep(n)(i => g(i) = Array.ofDim[Int](p(i), 2))\n rep(m) { i =>\n p(from(i)) -= 1\n g(from(i))(p(from(i)))(0) = to(i)\n g(from(i))(p(from(i)))(1) = w(i)\n p(to(i)) -= 1\n g(to(i))(p(to(i)))(0) = from(i)\n g(to(i))(p(to(i)))(1) = w(i)\n }\n g\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nKenkoooo is planning a trip in Republic of Snuke.\nIn this country, there are n cities and m trains running.\nThe cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally.\nAny city can be reached from any city by changing trains.\n\nTwo currencies are used in the country: yen and snuuk.\nAny train fare can be paid by both yen and snuuk.\nThe fare of the i-th train is a_i yen if paid in yen, and b_i snuuk if paid in snuuk.\n\nIn a city with a money exchange office, you can change 1 yen into 1 snuuk.\nHowever, when you do a money exchange, you have to change all your yen into snuuk.\nThat is, if Kenkoooo does a money exchange when he has X yen, he will then have X snuuk.\nCurrently, there is a money exchange office in every city, but the office in City i will shut down in i years and can never be used in and after that year.\n\nKenkoooo is planning to depart City s with 10^{15} yen in his pocket and head for City t, and change his yen into snuuk in some city while traveling.\nIt is acceptable to do the exchange in City s or City t.\n\nKenkoooo would like to have as much snuuk as possible when he reaches City t by making the optimal choices for the route to travel and the city to do the exchange.\nFor each i=0,...,n-1, find the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i years.\nYou can assume that the trip finishes within the year.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\n1 \\leq m \\leq 10^5\n\n1 \\leq s,t \\leq n\n\ns \\neq t\n\n1 \\leq u_i < v_i \\leq n\n\n1 \\leq a_i,b_i \\leq 10^9\n\nIf i\\neq j, then u_i \\neq u_j or v_i \\neq v_j.\n\nAny city can be reached from any city by changing trains.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn m s t\nu_1 v_1 a_1 b_1\n:\nu_m v_m a_m b_m\n\nOutput\n\nPrint n lines.\nIn the i-th line, print the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i-1 years.\n\nSample Input 1\n\n4 3 2 3\n1 4 1 100\n1 2 1 10\n1 3 20 1\n\nSample Output 1\n\n999999999999998\n999999999999989\n999999999999979\n999999999999897\n\nAfter 0 years, it is optimal to do the exchange in City 1.\n\nAfter 1 years, it is optimal to do the exchange in City 2.\n\nNote that City 1 can still be visited even after the exchange office is closed.\nAlso note that, if it was allowed to keep 1 yen when do the exchange in City 2 and change the remaining yen into snuuk, we could reach City 3 with 999999999999998 snuuk, but this is NOT allowed.\n\nAfter 2 years, it is optimal to do the exchange in City 3.\n\nAfter 3 years, it is optimal to do the exchange in City 4.\nNote that the same train can be used multiple times.\n\nSample Input 2\n\n8 12 3 8\n2 8 685087149 857180777\n6 7 298270585 209942236\n2 4 346080035 234079976\n2 5 131857300 22507157\n4 8 30723332 173476334\n2 6 480845267 448565596\n1 4 181424400 548830121\n4 5 57429995 195056405\n7 8 160277628 479932440\n1 6 475692952 203530153\n3 5 336869679 160714712\n2 7 389775999 199123879\n\nSample Output 2\n\n999999574976994\n999999574976994\n999999574976994\n999999574976994\n999999574976994\n999999574976994\n999999574976994\n999999574976994", "sample_input": "4 3 2 3\n1 4 1 100\n1 2 1 10\n1 3 20 1\n"}, "reference_outputs": ["999999999999998\n999999999999989\n999999999999979\n999999999999897\n"], "source_document_id": "p03305", "source_text": "Score : 400 points\n\nProblem Statement\n\nKenkoooo is planning a trip in Republic of Snuke.\nIn this country, there are n cities and m trains running.\nThe cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally.\nAny city can be reached from any city by changing trains.\n\nTwo currencies are used in the country: yen and snuuk.\nAny train fare can be paid by both yen and snuuk.\nThe fare of the i-th train is a_i yen if paid in yen, and b_i snuuk if paid in snuuk.\n\nIn a city with a money exchange office, you can change 1 yen into 1 snuuk.\nHowever, when you do a money exchange, you have to change all your yen into snuuk.\nThat is, if Kenkoooo does a money exchange when he has X yen, he will then have X snuuk.\nCurrently, there is a money exchange office in every city, but the office in City i will shut down in i years and can never be used in and after that year.\n\nKenkoooo is planning to depart City s with 10^{15} yen in his pocket and head for City t, and change his yen into snuuk in some city while traveling.\nIt is acceptable to do the exchange in City s or City t.\n\nKenkoooo would like to have as much snuuk as possible when he reaches City t by making the optimal choices for the route to travel and the city to do the exchange.\nFor each i=0,...,n-1, find the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i years.\nYou can assume that the trip finishes within the year.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\n1 \\leq m \\leq 10^5\n\n1 \\leq s,t \\leq n\n\ns \\neq t\n\n1 \\leq u_i < v_i \\leq n\n\n1 \\leq a_i,b_i \\leq 10^9\n\nIf i\\neq j, then u_i \\neq u_j or v_i \\neq v_j.\n\nAny city can be reached from any city by changing trains.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn m s t\nu_1 v_1 a_1 b_1\n:\nu_m v_m a_m b_m\n\nOutput\n\nPrint n lines.\nIn the i-th line, print the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i-1 years.\n\nSample Input 1\n\n4 3 2 3\n1 4 1 100\n1 2 1 10\n1 3 20 1\n\nSample Output 1\n\n999999999999998\n999999999999989\n999999999999979\n999999999999897\n\nAfter 0 years, it is optimal to do the exchange in City 1.\n\nAfter 1 years, it is optimal to do the exchange in City 2.\n\nNote that City 1 can still be visited even after the exchange office is closed.\nAlso note that, if it was allowed to keep 1 yen when do the exchange in City 2 and change the remaining yen into snuuk, we could reach City 3 with 999999999999998 snuuk, but this is NOT allowed.\n\nAfter 2 years, it is optimal to do the exchange in City 3.\n\nAfter 3 years, it is optimal to do the exchange in City 4.\nNote that the same train can be used multiple times.\n\nSample Input 2\n\n8 12 3 8\n2 8 685087149 857180777\n6 7 298270585 209942236\n2 4 346080035 234079976\n2 5 131857300 22507157\n4 8 30723332 173476334\n2 6 480845267 448565596\n1 4 181424400 548830121\n4 5 57429995 195056405\n7 8 160277628 479932440\n1 6 475692952 203530153\n3 5 336869679 160714712\n2 7 389775999 199123879\n\nSample Output 2\n\n999999574976994\n999999574976994\n999999574976994\n999999574976994\n999999574976994\n999999574976994\n999999574976994\n999999574976994", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4627, "cpu_time_ms": 1224, "memory_kb": 80264}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s236157805", "group_id": "codeNet:p03305", "input_text": "import java.io.{BufferedReader, InputStream, InputStreamReader, PrintWriter}\nimport java.util.StringTokenizer\n\nimport scala.collection.mutable\nimport scala.util.Sorting\nimport math.{abs, max, min}\nimport scala.collection.mutable.{ArrayBuffer, ListBuffer}\nimport scala.reflect.ClassTag\n\nobject Main {\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n def solve(): Unit = {\n val sc = new InputReader(System.in)\n val n, m = sc.nextInt()\n val s, t = sc.nextInt() - 1\n type Node = Int\n type Edge = (Node ,Long)\n val t1, t2 = map(n)(_ => ArrayBuffer.empty[Edge])\n rep(m) { _ =>\n val u, v = sc.nextInt() - 1\n val a, b = sc.nextLong()\n t1(u) += ((v, a))\n t1(v) += ((u, a))\n t2(u) += ((v, b))\n t2(v) += ((u, b))\n }\n\n def dijkstra(tree: Array[ArrayBuffer[Edge]], start: Int): Array[Long] = {\n val d = Array.fill[Long](n)(Long.MaxValue)\n type Visit = (Node, Long)\n val queue = mutable.PriorityQueue.empty[Visit](Ordering.by[Visit, Long](_._2).reverse)\n d(start) = 0\n queue.enqueue((start, 0))\n\n while(queue.nonEmpty) {\n val (v, c0) = queue.dequeue()\n if (d(v) == c0) {\n tree(v) foreach { case (u, c1) =>\n if (d(u) > c0 + c1) {\n d(u) = c0 + c1\n queue.enqueue((u, c0 + c1))\n }\n }\n }\n }\n\n d\n }\n\n val d1 = dijkstra(t1, s)\n val d2 = dijkstra(t2, t)\n\n val d = map(n){ i =>\n val j = n - 1 - i\n d1(j) + d2(j)\n }\n rep(n - 1) { i =>\n d(i + 1) = min(d(i + 1), d(i))\n }\n rep(n) { i =>\n val j = n - 1 - i\n val ans = 1000000000000000L - d(j)\n out.println(ans)\n }\n }\n\n\n def main(args: Array[String]): Unit = {\n solve()\n out.flush()\n }\n\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = null\n\n def next: String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next.toInt\n def nextLong(): Long = next.toLong\n def nextChar(): Char = next.charAt(0)\n }\n\n private def rep(n: Int)(f: Int => Unit): Unit = (0 until n) foreach f\n\n private def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n (0 until n) foreach (i => res(i) = f(i))\n res\n }\n\n private implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {\n def maxByOpt[B: Ordering](f: A => B): Option[A] = {\n if (as.nonEmpty) Some(as.maxBy(f)) else None\n }\n\n def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {\n val map = mutable.Map.empty[K, ArrayBuffer[A]]\n rep(a => map.getOrElseUpdate(f(a), ArrayBuffer()) += a)\n map\n }\n\n def rep(f: A => Unit): Unit = {\n as.indices foreach (i => f(as(i)))\n }\n\n def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {\n var sum = num.zero\n rep(a => sum = num.plus(sum, f(a)))\n sum\n }\n\n def minByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {\n limit(f, ixRange)(cmp.lt)\n }\n\n def maxByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {\n limit(f, ixRange)(cmp.gt)\n }\n\n private def limit[B](f: A => B, ixRange: Range)(cmp: (B, B) => Boolean): (A, B) = {\n var limA = as(ixRange.head)\n var limB = f(limA)\n\n for (i <- ixRange.tail) {\n val a = as(i)\n val b = f(a)\n if (cmp(b, limB)) {\n limA = a\n limB = b\n }\n }\n (limA, limB)\n }\n }\n\n private implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {\n def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {\n as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1531030741, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03305.html", "problem_id": "p03305", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03305/input.txt", "sample_output_relpath": "derived/input_output/data/p03305/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03305/Scala/s236157805.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s236157805", "user_id": "u460609472"}, "prompt_components": {"gold_output": "999999999999998\n999999999999989\n999999999999979\n999999999999897\n", "input_to_evaluate": "import java.io.{BufferedReader, InputStream, InputStreamReader, PrintWriter}\nimport java.util.StringTokenizer\n\nimport scala.collection.mutable\nimport scala.util.Sorting\nimport math.{abs, max, min}\nimport scala.collection.mutable.{ArrayBuffer, ListBuffer}\nimport scala.reflect.ClassTag\n\nobject Main {\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n def solve(): Unit = {\n val sc = new InputReader(System.in)\n val n, m = sc.nextInt()\n val s, t = sc.nextInt() - 1\n type Node = Int\n type Edge = (Node ,Long)\n val t1, t2 = map(n)(_ => ArrayBuffer.empty[Edge])\n rep(m) { _ =>\n val u, v = sc.nextInt() - 1\n val a, b = sc.nextLong()\n t1(u) += ((v, a))\n t1(v) += ((u, a))\n t2(u) += ((v, b))\n t2(v) += ((u, b))\n }\n\n def dijkstra(tree: Array[ArrayBuffer[Edge]], start: Int): Array[Long] = {\n val d = Array.fill[Long](n)(Long.MaxValue)\n type Visit = (Node, Long)\n val queue = mutable.PriorityQueue.empty[Visit](Ordering.by[Visit, Long](_._2).reverse)\n d(start) = 0\n queue.enqueue((start, 0))\n\n while(queue.nonEmpty) {\n val (v, c0) = queue.dequeue()\n if (d(v) == c0) {\n tree(v) foreach { case (u, c1) =>\n if (d(u) > c0 + c1) {\n d(u) = c0 + c1\n queue.enqueue((u, c0 + c1))\n }\n }\n }\n }\n\n d\n }\n\n val d1 = dijkstra(t1, s)\n val d2 = dijkstra(t2, t)\n\n val d = map(n){ i =>\n val j = n - 1 - i\n d1(j) + d2(j)\n }\n rep(n - 1) { i =>\n d(i + 1) = min(d(i + 1), d(i))\n }\n rep(n) { i =>\n val j = n - 1 - i\n val ans = 1000000000000000L - d(j)\n out.println(ans)\n }\n }\n\n\n def main(args: Array[String]): Unit = {\n solve()\n out.flush()\n }\n\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = null\n\n def next: String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next.toInt\n def nextLong(): Long = next.toLong\n def nextChar(): Char = next.charAt(0)\n }\n\n private def rep(n: Int)(f: Int => Unit): Unit = (0 until n) foreach f\n\n private def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n (0 until n) foreach (i => res(i) = f(i))\n res\n }\n\n private implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {\n def maxByOpt[B: Ordering](f: A => B): Option[A] = {\n if (as.nonEmpty) Some(as.maxBy(f)) else None\n }\n\n def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {\n val map = mutable.Map.empty[K, ArrayBuffer[A]]\n rep(a => map.getOrElseUpdate(f(a), ArrayBuffer()) += a)\n map\n }\n\n def rep(f: A => Unit): Unit = {\n as.indices foreach (i => f(as(i)))\n }\n\n def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {\n var sum = num.zero\n rep(a => sum = num.plus(sum, f(a)))\n sum\n }\n\n def minByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {\n limit(f, ixRange)(cmp.lt)\n }\n\n def maxByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {\n limit(f, ixRange)(cmp.gt)\n }\n\n private def limit[B](f: A => B, ixRange: Range)(cmp: (B, B) => Boolean): (A, B) = {\n var limA = as(ixRange.head)\n var limB = f(limA)\n\n for (i <- ixRange.tail) {\n val a = as(i)\n val b = f(a)\n if (cmp(b, limB)) {\n limA = a\n limB = b\n }\n }\n (limA, limB)\n }\n }\n\n private implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {\n def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {\n as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))\n }\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nKenkoooo is planning a trip in Republic of Snuke.\nIn this country, there are n cities and m trains running.\nThe cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally.\nAny city can be reached from any city by changing trains.\n\nTwo currencies are used in the country: yen and snuuk.\nAny train fare can be paid by both yen and snuuk.\nThe fare of the i-th train is a_i yen if paid in yen, and b_i snuuk if paid in snuuk.\n\nIn a city with a money exchange office, you can change 1 yen into 1 snuuk.\nHowever, when you do a money exchange, you have to change all your yen into snuuk.\nThat is, if Kenkoooo does a money exchange when he has X yen, he will then have X snuuk.\nCurrently, there is a money exchange office in every city, but the office in City i will shut down in i years and can never be used in and after that year.\n\nKenkoooo is planning to depart City s with 10^{15} yen in his pocket and head for City t, and change his yen into snuuk in some city while traveling.\nIt is acceptable to do the exchange in City s or City t.\n\nKenkoooo would like to have as much snuuk as possible when he reaches City t by making the optimal choices for the route to travel and the city to do the exchange.\nFor each i=0,...,n-1, find the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i years.\nYou can assume that the trip finishes within the year.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\n1 \\leq m \\leq 10^5\n\n1 \\leq s,t \\leq n\n\ns \\neq t\n\n1 \\leq u_i < v_i \\leq n\n\n1 \\leq a_i,b_i \\leq 10^9\n\nIf i\\neq j, then u_i \\neq u_j or v_i \\neq v_j.\n\nAny city can be reached from any city by changing trains.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn m s t\nu_1 v_1 a_1 b_1\n:\nu_m v_m a_m b_m\n\nOutput\n\nPrint n lines.\nIn the i-th line, print the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i-1 years.\n\nSample Input 1\n\n4 3 2 3\n1 4 1 100\n1 2 1 10\n1 3 20 1\n\nSample Output 1\n\n999999999999998\n999999999999989\n999999999999979\n999999999999897\n\nAfter 0 years, it is optimal to do the exchange in City 1.\n\nAfter 1 years, it is optimal to do the exchange in City 2.\n\nNote that City 1 can still be visited even after the exchange office is closed.\nAlso note that, if it was allowed to keep 1 yen when do the exchange in City 2 and change the remaining yen into snuuk, we could reach City 3 with 999999999999998 snuuk, but this is NOT allowed.\n\nAfter 2 years, it is optimal to do the exchange in City 3.\n\nAfter 3 years, it is optimal to do the exchange in City 4.\nNote that the same train can be used multiple times.\n\nSample Input 2\n\n8 12 3 8\n2 8 685087149 857180777\n6 7 298270585 209942236\n2 4 346080035 234079976\n2 5 131857300 22507157\n4 8 30723332 173476334\n2 6 480845267 448565596\n1 4 181424400 548830121\n4 5 57429995 195056405\n7 8 160277628 479932440\n1 6 475692952 203530153\n3 5 336869679 160714712\n2 7 389775999 199123879\n\nSample Output 2\n\n999999574976994\n999999574976994\n999999574976994\n999999574976994\n999999574976994\n999999574976994\n999999574976994\n999999574976994", "sample_input": "4 3 2 3\n1 4 1 100\n1 2 1 10\n1 3 20 1\n"}, "reference_outputs": ["999999999999998\n999999999999989\n999999999999979\n999999999999897\n"], "source_document_id": "p03305", "source_text": "Score : 400 points\n\nProblem Statement\n\nKenkoooo is planning a trip in Republic of Snuke.\nIn this country, there are n cities and m trains running.\nThe cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally.\nAny city can be reached from any city by changing trains.\n\nTwo currencies are used in the country: yen and snuuk.\nAny train fare can be paid by both yen and snuuk.\nThe fare of the i-th train is a_i yen if paid in yen, and b_i snuuk if paid in snuuk.\n\nIn a city with a money exchange office, you can change 1 yen into 1 snuuk.\nHowever, when you do a money exchange, you have to change all your yen into snuuk.\nThat is, if Kenkoooo does a money exchange when he has X yen, he will then have X snuuk.\nCurrently, there is a money exchange office in every city, but the office in City i will shut down in i years and can never be used in and after that year.\n\nKenkoooo is planning to depart City s with 10^{15} yen in his pocket and head for City t, and change his yen into snuuk in some city while traveling.\nIt is acceptable to do the exchange in City s or City t.\n\nKenkoooo would like to have as much snuuk as possible when he reaches City t by making the optimal choices for the route to travel and the city to do the exchange.\nFor each i=0,...,n-1, find the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i years.\nYou can assume that the trip finishes within the year.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\n1 \\leq m \\leq 10^5\n\n1 \\leq s,t \\leq n\n\ns \\neq t\n\n1 \\leq u_i < v_i \\leq n\n\n1 \\leq a_i,b_i \\leq 10^9\n\nIf i\\neq j, then u_i \\neq u_j or v_i \\neq v_j.\n\nAny city can be reached from any city by changing trains.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn m s t\nu_1 v_1 a_1 b_1\n:\nu_m v_m a_m b_m\n\nOutput\n\nPrint n lines.\nIn the i-th line, print the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i-1 years.\n\nSample Input 1\n\n4 3 2 3\n1 4 1 100\n1 2 1 10\n1 3 20 1\n\nSample Output 1\n\n999999999999998\n999999999999989\n999999999999979\n999999999999897\n\nAfter 0 years, it is optimal to do the exchange in City 1.\n\nAfter 1 years, it is optimal to do the exchange in City 2.\n\nNote that City 1 can still be visited even after the exchange office is closed.\nAlso note that, if it was allowed to keep 1 yen when do the exchange in City 2 and change the remaining yen into snuuk, we could reach City 3 with 999999999999998 snuuk, but this is NOT allowed.\n\nAfter 2 years, it is optimal to do the exchange in City 3.\n\nAfter 3 years, it is optimal to do the exchange in City 4.\nNote that the same train can be used multiple times.\n\nSample Input 2\n\n8 12 3 8\n2 8 685087149 857180777\n6 7 298270585 209942236\n2 4 346080035 234079976\n2 5 131857300 22507157\n4 8 30723332 173476334\n2 6 480845267 448565596\n1 4 181424400 548830121\n4 5 57429995 195056405\n7 8 160277628 479932440\n1 6 475692952 203530153\n3 5 336869679 160714712\n2 7 389775999 199123879\n\nSample Output 2\n\n999999574976994\n999999574976994\n999999574976994\n999999574976994\n999999574976994\n999999574976994\n999999574976994\n999999574976994", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3931, "cpu_time_ms": 1610, "memory_kb": 144232}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s395062457", "group_id": "codeNet:p03308", "input_text": "import scala.io.StdIn._\n\nobject Main extends App {\n val n = readInt()\n val a = readLine().split(\" \").map(_.toInt).toSeq\n\n def maxDiff(list: Seq[Int], max: Int): Int = {\n if (list.length > 2) {\n val i = (0 until list.length - 1).maxBy(i => (list(0) - list(i + 1)).abs)\n maxDiff(list.tail, math.max((list(0) - list(1 + 1)).abs, max))\n } else\n math.max((list(0) - list(1)).abs, max)\n }\n\n println(maxDiff(a, 0))\n}\n", "language": "Scala", "metadata": {"date": 1599662552, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03308.html", "problem_id": "p03308", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03308/input.txt", "sample_output_relpath": "derived/input_output/data/p03308/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03308/Scala/s395062457.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s395062457", "user_id": "u004161348"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main extends App {\n val n = readInt()\n val a = readLine().split(\" \").map(_.toInt).toSeq\n\n def maxDiff(list: Seq[Int], max: Int): Int = {\n if (list.length > 2) {\n val i = (0 until list.length - 1).maxBy(i => (list(0) - list(i + 1)).abs)\n maxDiff(list.tail, math.max((list(0) - list(1 + 1)).abs, max))\n } else\n math.max((list(0) - list(1)).abs, max)\n }\n\n println(maxDiff(a, 0))\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given an integer sequence A of length N.\nFind the maximum absolute difference of two elements (with different indices) in A.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum absolute difference of two elements (with different indices) in A.\n\nSample Input 1\n\n4\n1 4 6 3\n\nSample Output 1\n\n5\n\nThe maximum absolute difference of two elements is A_3-A_1=6-1=5.\n\nSample Input 2\n\n2\n1000000000 1\n\nSample Output 2\n\n999999999\n\nSample Input 3\n\n5\n1 1 1 1 1\n\nSample Output 3\n\n0", "sample_input": "4\n1 4 6 3\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03308", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given an integer sequence A of length N.\nFind the maximum absolute difference of two elements (with different indices) in A.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum absolute difference of two elements (with different indices) in A.\n\nSample Input 1\n\n4\n1 4 6 3\n\nSample Output 1\n\n5\n\nThe maximum absolute difference of two elements is A_3-A_1=6-1=5.\n\nSample Input 2\n\n2\n1000000000 1\n\nSample Output 2\n\n999999999\n\nSample Input 3\n\n5\n1 1 1 1 1\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 436, "cpu_time_ms": 505, "memory_kb": 54988}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s780315249", "group_id": "codeNet:p03308", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n\n val n = StdIn.readLine().toInt\n val a = StdIn.readLine().split(\" \").map(_.toLong)\n\n println(a.max - a.min)\n /* NG\n val r = a.foldLeft((1L, 1L)){ (acc, ai) =>\n val min = scala.math.min(acc._1, ai)\n val max = scala.math.max(acc._2, ai)\n (min, max)\n }\n */\n}", "language": "Scala", "metadata": {"date": 1534675075, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03308.html", "problem_id": "p03308", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03308/input.txt", "sample_output_relpath": "derived/input_output/data/p03308/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03308/Scala/s780315249.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s780315249", "user_id": "u895032849"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n\n val n = StdIn.readLine().toInt\n val a = StdIn.readLine().split(\" \").map(_.toLong)\n\n println(a.max - a.min)\n /* NG\n val r = a.foldLeft((1L, 1L)){ (acc, ai) =>\n val min = scala.math.min(acc._1, ai)\n val max = scala.math.max(acc._2, ai)\n (min, max)\n }\n */\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given an integer sequence A of length N.\nFind the maximum absolute difference of two elements (with different indices) in A.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum absolute difference of two elements (with different indices) in A.\n\nSample Input 1\n\n4\n1 4 6 3\n\nSample Output 1\n\n5\n\nThe maximum absolute difference of two elements is A_3-A_1=6-1=5.\n\nSample Input 2\n\n2\n1000000000 1\n\nSample Output 2\n\n999999999\n\nSample Input 3\n\n5\n1 1 1 1 1\n\nSample Output 3\n\n0", "sample_input": "4\n1 4 6 3\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03308", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given an integer sequence A of length N.\nFind the maximum absolute difference of two elements (with different indices) in A.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum absolute difference of two elements (with different indices) in A.\n\nSample Input 1\n\n4\n1 4 6 3\n\nSample Output 1\n\n5\n\nThe maximum absolute difference of two elements is A_3-A_1=6-1=5.\n\nSample Input 2\n\n2\n1000000000 1\n\nSample Output 2\n\n999999999\n\nSample Input 3\n\n5\n1 1 1 1 1\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 323, "memory_kb": 25532}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s527431836", "group_id": "codeNet:p03308", "input_text": "\nobject Main extends App{\n val n = scala.io.StdIn.readInt()\n val a = scala.io.StdIn.readLine.split(\" \").map(_.toLong)\n\n println(a.max - a.min)\n}", "language": "Scala", "metadata": {"date": 1531001711, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03308.html", "problem_id": "p03308", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03308/input.txt", "sample_output_relpath": "derived/input_output/data/p03308/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03308/Scala/s527431836.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s527431836", "user_id": "u412116291"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "\nobject Main extends App{\n val n = scala.io.StdIn.readInt()\n val a = scala.io.StdIn.readLine.split(\" \").map(_.toLong)\n\n println(a.max - a.min)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given an integer sequence A of length N.\nFind the maximum absolute difference of two elements (with different indices) in A.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum absolute difference of two elements (with different indices) in A.\n\nSample Input 1\n\n4\n1 4 6 3\n\nSample Output 1\n\n5\n\nThe maximum absolute difference of two elements is A_3-A_1=6-1=5.\n\nSample Input 2\n\n2\n1000000000 1\n\nSample Output 2\n\n999999999\n\nSample Input 3\n\n5\n1 1 1 1 1\n\nSample Output 3\n\n0", "sample_input": "4\n1 4 6 3\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03308", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given an integer sequence A of length N.\nFind the maximum absolute difference of two elements (with different indices) in A.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum absolute difference of two elements (with different indices) in A.\n\nSample Input 1\n\n4\n1 4 6 3\n\nSample Output 1\n\n5\n\nThe maximum absolute difference of two elements is A_3-A_1=6-1=5.\n\nSample Input 2\n\n2\n1000000000 1\n\nSample Output 2\n\n999999999\n\nSample Input 3\n\n5\n1 1 1 1 1\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 329, "memory_kb": 27448}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s744569389", "group_id": "codeNet:p03309", "input_text": "import scala.io.{StdIn => in}\nimport scala.collection.{mutable => mu}\n\nobject Main extends App {\n val n = in.readInt\n val a = in.readLine.split(\" \").map(_.toInt)\n\n val map = mu.HashMap.empty[Int, Int]\n val maxCnt = (0 until n)./:(0) { (acc, i) =>\n val c = a(i) - (i+1)\n val v = map.getOrElse(c, 0) + 1\n map(c) = v\n if(acc < v) v else acc\n }\n\n val b = map.filter(_._2 == maxCnt).minBy(_._1.abs)._1.toLong\n\n val ans = a./:(0L, 1L){ case ((acc, idx), ai) =>\n (acc + (ai - (b + idx)).abs, idx + 1L)\n }._1\n\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1569110249, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s744569389.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s744569389", "user_id": "u217010036"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.io.{StdIn => in}\nimport scala.collection.{mutable => mu}\n\nobject Main extends App {\n val n = in.readInt\n val a = in.readLine.split(\" \").map(_.toInt)\n\n val map = mu.HashMap.empty[Int, Int]\n val maxCnt = (0 until n)./:(0) { (acc, i) =>\n val c = a(i) - (i+1)\n val v = map.getOrElse(c, 0) + 1\n map(c) = v\n if(acc < v) v else acc\n }\n\n val b = map.filter(_._2 == maxCnt).minBy(_._1.abs)._1.toLong\n\n val ans = a./:(0L, 1L){ case ((acc, idx), ai) =>\n (acc + (ai - (b + idx)).abs, idx + 1L)\n }._1\n\n println(ans)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1056, "memory_kb": 85980}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s273039352", "group_id": "codeNet:p03312", "input_text": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val N = in.next().toInt\n val A = new Array[Long](N+1)\n for(i <- 1 to N)\n A(i) = in.next().toLong\n\n\n //\n def check(mid: Int, base: Int): Long = {\n if(mid < base) {\n val l = imos(mid-1)\n val r = imos(base-1) - l\n (r-l).abs\n }\n else {\n val l = imos(mid) - imos(base-1)\n val r = imos(N) - imos(mid)\n (r-l).abs\n }\n }\n\n\n\n // 下に凸のグラフの最小値\n def ternarySearchInt(small: Int, big: Int, i: Int): Int = {\n if(big - small <= 2) {\n val mid = (big + small) / 2\n if(check(big, i) <= check(mid, i)) big\n else if(check(small, i) <= check(mid, i)) small\n else mid\n }\n else{\n val midl = (big + small) / 2\n val midr = midl + 1\n if (check(midl, i) >= check(midr, i))\n ternarySearchInt(midl, big, i)\n else\n ternarySearchInt(small, midr, i)\n }\n }\n\n\n val imos = new Array[Long](N+1)\n for(i <- 1 to N) {\n imos(i) = imos(i-1) + A(i)\n }\n\n var ans = Long.MaxValue\n for(i <- 3 to N-1) { // iが右ブロックの最初\n val l = ternarySearchInt(1, i-1, i)\n val r = ternarySearchInt(i, N, i)\n val P = imos(l-1)\n val Q = imos(i-1) - P\n val R = imos(r) - imos(i-1)\n val S = imos(N) - imos(r)\n val hoge = List(P,Q,R,S)\n\n ans = Math.min(ans, hoge.max - hoge.min)\n }\n\n println(ans)\n}\n\n\nclass InputReader(stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream))\n private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1530502956, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03312.html", "problem_id": "p03312", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03312/input.txt", "sample_output_relpath": "derived/input_output/data/p03312/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03312/Scala/s273039352.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s273039352", "user_id": "u098968285"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val N = in.next().toInt\n val A = new Array[Long](N+1)\n for(i <- 1 to N)\n A(i) = in.next().toLong\n\n\n //\n def check(mid: Int, base: Int): Long = {\n if(mid < base) {\n val l = imos(mid-1)\n val r = imos(base-1) - l\n (r-l).abs\n }\n else {\n val l = imos(mid) - imos(base-1)\n val r = imos(N) - imos(mid)\n (r-l).abs\n }\n }\n\n\n\n // 下に凸のグラフの最小値\n def ternarySearchInt(small: Int, big: Int, i: Int): Int = {\n if(big - small <= 2) {\n val mid = (big + small) / 2\n if(check(big, i) <= check(mid, i)) big\n else if(check(small, i) <= check(mid, i)) small\n else mid\n }\n else{\n val midl = (big + small) / 2\n val midr = midl + 1\n if (check(midl, i) >= check(midr, i))\n ternarySearchInt(midl, big, i)\n else\n ternarySearchInt(small, midr, i)\n }\n }\n\n\n val imos = new Array[Long](N+1)\n for(i <- 1 to N) {\n imos(i) = imos(i-1) + A(i)\n }\n\n var ans = Long.MaxValue\n for(i <- 3 to N-1) { // iが右ブロックの最初\n val l = ternarySearchInt(1, i-1, i)\n val r = ternarySearchInt(i, N, i)\n val P = imos(l-1)\n val Q = imos(i-1) - P\n val R = imos(r) - imos(i-1)\n val S = imos(N) - imos(r)\n val hoge = List(P,Q,R,S)\n\n ans = Math.min(ans, hoge.max - hoge.min)\n }\n\n println(ans)\n}\n\n\nclass InputReader(stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream))\n private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n\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": "p03312", "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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1890, "cpu_time_ms": 960, "memory_kb": 69148}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s535239583", "group_id": "codeNet:p03316", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n val n0 = StdIn.readLine\n val n = n0.toInt\n val digits = n0.split(\"\")\n var summed = 0\n digits.foreach(d => summed = summed + d.toInt)\n\n val r = if (n % summed == 0) {\n \"Yes\"\n } else {\n \"No\"\n }\n println(r)\n}", "language": "Scala", "metadata": {"date": 1529803692, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03316.html", "problem_id": "p03316", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03316/input.txt", "sample_output_relpath": "derived/input_output/data/p03316/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03316/Scala/s535239583.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s535239583", "user_id": "u917768600"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n val n0 = StdIn.readLine\n val n = n0.toInt\n val digits = n0.split(\"\")\n var summed = 0\n digits.foreach(d => summed = summed + d.toInt)\n\n val r = if (n % summed == 0) {\n \"Yes\"\n } else {\n \"No\"\n }\n println(r)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nLet S(n) denote the sum of the digits in the decimal notation of n.\nFor example, S(101) = 1 + 0 + 1 = 2.\n\nGiven an integer N, determine if S(N) divides N.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf S(N) divides N, print Yes; if it does not, print No.\n\nSample Input 1\n\n12\n\nSample Output 1\n\nYes\n\nIn this input, N=12.\nAs S(12) = 1 + 2 = 3, S(N) divides N.\n\nSample Input 2\n\n101\n\nSample Output 2\n\nNo\n\nAs S(101) = 1 + 0 + 1 = 2, S(N) does not divide N.\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\nYes", "sample_input": "12\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03316", "source_text": "Score : 200 points\n\nProblem Statement\n\nLet S(n) denote the sum of the digits in the decimal notation of n.\nFor example, S(101) = 1 + 0 + 1 = 2.\n\nGiven an integer N, determine if S(N) divides N.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf S(N) divides N, print Yes; if it does not, print No.\n\nSample Input 1\n\n12\n\nSample Output 1\n\nYes\n\nIn this input, N=12.\nAs S(12) = 1 + 2 = 3, S(N) divides N.\n\nSample Input 2\n\n101\n\nSample Output 2\n\nNo\n\nAs S(101) = 1 + 0 + 1 = 2, S(N) does not divide N.\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 270, "cpu_time_ms": 326, "memory_kb": 27340}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s381665796", "group_id": "codeNet:p03317", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n solve\n }\n\n def getDivCount(x: Int, divisor: Int): Int = {\n // ここの数え方を考える\n var tmp = x\n var count = 0\n while (tmp > 0) {\n count += 1\n tmp = tmp - divisor\n }\n count\n }\n\n def solve(): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n, k = sc.nextInt\n val a = new Array[Int](n)\n for (i <- 0 until n) {\n a(i) = sc.nextInt\n }\n\n val minIndex = a.indexOf(1)\n println(getDivCount(minIndex, k-1) + getDivCount(n - minIndex - 1, k-1))\n }\n}\n", "language": "Scala", "metadata": {"date": 1579650461, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s381665796.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s381665796", "user_id": "u433254839"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n solve\n }\n\n def getDivCount(x: Int, divisor: Int): Int = {\n // ここの数え方を考える\n var tmp = x\n var count = 0\n while (tmp > 0) {\n count += 1\n tmp = tmp - divisor\n }\n count\n }\n\n def solve(): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n, k = sc.nextInt\n val a = new Array[Int](n)\n for (i <- 0 until n) {\n a(i) = sc.nextInt\n }\n\n val minIndex = a.indexOf(1)\n println(getDivCount(minIndex, k-1) + getDivCount(n - minIndex - 1, k-1))\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 690, "memory_kb": 52364}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s217362618", "group_id": "codeNet:p03318", "input_text": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = println(solve(new Scanner(System.in)))\n\n def solve(in: String): String = solve(new Scanner(in))\n\n def snukeD(N: Long): Long = {\n var n = N\n var m = 0L\n while (n > 0) {\n m += (n % 10)\n n /= 10\n }\n m\n }\n\n def f(N: Long): Long = {\n var n = N\n var sd = snukeD(N)\n var min = (n, n.toDouble / sd.toDouble)\n var delta = 1\n for (i <- 1 until N.toString.length) {\n while ((n + 1) % (delta * 10) != 0) {\n n += delta\n sd += 1\n val m = (n, n.toDouble / sd.toDouble)\n if (m._2 < min._2) {\n min = m\n }\n // println(\"next=\" + n + \", min=\" + min)\n }\n delta *= 10\n }\n // println(r)\n min._1\n }\n\n def solve(sc: Scanner): String = {\n val K = sc.nextLong\n\n var n = 1L\n while (n < K) {\n println(n)\n n = f(n + 1)\n }\n \"\"\n }\n}\n", "language": "Scala", "metadata": {"date": 1529890844, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s217362618.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s217362618", "user_id": "u297767059"}, "prompt_components": {"gold_output": "1\n2\n3\n4\n5\n6\n7\n8\n9\n19\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = println(solve(new Scanner(System.in)))\n\n def solve(in: String): String = solve(new Scanner(in))\n\n def snukeD(N: Long): Long = {\n var n = N\n var m = 0L\n while (n > 0) {\n m += (n % 10)\n n /= 10\n }\n m\n }\n\n def f(N: Long): Long = {\n var n = N\n var sd = snukeD(N)\n var min = (n, n.toDouble / sd.toDouble)\n var delta = 1\n for (i <- 1 until N.toString.length) {\n while ((n + 1) % (delta * 10) != 0) {\n n += delta\n sd += 1\n val m = (n, n.toDouble / sd.toDouble)\n if (m._2 < min._2) {\n min = m\n }\n // println(\"next=\" + n + \", min=\" + min)\n }\n delta *= 10\n }\n // println(r)\n min._1\n }\n\n def solve(sc: Scanner): String = {\n val K = sc.nextLong\n\n var n = 1L\n while (n < K) {\n println(n)\n n = f(n + 1)\n }\n \"\"\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 938, "cpu_time_ms": 341, "memory_kb": 25256}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s450644353", "group_id": "codeNet:p03320", "input_text": "object Main extends App {\n def sunuke(i:Long) = {\n var temp = i\n var sunuke = 0L\n while (temp>0){\n sunuke = sunuke + (temp%10)\n temp = temp/10\n }\n sunuke\n }\n def judge(n:Long) = {\n val sunukeN = sunuke(n)\n val diff = 9-n%10\n if (n*(sunukeN+diff)<=(n+diff)*sunukeN){\n true\n } else {\n false\n }\n }\n val sc = new java.util.Scanner(System.in)\n val k = sc.nextLong()\n var counter = 0\n var current = 1\n while (counter < k){\n if (judge(current)){\n println(current)\n counter = counter + 1\n }\n current = current + 1\n }\n}", "language": "Scala", "metadata": {"date": 1529803512, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03320.html", "problem_id": "p03320", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03320/input.txt", "sample_output_relpath": "derived/input_output/data/p03320/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03320/Scala/s450644353.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s450644353", "user_id": "u387147818"}, "prompt_components": {"gold_output": "1\n2\n3\n4\n5\n6\n7\n8\n9\n19\n", "input_to_evaluate": "object Main extends App {\n def sunuke(i:Long) = {\n var temp = i\n var sunuke = 0L\n while (temp>0){\n sunuke = sunuke + (temp%10)\n temp = temp/10\n }\n sunuke\n }\n def judge(n:Long) = {\n val sunukeN = sunuke(n)\n val diff = 9-n%10\n if (n*(sunukeN+diff)<=(n+diff)*sunukeN){\n true\n } else {\n false\n }\n }\n val sc = new java.util.Scanner(System.in)\n val k = sc.nextLong()\n var counter = 0\n var current = 1\n while (counter < k){\n if (judge(current)){\n println(current)\n counter = counter + 1\n }\n current = current + 1\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": "p03320", "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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 377, "memory_kb": 25804}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s970067929", "group_id": "codeNet:p03323", "input_text": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\nimport java.lang\n\nimport scala.annotation.tailrec\nimport scala.collection.mutable.ArrayBuffer\nimport scala.reflect.ClassTag\n\nobject Main {\n def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {\n converter(in.readLine)\n }\n\n def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {\n get[String].split(\"\\\\s+\").map[T](converter)\n }\n\n implicit val idConverter: String => String = s => s\n implicit val intConverter: String => Int = s => Integer.parseInt(s)\n implicit val longConverter: String => Long = s => lang.Long.parseLong(s)\n\n def get[T1, T2](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2\n ): (T1, T2) = {\n getArray[String] match {\n case Array(v1, v2) => (converter1(v1), converter2(v2))\n }\n }\n\n def get[T1, T2, T3](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3\n ): (T1, T2, T3) = {\n getArray[String] match {\n case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))\n }\n }\n\n def get[T1, T2, T3, T4](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3,\n converter4: String => T4\n ): (T1, T2, T3, T4) = {\n getArray[String] match {\n case Array(v1, v2, v3, v4) => (converter1(v1), converter2(v2), converter3(v3), converter4(v4))\n }\n }\n\n implicit class TimesInt(val n: Int) {\n def times(f: Int => Unit): Unit = {\n for (i <- 0 until n) {\n f(i)\n }\n }\n }\n\n def primes(n: Long): ArrayBuffer[Long] = {\n val buf = ArrayBuffer.empty[Long]\n val s = Math.sqrt(n).toInt\n\n var v = n\n for (i <- 2 to s) {\n if (v == 1 || v == 0) {\n return buf\n } else {\n while (v % i == 0) {\n buf.append(i)\n v /= i\n }\n }\n }\n if (v > s) {\n buf.append(v)\n }\n buf\n }\n\n def divisors(n: Int): ArrayBuffer[Int] = {\n val buf = ArrayBuffer.empty[Int]\n val s = Math.sqrt(n).toInt\n\n for (i <- 1 to s) {\n if (n % i == 0) {\n buf.append(i)\n if (i != n / i) {\n buf.append(n / i)\n }\n }\n }\n buf\n }\n\n @tailrec\n def gcd(a: Long, b: Long): Long = {\n val reminder = a % b\n if (reminder == 0) {\n b\n } else {\n gcd(b, reminder)\n }\n }\n\n @tailrec\n def gcd(a: Int, b: Int): Int = {\n val reminder = a % b\n if (reminder == 0) {\n b\n } else {\n gcd(b, reminder)\n }\n }\n\n def lcm(a: Long, b: Long): Long = {\n a / gcd(a, b) * b\n }\n\n def toBitArray(n: Int, width: Int): Array[Boolean] = {\n val buf = ArrayBuffer.fill(width)(false)\n\n @tailrec\n def inner(n: Int, i: Int): Array[Boolean] = {\n buf(i) = (n & 1) == 0\n if (i == 0) {\n buf.toArray\n } else {\n inner(n / 2, i - 1)\n }\n }\n\n inner(n, width - 1)\n }\n\n def modpow(n: Long, p: Long, m: Long): Long = {\n @tailrec\n def inner(n: Long, p: Long, acc: Long): Long = {\n if (p == 0) {\n acc\n } else if ((p & 1) == 0) {\n inner(n * n % m, p >> 1, acc)\n } else {\n inner(n * n % m, p >> 1, acc * n % m)\n }\n }\n\n inner(n % m, p, 1)\n }\n\n def main(args: Array[String]): Unit = {\n implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n val (a, b) = get[Int, Int]\n\n out.println(\n if (a >= 9 || b >= 9) {\n \":(\"\n } else {\n \"Yay!\"\n }\n )\n\n out.flush()\n }\n}", "language": "Scala", "metadata": {"date": 1594434760, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s970067929.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s970067929", "user_id": "u178269371"}, "prompt_components": {"gold_output": "Yay!\n", "input_to_evaluate": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\nimport java.lang\n\nimport scala.annotation.tailrec\nimport scala.collection.mutable.ArrayBuffer\nimport scala.reflect.ClassTag\n\nobject Main {\n def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {\n converter(in.readLine)\n }\n\n def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {\n get[String].split(\"\\\\s+\").map[T](converter)\n }\n\n implicit val idConverter: String => String = s => s\n implicit val intConverter: String => Int = s => Integer.parseInt(s)\n implicit val longConverter: String => Long = s => lang.Long.parseLong(s)\n\n def get[T1, T2](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2\n ): (T1, T2) = {\n getArray[String] match {\n case Array(v1, v2) => (converter1(v1), converter2(v2))\n }\n }\n\n def get[T1, T2, T3](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3\n ): (T1, T2, T3) = {\n getArray[String] match {\n case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))\n }\n }\n\n def get[T1, T2, T3, T4](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3,\n converter4: String => T4\n ): (T1, T2, T3, T4) = {\n getArray[String] match {\n case Array(v1, v2, v3, v4) => (converter1(v1), converter2(v2), converter3(v3), converter4(v4))\n }\n }\n\n implicit class TimesInt(val n: Int) {\n def times(f: Int => Unit): Unit = {\n for (i <- 0 until n) {\n f(i)\n }\n }\n }\n\n def primes(n: Long): ArrayBuffer[Long] = {\n val buf = ArrayBuffer.empty[Long]\n val s = Math.sqrt(n).toInt\n\n var v = n\n for (i <- 2 to s) {\n if (v == 1 || v == 0) {\n return buf\n } else {\n while (v % i == 0) {\n buf.append(i)\n v /= i\n }\n }\n }\n if (v > s) {\n buf.append(v)\n }\n buf\n }\n\n def divisors(n: Int): ArrayBuffer[Int] = {\n val buf = ArrayBuffer.empty[Int]\n val s = Math.sqrt(n).toInt\n\n for (i <- 1 to s) {\n if (n % i == 0) {\n buf.append(i)\n if (i != n / i) {\n buf.append(n / i)\n }\n }\n }\n buf\n }\n\n @tailrec\n def gcd(a: Long, b: Long): Long = {\n val reminder = a % b\n if (reminder == 0) {\n b\n } else {\n gcd(b, reminder)\n }\n }\n\n @tailrec\n def gcd(a: Int, b: Int): Int = {\n val reminder = a % b\n if (reminder == 0) {\n b\n } else {\n gcd(b, reminder)\n }\n }\n\n def lcm(a: Long, b: Long): Long = {\n a / gcd(a, b) * b\n }\n\n def toBitArray(n: Int, width: Int): Array[Boolean] = {\n val buf = ArrayBuffer.fill(width)(false)\n\n @tailrec\n def inner(n: Int, i: Int): Array[Boolean] = {\n buf(i) = (n & 1) == 0\n if (i == 0) {\n buf.toArray\n } else {\n inner(n / 2, i - 1)\n }\n }\n\n inner(n, width - 1)\n }\n\n def modpow(n: Long, p: Long, m: Long): Long = {\n @tailrec\n def inner(n: Long, p: Long, acc: Long): Long = {\n if (p == 0) {\n acc\n } else if ((p & 1) == 0) {\n inner(n * n % m, p >> 1, acc)\n } else {\n inner(n * n % m, p >> 1, acc * n % m)\n }\n }\n\n inner(n % m, p, 1)\n }\n\n def main(args: Array[String]): Unit = {\n implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n val (a, b) = get[Int, Int]\n\n out.println(\n if (a >= 9 || b >= 9) {\n \":(\"\n } else {\n \"Yay!\"\n }\n )\n\n out.flush()\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4001, "cpu_time_ms": 485, "memory_kb": 57048}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s446550930", "group_id": "codeNet:p03323", "input_text": "object Main extends App {\n\n import scala.math._\n\n val In = io.StdIn.readLine().split(\" \")\n val a = In(0).toInt\n val b = In(1).toInt\n\n if ( abs(a-b)*2 <= List(a,b).min *2 ) {\n println(\"Yay!\")\n } else {\n println(\":(\")\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1531725542, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s446550930.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s446550930", "user_id": "u873394503"}, "prompt_components": {"gold_output": "Yay!\n", "input_to_evaluate": "object Main extends App {\n\n import scala.math._\n\n val In = io.StdIn.readLine().split(\" \")\n val a = In(0).toInt\n val b = In(1).toInt\n\n if ( abs(a-b)*2 <= List(a,b).min *2 ) {\n println(\"Yay!\")\n } else {\n println(\":(\")\n }\n\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 326, "memory_kb": 25412}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s055389839", "group_id": "codeNet:p03323", "input_text": "import java.io.{InputStream, OutputStream, PrintStream}\nimport java.util.Scanner\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n val solver = new Solver(System.in, System.out)\n solver.solve()\n }\n\n class Solver(in: InputStream, out: OutputStream) {\n lazy val scanner = new Scanner(in)\n lazy val output = new PrintStream(out)\n\n def solve(): Unit = {\n val Array(a, b) = scanner.nextLine().split(\" \").map(_.toInt)\n\n val result =\n if (a <= 8 && b <= 8) \"Yay!\"\n else \":(\"\n\n output.println(result)\n }\n\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1529197723, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s055389839.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s055389839", "user_id": "u299987045"}, "prompt_components": {"gold_output": "Yay!\n", "input_to_evaluate": "import java.io.{InputStream, OutputStream, PrintStream}\nimport java.util.Scanner\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n val solver = new Solver(System.in, System.out)\n solver.solve()\n }\n\n class Solver(in: InputStream, out: OutputStream) {\n lazy val scanner = new Scanner(in)\n lazy val output = new PrintStream(out)\n\n def solve(): Unit = {\n val Array(a, b) = scanner.nextLine().split(\" \").map(_.toInt)\n\n val result =\n if (a <= 8 && b <= 8) \"Yay!\"\n else \":(\"\n\n output.println(result)\n }\n\n }\n\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 511, "memory_kb": 25808}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s221539437", "group_id": "codeNet:p03326", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n solve\n }\n\n def solve(): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n, m = sc.nextInt\n val x = new Array[Long](n)\n val y = new Array[Long](n)\n val z = new Array[Long](n)\n for (i <- 0 until n) {\n x(i) = sc.nextLong\n y(i) = sc.nextLong\n z(i) = sc.nextLong\n }\n\n var ans = 0L\n val sign = Array[Int](-1, 1)\n for (xs <- sign; ys <- sign; zs <- sign) {\n val sums = (0 until n).map(\n i =>\n xs * x(i) + ys * y(i) + zs * z(i)\n )\n\n val mx = sums.sorted.reverse.slice(0, m).sum\n\n ans = math.max(ans, mx)\n }\n\n println(ans)\n }\n}\n", "language": "Scala", "metadata": {"date": 1579580189, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s221539437.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s221539437", "user_id": "u433254839"}, "prompt_components": {"gold_output": "56\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n solve\n }\n\n def solve(): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n, m = sc.nextInt\n val x = new Array[Long](n)\n val y = new Array[Long](n)\n val z = new Array[Long](n)\n for (i <- 0 until n) {\n x(i) = sc.nextLong\n y(i) = sc.nextLong\n z(i) = sc.nextLong\n }\n\n var ans = 0L\n val sign = Array[Int](-1, 1)\n for (xs <- sign; ys <- sign; zs <- sign) {\n val sums = (0 until n).map(\n i =>\n xs * x(i) + ys * y(i) + zs * z(i)\n )\n\n val mx = sums.sorted.reverse.slice(0, m).sum\n\n ans = math.max(ans, mx)\n }\n\n println(ans)\n }\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 565, "memory_kb": 32868}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s085438338", "group_id": "codeNet:p03326", "input_text": "import scala.math.abs\n\nobject Main {\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val n, m = sc.nextInt\n val xyzs = List.fill(n, 3)(sc.nextLong)\n\n println(\n Stream.range(0, n)\n .toSet\n .subsets\n .filter(_.size == m)\n .map(_.foldLeft(List[Long](0, 0, 0))((stu: List[Long], i: Int) => {\n val List(x, y, z) = xyzs(i)\n val List(s, t, u) = stu\n List(x + s, y + t, z + u)\n }).map(abs).sum)\n .max\n )\n }\n}\n", "language": "Scala", "metadata": {"date": 1529201938, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s085438338.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s085438338", "user_id": "u710809824"}, "prompt_components": {"gold_output": "56\n", "input_to_evaluate": "import scala.math.abs\n\nobject Main {\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val n, m = sc.nextInt\n val xyzs = List.fill(n, 3)(sc.nextLong)\n\n println(\n Stream.range(0, n)\n .toSet\n .subsets\n .filter(_.size == m)\n .map(_.foldLeft(List[Long](0, 0, 0))((stu: List[Long], i: Int) => {\n val List(x, y, z) = xyzs(i)\n val List(s, t, u) = stu\n List(x + s, y + t, z + u)\n }).map(abs).sum)\n .max\n )\n }\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 504, "cpu_time_ms": 2111, "memory_kb": 118740}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s065759251", "group_id": "codeNet:p03327", "input_text": "object Main extends App {\nval n = scala.io.StdIn.readInt()\n\nif (n>999) println(\"ABD\") else println(\"ABC\")\n}", "language": "Scala", "metadata": {"date": 1559794497, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s065759251.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s065759251", "user_id": "u238510421"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "object Main extends App {\nval n = scala.io.StdIn.readInt()\n\nif (n>999) println(\"ABD\") else println(\"ABC\")\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 327, "memory_kb": 25664}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s369681710", "group_id": "codeNet:p03328", "input_text": "import java.io.{BufferedReader, InputStream, InputStreamReader}\nimport java.util.StringTokenizer\n\nimport scala.collection.mutable\nimport scala.util.Sorting\nimport math.{abs, max, min}\n\nobject Main {\n val MOD = 1000000007\n def solve(): Unit = {\n val sc = new InputReader(System.in)\n val a = sc.nextInt()\n val b = sc.nextInt()\n val d = b - a\n val c = d * (d + 1) / 2\n val ans = c - b\n println(ans)\n }\n\n\n def main(args: Array[String]): Unit = {\n solve()\n }\n\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = null\n\n def next: String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next.toInt\n def nextLong(): Long = next.toLong\n def nextChar(): Char = next.charAt(0)\n }\n}\n", "language": "Scala", "metadata": {"date": 1528679124, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03328.html", "problem_id": "p03328", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03328/input.txt", "sample_output_relpath": "derived/input_output/data/p03328/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03328/Scala/s369681710.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s369681710", "user_id": "u460609472"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.{BufferedReader, InputStream, InputStreamReader}\nimport java.util.StringTokenizer\n\nimport scala.collection.mutable\nimport scala.util.Sorting\nimport math.{abs, max, min}\n\nobject Main {\n val MOD = 1000000007\n def solve(): Unit = {\n val sc = new InputReader(System.in)\n val a = sc.nextInt()\n val b = sc.nextInt()\n val d = b - a\n val c = d * (d + 1) / 2\n val ans = c - b\n println(ans)\n }\n\n\n def main(args: Array[String]): Unit = {\n solve()\n }\n\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = null\n\n def next: String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next.toInt\n def nextLong(): Long = next.toLong\n def nextChar(): Char = next.charAt(0)\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIn some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter.\n\nIt had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower.\n\nAssuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover.\n\nAssume also that the depth of the snow cover is always at least 1 meter.\n\nConstraints\n\n1 \\leq a < b < 499500(=1+2+3+...+999)\n\nAll values in input are integers.\n\nThere is no input that contradicts the assumption.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the depth of the snow cover is x meters, print x as an integer.\n\nSample Input 1\n\n8 13\n\nSample Output 1\n\n2\n\nThe heights of the two towers are 10 meters and 15 meters, respectively.\nThus, we can see that the depth of the snow cover is 2 meters.\n\nSample Input 2\n\n54 65\n\nSample Output 2\n\n1", "sample_input": "8 13\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03328", "source_text": "Score : 200 points\n\nProblem Statement\n\nIn some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter.\n\nIt had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower.\n\nAssuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover.\n\nAssume also that the depth of the snow cover is always at least 1 meter.\n\nConstraints\n\n1 \\leq a < b < 499500(=1+2+3+...+999)\n\nAll values in input are integers.\n\nThere is no input that contradicts the assumption.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the depth of the snow cover is x meters, print x as an integer.\n\nSample Input 1\n\n8 13\n\nSample Output 1\n\n2\n\nThe heights of the two towers are 10 meters and 15 meters, respectively.\nThus, we can see that the depth of the snow cover is 2 meters.\n\nSample Input 2\n\n54 65\n\nSample Output 2\n\n1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 349, "memory_kb": 25408}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s712548547", "group_id": "codeNet:p03331", "input_text": "import scala.io.StdIn\nobject Main extends App {\n val N = StdIn.readLine().toInt\n val list = for {\n a <- 1 to N - 1\n b = N - a\n } yield a.toString.toList.map(_.asDigit).sum + b.toString.toList.map(_.asDigit).sum\n println(list.min)\n}\n", "language": "Scala", "metadata": {"date": 1566648381, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03331.html", "problem_id": "p03331", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03331/input.txt", "sample_output_relpath": "derived/input_output/data/p03331/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03331/Scala/s712548547.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s712548547", "user_id": "u407005073"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import scala.io.StdIn\nobject Main extends App {\n val N = StdIn.readLine().toInt\n val list = for {\n a <- 1 to N - 1\n b = N - a\n } yield a.toString.toList.map(_.asDigit).sum + b.toString.toList.map(_.asDigit).sum\n println(list.min)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has two positive integers A and B.\n\nIt is known that A plus B equals N.\nFind the minimum possible value of \"the sum of the digits of A\" plus \"the sum of the digits of B\" (in base 10).\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum possible value of \"the sum of the digits of A\" plus \"the sum of the digits of B\".\n\nSample Input 1\n\n15\n\nSample Output 1\n\n6\n\nWhen A=2 and B=13, the sums of their digits are 2 and 4, which minimizes the value in question.\n\nSample Input 2\n\n100000\n\nSample Output 2\n\n10", "sample_input": "15\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03331", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has two positive integers A and B.\n\nIt is known that A plus B equals N.\nFind the minimum possible value of \"the sum of the digits of A\" plus \"the sum of the digits of B\" (in base 10).\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum possible value of \"the sum of the digits of A\" plus \"the sum of the digits of B\".\n\nSample Input 1\n\n15\n\nSample Output 1\n\n6\n\nWhen A=2 and B=13, the sums of their digits are 2 and 4, which minimizes the value in question.\n\nSample Input 2\n\n100000\n\nSample Output 2\n\n10", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 242, "cpu_time_ms": 758, "memory_kb": 64020}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s173378649", "group_id": "codeNet:p03337", "input_text": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = println(solve(new Scanner(System.in)))\n\n def solve(in: String): String = solve(new Scanner(in))\n\n def solve(sc: Scanner): String = {\n val A = sc.nextInt\n val B = sc.nextInt\n\n Array(A + B, A - B, A * B).max.toString\n }\n}\n", "language": "Scala", "metadata": {"date": 1527382992, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03337.html", "problem_id": "p03337", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03337/input.txt", "sample_output_relpath": "derived/input_output/data/p03337/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03337/Scala/s173378649.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s173378649", "user_id": "u297767059"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = println(solve(new Scanner(System.in)))\n\n def solve(in: String): String = solve(new Scanner(in))\n\n def solve(sc: Scanner): String = {\n val A = sc.nextInt\n val B = sc.nextInt\n\n Array(A + B, A - B, A * B).max.toString\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given two integers A and B.\nFind the largest value among A+B, A-B and A \\times B.\n\nConstraints\n\n-1000 \\leq A,B \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the largest value among A+B, A-B and A \\times B.\n\nSample Input 1\n\n3 1\n\nSample Output 1\n\n4\n\n3+1=4, 3-1=2 and 3 \\times 1=3. The largest among them is 4.\n\nSample Input 2\n\n4 -2\n\nSample Output 2\n\n6\n\nThe largest is 4 - (-2) = 6.\n\nSample Input 3\n\n0 0\n\nSample Output 3\n\n0", "sample_input": "3 1\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03337", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given two integers A and B.\nFind the largest value among A+B, A-B and A \\times B.\n\nConstraints\n\n-1000 \\leq A,B \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the largest value among A+B, A-B and A \\times B.\n\nSample Input 1\n\n3 1\n\nSample Output 1\n\n4\n\n3+1=4, 3-1=2 and 3 \\times 1=3. The largest among them is 4.\n\nSample Input 2\n\n4 -2\n\nSample Output 2\n\n6\n\nThe largest is 4 - (-2) = 6.\n\nSample Input 3\n\n0 0\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 358, "memory_kb": 27324}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s358621353", "group_id": "codeNet:p03339", "input_text": "object Main extends App {\n\tval input = io.Source.stdin.getLines.toIndexedSeq.tail.head\n\tval wi = input.zipWithIndex.filter(_._1 == 'W')\n\n\tval bits = new java.util.BitSet()\n\twi.foreach(e => bits.set(e._2, true))\n\n\tval ret = (0 until input.length).foldLeft(Int.MaxValue) { (min, i) =>\n\t\tval l = bits.get(0, i).cardinality\n\t\tval r = input.length - i - bits.get(i, Int.MaxValue).cardinality\n\t\tMath.min(min, l + r)\n\t}\n\tprintln(ret)\n}\n", "language": "Scala", "metadata": {"date": 1541544629, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s358621353.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s358621353", "user_id": "u699236457"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main extends App {\n\tval input = io.Source.stdin.getLines.toIndexedSeq.tail.head\n\tval wi = input.zipWithIndex.filter(_._1 == 'W')\n\n\tval bits = new java.util.BitSet()\n\twi.foreach(e => bits.set(e._2, true))\n\n\tval ret = (0 until input.length).foldLeft(Int.MaxValue) { (min, i) =>\n\t\tval l = bits.get(0, i).cardinality\n\t\tval r = input.length - i - bits.get(i, Int.MaxValue).cardinality\n\t\tMath.min(min, l + r)\n\t}\n\tprintln(ret)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2112, "memory_kb": 142312}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s655554195", "group_id": "codeNet:p03339", "input_text": "object Main {\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val areE = sc.next.map(_ == 'E')\n\n println {\n (0 until n).map(leader =>\n (0 until leader).count(! areE(_)) +\n ((leader + 1) until n).count(areE)\n ).min\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1528008028, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s655554195.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s655554195", "user_id": "u710809824"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main {\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val areE = sc.next.map(_ == 'E')\n\n println {\n (0 until n).map(leader =>\n (0 until leader).count(! areE(_)) +\n ((leader + 1) until n).count(areE)\n ).min\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": "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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 315, "cpu_time_ms": 2111, "memory_kb": 117996}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s856665355", "group_id": "codeNet:p03345", "input_text": "object Main extends App {\n val Array(a,b,c,k) = io.StdIn.readLine.split(\" \").map(_.toLong)\n \n if (a == b && b == c) println(0)\n else {\n def rec(count: Long, x: Long, y: Long, z: Long): (Long, Long, Long) = {\n if (k == count) (x,y,z)\n else rec(count+1, y+z, x+z, x+y)\n }\n \n val abc = rec(0, a,b,c) // (high-hashi, mid-hashi, low-hashi\n val result = abc._1 - abc._2\n \n if (math.pow(10, 18) < result.abs) println(\"Unfair\")\n else println(result)\n }\n}", "language": "Scala", "metadata": {"date": 1592342950, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03345.html", "problem_id": "p03345", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03345/input.txt", "sample_output_relpath": "derived/input_output/data/p03345/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03345/Scala/s856665355.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s856665355", "user_id": "u104354966"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main extends App {\n val Array(a,b,c,k) = io.StdIn.readLine.split(\" \").map(_.toLong)\n \n if (a == b && b == c) println(0)\n else {\n def rec(count: Long, x: Long, y: Long, z: Long): (Long, Long, Long) = {\n if (k == count) (x,y,z)\n else rec(count+1, y+z, x+z, x+y)\n }\n \n val abc = rec(0, a,b,c) // (high-hashi, mid-hashi, low-hashi\n val result = abc._1 - abc._2\n \n if (math.pow(10, 18) < result.abs) println(\"Unfair\")\n else println(result)\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively.\nAfter repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get:\n\nEach of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result.\n\nHowever, if the absolute value of the answer exceeds 10^{18}, print Unfair instead.\n\nConstraints\n\n1 \\leq A,B,C \\leq 10^9\n\n0 \\leq K \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the integer Takahashi will get minus the integer Nakahashi will get, after repeating the following operation K times.\nIf the absolute value of the answer exceeds 10^{18}, print Unfair instead.\n\nSample Input 1\n\n1 2 3 1\n\nSample Output 1\n\n1\n\nAfter one operation, Takahashi, Nakahashi and Hikuhashi have 5, 4 and 3, respectively. We should print 5-4=1.\n\nSample Input 2\n\n2 3 2 0\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n1000000000 1000000000 1000000000 1000000000000000000\n\nSample Output 3\n\n0", "sample_input": "1 2 3 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03345", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively.\nAfter repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get:\n\nEach of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result.\n\nHowever, if the absolute value of the answer exceeds 10^{18}, print Unfair instead.\n\nConstraints\n\n1 \\leq A,B,C \\leq 10^9\n\n0 \\leq K \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the integer Takahashi will get minus the integer Nakahashi will get, after repeating the following operation K times.\nIf the absolute value of the answer exceeds 10^{18}, print Unfair instead.\n\nSample Input 1\n\n1 2 3 1\n\nSample Output 1\n\n1\n\nAfter one operation, Takahashi, Nakahashi and Hikuhashi have 5, 4 and 3, respectively. We should print 5-4=1.\n\nSample Input 2\n\n2 3 2 0\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n1000000000 1000000000 1000000000 1000000000000000000\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 27212}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s684206343", "group_id": "codeNet:p03351", "input_text": "object Main extends App {\n val Array(a,b,c,d) = scala.io.StdIn.readLine().split(\"\\\\s\").map(_.toInt)\n\n if ((a-c).abs <= d || ((a-b).abs <= d && (b-c).abs<=d)) println(\"Yes\") else println(\"No\")\n}", "language": "Scala", "metadata": {"date": 1559880916, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03351.html", "problem_id": "p03351", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03351/input.txt", "sample_output_relpath": "derived/input_output/data/p03351/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03351/Scala/s684206343.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s684206343", "user_id": "u238510421"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n val Array(a,b,c,d) = scala.io.StdIn.readLine().split(\"\\\\s\").map(_.toInt)\n\n if ((a-c).abs <= d || ((a-b).abs <= d && (b-c).abs<=d)) println(\"Yes\") else println(\"No\")\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThree people, A, B and C, are trying to communicate using transceivers.\nThey are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively.\nTwo people can directly communicate when the distance between them is at most d meters.\nDetermine if A and C can communicate, either directly or indirectly.\nHere, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.\n\nConstraints\n\n1 ≤ a,b,c ≤ 100\n\n1 ≤ d ≤ 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c d\n\nOutput\n\nIf A and C can communicate, print Yes; if they cannot, print No.\n\nSample Input 1\n\n4 7 9 3\n\nSample Output 1\n\nYes\n\nA and B can directly communicate, and also B and C can directly communicate, so we should print Yes.\n\nSample Input 2\n\n100 10 1 2\n\nSample Output 2\n\nNo\n\nThey cannot communicate in this case.\n\nSample Input 3\n\n10 10 10 1\n\nSample Output 3\n\nYes\n\nThere can be multiple people at the same position.\n\nSample Input 4\n\n1 100 2 10\n\nSample Output 4\n\nYes", "sample_input": "4 7 9 3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03351", "source_text": "Score : 100 points\n\nProblem Statement\n\nThree people, A, B and C, are trying to communicate using transceivers.\nThey are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively.\nTwo people can directly communicate when the distance between them is at most d meters.\nDetermine if A and C can communicate, either directly or indirectly.\nHere, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.\n\nConstraints\n\n1 ≤ a,b,c ≤ 100\n\n1 ≤ d ≤ 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c d\n\nOutput\n\nIf A and C can communicate, print Yes; if they cannot, print No.\n\nSample Input 1\n\n4 7 9 3\n\nSample Output 1\n\nYes\n\nA and B can directly communicate, and also B and C can directly communicate, so we should print Yes.\n\nSample Input 2\n\n100 10 1 2\n\nSample Output 2\n\nNo\n\nThey cannot communicate in this case.\n\nSample Input 3\n\n10 10 10 1\n\nSample Output 3\n\nYes\n\nThere can be multiple people at the same position.\n\nSample Input 4\n\n1 100 2 10\n\nSample Output 4\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 323, "memory_kb": 25520}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s145060457", "group_id": "codeNet:p03351", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n\n val s = StdIn.readLine()\n val K = StdIn.readLine().toInt\n val r = {\n for (i <- 0 until s.size;\n j <- 1 to s.size - i; if j <= K)\n yield s.substring(i, i + j)\n }.distinct.sorted.apply(K - 1)\n\n println(r)\n}\n", "language": "Scala", "metadata": {"date": 1530790927, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03351.html", "problem_id": "p03351", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03351/input.txt", "sample_output_relpath": "derived/input_output/data/p03351/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03351/Scala/s145060457.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s145060457", "user_id": "u895032849"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n\n val s = StdIn.readLine()\n val K = StdIn.readLine().toInt\n val r = {\n for (i <- 0 until s.size;\n j <- 1 to s.size - i; if j <= K)\n yield s.substring(i, i + j)\n }.distinct.sorted.apply(K - 1)\n\n println(r)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThree people, A, B and C, are trying to communicate using transceivers.\nThey are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively.\nTwo people can directly communicate when the distance between them is at most d meters.\nDetermine if A and C can communicate, either directly or indirectly.\nHere, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.\n\nConstraints\n\n1 ≤ a,b,c ≤ 100\n\n1 ≤ d ≤ 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c d\n\nOutput\n\nIf A and C can communicate, print Yes; if they cannot, print No.\n\nSample Input 1\n\n4 7 9 3\n\nSample Output 1\n\nYes\n\nA and B can directly communicate, and also B and C can directly communicate, so we should print Yes.\n\nSample Input 2\n\n100 10 1 2\n\nSample Output 2\n\nNo\n\nThey cannot communicate in this case.\n\nSample Input 3\n\n10 10 10 1\n\nSample Output 3\n\nYes\n\nThere can be multiple people at the same position.\n\nSample Input 4\n\n1 100 2 10\n\nSample Output 4\n\nYes", "sample_input": "4 7 9 3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03351", "source_text": "Score : 100 points\n\nProblem Statement\n\nThree people, A, B and C, are trying to communicate using transceivers.\nThey are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively.\nTwo people can directly communicate when the distance between them is at most d meters.\nDetermine if A and C can communicate, either directly or indirectly.\nHere, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.\n\nConstraints\n\n1 ≤ a,b,c ≤ 100\n\n1 ≤ d ≤ 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c d\n\nOutput\n\nIf A and C can communicate, print Yes; if they cannot, print No.\n\nSample Input 1\n\n4 7 9 3\n\nSample Output 1\n\nYes\n\nA and B can directly communicate, and also B and C can directly communicate, so we should print Yes.\n\nSample Input 2\n\n100 10 1 2\n\nSample Output 2\n\nNo\n\nThey cannot communicate in this case.\n\nSample Input 3\n\n10 10 10 1\n\nSample Output 3\n\nYes\n\nThere can be multiple people at the same position.\n\nSample Input 4\n\n1 100 2 10\n\nSample Output 4\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 328, "memory_kb": 27164}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s736342280", "group_id": "codeNet:p03351", "input_text": "object Main extends App {\n\tval Array(a,b,c,d) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\n\tif(math.abs(a-b) <= d && math.abs(b-c) <= d){\n\t\tprintln(\"Yes\")\n\t}else{\n\t\tprintln(\"No\")\n\t}\n\t\n}", "language": "Scala", "metadata": {"date": 1527467103, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03351.html", "problem_id": "p03351", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03351/input.txt", "sample_output_relpath": "derived/input_output/data/p03351/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03351/Scala/s736342280.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s736342280", "user_id": "u675876401"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n\tval Array(a,b,c,d) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\n\tif(math.abs(a-b) <= d && math.abs(b-c) <= d){\n\t\tprintln(\"Yes\")\n\t}else{\n\t\tprintln(\"No\")\n\t}\n\t\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThree people, A, B and C, are trying to communicate using transceivers.\nThey are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively.\nTwo people can directly communicate when the distance between them is at most d meters.\nDetermine if A and C can communicate, either directly or indirectly.\nHere, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.\n\nConstraints\n\n1 ≤ a,b,c ≤ 100\n\n1 ≤ d ≤ 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c d\n\nOutput\n\nIf A and C can communicate, print Yes; if they cannot, print No.\n\nSample Input 1\n\n4 7 9 3\n\nSample Output 1\n\nYes\n\nA and B can directly communicate, and also B and C can directly communicate, so we should print Yes.\n\nSample Input 2\n\n100 10 1 2\n\nSample Output 2\n\nNo\n\nThey cannot communicate in this case.\n\nSample Input 3\n\n10 10 10 1\n\nSample Output 3\n\nYes\n\nThere can be multiple people at the same position.\n\nSample Input 4\n\n1 100 2 10\n\nSample Output 4\n\nYes", "sample_input": "4 7 9 3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03351", "source_text": "Score : 100 points\n\nProblem Statement\n\nThree people, A, B and C, are trying to communicate using transceivers.\nThey are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively.\nTwo people can directly communicate when the distance between them is at most d meters.\nDetermine if A and C can communicate, either directly or indirectly.\nHere, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.\n\nConstraints\n\n1 ≤ a,b,c ≤ 100\n\n1 ≤ d ≤ 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c d\n\nOutput\n\nIf A and C can communicate, print Yes; if they cannot, print No.\n\nSample Input 1\n\n4 7 9 3\n\nSample Output 1\n\nYes\n\nA and B can directly communicate, and also B and C can directly communicate, so we should print Yes.\n\nSample Input 2\n\n100 10 1 2\n\nSample Output 2\n\nNo\n\nThey cannot communicate in this case.\n\nSample Input 3\n\n10 10 10 1\n\nSample Output 3\n\nYes\n\nThere can be multiple people at the same position.\n\nSample Input 4\n\n1 100 2 10\n\nSample Output 4\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 330, "memory_kb": 27336}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s025995536", "group_id": "codeNet:p03352", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val max = sc.nextInt() match {\n case 1 => 1\n case x =>\n val powers = for {\n i <- LazyList.from(2).takeWhile(_ <= x)\n j <- LazyList.from(2).takeWhile(_ <= x)\n } yield {\n math.pow(i, j).toInt\n }\n powers.filter(_ <= x).max\n }\n println(max)\n}\n", "language": "Scala", "metadata": {"date": 1593820022, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03352.html", "problem_id": "p03352", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03352/input.txt", "sample_output_relpath": "derived/input_output/data/p03352/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03352/Scala/s025995536.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s025995536", "user_id": "u737111725"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val max = sc.nextInt() match {\n case 1 => 1\n case x =>\n val powers = for {\n i <- LazyList.from(2).takeWhile(_ <= x)\n j <- LazyList.from(2).takeWhile(_ <= x)\n } yield {\n math.pow(i, j).toInt\n }\n powers.filter(_ <= x).max\n }\n println(max)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a positive integer X.\nFind the largest perfect power that is at most X.\nHere, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.\n\nConstraints\n\n1 ≤ X ≤ 1000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the largest perfect power that is at most X.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9.\nWe should print the largest among them, 9.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n999\n\nSample Output 3\n\n961", "sample_input": "10\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03352", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a positive integer X.\nFind the largest perfect power that is at most X.\nHere, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.\n\nConstraints\n\n1 ≤ X ≤ 1000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the largest perfect power that is at most X.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9.\nWe should print the largest among them, 9.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n999\n\nSample Output 3\n\n961", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 360, "cpu_time_ms": 1269, "memory_kb": 142396}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s818472913", "group_id": "codeNet:p03352", "input_text": "import java.util.Scanner\n\n\nobject Main {\n def read() = {\n val sc = new Scanner(System.in)\n val x = sc.nextInt()\n x\n }\n\n\n def pow(b: Int, p: Int): Int = {\n if (p == 0) {\n 1\n } else if (p % 2 == 0) {\n pow(b * b, p / 2)\n } else {\n // p%2 == 1\n b * pow(b * b, p / 2)\n }\n }\n\n def log(base: Int)(x: Int) = Math.log(x) / Math.log(base)\n\n def parfectPowerList(base: Int, upperBound: Int) = {\n val maxExponent = log(base)(upperBound).toInt\n (2 to maxExponent).map(x => pow(base, x))\n //↑すべての値はupperBound以下\n }\n\n def main(args: Array[String]): Unit = {\n val x: Int = read()\n val parfectPowers = (2 to x).flatMap(i => parfectPowerList(i, x))\n val result = parfectPowers.max\n println(result)\n }\n}", "language": "Scala", "metadata": {"date": 1526175953, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03352.html", "problem_id": "p03352", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03352/input.txt", "sample_output_relpath": "derived/input_output/data/p03352/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03352/Scala/s818472913.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s818472913", "user_id": "u494788559"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import java.util.Scanner\n\n\nobject Main {\n def read() = {\n val sc = new Scanner(System.in)\n val x = sc.nextInt()\n x\n }\n\n\n def pow(b: Int, p: Int): Int = {\n if (p == 0) {\n 1\n } else if (p % 2 == 0) {\n pow(b * b, p / 2)\n } else {\n // p%2 == 1\n b * pow(b * b, p / 2)\n }\n }\n\n def log(base: Int)(x: Int) = Math.log(x) / Math.log(base)\n\n def parfectPowerList(base: Int, upperBound: Int) = {\n val maxExponent = log(base)(upperBound).toInt\n (2 to maxExponent).map(x => pow(base, x))\n //↑すべての値はupperBound以下\n }\n\n def main(args: Array[String]): Unit = {\n val x: Int = read()\n val parfectPowers = (2 to x).flatMap(i => parfectPowerList(i, x))\n val result = parfectPowers.max\n println(result)\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a positive integer X.\nFind the largest perfect power that is at most X.\nHere, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.\n\nConstraints\n\n1 ≤ X ≤ 1000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the largest perfect power that is at most X.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9.\nWe should print the largest among them, 9.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n999\n\nSample Output 3\n\n961", "sample_input": "10\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03352", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a positive integer X.\nFind the largest perfect power that is at most X.\nHere, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.\n\nConstraints\n\n1 ≤ X ≤ 1000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the largest perfect power that is at most X.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9.\nWe should print the largest among them, 9.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n999\n\nSample Output 3\n\n961", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 351, "memory_kb": 27852}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s096989351", "group_id": "codeNet:p03353", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n\n val s = StdIn.readLine()\n val K = StdIn.readLine().toInt\n val r = {\n for (i <- 0 until s.size;\n j <- 1 to s.size - i; if j <= K)\n yield s.substring(i, i + j)\n }.distinct.sorted.apply(K - 1)\n\n println(r)\n}\n", "language": "Scala", "metadata": {"date": 1530790949, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s096989351.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s096989351", "user_id": "u895032849"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n\n val s = StdIn.readLine()\n val K = StdIn.readLine().toInt\n val r = {\n for (i <- 0 until s.size;\n j <- 1 to s.size - i; if j <= K)\n yield s.substring(i, i + j)\n }.distinct.sorted.apply(K - 1)\n\n println(r)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 681, "memory_kb": 74980}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s251748288", "group_id": "codeNet:p03353", "input_text": "import java.util.Scanner\n\nimport scala.collection.mutable\n\nobject Main {\n def main(args: Array[String]): Unit = println(solve(new Scanner(System.in)))\n\n def solve(in: String): String = solve(new Scanner(in))\n\n def solve(sc: Scanner): String = {\n val s = sc.next\n val K = sc.nextInt\n\n val ss = new mutable.HashSet[String]()\n\n for (i <- 0 until s.length; j <- i + 1 to Array(i + K, s.length).min) {\n ss += s.substring(i, j)\n }\n\n// ss.toList.sorted.foreach(println)\n ss.toList.sorted.take(K).last\n }\n}\n", "language": "Scala", "metadata": {"date": 1526265304, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s251748288.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s251748288", "user_id": "u297767059"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.collection.mutable\n\nobject Main {\n def main(args: Array[String]): Unit = println(solve(new Scanner(System.in)))\n\n def solve(in: String): String = solve(new Scanner(in))\n\n def solve(sc: Scanner): String = {\n val s = sc.next\n val K = sc.nextInt\n\n val ss = new mutable.HashSet[String]()\n\n for (i <- 0 until s.length; j <- i + 1 to Array(i + K, s.length).min) {\n ss += s.substring(i, j)\n }\n\n// ss.toList.sorted.foreach(println)\n ss.toList.sorted.take(K).last\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 529, "cpu_time_ms": 598, "memory_kb": 33504}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s543347603", "group_id": "codeNet:p03360", "input_text": "import scala.io.StdIn._\nimport scala.math.pow\n\nobject Main extends App {\n val s = readLine().split(\" \").map(_.toInt).toSeq\n val k = readInt()\n\n println(s.max * pow(2, k).toInt + s.filterNot(_ == s.max).sum)\n}\n", "language": "Scala", "metadata": {"date": 1600306342, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s543347603.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s543347603", "user_id": "u004161348"}, "prompt_components": {"gold_output": "30\n", "input_to_evaluate": "import scala.io.StdIn._\nimport scala.math.pow\n\nobject Main extends App {\n val s = readLine().split(\" \").map(_.toInt).toSeq\n val k = readInt()\n\n println(s.max * pow(2, k).toInt + s.filterNot(_ == s.max).sum)\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 491, "memory_kb": 58324}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s337779359", "group_id": "codeNet:p03360", "input_text": "object Main extends App {\n import scala.io.StdIn.readLine\n val Array(a, b, c) = readLine().split(' ').map(_.toInt)\n val Array(k) = readLine().split(' ').map(_.toInt)\n\n val values = (0 until k).foldLeft((a,b,c)) { case ((a,b,c), _ ) =>\n val maximumIdx = Seq(a,b,c).zipWithIndex.maxBy(_._1)._2\n maximumIdx match {\n case 0 =>\n (a * 2, b, c)\n case 1 =>\n (a, b * 2, c)\n case 2 =>\n (a, b, c * 2)\n }\n }\n\n println(Seq(values._1, values._2, values._3).sum)\n}", "language": "Scala", "metadata": {"date": 1600263476, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s337779359.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s337779359", "user_id": "u388106329"}, "prompt_components": {"gold_output": "30\n", "input_to_evaluate": "object Main extends App {\n import scala.io.StdIn.readLine\n val Array(a, b, c) = readLine().split(' ').map(_.toInt)\n val Array(k) = readLine().split(' ').map(_.toInt)\n\n val values = (0 until k).foldLeft((a,b,c)) { case ((a,b,c), _ ) =>\n val maximumIdx = Seq(a,b,c).zipWithIndex.maxBy(_._1)._2\n maximumIdx match {\n case 0 =>\n (a * 2, b, c)\n case 1 =>\n (a, b * 2, c)\n case 2 =>\n (a, b, c * 2)\n }\n }\n\n println(Seq(values._1, values._2, values._3).sum)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 502, "memory_kb": 54900}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s908279562", "group_id": "codeNet:p03362", "input_text": "object Main extends App {\n val primes: Stream[Int] = 2 #:: (Stream.from(3, 2) filter {n =>\n primes takeWhile {_ <= Math.sqrt(n).toInt} forall {n % _ != 0}\n })\n println(primes.filter(_ % 5 == 1).take(io.StdIn.readLine.toInt).mkString(\" \"))\n}", "language": "Scala", "metadata": {"date": 1525883973, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s908279562.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s908279562", "user_id": "u132324749"}, "prompt_components": {"gold_output": "3 5 7 11 31\n", "input_to_evaluate": "object Main extends App {\n val primes: Stream[Int] = 2 #:: (Stream.from(3, 2) filter {n =>\n primes takeWhile {_ <= Math.sqrt(n).toInt} forall {n % _ != 0}\n })\n println(primes.filter(_ % 5 == 1).take(io.StdIn.readLine.toInt).mkString(\" \"))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 341, "memory_kb": 25412}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s345967263", "group_id": "codeNet:p03362", "input_text": "import scala.io.Source\n\nobject Main extends App {\n val primes = sieve(Stream.from(2))\n\n def sieve(st: Stream[Int]): Stream[Int] = {\n val x = st.head\n x #:: sieve(st.tail.filter(_ % x != 0))\n }\n\n val lines: Iterator[String] = Source.stdin.getLines()\n val n = lines.next.toInt\n println(primes.take(n).mkString(\" \"))\n}\n", "language": "Scala", "metadata": {"date": 1525640255, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s345967263.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s345967263", "user_id": "u657217027"}, "prompt_components": {"gold_output": "3 5 7 11 31\n", "input_to_evaluate": "import scala.io.Source\n\nobject Main extends App {\n val primes = sieve(Stream.from(2))\n\n def sieve(st: Stream[Int]): Stream[Int] = {\n val x = st.head\n x #:: sieve(st.tail.filter(_ % x != 0))\n }\n\n val lines: Iterator[String] = Source.stdin.getLines()\n val n = lines.next.toInt\n println(primes.take(n).mkString(\" \"))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 331, "memory_kb": 25512}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s232891111", "group_id": "codeNet:p03362", "input_text": "import java.util.Scanner\n\nimport scala.collection.Searching._\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.immutable._\nimport scala.io.StdIn.readLine\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(new Node(None, 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) => root(p)\n }\n}\n\nobject Main {\n val m = (1 << 9) - 1\n\n def solve(sc: => Scanner): Unit = {\n println(getPrimeList.filter(_ % 5 == 4).drop(100).take(sc.nextInt).force.mkString(\" \"))\n }\n\n def recursive(now: Int, A: Array[List[Int]]): Int = {\n if (A(now).size == 0) (now) else {\n val next = A(now).head\n A(now) = A(now).filter(_ != next)\n A(next) = A(next).filter(_ != now)\n recursive(next, A)\n }\n }\n\n def getPermutation(now: Long = 0): Stream[Long] =\n Stream.cons(now, getPermutation(now + 1))\n\n\n def getPrimeList(): Stream[Long] =\n getPrimeListRecursive(getPermutation(2))\n\n\n def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n\n def check(A: Array[List[Int]]): Boolean = {\n A.map(_.size == 0).fold(true)((a, b) => a & b)\n }\n\n def shift(n: Long): Long = {\n if (n == 0) (0) else if (n == 1) (1) else (shift(n - 1) << 1)\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) (0) else (unShift(n >> 1) + 1)\n }\n\n def calc(v: Long): Long = (v + 1) * v / 2\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}", "language": "Scala", "metadata": {"date": 1525623878, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s232891111.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s232891111", "user_id": "u779353743"}, "prompt_components": {"gold_output": "3 5 7 11 31\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.collection.Searching._\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.immutable._\nimport scala.io.StdIn.readLine\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(new Node(None, 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) => root(p)\n }\n}\n\nobject Main {\n val m = (1 << 9) - 1\n\n def solve(sc: => Scanner): Unit = {\n println(getPrimeList.filter(_ % 5 == 4).drop(100).take(sc.nextInt).force.mkString(\" \"))\n }\n\n def recursive(now: Int, A: Array[List[Int]]): Int = {\n if (A(now).size == 0) (now) else {\n val next = A(now).head\n A(now) = A(now).filter(_ != next)\n A(next) = A(next).filter(_ != now)\n recursive(next, A)\n }\n }\n\n def getPermutation(now: Long = 0): Stream[Long] =\n Stream.cons(now, getPermutation(now + 1))\n\n\n def getPrimeList(): Stream[Long] =\n getPrimeListRecursive(getPermutation(2))\n\n\n def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =\n Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))\n\n\n def check(A: Array[List[Int]]): Boolean = {\n A.map(_.size == 0).fold(true)((a, b) => a & b)\n }\n\n def shift(n: Long): Long = {\n if (n == 0) (0) else if (n == 1) (1) else (shift(n - 1) << 1)\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) (0) else (unShift(n >> 1) + 1)\n }\n\n def calc(v: Long): Long = (v + 1) * v / 2\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2279, "cpu_time_ms": 518, "memory_kb": 43804}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s554483376", "group_id": "codeNet:p03362", "input_text": "import java.util.Scanner\n\nimport scala.collection.Searching._\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.immutable._\nimport scala.io.StdIn.readLine\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(new Node(None, 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) => root(p)\n }\n}\n\nobject Main {\n val m = (1 << 9) - 1\n\n def solve(sc: => Scanner): Unit = {\n println(getPrimeList(5555).filter(_ % 5 == 1).take(sc.nextInt).mkString(\" \"))\n }\n\n def recursive(now: Int, A: Array[List[Int]]): Int = {\n if (A(now).size == 0) (now) else {\n val next = A(now).head\n A(now) = A(now).filter(_ != next)\n A(next) = A(next).filter(_ != now)\n recursive(next, A)\n }\n }\n\n def getPrimeList(maxV: Long): List[Long] = {\n getPrimeListRecursive((2L to maxV).toList)\n }\n\n def getPrimeListRecursive(A: List[Long]): List[Long] = {\n if (A.size == 0) (List[Long]()) else {\n List(A.head) ++ getPrimeListRecursive(A.filter(_ % A.head != 0))\n }\n }\n\n def check(A: Array[List[Int]]): Boolean = {\n A.map(_.size == 0).fold(true)((a, b) => a & b)\n }\n\n def shift(n: Long): Long = {\n if (n == 0) (0) else if (n == 1) (1) else (shift(n - 1) << 1)\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) (0) else (unShift(n >> 1) + 1)\n }\n\n def calc(v: Long): Long = (v + 1) * v / 2\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}", "language": "Scala", "metadata": {"date": 1525615856, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s554483376.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s554483376", "user_id": "u779353743"}, "prompt_components": {"gold_output": "3 5 7 11 31\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.collection.Searching._\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.immutable._\nimport scala.io.StdIn.readLine\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(new Node(None, 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) => root(p)\n }\n}\n\nobject Main {\n val m = (1 << 9) - 1\n\n def solve(sc: => Scanner): Unit = {\n println(getPrimeList(5555).filter(_ % 5 == 1).take(sc.nextInt).mkString(\" \"))\n }\n\n def recursive(now: Int, A: Array[List[Int]]): Int = {\n if (A(now).size == 0) (now) else {\n val next = A(now).head\n A(now) = A(now).filter(_ != next)\n A(next) = A(next).filter(_ != now)\n recursive(next, A)\n }\n }\n\n def getPrimeList(maxV: Long): List[Long] = {\n getPrimeListRecursive((2L to maxV).toList)\n }\n\n def getPrimeListRecursive(A: List[Long]): List[Long] = {\n if (A.size == 0) (List[Long]()) else {\n List(A.head) ++ getPrimeListRecursive(A.filter(_ % A.head != 0))\n }\n }\n\n def check(A: Array[List[Int]]): Boolean = {\n A.map(_.size == 0).fold(true)((a, b) => a & b)\n }\n\n def shift(n: Long): Long = {\n if (n == 0) (0) else if (n == 1) (1) else (shift(n - 1) << 1)\n }\n\n def unShift(n: Long): Long = {\n if (n == 0) (0) else (unShift(n >> 1) + 1)\n }\n\n def calc(v: Long): Long = (v + 1) * v / 2\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2226, "cpu_time_ms": 468, "memory_kb": 46568}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s476153938", "group_id": "codeNet:p03363", "input_text": "import java.io.{BufferedOutputStream, BufferedReader, FileOutputStream, InputStreamReader, PrintWriter}\nimport java.lang\n\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.mutable.ArrayBuffer\nimport scala.reflect.ClassTag\n\nobject Main {\n val DEBUG = false\n\n lazy val debugOut: PrintWriter = {\n new PrintWriter(new BufferedOutputStream(new FileOutputStream(\"log.txt\", true)))\n }\n\n def log(message: => String): Unit = {\n if (DEBUG) {\n Console.err.println(message)\n }\n }\n\n def debug(closure: => Unit): Unit = {\n if (DEBUG) {\n closure\n }\n }\n\n def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {\n converter(in.readLine)\n }\n\n def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {\n get[String].split(\"\\\\s+\").map[T](converter)\n }\n\n implicit val idConverter: String => String = s => s\n implicit val intConverter: String => Int = s => Integer.parseInt(s)\n implicit val longConverter: String => Long = s => lang.Long.parseLong(s)\n\n def get[T1, T2](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2\n ): (T1, T2) = {\n getArray[String] match {\n case Array(v1, v2) => (converter1(v1), converter2(v2))\n }\n }\n\n def get[T1, T2, T3](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3\n ): (T1, T2, T3) = {\n getArray[String] match {\n case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))\n }\n }\n\n def get[T1, T2, T3, T4](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3,\n converter4: String => T4\n ): (T1, T2, T3, T4) = {\n getArray[String] match {\n case Array(v1, v2, v3, v4) => (converter1(v1), converter2(v2), converter3(v3), converter4(v4))\n }\n }\n\n implicit class TimesInt(val n: Int) {\n def times(f: Int => Unit): Unit = {\n for (i <- 0 until n) {\n f(i)\n }\n }\n }\n\n def primes(n: Long): ArrayBuffer[Long] = {\n val buf = ArrayBuffer.empty[Long]\n val s = Math.sqrt(n).toInt\n\n var v = n\n for (i <- 2 to s) {\n if (v == 1 || v == 0) {\n return buf\n } else {\n while (v % i == 0) {\n buf.append(i)\n v /= i\n }\n }\n }\n if (v > s) {\n buf.append(v)\n }\n buf\n }\n\n def divisors(n: Int): ArrayBuffer[Int] = {\n val buf = ArrayBuffer.empty[Int]\n val s = Math.sqrt(n).toInt\n\n for (i <- 1 to s) {\n if (n % i == 0) {\n buf.append(i)\n if (i != n / i) {\n buf.append(n / i)\n }\n }\n }\n buf\n }\n\n @tailrec\n def gcd(a: Long, b: Long): Long = {\n val reminder = a % b\n if (reminder == 0) {\n b\n } else {\n gcd(b, reminder)\n }\n }\n\n @tailrec\n def gcd(a: Int, b: Int): Int = {\n val reminder = a % b\n if (reminder == 0) {\n b\n } else {\n gcd(b, reminder)\n }\n }\n\n def lcm(a: Long, b: Long): Long = {\n a / gcd(a, b) * b\n }\n\n def toBitArray(n: Int, width: Int): Array[Boolean] = {\n val buf = ArrayBuffer.fill(width)(false)\n\n @tailrec\n def inner(n: Int, i: Int): Array[Boolean] = {\n buf(i) = (n & 1) == 0\n if (i == 0) {\n buf.toArray\n } else {\n inner(n / 2, i - 1)\n }\n }\n\n inner(n, width - 1)\n }\n\n def modpow(n: Long, p: Long, m: Long): Long = {\n @tailrec\n def inner(n: Long, p: Long, acc: Long): Long = {\n if (p == 0) {\n acc\n } else if ((p & 1) == 0) {\n inner(n * n % m, p >> 1, acc)\n } else {\n inner(n * n % m, p >> 1, acc * n % m)\n }\n }\n\n inner(n % m, p, 1)\n }\n\n def main(args: Array[String]): Unit = {\n implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n\n log(\"=== start\")\n\n val n = get[Int]\n val as = getArray[Int]\n\n val sums = as.scanLeft(0L) {\n case (acc, a) => acc + a\n }\n\n val map = mutable.HashMap.empty[Long, Long]\n for (sum <- sums) {\n map(sum) = map.getOrElse(sum, 0L) + 1\n }\n\n var patternNum = 0L\n for (c <- map.values) {\n patternNum += c * (c - 1) / 2\n }\n\n out.println(patternNum)\n\n out.flush()\n log(\"=== end\")\n debug {\n debugOut.flush()\n }\n }\n}", "language": "Scala", "metadata": {"date": 1599407379, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s476153938.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s476153938", "user_id": "u178269371"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.io.{BufferedOutputStream, BufferedReader, FileOutputStream, InputStreamReader, PrintWriter}\nimport java.lang\n\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.mutable.ArrayBuffer\nimport scala.reflect.ClassTag\n\nobject Main {\n val DEBUG = false\n\n lazy val debugOut: PrintWriter = {\n new PrintWriter(new BufferedOutputStream(new FileOutputStream(\"log.txt\", true)))\n }\n\n def log(message: => String): Unit = {\n if (DEBUG) {\n Console.err.println(message)\n }\n }\n\n def debug(closure: => Unit): Unit = {\n if (DEBUG) {\n closure\n }\n }\n\n def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {\n converter(in.readLine)\n }\n\n def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {\n get[String].split(\"\\\\s+\").map[T](converter)\n }\n\n implicit val idConverter: String => String = s => s\n implicit val intConverter: String => Int = s => Integer.parseInt(s)\n implicit val longConverter: String => Long = s => lang.Long.parseLong(s)\n\n def get[T1, T2](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2\n ): (T1, T2) = {\n getArray[String] match {\n case Array(v1, v2) => (converter1(v1), converter2(v2))\n }\n }\n\n def get[T1, T2, T3](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3\n ): (T1, T2, T3) = {\n getArray[String] match {\n case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))\n }\n }\n\n def get[T1, T2, T3, T4](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3,\n converter4: String => T4\n ): (T1, T2, T3, T4) = {\n getArray[String] match {\n case Array(v1, v2, v3, v4) => (converter1(v1), converter2(v2), converter3(v3), converter4(v4))\n }\n }\n\n implicit class TimesInt(val n: Int) {\n def times(f: Int => Unit): Unit = {\n for (i <- 0 until n) {\n f(i)\n }\n }\n }\n\n def primes(n: Long): ArrayBuffer[Long] = {\n val buf = ArrayBuffer.empty[Long]\n val s = Math.sqrt(n).toInt\n\n var v = n\n for (i <- 2 to s) {\n if (v == 1 || v == 0) {\n return buf\n } else {\n while (v % i == 0) {\n buf.append(i)\n v /= i\n }\n }\n }\n if (v > s) {\n buf.append(v)\n }\n buf\n }\n\n def divisors(n: Int): ArrayBuffer[Int] = {\n val buf = ArrayBuffer.empty[Int]\n val s = Math.sqrt(n).toInt\n\n for (i <- 1 to s) {\n if (n % i == 0) {\n buf.append(i)\n if (i != n / i) {\n buf.append(n / i)\n }\n }\n }\n buf\n }\n\n @tailrec\n def gcd(a: Long, b: Long): Long = {\n val reminder = a % b\n if (reminder == 0) {\n b\n } else {\n gcd(b, reminder)\n }\n }\n\n @tailrec\n def gcd(a: Int, b: Int): Int = {\n val reminder = a % b\n if (reminder == 0) {\n b\n } else {\n gcd(b, reminder)\n }\n }\n\n def lcm(a: Long, b: Long): Long = {\n a / gcd(a, b) * b\n }\n\n def toBitArray(n: Int, width: Int): Array[Boolean] = {\n val buf = ArrayBuffer.fill(width)(false)\n\n @tailrec\n def inner(n: Int, i: Int): Array[Boolean] = {\n buf(i) = (n & 1) == 0\n if (i == 0) {\n buf.toArray\n } else {\n inner(n / 2, i - 1)\n }\n }\n\n inner(n, width - 1)\n }\n\n def modpow(n: Long, p: Long, m: Long): Long = {\n @tailrec\n def inner(n: Long, p: Long, acc: Long): Long = {\n if (p == 0) {\n acc\n } else if ((p & 1) == 0) {\n inner(n * n % m, p >> 1, acc)\n } else {\n inner(n * n % m, p >> 1, acc * n % m)\n }\n }\n\n inner(n % m, p, 1)\n }\n\n def main(args: Array[String]): Unit = {\n implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n\n log(\"=== start\")\n\n val n = get[Int]\n val as = getArray[Int]\n\n val sums = as.scanLeft(0L) {\n case (acc, a) => acc + a\n }\n\n val map = mutable.HashMap.empty[Long, Long]\n for (sum <- sums) {\n map(sum) = map.getOrElse(sum, 0L) + 1\n }\n\n var patternNum = 0L\n for (c <- map.values) {\n patternNum += c * (c - 1) / 2\n }\n\n out.println(patternNum)\n\n out.flush()\n log(\"=== end\")\n debug {\n debugOut.flush()\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4697, "cpu_time_ms": 954, "memory_kb": 82124}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s620863757", "group_id": "codeNet:p03364", "input_text": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val N = in.next().toInt\n val S = Array.ofDim[Char](2*N, 2*N)\n\n for (y <- 1 to N){\n val s = in.next()\n for (x <- 1 to N){\n S(y)(x) = s(x-1)\n }\n }\n\n for (y <- N+1 to 2*N-1){\n for (x <- 1 to N){\n S(y)(x) = S(y-N)(x)\n }\n }\n for (y <- 1 to N){\n for (x <- N+1 to 2*N-1){\n S(y)(x) = S(y)(x-N)\n }\n }\n for (y <- N+1 to 2*N-1){\n for (x <- N+1 to 2*N-1){\n S(y)(x) = S(y-N)(x-N)\n }\n }\n\n\n\n\n // process\n var ans = 0\n\n val dp = Array.ofDim[Int](2*N, 2*N)\n var tmp = 42\n for(y <- 1 to 2*N-1; x <- y+1 to 2*N-1) {\n if(S(y)(x) == S(x)(y)) {\n dp(y)(x) = tmp\n }\n }\n var flag = true\n val ny = 1; val nx = 1\n for (y <- ny to ny+N-1; x <- y+1 to ny+N-1) {\n if(dp(y)(x) != tmp) {\n flag = false\n }\n }\n if(flag)\n ans += N\n\n\n //// for y\n for(sty <- 2 to N) {\n tmp += 1\n\n for(y <- sty to 2*N-1; x <- 1+(y-sty+1) to 2*N-1 - (sty-1)) {\n if(S(y)(x) == S(x+(sty-1))(y-(sty-1))) {\n dp(y)(x) = tmp\n }\n }\n\n val ny = sty; val nx = 1\n var flag = true\n for (y <- ny to ny+N-1; x <- nx + y-ny+1 to nx+N-1) {\n if(dp(y)(x) != tmp) {\n flag = false\n }\n }\n if(flag){\n ans += (N - sty + 1)\n }\n \n }\n\n\n //// for x\n for(stx <- 2 to N) {\n tmp += 1\n\n for(x <- stx to 2*N-1; y <- 1+(x-stx+1) to 2*N-1 - (stx-1)) {\n if(S(y)(x) == S(x-(stx-1))(y+(stx-1))) {\n dp(y)(x) = tmp\n }\n }\n \n ///\n val nx = stx; val ny = 1\n var flag = true\n\n for (x <- nx to nx+N-1; y <- ny + x-nx+1 to ny+N-1) {\n if(dp(y)(x) != tmp) {\n flag = false\n }\n }\n if(flag){\n ans += (N - stx + 1)\n }\n }\n\n\n println(ans)\n}\n\n\nclass InputReader(stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream))\n private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1524970453, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03364.html", "problem_id": "p03364", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03364/input.txt", "sample_output_relpath": "derived/input_output/data/p03364/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03364/Scala/s620863757.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s620863757", "user_id": "u098968285"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val N = in.next().toInt\n val S = Array.ofDim[Char](2*N, 2*N)\n\n for (y <- 1 to N){\n val s = in.next()\n for (x <- 1 to N){\n S(y)(x) = s(x-1)\n }\n }\n\n for (y <- N+1 to 2*N-1){\n for (x <- 1 to N){\n S(y)(x) = S(y-N)(x)\n }\n }\n for (y <- 1 to N){\n for (x <- N+1 to 2*N-1){\n S(y)(x) = S(y)(x-N)\n }\n }\n for (y <- N+1 to 2*N-1){\n for (x <- N+1 to 2*N-1){\n S(y)(x) = S(y-N)(x-N)\n }\n }\n\n\n\n\n // process\n var ans = 0\n\n val dp = Array.ofDim[Int](2*N, 2*N)\n var tmp = 42\n for(y <- 1 to 2*N-1; x <- y+1 to 2*N-1) {\n if(S(y)(x) == S(x)(y)) {\n dp(y)(x) = tmp\n }\n }\n var flag = true\n val ny = 1; val nx = 1\n for (y <- ny to ny+N-1; x <- y+1 to ny+N-1) {\n if(dp(y)(x) != tmp) {\n flag = false\n }\n }\n if(flag)\n ans += N\n\n\n //// for y\n for(sty <- 2 to N) {\n tmp += 1\n\n for(y <- sty to 2*N-1; x <- 1+(y-sty+1) to 2*N-1 - (sty-1)) {\n if(S(y)(x) == S(x+(sty-1))(y-(sty-1))) {\n dp(y)(x) = tmp\n }\n }\n\n val ny = sty; val nx = 1\n var flag = true\n for (y <- ny to ny+N-1; x <- nx + y-ny+1 to nx+N-1) {\n if(dp(y)(x) != tmp) {\n flag = false\n }\n }\n if(flag){\n ans += (N - sty + 1)\n }\n \n }\n\n\n //// for x\n for(stx <- 2 to N) {\n tmp += 1\n\n for(x <- stx to 2*N-1; y <- 1+(x-stx+1) to 2*N-1 - (stx-1)) {\n if(S(y)(x) == S(x-(stx-1))(y+(stx-1))) {\n dp(y)(x) = tmp\n }\n }\n \n ///\n val nx = stx; val ny = 1\n var flag = true\n\n for (x <- nx to nx+N-1; y <- ny + x-nx+1 to ny+N-1) {\n if(dp(y)(x) != tmp) {\n flag = false\n }\n }\n if(flag){\n ans += (N - stx + 1)\n }\n }\n\n\n println(ans)\n}\n\n\nclass InputReader(stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream))\n private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nSnuke has two boards, each divided into a grid with N rows and N columns.\nFor both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j).\n\nThere is a lowercase English letter written in each square on the first board. The letter written in Square (i,j) is S_{i,j}. On the second board, nothing is written yet.\n\nSnuke will write letters on the second board, as follows:\n\nFirst, choose two integers A and B ( 0 \\leq A, B < N ).\n\nWrite one letter in each square on the second board.\nSpecifically, write the letter written in Square ( i+A, j+B ) on the first board into Square (i,j) on the second board.\nHere, the k-th row is also represented as the (N+k)-th row, and the k-th column is also represented as the (N+k)-th column.\n\nAfter this operation, the second board is called a good board when, for every i and j ( 1 \\leq i, j \\leq N ), the letter in Square (i,j) and the letter in Square (j,i) are equal.\n\nFind the number of the ways to choose integers A and B ( 0 \\leq A, B < N ) such that the second board is a good board.\n\nConstraints\n\n1 \\leq N \\leq 300\n\nS_{i,j} ( 1 \\leq i, j \\leq N ) is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_{1,1}S_{1,2}..S_{1,N}\nS_{2,1}S_{2,2}..S_{2,N}\n:\nS_{N,1}S_{N,2}..S_{N,N}\n\nOutput\n\nPrint the number of the ways to choose integers A and B ( 0 \\leq A, B < N ) such that the second board is a good board.\n\nSample Input 1\n\n2\nab\nca\n\nSample Output 1\n\n2\n\nFor each pair of A and B, the second board will look as shown below:\n\nThe second board is a good board when (A,B) = (0,1) or (A,B) = (1,0), thus the answer is 2.\n\nSample Input 2\n\n4\naaaa\naaaa\naaaa\naaaa\n\nSample Output 2\n\n16\n\nEvery possible choice of A and B makes the second board good.\n\nSample Input 3\n\n5\nabcde\nfghij\nklmno\npqrst\nuvwxy\n\nSample Output 3\n\n0\n\nNo possible choice of A and B makes the second board good.", "sample_input": "2\nab\nca\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03364", "source_text": "Score : 500 points\n\nProblem Statement\n\nSnuke has two boards, each divided into a grid with N rows and N columns.\nFor both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j).\n\nThere is a lowercase English letter written in each square on the first board. The letter written in Square (i,j) is S_{i,j}. On the second board, nothing is written yet.\n\nSnuke will write letters on the second board, as follows:\n\nFirst, choose two integers A and B ( 0 \\leq A, B < N ).\n\nWrite one letter in each square on the second board.\nSpecifically, write the letter written in Square ( i+A, j+B ) on the first board into Square (i,j) on the second board.\nHere, the k-th row is also represented as the (N+k)-th row, and the k-th column is also represented as the (N+k)-th column.\n\nAfter this operation, the second board is called a good board when, for every i and j ( 1 \\leq i, j \\leq N ), the letter in Square (i,j) and the letter in Square (j,i) are equal.\n\nFind the number of the ways to choose integers A and B ( 0 \\leq A, B < N ) such that the second board is a good board.\n\nConstraints\n\n1 \\leq N \\leq 300\n\nS_{i,j} ( 1 \\leq i, j \\leq N ) is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_{1,1}S_{1,2}..S_{1,N}\nS_{2,1}S_{2,2}..S_{2,N}\n:\nS_{N,1}S_{N,2}..S_{N,N}\n\nOutput\n\nPrint the number of the ways to choose integers A and B ( 0 \\leq A, B < N ) such that the second board is a good board.\n\nSample Input 1\n\n2\nab\nca\n\nSample Output 1\n\n2\n\nFor each pair of A and B, the second board will look as shown below:\n\nThe second board is a good board when (A,B) = (0,1) or (A,B) = (1,0), thus the answer is 2.\n\nSample Input 2\n\n4\naaaa\naaaa\naaaa\naaaa\n\nSample Output 2\n\n16\n\nEvery possible choice of A and B makes the second board good.\n\nSample Input 3\n\n5\nabcde\nfghij\nklmno\npqrst\nuvwxy\n\nSample Output 3\n\n0\n\nNo possible choice of A and B makes the second board good.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2243, "cpu_time_ms": 1514, "memory_kb": 51328}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s965978334", "group_id": "codeNet:p03369", "input_text": "import scala.io.StdIn\nobject Main extends App {\n val answer = StdIn.readLine().split(\"\").filter(_=='o').size * 100 + 700\n println(answer)\n}\n", "language": "Scala", "metadata": {"date": 1566167752, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s965978334.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s965978334", "user_id": "u407005073"}, "prompt_components": {"gold_output": "900\n", "input_to_evaluate": "import scala.io.StdIn\nobject Main extends App {\n val answer = StdIn.readLine().split(\"\").filter(_=='o').size * 100 + 700\n println(answer)\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 320, "memory_kb": 25296}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s608148930", "group_id": "codeNet:p03369", "input_text": "import scala.io.StdIn\nobject Main extends App {\n val answer = StdIn.readLine().split(\"\").filter(_=='o').size * 100 + 900\n println(answer)\n}\n", "language": "Scala", "metadata": {"date": 1566167622, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s608148930.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s608148930", "user_id": "u407005073"}, "prompt_components": {"gold_output": "900\n", "input_to_evaluate": "import scala.io.StdIn\nobject Main extends App {\n val answer = StdIn.readLine().split(\"\").filter(_=='o').size * 100 + 900\n println(answer)\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 333, "memory_kb": 25424}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s661485617", "group_id": "codeNet:p03369", "input_text": "object Main extends App {\n println(readLine.toSeq.count(_.equals('o')) * 100 + 700)\n}", "language": "Scala", "metadata": {"date": 1528054825, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s661485617.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s661485617", "user_id": "u149419355"}, "prompt_components": {"gold_output": "900\n", "input_to_evaluate": "object Main extends App {\n println(readLine.toSeq.count(_.equals('o')) * 100 + 700)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 86, "cpu_time_ms": 326, "memory_kb": 25528}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s822058312", "group_id": "codeNet:p03370", "input_text": "object Main extends App {\n\tval Array(n, x) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\tval a = new Array[Int](n)\n\tfor(i <- 0 until n){\n\t\ta(i) = scala.io.StdIn.readInt\n\t}\n\n\tval tp = a.sum\n\tprintln(n + (x - tp)/a.min)\n}\n", "language": "Scala", "metadata": {"date": 1524364467, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s822058312.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s822058312", "user_id": "u675876401"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "object Main extends App {\n\tval Array(n, x) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\tval a = new Array[Int](n)\n\tfor(i <- 0 until n){\n\t\ta(i) = scala.io.StdIn.readInt\n\t}\n\n\tval tp = a.sum\n\tprintln(n + (x - tp)/a.min)\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 329, "memory_kb": 25512}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s379341308", "group_id": "codeNet:p03371", "input_text": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]) {\n solve(new Scanner(System.in))\n }\n\n def solve(sc: Scanner): Unit = {\n val A = sc.nextInt\n val B = sc.nextInt\n val C = sc.nextInt\n var X = sc.nextInt\n var Y = sc.nextInt\n\n var p = if (A + B > C * 2) {\n val m = List(X, Y).min\n X -= m\n Y -= m\n C * 2 * m\n } else 0\n p += List(A, C * 2).min * X\n p += List(B, C * 2).min * Y\n println(p)\n }\n}\n", "language": "Scala", "metadata": {"date": 1524359795, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s379341308.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s379341308", "user_id": "u297767059"}, "prompt_components": {"gold_output": "7900\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]) {\n solve(new Scanner(System.in))\n }\n\n def solve(sc: Scanner): Unit = {\n val A = sc.nextInt\n val B = sc.nextInt\n val C = sc.nextInt\n var X = sc.nextInt\n var Y = sc.nextInt\n\n var p = if (A + B > C * 2) {\n val m = List(X, Y).min\n X -= m\n Y -= m\n C * 2 * m\n } else 0\n p += List(A, C * 2).min * X\n p += List(B, C * 2).min * Y\n println(p)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 355, "memory_kb": 27332}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s379428312", "group_id": "codeNet:p03373", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val a, b, c, x, y = sc.nextInt()\n if (a + b <= 2 * c) {\n println(a * x + b * y)\n } else {\n var ans = 0\n if (x <= y) {\n ans += 2 * c * x\n ans += (y - x) * b.min(2 * c)\n } else {\n ans += 2 * c * y\n ans += (x - y) * a.min(2 * c)\n }\n println(ans)\n }\n}\n", "language": "Scala", "metadata": {"date": 1601169570, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03373.html", "problem_id": "p03373", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03373/input.txt", "sample_output_relpath": "derived/input_output/data/p03373/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03373/Scala/s379428312.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s379428312", "user_id": "u191819389"}, "prompt_components": {"gold_output": "7900\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val a, b, c, x, y = sc.nextInt()\n if (a + b <= 2 * c) {\n println(a * x + b * y)\n } else {\n var ans = 0\n if (x <= y) {\n ans += 2 * c * x\n ans += (y - x) * b.min(2 * c)\n } else {\n ans += 2 * c * y\n ans += (x - y) * a.min(2 * c)\n }\n println(ans)\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": "p03373", "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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 361, "cpu_time_ms": 533, "memory_kb": 55372}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s319503315", "group_id": "codeNet:p03379", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt()\n val x = List.fill(n)(sc.nextInt())\n val sorted = x.sorted\n val med1 = sorted.apply(n/2)\n val med2 = sorted.apply(n/2-1)\n for (i <- 1 to n){\n if (x(i-1)<=med2){\n println(med1)\n } else{\n println(med2)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1523756213, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03379.html", "problem_id": "p03379", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03379/input.txt", "sample_output_relpath": "derived/input_output/data/p03379/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03379/Scala/s319503315.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s319503315", "user_id": "u387147818"}, "prompt_components": {"gold_output": "4\n3\n3\n4\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt()\n val x = List.fill(n)(sc.nextInt())\n val sorted = x.sorted\n val med1 = sorted.apply(n/2)\n val med2 = sorted.apply(n/2-1)\n for (i <- 1 to n){\n if (x(i-1)<=med2){\n println(med1)\n } else{\n println(med2)\n }\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWhen l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.\n\nYou are given N numbers X_1, X_2, ..., X_N, where N is an even number.\nFor each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.\n\nFind B_i for each i = 1, 2, ..., N.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n1 \\leq X_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint N lines.\nThe i-th line should contain B_i.\n\nSample Input 1\n\n4\n2 4 4 3\n\nSample Output 1\n\n4\n3\n3\n4\n\nSince the median of X_2, X_3, X_4 is 4, B_1 = 4.\n\nSince the median of X_1, X_3, X_4 is 3, B_2 = 3.\n\nSince the median of X_1, X_2, X_4 is 3, B_3 = 3.\n\nSince the median of X_1, X_2, X_3 is 4, B_4 = 4.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n2\n1\n\nSample Input 3\n\n6\n5 5 4 4 3 3\n\nSample Output 3\n\n4\n4\n4\n4\n4\n4", "sample_input": "4\n2 4 4 3\n"}, "reference_outputs": ["4\n3\n3\n4\n"], "source_document_id": "p03379", "source_text": "Score : 300 points\n\nProblem Statement\n\nWhen l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.\n\nYou are given N numbers X_1, X_2, ..., X_N, where N is an even number.\nFor each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.\n\nFind B_i for each i = 1, 2, ..., N.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n1 \\leq X_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint N lines.\nThe i-th line should contain B_i.\n\nSample Input 1\n\n4\n2 4 4 3\n\nSample Output 1\n\n4\n3\n3\n4\n\nSince the median of X_2, X_3, X_4 is 4, B_1 = 4.\n\nSince the median of X_1, X_3, X_4 is 3, B_2 = 3.\n\nSince the median of X_1, X_2, X_4 is 3, B_3 = 3.\n\nSince the median of X_1, X_2, X_3 is 4, B_4 = 4.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n2\n1\n\nSample Input 3\n\n6\n5 5 4 4 3 3\n\nSample Output 3\n\n4\n4\n4\n4\n4\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 80640}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s541611928", "group_id": "codeNet:p03380", "input_text": "\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val N = sc.nextInt()\n val A = Array.fill(N)(sc.nextInt()).sorted\n\n // comb(ai, aj), これは ai を固定した時には,\n // 単峰関数のような関数 f_ai(x) = comb(ai, x)\n // となる。すると, 最大の値の候補は\n // ai の真ん中もしくは, 真ん中に近い2つの値が候補になる\n // これは, 二分探索で探せるのでいける\n // これを全てのaiについて調べても間に合う\n // 実際に combを計算する必要はない\n def solve(N: Int, A: Array[Int]): (Int, Int) = {\n def upperBounds(n: Int, upper: Int): Int = {\n @scala.annotation.tailrec\n def loop(left: Int, right: Int): Int =\n if (right - left > 1) {\n val mid = left + (right - left) / 2\n if (A(mid) >= n) loop(left, mid)\n else loop(mid, right)\n } else right\n loop(-1, upper)\n }\n def lowerBounds(n: Int, upper: Int): Int = {\n @scala.annotation.tailrec\n def loop(left: Int, right: Int): Int =\n if (right - left > 1) {\n val mid = left + (right - left) / 2\n if (A(mid) <= n) loop(mid, right)\n else loop(left, mid)\n } else left\n loop(-1, upper)\n }\n @scala.annotation.tailrec\n def loop(i: Int, diff: Int, n: Int, r: Int): (Int, Int) =\n if (i < N) {\n val center = (A(i) / 2.toDouble).round.toInt\n val li = lowerBounds(center, i)\n val ri = upperBounds(center, i)\n val left = if (li >= 0) A(li) else 0\n val right = if (ri < A(i)) A(ri) else A(i)\n if (left > A(i) - right) {\n if (left > diff) loop(i + 1, left, A(i), left)\n else loop(i + 1, diff, n, r)\n } else {\n if (A(i) - right > diff) loop(i + 1, A(i) - right, A(i), right)\n else loop(i + 1, diff, n, r)\n }\n } else (n, r)\n\n loop(1, 0, A.last, 0)\n }\n\n val (n, r) = solve(N, A)\n println(s\"$n $r\")\n }\n\n}\n\n", "language": "Scala", "metadata": {"date": 1576900517, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03380.html", "problem_id": "p03380", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03380/input.txt", "sample_output_relpath": "derived/input_output/data/p03380/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03380/Scala/s541611928.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s541611928", "user_id": "u891387249"}, "prompt_components": {"gold_output": "11 6\n", "input_to_evaluate": "\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val N = sc.nextInt()\n val A = Array.fill(N)(sc.nextInt()).sorted\n\n // comb(ai, aj), これは ai を固定した時には,\n // 単峰関数のような関数 f_ai(x) = comb(ai, x)\n // となる。すると, 最大の値の候補は\n // ai の真ん中もしくは, 真ん中に近い2つの値が候補になる\n // これは, 二分探索で探せるのでいける\n // これを全てのaiについて調べても間に合う\n // 実際に combを計算する必要はない\n def solve(N: Int, A: Array[Int]): (Int, Int) = {\n def upperBounds(n: Int, upper: Int): Int = {\n @scala.annotation.tailrec\n def loop(left: Int, right: Int): Int =\n if (right - left > 1) {\n val mid = left + (right - left) / 2\n if (A(mid) >= n) loop(left, mid)\n else loop(mid, right)\n } else right\n loop(-1, upper)\n }\n def lowerBounds(n: Int, upper: Int): Int = {\n @scala.annotation.tailrec\n def loop(left: Int, right: Int): Int =\n if (right - left > 1) {\n val mid = left + (right - left) / 2\n if (A(mid) <= n) loop(mid, right)\n else loop(left, mid)\n } else left\n loop(-1, upper)\n }\n @scala.annotation.tailrec\n def loop(i: Int, diff: Int, n: Int, r: Int): (Int, Int) =\n if (i < N) {\n val center = (A(i) / 2.toDouble).round.toInt\n val li = lowerBounds(center, i)\n val ri = upperBounds(center, i)\n val left = if (li >= 0) A(li) else 0\n val right = if (ri < A(i)) A(ri) else A(i)\n if (left > A(i) - right) {\n if (left > diff) loop(i + 1, left, A(i), left)\n else loop(i + 1, diff, n, r)\n } else {\n if (A(i) - right > diff) loop(i + 1, A(i) - right, A(i), right)\n else loop(i + 1, diff, n, r)\n }\n } else (n, r)\n\n loop(1, 0, A.last, 0)\n }\n\n val (n, r) = solve(N, A)\n println(s\"$n $r\")\n }\n\n}\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nLet {\\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order.\nFrom n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\\rm comb}(a_i,a_j) is maximized.\nIf there are multiple pairs that maximize the value, any of them is accepted.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\n0 \\leq a_i \\leq 10^9\n\na_1,a_2,...,a_n are pairwise distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_n\n\nOutput\n\nPrint a_i and a_j that you selected, with a space in between.\n\nSample Input 1\n\n5\n6 9 4 2 11\n\nSample Output 1\n\n11 6\n\n\\rm{comb}(a_i,a_j) for each possible selection is as follows:\n\n\\rm{comb}(4,2)=6\n\n\\rm{comb}(6,2)=15\n\n\\rm{comb}(6,4)=15\n\n\\rm{comb}(9,2)=36\n\n\\rm{comb}(9,4)=126\n\n\\rm{comb}(9,6)=84\n\n\\rm{comb}(11,2)=55\n\n\\rm{comb}(11,4)=330\n\n\\rm{comb}(11,6)=462\n\n\\rm{comb}(11,9)=55\n\nThus, we should print 11 and 6.\n\nSample Input 2\n\n2\n100 0\n\nSample Output 2\n\n100 0", "sample_input": "5\n6 9 4 2 11\n"}, "reference_outputs": ["11 6\n"], "source_document_id": "p03380", "source_text": "Score : 400 points\n\nProblem Statement\n\nLet {\\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order.\nFrom n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\\rm comb}(a_i,a_j) is maximized.\nIf there are multiple pairs that maximize the value, any of them is accepted.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\n0 \\leq a_i \\leq 10^9\n\na_1,a_2,...,a_n are pairwise distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\na_1 a_2 ... a_n\n\nOutput\n\nPrint a_i and a_j that you selected, with a space in between.\n\nSample Input 1\n\n5\n6 9 4 2 11\n\nSample Output 1\n\n11 6\n\n\\rm{comb}(a_i,a_j) for each possible selection is as follows:\n\n\\rm{comb}(4,2)=6\n\n\\rm{comb}(6,2)=15\n\n\\rm{comb}(6,4)=15\n\n\\rm{comb}(9,2)=36\n\n\\rm{comb}(9,4)=126\n\n\\rm{comb}(9,6)=84\n\n\\rm{comb}(11,2)=55\n\n\\rm{comb}(11,4)=330\n\n\\rm{comb}(11,6)=462\n\n\\rm{comb}(11,9)=55\n\nThus, we should print 11 and 6.\n\nSample Input 2\n\n2\n100 0\n\nSample Output 2\n\n100 0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2117, "cpu_time_ms": 888, "memory_kb": 52344}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s695377297", "group_id": "codeNet:p03381", "input_text": "import java.{util => ju}\nimport scala.collection.{mutable => mu}\nimport MyPredef._\n\n\nobject Main extends App {\n import java.util.Arrays\n val p = new java.io.PrintWriter(System.out)\n\n val n = MyPredef.nextInt\n val X = Array.fill(n)(MyPredef.nextInt)\n val Xs = X.clone()\n Arrays.sort(Xs)\n val halfB = Xs(n / 2 - 1) // before\n val halfA = Xs(n / 2) // after\n\n MyPredef.rep(n, i => {\n if (X(i) <= halfB) {\n p.println(halfA)\n } else {\n p.println(halfB)\n }\n })\n p.flush()\n}\n\n\nobject MyPredef {\n @inline def rep(n: Int, f: => Unit): Unit = { var c = 0; while (c < n) { f; c += 1 } }\n @inline def rep(n: Int, f: Int => Unit): Unit = { var c = 0; while (c < n) { f(c); c += 1 } }\n\n private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0\n @inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126\n @inline private def hasNextByte(): Boolean =\n if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else { true }\n @inline private def hasNext(): Boolean = {\n while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1\n hasNextByte()\n }\n @inline private def readByte(): Byte =\n if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else { -1 }\n def next(): String = {\n if(!hasNext()) ???\n val sb = new StringBuilder; var b = readByte()\n while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }\n sb.toString\n }\n def nextInt(): Int = {\n val n = nextLong()\n if (n < Int.MinValue || Int.MaxValue < n) ???\n n.toInt\n }\n def nextLong(): Long = {\n if(!hasNext()) ???\n var minus = false; var b = readByte()\n if (b == '-') { minus = true; b = readByte() }\n def go (b: Byte, n: Long = 0): Long =\n if ('0' <= b && b <= '9') { go(readByte(), n * 10 + b - '0') }\n else if (minus) { -n } else { n }\n go(b)\n }\n def nextDouble(): Double = next.toDouble\n}\n", "language": "Scala", "metadata": {"date": 1524108245, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s695377297.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s695377297", "user_id": "u290193605"}, "prompt_components": {"gold_output": "4\n3\n3\n4\n", "input_to_evaluate": "import java.{util => ju}\nimport scala.collection.{mutable => mu}\nimport MyPredef._\n\n\nobject Main extends App {\n import java.util.Arrays\n val p = new java.io.PrintWriter(System.out)\n\n val n = MyPredef.nextInt\n val X = Array.fill(n)(MyPredef.nextInt)\n val Xs = X.clone()\n Arrays.sort(Xs)\n val halfB = Xs(n / 2 - 1) // before\n val halfA = Xs(n / 2) // after\n\n MyPredef.rep(n, i => {\n if (X(i) <= halfB) {\n p.println(halfA)\n } else {\n p.println(halfB)\n }\n })\n p.flush()\n}\n\n\nobject MyPredef {\n @inline def rep(n: Int, f: => Unit): Unit = { var c = 0; while (c < n) { f; c += 1 } }\n @inline def rep(n: Int, f: Int => Unit): Unit = { var c = 0; while (c < n) { f(c); c += 1 } }\n\n private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0\n @inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126\n @inline private def hasNextByte(): Boolean =\n if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else { true }\n @inline private def hasNext(): Boolean = {\n while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1\n hasNextByte()\n }\n @inline private def readByte(): Byte =\n if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else { -1 }\n def next(): String = {\n if(!hasNext()) ???\n val sb = new StringBuilder; var b = readByte()\n while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }\n sb.toString\n }\n def nextInt(): Int = {\n val n = nextLong()\n if (n < Int.MinValue || Int.MaxValue < n) ???\n n.toInt\n }\n def nextLong(): Long = {\n if(!hasNext()) ???\n var minus = false; var b = readByte()\n if (b == '-') { minus = true; b = readByte() }\n def go (b: Byte, n: Long = 0): Long =\n if ('0' <= b && b <= '9') { go(readByte(), n * 10 + b - '0') }\n else if (minus) { -n } else { n }\n go(b)\n }\n def nextDouble(): Double = next.toDouble\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1897, "cpu_time_ms": 670, "memory_kb": 39696}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s004137245", "group_id": "codeNet:p03381", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val X = List.fill(n)(sc.nextInt)\n val Xs = X.sorted\n val halfB = Xs(n / 2 - 1) // before\n val halfA = Xs(n / 2) // after\n\n for (i <- 0 until n) {\n if (X(i) <= halfB) {\n println(halfA)\n } else {\n println(halfB)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1524094941, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s004137245.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s004137245", "user_id": "u290193605"}, "prompt_components": {"gold_output": "4\n3\n3\n4\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val X = List.fill(n)(sc.nextInt)\n val Xs = X.sorted\n val halfB = Xs(n / 2 - 1) // before\n val halfA = Xs(n / 2) // after\n\n for (i <- 0 until n) {\n if (X(i) <= halfB) {\n println(halfA)\n } else {\n println(halfB)\n }\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 334, "cpu_time_ms": 2111, "memory_kb": 79976}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s144091099", "group_id": "codeNet:p03385", "input_text": "object Main{\n def main(args: Array[String]){\n val numlist = io.StdIn.readLine().split(\" \").map(_.toInt).toList\n val a = numlist(0)\n val b = numlist(1)\n val k = numlist(2)\n (a to b).foreach(i => if (i < a + k || i > b - k) println(i))\n }\n}", "language": "Scala", "metadata": {"date": 1528639394, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s144091099.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s144091099", "user_id": "u254128596"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main{\n def main(args: Array[String]){\n val numlist = io.StdIn.readLine().split(\" \").map(_.toInt).toList\n val a = numlist(0)\n val b = numlist(1)\n val k = numlist(2)\n (a to b).foreach(i => if (i < a + k || i > b - k) println(i))\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 279, "cpu_time_ms": 329, "memory_kb": 25412}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s631885262", "group_id": "codeNet:p03385", "input_text": "object Main{\n def main(args: Array[String]){\n val inputString = io.StdIn.readLine()\n if (inputString.exists(s => s == 'a') && inputString.exists(s => s == 'b') && inputString.exists(s=> s == 'c')) println(\"Yes\") else println(\"No\")\n }\n}", "language": "Scala", "metadata": {"date": 1528635823, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s631885262.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s631885262", "user_id": "u254128596"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main{\n def main(args: Array[String]){\n val inputString = io.StdIn.readLine()\n if (inputString.exists(s => s == 'a') && inputString.exists(s => s == 'b') && inputString.exists(s=> s == 'c')) println(\"Yes\") else println(\"No\")\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 255, "cpu_time_ms": 333, "memory_kb": 25488}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s290828846", "group_id": "codeNet:p03385", "input_text": "object Main extends App {\n\tval s = scala.io.StdIn.readLine.toList.toSet\n\n\tif(s == Set('a', 'b', 'c')){\n\t\tprintln(\"Yes\")\n\t}else{\n\t\tprintln(\"No\")\n\t}\n}", "language": "Scala", "metadata": {"date": 1523149694, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s290828846.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s290828846", "user_id": "u675876401"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n\tval s = scala.io.StdIn.readLine.toList.toSet\n\n\tif(s == Set('a', 'b', 'c')){\n\t\tprintln(\"Yes\")\n\t}else{\n\t\tprintln(\"No\")\n\t}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 148, "cpu_time_ms": 362, "memory_kb": 25560}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s840536359", "group_id": "codeNet:p03386", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n val Array(a, b, k) = StdIn.readLine().trim.split(\" \").map(_.toInt)\n val k1 = if(b - a <= k) b - a else k\n val result: Array[Int] = if(a != b) ((a until a + k1).map(i => i) ++ (b - k1 + 1 to b ).map(i => i)).toArray\n else Array(a)\n \n println(result.distinct.mkString(f\"%n\"))\n}", "language": "Scala", "metadata": {"date": 1523412893, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s840536359.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s840536359", "user_id": "u895032849"}, "prompt_components": {"gold_output": "3\n4\n7\n8\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n val Array(a, b, k) = StdIn.readLine().trim.split(\" \").map(_.toInt)\n val k1 = if(b - a <= k) b - a else k\n val result: Array[Int] = if(a != b) ((a until a + k1).map(i => i) ++ (b - k1 + 1 to b ).map(i => i)).toArray\n else Array(a)\n \n println(result.distinct.mkString(f\"%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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 329, "memory_kb": 25536}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s958984707", "group_id": "codeNet:p03387", "input_text": "object Main extends App {\n val Array(a,b,c) = readLine.split(\" \").map{_.toInt}\n \n if ((a+b)%2==0&&(b+c)%2==0&&(c+a)%2==0) {\n val Array(aa,bb,cc) = Array(a,b,c).sorted\n println((2*cc-aa-bb)/2)\n } else {\n val even = Array(a,b,c).filter{_%2==0}\n val odd = Array(a,b,c).filter{_%2==1}\n if (even.size==1) {\n val aa = even(0)\n val bb = odd(0)+1\n val cc = odd(1)+1\n val Array(aaa,bbb,ccc) = Array(aa,bb,cc).sorted\n println(1+(2*ccc-aaa-bbb)/2)\n } else {\n val aa = even(0) + 1\n val bb = even(1) + 1\n val cc = odd(0)\n val Array(aaa,bbb,ccc) = Array(aa,bb,cc).sorted\n println(1+(2*ccc-aaa-bbb)/2)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1577566605, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s958984707.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s958984707", "user_id": "u696665136"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n val Array(a,b,c) = readLine.split(\" \").map{_.toInt}\n \n if ((a+b)%2==0&&(b+c)%2==0&&(c+a)%2==0) {\n val Array(aa,bb,cc) = Array(a,b,c).sorted\n println((2*cc-aa-bb)/2)\n } else {\n val even = Array(a,b,c).filter{_%2==0}\n val odd = Array(a,b,c).filter{_%2==1}\n if (even.size==1) {\n val aa = even(0)\n val bb = odd(0)+1\n val cc = odd(1)+1\n val Array(aaa,bbb,ccc) = Array(aa,bb,cc).sorted\n println(1+(2*ccc-aaa-bbb)/2)\n } else {\n val aa = even(0) + 1\n val bb = even(1) + 1\n val cc = odd(0)\n val Array(aaa,bbb,ccc) = Array(aa,bb,cc).sorted\n println(1+(2*ccc-aaa-bbb)/2)\n }\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 329, "memory_kb": 25540}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s465839942", "group_id": "codeNet:p03387", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n val Array(min, mid, max) = StdIn.readLine().trim.split(\" \").map(_.toInt).sorted\n\n val x = if(((3*max) % 2) == (min + mid + max) % 2){\n max\n } else max + 1\n \n println((3*x - (min + mid + max)) / 2)\n}", "language": "Scala", "metadata": {"date": 1523417028, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s465839942.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s465839942", "user_id": "u895032849"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n val Array(min, mid, max) = StdIn.readLine().trim.split(\" \").map(_.toInt).sorted\n\n val x = if(((3*max) % 2) == (min + mid + max) % 2){\n max\n } else max + 1\n \n println((3*x - (min + mid + max)) / 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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 328, "memory_kb": 27188}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s559940848", "group_id": "codeNet:p03391", "input_text": "object Main extends App {\n\tval n = scala.io.StdIn.readInt\n\tval a = new Array[Long](n)\n\tvar bs = Long.MaxValue\n\n\tfor(i<-0 until n){\n\t\tval tp = scala.io.StdIn.readLine.split(\" \").map(_.toLong)\n\t\ta(i) = tp(0)\n\t\t\n\t\tif(tp(0) > tp(1)){\n\t\t\tbs = math.min(bs, tp(1))\n\t\t}\n\t}\n\n\tif(bs == Long.MaxValue){\n\t\tprintln(0)\n\t}else{\n\t\tprintln(a.sum - bs)\n\t}\n}", "language": "Scala", "metadata": {"date": 1523287238, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03391.html", "problem_id": "p03391", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03391/input.txt", "sample_output_relpath": "derived/input_output/data/p03391/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03391/Scala/s559940848.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s559940848", "user_id": "u675876401"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n\tval n = scala.io.StdIn.readInt\n\tval a = new Array[Long](n)\n\tvar bs = Long.MaxValue\n\n\tfor(i<-0 until n){\n\t\tval tp = scala.io.StdIn.readLine.split(\" \").map(_.toLong)\n\t\ta(i) = tp(0)\n\t\t\n\t\tif(tp(0) > tp(1)){\n\t\t\tbs = math.min(bs, tp(1))\n\t\t}\n\t}\n\n\tif(bs == Long.MaxValue){\n\t\tprintln(0)\n\t}else{\n\t\tprintln(a.sum - bs)\n\t}\n}", "problem_context": "Score : 700 points\n\nProblem Statement\n\nYou are given sequences A and B consisting of non-negative integers.\nThe lengths of both A and B are N, and the sums of the elements in A and B are equal.\nThe i-th element in A is A_i, and the i-th element in B is B_i.\n\nTozan and Gezan repeats the following sequence of operations:\n\nIf A and B are equal sequences, terminate the process.\n\nOtherwise, first Tozan chooses a positive element in A and decrease it by 1.\n\nThen, Gezan chooses a positive element in B and decrease it by 1.\n\nThen, give one candy to Takahashi, their pet.\n\nTozan wants the number of candies given to Takahashi until the process is terminated to be as large as possible, while Gezan wants it to be as small as possible.\nFind the number of candies given to Takahashi when both of them perform the operations optimally.\n\nConstraints\n\n1 \\leq N \\leq 2 × 10^5\n\n0 \\leq A_i,B_i \\leq 10^9(1\\leq i\\leq N)\n\nThe sums of the elements in A and B are equal.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the number of candies given to Takahashi when both Tozan and Gezan perform the operations optimally.\n\nSample Input 1\n\n2\n1 2\n3 2\n\nSample Output 1\n\n2\n\nWhen both Tozan and Gezan perform the operations optimally, the process will proceed as follows:\n\nTozan decreases A_1 by 1.\n\nGezan decreases B_1 by 1.\n\nOne candy is given to Takahashi.\n\nTozan decreases A_2 by 1.\n\nGezan decreases B_1 by 1.\n\nOne candy is given to Takahashi.\n\nAs A and B are equal, the process is terminated.\n\nSample Input 2\n\n3\n8 3\n0 1\n4 8\n\nSample Output 2\n\n9\n\nSample Input 3\n\n1\n1 1\n\nSample Output 3\n\n0", "sample_input": "2\n1 2\n3 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03391", "source_text": "Score : 700 points\n\nProblem Statement\n\nYou are given sequences A and B consisting of non-negative integers.\nThe lengths of both A and B are N, and the sums of the elements in A and B are equal.\nThe i-th element in A is A_i, and the i-th element in B is B_i.\n\nTozan and Gezan repeats the following sequence of operations:\n\nIf A and B are equal sequences, terminate the process.\n\nOtherwise, first Tozan chooses a positive element in A and decrease it by 1.\n\nThen, Gezan chooses a positive element in B and decrease it by 1.\n\nThen, give one candy to Takahashi, their pet.\n\nTozan wants the number of candies given to Takahashi until the process is terminated to be as large as possible, while Gezan wants it to be as small as possible.\nFind the number of candies given to Takahashi when both of them perform the operations optimally.\n\nConstraints\n\n1 \\leq N \\leq 2 × 10^5\n\n0 \\leq A_i,B_i \\leq 10^9(1\\leq i\\leq N)\n\nThe sums of the elements in A and B are equal.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the number of candies given to Takahashi when both Tozan and Gezan perform the operations optimally.\n\nSample Input 1\n\n2\n1 2\n3 2\n\nSample Output 1\n\n2\n\nWhen both Tozan and Gezan perform the operations optimally, the process will proceed as follows:\n\nTozan decreases A_1 by 1.\n\nGezan decreases B_1 by 1.\n\nOne candy is given to Takahashi.\n\nTozan decreases A_2 by 1.\n\nGezan decreases B_1 by 1.\n\nOne candy is given to Takahashi.\n\nAs A and B are equal, the process is terminated.\n\nSample Input 2\n\n3\n8 3\n0 1\n4 8\n\nSample Output 2\n\n9\n\nSample Input 3\n\n1\n1 1\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 718, "memory_kb": 39972}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s256282835", "group_id": "codeNet:p03399", "input_text": "import java.util.Scanner\n\nimport scala.collection.Searching._\nimport scala.annotation.tailrec\nimport scala.collection.immutable.{NumericRange, Queue}\nimport scala.collection.mutable\nimport scala.io.StdIn.readLine\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(new Node(None, 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n @tailrec\n private def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) => root(p)\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n println(math.min(sc.nextInt, sc.nextInt) + math.min(sc.nextInt, sc.nextInt))\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}", "language": "Scala", "metadata": {"date": 1522073599, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s256282835.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s256282835", "user_id": "u779353743"}, "prompt_components": {"gold_output": "520\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.collection.Searching._\nimport scala.annotation.tailrec\nimport scala.collection.immutable.{NumericRange, Queue}\nimport scala.collection.mutable\nimport scala.io.StdIn.readLine\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(new Node(None, 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n @tailrec\n private def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) => root(p)\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n println(math.min(sc.nextInt, sc.nextInt) + math.min(sc.nextInt, sc.nextInt))\n }\n\n def gcd(i: Long, j: Long): Long = {\n if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1383, "cpu_time_ms": 346, "memory_kb": 25528}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s447034424", "group_id": "codeNet:p03401", "input_text": "object Main extends App {\n import scala.math.abs\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n var A: Array[Int] = Array.fill(n)(sc.nextInt)\n A = 0 +: A :+ 0\n // 全経路いった場合を計算\n var total = 0\n for (i <- 1 to n + 1) {\n total += abs(A(i) - A(i - 1))\n }\n println(total)\n println()\n\n // 端折る箇所がi-1 i+1の間だった場合は全経路いった場合と同じ、違った場合はi と i-1の絶対値の2倍の額を合計から引く\n for (i <- 1 to n) {\n val before = A(i - 1)\n val after = A(i + 1)\n\n println(total - abs(A(i) - before) - abs(after - A(i)) + abs(after - before))\n }\n }", "language": "Scala", "metadata": {"date": 1522814945, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03401.html", "problem_id": "p03401", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03401/input.txt", "sample_output_relpath": "derived/input_output/data/p03401/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03401/Scala/s447034424.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s447034424", "user_id": "u290193605"}, "prompt_components": {"gold_output": "12\n8\n10\n", "input_to_evaluate": "object Main extends App {\n import scala.math.abs\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n var A: Array[Int] = Array.fill(n)(sc.nextInt)\n A = 0 +: A :+ 0\n // 全経路いった場合を計算\n var total = 0\n for (i <- 1 to n + 1) {\n total += abs(A(i) - A(i - 1))\n }\n println(total)\n println()\n\n // 端折る箇所がi-1 i+1の間だった場合は全経路いった場合と同じ、違った場合はi と i-1の絶対値の2倍の額を合計から引く\n for (i <- 1 to n) {\n val before = A(i - 1)\n val after = A(i + 1)\n\n println(total - abs(A(i) - before) - abs(after - A(i)) + abs(after - before))\n }\n }", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N sightseeing spots on the x-axis, numbered 1, 2, ..., N.\nSpot i is at the point with coordinate A_i.\nIt costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis.\n\nYou planned a trip along the axis.\nIn this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0.\n\nHowever, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i.\nYou will visit the remaining spots as planned in the order they are numbered.\nYou will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned.\n\nFor each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n-5000 \\leq A_i \\leq 5000 (1 \\leq i \\leq N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint N lines.\nIn the i-th line, print the total cost of travel during the trip when the visit to Spot i is canceled.\n\nSample Input 1\n\n3\n3 5 -1\n\nSample Output 1\n\n12\n8\n10\n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit to Spot i is canceled, are as follows:\n\nFor i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n\nFor i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n\nFor i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\nSample Input 2\n\n5\n1 1 1 2 0\n\nSample Output 2\n\n4\n4\n4\n2\n4\n\nSample Input 3\n\n6\n-679 -2409 -3258 3095 -3291 -4462\n\nSample Output 3\n\n21630\n21630\n19932\n8924\n21630\n19288", "sample_input": "3\n3 5 -1\n"}, "reference_outputs": ["12\n8\n10\n"], "source_document_id": "p03401", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N sightseeing spots on the x-axis, numbered 1, 2, ..., N.\nSpot i is at the point with coordinate A_i.\nIt costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis.\n\nYou planned a trip along the axis.\nIn this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0.\n\nHowever, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i.\nYou will visit the remaining spots as planned in the order they are numbered.\nYou will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned.\n\nFor each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n-5000 \\leq A_i \\leq 5000 (1 \\leq i \\leq N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint N lines.\nIn the i-th line, print the total cost of travel during the trip when the visit to Spot i is canceled.\n\nSample Input 1\n\n3\n3 5 -1\n\nSample Output 1\n\n12\n8\n10\n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit to Spot i is canceled, are as follows:\n\nFor i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n\nFor i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n\nFor i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\nSample Input 2\n\n5\n1 1 1 2 0\n\nSample Output 2\n\n4\n4\n4\n2\n4\n\nSample Input 3\n\n6\n-679 -2409 -3258 3095 -3291 -4462\n\nSample Output 3\n\n21630\n21630\n19932\n8924\n21630\n19288", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 658, "cpu_time_ms": 1325, "memory_kb": 66512}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s045434887", "group_id": "codeNet:p03415", "input_text": "import scala.io._\nobject Main{\n def main(args: Array[String]) {\n val input = Source.fromInputStream(System.in)\n val lines = input.getLines.toSeq\n println(lines(0)(0)+lines(1)(1)+lines(2)(2))\n }\n}", "language": "Scala", "metadata": {"date": 1522129244, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s045434887.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s045434887", "user_id": "u308445996"}, "prompt_components": {"gold_output": "abc\n", "input_to_evaluate": "import scala.io._\nobject Main{\n def main(args: Array[String]) {\n val input = Source.fromInputStream(System.in)\n val lines = input.getLines.toSeq\n println(lines(0)(0)+lines(1)(1)+lines(2)(2))\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 326, "memory_kb": 27324}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s298356824", "group_id": "codeNet:p03416", "input_text": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val Array(a, b) = in.readLine.split(\" \").map(_.toInt)\n\n def check(i:Int):Boolean = {\n val s = String.valueOf(i)\n s(0) == s(4) && s(1) == s(3)\n }\n val ans = (a to b).map(check).count(_ == true)\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1555112656, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s298356824.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s298356824", "user_id": "u217010036"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val Array(a, b) = in.readLine.split(\" \").map(_.toInt)\n\n def check(i:Int):Boolean = {\n val s = String.valueOf(i)\n s(0) == s(4) && s(1) == s(3)\n }\n val ans = (a to b).map(check).count(_ == true)\n println(ans)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 470, "memory_kb": 33588}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s608125824", "group_id": "codeNet:p03416", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n val Array(n, m) = StdIn.readLine.split(\" \").map(_.toInt)\n\n val ans = (n to m).count(i => {\n ( i / 10000) == (i % 10) && (i / 1000 % 10) == (i / 10 % 10)\n })\n\n println(ans)\n}\n", "language": "Scala", "metadata": {"date": 1542761001, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s608125824.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s608125824", "user_id": "u217010036"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n val Array(n, m) = StdIn.readLine.split(\" \").map(_.toInt)\n\n val ans = (n to m).count(i => {\n ( i / 10000) == (i % 10) && (i / 1000 % 10) == (i / 10 % 10)\n })\n\n println(ans)\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 356, "memory_kb": 29656}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s168972883", "group_id": "codeNet:p03416", "input_text": "object Main extends App {\n\tval ab = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\n\tval a1 = List(1,2,3,4,5,6,7,8,9)\n\tval a2 = List(0,1,2,3,4,5,6,7,8,9)\n\tval a3 = List(0,1,2,3,4,5,6,7,8,9)\n\n\tvar cnt = Set[Int]()\n\n\tfor(x <- a1){\n\t\tval temp = x + 10*x + 100*x + 1000*x + 10000*x\n\t\tif(ab(0) <= temp && temp <= ab(1)){\n\t\t\tcnt = cnt + temp\n\t\t}\n\t}\n\n\tfor(x <- a1){\n\t\tfor(y <- a2){\n\t\t\tval t1 = 10000*x + 1000*x + 100*y + 10*x + x\n\t\t\tval t2 = 10000*x + 1000*y + 100*y + 10*y + x\n\n\t\t\tif(ab(0) <= t1 && t1 <= ab(1)){\n\t\t\t\tcnt = cnt + t1\n\t\t\t}\n\t\t\tif(ab(0) <= t2 && t2 <= ab(1)){\n\t\t\t\tcnt = cnt + t2\n\t\t\t}\n\n\t\t\tfor(z <- a3){\n\t\t\t\tval t3 = 10000*x + 1000*y + 100*z + 10*y + x\n\t\t\t\tif(ab(0) <= t3 && t3 <= ab(1)){\n\t\t\t\t\tcnt = cnt + t3\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprintln(cnt.size)\n}", "language": "Scala", "metadata": {"date": 1521924774, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s168972883.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s168972883", "user_id": "u675876401"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "object Main extends App {\n\tval ab = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\n\tval a1 = List(1,2,3,4,5,6,7,8,9)\n\tval a2 = List(0,1,2,3,4,5,6,7,8,9)\n\tval a3 = List(0,1,2,3,4,5,6,7,8,9)\n\n\tvar cnt = Set[Int]()\n\n\tfor(x <- a1){\n\t\tval temp = x + 10*x + 100*x + 1000*x + 10000*x\n\t\tif(ab(0) <= temp && temp <= ab(1)){\n\t\t\tcnt = cnt + temp\n\t\t}\n\t}\n\n\tfor(x <- a1){\n\t\tfor(y <- a2){\n\t\t\tval t1 = 10000*x + 1000*x + 100*y + 10*x + x\n\t\t\tval t2 = 10000*x + 1000*y + 100*y + 10*y + x\n\n\t\t\tif(ab(0) <= t1 && t1 <= ab(1)){\n\t\t\t\tcnt = cnt + t1\n\t\t\t}\n\t\t\tif(ab(0) <= t2 && t2 <= ab(1)){\n\t\t\t\tcnt = cnt + t2\n\t\t\t}\n\n\t\t\tfor(z <- a3){\n\t\t\t\tval t3 = 10000*x + 1000*y + 100*z + 10*y + x\n\t\t\t\tif(ab(0) <= t3 && t3 <= ab(1)){\n\t\t\t\t\tcnt = cnt + t3\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprintln(cnt.size)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 753, "cpu_time_ms": 336, "memory_kb": 27324}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s668252118", "group_id": "codeNet:p03425", "input_text": "import scala.io.StdIn\nobject Main extends App {\n \n val n = StdIn.readLine().toInt\n val linse = (0 until n).map(_ => StdIn.readLine())\n \n val combis = List('M','A','R','C','H').combinations(3)\n\n val members = linse.filter{p =>\n p.charAt(0) == 'M' || p.charAt(0) == 'A' || p.charAt(0) == 'R' || p.charAt(0) == 'C' || p.charAt(0) == 'H'\n }.groupBy(name => name.charAt(0)).map(a => a._1 -> a._2.size)\n\n //val combi = members.keys.toList.combinations(3)\n //println(combi.mkString(\" \"))\n\n val result = combis.foldLeft(0L){ (acc, l) =>\n acc + (members.get(l(0)).getOrElse(0).toLong * \n members.get(l(1)).getOrElse(0).toLong * members.get(l(2)).getOrElse(0).toLong)\n }\n\n println(result)\n\n}", "language": "Scala", "metadata": {"date": 1526164605, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03425.html", "problem_id": "p03425", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03425/input.txt", "sample_output_relpath": "derived/input_output/data/p03425/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03425/Scala/s668252118.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s668252118", "user_id": "u895032849"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.io.StdIn\nobject Main extends App {\n \n val n = StdIn.readLine().toInt\n val linse = (0 until n).map(_ => StdIn.readLine())\n \n val combis = List('M','A','R','C','H').combinations(3)\n\n val members = linse.filter{p =>\n p.charAt(0) == 'M' || p.charAt(0) == 'A' || p.charAt(0) == 'R' || p.charAt(0) == 'C' || p.charAt(0) == 'H'\n }.groupBy(name => name.charAt(0)).map(a => a._1 -> a._2.size)\n\n //val combi = members.keys.toList.combinations(3)\n //println(combi.mkString(\" \"))\n\n val result = combis.foldLeft(0L){ (acc, l) =>\n acc + (members.get(l(0)).getOrElse(0).toLong * \n members.get(l(1)).getOrElse(0).toLong * members.get(l(2)).getOrElse(0).toLong)\n }\n\n println(result)\n\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N people. The name of the i-th person is S_i.\n\nWe would like to choose three people so that the following conditions are met:\n\nThe name of every chosen person begins with M, A, R, C or H.\n\nThere are no multiple people whose names begin with the same letter.\n\nHow many such ways are there to choose three people, disregarding order?\n\nNote that the answer may not fit into a 32-bit integer type.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nS_i consists of uppercase English letters.\n\n1 \\leq |S_i| \\leq 10\n\nS_i \\neq S_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nIf there are x ways to choose three people so that the given conditions are met, print x.\n\nSample Input 1\n\n5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI\n\nSample Output 1\n\n2\n\nWe can choose three people with the following names:\n\nMASHIKE, RUMOI, HABORO\n\nMASHIKE, RUMOI, HOROKANAI\n\nThus, we have two ways.\n\nSample Input 2\n\n4\nZZ\nZZZ\nZ\nZZZZZZZZZZ\n\nSample Output 2\n\n0\n\nNote that there may be no ways to choose three people so that the given conditions are met.\n\nSample Input 3\n\n5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO\n\nSample Output 3\n\n7", "sample_input": "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03425", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N people. The name of the i-th person is S_i.\n\nWe would like to choose three people so that the following conditions are met:\n\nThe name of every chosen person begins with M, A, R, C or H.\n\nThere are no multiple people whose names begin with the same letter.\n\nHow many such ways are there to choose three people, disregarding order?\n\nNote that the answer may not fit into a 32-bit integer type.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nS_i consists of uppercase English letters.\n\n1 \\leq |S_i| \\leq 10\n\nS_i \\neq S_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nIf there are x ways to choose three people so that the given conditions are met, print x.\n\nSample Input 1\n\n5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI\n\nSample Output 1\n\n2\n\nWe can choose three people with the following names:\n\nMASHIKE, RUMOI, HABORO\n\nMASHIKE, RUMOI, HOROKANAI\n\nThus, we have two ways.\n\nSample Input 2\n\n4\nZZ\nZZZ\nZ\nZZZZZZZZZZ\n\nSample Output 2\n\n0\n\nNote that there may be no ways to choose three people so that the given conditions are met.\n\nSample Input 3\n\n5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO\n\nSample Output 3\n\n7", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 614, "memory_kb": 41756}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s110200882", "group_id": "codeNet:p03425", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n\n val n = StdIn.readLine().toInt\n val linse = (0 until n).map(_ => StdIn.readLine())\n \n val combis = \"MARCH\".split(\"\").combinations(3).map(p => p.toList.map(_.charAt(0)))\n //println(combis.mkString(\" \"))\n\n val members = linse.filter{p =>\n p.charAt(0) == 'M' || p.charAt(0) == 'A' || p.charAt(0) == 'R' || p.charAt(0) == 'C' || p.charAt(0) == 'H'\n }.groupBy(name => name.charAt(0)).map(a => a._1 -> a._2.size)\n\n //val combi = members.keys.toList.combinations(3)\n //println(combi.mkString(\" \"))\n\n val result = combis.foldLeft(0L){ (acc, l) =>\n acc + (members.get(l(0)).getOrElse(0).toLong * \n members.get(l(1)).getOrElse(0).toLong * members.get(l(2)).getOrElse(0).toLong)\n }\n\n println(result)\n}", "language": "Scala", "metadata": {"date": 1526164182, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03425.html", "problem_id": "p03425", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03425/input.txt", "sample_output_relpath": "derived/input_output/data/p03425/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03425/Scala/s110200882.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s110200882", "user_id": "u895032849"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n\n val n = StdIn.readLine().toInt\n val linse = (0 until n).map(_ => StdIn.readLine())\n \n val combis = \"MARCH\".split(\"\").combinations(3).map(p => p.toList.map(_.charAt(0)))\n //println(combis.mkString(\" \"))\n\n val members = linse.filter{p =>\n p.charAt(0) == 'M' || p.charAt(0) == 'A' || p.charAt(0) == 'R' || p.charAt(0) == 'C' || p.charAt(0) == 'H'\n }.groupBy(name => name.charAt(0)).map(a => a._1 -> a._2.size)\n\n //val combi = members.keys.toList.combinations(3)\n //println(combi.mkString(\" \"))\n\n val result = combis.foldLeft(0L){ (acc, l) =>\n acc + (members.get(l(0)).getOrElse(0).toLong * \n members.get(l(1)).getOrElse(0).toLong * members.get(l(2)).getOrElse(0).toLong)\n }\n\n println(result)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N people. The name of the i-th person is S_i.\n\nWe would like to choose three people so that the following conditions are met:\n\nThe name of every chosen person begins with M, A, R, C or H.\n\nThere are no multiple people whose names begin with the same letter.\n\nHow many such ways are there to choose three people, disregarding order?\n\nNote that the answer may not fit into a 32-bit integer type.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nS_i consists of uppercase English letters.\n\n1 \\leq |S_i| \\leq 10\n\nS_i \\neq S_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nIf there are x ways to choose three people so that the given conditions are met, print x.\n\nSample Input 1\n\n5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI\n\nSample Output 1\n\n2\n\nWe can choose three people with the following names:\n\nMASHIKE, RUMOI, HABORO\n\nMASHIKE, RUMOI, HOROKANAI\n\nThus, we have two ways.\n\nSample Input 2\n\n4\nZZ\nZZZ\nZ\nZZZZZZZZZZ\n\nSample Output 2\n\n0\n\nNote that there may be no ways to choose three people so that the given conditions are met.\n\nSample Input 3\n\n5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO\n\nSample Output 3\n\n7", "sample_input": "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03425", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N people. The name of the i-th person is S_i.\n\nWe would like to choose three people so that the following conditions are met:\n\nThe name of every chosen person begins with M, A, R, C or H.\n\nThere are no multiple people whose names begin with the same letter.\n\nHow many such ways are there to choose three people, disregarding order?\n\nNote that the answer may not fit into a 32-bit integer type.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nS_i consists of uppercase English letters.\n\n1 \\leq |S_i| \\leq 10\n\nS_i \\neq S_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nIf there are x ways to choose three people so that the given conditions are met, print x.\n\nSample Input 1\n\n5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI\n\nSample Output 1\n\n2\n\nWe can choose three people with the following names:\n\nMASHIKE, RUMOI, HABORO\n\nMASHIKE, RUMOI, HOROKANAI\n\nThus, we have two ways.\n\nSample Input 2\n\n4\nZZ\nZZZ\nZ\nZZZZZZZZZZ\n\nSample Output 2\n\n0\n\nNote that there may be no ways to choose three people so that the given conditions are met.\n\nSample Input 3\n\n5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO\n\nSample Output 3\n\n7", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 606, "memory_kb": 42036}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s915706691", "group_id": "codeNet:p03426", "input_text": "object Main extends App {\n val sr = new StdinReader\n val h, w, d = sr.nextInt\n val table: Map[Int, (Int, Int)] = (for {\n y <- 0 until h\n x <- 0 until w\n } yield sr.nextInt -> (x, y)).toMap\n\n val tbl = new Array[Int](h * w + 1)\n (1 to d).flatMap{dd =>\n ((dd + d) to (h * w) by d).map {p => \n val lPos = table(p - d)\n val rPos = table(p)\n val mp = Math.abs(lPos._1 - rPos._1) + Math.abs(lPos._2 - rPos._2)\n tbl(p) = mp + tbl(p - d)\n }\n }\n\n println(\n (1 to sr.nextInt).map{i =>\n val l, r = sr.nextInt\n tbl(r) - tbl(l)\n }.mkString(\"\\n\"))\n\n\nclass StdinReader {\n val is = System.in\n val buffer = new Array[Byte](1024 * 1024)\n var size = 0\n var pos = 0\n\n private def readByte: Byte = {\n if (pos >= size) {\n pos = 0;\n size = is.read(buffer);\n }\n if (size < 0) -1\n else {\n val ret = buffer(pos)\n pos += 1\n ret\n }\n }\n\n // support single byte char only\n def next: String = {\n val sb = new StringBuilder\n var reading = false\n var completed = false\n while(!completed) {\n val b = readByte\n\n if ('!' <= b && b <= '~') {\n sb.append(b.asInstanceOf[Char])\n reading = true\n } else {\n if (reading) completed = true\n }\n }\n sb.toString\n }\n\n def nextInt: Int = {\n var i = 0\n var reading = false\n var completed = false\n while(!completed) {\n val b = readByte\n\n if (b == '-') {\n reading = true\n i *= -1\n } else if ('0' <= b && b <= '9') {\n reading = true\n i = i * 10 + (b - '0')\n } else if (reading) completed = true\n }\n i\n }\n}\n}", "language": "Scala", "metadata": {"date": 1522257359, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s915706691.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s915706691", "user_id": "u132324749"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "object Main extends App {\n val sr = new StdinReader\n val h, w, d = sr.nextInt\n val table: Map[Int, (Int, Int)] = (for {\n y <- 0 until h\n x <- 0 until w\n } yield sr.nextInt -> (x, y)).toMap\n\n val tbl = new Array[Int](h * w + 1)\n (1 to d).flatMap{dd =>\n ((dd + d) to (h * w) by d).map {p => \n val lPos = table(p - d)\n val rPos = table(p)\n val mp = Math.abs(lPos._1 - rPos._1) + Math.abs(lPos._2 - rPos._2)\n tbl(p) = mp + tbl(p - d)\n }\n }\n\n println(\n (1 to sr.nextInt).map{i =>\n val l, r = sr.nextInt\n tbl(r) - tbl(l)\n }.mkString(\"\\n\"))\n\n\nclass StdinReader {\n val is = System.in\n val buffer = new Array[Byte](1024 * 1024)\n var size = 0\n var pos = 0\n\n private def readByte: Byte = {\n if (pos >= size) {\n pos = 0;\n size = is.read(buffer);\n }\n if (size < 0) -1\n else {\n val ret = buffer(pos)\n pos += 1\n ret\n }\n }\n\n // support single byte char only\n def next: String = {\n val sb = new StringBuilder\n var reading = false\n var completed = false\n while(!completed) {\n val b = readByte\n\n if ('!' <= b && b <= '~') {\n sb.append(b.asInstanceOf[Char])\n reading = true\n } else {\n if (reading) completed = true\n }\n }\n sb.toString\n }\n\n def nextInt: Int = {\n var i = 0\n var reading = false\n var completed = false\n while(!completed) {\n val b = readByte\n\n if (b == '-') {\n reading = true\n i *= -1\n } else if ('0' <= b && b <= '9') {\n reading = true\n i = i * 10 + (b - '0')\n } else if (reading) completed = true\n }\n i\n }\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1647, "cpu_time_ms": 1091, "memory_kb": 80768}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s694689236", "group_id": "codeNet:p03433", "input_text": "import scala.io.StdIn\nobject Main extends App {\n val N = StdIn.readLine().toInt\n val A = StdIn.readLine().toInt\n println(if ((N % 500) <= A) \"Yes\" else \"No\")\n}\n", "language": "Scala", "metadata": {"date": 1566166200, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03433.html", "problem_id": "p03433", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03433/input.txt", "sample_output_relpath": "derived/input_output/data/p03433/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03433/Scala/s694689236.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s694689236", "user_id": "u407005073"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.io.StdIn\nobject Main extends App {\n val N = StdIn.readLine().toInt\n val A = StdIn.readLine().toInt\n println(if ((N % 500) <= A) \"Yes\" else \"No\")\n}\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nE869120 has A 1-yen coins and infinitely many 500-yen coins.\n\nDetermine if he can pay exactly N yen using only these coins.\n\nConstraints\n\nN is an integer between 1 and 10000 (inclusive).\n\nA is an integer between 0 and 1000 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\n\nOutput\n\nIf E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print Yes; otherwise, print No.\n\nSample Input 1\n\n2018\n218\n\nSample Output 1\n\nYes\n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer is Yes.\n\nSample Input 2\n\n2763\n0\n\nSample Output 2\n\nNo\n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only 500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\nSample Input 3\n\n37\n514\n\nSample Output 3\n\nYes", "sample_input": "2018\n218\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03433", "source_text": "Score: 100 points\n\nProblem Statement\n\nE869120 has A 1-yen coins and infinitely many 500-yen coins.\n\nDetermine if he can pay exactly N yen using only these coins.\n\nConstraints\n\nN is an integer between 1 and 10000 (inclusive).\n\nA is an integer between 0 and 1000 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\n\nOutput\n\nIf E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print Yes; otherwise, print No.\n\nSample Input 1\n\n2018\n218\n\nSample Output 1\n\nYes\n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer is Yes.\n\nSample Input 2\n\n2763\n0\n\nSample Output 2\n\nNo\n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only 500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\nSample Input 3\n\n37\n514\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 328, "memory_kb": 25428}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s083436475", "group_id": "codeNet:p03433", "input_text": "object Main extends App{\n val n = scala.io.StdIn.readInt\n val a = scala.io.StdIn.readInt\n \n \t val b = n%500\n\n val ans = if((a-b)>= 0){\n \"Yes\"\n }else{\n \"No\"\n }\n println(ans)\n }\n \n", "language": "Scala", "metadata": {"date": 1560453260, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03433.html", "problem_id": "p03433", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03433/input.txt", "sample_output_relpath": "derived/input_output/data/p03433/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03433/Scala/s083436475.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s083436475", "user_id": "u440413862"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App{\n val n = scala.io.StdIn.readInt\n val a = scala.io.StdIn.readInt\n \n \t val b = n%500\n\n val ans = if((a-b)>= 0){\n \"Yes\"\n }else{\n \"No\"\n }\n println(ans)\n }\n \n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nE869120 has A 1-yen coins and infinitely many 500-yen coins.\n\nDetermine if he can pay exactly N yen using only these coins.\n\nConstraints\n\nN is an integer between 1 and 10000 (inclusive).\n\nA is an integer between 0 and 1000 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\n\nOutput\n\nIf E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print Yes; otherwise, print No.\n\nSample Input 1\n\n2018\n218\n\nSample Output 1\n\nYes\n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer is Yes.\n\nSample Input 2\n\n2763\n0\n\nSample Output 2\n\nNo\n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only 500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\nSample Input 3\n\n37\n514\n\nSample Output 3\n\nYes", "sample_input": "2018\n218\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03433", "source_text": "Score: 100 points\n\nProblem Statement\n\nE869120 has A 1-yen coins and infinitely many 500-yen coins.\n\nDetermine if he can pay exactly N yen using only these coins.\n\nConstraints\n\nN is an integer between 1 and 10000 (inclusive).\n\nA is an integer between 0 and 1000 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\n\nOutput\n\nIf E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print Yes; otherwise, print No.\n\nSample Input 1\n\n2018\n218\n\nSample Output 1\n\nYes\n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer is Yes.\n\nSample Input 2\n\n2763\n0\n\nSample Output 2\n\nNo\n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only 500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\nSample Input 3\n\n37\n514\n\nSample Output 3\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 258, "cpu_time_ms": 329, "memory_kb": 25512}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s730622533", "group_id": "codeNet:p03434", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val N = sc.nextInt()\n val a = List.fill(N)(sc.nextInt())\n\n println(calc(N, a))\n\n def calc(N: Int, a: List[Int]) : Int = {\n a.sorted.foldLeft(0)((alice, bob) => bob - alice)\n }\n}\n", "language": "Scala", "metadata": {"date": 1598835587, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03434.html", "problem_id": "p03434", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03434/input.txt", "sample_output_relpath": "derived/input_output/data/p03434/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03434/Scala/s730622533.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s730622533", "user_id": "u876157995"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val N = sc.nextInt()\n val a = List.fill(N)(sc.nextInt())\n\n println(calc(N, a))\n\n def calc(N: Int, a: List[Int]) : Int = {\n a.sorted.foldLeft(0)((alice, bob) => bob - alice)\n }\n}\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nWe have N cards. A number a_i is written on the i-th card.\n\nAlice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first.\n\nThe game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.\n\nConstraints\n\nN is an integer between 1 and 100 (inclusive).\n\na_i \\ (1 \\leq i \\leq N) is an integer between 1 and 100 (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 Alice's score minus Bob's score when both players take the optimal strategy to maximize their scores.\n\nSample Input 1\n\n2\n3 1\n\nSample Output 1\n\n2\n\nFirst, Alice will take the card with 3. Then, Bob will take the card with 1.\nThe difference of their scores will be 3 - 1 = 2.\n\nSample Input 2\n\n3\n2 7 4\n\nSample Output 2\n\n5\n\nFirst, Alice will take the card with 7. Then, Bob will take the card with 4. Lastly, Alice will take the card with 2. The difference of their scores will be 7 - 4 + 2 = 5. The difference of their scores will be 3 - 1 = 2.\n\nSample Input 3\n\n4\n20 18 2 18\n\nSample Output 3\n\n18", "sample_input": "2\n3 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03434", "source_text": "Score: 200 points\n\nProblem Statement\n\nWe have N cards. A number a_i is written on the i-th card.\n\nAlice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first.\n\nThe game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.\n\nConstraints\n\nN is an integer between 1 and 100 (inclusive).\n\na_i \\ (1 \\leq i \\leq N) is an integer between 1 and 100 (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 Alice's score minus Bob's score when both players take the optimal strategy to maximize their scores.\n\nSample Input 1\n\n2\n3 1\n\nSample Output 1\n\n2\n\nFirst, Alice will take the card with 3. Then, Bob will take the card with 1.\nThe difference of their scores will be 3 - 1 = 2.\n\nSample Input 2\n\n3\n2 7 4\n\nSample Output 2\n\n5\n\nFirst, Alice will take the card with 7. Then, Bob will take the card with 4. Lastly, Alice will take the card with 2. The difference of their scores will be 7 - 4 + 2 = 5. The difference of their scores will be 3 - 1 = 2.\n\nSample Input 3\n\n4\n20 18 2 18\n\nSample Output 3\n\n18", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 500, "memory_kb": 55548}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s930699618", "group_id": "codeNet:p03434", "input_text": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val n = sc.nextInt()\n val as = List.fill(n)(sc.nextInt())\n val ass = as.sorted.reverse\n var ans = 0\n for (i <- ass.indices) {\n if (i % 2 == 0) {\n ans += ass(i)\n } else {\n ans -= ass(i)\n }\n }\n\n println(ans)\n }\n}\n", "language": "Scala", "metadata": {"date": 1587758656, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03434.html", "problem_id": "p03434", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03434/input.txt", "sample_output_relpath": "derived/input_output/data/p03434/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03434/Scala/s930699618.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s930699618", "user_id": "u336949031"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val n = sc.nextInt()\n val as = List.fill(n)(sc.nextInt())\n val ass = as.sorted.reverse\n var ans = 0\n for (i <- ass.indices) {\n if (i % 2 == 0) {\n ans += ass(i)\n } else {\n ans -= ass(i)\n }\n }\n\n println(ans)\n }\n}\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nWe have N cards. A number a_i is written on the i-th card.\n\nAlice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first.\n\nThe game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.\n\nConstraints\n\nN is an integer between 1 and 100 (inclusive).\n\na_i \\ (1 \\leq i \\leq N) is an integer between 1 and 100 (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 Alice's score minus Bob's score when both players take the optimal strategy to maximize their scores.\n\nSample Input 1\n\n2\n3 1\n\nSample Output 1\n\n2\n\nFirst, Alice will take the card with 3. Then, Bob will take the card with 1.\nThe difference of their scores will be 3 - 1 = 2.\n\nSample Input 2\n\n3\n2 7 4\n\nSample Output 2\n\n5\n\nFirst, Alice will take the card with 7. Then, Bob will take the card with 4. Lastly, Alice will take the card with 2. The difference of their scores will be 7 - 4 + 2 = 5. The difference of their scores will be 3 - 1 = 2.\n\nSample Input 3\n\n4\n20 18 2 18\n\nSample Output 3\n\n18", "sample_input": "2\n3 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03434", "source_text": "Score: 200 points\n\nProblem Statement\n\nWe have N cards. A number a_i is written on the i-th card.\n\nAlice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first.\n\nThe game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.\n\nConstraints\n\nN is an integer between 1 and 100 (inclusive).\n\na_i \\ (1 \\leq i \\leq N) is an integer between 1 and 100 (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 Alice's score minus Bob's score when both players take the optimal strategy to maximize their scores.\n\nSample Input 1\n\n2\n3 1\n\nSample Output 1\n\n2\n\nFirst, Alice will take the card with 3. Then, Bob will take the card with 1.\nThe difference of their scores will be 3 - 1 = 2.\n\nSample Input 2\n\n3\n2 7 4\n\nSample Output 2\n\n5\n\nFirst, Alice will take the card with 7. Then, Bob will take the card with 4. Lastly, Alice will take the card with 2. The difference of their scores will be 7 - 4 + 2 = 5. The difference of their scores will be 3 - 1 = 2.\n\nSample Input 3\n\n4\n20 18 2 18\n\nSample Output 3\n\n18", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 351, "memory_kb": 25668}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s442749377", "group_id": "codeNet:p03436", "input_text": "object Main extends App {\n\tprivate val Empty = Int.MaxValue - 1\n\tprivate val Wall = Int.MaxValue\n\n\tprivate def pre(inputs: Seq[String]) = {\n\t\tval g = inputs.head.split(' ').map(_.toInt)\n\t\tval total = g(0) * g(1)\n\t\tval w = inputs.map(_.count(_ == '#')).sum //TODO '.'に変えてみる?\n\t\tval min = solve(inputs)\n\t\tval ret = total - w - min - 1\n\t\t//assert(0 <= ret) //FIXME RE\n\t\tassert(-1 != ret) //FIXME RE\n\n\t\t//assert(ret < Empty)\n\t\tret\n\t}\n\n\tprivate def solve(inputs: Seq[String]) = {\n\t\tval g = inputs.head.split(' ').map(_.toInt)\n\t\tval sy = 1\n\t\tval sx = 1\n\t\tval gy = g(0)\n\t\tval gx = g(1)\n\t\tval ffff = inputs.tail.map(_.toCharArray.map(e => if (e == '#') Wall else Empty).toArray).toArray\n\t\tval fff = ffff.map(Wall +: _ :+ Wall)\n\t\tval wall = fff(0).map(_ => Wall)\n\t\tval f = wall +: fff :+ wall\n\n\t\tval q = scala.collection.mutable.Queue[(Int, Int)]()\n\t\tq.enqueue((sx, sy))\n\t\tf(sy)(sx) = -1\n\t\tdo {\n\t\t\tval (ny, nx) = q.dequeue()\n\t\t\tif (f(ny)(nx) == -1 || f(ny)(nx) == Empty) {\n\t\t\t\t//f.foreach(e => println(e.toSeq.filterNot(_ == Empty)))\n\n\t\t\t\tf(ny)(nx) = 1 + Math.min(f(ny)(nx),\n\t\t\t\t\tMath.min(\n\t\t\t\t\t\tMath.min(f(ny - 1)(nx), f(ny + 1)(nx)),\n\t\t\t\t\t\tMath.min(f(ny)(nx - 1), f(ny)(nx + 1))))\n\n\t\t\t\tq.enqueue((ny - 1, nx))\n\t\t\t\tq.enqueue((ny + 1, nx))\n\t\t\t\tq.enqueue((ny, nx - 1))\n\t\t\t\tq.enqueue((ny, nx + 1))\n\n\t\t\t\tif (nx == gx && ny == gy) q.clear()\n\t\t\t}\n\t\t} while (q.nonEmpty)\n\n\t\t//print(\"done\")\n\t\tf(gy)(gx)\n\t}\n\n\tprivate val s1 =\n\t\t\"\"\"3 3\n\t\t\t|..#\n\t\t\t|#..\n\t\t\t|...\n\t\t\t|\"\"\".stripMargin.split(\"\\r\\n\")\n\tprivate val s2 =\n\t\t\"\"\"10 37\n\t\t\t|.....................................\n\t\t\t|...#...####...####..###...###...###..\n\t\t\t|..#.#..#...#.##....#...#.#...#.#...#.\n\t\t\t|..#.#..#...#.#.....#...#.#...#.#...#.\n\t\t\t|.#...#.#..##.#.....#...#.#.###.#.###.\n\t\t\t|.#####.####..#.....#...#..##....##...\n\t\t\t|.#...#.#...#.#.....#...#.#...#.#...#.\n\t\t\t|.#...#.#...#.##....#...#.#...#.#...#.\n\t\t\t|.#...#.####...####..###...###...###..\n\t\t\t|.....................................\n\t\t\t|\"\"\".stripMargin.split(\"\\r\\n\")\n\tprivate val s3 =\n\t\t\"\"\"10 37\n\t\t\t|.....................................\n\t\t\t|.....................................\n\t\t\t|.....................................\n\t\t\t|.....................................\n\t\t\t|.....................................\n\t\t\t|.....................................\n\t\t\t|.....................................\n\t\t\t|.....................................\n\t\t\t|.....................................\n\t\t\t|.....................................\n\t\t\t|\"\"\".stripMargin.split(\"\\r\\n\")\n\tprivate val s4 =\n\t\t\"\"\"5 37\n\t\t\t|.....................................\n\t\t\t|####################################.\n\t\t\t|.....................................\n\t\t\t|.####################################\n\t\t\t|.....................................\n\t\t\t|\"\"\".stripMargin.split(\"\\r\\n\")\n\tassert(pre(s1) == 2)\n\tassert(pre(s2) == 209)\n\tassert(pre(s3) == 370 - 10 - 37 + 1)\n\tassert(pre(s4) == 0)\n\n\tprintln(pre(scala.io.Source.stdin.getLines().toSeq))\n}\n", "language": "Scala", "metadata": {"date": 1544542947, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s442749377.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s442749377", "user_id": "u699236457"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n\tprivate val Empty = Int.MaxValue - 1\n\tprivate val Wall = Int.MaxValue\n\n\tprivate def pre(inputs: Seq[String]) = {\n\t\tval g = inputs.head.split(' ').map(_.toInt)\n\t\tval total = g(0) * g(1)\n\t\tval w = inputs.map(_.count(_ == '#')).sum //TODO '.'に変えてみる?\n\t\tval min = solve(inputs)\n\t\tval ret = total - w - min - 1\n\t\t//assert(0 <= ret) //FIXME RE\n\t\tassert(-1 != ret) //FIXME RE\n\n\t\t//assert(ret < Empty)\n\t\tret\n\t}\n\n\tprivate def solve(inputs: Seq[String]) = {\n\t\tval g = inputs.head.split(' ').map(_.toInt)\n\t\tval sy = 1\n\t\tval sx = 1\n\t\tval gy = g(0)\n\t\tval gx = g(1)\n\t\tval ffff = inputs.tail.map(_.toCharArray.map(e => if (e == '#') Wall else Empty).toArray).toArray\n\t\tval fff = ffff.map(Wall +: _ :+ Wall)\n\t\tval wall = fff(0).map(_ => Wall)\n\t\tval f = wall +: fff :+ wall\n\n\t\tval q = scala.collection.mutable.Queue[(Int, Int)]()\n\t\tq.enqueue((sx, sy))\n\t\tf(sy)(sx) = -1\n\t\tdo {\n\t\t\tval (ny, nx) = q.dequeue()\n\t\t\tif (f(ny)(nx) == -1 || f(ny)(nx) == Empty) {\n\t\t\t\t//f.foreach(e => println(e.toSeq.filterNot(_ == Empty)))\n\n\t\t\t\tf(ny)(nx) = 1 + Math.min(f(ny)(nx),\n\t\t\t\t\tMath.min(\n\t\t\t\t\t\tMath.min(f(ny - 1)(nx), f(ny + 1)(nx)),\n\t\t\t\t\t\tMath.min(f(ny)(nx - 1), f(ny)(nx + 1))))\n\n\t\t\t\tq.enqueue((ny - 1, nx))\n\t\t\t\tq.enqueue((ny + 1, nx))\n\t\t\t\tq.enqueue((ny, nx - 1))\n\t\t\t\tq.enqueue((ny, nx + 1))\n\n\t\t\t\tif (nx == gx && ny == gy) q.clear()\n\t\t\t}\n\t\t} while (q.nonEmpty)\n\n\t\t//print(\"done\")\n\t\tf(gy)(gx)\n\t}\n\n\tprivate val s1 =\n\t\t\"\"\"3 3\n\t\t\t|..#\n\t\t\t|#..\n\t\t\t|...\n\t\t\t|\"\"\".stripMargin.split(\"\\r\\n\")\n\tprivate val s2 =\n\t\t\"\"\"10 37\n\t\t\t|.....................................\n\t\t\t|...#...####...####..###...###...###..\n\t\t\t|..#.#..#...#.##....#...#.#...#.#...#.\n\t\t\t|..#.#..#...#.#.....#...#.#...#.#...#.\n\t\t\t|.#...#.#..##.#.....#...#.#.###.#.###.\n\t\t\t|.#####.####..#.....#...#..##....##...\n\t\t\t|.#...#.#...#.#.....#...#.#...#.#...#.\n\t\t\t|.#...#.#...#.##....#...#.#...#.#...#.\n\t\t\t|.#...#.####...####..###...###...###..\n\t\t\t|.....................................\n\t\t\t|\"\"\".stripMargin.split(\"\\r\\n\")\n\tprivate val s3 =\n\t\t\"\"\"10 37\n\t\t\t|.....................................\n\t\t\t|.....................................\n\t\t\t|.....................................\n\t\t\t|.....................................\n\t\t\t|.....................................\n\t\t\t|.....................................\n\t\t\t|.....................................\n\t\t\t|.....................................\n\t\t\t|.....................................\n\t\t\t|.....................................\n\t\t\t|\"\"\".stripMargin.split(\"\\r\\n\")\n\tprivate val s4 =\n\t\t\"\"\"5 37\n\t\t\t|.....................................\n\t\t\t|####################################.\n\t\t\t|.....................................\n\t\t\t|.####################################\n\t\t\t|.....................................\n\t\t\t|\"\"\".stripMargin.split(\"\\r\\n\")\n\tassert(pre(s1) == 2)\n\tassert(pre(s2) == 209)\n\tassert(pre(s3) == 370 - 10 - 37 + 1)\n\tassert(pre(s4) == 0)\n\n\tprintln(pre(scala.io.Source.stdin.getLines().toSeq))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2890, "cpu_time_ms": 441, "memory_kb": 29004}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s137468072", "group_id": "codeNet:p03436", "input_text": "import scala.collection.mutable.{HashSet => MSet}\nimport scala.io.StdIn._\nobject Main extends App {\n val Dirs = Seq((-1, 0), (1, 0), (0, -1), (0, 1))\n val checked = MSet[(Int, Int)]()\n\n val Array(h, w) = readLine.split(\" \").map{_.toInt}\n val field: Array[String] = (1 to h).map{i => readLine}.toArray\n val Blacks = field.map{_.count(_ == '#')}.sum\n\n def valid(x: Int, y: Int): Boolean =\n 0 < x && x <= w && 0 < y && y <= h && field(y - 1).charAt(x - 1) == '.' && !checked(x, y)\n\n @scala.annotation.tailrec\n def check(pos: Set[(Int, Int)], step: Int = 1): Int = {\n val valids = (for {\n (x, y) <- pos\n (dx, dy) <- Dirs if (valid(x + dx, y + dy))\n } yield (x + dx, y + dy)).toSet\n checked ++= valids\n if (checked(w, h)) w * h - (Blacks + step + 1)\n else if (valids.size == 0) -1\n else check(valids, step + 1)\n }\n\n println(check(Set((1, 1))))\n}", "language": "Scala", "metadata": {"date": 1522169960, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s137468072.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s137468072", "user_id": "u132324749"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.collection.mutable.{HashSet => MSet}\nimport scala.io.StdIn._\nobject Main extends App {\n val Dirs = Seq((-1, 0), (1, 0), (0, -1), (0, 1))\n val checked = MSet[(Int, Int)]()\n\n val Array(h, w) = readLine.split(\" \").map{_.toInt}\n val field: Array[String] = (1 to h).map{i => readLine}.toArray\n val Blacks = field.map{_.count(_ == '#')}.sum\n\n def valid(x: Int, y: Int): Boolean =\n 0 < x && x <= w && 0 < y && y <= h && field(y - 1).charAt(x - 1) == '.' && !checked(x, y)\n\n @scala.annotation.tailrec\n def check(pos: Set[(Int, Int)], step: Int = 1): Int = {\n val valids = (for {\n (x, y) <- pos\n (dx, dy) <- Dirs if (valid(x + dx, y + dy))\n } yield (x + dx, y + dy)).toSet\n checked ++= valids\n if (checked(w, h)) w * h - (Blacks + step + 1)\n else if (valids.size == 0) -1\n else check(valids, step + 1)\n }\n\n println(check(Set((1, 1))))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 881, "cpu_time_ms": 495, "memory_kb": 29132}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s049334315", "group_id": "codeNet:p03437", "input_text": "object Main {\n\n def func(a: Long, b: Long): Long = {\n var result = a * 2\n while(true) {\n if (result % b != 0)\n return result\n result += a\n }\n return -1\n }\n\n def main(args: Array[String]): Unit = {\n val context = Console.readLine()\n val numbers = context.split(\" \").map(_.toLong)\n\n if (numbers(1) % numbers(0) == 0) {\n println(\"-1\")\n } else {\n println(func(numbers(0), numbers(1)))\n }\n }\n}", "language": "Scala", "metadata": {"date": 1517865611, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s049334315.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s049334315", "user_id": "u798040367"}, "prompt_components": {"gold_output": "16\n", "input_to_evaluate": "object Main {\n\n def func(a: Long, b: Long): Long = {\n var result = a * 2\n while(true) {\n if (result % b != 0)\n return result\n result += a\n }\n return -1\n }\n\n def main(args: Array[String]): Unit = {\n val context = Console.readLine()\n val numbers = context.split(\" \").map(_.toLong)\n\n if (numbers(1) % numbers(0) == 0) {\n println(\"-1\")\n } else {\n println(func(numbers(0), numbers(1)))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 27300}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s655126021", "group_id": "codeNet:p03438", "input_text": "import java.util.Scanner\n\n/**\n * Created by 80011714 on 2018/2/5.\n */\nobject Main {\n\n def solve(sc: Scanner): Unit = {\n val x, y = sc.nextLong()\n println(if (x % y == 0) (-1) else {\n var i = 1\n while (i * x % y == 0) (i += 1)\n i * x\n })\n }\n\n def task2(n: Int, left: Array[Long], right: Array[Long]): String = {\n if (n == 1)\n return if (left.head <= right.head) \"Yes\" else \"No\"\n\n if (left.head < right.head) {\n val right_add_count = (right.head - left.head) / 2\n right(1) += right_add_count\n } else if (left.head > right.head) {\n val left_add_count = left.head - right.head\n left(1) += (left_add_count * 2)\n }\n return task2(n - 1, left.tail, right.tail)\n }\n\n def main(args: Array[String]): Unit = {\n// val sc: Scanner = new Scanner(System.in)\n\n val N = scala.io.StdIn.readInt\n val a = scala.io.StdIn.readLine.split(\" \").map(_.toLong).toSeq.toArray\n val b = scala.io.StdIn.readLine.split(\" \").map(_.toLong).toSeq.toArray\n\n println(task2(N, a, b))\n }\n}\n", "language": "Scala", "metadata": {"date": 1517868898, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03438.html", "problem_id": "p03438", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03438/input.txt", "sample_output_relpath": "derived/input_output/data/p03438/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03438/Scala/s655126021.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s655126021", "user_id": "u798040367"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner\n\n/**\n * Created by 80011714 on 2018/2/5.\n */\nobject Main {\n\n def solve(sc: Scanner): Unit = {\n val x, y = sc.nextLong()\n println(if (x % y == 0) (-1) else {\n var i = 1\n while (i * x % y == 0) (i += 1)\n i * x\n })\n }\n\n def task2(n: Int, left: Array[Long], right: Array[Long]): String = {\n if (n == 1)\n return if (left.head <= right.head) \"Yes\" else \"No\"\n\n if (left.head < right.head) {\n val right_add_count = (right.head - left.head) / 2\n right(1) += right_add_count\n } else if (left.head > right.head) {\n val left_add_count = left.head - right.head\n left(1) += (left_add_count * 2)\n }\n return task2(n - 1, left.tail, right.tail)\n }\n\n def main(args: Array[String]): Unit = {\n// val sc: Scanner = new Scanner(System.in)\n\n val N = scala.io.StdIn.readInt\n val a = scala.io.StdIn.readLine.split(\" \").map(_.toLong).toSeq.toArray\n val b = scala.io.StdIn.readLine.split(\" \").map(_.toLong).toSeq.toArray\n\n println(task2(N, a, b))\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N.\nDetermine if we can repeat the following operation zero or more times so that the sequences a and b become equal.\n\nOperation: Choose two integers i and j (possibly the same) between 1 and N (inclusive), then perform the following two actions simultaneously:\n\nAdd 2 to a_i.\n\nAdd 1 to b_j.\n\nConstraints\n\n1 ≤ N ≤ 10 000\n\n0 ≤ a_i,b_i ≤ 10^9 (1 ≤ i ≤ N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 .. a_N\nb_1 b_2 .. b_N\n\nOutput\n\nIf we can repeat the operation zero or more times so that the sequences a and b become equal, print Yes; otherwise, print No.\n\nSample Input 1\n\n3\n1 2 3\n5 2 2\n\nSample Output 1\n\nYes\n\nFor example, we can perform three operations as follows to do our job:\n\nFirst operation: i=1 and j=2. Now we have a = \\{3,2,3\\}, b = \\{5,3,2\\}.\n\nSecond operation: i=1 and j=2. Now we have a = \\{5,2,3\\}, b = \\{5,4,2\\}.\n\nThird operation: i=2 and j=3. Now we have a = \\{5,4,3\\}, b = \\{5,4,3\\}.\n\nSample Input 2\n\n5\n3 1 4 1 5\n2 7 1 8 2\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n5\n2 7 1 8 2\n3 1 4 1 5\n\nSample Output 3\n\nNo", "sample_input": "3\n1 2 3\n5 2 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03438", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N.\nDetermine if we can repeat the following operation zero or more times so that the sequences a and b become equal.\n\nOperation: Choose two integers i and j (possibly the same) between 1 and N (inclusive), then perform the following two actions simultaneously:\n\nAdd 2 to a_i.\n\nAdd 1 to b_j.\n\nConstraints\n\n1 ≤ N ≤ 10 000\n\n0 ≤ a_i,b_i ≤ 10^9 (1 ≤ i ≤ N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 .. a_N\nb_1 b_2 .. b_N\n\nOutput\n\nIf we can repeat the operation zero or more times so that the sequences a and b become equal, print Yes; otherwise, print No.\n\nSample Input 1\n\n3\n1 2 3\n5 2 2\n\nSample Output 1\n\nYes\n\nFor example, we can perform three operations as follows to do our job:\n\nFirst operation: i=1 and j=2. Now we have a = \\{3,2,3\\}, b = \\{5,3,2\\}.\n\nSecond operation: i=1 and j=2. Now we have a = \\{5,2,3\\}, b = \\{5,4,2\\}.\n\nThird operation: i=2 and j=3. Now we have a = \\{5,4,3\\}, b = \\{5,4,3\\}.\n\nSample Input 2\n\n5\n3 1 4 1 5\n2 7 1 8 2\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n5\n2 7 1 8 2\n3 1 4 1 5\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1037, "cpu_time_ms": 1035, "memory_kb": 116592}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s954083648", "group_id": "codeNet:p03450", "input_text": "import java.io.{BufferedReader, InputStream, InputStreamReader}\nimport java.util.StringTokenizer\n\nimport scala.collection.mutable\nimport scala.util.Sorting\nimport math.{abs, max, min}\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n val MOD = 1000000007\n def solve(): Unit = {\n val sc = new InputReader(System.in)\n val N = sc.nextInt()\n val M = sc.nextInt()\n\n type Node = Int\n type Edge = (Node, Int)\n val E = Array.ofDim[ArrayBuffer[Edge]](N)\n (0 until M) foreach { _ =>\n val l = sc.nextInt() - 1\n val r = sc.nextInt() - 1\n val d = sc.nextInt()\n if (E(l) == null) E(l) = ArrayBuffer.empty\n if (E(r) == null) E(r) = ArrayBuffer.empty\n E(l) += ((r, d))\n E(r) += ((l, -d))\n }\n\n val d = Array.ofDim[Int](N)\n type Elm = (Node, Int)\n val que = mutable.Queue.empty[Elm]\n\n (0 until N) foreach { i =>\n if (d(i) == 0) {\n visit(i, 0)\n while(que.nonEmpty) {\n val (cost, v) = que.dequeue()\n if (d(v) == 0) {\n d(v) = cost\n visit(v, cost)\n }\n }\n }\n }\n\n def visit(v: Int, cost0: Int): Unit = {\n if (E(v) != null) {\n E(v) foreach { case (u, cost) =>\n que.enqueue((cost0 + cost, u))\n }\n }\n }\n\n var valid = true\n for {\n v <- 0 until N\n j <- Option(E(v)) map (_.indices) getOrElse Seq.empty\n } {\n val (u, cost) = E(v)(j)\n valid &= d(v) + cost == d(u)\n }\n\n if (valid) println(\"Yes\") else println(\"No\")\n }\n\n\n def main(args: Array[String]): Unit = {\n solve()\n }\n\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = null\n\n def next: String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next.toInt\n def nextLong(): Long = next.toLong\n def nextChar(): Char = next.charAt(0)\n }\n\n\n class UnionFind(n: Int) {\n private val par = Array.iterate(0, n)(_ + 1)\n private val rank = Array.ofDim[Int](n)\n\n def find(x: Int): Int = {\n if (par(x) == x) x\n else {\n par(x) = find(par(x))\n par(x)\n }\n }\n\n def unite(x: Int, y: Int): Unit = {\n val x1 = find(x)\n val y1 = find(y)\n if (x1 != y1) {\n if (rank(x1) < rank(y)) {\n par(x1) = y1\n } else {\n par(y1) = x1\n if (rank(x1) == rank(y1)) rank(x1) += 1\n }\n }\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1528956451, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s954083648.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s954083648", "user_id": "u460609472"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.io.{BufferedReader, InputStream, InputStreamReader}\nimport java.util.StringTokenizer\n\nimport scala.collection.mutable\nimport scala.util.Sorting\nimport math.{abs, max, min}\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n val MOD = 1000000007\n def solve(): Unit = {\n val sc = new InputReader(System.in)\n val N = sc.nextInt()\n val M = sc.nextInt()\n\n type Node = Int\n type Edge = (Node, Int)\n val E = Array.ofDim[ArrayBuffer[Edge]](N)\n (0 until M) foreach { _ =>\n val l = sc.nextInt() - 1\n val r = sc.nextInt() - 1\n val d = sc.nextInt()\n if (E(l) == null) E(l) = ArrayBuffer.empty\n if (E(r) == null) E(r) = ArrayBuffer.empty\n E(l) += ((r, d))\n E(r) += ((l, -d))\n }\n\n val d = Array.ofDim[Int](N)\n type Elm = (Node, Int)\n val que = mutable.Queue.empty[Elm]\n\n (0 until N) foreach { i =>\n if (d(i) == 0) {\n visit(i, 0)\n while(que.nonEmpty) {\n val (cost, v) = que.dequeue()\n if (d(v) == 0) {\n d(v) = cost\n visit(v, cost)\n }\n }\n }\n }\n\n def visit(v: Int, cost0: Int): Unit = {\n if (E(v) != null) {\n E(v) foreach { case (u, cost) =>\n que.enqueue((cost0 + cost, u))\n }\n }\n }\n\n var valid = true\n for {\n v <- 0 until N\n j <- Option(E(v)) map (_.indices) getOrElse Seq.empty\n } {\n val (u, cost) = E(v)(j)\n valid &= d(v) + cost == d(u)\n }\n\n if (valid) println(\"Yes\") else println(\"No\")\n }\n\n\n def main(args: Array[String]): Unit = {\n solve()\n }\n\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = null\n\n def next: String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next.toInt\n def nextLong(): Long = next.toLong\n def nextChar(): Char = next.charAt(0)\n }\n\n\n class UnionFind(n: Int) {\n private val par = Array.iterate(0, n)(_ + 1)\n private val rank = Array.ofDim[Int](n)\n\n def find(x: Int): Int = {\n if (par(x) == x) x\n else {\n par(x) = find(par(x))\n par(x)\n }\n }\n\n def unite(x: Int, y: Int): Unit = {\n val x1 = find(x)\n val y1 = find(y)\n if (x1 != y1) {\n if (rank(x1) < rank(y)) {\n par(x1) = y1\n } else {\n par(y1) = x1\n if (rank(x1) == rank(y1)) rank(x1) += 1\n }\n }\n }\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N people standing on the x-axis.\nLet the coordinate of Person i be x_i.\nFor every i, x_i is an integer between 0 and 10^9 (inclusive).\nIt is possible that more than one person is standing at the same coordinate.\n\nYou will given M pieces of information regarding the positions of these people.\nThe i-th piece of information has the form (L_i, R_i, D_i).\nThis means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds.\n\nIt turns out that some of these M pieces of information may be incorrect.\nDetermine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.\n\nConstraints\n\n1 \\leq N \\leq 100 000\n\n0 \\leq M \\leq 200 000\n\n1 \\leq L_i, R_i \\leq N (1 \\leq i \\leq M)\n\n0 \\leq D_i \\leq 10 000 (1 \\leq i \\leq M)\n\nL_i \\neq R_i (1 \\leq i \\leq M)\n\nIf i \\neq j, then (L_i, R_i) \\neq (L_j, R_j) and (L_i, R_i) \\neq (R_j, L_j).\n\nD_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nL_1 R_1 D_1\nL_2 R_2 D_2\n:\nL_M R_M D_M\n\nOutput\n\nIf there exists a set of values (x_1, x_2, ..., x_N) that is consistent with all given pieces of information, print Yes; if it does not exist, print No.\n\nSample Input 1\n\n3 3\n1 2 1\n2 3 1\n1 3 2\n\nSample Output 1\n\nYes\n\nSome possible sets of values (x_1, x_2, x_3) are (0, 1, 2) and (101, 102, 103).\n\nSample Input 2\n\n3 3\n1 2 1\n2 3 1\n1 3 5\n\nSample Output 2\n\nNo\n\nIf the first two pieces of information are correct, x_3 - x_1 = 2 holds, which is contradictory to the last piece of information.\n\nSample Input 3\n\n4 3\n2 1 1\n2 3 5\n3 4 2\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n10 3\n8 7 100\n7 9 100\n9 8 100\n\nSample Output 4\n\nNo\n\nSample Input 5\n\n100 0\n\nSample Output 5\n\nYes", "sample_input": "3 3\n1 2 1\n2 3 1\n1 3 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03450", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N people standing on the x-axis.\nLet the coordinate of Person i be x_i.\nFor every i, x_i is an integer between 0 and 10^9 (inclusive).\nIt is possible that more than one person is standing at the same coordinate.\n\nYou will given M pieces of information regarding the positions of these people.\nThe i-th piece of information has the form (L_i, R_i, D_i).\nThis means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds.\n\nIt turns out that some of these M pieces of information may be incorrect.\nDetermine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.\n\nConstraints\n\n1 \\leq N \\leq 100 000\n\n0 \\leq M \\leq 200 000\n\n1 \\leq L_i, R_i \\leq N (1 \\leq i \\leq M)\n\n0 \\leq D_i \\leq 10 000 (1 \\leq i \\leq M)\n\nL_i \\neq R_i (1 \\leq i \\leq M)\n\nIf i \\neq j, then (L_i, R_i) \\neq (L_j, R_j) and (L_i, R_i) \\neq (R_j, L_j).\n\nD_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nL_1 R_1 D_1\nL_2 R_2 D_2\n:\nL_M R_M D_M\n\nOutput\n\nIf there exists a set of values (x_1, x_2, ..., x_N) that is consistent with all given pieces of information, print Yes; if it does not exist, print No.\n\nSample Input 1\n\n3 3\n1 2 1\n2 3 1\n1 3 2\n\nSample Output 1\n\nYes\n\nSome possible sets of values (x_1, x_2, x_3) are (0, 1, 2) and (101, 102, 103).\n\nSample Input 2\n\n3 3\n1 2 1\n2 3 1\n1 3 5\n\nSample Output 2\n\nNo\n\nIf the first two pieces of information are correct, x_3 - x_1 = 2 holds, which is contradictory to the last piece of information.\n\nSample Input 3\n\n4 3\n2 1 1\n2 3 5\n3 4 2\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n10 3\n8 7 100\n7 9 100\n9 8 100\n\nSample Output 4\n\nNo\n\nSample Input 5\n\n100 0\n\nSample Output 5\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2601, "cpu_time_ms": 2119, "memory_kb": 206156}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s851014526", "group_id": "codeNet:p03457", "input_text": "object Main extends App {\n val n = io.StdIn.readLine.toInt\n val arr = Iterator.continually(io.StdIn.readLine.split(\" \"))\n .take(n)\n .toArray\n val ans = (Array(Array(\"0\",\"0\",\"0\")).toBuffer++arr)\n .zip(arr)\n .forall{case (cur, nex) => {\n val dt =nex(0).toInt - cur(0).toInt\n val dist = (nex(1).toInt - cur(1).toInt).abs +\n (nex(2).toInt - cur(2).toInt).abs\n dt >= dist && (dist&1) == (dt&1)\n }}\n\n println(if(ans) \"Yes\" else \"No\")\n}", "language": "Scala", "metadata": {"date": 1543872913, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03457.html", "problem_id": "p03457", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03457/input.txt", "sample_output_relpath": "derived/input_output/data/p03457/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03457/Scala/s851014526.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s851014526", "user_id": "u217010036"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n val n = io.StdIn.readLine.toInt\n val arr = Iterator.continually(io.StdIn.readLine.split(\" \"))\n .take(n)\n .toArray\n val ans = (Array(Array(\"0\",\"0\",\"0\")).toBuffer++arr)\n .zip(arr)\n .forall{case (cur, nex) => {\n val dt =nex(0).toInt - cur(0).toInt\n val dist = (nex(1).toInt - cur(1).toInt).abs +\n (nex(2).toInt - cur(2).toInt).abs\n dt >= dist && (dist&1) == (dt&1)\n }}\n\n println(if(ans) \"Yes\" else \"No\")\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "sample_input": "2\n3 1 2\n6 1 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03457", "source_text": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 479, "cpu_time_ms": 984, "memory_kb": 77760}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s044300410", "group_id": "codeNet:p03457", "input_text": "object Main extends App {\n val n = io.StdIn.readLine.toInt\n val ans = Iterator.continually(io.StdIn.readLine.split(\" \"))\n .take(n)\n .map(in => {\n val c = in(0).toInt - in(1).toInt - in(2).toInt\n if (c < 0 || (c & 1) == 1) false else true\n })\n .forall(_ == true)\n// .takeWhile(_ == true)\n// .size\n\n println(if(ans) \"Yes\" else \"No\")\n}", "language": "Scala", "metadata": {"date": 1543720073, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03457.html", "problem_id": "p03457", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03457/input.txt", "sample_output_relpath": "derived/input_output/data/p03457/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03457/Scala/s044300410.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s044300410", "user_id": "u217010036"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n val n = io.StdIn.readLine.toInt\n val ans = Iterator.continually(io.StdIn.readLine.split(\" \"))\n .take(n)\n .map(in => {\n val c = in(0).toInt - in(1).toInt - in(2).toInt\n if (c < 0 || (c & 1) == 1) false else true\n })\n .forall(_ == true)\n// .takeWhile(_ == true)\n// .size\n\n println(if(ans) \"Yes\" else \"No\")\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "sample_input": "2\n3 1 2\n6 1 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03457", "source_text": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 682, "memory_kb": 43236}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s782374366", "group_id": "codeNet:p03457", "input_text": "object Main extends App {\n val n = io.StdIn.readLine.toInt\n val ans = Iterator.continually(io.StdIn.readLine)\n .take(n)\n .map(_.split(\" \").map(_.toInt))\n .map(in => {\n val Array(t, x, y) = in\n if (x + y > t) \"No\"\n else if (((t % (x + y)) & 1) == 1) \"No\"\n else \"Yes\"\n })\n .toArray\n\n println(if (ans.contains(\"No\")) \"No\" else \"Yes\")\n}", "language": "Scala", "metadata": {"date": 1543713328, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03457.html", "problem_id": "p03457", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03457/input.txt", "sample_output_relpath": "derived/input_output/data/p03457/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03457/Scala/s782374366.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s782374366", "user_id": "u217010036"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n val n = io.StdIn.readLine.toInt\n val ans = Iterator.continually(io.StdIn.readLine)\n .take(n)\n .map(_.split(\" \").map(_.toInt))\n .map(in => {\n val Array(t, x, y) = in\n if (x + y > t) \"No\"\n else if (((t % (x + y)) & 1) == 1) \"No\"\n else \"Yes\"\n })\n .toArray\n\n println(if (ans.contains(\"No\")) \"No\" else \"Yes\")\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "sample_input": "2\n3 1 2\n6 1 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03457", "source_text": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 388, "cpu_time_ms": 1017, "memory_kb": 52892}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s723755043", "group_id": "codeNet:p03457", "input_text": "import scala.util.control.Breaks._\nimport scala.math.abs\n\nobject Main {\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val txys = List(0, 0, 0) :: List.fill(n, 3)(sc.nextInt)\n\n var possible = true\n breakable { for (i <- 0 until n) {\n val List(t0, x0, y0) = txys(i)\n val List(t1, x1, y1) = txys(i + 1)\n val res = t1 - t0 - (abs(x1 - x0) + abs(y1 - y0))\n if (res < 0 || res%2 != 0) {\n possible = false\n break\n }\n } }\n println(if (possible) \"Yes\" else \"No\")\n }\n}\n", "language": "Scala", "metadata": {"date": 1527964847, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03457.html", "problem_id": "p03457", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03457/input.txt", "sample_output_relpath": "derived/input_output/data/p03457/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03457/Scala/s723755043.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s723755043", "user_id": "u710809824"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.util.control.Breaks._\nimport scala.math.abs\n\nobject Main {\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val txys = List(0, 0, 0) :: List.fill(n, 3)(sc.nextInt)\n\n var possible = true\n breakable { for (i <- 0 until n) {\n val List(t0, x0, y0) = txys(i)\n val List(t1, x1, y1) = txys(i + 1)\n val res = t1 - t0 - (abs(x1 - x0) + abs(y1 - y0))\n if (res < 0 || res%2 != 0) {\n possible = false\n break\n }\n } }\n println(if (possible) \"Yes\" else \"No\")\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "sample_input": "2\n3 1 2\n6 1 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03457", "source_text": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 118832}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s759825733", "group_id": "codeNet:p03457", "input_text": "object Main extends App {\n val n = io.StdIn.readLine().toInt\n val list = collection.mutable.ListBuffer[Array[Int]](Array(0 ,0, 0))\n (1 to n).foreach { i =>\n list += io.StdIn.readLine().split(' ').map(_.toInt).toArray\n }\n def f(t: Int, x: Int): Boolean = {\n if (t == 0) (x == 0)\n else if(x == 0) (t & 1) == 0\n else if (x < 0 || x > t) false\n else (f(t - 1, x - 1))\n }\n list.zip(list.tail)\n val list2 = list.zip(list.tail).map{case (x1, x2) => (x2(0) - x1(0), Math.abs(x2(1) - x1(1)) + Math.abs(x2(2) - x1(2)))}\n print(if(list2.forall{case (t, x) => f(t, x)}) \"Yes\" else \"No\")\n}\n", "language": "Scala", "metadata": {"date": 1525727939, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03457.html", "problem_id": "p03457", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03457/input.txt", "sample_output_relpath": "derived/input_output/data/p03457/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03457/Scala/s759825733.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s759825733", "user_id": "u006018820"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n val n = io.StdIn.readLine().toInt\n val list = collection.mutable.ListBuffer[Array[Int]](Array(0 ,0, 0))\n (1 to n).foreach { i =>\n list += io.StdIn.readLine().split(' ').map(_.toInt).toArray\n }\n def f(t: Int, x: Int): Boolean = {\n if (t == 0) (x == 0)\n else if(x == 0) (t & 1) == 0\n else if (x < 0 || x > t) false\n else (f(t - 1, x - 1))\n }\n list.zip(list.tail)\n val list2 = list.zip(list.tail).map{case (x1, x2) => (x2(0) - x1(0), Math.abs(x2(1) - x1(1)) + Math.abs(x2(2) - x1(2)))}\n print(if(list2.forall{case (t, x) => f(t, x)}) \"Yes\" else \"No\")\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "sample_input": "2\n3 1 2\n6 1 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03457", "source_text": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 601, "cpu_time_ms": 930, "memory_kb": 63180}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s424278115", "group_id": "codeNet:p03457", "input_text": "object Main extends App {\n val n = io.StdIn.readLine().toInt\n val list = collection.mutable.ListBuffer[Array[Int]](Array(0 ,0, 0))\n (1 to n).foreach { i =>\n list += io.StdIn.readLine().split(' ').map(_.toInt).toArray\n }\n val cache = collection.mutable.HashMap[(Int, Int, Int), Boolean]()\n def f(t: Int, x: Int, y: Int): Boolean = {\n val absX = Math.abs(x)\n val absY = Math.abs(y)\n if (t == 0) (x == 0 && y == 0)\n else if (absX > t || absY > t || absX + absY > t) false\n else (f(t - 1, x + 1, y) || f(t - 1, x - 1, y) || f(t - 1, x, y + 1) || f(t - 1, x, y - 1)) \n }\n list.zip(list.tail)\n val list2 = list.zip(list.tail).map{case (x1, x2) => (x2(0) - x1(0), x2(1) - x1(1), x2(2) - x1(2))}\n print(if(list2.forall{case (t, x, y) => cache.getOrElseUpdate((t, x, y), f(t, x, y))}) \"Yes\" else \"No\")\n}", "language": "Scala", "metadata": {"date": 1525726035, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03457.html", "problem_id": "p03457", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03457/input.txt", "sample_output_relpath": "derived/input_output/data/p03457/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03457/Scala/s424278115.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s424278115", "user_id": "u006018820"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n val n = io.StdIn.readLine().toInt\n val list = collection.mutable.ListBuffer[Array[Int]](Array(0 ,0, 0))\n (1 to n).foreach { i =>\n list += io.StdIn.readLine().split(' ').map(_.toInt).toArray\n }\n val cache = collection.mutable.HashMap[(Int, Int, Int), Boolean]()\n def f(t: Int, x: Int, y: Int): Boolean = {\n val absX = Math.abs(x)\n val absY = Math.abs(y)\n if (t == 0) (x == 0 && y == 0)\n else if (absX > t || absY > t || absX + absY > t) false\n else (f(t - 1, x + 1, y) || f(t - 1, x - 1, y) || f(t - 1, x, y + 1) || f(t - 1, x, y - 1)) \n }\n list.zip(list.tail)\n val list2 = list.zip(list.tail).map{case (x1, x2) => (x2(0) - x1(0), x2(1) - x1(1), x2(2) - x1(2))}\n print(if(list2.forall{case (t, x, y) => cache.getOrElseUpdate((t, x, y), f(t, x, y))}) \"Yes\" else \"No\")\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "sample_input": "2\n3 1 2\n6 1 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03457", "source_text": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 65352}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s929739997", "group_id": "codeNet:p03457", "input_text": "object Main extends App {\n val n = io.StdIn.readLine().toInt\n val list: collection.mutable.ListBuffer[Array[Int]] = collection.mutable.ListBuffer[Array[Int]](Array(0,0,0))\n (1 to n).foreach { i =>\n list += io.StdIn.readLine().split(' ').map(_.toInt).toArray\n } \n def f(t:Int, x: Int, y: Int): Boolean = {\n if(t == 0) (x == 0 && y == 0)\n else (f(t - 1, x + 1, y) || f(t - 1, x - 1, y) || f(t - 1, x, y + 1) || f(t - 1, x, y - 1)) \n }\n list.zip(list.tail)\n // list.foldLeft(Array(0,0,0)){(acc, x)}\n val list2 = list.zip(list.tail).map{case (x1, x2) => (x2(0)-x1(0), x2(1)-x1(1), x2(2)-x1(2))}\n print(if(list2.forall{case (t, x, y) => f(t, x, y)}) \"Yes\" else \"No\")\n}", "language": "Scala", "metadata": {"date": 1525723491, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03457.html", "problem_id": "p03457", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03457/input.txt", "sample_output_relpath": "derived/input_output/data/p03457/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03457/Scala/s929739997.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s929739997", "user_id": "u006018820"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n val n = io.StdIn.readLine().toInt\n val list: collection.mutable.ListBuffer[Array[Int]] = collection.mutable.ListBuffer[Array[Int]](Array(0,0,0))\n (1 to n).foreach { i =>\n list += io.StdIn.readLine().split(' ').map(_.toInt).toArray\n } \n def f(t:Int, x: Int, y: Int): Boolean = {\n if(t == 0) (x == 0 && y == 0)\n else (f(t - 1, x + 1, y) || f(t - 1, x - 1, y) || f(t - 1, x, y + 1) || f(t - 1, x, y - 1)) \n }\n list.zip(list.tail)\n // list.foldLeft(Array(0,0,0)){(acc, x)}\n val list2 = list.zip(list.tail).map{case (x1, x2) => (x2(0)-x1(0), x2(1)-x1(1), x2(2)-x1(2))}\n print(if(list2.forall{case (t, x, y) => f(t, x, y)}) \"Yes\" else \"No\")\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "sample_input": "2\n3 1 2\n6 1 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03457", "source_text": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 63148}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s026825553", "group_id": "codeNet:p03457", "input_text": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val inum = sc.nextInt()\n var flag = false\n\n for (i <- 1 to inum) {\n var num, numx, numy = sc.nextInt\n if (num <= (numx + numy) && !flag) {\n if (num % 2 == 0 && (numx + numy) % 2 == 0) flag=true else flag=false\n if (num % 2 == 1 && (numx + numy) % 2 == 1) flag=true else flag=false\n }\n }\n\n if(flag)println(\"Yes\") else println(\"No\")\n }\n}", "language": "Scala", "metadata": {"date": 1518384522, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03457.html", "problem_id": "p03457", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03457/input.txt", "sample_output_relpath": "derived/input_output/data/p03457/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03457/Scala/s026825553.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s026825553", "user_id": "u658559310"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val inum = sc.nextInt()\n var flag = false\n\n for (i <- 1 to inum) {\n var num, numx, numy = sc.nextInt\n if (num <= (numx + numy) && !flag) {\n if (num % 2 == 0 && (numx + numy) % 2 == 0) flag=true else flag=false\n if (num % 2 == 1 && (numx + numy) % 2 == 1) flag=true else flag=false\n }\n }\n\n if(flag)println(\"Yes\") else println(\"No\")\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "sample_input": "2\n3 1 2\n6 1 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03457", "source_text": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 499, "cpu_time_ms": 746, "memory_kb": 90784}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s456669748", "group_id": "codeNet:p03458", "input_text": "object Main extends App {\n val Array(n, k) = io.StdIn.readLine().split(' ').map(_.toInt)\n type Record = (Int, Int, Boolean)\n val list = collection.mutable.ListBuffer[Record]()\n (1 to n).foreach { i =>\n val temp = io.StdIn.readLine().split(' ')\n list += ((temp(0).toInt % (k * 2) , temp(1).toInt % (k * 2), temp(2) == \"W\"))\n }\n def shift(x: Int): Int = if(x == (k * 2)) 0 else x + 1\n def shift(x: Record): Record = (shift(x._1), shift(x._2), x._3)\n def count(xs: Seq[Record]): Int = xs.count {\n case (x, y, bool) => ( (x < k && y < k) || (x >= k && y >= k) == bool )\n }\n\n var max = 0\n var shiftList = list\n\n (0 to k).foreach { i =>\n val cnt = count(shiftList)\n max = Math.max(Math.max(cnt, n - cnt), max)\n shiftList = shiftList.map(shift)\n }\n print(max)\n\n}\n", "language": "Scala", "metadata": {"date": 1525793832, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03458.html", "problem_id": "p03458", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03458/input.txt", "sample_output_relpath": "derived/input_output/data/p03458/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03458/Scala/s456669748.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s456669748", "user_id": "u006018820"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "object Main extends App {\n val Array(n, k) = io.StdIn.readLine().split(' ').map(_.toInt)\n type Record = (Int, Int, Boolean)\n val list = collection.mutable.ListBuffer[Record]()\n (1 to n).foreach { i =>\n val temp = io.StdIn.readLine().split(' ')\n list += ((temp(0).toInt % (k * 2) , temp(1).toInt % (k * 2), temp(2) == \"W\"))\n }\n def shift(x: Int): Int = if(x == (k * 2)) 0 else x + 1\n def shift(x: Record): Record = (shift(x._1), shift(x._2), x._3)\n def count(xs: Seq[Record]): Int = xs.count {\n case (x, y, bool) => ( (x < k && y < k) || (x >= k && y >= k) == bool )\n }\n\n var max = 0\n var shiftList = list\n\n (0 to k).foreach { i =>\n val cnt = count(shiftList)\n max = Math.max(Math.max(cnt, n - cnt), max)\n shiftList = shiftList.map(shift)\n }\n print(max)\n\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nAtCoDeer is thinking of painting an infinite two-dimensional grid in a checked pattern of side K.\nHere, a checked pattern of side K is a pattern where each square is painted black or white so that each connected component of each color is a K × K square.\nBelow is an example of a checked pattern of side 3:\n\nAtCoDeer has N desires.\nThe i-th desire is represented by x_i, y_i and c_i.\nIf c_i is B, it means that he wants to paint the square (x_i,y_i) black; if c_i is W, he wants to paint the square (x_i,y_i) white.\nAt most how many desires can he satisfy at the same time?\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n1 ≤ K ≤ 1000\n\n0 ≤ x_i ≤ 10^9\n\n0 ≤ y_i ≤ 10^9\n\nIf i ≠ j, then (x_i,y_i) ≠ (x_j,y_j).\n\nc_i is B or W.\n\nN, K, x_i and y_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nx_1 y_1 c_1\nx_2 y_2 c_2\n:\nx_N y_N c_N\n\nOutput\n\nPrint the maximum number of desires that can be satisfied at the same time.\n\nSample Input 1\n\n4 3\n0 1 W\n1 2 W\n5 3 B\n5 4 B\n\nSample Output 1\n\n4\n\nHe can satisfy all his desires by painting as shown in the example above.\n\nSample Input 2\n\n2 1000\n0 0 B\n0 1 W\n\nSample Output 2\n\n2\n\nSample Input 3\n\n6 2\n1 2 B\n2 1 W\n2 2 B\n1 0 B\n0 6 W\n4 5 W\n\nSample Output 3\n\n4", "sample_input": "4 3\n0 1 W\n1 2 W\n5 3 B\n5 4 B\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03458", "source_text": "Score : 500 points\n\nProblem Statement\n\nAtCoDeer is thinking of painting an infinite two-dimensional grid in a checked pattern of side K.\nHere, a checked pattern of side K is a pattern where each square is painted black or white so that each connected component of each color is a K × K square.\nBelow is an example of a checked pattern of side 3:\n\nAtCoDeer has N desires.\nThe i-th desire is represented by x_i, y_i and c_i.\nIf c_i is B, it means that he wants to paint the square (x_i,y_i) black; if c_i is W, he wants to paint the square (x_i,y_i) white.\nAt most how many desires can he satisfy at the same time?\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n1 ≤ K ≤ 1000\n\n0 ≤ x_i ≤ 10^9\n\n0 ≤ y_i ≤ 10^9\n\nIf i ≠ j, then (x_i,y_i) ≠ (x_j,y_j).\n\nc_i is B or W.\n\nN, K, x_i and y_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nx_1 y_1 c_1\nx_2 y_2 c_2\n:\nx_N y_N c_N\n\nOutput\n\nPrint the maximum number of desires that can be satisfied at the same time.\n\nSample Input 1\n\n4 3\n0 1 W\n1 2 W\n5 3 B\n5 4 B\n\nSample Output 1\n\n4\n\nHe can satisfy all his desires by painting as shown in the example above.\n\nSample Input 2\n\n2 1000\n0 0 B\n0 1 W\n\nSample Output 2\n\n2\n\nSample Input 3\n\n6 2\n1 2 B\n2 1 W\n2 2 B\n1 0 B\n0 6 W\n4 5 W\n\nSample Output 3\n\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 788, "cpu_time_ms": 2111, "memory_kb": 152292}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s605957408", "group_id": "codeNet:p03459", "input_text": "import java.util.Scanner\n\nimport scala.annotation.tailrec\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val N = sc.nextInt\n val es = Element(0, Position(0, 0)) +: Seq.fill(N)(Element(sc.nextInt, Position(sc.nextInt, sc.nextInt)))\n\n println(if (solve(es)) \"Yes\" else \"No\")\n\n @tailrec\n private[this] def solve(es: Seq[Element]): Boolean = es match {\n case h +: n +: rest =>\n h.validNext(n) || solve(n +: rest)\n case _ => true\n }\n}\n\ncase class Element(t: Int, p: Position) {\n def validNext(destination: Element): Boolean = {\n val distance = p.distance(destination.p)\n val dt = destination.t - t\n if (distance > dt) false\n else if (dt - distance % 2 == 0) true\n else false\n }\n}\n\ncase class Position(x: Int, y: Int) {\n def distance(that: Position): Int =\n Math.abs(that.x - x) + Math.abs(that.y - y)\n}\n", "language": "Scala", "metadata": {"date": 1530572672, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03459.html", "problem_id": "p03459", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03459/input.txt", "sample_output_relpath": "derived/input_output/data/p03459/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03459/Scala/s605957408.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s605957408", "user_id": "u220774651"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.annotation.tailrec\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val N = sc.nextInt\n val es = Element(0, Position(0, 0)) +: Seq.fill(N)(Element(sc.nextInt, Position(sc.nextInt, sc.nextInt)))\n\n println(if (solve(es)) \"Yes\" else \"No\")\n\n @tailrec\n private[this] def solve(es: Seq[Element]): Boolean = es match {\n case h +: n +: rest =>\n h.validNext(n) || solve(n +: rest)\n case _ => true\n }\n}\n\ncase class Element(t: Int, p: Position) {\n def validNext(destination: Element): Boolean = {\n val distance = p.distance(destination.p)\n val dt = destination.t - t\n if (distance > dt) false\n else if (dt - distance % 2 == 0) true\n else false\n }\n}\n\ncase class Position(x: Int, y: Int) {\n def distance(that: Position): Int =\n Math.abs(that.x - x) + Math.abs(that.y - y)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "sample_input": "2\n3 1 2\n6 1 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03459", "source_text": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 851, "cpu_time_ms": 826, "memory_kb": 104324}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s982980151", "group_id": "codeNet:p03459", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n var prev_place = Array(0, 0, 0)\n val n = io.StdIn.readLine().toInt\n\n var result = true\n var i = 0\n while (i < n && result == true) {\n val place = io.StdIn.readLine().split(' ').map({ _.toInt })\n val time = place(0) - prev_place(0)\n val move = place.zip(prev_place).map({ case (x, y) => x-y }).drop(1)\n\n if (move.sum > time)\n result = false\n\n if ((time + move.sum) % 2 == 1)\n result = false\n\n prev_place = place\n i += 1\n }\n\n if (result == true)\n println(\"Yes\")\n else\n println(\"No\")\n }\n}\n", "language": "Scala", "metadata": {"date": 1518476203, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03459.html", "problem_id": "p03459", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03459/input.txt", "sample_output_relpath": "derived/input_output/data/p03459/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03459/Scala/s982980151.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s982980151", "user_id": "u551313534"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n var prev_place = Array(0, 0, 0)\n val n = io.StdIn.readLine().toInt\n\n var result = true\n var i = 0\n while (i < n && result == true) {\n val place = io.StdIn.readLine().split(' ').map({ _.toInt })\n val time = place(0) - prev_place(0)\n val move = place.zip(prev_place).map({ case (x, y) => x-y }).drop(1)\n\n if (move.sum > time)\n result = false\n\n if ((time + move.sum) % 2 == 1)\n result = false\n\n prev_place = place\n i += 1\n }\n\n if (result == true)\n println(\"Yes\")\n else\n println(\"No\")\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "sample_input": "2\n3 1 2\n6 1 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03459", "source_text": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 906, "memory_kb": 62384}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s366690164", "group_id": "codeNet:p03460", "input_text": "object Main extends App {\n val Array(n, k) = io.StdIn.readLine().split(' ').map(_.toInt)\n val k2 = k*2\n val end = k2-1\n // 0 ≦ x,y ≦ 2K に圧縮\n val squares = Array.fill(k2)(Array.fill(k2)(0))\n for (i <- 1 to n) {\n val Array(x, y, color) = io.StdIn.readLine().split(' ')\n // 'W'はY方向にKずらした'B'と同値\n squares(x.toInt % k2)((y.toInt + (if (color == \"B\") 0 else k)) % k2) += 1\n }\n // 計算量削減のために累積和を事前算出\n for {\n i <- 0 to end\n j <- 1 to end\n } squares(i)(j) += squares(i)(j-1)\n for {\n j <- 0 to end\n i <- 1 to end\n } squares(i)(j) += squares(i-1)(j)\n val max = (for {\n i <- 0 to k-1\n j <- 0 to k-1\n } yield {\n // ex) k = 2\n // ■ □ □ ■ \n // j+k □ ■ ■ □\n // □ ■ ■ □\n // j ■ □ □ ■\n // i i+k\n val cnt =\n (squares(i)(j)) +\n (squares(end)(j) - squares(i+k)(j)) +\n (squares(i+k)(j+k) - squares(i+k)(j) - squares(i)(j+k) + squares(i)(j)) +\n (squares(i)(end) - squares(i)(j+k)) +\n (squares(end)(end) - squares(end)(j+k) - squares(i+k)(end) + squares(i+k)(j+k))\n Math.max(cnt, n - cnt)\n }).max\n print(max)\n}\n", "language": "Scala", "metadata": {"date": 1525874352, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03460.html", "problem_id": "p03460", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03460/input.txt", "sample_output_relpath": "derived/input_output/data/p03460/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03460/Scala/s366690164.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s366690164", "user_id": "u006018820"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "object Main extends App {\n val Array(n, k) = io.StdIn.readLine().split(' ').map(_.toInt)\n val k2 = k*2\n val end = k2-1\n // 0 ≦ x,y ≦ 2K に圧縮\n val squares = Array.fill(k2)(Array.fill(k2)(0))\n for (i <- 1 to n) {\n val Array(x, y, color) = io.StdIn.readLine().split(' ')\n // 'W'はY方向にKずらした'B'と同値\n squares(x.toInt % k2)((y.toInt + (if (color == \"B\") 0 else k)) % k2) += 1\n }\n // 計算量削減のために累積和を事前算出\n for {\n i <- 0 to end\n j <- 1 to end\n } squares(i)(j) += squares(i)(j-1)\n for {\n j <- 0 to end\n i <- 1 to end\n } squares(i)(j) += squares(i-1)(j)\n val max = (for {\n i <- 0 to k-1\n j <- 0 to k-1\n } yield {\n // ex) k = 2\n // ■ □ □ ■ \n // j+k □ ■ ■ □\n // □ ■ ■ □\n // j ■ □ □ ■\n // i i+k\n val cnt =\n (squares(i)(j)) +\n (squares(end)(j) - squares(i+k)(j)) +\n (squares(i+k)(j+k) - squares(i+k)(j) - squares(i)(j+k) + squares(i)(j)) +\n (squares(i)(end) - squares(i)(j+k)) +\n (squares(end)(end) - squares(end)(j+k) - squares(i+k)(end) + squares(i+k)(j+k))\n Math.max(cnt, n - cnt)\n }).max\n print(max)\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nAtCoDeer is thinking of painting an infinite two-dimensional grid in a checked pattern of side K.\nHere, a checked pattern of side K is a pattern where each square is painted black or white so that each connected component of each color is a K × K square.\nBelow is an example of a checked pattern of side 3:\n\nAtCoDeer has N desires.\nThe i-th desire is represented by x_i, y_i and c_i.\nIf c_i is B, it means that he wants to paint the square (x_i,y_i) black; if c_i is W, he wants to paint the square (x_i,y_i) white.\nAt most how many desires can he satisfy at the same time?\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n1 ≤ K ≤ 1000\n\n0 ≤ x_i ≤ 10^9\n\n0 ≤ y_i ≤ 10^9\n\nIf i ≠ j, then (x_i,y_i) ≠ (x_j,y_j).\n\nc_i is B or W.\n\nN, K, x_i and y_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nx_1 y_1 c_1\nx_2 y_2 c_2\n:\nx_N y_N c_N\n\nOutput\n\nPrint the maximum number of desires that can be satisfied at the same time.\n\nSample Input 1\n\n4 3\n0 1 W\n1 2 W\n5 3 B\n5 4 B\n\nSample Output 1\n\n4\n\nHe can satisfy all his desires by painting as shown in the example above.\n\nSample Input 2\n\n2 1000\n0 0 B\n0 1 W\n\nSample Output 2\n\n2\n\nSample Input 3\n\n6 2\n1 2 B\n2 1 W\n2 2 B\n1 0 B\n0 6 W\n4 5 W\n\nSample Output 3\n\n4", "sample_input": "4 3\n0 1 W\n1 2 W\n5 3 B\n5 4 B\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03460", "source_text": "Score : 500 points\n\nProblem Statement\n\nAtCoDeer is thinking of painting an infinite two-dimensional grid in a checked pattern of side K.\nHere, a checked pattern of side K is a pattern where each square is painted black or white so that each connected component of each color is a K × K square.\nBelow is an example of a checked pattern of side 3:\n\nAtCoDeer has N desires.\nThe i-th desire is represented by x_i, y_i and c_i.\nIf c_i is B, it means that he wants to paint the square (x_i,y_i) black; if c_i is W, he wants to paint the square (x_i,y_i) white.\nAt most how many desires can he satisfy at the same time?\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n1 ≤ K ≤ 1000\n\n0 ≤ x_i ≤ 10^9\n\n0 ≤ y_i ≤ 10^9\n\nIf i ≠ j, then (x_i,y_i) ≠ (x_j,y_j).\n\nc_i is B or W.\n\nN, K, x_i and y_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nx_1 y_1 c_1\nx_2 y_2 c_2\n:\nx_N y_N c_N\n\nOutput\n\nPrint the maximum number of desires that can be satisfied at the same time.\n\nSample Input 1\n\n4 3\n0 1 W\n1 2 W\n5 3 B\n5 4 B\n\nSample Output 1\n\n4\n\nHe can satisfy all his desires by painting as shown in the example above.\n\nSample Input 2\n\n2 1000\n0 0 B\n0 1 W\n\nSample Output 2\n\n2\n\nSample Input 3\n\n6 2\n1 2 B\n2 1 W\n2 2 B\n1 0 B\n0 6 W\n4 5 W\n\nSample Output 3\n\n4", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1196, "cpu_time_ms": 1167, "memory_kb": 103448}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s115844766", "group_id": "codeNet:p03463", "input_text": "import scala.io.StdIn._\n\nobject Main extends App {\n val Array(n, a, b) = readLine().split(\" \").map(_.toInt)\n if (math.abs(b - a) % 2 == 1) println(\"Borys\") else println(\"Alice\")\n}\n", "language": "Scala", "metadata": {"date": 1515982000, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s115844766.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s115844766", "user_id": "u478134456"}, "prompt_components": {"gold_output": "Alice\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main extends App {\n val Array(n, a, b) = readLine().split(\" \").map(_.toInt)\n if (math.abs(b - a) % 2 == 1) println(\"Borys\") else println(\"Alice\")\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 323, "memory_kb": 25668}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s295223304", "group_id": "codeNet:p03464", "input_text": "object Main extends App {\n\tval temp = scala.io.StdIn.readInt\n\tval A = scala.io.StdIn.readLine.split(\" \").map(_.toLong).reverse\n\n\tvar N = List[Long](2L)\n\n\tdef test(x: Long, y: List[Long]): List[Long] = {\n\t\tvar list = y\n\t\tfor(i<-1L until x){\n\t\t\tlist = list ::: y.map(_ + i)\n\t\t}\n\t\tlist\n\t}\n\n\tfor(i<-0 until temp){\n\t\tN = N.filter(_ >= A(i)).filter(_%A(i) == 0)\n\t\tN = test(A(i), N)\t\t\n\t}\n\t\n\tif(N == Nil) println(-1)\n\telse println(s\"${N.min} ${N.max}\")\n}", "language": "Scala", "metadata": {"date": 1516123762, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s295223304.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s295223304", "user_id": "u675876401"}, "prompt_components": {"gold_output": "6 8\n", "input_to_evaluate": "object Main extends App {\n\tval temp = scala.io.StdIn.readInt\n\tval A = scala.io.StdIn.readLine.split(\" \").map(_.toLong).reverse\n\n\tvar N = List[Long](2L)\n\n\tdef test(x: Long, y: List[Long]): List[Long] = {\n\t\tvar list = y\n\t\tfor(i<-1L until x){\n\t\t\tlist = list ::: y.map(_ + i)\n\t\t}\n\t\tlist\n\t}\n\n\tfor(i<-0 until temp){\n\t\tN = N.filter(_ >= A(i)).filter(_%A(i) == 0)\n\t\tN = test(A(i), N)\t\t\n\t}\n\t\n\tif(N == Nil) println(-1)\n\telse println(s\"${N.min} ${N.max}\")\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 128932}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s592192223", "group_id": "codeNet:p03470", "input_text": "import scala.io.StdIn._\n\nobject Main extends App {\n val n = readInt()\n val d = List.fill(n)(readInt()).sorted.toSet\n println(d.size)\n}\n", "language": "Scala", "metadata": {"date": 1515377932, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s592192223.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s592192223", "user_id": "u478134456"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main extends App {\n val n = readInt()\n val d = List.fill(n)(readInt()).sorted.toSet\n println(d.size)\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 138, "cpu_time_ms": 332, "memory_kb": 27180}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s487000215", "group_id": "codeNet:p03474", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n val Array(a, b) = StdIn.readLine().split(' ').map(_.toInt)\n val s = StdIn.readLine()\n val r = s.slice(0, a) + s.slice(a+1, s.length)\n //println(r)\n println(if(s.length == (a + b + 1) && s.charAt(a) == '-' && r.forall(p => p.isDigit)) \"Yes\" else \"No\")\n}\n", "language": "Scala", "metadata": {"date": 1526773096, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s487000215.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s487000215", "user_id": "u895032849"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n val Array(a, b) = StdIn.readLine().split(' ').map(_.toInt)\n val s = StdIn.readLine()\n val r = s.slice(0, a) + s.slice(a+1, s.length)\n //println(r)\n println(if(s.length == (a + b + 1) && s.charAt(a) == '-' && r.forall(p => p.isDigit)) \"Yes\" else \"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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 308, "cpu_time_ms": 322, "memory_kb": 27460}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s430951941", "group_id": "codeNet:p03476", "input_text": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\nimport java.lang\n\nimport scala.annotation.tailrec\nimport scala.collection.mutable.ArrayBuffer\nimport scala.reflect.ClassTag\n\nobject Main {\n def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {\n converter(in.readLine)\n }\n\n def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {\n get[String].split(\"\\\\s+\").map[T](converter)\n }\n\n implicit val idConverter: String => String = s => s\n implicit val intConverter: String => Int = s => Integer.parseInt(s)\n implicit val longConverter: String => Long = s => lang.Long.parseLong(s)\n\n def get[T1, T2](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2\n ): (T1, T2) = {\n getArray[String] match {\n case Array(v1, v2) => (converter1(v1), converter2(v2))\n }\n }\n\n def get[T1, T2, T3](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3\n ): (T1, T2, T3) = {\n getArray[String] match {\n case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))\n }\n }\n\n def get[T1, T2, T3, T4](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3,\n converter4: String => T4\n ): (T1, T2, T3, T4) = {\n getArray[String] match {\n case Array(v1, v2, v3, v4) => (converter1(v1), converter2(v2), converter3(v3), converter4(v4))\n }\n }\n\n implicit class TimesInt(val n: Int) {\n def times(f: Int => Unit): Unit = {\n for (i <- 0 until n) {\n f(i)\n }\n }\n }\n\n def primes(n: Long): ArrayBuffer[Long] = {\n val buf = ArrayBuffer.empty[Long]\n val s = Math.sqrt(n).toInt\n\n var v = n\n for (i <- 2 to s) {\n if (v == 1 || v == 0) {\n return buf\n } else {\n while (v % i == 0) {\n buf.append(i)\n v /= i\n }\n }\n }\n if (v > s) {\n buf.append(v)\n }\n buf\n }\n\n def divisors(n: Int): ArrayBuffer[Int] = {\n val buf = ArrayBuffer.empty[Int]\n val s = Math.sqrt(n).toInt\n\n for (i <- 1 to s) {\n if (n % i == 0) {\n buf.append(i)\n if (i != n / i) {\n buf.append(n / i)\n }\n }\n }\n buf\n }\n\n @tailrec\n def gcd(a: Long, b: Long): Long = {\n val reminder = a % b\n if (reminder == 0) {\n b\n } else {\n gcd(b, reminder)\n }\n }\n\n @tailrec\n def gcd(a: Int, b: Int): Int = {\n val reminder = a % b\n if (reminder == 0) {\n b\n } else {\n gcd(b, reminder)\n }\n }\n\n def lcm(a: Long, b: Long): Long = {\n a / gcd(a, b) * b\n }\n\n def toBitArray(n: Int, width: Int): Array[Boolean] = {\n val buf = ArrayBuffer.fill(width)(false)\n\n @tailrec\n def inner(n: Int, i: Int): Array[Boolean] = {\n buf(i) = (n & 1) == 0\n if (i == 0) {\n buf.toArray\n } else {\n inner(n / 2, i - 1)\n }\n }\n\n inner(n, width - 1)\n }\n\n def modpow(n: Long, p: Long, m: Long): Long = {\n @tailrec\n def inner(n: Long, p: Long, acc: Long): Long = {\n if (p == 0) {\n acc\n } else if ((p & 1) == 0) {\n inner(n * n % m, p >> 1, acc)\n } else {\n inner(n * n % m, p >> 1, acc * n % m)\n }\n }\n\n inner(n % m, p, 1)\n }\n\n def main(args: Array[String]): Unit = {\n implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n val q = get[Int]\n\n val isPrimes = Array.fill(100001)(true)\n\n isPrimes(1) = false\n for (i <- 2 to 50000) {\n if (isPrimes(i)) {\n @tailrec\n def erasePrimes(k: Int): Unit = {\n val newI = i * k\n if (newI <= 100000) {\n isPrimes(newI) = false\n erasePrimes(k + 1)\n }\n }\n\n erasePrimes(2)\n }\n }\n\n val is2017Likes = Array.fill(100001)(false)\n for (i <- 3 to 100000 by 2) {\n is2017Likes(i) = isPrimes(i) && isPrimes((i + 1) / 2)\n }\n\n val is2017LikesSum = Array.fill(100001)(0)\n for (i <- 1 until is2017LikesSum.length) {\n if (is2017Likes(i)) {\n is2017LikesSum(i) = is2017LikesSum(i - 1) + 1\n } else {\n is2017LikesSum(i) = is2017LikesSum(i - 1)\n }\n }\n\n for ((l, r) <- Array.fill(q)(get[Int, Int])) {\n out.println(is2017LikesSum(r) - is2017LikesSum(l - 1))\n }\n\n out.flush()\n }\n}", "language": "Scala", "metadata": {"date": 1597497590, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03476.html", "problem_id": "p03476", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03476/input.txt", "sample_output_relpath": "derived/input_output/data/p03476/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03476/Scala/s430951941.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s430951941", "user_id": "u178269371"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\nimport java.lang\n\nimport scala.annotation.tailrec\nimport scala.collection.mutable.ArrayBuffer\nimport scala.reflect.ClassTag\n\nobject Main {\n def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {\n converter(in.readLine)\n }\n\n def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {\n get[String].split(\"\\\\s+\").map[T](converter)\n }\n\n implicit val idConverter: String => String = s => s\n implicit val intConverter: String => Int = s => Integer.parseInt(s)\n implicit val longConverter: String => Long = s => lang.Long.parseLong(s)\n\n def get[T1, T2](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2\n ): (T1, T2) = {\n getArray[String] match {\n case Array(v1, v2) => (converter1(v1), converter2(v2))\n }\n }\n\n def get[T1, T2, T3](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3\n ): (T1, T2, T3) = {\n getArray[String] match {\n case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))\n }\n }\n\n def get[T1, T2, T3, T4](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3,\n converter4: String => T4\n ): (T1, T2, T3, T4) = {\n getArray[String] match {\n case Array(v1, v2, v3, v4) => (converter1(v1), converter2(v2), converter3(v3), converter4(v4))\n }\n }\n\n implicit class TimesInt(val n: Int) {\n def times(f: Int => Unit): Unit = {\n for (i <- 0 until n) {\n f(i)\n }\n }\n }\n\n def primes(n: Long): ArrayBuffer[Long] = {\n val buf = ArrayBuffer.empty[Long]\n val s = Math.sqrt(n).toInt\n\n var v = n\n for (i <- 2 to s) {\n if (v == 1 || v == 0) {\n return buf\n } else {\n while (v % i == 0) {\n buf.append(i)\n v /= i\n }\n }\n }\n if (v > s) {\n buf.append(v)\n }\n buf\n }\n\n def divisors(n: Int): ArrayBuffer[Int] = {\n val buf = ArrayBuffer.empty[Int]\n val s = Math.sqrt(n).toInt\n\n for (i <- 1 to s) {\n if (n % i == 0) {\n buf.append(i)\n if (i != n / i) {\n buf.append(n / i)\n }\n }\n }\n buf\n }\n\n @tailrec\n def gcd(a: Long, b: Long): Long = {\n val reminder = a % b\n if (reminder == 0) {\n b\n } else {\n gcd(b, reminder)\n }\n }\n\n @tailrec\n def gcd(a: Int, b: Int): Int = {\n val reminder = a % b\n if (reminder == 0) {\n b\n } else {\n gcd(b, reminder)\n }\n }\n\n def lcm(a: Long, b: Long): Long = {\n a / gcd(a, b) * b\n }\n\n def toBitArray(n: Int, width: Int): Array[Boolean] = {\n val buf = ArrayBuffer.fill(width)(false)\n\n @tailrec\n def inner(n: Int, i: Int): Array[Boolean] = {\n buf(i) = (n & 1) == 0\n if (i == 0) {\n buf.toArray\n } else {\n inner(n / 2, i - 1)\n }\n }\n\n inner(n, width - 1)\n }\n\n def modpow(n: Long, p: Long, m: Long): Long = {\n @tailrec\n def inner(n: Long, p: Long, acc: Long): Long = {\n if (p == 0) {\n acc\n } else if ((p & 1) == 0) {\n inner(n * n % m, p >> 1, acc)\n } else {\n inner(n * n % m, p >> 1, acc * n % m)\n }\n }\n\n inner(n % m, p, 1)\n }\n\n def main(args: Array[String]): Unit = {\n implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n val q = get[Int]\n\n val isPrimes = Array.fill(100001)(true)\n\n isPrimes(1) = false\n for (i <- 2 to 50000) {\n if (isPrimes(i)) {\n @tailrec\n def erasePrimes(k: Int): Unit = {\n val newI = i * k\n if (newI <= 100000) {\n isPrimes(newI) = false\n erasePrimes(k + 1)\n }\n }\n\n erasePrimes(2)\n }\n }\n\n val is2017Likes = Array.fill(100001)(false)\n for (i <- 3 to 100000 by 2) {\n is2017Likes(i) = isPrimes(i) && isPrimes((i + 1) / 2)\n }\n\n val is2017LikesSum = Array.fill(100001)(0)\n for (i <- 1 until is2017LikesSum.length) {\n if (is2017Likes(i)) {\n is2017LikesSum(i) = is2017LikesSum(i - 1) + 1\n } else {\n is2017LikesSum(i) = is2017LikesSum(i - 1)\n }\n }\n\n for ((l, r) <- Array.fill(q)(get[Int, Int])) {\n out.println(is2017LikesSum(r) - is2017LikesSum(l - 1))\n }\n\n out.flush()\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe say that a odd number N is similar to 2017 when both N and (N+1)/2 are prime.\n\nYou are given Q queries.\n\nIn the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i.\n\nConstraints\n\n1≤Q≤10^5\n\n1≤l_i≤r_i≤10^5\n\nl_i and r_i are odd.\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ\nl_1 r_1\n:\nl_Q r_Q\n\nOutput\n\nPrint Q lines. The i-th line (1≤i≤Q) should contain the response to the i-th query.\n\nSample Input 1\n\n1\n3 7\n\nSample Output 1\n\n2\n\n3 is similar to 2017, since both 3 and (3+1)/2=2 are prime.\n\n5 is similar to 2017, since both 5 and (5+1)/2=3 are prime.\n\n7 is not similar to 2017, since (7+1)/2=4 is not prime, although 7 is prime.\n\nThus, the response to the first query should be 2.\n\nSample Input 2\n\n4\n13 13\n7 11\n7 11\n2017 2017\n\nSample Output 2\n\n1\n0\n0\n1\n\nNote that 2017 is also similar to 2017.\n\nSample Input 3\n\n6\n1 53\n13 91\n37 55\n19 51\n73 91\n13 49\n\nSample Output 3\n\n4\n4\n1\n1\n1\n2", "sample_input": "1\n3 7\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03476", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe say that a odd number N is similar to 2017 when both N and (N+1)/2 are prime.\n\nYou are given Q queries.\n\nIn the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i.\n\nConstraints\n\n1≤Q≤10^5\n\n1≤l_i≤r_i≤10^5\n\nl_i and r_i are odd.\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ\nl_1 r_1\n:\nl_Q r_Q\n\nOutput\n\nPrint Q lines. The i-th line (1≤i≤Q) should contain the response to the i-th query.\n\nSample Input 1\n\n1\n3 7\n\nSample Output 1\n\n2\n\n3 is similar to 2017, since both 3 and (3+1)/2=2 are prime.\n\n5 is similar to 2017, since both 5 and (5+1)/2=3 are prime.\n\n7 is not similar to 2017, since (7+1)/2=4 is not prime, although 7 is prime.\n\nThus, the response to the first query should be 2.\n\nSample Input 2\n\n4\n13 13\n7 11\n7 11\n2017 2017\n\nSample Output 2\n\n1\n0\n0\n1\n\nNote that 2017 is also similar to 2017.\n\nSample Input 3\n\n6\n1 53\n13 91\n37 55\n19 51\n73 91\n13 49\n\nSample Output 3\n\n4\n4\n1\n1\n1\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4777, "cpu_time_ms": 991, "memory_kb": 66736}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s009621551", "group_id": "codeNet:p03476", "input_text": "import java.util.Scanner\n\nobject Main {\n def read() = {\n val sc = new Scanner(System.in)\n val q = sc.nextInt()\n val ranges = for (_ <- 0 until q) yield Range(sc.nextInt(), sc.nextInt())\n (q, ranges)\n }\n\n case class Range(min: Int, max: Int) {\n }\n\n val numMax = 100001\n val isPrimeAsTable: Vector[Boolean] = {\n val n = numMax\n val primeBitmap = Array.fill(n)(true)\n primeBitmap(0) = false\n primeBitmap(1) = false\n\n for (i <- 2 until Math.sqrt(n).toInt) {\n if (primeBitmap(i)) {\n // i is prime\n val multipleOfI = (2 * i until n).filter(j => j % i == 0)\n multipleOfI.foreach(j => primeBitmap(j) = false)\n }\n }\n primeBitmap.toVector\n }\n\n def isOdd(n: Int) = n % 2 == 1\n\n def like2017(n: Int): Boolean = isOdd(n) && isPrimeAsTable(n) && isPrimeAsTable((n + 1) / 2)\n\n val isLike2017AsTable: Vector[Boolean] = {\n val n = numMax\n (0 until n).map(like2017).toVector\n }\n\n // cumulativeSum(Vector(a_0,a_1,a_2)) =\n // Vector\n // (0,\n // a_0,\n // a_0 + a_1,\n // a_0 + a_1 + a_2)\n def cumulativeSum[T](a: Vector[T])(implicit num: Numeric[T]): Vector[T] = {\n a.scanLeft(num.zero)(num.plus)\n }\n\n // countLike2017Until(n) = #{k | k<-{0,1,2...,n-1}, kはlike2017}\n val countLike2017Until: Vector[Int] = cumulativeSum(isLike2017AsTable.map(if (_) 1 else 0))\n\n def countLike2017(range: Range) = {\n countLike2017Until(range.max + 1) - countLike2017Until(range.min)\n }\n\n def main(args: Array[String]): Unit = {\n val (_, ranges) = read()\n for (range <- ranges) {\n val result = countLike2017(range)\n println(result)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1515404767, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03476.html", "problem_id": "p03476", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03476/input.txt", "sample_output_relpath": "derived/input_output/data/p03476/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03476/Scala/s009621551.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s009621551", "user_id": "u494788559"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def read() = {\n val sc = new Scanner(System.in)\n val q = sc.nextInt()\n val ranges = for (_ <- 0 until q) yield Range(sc.nextInt(), sc.nextInt())\n (q, ranges)\n }\n\n case class Range(min: Int, max: Int) {\n }\n\n val numMax = 100001\n val isPrimeAsTable: Vector[Boolean] = {\n val n = numMax\n val primeBitmap = Array.fill(n)(true)\n primeBitmap(0) = false\n primeBitmap(1) = false\n\n for (i <- 2 until Math.sqrt(n).toInt) {\n if (primeBitmap(i)) {\n // i is prime\n val multipleOfI = (2 * i until n).filter(j => j % i == 0)\n multipleOfI.foreach(j => primeBitmap(j) = false)\n }\n }\n primeBitmap.toVector\n }\n\n def isOdd(n: Int) = n % 2 == 1\n\n def like2017(n: Int): Boolean = isOdd(n) && isPrimeAsTable(n) && isPrimeAsTable((n + 1) / 2)\n\n val isLike2017AsTable: Vector[Boolean] = {\n val n = numMax\n (0 until n).map(like2017).toVector\n }\n\n // cumulativeSum(Vector(a_0,a_1,a_2)) =\n // Vector\n // (0,\n // a_0,\n // a_0 + a_1,\n // a_0 + a_1 + a_2)\n def cumulativeSum[T](a: Vector[T])(implicit num: Numeric[T]): Vector[T] = {\n a.scanLeft(num.zero)(num.plus)\n }\n\n // countLike2017Until(n) = #{k | k<-{0,1,2...,n-1}, kはlike2017}\n val countLike2017Until: Vector[Int] = cumulativeSum(isLike2017AsTable.map(if (_) 1 else 0))\n\n def countLike2017(range: Range) = {\n countLike2017Until(range.max + 1) - countLike2017Until(range.min)\n }\n\n def main(args: Array[String]): Unit = {\n val (_, ranges) = read()\n for (range <- ranges) {\n val result = countLike2017(range)\n println(result)\n }\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe say that a odd number N is similar to 2017 when both N and (N+1)/2 are prime.\n\nYou are given Q queries.\n\nIn the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i.\n\nConstraints\n\n1≤Q≤10^5\n\n1≤l_i≤r_i≤10^5\n\nl_i and r_i are odd.\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ\nl_1 r_1\n:\nl_Q r_Q\n\nOutput\n\nPrint Q lines. The i-th line (1≤i≤Q) should contain the response to the i-th query.\n\nSample Input 1\n\n1\n3 7\n\nSample Output 1\n\n2\n\n3 is similar to 2017, since both 3 and (3+1)/2=2 are prime.\n\n5 is similar to 2017, since both 5 and (5+1)/2=3 are prime.\n\n7 is not similar to 2017, since (7+1)/2=4 is not prime, although 7 is prime.\n\nThus, the response to the first query should be 2.\n\nSample Input 2\n\n4\n13 13\n7 11\n7 11\n2017 2017\n\nSample Output 2\n\n1\n0\n0\n1\n\nNote that 2017 is also similar to 2017.\n\nSample Input 3\n\n6\n1 53\n13 91\n37 55\n19 51\n73 91\n13 49\n\nSample Output 3\n\n4\n4\n1\n1\n1\n2", "sample_input": "1\n3 7\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03476", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe say that a odd number N is similar to 2017 when both N and (N+1)/2 are prime.\n\nYou are given Q queries.\n\nIn the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i.\n\nConstraints\n\n1≤Q≤10^5\n\n1≤l_i≤r_i≤10^5\n\nl_i and r_i are odd.\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ\nl_1 r_1\n:\nl_Q r_Q\n\nOutput\n\nPrint Q lines. The i-th line (1≤i≤Q) should contain the response to the i-th query.\n\nSample Input 1\n\n1\n3 7\n\nSample Output 1\n\n2\n\n3 is similar to 2017, since both 3 and (3+1)/2=2 are prime.\n\n5 is similar to 2017, since both 5 and (5+1)/2=3 are prime.\n\n7 is not similar to 2017, since (7+1)/2=4 is not prime, although 7 is prime.\n\nThus, the response to the first query should be 2.\n\nSample Input 2\n\n4\n13 13\n7 11\n7 11\n2017 2017\n\nSample Output 2\n\n1\n0\n0\n1\n\nNote that 2017 is also similar to 2017.\n\nSample Input 3\n\n6\n1 53\n13 91\n37 55\n19 51\n73 91\n13 49\n\nSample Output 3\n\n4\n4\n1\n1\n1\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1619, "cpu_time_ms": 1808, "memory_kb": 110728}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s384172801", "group_id": "codeNet:p03477", "input_text": "import scala.io.StdIn\n\nobject Main{\n\n val line = StdIn.readLine().split(\" \").map(_.toInt).toList.splitAt(2)\n\n def solve(input: (List[Int], List[Int])): String = {\n val result = input._1.sum - input._2.sum\n if(result > 0){\n \"Left\"\n } else if (result < 0){\n \"Right\"\n } else {\n \"Balanced\"\n }\n }\n\n println(solve(line))\n}\n\n", "language": "Scala", "metadata": {"date": 1520060785, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03477.html", "problem_id": "p03477", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03477/input.txt", "sample_output_relpath": "derived/input_output/data/p03477/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03477/Scala/s384172801.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s384172801", "user_id": "u159043787"}, "prompt_components": {"gold_output": "Left\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main{\n\n val line = StdIn.readLine().split(\" \").map(_.toInt).toList.splitAt(2)\n\n def solve(input: (List[Int], List[Int])): String = {\n val result = input._1.sum - input._2.sum\n if(result > 0){\n \"Left\"\n } else if (result < 0){\n \"Right\"\n } else {\n \"Balanced\"\n }\n }\n\n println(solve(line))\n}\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L8, we should print Left.\n\nSample Input 2\n\n3 4 5 2\n\nSample Output 2\n\nBalanced\n\nThe total weight of the masses on the left pan is 7, and the total weight of the masses on the right pan is 7. Since 7=7, we should print Balanced.\n\nSample Input 3\n\n1 7 6 4\n\nSample Output 3\n\nRight\n\nThe total weight of the masses on the left pan is 8, and the total weight of the masses on the right pan is 10. Since 8<10, we should print Right.", "sample_input": "3 8 7 1\n"}, "reference_outputs": ["Left\n"], "source_document_id": "p03477", "source_text": "Score : 100 points\n\nProblem Statement\n\nA balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L8, we should print Left.\n\nSample Input 2\n\n3 4 5 2\n\nSample Output 2\n\nBalanced\n\nThe total weight of the masses on the left pan is 7, and the total weight of the masses on the right pan is 7. Since 7=7, we should print Balanced.\n\nSample Input 3\n\n1 7 6 4\n\nSample Output 3\n\nRight\n\nThe total weight of the masses on the left pan is 8, and the total weight of the masses on the right pan is 10. Since 8<10, we should print Right.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 322, "memory_kb": 25412}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s108326104", "group_id": "codeNet:p03477", "input_text": "object Main {\ndef main(args: Array[String]): Unit = {\n val in = readLine.split(\" \").map(_.toInt)\n val a = in(0)\n val b = in(1)\n val c = in(2)\n val d = in(3)\n\n val lw = a + b\n val rw = c + d\n if (lw > rw){\n print(\"Left\")\n } else if(lw == rw){\n print(\"Balanced\")\n } else{\n print(\"Right\")\n }\n }\n}", "language": "Scala", "metadata": {"date": 1514081007, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03477.html", "problem_id": "p03477", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03477/input.txt", "sample_output_relpath": "derived/input_output/data/p03477/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03477/Scala/s108326104.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s108326104", "user_id": "u173561231"}, "prompt_components": {"gold_output": "Left\n", "input_to_evaluate": "object Main {\ndef main(args: Array[String]): Unit = {\n val in = readLine.split(\" \").map(_.toInt)\n val a = in(0)\n val b = in(1)\n val c = in(2)\n val d = in(3)\n\n val lw = a + b\n val rw = c + d\n if (lw > rw){\n print(\"Left\")\n } else if(lw == rw){\n print(\"Balanced\")\n } else{\n print(\"Right\")\n }\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L8, we should print Left.\n\nSample Input 2\n\n3 4 5 2\n\nSample Output 2\n\nBalanced\n\nThe total weight of the masses on the left pan is 7, and the total weight of the masses on the right pan is 7. Since 7=7, we should print Balanced.\n\nSample Input 3\n\n1 7 6 4\n\nSample Output 3\n\nRight\n\nThe total weight of the masses on the left pan is 8, and the total weight of the masses on the right pan is 10. Since 8<10, we should print Right.", "sample_input": "3 8 7 1\n"}, "reference_outputs": ["Left\n"], "source_document_id": "p03477", "source_text": "Score : 100 points\n\nProblem Statement\n\nA balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L8, we should print Left.\n\nSample Input 2\n\n3 4 5 2\n\nSample Output 2\n\nBalanced\n\nThe total weight of the masses on the left pan is 7, and the total weight of the masses on the right pan is 7. Since 7=7, we should print Balanced.\n\nSample Input 3\n\n1 7 6 4\n\nSample Output 3\n\nRight\n\nThe total weight of the masses on the left pan is 8, and the total weight of the masses on the right pan is 10. Since 8<10, we should print Right.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 342, "cpu_time_ms": 323, "memory_kb": 25400}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s371611261", "group_id": "codeNet:p03481", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val X, Y = sc.nextLong()\n println(LazyList.from(0).map(math.pow(2, _) * X).takeWhile(_ <= Y).length)\n}\n", "language": "Scala", "metadata": {"date": 1593979459, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03481.html", "problem_id": "p03481", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03481/input.txt", "sample_output_relpath": "derived/input_output/data/p03481/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03481/Scala/s371611261.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s371611261", "user_id": "u737111725"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val X, Y = sc.nextLong()\n println(LazyList.from(0).map(math.pow(2, _) * X).takeWhile(_ <= Y).length)\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": "p03481", "source_text": "Score : 300 points\n\nProblem Statement\n\nAs a token of his gratitude, Takahashi has decided to give his mother an integer sequence.\nThe sequence A needs to satisfy the conditions below:\n\nA consists of integers between X and Y (inclusive).\n\nFor each 1\\leq i \\leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i.\n\nFind the maximum possible length of the sequence.\n\nConstraints\n\n1 \\leq X \\leq Y \\leq 10^{18}\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the maximum possible length of the sequence.\n\nSample Input 1\n\n3 20\n\nSample Output 1\n\n3\n\nThe sequence 3,6,18 satisfies the conditions.\n\nSample Input 2\n\n25 100\n\nSample Output 2\n\n3\n\nSample Input 3\n\n314159265 358979323846264338\n\nSample Output 3\n\n31", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 512, "memory_kb": 55320}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s449416576", "group_id": "codeNet:p03485", "input_text": "object Main extends App {\n import scala.math.ceil\n val Array(a,b) = readLine split(\" \") map{_.toDouble}\n println(ceil((a+b)/2).toInt)\n}", "language": "Scala", "metadata": {"date": 1575914848, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03485.html", "problem_id": "p03485", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03485/input.txt", "sample_output_relpath": "derived/input_output/data/p03485/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03485/Scala/s449416576.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s449416576", "user_id": "u696665136"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n import scala.math.ceil\n val Array(a,b) = readLine split(\" \") map{_.toDouble}\n println(ceil((a+b)/2).toInt)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given two positive integers a and b.\nLet x be the average of a and b.\nPrint x rounded up to the nearest integer.\n\nConstraints\n\na and b are integers.\n\n1 \\leq a, b \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint x rounded up to the nearest integer.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\n2\n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest integer, 2.\n\nSample Input 2\n\n7 4\n\nSample Output 2\n\n6\n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest integer, 6.\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\n5", "sample_input": "1 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03485", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given two positive integers a and b.\nLet x be the average of a and b.\nPrint x rounded up to the nearest integer.\n\nConstraints\n\na and b are integers.\n\n1 \\leq a, b \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint x rounded up to the nearest integer.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\n2\n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest integer, 2.\n\nSample Input 2\n\n7 4\n\nSample Output 2\n\n6\n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest integer, 6.\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 138, "cpu_time_ms": 327, "memory_kb": 27300}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s060612689", "group_id": "codeNet:p03485", "input_text": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]) {\n if (args.length > 0 && args(0) == \"TEST\") {\n println(test())\n } else {\n val input = io.Source.stdin.getLines().mkString(\"\\n\")\n println(solve(input).trim())\n }\n }\n\n def solve(input: String): String = {\n val s: Scanner = new Scanner(input)\n val a,b = s.nextInt\n ((a + b) / 2.0).ceil.toInt.toString\n }\n\n val tests = List(\n \"\"\"1 3\"\"\".stripMargin -> \"\"\"2\"\"\",\n \"\"\"7 4\"\"\".stripMargin -> \"\"\"6\"\"\",\n \"\"\"5 5\"\"\" -> \"5\"\n )\n\n def test(): String = tests.map { case (i, o) => (i.trim(), o.trim()) }\n .zipWithIndex.map {\n case ((input, outputExpect), i) =>\n val output = solve(input).trim()\n val tnum = i + 1\n s\"test$tnum:\" + (\n if (output == outputExpect) \"Passed\"\n else s\"Failed\\nexpect:\\n$outputExpect\\noutput:\\n$output\")\n }\n .mkString(\"\\n\")\n}", "language": "Scala", "metadata": {"date": 1563740807, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03485.html", "problem_id": "p03485", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03485/input.txt", "sample_output_relpath": "derived/input_output/data/p03485/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03485/Scala/s060612689.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s060612689", "user_id": "u334087399"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]) {\n if (args.length > 0 && args(0) == \"TEST\") {\n println(test())\n } else {\n val input = io.Source.stdin.getLines().mkString(\"\\n\")\n println(solve(input).trim())\n }\n }\n\n def solve(input: String): String = {\n val s: Scanner = new Scanner(input)\n val a,b = s.nextInt\n ((a + b) / 2.0).ceil.toInt.toString\n }\n\n val tests = List(\n \"\"\"1 3\"\"\".stripMargin -> \"\"\"2\"\"\",\n \"\"\"7 4\"\"\".stripMargin -> \"\"\"6\"\"\",\n \"\"\"5 5\"\"\" -> \"5\"\n )\n\n def test(): String = tests.map { case (i, o) => (i.trim(), o.trim()) }\n .zipWithIndex.map {\n case ((input, outputExpect), i) =>\n val output = solve(input).trim()\n val tnum = i + 1\n s\"test$tnum:\" + (\n if (output == outputExpect) \"Passed\"\n else s\"Failed\\nexpect:\\n$outputExpect\\noutput:\\n$output\")\n }\n .mkString(\"\\n\")\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given two positive integers a and b.\nLet x be the average of a and b.\nPrint x rounded up to the nearest integer.\n\nConstraints\n\na and b are integers.\n\n1 \\leq a, b \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint x rounded up to the nearest integer.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\n2\n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest integer, 2.\n\nSample Input 2\n\n7 4\n\nSample Output 2\n\n6\n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest integer, 6.\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\n5", "sample_input": "1 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03485", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given two positive integers a and b.\nLet x be the average of a and b.\nPrint x rounded up to the nearest integer.\n\nConstraints\n\na and b are integers.\n\n1 \\leq a, b \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint x rounded up to the nearest integer.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\n2\n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest integer, 2.\n\nSample Input 2\n\n7 4\n\nSample Output 2\n\n6\n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest integer, 6.\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 891, "cpu_time_ms": 344, "memory_kb": 25540}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s714089409", "group_id": "codeNet:p03485", "input_text": "import scala.io.StdIn._\n\nobject Main extends App {\n val x = readLine().split(\" \").map(_.toInt).sum / 2.0\n println(math.ceil(x).toInt)\n}\n", "language": "Scala", "metadata": {"date": 1513476212, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03485.html", "problem_id": "p03485", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03485/input.txt", "sample_output_relpath": "derived/input_output/data/p03485/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03485/Scala/s714089409.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s714089409", "user_id": "u478134456"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main extends App {\n val x = readLine().split(\" \").map(_.toInt).sum / 2.0\n println(math.ceil(x).toInt)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given two positive integers a and b.\nLet x be the average of a and b.\nPrint x rounded up to the nearest integer.\n\nConstraints\n\na and b are integers.\n\n1 \\leq a, b \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint x rounded up to the nearest integer.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\n2\n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest integer, 2.\n\nSample Input 2\n\n7 4\n\nSample Output 2\n\n6\n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest integer, 6.\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\n5", "sample_input": "1 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03485", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given two positive integers a and b.\nLet x be the average of a and b.\nPrint x rounded up to the nearest integer.\n\nConstraints\n\na and b are integers.\n\n1 \\leq a, b \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint x rounded up to the nearest integer.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\n2\n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest integer, 2.\n\nSample Input 2\n\n7 4\n\nSample Output 2\n\n6\n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest integer, 6.\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\n5", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 138, "cpu_time_ms": 324, "memory_kb": 26764}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s104792192", "group_id": "codeNet:p03486", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n val s = StdIn.readLine().sorted\n val t = StdIn.readLine().sortBy(f => -1*f)\n \n def loop(sl: String, tl: String): Boolean = {\n if(sl.nonEmpty && tl.isEmpty) false\n else if(sl.isEmpty && tl.nonEmpty) true\n else if(sl.isEmpty && tl.isEmpty) false\n else if(sl.head > tl.head) false\n else if(sl.head < tl.head) true\n else loop(sl.tail, tl.tail)\n }\n \n println(if(loop(s, t)) \"Yes\" else \"No\")\n}\n", "language": "Scala", "metadata": {"date": 1526844816, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s104792192.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s104792192", "user_id": "u895032849"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n val s = StdIn.readLine().sorted\n val t = StdIn.readLine().sortBy(f => -1*f)\n \n def loop(sl: String, tl: String): Boolean = {\n if(sl.nonEmpty && tl.isEmpty) false\n else if(sl.isEmpty && tl.nonEmpty) true\n else if(sl.isEmpty && tl.isEmpty) false\n else if(sl.head > tl.head) false\n else if(sl.head < tl.head) true\n else loop(sl.tail, tl.tail)\n }\n \n println(if(loop(s, t)) \"Yes\" else \"No\")\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 328, "memory_kb": 25540}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s344003197", "group_id": "codeNet:p03489", "input_text": "import scala.collection.mutable.HashMap\nimport scala.collection.immutable.List\n\nobject Main {\n def main(args: Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n \n import Function.tupled\n println(List.fill(n)(sc.nextInt)\n .groupBy(identity)\n .mapValues(_.length)\n .map(tupled {(number, count) =>\n if (count >= number) count - number\n else count\n }\n )\n .sum\n )\n }\n}\n", "language": "Scala", "metadata": {"date": 1514571887, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03489.html", "problem_id": "p03489", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03489/input.txt", "sample_output_relpath": "derived/input_output/data/p03489/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03489/Scala/s344003197.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s344003197", "user_id": "u551313534"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import scala.collection.mutable.HashMap\nimport scala.collection.immutable.List\n\nobject Main {\n def main(args: Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n \n import Function.tupled\n println(List.fill(n)(sc.nextInt)\n .groupBy(identity)\n .mapValues(_.length)\n .map(tupled {(number, count) =>\n if (count >= number) count - number\n else count\n }\n )\n .sum\n )\n }\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": "p03489", "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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1282, "memory_kb": 90420}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s074196376", "group_id": "codeNet:p03490", "input_text": "import java.io._\nimport java.util.StringTokenizer\n\nimport scala.collection.mutable\nimport scala.util.Sorting\nimport math.{abs, max, min}\nimport scala.collection.mutable.{ArrayBuffer, ListBuffer}\nimport scala.reflect.ClassTag\n\nobject Main {\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n\n def solve(): Unit = {\n val sc = new InputReader(System.in)\n val S = sc.next()\n val x, y = sc.nextInt()\n\n val X, Y = ArrayBuffer[Int]()\n var h = true\n var move = 0\n rep(S.length) { i =>\n S(i) match {\n case 'F' => move += 1\n case 'T' =>\n (if (h) X else Y) += move\n h ^= true\n move = 0\n }\n }\n if (move > 0) (if (h) X else Y) += move\n\n def reach(A: ArrayBuffer[Int], p: Int): Boolean = {\n val s = A.sum\n if (A.isEmpty || s == 0) p == 0 // 移動できない\n else {\n var cur, next = Array.ofDim[Boolean](s * 2 + 1)\n cur(s) = true\n rep(A.length) { i =>\n rep(s * 2 + 1) { j =>\n next(j) = cur(j)\n if (j + A(i) <= s * 2) next(j) ||= cur(j + A(i))\n if (j - A(i) >= 0) next(j) ||= cur(j - A(i))\n }\n val tmp = cur\n cur = next\n next = tmp\n }\n cur(s + p)\n }\n }\n\n val ok = reach(X, x) && reach(Y, y)\n val ans = if (ok) \"Yes\" else \"No\"\n out.println(ans)\n }\n\n def main(args: Array[String]): Unit = {\n solve()\n out.flush()\n }\n\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next().toInt\n def nextLong(): Long = next().toLong\n def nextChar(): Char = next().charAt(0)\n }\n def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n\n def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n rep(n)(i => res(i) = f(i))\n res\n }\n\n implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {\n // todo Orderingだとboxing発生するので自作Orderを用意したい\n def maxByOpt[B: Ordering](f: A => B): Option[A] = {\n if (as.nonEmpty) Some(as.maxBy(f)) else None\n }\n\n def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {\n val map = mutable.Map.empty[K, ArrayBuffer[A]]\n rep(as.length)(i => map.getOrElseUpdate(f(as(i)), ArrayBuffer()) += as(i))\n map\n }\n\n def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {\n var sum = num.zero\n rep(as.length)(i => sum = num.plus(sum, f(as(i))))\n sum\n }\n\n def minByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {\n limit(f, ixRange)(cmp.lt)\n }\n\n def maxByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {\n limit(f, ixRange)(cmp.gt)\n }\n\n private def limit[B](f: A => B, ixRange: Range)(cmp: (B, B) => Boolean): (A, B) = {\n var limA = as(ixRange.head)\n var limB = f(limA)\n\n for (i <- ixRange.tail) {\n val a = as(i)\n val b = f(a)\n if (cmp(b, limB)) {\n limA = a\n limB = b\n }\n }\n (limA, limB)\n }\n }\n\n implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {\n def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {\n as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1534541237, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03490.html", "problem_id": "p03490", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03490/input.txt", "sample_output_relpath": "derived/input_output/data/p03490/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03490/Scala/s074196376.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s074196376", "user_id": "u460609472"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.io._\nimport java.util.StringTokenizer\n\nimport scala.collection.mutable\nimport scala.util.Sorting\nimport math.{abs, max, min}\nimport scala.collection.mutable.{ArrayBuffer, ListBuffer}\nimport scala.reflect.ClassTag\n\nobject Main {\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n\n def solve(): Unit = {\n val sc = new InputReader(System.in)\n val S = sc.next()\n val x, y = sc.nextInt()\n\n val X, Y = ArrayBuffer[Int]()\n var h = true\n var move = 0\n rep(S.length) { i =>\n S(i) match {\n case 'F' => move += 1\n case 'T' =>\n (if (h) X else Y) += move\n h ^= true\n move = 0\n }\n }\n if (move > 0) (if (h) X else Y) += move\n\n def reach(A: ArrayBuffer[Int], p: Int): Boolean = {\n val s = A.sum\n if (A.isEmpty || s == 0) p == 0 // 移動できない\n else {\n var cur, next = Array.ofDim[Boolean](s * 2 + 1)\n cur(s) = true\n rep(A.length) { i =>\n rep(s * 2 + 1) { j =>\n next(j) = cur(j)\n if (j + A(i) <= s * 2) next(j) ||= cur(j + A(i))\n if (j - A(i) >= 0) next(j) ||= cur(j - A(i))\n }\n val tmp = cur\n cur = next\n next = tmp\n }\n cur(s + p)\n }\n }\n\n val ok = reach(X, x) && reach(Y, y)\n val ans = if (ok) \"Yes\" else \"No\"\n out.println(ans)\n }\n\n def main(args: Array[String]): Unit = {\n solve()\n out.flush()\n }\n\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next().toInt\n def nextLong(): Long = next().toLong\n def nextChar(): Char = next().charAt(0)\n }\n def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n\n def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n rep(n)(i => res(i) = f(i))\n res\n }\n\n implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {\n // todo Orderingだとboxing発生するので自作Orderを用意したい\n def maxByOpt[B: Ordering](f: A => B): Option[A] = {\n if (as.nonEmpty) Some(as.maxBy(f)) else None\n }\n\n def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {\n val map = mutable.Map.empty[K, ArrayBuffer[A]]\n rep(as.length)(i => map.getOrElseUpdate(f(as(i)), ArrayBuffer()) += as(i))\n map\n }\n\n def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {\n var sum = num.zero\n rep(as.length)(i => sum = num.plus(sum, f(as(i))))\n sum\n }\n\n def minByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {\n limit(f, ixRange)(cmp.lt)\n }\n\n def maxByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {\n limit(f, ixRange)(cmp.gt)\n }\n\n private def limit[B](f: A => B, ixRange: Range)(cmp: (B, B) => Boolean): (A, B) = {\n var limA = as(ixRange.head)\n var limB = f(limA)\n\n for (i <- ixRange.tail) {\n val a = as(i)\n val b = f(a)\n if (cmp(b, limB)) {\n limA = a\n limB = b\n }\n }\n (limA, limB)\n }\n }\n\n implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {\n def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {\n as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))\n }\n }\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": "p03490", "source_text": "Score : 500 points\n\nProblem Statement\n\nA robot is put at the origin in a two-dimensional plane.\nInitially, the robot is facing in the positive x-axis direction.\n\nThis robot will be given an instruction sequence s.\ns consists of the following two kinds of letters, and will be executed in order from front to back.\n\nF : Move in the current direction by distance 1.\n\nT : Turn 90 degrees, either clockwise or counterclockwise.\n\nThe objective of the robot is to be at coordinates (x, y) after all the instructions are executed.\nDetermine whether this objective is achievable.\n\nConstraints\n\ns consists of F and T.\n\n1 \\leq |s| \\leq 8 000\n\nx and y are integers.\n\n|x|, |y| \\leq |s|\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nx y\n\nOutput\n\nIf the objective is achievable, print Yes; if it is not, print No.\n\nSample Input 1\n\nFTFFTFFF\n4 2\n\nSample Output 1\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning clockwise in the second T.\n\nSample Input 2\n\nFTFFTFFF\n-2 -2\n\nSample Output 2\n\nYes\n\nThe objective can be achieved by, for example, turning clockwise in the first T and turning clockwise in the second T.\n\nSample Input 3\n\nFF\n1 0\n\nSample Output 3\n\nNo\n\nSample Input 4\n\nTF\n1 0\n\nSample Output 4\n\nNo\n\nSample Input 5\n\nFFTTFF\n0 0\n\nSample Output 5\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning counterclockwise in the second T.\n\nSample Input 6\n\nTTTT\n1 0\n\nSample Output 6\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3806, "cpu_time_ms": 556, "memory_kb": 27320}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s003924053", "group_id": "codeNet:p03490", "input_text": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val s = in.next()\n val _x, y = in.next().toInt\n val N = s.length\n var x = _x\n\n var dir = 0\n var sayuu: List[Int] = Nil\n var updown: List[Int] = Nil\n\n def calc(com: Char, num: Int): Unit = {\n com match {\n case 'F' =>\n if(dir == 0)\n sayuu = num :: sayuu\n else\n updown = num :: updown\n case 'T' =>\n if(num % 2 == 1)\n dir += 90\n dir %= 180\n\n }\n }\n\n var ind = 0\n ////\n breakable {\n while(ind < N) {\n if(s(ind) == 'F') {\n ind += 1\n }\n else\n break\n }\n }\n\n x -= ind\n\n while(ind < N) {\n val now = s(ind)\n var r = ind + 1\n\n breakable {\n while(true) {\n if(r == N || now != s(r)) {\n calc(now, r-ind)\n ind = r\n break\n }\n else {\n r += 1\n }\n }\n }\n }\n\n // val dplr = new Array[Int](16002)\n // val dpud = new Array[Int](16002)\n\n var setlr: Set[Int] = Set()\n \n for(e <- sayuu) {\n var now = Set(e, -e)\n\n for(e2 <- setlr) {\n now = now + (e2 + e) + (e2 - e)\n }\n\n setlr = now\n }\n\n var setud: Set[Int] = Set()\n for(e <- updown) {\n var now = Set(e, -e)\n\n for(e2 <- setud) {\n now = now + (e2 + e) + (e2 - e)\n }\n\n setud = now\n }\n\n if(setlr.contains(x) && setud.contains(y))\n println(\"Yes\")\n else\n println(\"No\")\n}\n\n\nclass InputReader(stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream))\n private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n", "language": "Scala", "metadata": {"date": 1527549995, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03490.html", "problem_id": "p03490", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03490/input.txt", "sample_output_relpath": "derived/input_output/data/p03490/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03490/Scala/s003924053.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s003924053", "user_id": "u098968285"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val s = in.next()\n val _x, y = in.next().toInt\n val N = s.length\n var x = _x\n\n var dir = 0\n var sayuu: List[Int] = Nil\n var updown: List[Int] = Nil\n\n def calc(com: Char, num: Int): Unit = {\n com match {\n case 'F' =>\n if(dir == 0)\n sayuu = num :: sayuu\n else\n updown = num :: updown\n case 'T' =>\n if(num % 2 == 1)\n dir += 90\n dir %= 180\n\n }\n }\n\n var ind = 0\n ////\n breakable {\n while(ind < N) {\n if(s(ind) == 'F') {\n ind += 1\n }\n else\n break\n }\n }\n\n x -= ind\n\n while(ind < N) {\n val now = s(ind)\n var r = ind + 1\n\n breakable {\n while(true) {\n if(r == N || now != s(r)) {\n calc(now, r-ind)\n ind = r\n break\n }\n else {\n r += 1\n }\n }\n }\n }\n\n // val dplr = new Array[Int](16002)\n // val dpud = new Array[Int](16002)\n\n var setlr: Set[Int] = Set()\n \n for(e <- sayuu) {\n var now = Set(e, -e)\n\n for(e2 <- setlr) {\n now = now + (e2 + e) + (e2 - e)\n }\n\n setlr = now\n }\n\n var setud: Set[Int] = Set()\n for(e <- updown) {\n var now = Set(e, -e)\n\n for(e2 <- setud) {\n now = now + (e2 + e) + (e2 - e)\n }\n\n setud = now\n }\n\n if(setlr.contains(x) && setud.contains(y))\n println(\"Yes\")\n else\n println(\"No\")\n}\n\n\nclass InputReader(stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream))\n private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\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": "p03490", "source_text": "Score : 500 points\n\nProblem Statement\n\nA robot is put at the origin in a two-dimensional plane.\nInitially, the robot is facing in the positive x-axis direction.\n\nThis robot will be given an instruction sequence s.\ns consists of the following two kinds of letters, and will be executed in order from front to back.\n\nF : Move in the current direction by distance 1.\n\nT : Turn 90 degrees, either clockwise or counterclockwise.\n\nThe objective of the robot is to be at coordinates (x, y) after all the instructions are executed.\nDetermine whether this objective is achievable.\n\nConstraints\n\ns consists of F and T.\n\n1 \\leq |s| \\leq 8 000\n\nx and y are integers.\n\n|x|, |y| \\leq |s|\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nx y\n\nOutput\n\nIf the objective is achievable, print Yes; if it is not, print No.\n\nSample Input 1\n\nFTFFTFFF\n4 2\n\nSample Output 1\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning clockwise in the second T.\n\nSample Input 2\n\nFTFFTFFF\n-2 -2\n\nSample Output 2\n\nYes\n\nThe objective can be achieved by, for example, turning clockwise in the first T and turning clockwise in the second T.\n\nSample Input 3\n\nFF\n1 0\n\nSample Output 3\n\nNo\n\nSample Input 4\n\nTF\n1 0\n\nSample Output 4\n\nNo\n\nSample Input 5\n\nFFTTFF\n0 0\n\nSample Output 5\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning counterclockwise in the second T.\n\nSample Input 6\n\nTTTT\n1 0\n\nSample Output 6\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1912, "cpu_time_ms": 2111, "memory_kb": 121104}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s441506479", "group_id": "codeNet:p03490", "input_text": "import java.util.Scanner\n\nimport scala.collection.mutable\nimport scala.collection.immutable\n\nobject Main {\n def isOdd(num:Int) = num % 2 != 0\n def isEven(num:Int) = num % 2 == 0\n\n def main(args: Array[String]) = {\n def func(cand:immutable.Set[Int], move:Int):immutable.Set[Int] = {\n var next_cand = new mutable.HashSet[Int]\n for (x <- cand) {\n next_cand += x + move\n next_cand += x - move\n }\n\n val ret:immutable.Set[Int] = immutable.Set.empty ++ next_cand\n return ret\n }\n\n val sc = new Scanner(System.in)\n val moves = sc.nextLine().split(\"T\").map(_.length).zipWithIndex\n val x_moves = moves.collect{\n case x if isEven(x._2) => x._1\n }\n val y_moves = moves.collect{\n case x if isOdd(x._2) => x._1\n }\n\n val xpos_cand = x_moves.tail.foldLeft(Set(x_moves(0)))(func)\n val ypos_cand = y_moves.foldLeft(Set(0))(func)\n\n val goal = sc.nextLine().split(\" \").map(_.toInt)\n if (xpos_cand.contains(goal(0)) &&\n ypos_cand.contains(goal(1)))\n println(\"Yes\")\n else\n println(\"No\")\n }\n}\n", "language": "Scala", "metadata": {"date": 1514589314, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03490.html", "problem_id": "p03490", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03490/input.txt", "sample_output_relpath": "derived/input_output/data/p03490/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03490/Scala/s441506479.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s441506479", "user_id": "u551313534"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.collection.mutable\nimport scala.collection.immutable\n\nobject Main {\n def isOdd(num:Int) = num % 2 != 0\n def isEven(num:Int) = num % 2 == 0\n\n def main(args: Array[String]) = {\n def func(cand:immutable.Set[Int], move:Int):immutable.Set[Int] = {\n var next_cand = new mutable.HashSet[Int]\n for (x <- cand) {\n next_cand += x + move\n next_cand += x - move\n }\n\n val ret:immutable.Set[Int] = immutable.Set.empty ++ next_cand\n return ret\n }\n\n val sc = new Scanner(System.in)\n val moves = sc.nextLine().split(\"T\").map(_.length).zipWithIndex\n val x_moves = moves.collect{\n case x if isEven(x._2) => x._1\n }\n val y_moves = moves.collect{\n case x if isOdd(x._2) => x._1\n }\n\n val xpos_cand = x_moves.tail.foldLeft(Set(x_moves(0)))(func)\n val ypos_cand = y_moves.foldLeft(Set(0))(func)\n\n val goal = sc.nextLine().split(\" \").map(_.toInt)\n if (xpos_cand.contains(goal(0)) &&\n ypos_cand.contains(goal(1)))\n println(\"Yes\")\n else\n println(\"No\")\n }\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": "p03490", "source_text": "Score : 500 points\n\nProblem Statement\n\nA robot is put at the origin in a two-dimensional plane.\nInitially, the robot is facing in the positive x-axis direction.\n\nThis robot will be given an instruction sequence s.\ns consists of the following two kinds of letters, and will be executed in order from front to back.\n\nF : Move in the current direction by distance 1.\n\nT : Turn 90 degrees, either clockwise or counterclockwise.\n\nThe objective of the robot is to be at coordinates (x, y) after all the instructions are executed.\nDetermine whether this objective is achievable.\n\nConstraints\n\ns consists of F and T.\n\n1 \\leq |s| \\leq 8 000\n\nx and y are integers.\n\n|x|, |y| \\leq |s|\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nx y\n\nOutput\n\nIf the objective is achievable, print Yes; if it is not, print No.\n\nSample Input 1\n\nFTFFTFFF\n4 2\n\nSample Output 1\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning clockwise in the second T.\n\nSample Input 2\n\nFTFFTFFF\n-2 -2\n\nSample Output 2\n\nYes\n\nThe objective can be achieved by, for example, turning clockwise in the first T and turning clockwise in the second T.\n\nSample Input 3\n\nFF\n1 0\n\nSample Output 3\n\nNo\n\nSample Input 4\n\nTF\n1 0\n\nSample Output 4\n\nNo\n\nSample Input 5\n\nFFTTFF\n0 0\n\nSample Output 5\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning counterclockwise in the second T.\n\nSample Input 6\n\nTTTT\n1 0\n\nSample Output 6\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1076, "cpu_time_ms": 2061, "memory_kb": 121668}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s001039828", "group_id": "codeNet:p03494", "input_text": "object Main extends App {\n\n val n = io.StdIn.readLine().toInt\n val nums = io.StdIn.readLine().split(' ').map(_.toInt)\n calc(nums)\n\n def calc(nums: Array[Int], cnt: Int = 0): Array[Int] = {\n val t = for (x <- nums) yield {\n if (x % 2 != 0) {\n println(cnt)\n sys.exit\n }\n x / 2\n }\n if (cnt == 10) {\n sys.exit()\n }\n calc(t, cnt + 1)\n }\n\n}", "language": "Scala", "metadata": {"date": 1545364259, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s001039828.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s001039828", "user_id": "u526852644"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n\n val n = io.StdIn.readLine().toInt\n val nums = io.StdIn.readLine().split(' ').map(_.toInt)\n calc(nums)\n\n def calc(nums: Array[Int], cnt: Int = 0): Array[Int] = {\n val t = for (x <- nums) yield {\n if (x % 2 != 0) {\n println(cnt)\n sys.exit\n }\n x / 2\n }\n if (cnt == 10) {\n sys.exit()\n }\n calc(t, cnt + 1)\n }\n\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 388, "cpu_time_ms": 337, "memory_kb": 25528}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s041933667", "group_id": "codeNet:p03494", "input_text": "\nimport java.util.Scanner\nobject Main {\n\n def main(args: Array[String]){\n val sc = new Scanner(System.in)\n\n val t = sc.nextLine().toInt\n val A = sc.nextLine().split(\" \").map(_.toInt)\n\n def two_index(n:Int): Int = {\n var idx = 0\n var num = n\n while (num % 2 == 0){\n num = num / 2\n idx = idx + 1\n }\n return idx\n }\n \n val two_index_obj = two_index _ \n println(A.map(two_index_obj).min)\n }\n}\n", "language": "Scala", "metadata": {"date": 1523893259, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s041933667.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s041933667", "user_id": "u159043787"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "\nimport java.util.Scanner\nobject Main {\n\n def main(args: Array[String]){\n val sc = new Scanner(System.in)\n\n val t = sc.nextLine().toInt\n val A = sc.nextLine().split(\" \").map(_.toInt)\n\n def two_index(n:Int): Int = {\n var idx = 0\n var num = n\n while (num % 2 == 0){\n num = num / 2\n idx = idx + 1\n }\n return idx\n }\n \n val two_index_obj = two_index _ \n println(A.map(two_index_obj).min)\n }\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 354, "memory_kb": 25672}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s338312689", "group_id": "codeNet:p03496", "input_text": "object Main extends App {\n\t\n\tval N = scala.io.StdIn.readInt\n\tvar A = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\n\tvar i = 0\n\n\tvar l1 = List[Int]()\n\tvar l2 = List[Int]()\n\n\tdo{\n\t\tif(A(i) > A(i+1)){\n\t\t\tif(A(i) < 0){\n\t\t\t\tA(i) = A(i) + A(i+1)\n\t\t\t\tl1 = (i+2) :: l1\n\t\t\t\tl2 = (i+1) :: l2\n\t\t\t}else{\n\t\t\t\tA(i+1) = A(i+1) + A(i)\n\t\t\t\tl1 = (i+1) :: l1\n\t\t\t\tl2 = (i+2) :: l2\n\t\t\t}\n\t\t}else{\n\t\t\ti = i + 1\n\t\t}\n\n\t}while(i < (N-1))\n\n\tif(l1.size == 0){\n\t\tprintln(0)\n\t}else{\n\t\tprintln(l1.size)\n\n\t\tl1 = l1.reverse\n\t\tl2 = l2.reverse\n\n\t\tfor(i<-0 until l1.size){\n\t\t\tprintln(l1(i) + \" \" + l2(i))\n\t\t}\n\t}\n\n\n\n\n\n}\n", "language": "Scala", "metadata": {"date": 1512963102, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03496.html", "problem_id": "p03496", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03496/input.txt", "sample_output_relpath": "derived/input_output/data/p03496/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03496/Scala/s338312689.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s338312689", "user_id": "u675876401"}, "prompt_components": {"gold_output": "2\n2 3\n3 3\n", "input_to_evaluate": "object Main extends App {\n\t\n\tval N = scala.io.StdIn.readInt\n\tvar A = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\n\tvar i = 0\n\n\tvar l1 = List[Int]()\n\tvar l2 = List[Int]()\n\n\tdo{\n\t\tif(A(i) > A(i+1)){\n\t\t\tif(A(i) < 0){\n\t\t\t\tA(i) = A(i) + A(i+1)\n\t\t\t\tl1 = (i+2) :: l1\n\t\t\t\tl2 = (i+1) :: l2\n\t\t\t}else{\n\t\t\t\tA(i+1) = A(i+1) + A(i)\n\t\t\t\tl1 = (i+1) :: l1\n\t\t\t\tl2 = (i+2) :: l2\n\t\t\t}\n\t\t}else{\n\t\t\ti = i + 1\n\t\t}\n\n\t}while(i < (N-1))\n\n\tif(l1.size == 0){\n\t\tprintln(0)\n\t}else{\n\t\tprintln(l1.size)\n\n\t\tl1 = l1.reverse\n\t\tl2 = l2.reverse\n\n\t\tfor(i<-0 until l1.size){\n\t\t\tprintln(l1(i) + \" \" + l2(i))\n\t\t}\n\t}\n\n\n\n\n\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nSnuke has an integer sequence, a, of length N. The i-th element of a (1-indexed) is a_{i}.\n\nHe can perform the following operation any number of times:\n\nOperation: Choose integers x and y between 1 and N (inclusive), and add a_x to a_y.\n\nHe would like to perform this operation between 0 and 2N times (inclusive) so that a satisfies the condition below. Show one such sequence of operations.\nIt can be proved that such a sequence of operations always exists under the constraints in this problem.\n\nCondition: a_1 \\leq a_2 \\leq ... \\leq a_{N}\n\nConstraints\n\n2 \\leq N \\leq 50\n\n-10^{6} \\leq a_i \\leq 10^{6}\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_{N}\n\nOutput\n\nLet m be the number of operations in your solution. In the first line, print m.\nIn the i-th of the subsequent m lines, print the numbers x and y chosen in the i-th operation, with a space in between.\nThe output will be considered correct if m is between 0 and 2N (inclusive) and a satisfies the condition after the m operations.\n\nSample Input 1\n\n3\n-2 5 -1\n\nSample Output 1\n\n2\n2 3\n3 3\n\nAfter the first operation, a = (-2,5,4).\n\nAfter the second operation, a = (-2,5,8), and the condition is now satisfied.\n\nSample Input 2\n\n2\n-1 -3\n\nSample Output 2\n\n1\n2 1\n\nAfter the first operation, a = (-4,-3) and the condition is now satisfied.\n\nSample Input 3\n\n5\n0 0 0 0 0\n\nSample Output 3\n\n0\n\nThe condition is satisfied already in the beginning.", "sample_input": "3\n-2 5 -1\n"}, "reference_outputs": ["2\n2 3\n3 3\n"], "source_document_id": "p03496", "source_text": "Score : 600 points\n\nProblem Statement\n\nSnuke has an integer sequence, a, of length N. The i-th element of a (1-indexed) is a_{i}.\n\nHe can perform the following operation any number of times:\n\nOperation: Choose integers x and y between 1 and N (inclusive), and add a_x to a_y.\n\nHe would like to perform this operation between 0 and 2N times (inclusive) so that a satisfies the condition below. Show one such sequence of operations.\nIt can be proved that such a sequence of operations always exists under the constraints in this problem.\n\nCondition: a_1 \\leq a_2 \\leq ... \\leq a_{N}\n\nConstraints\n\n2 \\leq N \\leq 50\n\n-10^{6} \\leq a_i \\leq 10^{6}\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_{N}\n\nOutput\n\nLet m be the number of operations in your solution. In the first line, print m.\nIn the i-th of the subsequent m lines, print the numbers x and y chosen in the i-th operation, with a space in between.\nThe output will be considered correct if m is between 0 and 2N (inclusive) and a satisfies the condition after the m operations.\n\nSample Input 1\n\n3\n-2 5 -1\n\nSample Output 1\n\n2\n2 3\n3 3\n\nAfter the first operation, a = (-2,5,4).\n\nAfter the second operation, a = (-2,5,8), and the condition is now satisfied.\n\nSample Input 2\n\n2\n-1 -3\n\nSample Output 2\n\n1\n2 1\n\nAfter the first operation, a = (-4,-3) and the condition is now satisfied.\n\nSample Input 3\n\n5\n0 0 0 0 0\n\nSample Output 3\n\n0\n\nThe condition is satisfied already in the beginning.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2119, "memory_kb": 239940}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s230374708", "group_id": "codeNet:p03501", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n val x = StdIn.readLine().split(' ').map(_.toInt)\n println(scala.math.min(x(0)*x(1), x(2)))\n}\n", "language": "Scala", "metadata": {"date": 1526849230, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s230374708.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s230374708", "user_id": "u895032849"}, "prompt_components": {"gold_output": "119\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n val x = StdIn.readLine().split(' ').map(_.toInt)\n println(scala.math.min(x(0)*x(1), x(2)))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 335, "memory_kb": 27296}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s807402261", "group_id": "codeNet:p03502", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt()\n val f = n.toString.map(_.toString.toInt).sum\n println(if (n % f == 0) \"Yes\" else \"No\")\n}\n", "language": "Scala", "metadata": {"date": 1598206464, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03502.html", "problem_id": "p03502", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03502/input.txt", "sample_output_relpath": "derived/input_output/data/p03502/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03502/Scala/s807402261.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s807402261", "user_id": "u191819389"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt()\n val f = n.toString.map(_.toString.toInt).sum\n println(if (n % f == 0) \"Yes\" else \"No\")\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAn integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10.\n\nGiven an integer N, determine whether it is a Harshad number.\n\nConstraints\n\n1?N?10^8\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint Yes if N is a Harshad number; print No otherwise.\n\nSample Input 1\n\n12\n\nSample Output 1\n\nYes\n\nf(12)=1+2=3. Since 12 is divisible by 3, 12 is a Harshad number.\n\nSample Input 2\n\n57\n\nSample Output 2\n\nNo\n\nf(57)=5+7=12. Since 57 is not divisible by 12, 12 is not a Harshad number.\n\nSample Input 3\n\n148\n\nSample Output 3\n\nNo", "sample_input": "12\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03502", "source_text": "Score : 200 points\n\nProblem Statement\n\nAn integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10.\n\nGiven an integer N, determine whether it is a Harshad number.\n\nConstraints\n\n1?N?10^8\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint Yes if N is a Harshad number; print No otherwise.\n\nSample Input 1\n\n12\n\nSample Output 1\n\nYes\n\nf(12)=1+2=3. Since 12 is divisible by 3, 12 is a Harshad number.\n\nSample Input 2\n\n57\n\nSample Output 2\n\nNo\n\nf(57)=5+7=12. Since 57 is not divisible by 12, 12 is not a Harshad number.\n\nSample Input 3\n\n148\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 185, "cpu_time_ms": 512, "memory_kb": 55492}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s080237594", "group_id": "codeNet:p03502", "input_text": "object Main extends App {\n var a = readInt\n var b = a\n var sum = 0\n for(i <- 0 until a.toString.size) {\n sum = sum + a%10\n a = a / 10\n }\n print(if(b%sum!=0){\"No\"} else {\"Yes\"})\n}", "language": "Scala", "metadata": {"date": 1562635128, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03502.html", "problem_id": "p03502", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03502/input.txt", "sample_output_relpath": "derived/input_output/data/p03502/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03502/Scala/s080237594.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s080237594", "user_id": "u533688845"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n var a = readInt\n var b = a\n var sum = 0\n for(i <- 0 until a.toString.size) {\n sum = sum + a%10\n a = a / 10\n }\n print(if(b%sum!=0){\"No\"} else {\"Yes\"})\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAn integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10.\n\nGiven an integer N, determine whether it is a Harshad number.\n\nConstraints\n\n1?N?10^8\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint Yes if N is a Harshad number; print No otherwise.\n\nSample Input 1\n\n12\n\nSample Output 1\n\nYes\n\nf(12)=1+2=3. Since 12 is divisible by 3, 12 is a Harshad number.\n\nSample Input 2\n\n57\n\nSample Output 2\n\nNo\n\nf(57)=5+7=12. Since 57 is not divisible by 12, 12 is not a Harshad number.\n\nSample Input 3\n\n148\n\nSample Output 3\n\nNo", "sample_input": "12\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03502", "source_text": "Score : 200 points\n\nProblem Statement\n\nAn integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10.\n\nGiven an integer N, determine whether it is a Harshad number.\n\nConstraints\n\n1?N?10^8\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint Yes if N is a Harshad number; print No otherwise.\n\nSample Input 1\n\n12\n\nSample Output 1\n\nYes\n\nf(12)=1+2=3. Since 12 is divisible by 3, 12 is a Harshad number.\n\nSample Input 2\n\n57\n\nSample Output 2\n\nNo\n\nf(57)=5+7=12. Since 57 is not divisible by 12, 12 is not a Harshad number.\n\nSample Input 3\n\n148\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 327, "memory_kb": 27072}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s883937896", "group_id": "codeNet:p03543", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n \n val s = StdIn.readLine()\n println(\n if(s(0) == s(1) && s(1) == s(2)) \"Yes\"\n else if(s(1) == s(2) && s(2) == s(3)) \"Yes\"\n else \"No\"\n )\n}", "language": "Scala", "metadata": {"date": 1526958391, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s883937896.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s883937896", "user_id": "u895032849"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n \n val s = StdIn.readLine()\n println(\n if(s(0) == s(1) && s(1) == s(2)) \"Yes\"\n else if(s(1) == s(2) && s(2) == s(3)) \"Yes\"\n else \"No\"\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 320, "memory_kb": 27184}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s652352412", "group_id": "codeNet:p03543", "input_text": "object Main extends App {\n val N = io.StdIn.readLine().split(\"\").toSet\n if (N.size <= 2) println(\"Yes\") else println(\"No\")\n}\n", "language": "Scala", "metadata": {"date": 1511056976, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s652352412.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s652352412", "user_id": "u478134456"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n val N = io.StdIn.readLine().split(\"\").toSet\n if (N.size <= 2) println(\"Yes\") else println(\"No\")\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 418, "memory_kb": 25648}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s115911498", "group_id": "codeNet:p03544", "input_text": "\nobject Main extends App {\n \n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt()\n val lucas: Stream[Long] = 2L #:: 1L #:: lucas.zip(lucas.tail).map(n => n._1 + n._2)\n println(lucas(n))\n}", "language": "Scala", "metadata": {"date": 1599179811, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03544.html", "problem_id": "p03544", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03544/input.txt", "sample_output_relpath": "derived/input_output/data/p03544/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03544/Scala/s115911498.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s115911498", "user_id": "u396472025"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "\nobject Main extends App {\n \n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt()\n val lucas: Stream[Long] = 2L #:: 1L #:: lucas.zip(lucas.tail).map(n => n._1 + n._2)\n println(lucas(n))\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIt is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers.\n\nYou are given an integer N. Find the N-th Lucas number.\n\nHere, the i-th Lucas number L_i is defined as follows:\n\nL_0=2\n\nL_1=1\n\nL_i=L_{i-1}+L_{i-2} (i≥2)\n\nConstraints\n\n1≤N≤86\n\nIt is guaranteed that the answer is less than 10^{18}.\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the N-th Lucas number.\n\nSample Input 1\n\n5\n\nSample Output 1\n\n11\n\nL_0=2\n\nL_1=1\n\nL_2=L_0+L_1=3\n\nL_3=L_1+L_2=4\n\nL_4=L_2+L_3=7\n\nL_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\nSample Input 2\n\n86\n\nSample Output 2\n\n939587134549734843", "sample_input": "5\n"}, "reference_outputs": ["11\n"], "source_document_id": "p03544", "source_text": "Score : 200 points\n\nProblem Statement\n\nIt is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers.\n\nYou are given an integer N. Find the N-th Lucas number.\n\nHere, the i-th Lucas number L_i is defined as follows:\n\nL_0=2\n\nL_1=1\n\nL_i=L_{i-1}+L_{i-2} (i≥2)\n\nConstraints\n\n1≤N≤86\n\nIt is guaranteed that the answer is less than 10^{18}.\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the N-th Lucas number.\n\nSample Input 1\n\n5\n\nSample Output 1\n\n11\n\nL_0=2\n\nL_1=1\n\nL_2=L_0+L_1=3\n\nL_3=L_1+L_2=4\n\nL_4=L_2+L_3=7\n\nL_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\nSample Input 2\n\n86\n\nSample Output 2\n\n939587134549734843", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 499, "memory_kb": 55480}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s835707231", "group_id": "codeNet:p03544", "input_text": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n val n: Int = sc.nextLine.toInt\n\n def go(i: Int, prev: BigInt, post: BigInt): BigInt ={\n if (i == 0) prev\n else{\n go(i-1, post, prev+post)\n }\n }\n println(go(n, 2, 1))\n }\n}\n", "language": "Scala", "metadata": {"date": 1558272642, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03544.html", "problem_id": "p03544", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03544/input.txt", "sample_output_relpath": "derived/input_output/data/p03544/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03544/Scala/s835707231.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s835707231", "user_id": "u629133942"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n val n: Int = sc.nextLine.toInt\n\n def go(i: Int, prev: BigInt, post: BigInt): BigInt ={\n if (i == 0) prev\n else{\n go(i-1, post, prev+post)\n }\n }\n println(go(n, 2, 1))\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIt is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers.\n\nYou are given an integer N. Find the N-th Lucas number.\n\nHere, the i-th Lucas number L_i is defined as follows:\n\nL_0=2\n\nL_1=1\n\nL_i=L_{i-1}+L_{i-2} (i≥2)\n\nConstraints\n\n1≤N≤86\n\nIt is guaranteed that the answer is less than 10^{18}.\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the N-th Lucas number.\n\nSample Input 1\n\n5\n\nSample Output 1\n\n11\n\nL_0=2\n\nL_1=1\n\nL_2=L_0+L_1=3\n\nL_3=L_1+L_2=4\n\nL_4=L_2+L_3=7\n\nL_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\nSample Input 2\n\n86\n\nSample Output 2\n\n939587134549734843", "sample_input": "5\n"}, "reference_outputs": ["11\n"], "source_document_id": "p03544", "source_text": "Score : 200 points\n\nProblem Statement\n\nIt is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers.\n\nYou are given an integer N. Find the N-th Lucas number.\n\nHere, the i-th Lucas number L_i is defined as follows:\n\nL_0=2\n\nL_1=1\n\nL_i=L_{i-1}+L_{i-2} (i≥2)\n\nConstraints\n\n1≤N≤86\n\nIt is guaranteed that the answer is less than 10^{18}.\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the N-th Lucas number.\n\nSample Input 1\n\n5\n\nSample Output 1\n\n11\n\nL_0=2\n\nL_1=1\n\nL_2=L_0+L_1=3\n\nL_3=L_1+L_2=4\n\nL_4=L_2+L_3=7\n\nL_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\nSample Input 2\n\n86\n\nSample Output 2\n\n939587134549734843", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 334, "cpu_time_ms": 343, "memory_kb": 25544}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s019005911", "group_id": "codeNet:p03545", "input_text": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val numbers = sc.nextLine.split(\"\").map(_.toInt)\n\n var ans: String = numbers.head.toString\n\n def go(num: Array[Int], sumValue: Int, res: String): Boolean = {\n if (num.isEmpty) {\n if (sumValue == 7) {\n ans += res + \"=7\"\n true\n }\n else false\n } else {\n go(num.tail, sumValue + num.head, Array(res, \"+\", num.head.toString).mkString(\"\")) |\n go(num.tail, sumValue - num.head, Array(res, \"-\", num.head.toString).mkString(\"\"))\n }\n }\n\n go(numbers.tail, numbers.head, \"\")\n println(ans)\n }\n}\n", "language": "Scala", "metadata": {"date": 1558963630, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s019005911.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s019005911", "user_id": "u629133942"}, "prompt_components": {"gold_output": "1+2+2+2=7\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val numbers = sc.nextLine.split(\"\").map(_.toInt)\n\n var ans: String = numbers.head.toString\n\n def go(num: Array[Int], sumValue: Int, res: String): Boolean = {\n if (num.isEmpty) {\n if (sumValue == 7) {\n ans += res + \"=7\"\n true\n }\n else false\n } else {\n go(num.tail, sumValue + num.head, Array(res, \"+\", num.head.toString).mkString(\"\")) |\n go(num.tail, sumValue - num.head, Array(res, \"-\", num.head.toString).mkString(\"\"))\n }\n }\n\n go(numbers.tail, numbers.head, \"\")\n println(ans)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 690, "cpu_time_ms": 341, "memory_kb": 25520}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s640485125", "group_id": "codeNet:p03545", "input_text": "object Main extends App {\n\tval N = scala.io.StdIn.readLine.toArray\n\n\tval a1 = N(0).toInt - 48\n\tval a2 = N(1).toInt - 48\n\tval a3 = N(2).toInt - 48\n\tval a4 = N(3).toInt - 48\n\n\tif(a1 + a2 + a3 + a4 == 7){\n\t\tprintln(s\"$a1+$a2+$a3+$a4=7\")\n\t}else if(a1 + a2 + a3 - a4 == 7){\n\t\tprintln(s\"$a1+$a2+$a3-$a4=7\")\n\t}else if(a1 + a2 - a3 + a4 == 7){\n\t\tprintln(s\"$a1+$a2-$a3+$a4=7\")\n\t}else if(a1 + a2 - a3 - a4 == 7){\n\t\tprintln(s\"$a1+$a2-$a3-$a4=7\")\n\t}else if(a1 - a2 + a3 + a4 == 7){\n\t\tprintln(s\"$a1-$a2+$a3+$a4=7\")\n\t}else if(a1 - a2 + a3 - a4 == 7){\n\t\tprintln(s\"$a1-$a2+$a3-$a4=7\")\n\t}else if(a1 - a2 - a3 + a4 == 7){\n\t\tprintln(s\"$a1-$a2-$a3+$a4=7\")\n\t}else if(a1 - a2 - a3 - a4 == 7){\n\t\tprintln(s\"$a1-$a2-$a3-$a4=7\")\n\t}\n}", "language": "Scala", "metadata": {"date": 1515521240, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s640485125.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s640485125", "user_id": "u675876401"}, "prompt_components": {"gold_output": "1+2+2+2=7\n", "input_to_evaluate": "object Main extends App {\n\tval N = scala.io.StdIn.readLine.toArray\n\n\tval a1 = N(0).toInt - 48\n\tval a2 = N(1).toInt - 48\n\tval a3 = N(2).toInt - 48\n\tval a4 = N(3).toInt - 48\n\n\tif(a1 + a2 + a3 + a4 == 7){\n\t\tprintln(s\"$a1+$a2+$a3+$a4=7\")\n\t}else if(a1 + a2 + a3 - a4 == 7){\n\t\tprintln(s\"$a1+$a2+$a3-$a4=7\")\n\t}else if(a1 + a2 - a3 + a4 == 7){\n\t\tprintln(s\"$a1+$a2-$a3+$a4=7\")\n\t}else if(a1 + a2 - a3 - a4 == 7){\n\t\tprintln(s\"$a1+$a2-$a3-$a4=7\")\n\t}else if(a1 - a2 + a3 + a4 == 7){\n\t\tprintln(s\"$a1-$a2+$a3+$a4=7\")\n\t}else if(a1 - a2 + a3 - a4 == 7){\n\t\tprintln(s\"$a1-$a2+$a3-$a4=7\")\n\t}else if(a1 - a2 - a3 + a4 == 7){\n\t\tprintln(s\"$a1-$a2-$a3+$a4=7\")\n\t}else if(a1 - a2 - a3 - a4 == 7){\n\t\tprintln(s\"$a1-$a2-$a3-$a4=7\")\n\t}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 707, "cpu_time_ms": 334, "memory_kb": 25420}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s605716521", "group_id": "codeNet:p03546", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val h, w = sc.nextInt()\n val n = 10\n val c = Array.fill(n, n)(sc.nextInt())\n val a = List.fill(h * w)(sc.nextInt())\n\n for {\n k <- 0 until n\n i <- 0 until n\n j <- 0 until n\n if c(i)(k) + c(k)(j) < c(i)(j)\n } {\n c(i)(j) = c(i)(k) + c(k)(j)\n }\n\n val count = a.groupBy(identity).view.mapValues(_.length).toMap.withDefaultValue(0)\n val ans = (2 until n).map(i => c(i)(1) * count(i)).sum\n println(ans)\n}\n", "language": "Scala", "metadata": {"date": 1598205842, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03546.html", "problem_id": "p03546", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03546/input.txt", "sample_output_relpath": "derived/input_output/data/p03546/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03546/Scala/s605716521.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s605716521", "user_id": "u191819389"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val h, w = sc.nextInt()\n val n = 10\n val c = Array.fill(n, n)(sc.nextInt())\n val a = List.fill(h * w)(sc.nextInt())\n\n for {\n k <- 0 until n\n i <- 0 until n\n j <- 0 until n\n if c(i)(k) + c(k)(j) < c(i)(j)\n } {\n c(i)(j) = c(i)(k) + c(k)(j)\n }\n\n val count = a.groupBy(identity).view.mapValues(_.length).toMap.withDefaultValue(0)\n val ans = (2 until n).map(i => c(i)(1) * count(i)).sum\n println(ans)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nJoisino the magical girl has decided to turn every single digit that exists on this world into 1.\n\nRewriting a digit i with j (0≤i,j≤9) costs c_{i,j} MP (Magic Points).\n\nShe is now standing before a wall. The wall is divided into HW squares in H rows and W columns, and at least one square contains a digit between 0 and 9 (inclusive).\n\nYou are given A_{i,j} that describes the square at the i-th row from the top and j-th column from the left, as follows:\n\nIf A_{i,j}≠-1, the square contains a digit A_{i,j}.\n\nIf A_{i,j}=-1, the square does not contain a digit.\n\nFind the minimum total amount of MP required to turn every digit on this wall into 1 in the end.\n\nConstraints\n\n1≤H,W≤200\n\n1≤c_{i,j}≤10^3 (i≠j)\n\nc_{i,j}=0 (i=j)\n\n-1≤A_{i,j}≤9\n\nAll input values are integers.\n\nThere is at least one digit on the wall.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nc_{0,0} ... c_{0,9}\n:\nc_{9,0} ... c_{9,9}\nA_{1,1} ... A_{1,W}\n:\nA_{H,1} ... A_{H,W}\n\nOutput\n\nPrint the minimum total amount of MP required to turn every digit on the wall into 1 in the end.\n\nSample Input 1\n\n2 4\n0 9 9 9 9 9 9 9 9 9\n9 0 9 9 9 9 9 9 9 9\n9 9 0 9 9 9 9 9 9 9\n9 9 9 0 9 9 9 9 9 9\n9 9 9 9 0 9 9 9 9 2\n9 9 9 9 9 0 9 9 9 9\n9 9 9 9 9 9 0 9 9 9\n9 9 9 9 9 9 9 0 9 9\n9 9 9 9 2 9 9 9 0 9\n9 2 9 9 9 9 9 9 9 0\n-1 -1 -1 -1\n8 1 1 8\n\nSample Output 1\n\n12\n\nTo turn a single 8 into 1, it is optimal to first turn 8 into 4, then turn 4 into 9, and finally turn 9 into 1, costing 6 MP.\n\nThe wall contains two 8s, so the minimum total MP required is 6×2=12.\n\nSample Input 2\n\n5 5\n0 999 999 999 999 999 999 999 999 999\n999 0 999 999 999 999 999 999 999 999\n999 999 0 999 999 999 999 999 999 999\n999 999 999 0 999 999 999 999 999 999\n999 999 999 999 0 999 999 999 999 999\n999 999 999 999 999 0 999 999 999 999\n999 999 999 999 999 999 0 999 999 999\n999 999 999 999 999 999 999 0 999 999\n999 999 999 999 999 999 999 999 0 999\n999 999 999 999 999 999 999 999 999 0\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n\nSample Output 2\n\n0\n\nNote that she may not need to change any digit.\n\nSample Input 3\n\n3 5\n0 4 3 6 2 7 2 5 3 3\n4 0 5 3 7 5 3 7 2 7\n5 7 0 7 2 9 3 2 9 1\n3 6 2 0 2 4 6 4 2 3\n3 5 7 4 0 6 9 7 6 7\n9 8 5 2 2 0 4 7 6 5\n5 4 6 3 2 3 0 5 4 3\n3 6 2 3 4 2 4 0 8 9\n4 6 5 4 3 5 3 2 0 8\n2 1 3 4 5 7 8 6 4 0\n3 5 2 6 1\n2 5 3 2 1\n6 9 2 5 6\n\nSample Output 3\n\n47", "sample_input": "2 4\n0 9 9 9 9 9 9 9 9 9\n9 0 9 9 9 9 9 9 9 9\n9 9 0 9 9 9 9 9 9 9\n9 9 9 0 9 9 9 9 9 9\n9 9 9 9 0 9 9 9 9 2\n9 9 9 9 9 0 9 9 9 9\n9 9 9 9 9 9 0 9 9 9\n9 9 9 9 9 9 9 0 9 9\n9 9 9 9 2 9 9 9 0 9\n9 2 9 9 9 9 9 9 9 0\n-1 -1 -1 -1\n8 1 1 8\n"}, "reference_outputs": ["12\n"], "source_document_id": "p03546", "source_text": "Score : 400 points\n\nProblem Statement\n\nJoisino the magical girl has decided to turn every single digit that exists on this world into 1.\n\nRewriting a digit i with j (0≤i,j≤9) costs c_{i,j} MP (Magic Points).\n\nShe is now standing before a wall. The wall is divided into HW squares in H rows and W columns, and at least one square contains a digit between 0 and 9 (inclusive).\n\nYou are given A_{i,j} that describes the square at the i-th row from the top and j-th column from the left, as follows:\n\nIf A_{i,j}≠-1, the square contains a digit A_{i,j}.\n\nIf A_{i,j}=-1, the square does not contain a digit.\n\nFind the minimum total amount of MP required to turn every digit on this wall into 1 in the end.\n\nConstraints\n\n1≤H,W≤200\n\n1≤c_{i,j}≤10^3 (i≠j)\n\nc_{i,j}=0 (i=j)\n\n-1≤A_{i,j}≤9\n\nAll input values are integers.\n\nThere is at least one digit on the wall.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nc_{0,0} ... c_{0,9}\n:\nc_{9,0} ... c_{9,9}\nA_{1,1} ... A_{1,W}\n:\nA_{H,1} ... A_{H,W}\n\nOutput\n\nPrint the minimum total amount of MP required to turn every digit on the wall into 1 in the end.\n\nSample Input 1\n\n2 4\n0 9 9 9 9 9 9 9 9 9\n9 0 9 9 9 9 9 9 9 9\n9 9 0 9 9 9 9 9 9 9\n9 9 9 0 9 9 9 9 9 9\n9 9 9 9 0 9 9 9 9 2\n9 9 9 9 9 0 9 9 9 9\n9 9 9 9 9 9 0 9 9 9\n9 9 9 9 9 9 9 0 9 9\n9 9 9 9 2 9 9 9 0 9\n9 2 9 9 9 9 9 9 9 0\n-1 -1 -1 -1\n8 1 1 8\n\nSample Output 1\n\n12\n\nTo turn a single 8 into 1, it is optimal to first turn 8 into 4, then turn 4 into 9, and finally turn 9 into 1, costing 6 MP.\n\nThe wall contains two 8s, so the minimum total MP required is 6×2=12.\n\nSample Input 2\n\n5 5\n0 999 999 999 999 999 999 999 999 999\n999 0 999 999 999 999 999 999 999 999\n999 999 0 999 999 999 999 999 999 999\n999 999 999 0 999 999 999 999 999 999\n999 999 999 999 0 999 999 999 999 999\n999 999 999 999 999 0 999 999 999 999\n999 999 999 999 999 999 0 999 999 999\n999 999 999 999 999 999 999 0 999 999\n999 999 999 999 999 999 999 999 0 999\n999 999 999 999 999 999 999 999 999 0\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n\nSample Output 2\n\n0\n\nNote that she may not need to change any digit.\n\nSample Input 3\n\n3 5\n0 4 3 6 2 7 2 5 3 3\n4 0 5 3 7 5 3 7 2 7\n5 7 0 7 2 9 3 2 9 1\n3 6 2 0 2 4 6 4 2 3\n3 5 7 4 0 6 9 7 6 7\n9 8 5 2 2 0 4 7 6 5\n5 4 6 3 2 3 0 5 4 3\n3 6 2 3 4 2 4 0 8 9\n4 6 5 4 3 5 3 2 0 8\n2 1 3 4 5 7 8 6 4 0\n3 5 2 6 1\n2 5 3 2 1\n6 9 2 5 6\n\nSample Output 3\n\n47", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 728, "memory_kb": 62760}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s573378502", "group_id": "codeNet:p03547", "input_text": "import scala.math._\n\nobject Main extends App {\n val sc = new java.util.Scanner(System.in)\n val x, y = sc.next\n\n val ans = if (x < y) \"<\" else if (x > y) \">\" else \"=\"\n\n println(ans)\n\n ///////////////////////////////////////////\n\n def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =\n Iterator.iterate(start)(_ + step).takeWhile(_ <= end)\n\n def lcm(a :Int, b :Int): Int =\n a / gcd(a, b) * b\n\n def lcm(a :Long, b :Long): Long =\n a / gcd(a, b) * b\n\n def gcd(a: Int, b: Int): Int =\n if (b == 0) a else gcd(b, a % b)\n\n def gcd(a: Long, b: Long): Long =\n if (b == 0) a else gcd(b, a % b)\n\n def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =\n a.get(key) match {\n case Some(v) => a.updated(key, f(value, v))\n case _ => a + (key -> value)\n }\n}", "language": "Scala", "metadata": {"date": 1562288015, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s573378502.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s573378502", "user_id": "u040380439"}, "prompt_components": {"gold_output": "<\n", "input_to_evaluate": "import scala.math._\n\nobject Main extends App {\n val sc = new java.util.Scanner(System.in)\n val x, y = sc.next\n\n val ans = if (x < y) \"<\" else if (x > y) \">\" else \"=\"\n\n println(ans)\n\n ///////////////////////////////////////////\n\n def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =\n Iterator.iterate(start)(_ + step).takeWhile(_ <= end)\n\n def lcm(a :Int, b :Int): Int =\n a / gcd(a, b) * b\n\n def lcm(a :Long, b :Long): Long =\n a / gcd(a, b) * b\n\n def gcd(a: Int, b: Int): Int =\n if (b == 0) a else gcd(b, a % b)\n\n def gcd(a: Long, b: Long): Long =\n if (b == 0) a else gcd(b, a % b)\n\n def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =\n a.get(key) match {\n case Some(v) => a.updated(key, f(value, v))\n case _ => a + (key -> value)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 808, "cpu_time_ms": 338, "memory_kb": 27212}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s688810021", "group_id": "codeNet:p03547", "input_text": "import java.util.Scanner\n\nimport scala.collection.Searching._\nimport scala.annotation.tailrec\nimport scala.collection.immutable.Queue\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(new Node(None, 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n @tailrec\n private def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) => root(p)\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val X, Y = sc.next\n if (X == Y) {\n println(\"=\")\n } else if (X < Y) {\n println(\"<\")\n } else {\n println(\">\")\n }\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}", "language": "Scala", "metadata": {"date": 1510488574, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s688810021.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s688810021", "user_id": "u779353743"}, "prompt_components": {"gold_output": "<\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.collection.Searching._\nimport scala.annotation.tailrec\nimport scala.collection.immutable.Queue\n\nclass IUnionFind(val size: Int) {\n\n private case class Node(var parent: Option[Int], var treeSize: Int)\n\n private val nodes = Array.fill[Node](size)(new Node(None, 1))\n\n def union(t1: Int, t2: Int): IUnionFind = {\n if (t1 == t2) return this\n\n val root1 = root(t1)\n val root2 = root(t2)\n if (root1 == root2) return this\n\n val node1 = nodes(root1)\n val node2 = nodes(root2)\n\n if (node1.treeSize < node2.treeSize) {\n node1.parent = Some(t2)\n node2.treeSize += node1.treeSize\n } else {\n node2.parent = Some(t1)\n node1.treeSize += node2.treeSize\n }\n this\n }\n\n def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)\n\n @tailrec\n private def root(t: Int): Int = nodes(t).parent match {\n case None => t\n case Some(p) => root(p)\n }\n}\n\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val X, Y = sc.next\n if (X == Y) {\n println(\"=\")\n } else if (X < Y) {\n println(\"<\")\n } else {\n println(\">\")\n }\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 332, "memory_kb": 25488}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s357463750", "group_id": "codeNet:p03547", "input_text": "object Main {\n def main(args: Array[String]) {\n val sc = new java.util.Scanner(System.in)\n val X = sc.next().charAt(0)\n val Y = sc.next().charAt(0)\n val r = if (X > Y) '>' else if (X < Y) '<' else '='\n println(r)\n }\n}", "language": "Scala", "metadata": {"date": 1510452792, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s357463750.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s357463750", "user_id": "u054322298"}, "prompt_components": {"gold_output": "<\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]) {\n val sc = new java.util.Scanner(System.in)\n val X = sc.next().charAt(0)\n val Y = sc.next().charAt(0)\n val r = if (X > Y) '>' else if (X < Y) '<' else '='\n println(r)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 355, "memory_kb": 25412}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s504092581", "group_id": "codeNet:p03550", "input_text": "object Main extends App {\n\timport scala.math._\n\n\tval NZW = scala.io.StdIn.readLine.split(\" \").map(_.toLong)\n\tval A = scala.io.StdIn.readLine.split(\" \").map(_.toLong)\n\n\tval N = NZW(0).toInt\n\n\tval a = (NZW(2) - A(N-1)).abs\n\tval b = (A(N-1) - A(N-2)).abs\n\n\tprintln(max(a,b))\n\t\n\n}\n", "language": "Scala", "metadata": {"date": 1510506262, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s504092581.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s504092581", "user_id": "u675876401"}, "prompt_components": {"gold_output": "900\n", "input_to_evaluate": "object Main extends App {\n\timport scala.math._\n\n\tval NZW = scala.io.StdIn.readLine.split(\" \").map(_.toLong)\n\tval A = scala.io.StdIn.readLine.split(\" \").map(_.toLong)\n\n\tval N = NZW(0).toInt\n\n\tval a = (NZW(2) - A(N-1)).abs\n\tval b = (A(N-1) - A(N-2)).abs\n\n\tprintln(max(a,b))\n\t\n\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 362, "memory_kb": 28820}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s782166488", "group_id": "codeNet:p03550", "input_text": "object Main {\n def main(args: Array[String]) {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val z = sc.nextInt\n val w = sc.nextInt\n val an = List.fill(n)(sc.nextInt)\n\n val ans = if (an.length == 1) {\n Math.abs(an.head - w)\n } else {\n val a = Math.abs(an.head - w)\n val b = Math.abs(an.last - an(an.length - 1))\n if (a > b) a else b\n }\n\n println(ans)\n }\n}\n", "language": "Scala", "metadata": {"date": 1510461323, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s782166488.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s782166488", "user_id": "u592088571"}, "prompt_components": {"gold_output": "900\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]) {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val z = sc.nextInt\n val w = sc.nextInt\n val an = List.fill(n)(sc.nextInt)\n\n val ans = if (an.length == 1) {\n Math.abs(an.head - w)\n } else {\n val a = Math.abs(an.head - w)\n val b = Math.abs(an.last - an(an.length - 1))\n if (a > b) a else b\n }\n\n println(ans)\n }\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 455, "memory_kb": 29692}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s528672366", "group_id": "codeNet:p03560", "input_text": "import scala.collection.mutable\n\nobject Main extends App {\n val sc = new java.util.Scanner(System.in)\n val k = sc.nextInt()\n var e = List[(Int, Int, Int)]()\n for (i <- 0 until k) {\n if (i % 10 != 9) {\n e ::= (i, (i+1) % k, 1)\n }\n e ::= (i, (10 * i) % k, 0)\n }\n\n val sp = binaryBfs(1, k, e)\n println(sp(0) + 1)\n\n def binaryBfs(s: Int, n: Int, edges: Seq[(Int, Int, Int)]): Array[Int] = {\n val adj = Array.fill(n)(List[(Int, Int)]())\n for ((u, v, w) <- edges) {\n adj(u) ::= (v, w)\n }\n\n val sp = Array.fill(n)(-1)\n sp(s) = 0\n val deque = mutable.ArrayDeque[Int]()\n deque.append(s)\n while (deque.nonEmpty) {\n val u = deque.removeHead()\n for ((v, w) <- adj(u) if (sp(v) == -1 || sp(u) + w < sp(v))) {\n sp(v) = sp(u) + w\n if (w == 0) {\n deque.prepend(v)\n } else {\n deque.append(v)\n }\n }\n }\n sp\n }\n}\n", "language": "Scala", "metadata": {"date": 1597611376, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03560.html", "problem_id": "p03560", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03560/input.txt", "sample_output_relpath": "derived/input_output/data/p03560/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03560/Scala/s528672366.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s528672366", "user_id": "u191819389"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.collection.mutable\n\nobject Main extends App {\n val sc = new java.util.Scanner(System.in)\n val k = sc.nextInt()\n var e = List[(Int, Int, Int)]()\n for (i <- 0 until k) {\n if (i % 10 != 9) {\n e ::= (i, (i+1) % k, 1)\n }\n e ::= (i, (10 * i) % k, 0)\n }\n\n val sp = binaryBfs(1, k, e)\n println(sp(0) + 1)\n\n def binaryBfs(s: Int, n: Int, edges: Seq[(Int, Int, Int)]): Array[Int] = {\n val adj = Array.fill(n)(List[(Int, Int)]())\n for ((u, v, w) <- edges) {\n adj(u) ::= (v, w)\n }\n\n val sp = Array.fill(n)(-1)\n sp(s) = 0\n val deque = mutable.ArrayDeque[Int]()\n deque.append(s)\n while (deque.nonEmpty) {\n val u = deque.removeHead()\n for ((v, w) <- adj(u) if (sp(v) == -1 || sp(u) + w < sp(v))) {\n sp(v) = sp(u) + w\n if (w == 0) {\n deque.prepend(v)\n } else {\n deque.append(v)\n }\n }\n }\n sp\n }\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": "p03560", "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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 912, "cpu_time_ms": 820, "memory_kb": 96588}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s680299041", "group_id": "codeNet:p03563", "input_text": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n val r: Int = sc.nextLine.toInt\n val g: Int = sc.nextLine.toInt\n println(2 * g - r)\n }\n}\n", "language": "Scala", "metadata": {"date": 1557712105, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s680299041.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s680299041", "user_id": "u629133942"}, "prompt_components": {"gold_output": "2032\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n val r: Int = sc.nextLine.toInt\n val g: Int = sc.nextLine.toInt\n println(2 * g - r)\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 226, "cpu_time_ms": 343, "memory_kb": 27216}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s394760212", "group_id": "codeNet:p03564", "input_text": "object Main extends App {\n val scanner = new java.util.Scanner(System.in)\n val n = scanner.next().toInt\n val k = scanner.next().toInt\n println(sim(1, k, n).min)\n \n def sim(n: Int, k: Int, cnt: Int): List[Int] = {\n if (cnt == 0) { \n List(n)\n } else {\n sim(n+k, k, cnt-1) ::: sim(n*2, k, cnt-1)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1524756223, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s394760212.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s394760212", "user_id": "u219949952"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "object Main extends App {\n val scanner = new java.util.Scanner(System.in)\n val n = scanner.next().toInt\n val k = scanner.next().toInt\n println(sim(1, k, n).min)\n \n def sim(n: Int, k: Int, cnt: Int): List[Int] = {\n if (cnt == 0) { \n List(n)\n } else {\n sim(n+k, k, cnt-1) ::: sim(n*2, k, cnt-1)\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 375, "memory_kb": 25672}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s914875398", "group_id": "codeNet:p03575", "input_text": "import java.io.{BufferedReader, InputStreamReader}\n\nobject Main extends App {\n\n val in = new BufferedReader(new InputStreamReader(System.in))\n val Array(n, m) = in.readLine.split(\" \").map(_.toInt)\n val edges = Iterator.continually(in.readLine)\n .take(m)\n .map(_.split(\" \").map(_.toInt))\n .toArray\n\n val graph = {\n val arr = Array.ofDim[Boolean](n+1,n+1)\n for(edge <- edges) {\n arr(edge(0))(edge(1)) = true\n arr(edge(1))(edge(0)) = true\n }\n arr\n }\n var visit = Array.ofDim[Boolean](n+1)\n\n def dfs(v:Int):Unit = {\n if(visit(v)) return\n visit(v) = true\n for(i <- 1 to n) {\n if(graph(v)(i)) dfs(i)\n }\n }\n\n val ans = {\n for(edge <- edges) yield {\n visit = Array.fill(n+1)(false)\n graph(edge(0))(edge(1)) = false\n graph(edge(1))(edge(0)) = false\n dfs(edge(0))\n // println(visit.mkString(\" \"))\n graph(edge(0))(edge(1)) = true\n graph(edge(1))(edge(0)) = true\n visit.tail.forall(_ == true)\n }\n }\n\n println(ans.count(_ == false))\n}", "language": "Scala", "metadata": {"date": 1546458787, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s914875398.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s914875398", "user_id": "u217010036"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.io.{BufferedReader, InputStreamReader}\n\nobject Main extends App {\n\n val in = new BufferedReader(new InputStreamReader(System.in))\n val Array(n, m) = in.readLine.split(\" \").map(_.toInt)\n val edges = Iterator.continually(in.readLine)\n .take(m)\n .map(_.split(\" \").map(_.toInt))\n .toArray\n\n val graph = {\n val arr = Array.ofDim[Boolean](n+1,n+1)\n for(edge <- edges) {\n arr(edge(0))(edge(1)) = true\n arr(edge(1))(edge(0)) = true\n }\n arr\n }\n var visit = Array.ofDim[Boolean](n+1)\n\n def dfs(v:Int):Unit = {\n if(visit(v)) return\n visit(v) = true\n for(i <- 1 to n) {\n if(graph(v)(i)) dfs(i)\n }\n }\n\n val ans = {\n for(edge <- edges) yield {\n visit = Array.fill(n+1)(false)\n graph(edge(0))(edge(1)) = false\n graph(edge(1))(edge(0)) = false\n dfs(edge(0))\n // println(visit.mkString(\" \"))\n graph(edge(0))(edge(1)) = true\n graph(edge(1))(edge(0)) = true\n visit.tail.forall(_ == true)\n }\n }\n\n println(ans.count(_ == false))\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= K){\n ans = ans.min((rx-lx)*(uy-by))\n }\n }\n }\n }\n }\n assert(ans >= 0)\n println(ans)\n }\n}\n", "language": "Scala", "metadata": {"date": 1508043573, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s572960018.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s572960018", "user_id": "u013750540"}, "prompt_components": {"gold_output": "21\n", "input_to_evaluate": "object Main{\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val N = sc.nextInt\n val K = sc.nextInt\n\n val x_ = Array.ofDim[BigInt](N)\n val y_ = Array.ofDim[BigInt](N)\n for(i <- 0 to N-1){\n x_(i) = sc.nextInt\n y_(i) = sc.nextInt\n }\n\n val x = x_.sorted\n val y = y_.sorted\n\n println(x.deep)\n println(y.deep)\n\n var ans : BigInt = (x(N-1)-x(0)) * (y(N-1)-y(0))\n println(\"ans : \" + ans)\n for(xi <- 0 to N-1){\n for(xj <- xi+1 to N-1){\n for(yi <- 0 to N-1){\n for(yj <- yi+1 to N-1){\n val lx = x(xi)\n val rx = x(xj)\n val by = y(yi)\n val uy = y(yj)\n\n var cnt = 0\n for(i <- 0 to N-1){\n if(lx<=x(i) && x(i)<=rx && by<=y(i) && y(i)<=uy) cnt = cnt + 1\n }\n\n if((rx-lx)*(uy-by) == 10){\n println(x(xi) + \" \" + x(xj) + \" \" + y(yi) + \" \" + y(yj))\n }\n if(cnt >= K){\n ans = ans.min((rx-lx)*(uy-by))\n }\n }\n }\n }\n }\n assert(ans >= 0)\n println(ans)\n }\n}\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 max._1)\n max = (concent, weight, s)\n }\n max\n }\n \n println(ans._2 + \" \" + ans._3)\n}", "language": "Scala", "metadata": {"date": 1546473257, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s155003070.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s155003070", "user_id": "u217010036"}, "prompt_components": {"gold_output": "110 10\n", "input_to_evaluate": "import java.io.{BufferedReader, InputStreamReader}\nimport java.util.Arrays\n\nobject Main extends App {\n\n val in = new BufferedReader(new InputStreamReader(System.in))\n val Array(a, b, c, d, e, f) = in.readLine.split(\" \").map(_.toInt)\n // 入れる水の量 100a 100b\n // 入れる砂糖の量 c d\n // 100gあたりとける量 e\n // ビーカーに入る量 f\n val water = {\n for {\n i <- 0 to f/(a*100)\n j <- 0 to f/(b*100)\n w = 100 * a * i + 100 * b * j\n if(0 < w && w <= f)\n } yield w\n }.distinct.toArray\n val sugar = {\n for {\n i <- 0 to (f-100)/c\n j <- 0 to (f-100)/d\n w = c * i + d * j\n if(0 < w && w <= f)\n } yield w\n }.distinct.toArray\n\n // println(water.length + \" \" + sugar.length)\n\n val ans = {\n var max = (0d, 0, 0)\n for {\n w <- water\n s <- sugar\n weight = w + s\n concent = s.toDouble / (w.toDouble/100d)\n if w + s <= f && concent <= e\n } {\n // println(weight + \" \" + concent)\n if(concent > max._1)\n max = (concent, weight, s)\n }\n max\n }\n \n println(ans._2 + \" \" + ans._3)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 609, "memory_kb": 44416}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s222702331", "group_id": "codeNet:p03601", "input_text": "import java.io.{BufferedReader, InputStream, InputStreamReader, PrintWriter}\nimport java.util.StringTokenizer\n\nimport scala.collection.mutable\nimport scala.util.Sorting\nimport math.{abs, max, min}\nimport scala.collection.mutable.{ArrayBuffer, ListBuffer}\nimport scala.reflect.ClassTag\n\nobject Main {\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n def solve(): Unit = {\n val sc = new InputReader(System.in)\n val A, B, C, D, E, F = sc.nextInt()\n\n def waters: Array[Int] = {\n val set = mutable.HashSet[Int]()\n for {\n a <- 0 to F / A / 100\n b <- 0 to F / B / 100\n } {\n val w = a * A + b * B\n if (w * 100 <= F && w > 0) set += w\n }\n set.toArray\n }\n\n def sugars: Array[Int] = {\n val set = mutable.HashSet[Int]()\n for {\n c <- 0 to F / C\n d <- 0 to F / D\n } {\n val s = c * C + d * D\n if (s <= F) set += s\n }\n set.toArray\n }\n\n val (w, s) = (for {\n w <- waters\n s <- sugars\n if w * 100 + s <= F && s <= w * E\n } yield (w * 100, s)).maxBy(x => x._2.toDouble / (x._1 + x._2))\n\n out.println(s\"${s + w} $s\")\n }\n\n\n def main(args: Array[String]): Unit = {\n solve()\n out.flush()\n }\n\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = null\n\n def next: String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next.toInt\n def nextLong(): Long = next.toLong\n def nextChar(): Char = next.charAt(0)\n }\n\n private def rep(n: Int)(f: Int => Unit): Unit = (0 until n) foreach f\n\n private def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n (0 until n) foreach (i => res(i) = f(i))\n res\n }\n\n private implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {\n def maxByOpt[B: Ordering](f: A => B): Option[A] = {\n if (as.nonEmpty) Some(as.maxBy(f)) else None\n }\n\n def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {\n val map = mutable.Map.empty[K, ArrayBuffer[A]]\n rep(a => map.getOrElseUpdate(f(a), ArrayBuffer()) += a)\n map\n }\n\n def rep(f: A => Unit): Unit = {\n as.indices foreach (i => f(as(i)))\n }\n\n def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {\n var sum = num.zero\n rep(a => sum = num.plus(sum, f(a)))\n sum\n }\n }\n\n private implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {\n def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {\n as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))\n }\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1530597874, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03601.html", "problem_id": "p03601", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03601/input.txt", "sample_output_relpath": "derived/input_output/data/p03601/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03601/Scala/s222702331.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s222702331", "user_id": "u460609472"}, "prompt_components": {"gold_output": "110 10\n", "input_to_evaluate": "import java.io.{BufferedReader, InputStream, InputStreamReader, PrintWriter}\nimport java.util.StringTokenizer\n\nimport scala.collection.mutable\nimport scala.util.Sorting\nimport math.{abs, max, min}\nimport scala.collection.mutable.{ArrayBuffer, ListBuffer}\nimport scala.reflect.ClassTag\n\nobject Main {\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n def solve(): Unit = {\n val sc = new InputReader(System.in)\n val A, B, C, D, E, F = sc.nextInt()\n\n def waters: Array[Int] = {\n val set = mutable.HashSet[Int]()\n for {\n a <- 0 to F / A / 100\n b <- 0 to F / B / 100\n } {\n val w = a * A + b * B\n if (w * 100 <= F && w > 0) set += w\n }\n set.toArray\n }\n\n def sugars: Array[Int] = {\n val set = mutable.HashSet[Int]()\n for {\n c <- 0 to F / C\n d <- 0 to F / D\n } {\n val s = c * C + d * D\n if (s <= F) set += s\n }\n set.toArray\n }\n\n val (w, s) = (for {\n w <- waters\n s <- sugars\n if w * 100 + s <= F && s <= w * E\n } yield (w * 100, s)).maxBy(x => x._2.toDouble / (x._1 + x._2))\n\n out.println(s\"${s + w} $s\")\n }\n\n\n def main(args: Array[String]): Unit = {\n solve()\n out.flush()\n }\n\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = null\n\n def next: String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next.toInt\n def nextLong(): Long = next.toLong\n def nextChar(): Char = next.charAt(0)\n }\n\n private def rep(n: Int)(f: Int => Unit): Unit = (0 until n) foreach f\n\n private def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n (0 until n) foreach (i => res(i) = f(i))\n res\n }\n\n private implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {\n def maxByOpt[B: Ordering](f: A => B): Option[A] = {\n if (as.nonEmpty) Some(as.maxBy(f)) else None\n }\n\n def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {\n val map = mutable.Map.empty[K, ArrayBuffer[A]]\n rep(a => map.getOrElseUpdate(f(a), ArrayBuffer()) += a)\n map\n }\n\n def rep(f: A => Unit): Unit = {\n as.indices foreach (i => f(as(i)))\n }\n\n def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {\n var sum = num.zero\n rep(a => sum = num.plus(sum, f(a)))\n sum\n }\n }\n\n private implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {\n def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {\n as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))\n }\n }\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": "p03601", "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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2791, "cpu_time_ms": 505, "memory_kb": 40264}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s045735787", "group_id": "codeNet:p03605", "input_text": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val n = in.readLine.map(_.toString.toInt)\n val ans = if(n.exists(_ == 9)) \"Yes\" else \"No\"\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1549339417, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s045735787.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s045735787", "user_id": "u217010036"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val n = in.readLine.map(_.toString.toInt)\n val ans = if(n.exists(_ == 9)) \"Yes\" else \"No\"\n println(ans)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 347, "memory_kb": 25512}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s437405055", "group_id": "codeNet:p03605", "input_text": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val n = in.readLine.map(_.toString.toInt)\n println(n.mkString(\" \"))\n val ans = if(n.exists(_ == 9)) \"Yes\" else \"No\"\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1549339375, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s437405055.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s437405055", "user_id": "u217010036"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val n = in.readLine.map(_.toString.toInt)\n println(n.mkString(\" \"))\n val ans = if(n.exists(_ == 9)) \"Yes\" else \"No\"\n println(ans)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 193, "cpu_time_ms": 333, "memory_kb": 27412}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s998776725", "group_id": "codeNet:p03607", "input_text": "object Main extends App {\n\tval N = scala.io.StdIn.readInt\n\tvar temp = List[Long]()\n\n\tfor(i<-0 until N){\n\t\tval A = scala.io.StdIn.readLong\n\t\tif(temp.contains(A)) temp = temp.filterNot(_==A)\n\t\telse temp = A::temp\n\t}\n\n\tprintln(temp.size)\n}\n", "language": "Scala", "metadata": {"date": 1505009841, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s998776725.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s998776725", "user_id": "u675876401"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main extends App {\n\tval N = scala.io.StdIn.readInt\n\tvar temp = List[Long]()\n\n\tfor(i<-0 until N){\n\t\tval A = scala.io.StdIn.readLong\n\t\tif(temp.contains(A)) temp = temp.filterNot(_==A)\n\t\telse temp = A::temp\n\t}\n\n\tprintln(temp.size)\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 116316}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s992309154", "group_id": "codeNet:p03609", "input_text": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n val Array(x, t) = sc.nextLine.split(\" \").map(_.toInt)\n println(Array(0, x-t).max)\n }\n}\n", "language": "Scala", "metadata": {"date": 1557713154, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03609.html", "problem_id": "p03609", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03609/input.txt", "sample_output_relpath": "derived/input_output/data/p03609/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03609/Scala/s992309154.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s992309154", "user_id": "u629133942"}, "prompt_components": {"gold_output": "83\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n val Array(x, t) = sc.nextLine.split(\" \").map(_.toInt)\n println(Array(0, x-t).max)\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand.\n\nHow many grams of sand will the upper bulb contains after t seconds?\n\nConstraints\n\n1≤X≤10^9\n\n1≤t≤10^9\n\nX and t are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nX t\n\nOutput\n\nPrint the number of sand in the upper bulb after t second.\n\nSample Input 1\n\n100 17\n\nSample Output 1\n\n83\n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83 grams.\n\nSample Input 2\n\n48 58\n\nSample Output 2\n\n0\n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n0", "sample_input": "100 17\n"}, "reference_outputs": ["83\n"], "source_document_id": "p03609", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand.\n\nHow many grams of sand will the upper bulb contains after t seconds?\n\nConstraints\n\n1≤X≤10^9\n\n1≤t≤10^9\n\nX and t are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nX t\n\nOutput\n\nPrint the number of sand in the upper bulb after t second.\n\nSample Input 1\n\n100 17\n\nSample Output 1\n\n83\n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83 grams.\n\nSample Input 2\n\n48 58\n\nSample Output 2\n\n0\n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 365, "memory_kb": 25416}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s378103789", "group_id": "codeNet:p03609", "input_text": "object Main extends App {\n\tval temp = scala.io.StdIn.readLine.split(\" \").map(_.toLong)\n\n\tval result = temp(0)-temp(1)\n\n\tif(result>=0)println(result)\n\telse println(0)\n}", "language": "Scala", "metadata": {"date": 1504406670, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03609.html", "problem_id": "p03609", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03609/input.txt", "sample_output_relpath": "derived/input_output/data/p03609/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03609/Scala/s378103789.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s378103789", "user_id": "u675876401"}, "prompt_components": {"gold_output": "83\n", "input_to_evaluate": "object Main extends App {\n\tval temp = scala.io.StdIn.readLine.split(\" \").map(_.toLong)\n\n\tval result = temp(0)-temp(1)\n\n\tif(result>=0)println(result)\n\telse println(0)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand.\n\nHow many grams of sand will the upper bulb contains after t seconds?\n\nConstraints\n\n1≤X≤10^9\n\n1≤t≤10^9\n\nX and t are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nX t\n\nOutput\n\nPrint the number of sand in the upper bulb after t second.\n\nSample Input 1\n\n100 17\n\nSample Output 1\n\n83\n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83 grams.\n\nSample Input 2\n\n48 58\n\nSample Output 2\n\n0\n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n0", "sample_input": "100 17\n"}, "reference_outputs": ["83\n"], "source_document_id": "p03609", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand.\n\nHow many grams of sand will the upper bulb contains after t seconds?\n\nConstraints\n\n1≤X≤10^9\n\n1≤t≤10^9\n\nX and t are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nX t\n\nOutput\n\nPrint the number of sand in the upper bulb after t second.\n\nSample Input 1\n\n100 17\n\nSample Output 1\n\n83\n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83 grams.\n\nSample Input 2\n\n48 58\n\nSample Output 2\n\n0\n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 315, "memory_kb": 25296}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s765136666", "group_id": "codeNet:p03610", "input_text": "object Main extends App {\n val s = readLine.toArray\n var i = 0\n while (i < s.length) {\n print(s(i))\n i += 2\n }\n}", "language": "Scala", "metadata": {"date": 1575931074, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s765136666.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s765136666", "user_id": "u696665136"}, "prompt_components": {"gold_output": "acdr\n", "input_to_evaluate": "object Main extends App {\n val s = readLine.toArray\n var i = 0\n while (i < s.length) {\n print(s(i))\n i += 2\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 764, "memory_kb": 40388}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s567788234", "group_id": "codeNet:p03610", "input_text": "object Main extends App {\n val s = readLine.split(\"\")\n println(s.zipWithIndex.filter{case (_,index) => index%2 == 1}.map{case (x,_) => x}.foldLeft(\"\"){_ + _})\n}", "language": "Scala", "metadata": {"date": 1575927618, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s567788234.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s567788234", "user_id": "u696665136"}, "prompt_components": {"gold_output": "acdr\n", "input_to_evaluate": "object Main extends App {\n val s = readLine.split(\"\")\n println(s.zipWithIndex.filter{case (_,index) => index%2 == 1}.map{case (x,_) => x}.foldLeft(\"\"){_ + _})\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 119572}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s137195179", "group_id": "codeNet:p03610", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val s = sc.next\n\n val res = s.zipWithIndex.filter(_._2 % 2 == 0).map(_._1).mkString\n\n println(res)\n}", "language": "Scala", "metadata": {"date": 1557623080, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s137195179.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s137195179", "user_id": "u829407811"}, "prompt_components": {"gold_output": "acdr\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val s = sc.next\n\n val res = s.zipWithIndex.filter(_._2 % 2 == 0).map(_._1).mkString\n\n println(res)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 573, "memory_kb": 36368}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s845776191", "group_id": "codeNet:p03611", "input_text": "import io.StdIn._\nobject Main extends App {\n val n = readInt\n val as = readLine.split(\" \").map(_.toInt)\n \n val number = as.distinct\n val counts = number.map(n => as.filter(a => n-1 == a || n == a || n+1 == a).length)\n\n println(counts.max)\n}", "language": "Scala", "metadata": {"date": 1591845917, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s845776191.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s845776191", "user_id": "u104354966"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import io.StdIn._\nobject Main extends App {\n val n = readInt\n val as = readLine.split(\" \").map(_.toInt)\n \n val number = as.distinct\n val counts = number.map(n => as.filter(a => n-1 == a || n == a || n+1 == a).length)\n\n println(counts.max)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 258, "cpu_time_ms": 2107, "memory_kb": 120028}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s056352578", "group_id": "codeNet:p03611", "input_text": "import scala.collection.mutable\nimport java.io.{BufferedReader, InputStreamReader}\n\nobject Main extends App {\n val in = new BufferedReader(new InputStreamReader(System.in))\n val map = mutable.HashMap[Int,Int]()\n\n val n = in.readLine.toInt\n in.readLine.split(\" \").map(_.toInt)\n .foreach(e => {\n if(!map.contains(e)) map += e -> 1\n else map(e) +=1\n })\n\n val x = map.keySet\n\n val ans = {\n var max = -1\n for {\n i <- x\n } {\n var cnt = 0\n map.foreach(e => {\n if(i-1 <= e._1 && e._1 <= i+1) cnt += e._2\n })\n\n if(cnt > max) max = cnt\n }\n max\n }\n\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1546491310, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s056352578.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s056352578", "user_id": "u217010036"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import scala.collection.mutable\nimport java.io.{BufferedReader, InputStreamReader}\n\nobject Main extends App {\n val in = new BufferedReader(new InputStreamReader(System.in))\n val map = mutable.HashMap[Int,Int]()\n\n val n = in.readLine.toInt\n in.readLine.split(\" \").map(_.toInt)\n .foreach(e => {\n if(!map.contains(e)) map += e -> 1\n else map(e) +=1\n })\n\n val x = map.keySet\n\n val ans = {\n var max = -1\n for {\n i <- x\n } {\n var cnt = 0\n map.foreach(e => {\n if(i-1 <= e._1 && e._1 <= i+1) cnt += e._2\n })\n\n if(cnt > max) max = cnt\n }\n max\n }\n\n println(ans)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 117556}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s423073337", "group_id": "codeNet:p03611", "input_text": "object Main extends App {\n\tval N = scala.io.StdIn.readInt\n\tval A = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\n\tval map = scala.collection.mutable.Map[Int,Int]()\n\n\tfor(x <- A){\n\t\tmap.put(x - 1, map.getOrElse(x - 1, 0) + 1)\n\t\tmap.put(x , map.getOrElse(x , 0) + 1)\n\t\tmap.put(x + 1, map.getOrElse(x + 1, 0) + 1)\n\t}\n\tprintln(map.maxBy(_._2)._2)\n}\n", "language": "Scala", "metadata": {"date": 1504564015, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s423073337.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s423073337", "user_id": "u675876401"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "object Main extends App {\n\tval N = scala.io.StdIn.readInt\n\tval A = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\n\tval map = scala.collection.mutable.Map[Int,Int]()\n\n\tfor(x <- A){\n\t\tmap.put(x - 1, map.getOrElse(x - 1, 0) + 1)\n\t\tmap.put(x , map.getOrElse(x , 0) + 1)\n\t\tmap.put(x + 1, map.getOrElse(x + 1, 0) + 1)\n\t}\n\tprintln(map.maxBy(_._2)._2)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 736, "memory_kb": 55888}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s163935397", "group_id": "codeNet:p03613", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt()\n val as = List.fill(n)(sc.nextInt()+1)\n val b = Array.fill(100002)(0)\n for (a <- as) {\n b(a-1) += 1\n b(a) += 1\n b(a+1) += 1\n }\n println(b.max)\n}\n", "language": "Scala", "metadata": {"date": 1596942228, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03613.html", "problem_id": "p03613", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03613/input.txt", "sample_output_relpath": "derived/input_output/data/p03613/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03613/Scala/s163935397.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s163935397", "user_id": "u191819389"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt()\n val as = List.fill(n)(sc.nextInt()+1)\n val b = Array.fill(100002)(0)\n for (a <- as) {\n b(a-1) += 1\n b(a) += 1\n b(a+1) += 1\n }\n println(b.max)\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": "p03613", "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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 252, "cpu_time_ms": 815, "memory_kb": 62376}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s461563643", "group_id": "codeNet:p03617", "input_text": "import java.util.Scanner\n\nobject Main {\n\n def solve(sc: => Scanner): Unit = {\n val A1 = math.min(sc.nextLong * 4, math.min(sc.nextLong * 2, sc.nextLong))\n val A2 = math.min(A1 * 2, sc.nextLong)\n val N = sc.nextLong\n println((N / 2: Long) * A2 + N % 2 * A1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}\n", "language": "Scala", "metadata": {"date": 1504919927, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s461563643.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s461563643", "user_id": "u779353743"}, "prompt_components": {"gold_output": "150\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n\n def solve(sc: => Scanner): Unit = {\n val A1 = math.min(sc.nextLong * 4, math.min(sc.nextLong * 2, sc.nextLong))\n val A2 = math.min(A1 * 2, sc.nextLong)\n val N = sc.nextLong\n println((N / 2: Long) * A2 + N % 2 * A1)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 382, "cpu_time_ms": 350, "memory_kb": 25884}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s096431815", "group_id": "codeNet:p03625", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n\n val n = StdIn.readLine().toInt\n val a = StdIn.readLine().split(\" \")\n val r = a.foldLeft(Map.empty[Int, Int]) { (acc, s) =>\n val key = s.toInt\n if (acc.contains(key)) acc.updated(key, acc(key) + 1)\n else acc + (key -> 1)\n }\n\n val tar = r.filter(p => 2 <= p._2)\n val keys = tar.keys.toList.sortBy(e => -1 * e)\n val ans = if (tar.isEmpty) {\n 0\n }else if (tar.getOrElse(keys.head, 0) >= 4) {\n keys.head * keys.head\n }\n else if (tar.getOrElse(keys.head, 0) >= 2 &&\n tar.getOrElse(keys.tail.head, 0) >= 2) {\n keys.head * keys.tail.head\n } else {\n 0\n }\n println (ans)\n}\n", "language": "Scala", "metadata": {"date": 1531181197, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03625.html", "problem_id": "p03625", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03625/input.txt", "sample_output_relpath": "derived/input_output/data/p03625/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03625/Scala/s096431815.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s096431815", "user_id": "u895032849"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n\n val n = StdIn.readLine().toInt\n val a = StdIn.readLine().split(\" \")\n val r = a.foldLeft(Map.empty[Int, Int]) { (acc, s) =>\n val key = s.toInt\n if (acc.contains(key)) acc.updated(key, acc(key) + 1)\n else acc + (key -> 1)\n }\n\n val tar = r.filter(p => 2 <= p._2)\n val keys = tar.keys.toList.sortBy(e => -1 * e)\n val ans = if (tar.isEmpty) {\n 0\n }else if (tar.getOrElse(keys.head, 0) >= 4) {\n keys.head * keys.head\n }\n else if (tar.getOrElse(keys.head, 0) >= 2 &&\n tar.getOrElse(keys.tail.head, 0) >= 2) {\n keys.head * keys.tail.head\n } else {\n 0\n }\n println (ans)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have N sticks with negligible thickness.\nThe length of the i-th stick is A_i.\n\nSnuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides.\nFind the maximum possible area of the rectangle.\n\nConstraints\n\n4 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nA_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible area of the rectangle.\nIf no rectangle can be formed, print 0.\n\nSample Input 1\n\n6\n3 1 2 4 2 1\n\nSample Output 1\n\n2\n\n1 \\times 2 rectangle can be formed.\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\n0\n\nNo rectangle can be formed.\n\nSample Input 3\n\n10\n3 3 3 3 4 4 4 5 5 5\n\nSample Output 3\n\n20", "sample_input": "6\n3 1 2 4 2 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03625", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have N sticks with negligible thickness.\nThe length of the i-th stick is A_i.\n\nSnuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides.\nFind the maximum possible area of the rectangle.\n\nConstraints\n\n4 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nA_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible area of the rectangle.\nIf no rectangle can be formed, print 0.\n\nSample Input 1\n\n6\n3 1 2 4 2 1\n\nSample Output 1\n\n2\n\n1 \\times 2 rectangle can be formed.\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\n0\n\nNo rectangle can be formed.\n\nSample Input 3\n\n10\n3 3 3 3 4 4 4 5 5 5\n\nSample Output 3\n\n20", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 651, "cpu_time_ms": 1082, "memory_kb": 96460}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s057209438", "group_id": "codeNet:p03629", "input_text": "\nimport java.util.Scanner\n\nobject Main extends App {\n\n val FF = (1 << 26) - 1\n\n val sc = new Scanner(System.in)\n\n val str = sc.next()\n var cs = Array.fill(26)(Seq[Int](Int.MaxValue))\n str.zipWithIndex\n .groupBy(_._1)\n .toStream\n .foreach {\n case (c, seq) =>\n// println(c, seq)\n cs(c - 'a') = seq.map(_._2) ++ Seq(Int.MaxValue)\n }\n\n\n var bf = 0\n var len = 0\n for (c <- str.reverse) {\n bf = bf | (1 << (c - 'a'))\n\n if (bf == FF) {\n bf = 0\n len = len + 1\n }\n }\n\n\n// cs.foreach(println(_))\n// println(\"info\", len, bf)\n\n val head = Range(0, 26)\n .find(i => ((bf >> i) & 1) == 0).get\n print(('a' + head).toChar)\n\n var cur = cs(head)(0)\n for (i <- 1 to len) {\n cur = find(cur, len - i + 2)\n }\n println\n\n def find(x: Int, k: Int): Int = {\n for (c <- 0 to 25) {\n val t = find(x, cs(c))\n// println(\"inner\", ('a' + c).toChar, k, t, cs(c).length - t)\n if (cs(c).length - t <= k) {\n print(('a' + c).toChar)\n return if (cs(c).isEmpty) 0 else cs(c)(t)\n }\n }\n 0\n }\n\n def find(x: Int, seq: Seq[Int]) = {\n var l = 0\n var r = seq.length\n while (l < r) {\n val m = (l + r) / 2\n if (seq(m) <= x) l = m + 1\n else r = m\n }\n l\n }\n}\n", "language": "Scala", "metadata": {"date": 1504574777, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03629.html", "problem_id": "p03629", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03629/input.txt", "sample_output_relpath": "derived/input_output/data/p03629/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03629/Scala/s057209438.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s057209438", "user_id": "u726872801"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "\nimport java.util.Scanner\n\nobject Main extends App {\n\n val FF = (1 << 26) - 1\n\n val sc = new Scanner(System.in)\n\n val str = sc.next()\n var cs = Array.fill(26)(Seq[Int](Int.MaxValue))\n str.zipWithIndex\n .groupBy(_._1)\n .toStream\n .foreach {\n case (c, seq) =>\n// println(c, seq)\n cs(c - 'a') = seq.map(_._2) ++ Seq(Int.MaxValue)\n }\n\n\n var bf = 0\n var len = 0\n for (c <- str.reverse) {\n bf = bf | (1 << (c - 'a'))\n\n if (bf == FF) {\n bf = 0\n len = len + 1\n }\n }\n\n\n// cs.foreach(println(_))\n// println(\"info\", len, bf)\n\n val head = Range(0, 26)\n .find(i => ((bf >> i) & 1) == 0).get\n print(('a' + head).toChar)\n\n var cur = cs(head)(0)\n for (i <- 1 to len) {\n cur = find(cur, len - i + 2)\n }\n println\n\n def find(x: Int, k: Int): Int = {\n for (c <- 0 to 25) {\n val t = find(x, cs(c))\n// println(\"inner\", ('a' + c).toChar, k, t, cs(c).length - t)\n if (cs(c).length - t <= k) {\n print(('a' + c).toChar)\n return if (cs(c).isEmpty) 0 else cs(c)(t)\n }\n }\n 0\n }\n\n def find(x: Int, seq: Seq[Int]) = {\n var l = 0\n var r = seq.length\n while (l < r) {\n val m = (l + r) / 2\n if (seq(m) <= x) l = m + 1\n else r = m\n }\n l\n }\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nA subsequence of a string S is a string that can be obtained by deleting zero or more characters from S without changing the order of the remaining characters.\nFor example, arc, artistic and (an empty string) are all subsequences of artistic; abc and ci are not.\n\nYou are given a string A consisting of lowercase English letters.\nFind the shortest string among the strings consisting of lowercase English letters that are not subsequences of A.\nIf there are more than one such string, find the lexicographically smallest one among them.\n\nConstraints\n\n1 \\leq |A| \\leq 2 \\times 10^5\n\nA consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\n\nOutput\n\nPrint the lexicographically smallest string among the shortest strings consisting of lowercase English letters that are not subsequences of A.\n\nSample Input 1\n\natcoderregularcontest\n\nSample Output 1\n\nb\n\nThe string atcoderregularcontest contains a as a subsequence, but not b.\n\nSample Input 2\n\nabcdefghijklmnopqrstuvwxyz\n\nSample Output 2\n\naa\n\nSample Input 3\n\nfrqnvhydscshfcgdemurlfrutcpzhopfotpifgepnqjxupnskapziurswqazdwnwbgdhyktfyhqqxpoidfhjdakoxraiedxskywuepzfniuyskxiyjpjlxuqnfgmnjcvtlpnclfkpervxmdbvrbrdn\n\nSample Output 3\n\naca", "sample_input": "atcoderregularcontest\n"}, "reference_outputs": ["b\n"], "source_document_id": "p03629", "source_text": "Score : 600 points\n\nProblem Statement\n\nA subsequence of a string S is a string that can be obtained by deleting zero or more characters from S without changing the order of the remaining characters.\nFor example, arc, artistic and (an empty string) are all subsequences of artistic; abc and ci are not.\n\nYou are given a string A consisting of lowercase English letters.\nFind the shortest string among the strings consisting of lowercase English letters that are not subsequences of A.\nIf there are more than one such string, find the lexicographically smallest one among them.\n\nConstraints\n\n1 \\leq |A| \\leq 2 \\times 10^5\n\nA consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\n\nOutput\n\nPrint the lexicographically smallest string among the shortest strings consisting of lowercase English letters that are not subsequences of A.\n\nSample Input 1\n\natcoderregularcontest\n\nSample Output 1\n\nb\n\nThe string atcoderregularcontest contains a as a subsequence, but not b.\n\nSample Input 2\n\nabcdefghijklmnopqrstuvwxyz\n\nSample Output 2\n\naa\n\nSample Input 3\n\nfrqnvhydscshfcgdemurlfrutcpzhopfotpifgepnqjxupnskapziurswqazdwnwbgdhyktfyhqqxpoidfhjdakoxraiedxskywuepzfniuyskxiyjpjlxuqnfgmnjcvtlpnclfkpervxmdbvrbrdn\n\nSample Output 3\n\naca", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1116, "memory_kb": 65092}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s540028379", "group_id": "codeNet:p03631", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val n = sc.nextInt\n \n val res = if(n / 100 == n % 10) \"Yes\" else \"No\"\n\n println(res)\n}", "language": "Scala", "metadata": {"date": 1557441955, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03631.html", "problem_id": "p03631", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03631/input.txt", "sample_output_relpath": "derived/input_output/data/p03631/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03631/Scala/s540028379.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s540028379", "user_id": "u829407811"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val n = sc.nextInt\n \n val res = if(n / 100 == n % 10) \"Yes\" else \"No\"\n\n println(res)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a three-digit positive integer N.\n\nDetermine whether N is a palindromic number.\n\nHere, a palindromic number is an integer that reads the same backward as forward in decimal notation.\n\nConstraints\n\n100≤N≤999\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N is a palindromic number, print Yes; otherwise, print No.\n\nSample Input 1\n\n575\n\nSample Output 1\n\nYes\n\nN=575 is also 575 when read backward, so it is a palindromic number. You should print Yes.\n\nSample Input 2\n\n123\n\nSample Output 2\n\nNo\n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You should print No.\n\nSample Input 3\n\n812\n\nSample Output 3\n\nNo", "sample_input": "575\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03631", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a three-digit positive integer N.\n\nDetermine whether N is a palindromic number.\n\nHere, a palindromic number is an integer that reads the same backward as forward in decimal notation.\n\nConstraints\n\n100≤N≤999\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N is a palindromic number, print Yes; otherwise, print No.\n\nSample Input 1\n\n575\n\nSample Output 1\n\nYes\n\nN=575 is also 575 when read backward, so it is a palindromic number. You should print Yes.\n\nSample Input 2\n\n123\n\nSample Output 2\n\nNo\n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You should print No.\n\nSample Input 3\n\n812\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 342, "memory_kb": 27592}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s510485697", "group_id": "codeNet:p03631", "input_text": "import java.util.Scanner\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val S = sc.next\n println(if (S.reverse.equals(S)) (\"Yes\") else (\"No\"))\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}", "language": "Scala", "metadata": {"date": 1502677687, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03631.html", "problem_id": "p03631", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03631/input.txt", "sample_output_relpath": "derived/input_output/data/p03631/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03631/Scala/s510485697.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s510485697", "user_id": "u779353743"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val S = sc.next\n println(if (S.reverse.equals(S)) (\"Yes\") else (\"No\"))\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a three-digit positive integer N.\n\nDetermine whether N is a palindromic number.\n\nHere, a palindromic number is an integer that reads the same backward as forward in decimal notation.\n\nConstraints\n\n100≤N≤999\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N is a palindromic number, print Yes; otherwise, print No.\n\nSample Input 1\n\n575\n\nSample Output 1\n\nYes\n\nN=575 is also 575 when read backward, so it is a palindromic number. You should print Yes.\n\nSample Input 2\n\n123\n\nSample Output 2\n\nNo\n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You should print No.\n\nSample Input 3\n\n812\n\nSample Output 3\n\nNo", "sample_input": "575\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03631", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a three-digit positive integer N.\n\nDetermine whether N is a palindromic number.\n\nHere, a palindromic number is an integer that reads the same backward as forward in decimal notation.\n\nConstraints\n\n100≤N≤999\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N is a palindromic number, print Yes; otherwise, print No.\n\nSample Input 1\n\n575\n\nSample Output 1\n\nYes\n\nN=575 is also 575 when read backward, so it is a palindromic number. You should print Yes.\n\nSample Input 2\n\n123\n\nSample Output 2\n\nNo\n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You should print No.\n\nSample Input 3\n\n812\n\nSample Output 3\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 346, "memory_kb": 25536}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s349592146", "group_id": "codeNet:p03632", "input_text": "object Main {\n def main(args: Array[String]) : Unit = {\n val sc = new java.util.Scanner(System.in)\n val a, b, c, d = sc.nextInt\n println(calc(a, b, c, d))\n }\n def calc(a: Int, b: Int, c: Int, d: Int) : Int = {\n var ans = max(b - c, 0)\n if (ans > 0 && b - d > 0) {\n ans -= b - d\n }\n ans\n }\n def max(a: Int, b: Int) : Int = { if (a > b) a else b }\n}\n", "language": "Scala", "metadata": {"date": 1503014874, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03632.html", "problem_id": "p03632", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03632/input.txt", "sample_output_relpath": "derived/input_output/data/p03632/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03632/Scala/s349592146.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s349592146", "user_id": "u566924053"}, "prompt_components": {"gold_output": "50\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]) : Unit = {\n val sc = new java.util.Scanner(System.in)\n val a, b, c, d = sc.nextInt\n println(calc(a, b, c, d))\n }\n def calc(a: Int, b: Int, c: Int, d: Int) : Int = {\n var ans = max(b - c, 0)\n if (ans > 0 && b - d > 0) {\n ans -= b - d\n }\n ans\n }\n def max(a: Int, b: Int) : Int = { if (a > b) a else b }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAlice and Bob are controlling a robot. They each have one switch that controls the robot.\n\nAlice started holding down her button A second after the start-up of the robot, and released her button B second after the start-up.\n\nBob started holding down his button C second after the start-up, and released his button D second after the start-up.\n\nFor how many seconds both Alice and Bob were holding down their buttons?\n\nConstraints\n\n0≤A {\n val a:Long = lcm(acc._2, e)\n (a,e)\n })._1\n\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1546570554, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s975286661.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s975286661", "user_id": "u217010036"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import scala.io.StdIn\n\nimport scala.annotation.tailrec\n\nobject Main extends App {\n val n = StdIn.readInt\n\n @tailrec\n def gdc(x:Long, y:Long):Long = {\n if(y == 0) x\n else gdc(y, x % y)\n }\n\n def lcm(x:Long, y:Long):Long = {\n x * (y / gdc(x, y))\n }\n\n val ans = Iterator.continually(StdIn.readLine.toLong)\n .take(n)\n ./:(0L,1L)((acc,e) => {\n val a:Long = lcm(acc._2, e)\n (a,e)\n })._1\n\n println(ans)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 329, "memory_kb": 27312}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s847968884", "group_id": "codeNet:p03634", "input_text": "import java.io._\nimport java.util.StringTokenizer\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val N = in.next().toInt\n // (node, cost)\n val graph: Array[List[(Int, Int)]] = Array.fill(N+1)(Nil)\n for(_ <- 1 to N-1) {\n val a, b, cost = in.next().toInt\n graph(a) = (b, cost) :: graph(a)\n graph(b) = (a, cost) :: graph(b)\n }\n\n val Q, K = in.next().toInt\n\n // dfs\n val stack = new scala.collection.mutable.Stack[(Int, Int)] // (nowNode, cost)\n stack.push((K, 0))\n\n val dp = new Array[Long](N+1)\n dp(K) = 2\n\n while (!stack.isEmpty) {\n val (now, accCost) = stack.pop\n for((node, cost) <- graph(now)) {\n if(dp(node) == 0) {\n dp(node) = accCost + cost\n stack.push((node, accCost + cost))\n }\n }\n }\n\n for (_ <- 1 to Q) {\n val x, y = in.next().toInt\n val ans = dp(x) + dp(y)\n pw.println(ans)\n }\n pw.flush()\n\n}\n\n\nclass InputReader(stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream))\n private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\n }\n}\n", "language": "Scala", "metadata": {"date": 1514247095, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s847968884.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s847968884", "user_id": "u098968285"}, "prompt_components": {"gold_output": "3\n2\n4\n", "input_to_evaluate": "import java.io._\nimport java.util.StringTokenizer\n\nobject Main extends App {\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val N = in.next().toInt\n // (node, cost)\n val graph: Array[List[(Int, Int)]] = Array.fill(N+1)(Nil)\n for(_ <- 1 to N-1) {\n val a, b, cost = in.next().toInt\n graph(a) = (b, cost) :: graph(a)\n graph(b) = (a, cost) :: graph(b)\n }\n\n val Q, K = in.next().toInt\n\n // dfs\n val stack = new scala.collection.mutable.Stack[(Int, Int)] // (nowNode, cost)\n stack.push((K, 0))\n\n val dp = new Array[Long](N+1)\n dp(K) = 2\n\n while (!stack.isEmpty) {\n val (now, accCost) = stack.pop\n for((node, cost) <- graph(now)) {\n if(dp(node) == 0) {\n dp(node) = accCost + cost\n stack.push((node, accCost + cost))\n }\n }\n }\n\n for (_ <- 1 to Q) {\n val x, y = in.next().toInt\n val ans = dp(x) + dp(y)\n pw.println(ans)\n }\n pw.flush()\n\n}\n\n\nclass InputReader(stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream))\n private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())\n def next(): String = {\n while (!tokenizer.hasMoreTokens()) {\n tokenizer = new StringTokenizer(reader.readLine())\n }\n tokenizer.nextToken()\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1286, "cpu_time_ms": 873, "memory_kb": 80132}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s341795612", "group_id": "codeNet:p03635", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val a = List.fill(n)(sc.nextInt)\n \n val multipleOf4 = a.filter( _ % 4 == 0)\n val multipleOf2 = a.filter( _ % 2 == 0)\n val ans = if (multipleOf4.length <= a.length / 2) {\n if (multipleOf4.length + (multipleOf2.length - multipleOf4.length) / 2 <= a.length / 2) \"Yes\"\n else \"No\"\n }\n else \"Yes\"\n \n println(ans)\n }\n}", "language": "Scala", "metadata": {"date": 1510881397, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03635.html", "problem_id": "p03635", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03635/input.txt", "sample_output_relpath": "derived/input_output/data/p03635/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03635/Scala/s341795612.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s341795612", "user_id": "u592088571"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val a = List.fill(n)(sc.nextInt)\n \n val multipleOf4 = a.filter( _ % 4 == 0)\n val multipleOf2 = a.filter( _ % 2 == 0)\n val ans = if (multipleOf4.length <= a.length / 2) {\n if (multipleOf4.length + (multipleOf2.length - multipleOf4.length) / 2 <= a.length / 2) \"Yes\"\n else \"No\"\n }\n else \"Yes\"\n \n println(ans)\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn K-city, there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city?\n\nConstraints\n\n2 ≤ n, m ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn m\n\nOutput\n\nPrint the number of blocks in K-city.\n\nSample Input 1\n\n3 4\n\nSample Output 1\n\n6\n\nThere are six blocks, as shown below:\n\nSample Input 2\n\n2 2\n\nSample Output 2\n\n1\n\nThere are one block, as shown below:", "sample_input": "3 4\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03635", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn K-city, there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city?\n\nConstraints\n\n2 ≤ n, m ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn m\n\nOutput\n\nPrint the number of blocks in K-city.\n\nSample Input 1\n\n3 4\n\nSample Output 1\n\n6\n\nThere are six blocks, as shown below:\n\nSample Input 2\n\n2 2\n\nSample Output 2\n\n1\n\nThere are one block, as shown below:", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 469, "cpu_time_ms": 347, "memory_kb": 25544}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s867966001", "group_id": "codeNet:p03637", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n\n val n = StdIn.readInt\n val a = StdIn.readLine.split(\" \").map(_.toLong)\n\n val (odd, even, mlt4) = a./:(0,0,0)((cnt,i) => {\n val odd = if((i&1) == 1) 1 else 0\n val even = if((i&1) == 0) 1 else 0\n val mlt4 = if((i&3) == 0) 1 else 0\n (cnt._1+odd, cnt._2+even, cnt._3+mlt4)\n })\n\n val ans = if(odd == mlt4+1) {\n if(even == mlt4) \"Yes\"\n else \"No\"\n }\n else if(odd <= mlt4) \"Yes\" else \"No\"\n\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1546630668, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03637.html", "problem_id": "p03637", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03637/input.txt", "sample_output_relpath": "derived/input_output/data/p03637/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03637/Scala/s867966001.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s867966001", "user_id": "u217010036"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n\n val n = StdIn.readInt\n val a = StdIn.readLine.split(\" \").map(_.toLong)\n\n val (odd, even, mlt4) = a./:(0,0,0)((cnt,i) => {\n val odd = if((i&1) == 1) 1 else 0\n val even = if((i&1) == 0) 1 else 0\n val mlt4 = if((i&3) == 0) 1 else 0\n (cnt._1+odd, cnt._2+even, cnt._3+mlt4)\n })\n\n val ans = if(odd == mlt4+1) {\n if(even == mlt4) \"Yes\"\n else \"No\"\n }\n else if(odd <= mlt4) \"Yes\" else \"No\"\n\n println(ans)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a sequence of length N, a = (a_1, a_2, ..., a_N).\nEach a_i is a positive integer.\n\nSnuke's objective is to permute the element in a so that the following condition is satisfied:\n\nFor each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.\n\nDetermine whether Snuke can achieve his objective.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\na_i is an integer.\n\n1 ≤ a_i ≤ 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\nIf Snuke can achieve his objective, print Yes; otherwise, print No.\n\nSample Input 1\n\n3\n1 10 100\n\nSample Output 1\n\nYes\n\nOne solution is (1, 100, 10).\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\nNo\n\nIt is impossible to permute a so that the condition is satisfied.\n\nSample Input 3\n\n3\n1 4 1\n\nSample Output 3\n\nYes\n\nThe condition is already satisfied initially.\n\nSample Input 4\n\n2\n1 1\n\nSample Output 4\n\nNo\n\nSample Input 5\n\n6\n2 7 1 8 2 8\n\nSample Output 5\n\nYes", "sample_input": "3\n1 10 100\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03637", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a sequence of length N, a = (a_1, a_2, ..., a_N).\nEach a_i is a positive integer.\n\nSnuke's objective is to permute the element in a so that the following condition is satisfied:\n\nFor each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.\n\nDetermine whether Snuke can achieve his objective.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\na_i is an integer.\n\n1 ≤ a_i ≤ 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\nIf Snuke can achieve his objective, print Yes; otherwise, print No.\n\nSample Input 1\n\n3\n1 10 100\n\nSample Output 1\n\nYes\n\nOne solution is (1, 100, 10).\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\nNo\n\nIt is impossible to permute a so that the condition is satisfied.\n\nSample Input 3\n\n3\n1 4 1\n\nSample Output 3\n\nYes\n\nThe condition is already satisfied initially.\n\nSample Input 4\n\n2\n1 1\n\nSample Output 4\n\nNo\n\nSample Input 5\n\n6\n2 7 1 8 2 8\n\nSample Output 5\n\nYes", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 556, "memory_kb": 42488}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s345277830", "group_id": "codeNet:p03638", "input_text": "import scala.annotation.tailrec\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val h, w = sc.nextInt\n val n = sc.nextInt\n val as = Vector.fill(n)(sc.nextInt)\n\n val rows = split(go(1, as, Vector[Vector[Int]]()).flatten, w)\n val ans = reverseOdd(rows)\n\n ans.foreach{ a =>\n a.foreach { b =>\n printf(\"%s \", b)\n }\n println()\n }\n\n }\n\n @tailrec\n def go(i: Int, seq: Seq[Int], result: Seq[Seq[Int]]): Seq[Seq[Int]] = {\n if (seq.length == 0) result\n else go(i+1, seq.tail, result :+ Seq.fill(seq.head)(i))\n }\n\n def split(seq: Seq[Int], n: Int): Seq[Seq[Int]] = {\n def go(s: Seq[Int], result: Seq[Seq[Int]]): Seq[Seq[Int]] = {\n if (s.length == 0) result\n else go(s.drop(n), result :+ s.dropRight(s.length - n))\n }\n go(seq, Seq[Seq[Int]]())\n }\n\n def reverseOdd(seq: Seq[Seq[Int]]): Seq[Seq[Int]] = {\n def go(i: Int, s: Seq[Seq[Int]], result: Seq[Seq[Int]]): Seq[Seq[Int]] = {\n if (s.length == 0) result\n else if (i % 2 == 0) go(i+1, s.tail, result :+ s.head)\n else go(i+1, s.tail, result :+ s.head.reverse)\n }\n go(0, seq, Seq[Seq[Int]]())\n }\n}", "language": "Scala", "metadata": {"date": 1510895116, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s345277830.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s345277830", "user_id": "u592088571"}, "prompt_components": {"gold_output": "1 1\n2 3\n", "input_to_evaluate": "import scala.annotation.tailrec\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val h, w = sc.nextInt\n val n = sc.nextInt\n val as = Vector.fill(n)(sc.nextInt)\n\n val rows = split(go(1, as, Vector[Vector[Int]]()).flatten, w)\n val ans = reverseOdd(rows)\n\n ans.foreach{ a =>\n a.foreach { b =>\n printf(\"%s \", b)\n }\n println()\n }\n\n }\n\n @tailrec\n def go(i: Int, seq: Seq[Int], result: Seq[Seq[Int]]): Seq[Seq[Int]] = {\n if (seq.length == 0) result\n else go(i+1, seq.tail, result :+ Seq.fill(seq.head)(i))\n }\n\n def split(seq: Seq[Int], n: Int): Seq[Seq[Int]] = {\n def go(s: Seq[Int], result: Seq[Seq[Int]]): Seq[Seq[Int]] = {\n if (s.length == 0) result\n else go(s.drop(n), result :+ s.dropRight(s.length - n))\n }\n go(seq, Seq[Seq[Int]]())\n }\n\n def reverseOdd(seq: Seq[Seq[Int]]): Seq[Seq[Int]] = {\n def go(i: Int, s: Seq[Seq[Int]], result: Seq[Seq[Int]]): Seq[Seq[Int]] = {\n if (s.length == 0) result\n else if (i % 2 == 0) go(i+1, s.tail, result :+ s.head)\n else go(i+1, s.tail, result :+ s.head.reverse)\n }\n go(0, seq, Seq[Seq[Int]]())\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1361, "memory_kb": 44364}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s143147387", "group_id": "codeNet:p03644", "input_text": "import scala.io.StdIn\n\nimport scala.annotation.tailrec\n\nobject Main extends App {\n val n = StdIn.readInt\n\n @tailrec\n def rec(acc:Int,num:Int):Int = {\n if((num&1) == 1) acc\n else {\n rec(acc+1,num>>1)\n }\n }\n val ans = (1 to n)./:(1,0)((max,i) => {\n val cnt = rec(0,i)\n if(max._2 < cnt) (i,cnt) else max\n })._1\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1546558581, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03644.html", "problem_id": "p03644", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03644/input.txt", "sample_output_relpath": "derived/input_output/data/p03644/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03644/Scala/s143147387.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s143147387", "user_id": "u217010036"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import scala.io.StdIn\n\nimport scala.annotation.tailrec\n\nobject Main extends App {\n val n = StdIn.readInt\n\n @tailrec\n def rec(acc:Int,num:Int):Int = {\n if((num&1) == 1) acc\n else {\n rec(acc+1,num>>1)\n }\n }\n val ans = (1 to n)./:(1,0)((max,i) => {\n val cnt = rec(0,i)\n if(max._2 < cnt) (i,cnt) else max\n })._1\n println(ans)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves numbers divisible by 2.\n\nYou are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique.\n\nHere, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder.\n\nFor example,\n\n6 can be divided by 2 once: 6 -> 3.\n\n8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1.\n\n3 can be divided by 2 zero times.\n\nConstraints\n\n1 ≤ N ≤ 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\n7\n\nSample Output 1\n\n4\n\n4 can be divided by 2 twice, which is the most number of times among 1, 2, ..., 7.\n\nSample Input 2\n\n32\n\nSample Output 2\n\n32\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1\n\nSample Input 4\n\n100\n\nSample Output 4\n\n64", "sample_input": "7\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03644", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves numbers divisible by 2.\n\nYou are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique.\n\nHere, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder.\n\nFor example,\n\n6 can be divided by 2 once: 6 -> 3.\n\n8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1.\n\n3 can be divided by 2 zero times.\n\nConstraints\n\n1 ≤ N ≤ 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\n7\n\nSample Output 1\n\n4\n\n4 can be divided by 2 twice, which is the most number of times among 1, 2, ..., 7.\n\nSample Input 2\n\n32\n\nSample Output 2\n\n32\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1\n\nSample Input 4\n\n100\n\nSample Output 4\n\n64", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 332, "memory_kb": 27456}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s573461838", "group_id": "codeNet:p03644", "input_text": "import java.util\nimport java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val n = sc.nextInt()\n var ans = 0\n for(i <- 1 to n) {\n var j = i\n var cnt = 0\n while(j%2==0) {\n j /= 2\n cnt += 1\n }\n ans = Math.max(ans, cnt)\n }\n println(ans)\n }\n}\n", "language": "Scala", "metadata": {"date": 1515796633, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03644.html", "problem_id": "p03644", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03644/input.txt", "sample_output_relpath": "derived/input_output/data/p03644/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03644/Scala/s573461838.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s573461838", "user_id": "u817142576"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util\nimport java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val n = sc.nextInt()\n var ans = 0\n for(i <- 1 to n) {\n var j = i\n var cnt = 0\n while(j%2==0) {\n j /= 2\n cnt += 1\n }\n ans = Math.max(ans, cnt)\n }\n println(ans)\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves numbers divisible by 2.\n\nYou are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique.\n\nHere, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder.\n\nFor example,\n\n6 can be divided by 2 once: 6 -> 3.\n\n8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1.\n\n3 can be divided by 2 zero times.\n\nConstraints\n\n1 ≤ N ≤ 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\n7\n\nSample Output 1\n\n4\n\n4 can be divided by 2 twice, which is the most number of times among 1, 2, ..., 7.\n\nSample Input 2\n\n32\n\nSample Output 2\n\n32\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1\n\nSample Input 4\n\n100\n\nSample Output 4\n\n64", "sample_input": "7\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03644", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves numbers divisible by 2.\n\nYou are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique.\n\nHere, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder.\n\nFor example,\n\n6 can be divided by 2 once: 6 -> 3.\n\n8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1.\n\n3 can be divided by 2 zero times.\n\nConstraints\n\n1 ≤ N ≤ 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\n7\n\nSample Output 1\n\n4\n\n4 can be divided by 2 twice, which is the most number of times among 1, 2, ..., 7.\n\nSample Input 2\n\n32\n\nSample Output 2\n\n32\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1\n\nSample Input 4\n\n100\n\nSample Output 4\n\n64", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 349, "memory_kb": 27308}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s356022548", "group_id": "codeNet:p03644", "input_text": "object Main extends App {\n\tval N = scala.io.StdIn.readInt\n\n\tif(N<2) println(1)\n\telse if(N<4) println(2)\n\telse if(N<8) println(4)\n\telse if(N<16) println(8)\n\telse if(N<32) println(16)\n\telse if(N<64) println(32)\n\telse println(64)\n}", "language": "Scala", "metadata": {"date": 1501377091, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03644.html", "problem_id": "p03644", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03644/input.txt", "sample_output_relpath": "derived/input_output/data/p03644/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03644/Scala/s356022548.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s356022548", "user_id": "u675876401"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "object Main extends App {\n\tval N = scala.io.StdIn.readInt\n\n\tif(N<2) println(1)\n\telse if(N<4) println(2)\n\telse if(N<8) println(4)\n\telse if(N<16) println(8)\n\telse if(N<32) println(16)\n\telse if(N<64) println(32)\n\telse println(64)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves numbers divisible by 2.\n\nYou are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique.\n\nHere, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder.\n\nFor example,\n\n6 can be divided by 2 once: 6 -> 3.\n\n8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1.\n\n3 can be divided by 2 zero times.\n\nConstraints\n\n1 ≤ N ≤ 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\n7\n\nSample Output 1\n\n4\n\n4 can be divided by 2 twice, which is the most number of times among 1, 2, ..., 7.\n\nSample Input 2\n\n32\n\nSample Output 2\n\n32\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1\n\nSample Input 4\n\n100\n\nSample Output 4\n\n64", "sample_input": "7\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03644", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves numbers divisible by 2.\n\nYou are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique.\n\nHere, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder.\n\nFor example,\n\n6 can be divided by 2 once: 6 -> 3.\n\n8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1.\n\n3 can be divided by 2 zero times.\n\nConstraints\n\n1 ≤ N ≤ 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\n7\n\nSample Output 1\n\n4\n\n4 can be divided by 2 twice, which is the most number of times among 1, 2, ..., 7.\n\nSample Input 2\n\n32\n\nSample Output 2\n\n32\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1\n\nSample Input 4\n\n100\n\nSample Output 4\n\n64", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 332, "memory_kb": 25408}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s667236288", "group_id": "codeNet:p03645", "input_text": "import scala.io.StdIn\nimport scala.collection.mutable._\n\nobject Main extends App {\n\n val Array(n, m) = StdIn.readLine.split(\" \").map(_.toInt)\n val graph = Array.fill(n+1)(ListBuffer.empty[Int])\n Iterator.continually(StdIn.readLine)\n .take(m)\n .map(_.split(\" \").map(_.toInt))\n .foreach(e => graph(e(0)) += e(1))\n\n val visit = Array.ofDim[Boolean](n+1)\n def dfs(pos:Int, cnt:Int):Unit = {\n if(cnt < 0) return\n visit(pos) = true\n // print(pos + \" \")\n for(i <- graph(pos)) {\n dfs(i, cnt-1)\n }\n }\n\n dfs(1,2)\n val ans = if(visit(n)) \"POSSIBLE\" else \"IMPOSSIBLE\"\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1546638417, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s667236288.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s667236288", "user_id": "u217010036"}, "prompt_components": {"gold_output": "POSSIBLE\n", "input_to_evaluate": "import scala.io.StdIn\nimport scala.collection.mutable._\n\nobject Main extends App {\n\n val Array(n, m) = StdIn.readLine.split(\" \").map(_.toInt)\n val graph = Array.fill(n+1)(ListBuffer.empty[Int])\n Iterator.continually(StdIn.readLine)\n .take(m)\n .map(_.split(\" \").map(_.toInt))\n .foreach(e => graph(e(0)) += e(1))\n\n val visit = Array.ofDim[Boolean](n+1)\n def dfs(pos:Int, cnt:Int):Unit = {\n if(cnt < 0) return\n visit(pos) = true\n // print(pos + \" \")\n for(i <- graph(pos)) {\n dfs(i, cnt-1)\n }\n }\n\n dfs(1,2)\n val ans = if(visit(n)) \"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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 609, "cpu_time_ms": 995, "memory_kb": 81268}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s531247957", "group_id": "codeNet:p03645", "input_text": "object Main extends App {\n\tval NM = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\n\tvar a = List[Int]()\n\tvar b = List[Int]()\n\n\tfor(i<-0 until NM(1)){\n\t\tval t = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\t\tif(t(0) == 1) a = t(1)::a\n\t\tif(t(1) == NM(0)) b = t(0)::b\n\t}\n\n\tdef find(a: List[Int], b: List[Int]): Boolean = {\n\t\tfor(i<-a){\n\t\t\tif(b.contains(i)) return true\n\t\t}\n\t\treturn false\n\t}\n\n\tif(find(a,b)) println(\"POSSIBLE\")\n\telse println(\"IMPOSSIBLE\")\n\n}\n", "language": "Scala", "metadata": {"date": 1501564118, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s531247957.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s531247957", "user_id": "u675876401"}, "prompt_components": {"gold_output": "POSSIBLE\n", "input_to_evaluate": "object Main extends App {\n\tval NM = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\n\tvar a = List[Int]()\n\tvar b = List[Int]()\n\n\tfor(i<-0 until NM(1)){\n\t\tval t = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\t\tif(t(0) == 1) a = t(1)::a\n\t\tif(t(1) == NM(0)) b = t(0)::b\n\t}\n\n\tdef find(a: List[Int], b: List[Int]): Boolean = {\n\t\tfor(i<-a){\n\t\t\tif(b.contains(i)) return true\n\t\t}\n\t\treturn false\n\t}\n\n\tif(find(a,b)) println(\"POSSIBLE\")\n\telse println(\"IMPOSSIBLE\")\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 60300}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s839574242", "group_id": "codeNet:p03657", "input_text": "object Main extends App {\n val in = io.StdIn.readLine().split(\" \").map(_.toInt)\n val A = in(0)\n val B = in(1)\n if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0)\n println(\"Possible\")\n else\n println(\"Impossible\")\n\n}", "language": "Scala", "metadata": {"date": 1501308542, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03657.html", "problem_id": "p03657", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03657/input.txt", "sample_output_relpath": "derived/input_output/data/p03657/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03657/Scala/s839574242.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s839574242", "user_id": "u010733367"}, "prompt_components": {"gold_output": "Possible\n", "input_to_evaluate": "object Main extends App {\n val in = io.StdIn.readLine().split(\" \").map(_.toInt)\n val A = in(0)\n val B = in(1)\n if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0)\n println(\"Possible\")\n else\n println(\"Impossible\")\n\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSnuke is giving cookies to his three goats.\n\nHe has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins).\n\nYour task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.\n\nConstraints\n\n1 \\leq A,B \\leq 100\n\nBoth A and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf it is possible to give cookies so that each of the three goats can have the same number of cookies, print Possible; otherwise, print Impossible.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\nPossible\n\nIf Snuke gives nine cookies, each of the three goats can have three cookies.\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\nImpossible\n\nSince there are only two cookies, the three goats cannot have the same number of cookies no matter what Snuke gives to them.", "sample_input": "4 5\n"}, "reference_outputs": ["Possible\n"], "source_document_id": "p03657", "source_text": "Score : 100 points\n\nProblem Statement\n\nSnuke is giving cookies to his three goats.\n\nHe has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins).\n\nYour task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.\n\nConstraints\n\n1 \\leq A,B \\leq 100\n\nBoth A and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf it is possible to give cookies so that each of the three goats can have the same number of cookies, print Possible; otherwise, print Impossible.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\nPossible\n\nIf Snuke gives nine cookies, each of the three goats can have three cookies.\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\nImpossible\n\nSince there are only two cookies, the three goats cannot have the same number of cookies no matter what Snuke gives to them.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 322, "memory_kb": 25412}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s367773629", "group_id": "codeNet:p03658", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n val Array(n, k) = StdIn.readLine.split(\" \").map(_.toInt)\n val ans = StdIn.readLine.split(\" \").map(_.toInt)\n .sorted.takeRight(k).sum\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1546718997, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03658.html", "problem_id": "p03658", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03658/input.txt", "sample_output_relpath": "derived/input_output/data/p03658/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03658/Scala/s367773629.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s367773629", "user_id": "u217010036"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n val Array(n, k) = StdIn.readLine.split(\" \").map(_.toInt)\n val ans = StdIn.readLine.split(\" \").map(_.toInt)\n .sorted.takeRight(k).sum\n println(ans)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSnuke has N sticks.\nThe length of the i-th stick is l_i.\n\nSnuke is making a snake toy by joining K of the sticks together.\n\nThe length of the toy is represented by the sum of the individual sticks that compose it.\nFind the maximum possible length of the toy.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 50\n\n1 \\leq l_i \\leq 50\n\nl_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nl_1 l_2 l_3 ... l_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n5 3\n1 2 3 4 5\n\nSample Output 1\n\n12\n\nYou can make a toy of length 12 by joining the sticks of lengths 3, 4 and 5, which is the maximum possible length.\n\nSample Input 2\n\n15 14\n50 26 27 21 41 7 42 35 7 5 5 36 39 1 45\n\nSample Output 2\n\n386", "sample_input": "5 3\n1 2 3 4 5\n"}, "reference_outputs": ["12\n"], "source_document_id": "p03658", "source_text": "Score : 200 points\n\nProblem Statement\n\nSnuke has N sticks.\nThe length of the i-th stick is l_i.\n\nSnuke is making a snake toy by joining K of the sticks together.\n\nThe length of the toy is represented by the sum of the individual sticks that compose it.\nFind the maximum possible length of the toy.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 50\n\n1 \\leq l_i \\leq 50\n\nl_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nl_1 l_2 l_3 ... l_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n5 3\n1 2 3 4 5\n\nSample Output 1\n\n12\n\nYou can make a toy of length 12 by joining the sticks of lengths 3, 4 and 5, which is the maximum possible length.\n\nSample Input 2\n\n15 14\n50 26 27 21 41 7 42 35 7 5 5 36 39 1 45\n\nSample Output 2\n\n386", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 334, "memory_kb": 25396}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s715585157", "group_id": "codeNet:p03658", "input_text": "object Main {\n\n\tdef main(arg:Array[String]) = {\n\t\tvar list = scala.io.StdIn.readLine().split(\" \").map(_.toInt).toList;\n\t\tvar l = scala.io.StdIn.readLine().split(\" \").map(_.toInt).toList;\n\t\tprintln(l.sorted.takeRight(list(1)).sum);\n\t}\n\n}\n\n", "language": "Scala", "metadata": {"date": 1524326694, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03658.html", "problem_id": "p03658", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03658/input.txt", "sample_output_relpath": "derived/input_output/data/p03658/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03658/Scala/s715585157.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s715585157", "user_id": "u029876051"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "object Main {\n\n\tdef main(arg:Array[String]) = {\n\t\tvar list = scala.io.StdIn.readLine().split(\" \").map(_.toInt).toList;\n\t\tvar l = scala.io.StdIn.readLine().split(\" \").map(_.toInt).toList;\n\t\tprintln(l.sorted.takeRight(list(1)).sum);\n\t}\n\n}\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSnuke has N sticks.\nThe length of the i-th stick is l_i.\n\nSnuke is making a snake toy by joining K of the sticks together.\n\nThe length of the toy is represented by the sum of the individual sticks that compose it.\nFind the maximum possible length of the toy.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 50\n\n1 \\leq l_i \\leq 50\n\nl_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nl_1 l_2 l_3 ... l_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n5 3\n1 2 3 4 5\n\nSample Output 1\n\n12\n\nYou can make a toy of length 12 by joining the sticks of lengths 3, 4 and 5, which is the maximum possible length.\n\nSample Input 2\n\n15 14\n50 26 27 21 41 7 42 35 7 5 5 36 39 1 45\n\nSample Output 2\n\n386", "sample_input": "5 3\n1 2 3 4 5\n"}, "reference_outputs": ["12\n"], "source_document_id": "p03658", "source_text": "Score : 200 points\n\nProblem Statement\n\nSnuke has N sticks.\nThe length of the i-th stick is l_i.\n\nSnuke is making a snake toy by joining K of the sticks together.\n\nThe length of the toy is represented by the sum of the individual sticks that compose it.\nFind the maximum possible length of the toy.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 50\n\n1 \\leq l_i \\leq 50\n\nl_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nl_1 l_2 l_3 ... l_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n5 3\n1 2 3 4 5\n\nSample Output 1\n\n12\n\nYou can make a toy of length 12 by joining the sticks of lengths 3, 4 and 5, which is the maximum possible length.\n\nSample Input 2\n\n15 14\n50 26 27 21 41 7 42 35 7 5 5 36 39 1 45\n\nSample Output 2\n\n386", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 338, "memory_kb": 27448}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s670957401", "group_id": "codeNet:p03658", "input_text": "import java.util.Scanner\n\n/**\n * Created by goryudyuma on 2017/07/16.\n */\n\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val N = sc.nextInt()\n val K = sc.nextInt()\n val arr: Array[Int] = new Array[Int](N)\n\n for (i <- 0 until N) {\n arr(i) = sc.nextInt()\n }\n\n println(arr.sorted.reverse.splitAt(K)._1.sum)\n }\n}\n", "language": "Scala", "metadata": {"date": 1500249620, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03658.html", "problem_id": "p03658", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03658/input.txt", "sample_output_relpath": "derived/input_output/data/p03658/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03658/Scala/s670957401.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s670957401", "user_id": "u779353743"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "import java.util.Scanner\n\n/**\n * Created by goryudyuma on 2017/07/16.\n */\n\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val N = sc.nextInt()\n val K = sc.nextInt()\n val arr: Array[Int] = new Array[Int](N)\n\n for (i <- 0 until N) {\n arr(i) = sc.nextInt()\n }\n\n println(arr.sorted.reverse.splitAt(K)._1.sum)\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSnuke has N sticks.\nThe length of the i-th stick is l_i.\n\nSnuke is making a snake toy by joining K of the sticks together.\n\nThe length of the toy is represented by the sum of the individual sticks that compose it.\nFind the maximum possible length of the toy.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 50\n\n1 \\leq l_i \\leq 50\n\nl_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nl_1 l_2 l_3 ... l_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n5 3\n1 2 3 4 5\n\nSample Output 1\n\n12\n\nYou can make a toy of length 12 by joining the sticks of lengths 3, 4 and 5, which is the maximum possible length.\n\nSample Input 2\n\n15 14\n50 26 27 21 41 7 42 35 7 5 5 36 39 1 45\n\nSample Output 2\n\n386", "sample_input": "5 3\n1 2 3 4 5\n"}, "reference_outputs": ["12\n"], "source_document_id": "p03658", "source_text": "Score : 200 points\n\nProblem Statement\n\nSnuke has N sticks.\nThe length of the i-th stick is l_i.\n\nSnuke is making a snake toy by joining K of the sticks together.\n\nThe length of the toy is represented by the sum of the individual sticks that compose it.\nFind the maximum possible length of the toy.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 50\n\n1 \\leq l_i \\leq 50\n\nl_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nl_1 l_2 l_3 ... l_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n5 3\n1 2 3 4 5\n\nSample Output 1\n\n12\n\nYou can make a toy of length 12 by joining the sticks of lengths 3, 4 and 5, which is the maximum possible length.\n\nSample Input 2\n\n15 14\n50 26 27 21 41 7 42 35 7 5 5 36 39 1 45\n\nSample Output 2\n\n386", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 383, "cpu_time_ms": 350, "memory_kb": 25896}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s701321186", "group_id": "codeNet:p03659", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val as = Array.fill(n)(sc.nextLong)\n var i = as.sum\n var min = Integer.MAX_VALUE.toLong\n as.drop(1).reverseIterator.foreach { a =>\n i -= a * 2\n if (math.abs(i) < min) min = math.abs(i)\n }\n println(min)\n}", "language": "Scala", "metadata": {"date": 1500171854, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03659.html", "problem_id": "p03659", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03659/input.txt", "sample_output_relpath": "derived/input_output/data/p03659/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03659/Scala/s701321186.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s701321186", "user_id": "u810300246"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val as = Array.fill(n)(sc.nextLong)\n var i = as.sum\n var min = Integer.MAX_VALUE.toLong\n as.drop(1).reverseIterator.foreach { a =>\n i -= a * 2\n if (math.abs(i) < min) min = math.abs(i)\n }\n println(min)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it.\n\nThey will share these cards.\nFirst, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards.\nHere, both Snuke and Raccoon have to take at least one card.\n\nLet the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively.\nThey would like to minimize |x-y|.\nFind the minimum possible value of |x-y|.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n-10^{9} \\leq a_i \\leq 10^{9}\n\na_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6\n1 2 3 4 5 6\n\nSample Output 1\n\n1\n\nIf Snuke takes four cards from the top, and Raccoon takes the remaining two cards, x=10, y=11, and thus |x-y|=1. This is the minimum possible value.\n\nSample Input 2\n\n2\n10 -10\n\nSample Output 2\n\n20\n\nSnuke can only take one card from the top, and Raccoon can only take the remaining one card. In this case, x=10, y=-10, and thus |x-y|=20.", "sample_input": "6\n1 2 3 4 5 6\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03659", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it.\n\nThey will share these cards.\nFirst, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards.\nHere, both Snuke and Raccoon have to take at least one card.\n\nLet the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively.\nThey would like to minimize |x-y|.\nFind the minimum possible value of |x-y|.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n-10^{9} \\leq a_i \\leq 10^{9}\n\na_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6\n1 2 3 4 5 6\n\nSample Output 1\n\n1\n\nIf Snuke takes four cards from the top, and Raccoon takes the remaining two cards, x=10, y=11, and thus |x-y|=1. This is the minimum possible value.\n\nSample Input 2\n\n2\n10 -10\n\nSample Output 2\n\n20\n\nSnuke can only take one card from the top, and Raccoon can only take the remaining one card. In this case, x=10, y=-10, and thus |x-y|=20.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 307, "cpu_time_ms": 829, "memory_kb": 70520}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s650945198", "group_id": "codeNet:p03661", "input_text": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n val MOD = 1000000007\n val n = readLine.toInt\n val a = readLine.split(\" \").map(_.toLong).sorted\n\n val s = a.sum\n val half = s / 2\n\n def calc(id: Int, curVal: Long, count: Int): Long = {\n if(id >= n - 1 || half < curVal || count == n - 1) math.abs(s - 2 * curVal)\n else {\n val a1 = calc(id + 1, curVal, count)\n val a2 = calc(id + 1, curVal + a(id + 1), count + 1)\n math.min(a1, a2)\n }\n }\n\n val ans = (for(i <- 0 until n) yield calc(i, a(i), 1)).min\n println(ans)\n}\n", "language": "Scala", "metadata": {"date": 1500774789, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03661.html", "problem_id": "p03661", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03661/input.txt", "sample_output_relpath": "derived/input_output/data/p03661/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03661/Scala/s650945198.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s650945198", "user_id": "u185193776"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n val MOD = 1000000007\n val n = readLine.toInt\n val a = readLine.split(\" \").map(_.toLong).sorted\n\n val s = a.sum\n val half = s / 2\n\n def calc(id: Int, curVal: Long, count: Int): Long = {\n if(id >= n - 1 || half < curVal || count == n - 1) math.abs(s - 2 * curVal)\n else {\n val a1 = calc(id + 1, curVal, count)\n val a2 = calc(id + 1, curVal + a(id + 1), count + 1)\n math.min(a1, a2)\n }\n }\n\n val ans = (for(i <- 0 until n) yield calc(i, a(i), 1)).min\n println(ans)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it.\n\nThey will share these cards.\nFirst, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards.\nHere, both Snuke and Raccoon have to take at least one card.\n\nLet the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively.\nThey would like to minimize |x-y|.\nFind the minimum possible value of |x-y|.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n-10^{9} \\leq a_i \\leq 10^{9}\n\na_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6\n1 2 3 4 5 6\n\nSample Output 1\n\n1\n\nIf Snuke takes four cards from the top, and Raccoon takes the remaining two cards, x=10, y=11, and thus |x-y|=1. This is the minimum possible value.\n\nSample Input 2\n\n2\n10 -10\n\nSample Output 2\n\n20\n\nSnuke can only take one card from the top, and Raccoon can only take the remaining one card. In this case, x=10, y=-10, and thus |x-y|=20.", "sample_input": "6\n1 2 3 4 5 6\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03661", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it.\n\nThey will share these cards.\nFirst, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards.\nHere, both Snuke and Raccoon have to take at least one card.\n\nLet the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively.\nThey would like to minimize |x-y|.\nFind the minimum possible value of |x-y|.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n-10^{9} \\leq a_i \\leq 10^{9}\n\na_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6\n1 2 3 4 5 6\n\nSample Output 1\n\n1\n\nIf Snuke takes four cards from the top, and Raccoon takes the remaining two cards, x=10, y=11, and thus |x-y|=1. This is the minimum possible value.\n\nSample Input 2\n\n2\n10 -10\n\nSample Output 2\n\n20\n\nSnuke can only take one card from the top, and Raccoon can only take the remaining one card. In this case, x=10, y=-10, and thus |x-y|=20.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 63728}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s289268151", "group_id": "codeNet:p03666", "input_text": "object Main extends App {\n\tval temp = scala.io.StdIn.readLine.split(\" \").map(_.toLong)\n\n\tval N = temp(0)\n\tval A = temp(1)\n\tval B = temp(2)\n\tval C = temp(3)\n\tval D = temp(4)\n\n\tprintln(temp.mkString(\" \"))\n\n\tval sum = B - A\n\n\tvar resalt = \"NO\"\n\n\tfor(i<- 0L until N){\n\t\tval under = i * C - (N - 1 - i) * D\n\t\tval top = i * D - (N - 1 - i) * C\n\n//\t\tprintln(s\" ${under} < ${sum} < ${top}\")\n\n\t\tif(under <= sum && sum <= top){\n\t\t\tresalt = \"YES\"\n\t\t}\n\t}\n\n\tprintln(resalt)\n\n}", "language": "Scala", "metadata": {"date": 1500093850, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03666.html", "problem_id": "p03666", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03666/input.txt", "sample_output_relpath": "derived/input_output/data/p03666/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03666/Scala/s289268151.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s289268151", "user_id": "u675876401"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "object Main extends App {\n\tval temp = scala.io.StdIn.readLine.split(\" \").map(_.toLong)\n\n\tval N = temp(0)\n\tval A = temp(1)\n\tval B = temp(2)\n\tval C = temp(3)\n\tval D = temp(4)\n\n\tprintln(temp.mkString(\" \"))\n\n\tval sum = B - A\n\n\tvar resalt = \"NO\"\n\n\tfor(i<- 0L until N){\n\t\tval under = i * C - (N - 1 - i) * D\n\t\tval top = i * D - (N - 1 - i) * C\n\n//\t\tprintln(s\" ${under} < ${sum} < ${top}\")\n\n\t\tif(under <= sum && sum <= top){\n\t\t\tresalt = \"YES\"\n\t\t}\n\t}\n\n\tprintln(resalt)\n\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N squares in a row.\nThe leftmost square contains the integer A, and the rightmost contains the integer B. The other squares are empty.\n\nAohashi would like to fill the empty squares with integers so that the following condition is satisfied:\n\nFor any two adjacent squares, the (absolute) difference of the two integers in those squares is between C and D (inclusive).\n\nAs long as the condition is satisfied, it is allowed to use arbitrarily large or small integers to fill the squares.\nDetermine whether it is possible to fill the squares under the condition.\n\nConstraints\n\n3 \\leq N \\leq 500000\n\n0 \\leq A \\leq 10^9\n\n0 \\leq B \\leq 10^9\n\n0 \\leq C \\leq D \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C D\n\nOutput\n\nPrint YES if it is possible to fill the squares under the condition; print NO otherwise.\n\nSample Input 1\n\n5 1 5 2 4\n\nSample Output 1\n\nYES\n\nFor example, fill the squares with the following integers: 1, -1, 3, 7, 5, from left to right.\n\nSample Input 2\n\n4 7 6 4 5\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n48792 105960835 681218449 90629745 90632170\n\nSample Output 3\n\nNO\n\nSample Input 4\n\n491995 412925347 825318103 59999126 59999339\n\nSample Output 4\n\nYES", "sample_input": "5 1 5 2 4\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03666", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N squares in a row.\nThe leftmost square contains the integer A, and the rightmost contains the integer B. The other squares are empty.\n\nAohashi would like to fill the empty squares with integers so that the following condition is satisfied:\n\nFor any two adjacent squares, the (absolute) difference of the two integers in those squares is between C and D (inclusive).\n\nAs long as the condition is satisfied, it is allowed to use arbitrarily large or small integers to fill the squares.\nDetermine whether it is possible to fill the squares under the condition.\n\nConstraints\n\n3 \\leq N \\leq 500000\n\n0 \\leq A \\leq 10^9\n\n0 \\leq B \\leq 10^9\n\n0 \\leq C \\leq D \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C D\n\nOutput\n\nPrint YES if it is possible to fill the squares under the condition; print NO otherwise.\n\nSample Input 1\n\n5 1 5 2 4\n\nSample Output 1\n\nYES\n\nFor example, fill the squares with the following integers: 1, -1, 3, 7, 5, from left to right.\n\nSample Input 2\n\n4 7 6 4 5\n\nSample Output 2\n\nNO\n\nSample Input 3\n\n48792 105960835 681218449 90629745 90632170\n\nSample Output 3\n\nNO\n\nSample Input 4\n\n491995 412925347 825318103 59999126 59999339\n\nSample Output 4\n\nYES", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 412, "memory_kb": 34832}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s426907080", "group_id": "codeNet:p03671", "input_text": "object Main {\n def main(args: Array[String]) {\n import scala.io.StdIn.readLine\n val Array(a, b, c) = readLine split \" \" map (_.toInt)\n println(Seq(a+b, b+c, c+a).max)\n }\n}", "language": "Scala", "metadata": {"date": 1498957914, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s426907080.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s426907080", "user_id": "u889397618"}, "prompt_components": {"gold_output": "1300\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]) {\n import scala.io.StdIn.readLine\n val Array(a, b, c) = readLine split \" \" map (_.toInt)\n println(Seq(a+b, b+c, c+a).max)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 318, "memory_kb": 25528}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s204463225", "group_id": "codeNet:p03672", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val s = sc.next\n val n = s.length\n\n def loop(str: String): String ={\n val l = str.length\n if(l < n && str.substring(0,l/2) == str.substring(l/2)) str\n else loop(str.substring(0,l - 2))\n }\n\n val res = loop(s).length\n\n println(res)\n}", "language": "Scala", "metadata": {"date": 1557221279, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03672.html", "problem_id": "p03672", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03672/input.txt", "sample_output_relpath": "derived/input_output/data/p03672/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03672/Scala/s204463225.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s204463225", "user_id": "u829407811"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val s = sc.next\n val n = s.length\n\n def loop(str: String): String ={\n val l = str.length\n if(l < n && str.substring(0,l/2) == str.substring(l/2)) str\n else loop(str.substring(0,l - 2))\n }\n\n val res = loop(s).length\n\n println(res)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe will call a string that can be obtained by concatenating two equal strings an even string.\nFor example, xyzxyz and aaaaaa are even, while ababab and xyzxy are not.\n\nYou are given an even string S consisting of lowercase English letters.\nFind the length of the longest even string that can be obtained by deleting one or more characters from the end of S.\nIt is guaranteed that such a non-empty string exists for a given input.\n\nConstraints\n\n2 \\leq |S| \\leq 200\n\nS is an even string consisting of lowercase English letters.\n\nThere exists a non-empty even string that can be obtained by deleting one or more characters from the end of S.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the length of the longest even string that can be obtained.\n\nSample Input 1\n\nabaababaab\n\nSample Output 1\n\n6\n\nabaababaab itself is even, but we need to delete at least one character.\n\nabaababaa is not even.\n\nabaababa is not even.\n\nabaabab is not even.\n\nabaaba is even. Thus, we should print its length, 6.\n\nSample Input 2\n\nxxxx\n\nSample Output 2\n\n2\n\nxxx is not even.\n\nxx is even.\n\nSample Input 3\n\nabcabcabcabc\n\nSample Output 3\n\n6\n\nThe longest even string that can be obtained is abcabc, whose length is 6.\n\nSample Input 4\n\nakasakaakasakasakaakas\n\nSample Output 4\n\n14\n\nThe longest even string that can be obtained is akasakaakasaka, whose length is 14.", "sample_input": "abaababaab\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03672", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe will call a string that can be obtained by concatenating two equal strings an even string.\nFor example, xyzxyz and aaaaaa are even, while ababab and xyzxy are not.\n\nYou are given an even string S consisting of lowercase English letters.\nFind the length of the longest even string that can be obtained by deleting one or more characters from the end of S.\nIt is guaranteed that such a non-empty string exists for a given input.\n\nConstraints\n\n2 \\leq |S| \\leq 200\n\nS is an even string consisting of lowercase English letters.\n\nThere exists a non-empty even string that can be obtained by deleting one or more characters from the end of S.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the length of the longest even string that can be obtained.\n\nSample Input 1\n\nabaababaab\n\nSample Output 1\n\n6\n\nabaababaab itself is even, but we need to delete at least one character.\n\nabaababaa is not even.\n\nabaababa is not even.\n\nabaabab is not even.\n\nabaaba is even. Thus, we should print its length, 6.\n\nSample Input 2\n\nxxxx\n\nSample Output 2\n\n2\n\nxxx is not even.\n\nxx is even.\n\nSample Input 3\n\nabcabcabcabc\n\nSample Output 3\n\n6\n\nThe longest even string that can be obtained is abcabc, whose length is 6.\n\nSample Input 4\n\nakasakaakasakasakaakas\n\nSample Output 4\n\n14\n\nThe longest even string that can be obtained is akasakaakasaka, whose length is 14.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 334, "cpu_time_ms": 367, "memory_kb": 25792}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s649716147", "group_id": "codeNet:p03680", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val list = List.fill(n)(sc.nextInt)\n \n def loop(num: Int, count: Int): Int = {\n if (num == 2) count\n else if (count > n) -1\n else loop(list(num - 1), count + 1)\n }\n \n println(loop(1, 0))\n}", "language": "Scala", "metadata": {"date": 1578293158, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s649716147.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s649716147", "user_id": "u715268393"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val list = List.fill(n)(sc.nextInt)\n \n def loop(num: Int, count: Int): Int = {\n if (num == 2) count\n else if (count > n) -1\n else loop(list(num - 1), count + 1)\n }\n \n println(loop(1, 0))\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi wants to gain muscle, and decides to work out at AtCoder Gym.\n\nThe exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up.\nThese buttons are numbered 1 through N.\nWhen Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i.\nWhen Button i is not lighten up, nothing will happen by pressing it.\n\nInitially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up.\n\nDetermine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1\na_2\n:\na_N\n\nOutput\n\nPrint -1 if it is impossible to lighten up Button 2.\nOtherwise, print the minimum number of times we need to press buttons in order to lighten up Button 2.\n\nSample Input 1\n\n3\n3\n1\n2\n\nSample Output 1\n\n2\n\nPress Button 1, then Button 3.\n\nSample Input 2\n\n4\n3\n4\n1\n2\n\nSample Output 2\n\n-1\n\nPressing Button 1 lightens up Button 3, and vice versa, so Button 2 will never be lighten up.\n\nSample Input 3\n\n5\n3\n3\n4\n2\n4\n\nSample Output 3\n\n3", "sample_input": "3\n3\n1\n2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03680", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi wants to gain muscle, and decides to work out at AtCoder Gym.\n\nThe exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up.\nThese buttons are numbered 1 through N.\nWhen Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i.\nWhen Button i is not lighten up, nothing will happen by pressing it.\n\nInitially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up.\n\nDetermine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1\na_2\n:\na_N\n\nOutput\n\nPrint -1 if it is impossible to lighten up Button 2.\nOtherwise, print the minimum number of times we need to press buttons in order to lighten up Button 2.\n\nSample Input 1\n\n3\n3\n1\n2\n\nSample Output 1\n\n2\n\nPress Button 1, then Button 3.\n\nSample Input 2\n\n4\n3\n4\n1\n2\n\nSample Output 2\n\n-1\n\nPressing Button 1 lightens up Button 3, and vice versa, so Button 2 will never be lighten up.\n\nSample Input 3\n\n5\n3\n3\n4\n2\n4\n\nSample Output 3\n\n3", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 54868}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s875767356", "group_id": "codeNet:p03680", "input_text": "object Main {\n def solve(i:Int, n: Int, maxNum: Int, arr: IndexedSeq[Int]):Int = {\n if (n == maxNum){\n -1\n }else{\n if(arr(i)==1){\n n + 1\n }else{\n solve(arr(i), n+1, maxNum, arr)\n }\n }\n }\n\n def main(args: Array[String]): Unit = {\n val n = io.StdIn.readLine().toInt\n val arr = for(i <- 0 until n) yield io.StdIn.readLine().toInt-1\n println(solve(0,0,n,arr))\n }\n}\n", "language": "Scala", "metadata": {"date": 1498607683, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s875767356.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s875767356", "user_id": "u653020951"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main {\n def solve(i:Int, n: Int, maxNum: Int, arr: IndexedSeq[Int]):Int = {\n if (n == maxNum){\n -1\n }else{\n if(arr(i)==1){\n n + 1\n }else{\n solve(arr(i), n+1, maxNum, arr)\n }\n }\n }\n\n def main(args: Array[String]): Unit = {\n val n = io.StdIn.readLine().toInt\n val arr = for(i <- 0 until n) yield io.StdIn.readLine().toInt-1\n println(solve(0,0,n,arr))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 544, "memory_kb": 39536}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s127788052", "group_id": "codeNet:p03680", "input_text": "import io.StdIn.readInt\nimport annotation.tailrec\nimport collection.mutable.{Seq => MutableSeq}\n\nobject Main extends App {\n val n = readInt\n val as = Seq.fill(n)(readInt)\n val vs = MutableSeq.fill(n)(false)\n\n println(solve(0, 0, as, vs))\n\n @tailrec def solve(pos: Int, res: Int, as: Seq[Int], vs: MutableSeq[Boolean]): Int = {\n if (pos == 1) res\n else if (vs(pos)) -1\n else {\n solve(as(pos) - 1, res + 1, as, vs.updated(pos, true))\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1498357295, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s127788052.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s127788052", "user_id": "u158295568"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import io.StdIn.readInt\nimport annotation.tailrec\nimport collection.mutable.{Seq => MutableSeq}\n\nobject Main extends App {\n val n = readInt\n val as = Seq.fill(n)(readInt)\n val vs = MutableSeq.fill(n)(false)\n\n println(solve(0, 0, as, vs))\n\n @tailrec def solve(pos: Int, res: Int, as: Seq[Int], vs: MutableSeq[Boolean]): Int = {\n if (pos == 1) res\n else if (vs(pos)) -1\n else {\n solve(as(pos) - 1, res + 1, as, vs.updated(pos, true))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 123368}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s598966259", "group_id": "codeNet:p03687", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val s = sc.next\n val distinct = s.distinct\n\n val res = distinct.map(loop(_, s).max).min\n println(res)\n\n def loop(ch: Char, str: String, vec: Vector[Int] = Vector.empty): Vector[Int] = {\n str.foldLeft(vec){ case (acc, c) =>\n val (tr, fa) = str.span(_ != ch)\n if(fa.isEmpty) vec :+ tr.length\n else loop(ch, fa.tail, vec :+ tr.length)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1576939323, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s598966259.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s598966259", "user_id": "u829407811"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val s = sc.next\n val distinct = s.distinct\n\n val res = distinct.map(loop(_, s).max).min\n println(res)\n\n def loop(ch: Char, str: String, vec: Vector[Int] = Vector.empty): Vector[Int] = {\n str.foldLeft(vec){ case (acc, c) =>\n val (tr, fa) = str.span(_ != ch)\n if(fa.isEmpty) vec :+ tr.length\n else loop(ch, fa.tail, vec :+ tr.length)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 454, "cpu_time_ms": 2111, "memory_kb": 120368}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s121407222", "group_id": "codeNet:p03695", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n solve\n }\n\n def solve(): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val a = new Array[Int](n)\n for (i <- 0 until n) {\n a(i) = sc.nextInt\n }\n\n val colors = scala.collection.mutable.Set[String]()\n var over3200 = 0\n for (i <- 0 until n) {\n if (a(i) <= 399) colors.add(\"grey\")\n else if (a(i) <= 799) colors.add(\"brown\")\n else if (a(i) <= 1199) colors.add(\"green\")\n else if (a(i) <= 1599) colors.add(\"light_blue\")\n else if (a(i) <= 1999) colors.add(\"blue\")\n else if (a(i) <= 2399) colors.add(\"yellow\")\n else if (a(i) <= 2799) colors.add(\"orange\")\n else if (a(i) <= 3199) colors.add(\"red\")\n else over3200 += 1\n }\n\n val min = colors.size\n val max = math.min(colors.size + over3200, 8)\n println(min + \" \" + max)\n\n }\n}\n", "language": "Scala", "metadata": {"date": 1583872461, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s121407222.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s121407222", "user_id": "u433254839"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n solve\n }\n\n def solve(): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val a = new Array[Int](n)\n for (i <- 0 until n) {\n a(i) = sc.nextInt\n }\n\n val colors = scala.collection.mutable.Set[String]()\n var over3200 = 0\n for (i <- 0 until n) {\n if (a(i) <= 399) colors.add(\"grey\")\n else if (a(i) <= 799) colors.add(\"brown\")\n else if (a(i) <= 1199) colors.add(\"green\")\n else if (a(i) <= 1599) colors.add(\"light_blue\")\n else if (a(i) <= 1999) colors.add(\"blue\")\n else if (a(i) <= 2399) colors.add(\"yellow\")\n else if (a(i) <= 2799) colors.add(\"orange\")\n else if (a(i) <= 3199) colors.add(\"red\")\n else over3200 += 1\n }\n\n val min = colors.size\n val max = math.min(colors.size + over3200, 8)\n println(min + \" \" + max)\n\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 888, "cpu_time_ms": 348, "memory_kb": 27340}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s354131209", "group_id": "codeNet:p03695", "input_text": "object Main extends App {\n\tval N = scala.io.StdIn.readInt\n\tval x = scala.io.StdIn.readLine\n\n\tval a: Array[Int] = new Array(N)\n\tval b: Array[Int] = new Array(9)\n\n\tfor(i <- 0 until N){\n\t\ta(i) = x.split(\" \")(i).toInt\n\t}\n\n\tdef find(x: Int):Int = {\n\t\tif(1<=x && x<=399){\n\t\t\treturn 0;\n\t\t}else if(400<=x && x<=799){\n\t\t\treturn 1;\n\t\t}else if(800<=x && x<=1199){\n\t\t\treturn 2;\n\t\t}else if(1200<=x && x<=1599){\n\t\t\treturn 3;\n\t\t}else if(1600<=x && x<=1999){\n\t\t\treturn 4;\n\t\t}else if(2000<=x && x<=2399){\n\t\t\treturn 5;\n\t\t}else if(2400<=x && x<=2799){\n\t\t\treturn 6;\n\t\t}else if(2800<=x && x<=3199){\n\t\t\treturn 7;\n\t\t}else{\n\t\t\treturn 8;\n\t\t}\n\t}\n\n\tfor(i<- 0 until N){\n\t\tval t = find(a(i))\n\n\t\tb(t) = b(t) + 1;\n\t}\n\n\tvar count = 0\n\n\tfor(i<- 0 to 7){\n\t\tif(b(i) != 0) count = count + 1\n\t}\n\n\tif(b(8) == 0){\n\t\tprintln(count + \" \" + count)\n\t}else{\n\t\tval u = count + b(8)\n\t\tif(u <= 8){\n\t\t\tprintln(count + \" \"+ u)\n\t\t}else{\n\t\t\tprintln(count + \" 8\")\n\t\t}\n\t}\n\t\n}", "language": "Scala", "metadata": {"date": 1497147057, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s354131209.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s354131209", "user_id": "u675876401"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "object Main extends App {\n\tval N = scala.io.StdIn.readInt\n\tval x = scala.io.StdIn.readLine\n\n\tval a: Array[Int] = new Array(N)\n\tval b: Array[Int] = new Array(9)\n\n\tfor(i <- 0 until N){\n\t\ta(i) = x.split(\" \")(i).toInt\n\t}\n\n\tdef find(x: Int):Int = {\n\t\tif(1<=x && x<=399){\n\t\t\treturn 0;\n\t\t}else if(400<=x && x<=799){\n\t\t\treturn 1;\n\t\t}else if(800<=x && x<=1199){\n\t\t\treturn 2;\n\t\t}else if(1200<=x && x<=1599){\n\t\t\treturn 3;\n\t\t}else if(1600<=x && x<=1999){\n\t\t\treturn 4;\n\t\t}else if(2000<=x && x<=2399){\n\t\t\treturn 5;\n\t\t}else if(2400<=x && x<=2799){\n\t\t\treturn 6;\n\t\t}else if(2800<=x && x<=3199){\n\t\t\treturn 7;\n\t\t}else{\n\t\t\treturn 8;\n\t\t}\n\t}\n\n\tfor(i<- 0 until N){\n\t\tval t = find(a(i))\n\n\t\tb(t) = b(t) + 1;\n\t}\n\n\tvar count = 0\n\n\tfor(i<- 0 to 7){\n\t\tif(b(i) != 0) count = count + 1\n\t}\n\n\tif(b(8) == 0){\n\t\tprintln(count + \" \" + count)\n\t}else{\n\t\tval u = count + b(8)\n\t\tif(u <= 8){\n\t\t\tprintln(count + \" \"+ u)\n\t\t}else{\n\t\t\tprintln(count + \" 8\")\n\t\t}\n\t}\n\t\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 344, "memory_kb": 25292}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s060528245", "group_id": "codeNet:p03696", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n import collection._\n val n = io.StdIn.readLine()\n val str = io.StdIn.readLine()\n\n val (l, r) = str.foldLeft((0,0)){\n case ((lacc, acc), c) => {\n c match {\n case '(' => (lacc, acc + 1)\n case ')' if acc == 0 => (lacc + 1, 0)\n case _ => (lacc, acc - 1)\n }\n }\n }\n\n val left = Seq.fill(l)('(')\n val right = Seq.fill(r)(')')\n println(left.mkString + str + right.mkString)\n }\n}", "language": "Scala", "metadata": {"date": 1499187736, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s060528245.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s060528245", "user_id": "u653020951"}, "prompt_components": {"gold_output": "(())\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n import collection._\n val n = io.StdIn.readLine()\n val str = io.StdIn.readLine()\n\n val (l, r) = str.foldLeft((0,0)){\n case ((lacc, acc), c) => {\n c match {\n case '(' => (lacc, acc + 1)\n case ')' if acc == 0 => (lacc + 1, 0)\n case _ => (lacc, acc - 1)\n }\n }\n }\n\n val left = Seq.fill(l)('(')\n val right = Seq.fill(r)(')')\n println(left.mkString + str + right.mkString)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 503, "cpu_time_ms": 327, "memory_kb": 27312}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s447316185", "group_id": "codeNet:p03697", "input_text": "import java.io.{PrintWriter, _}\nimport java.util\nimport java.util._\n\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val inputStream = System.in\n val outputStream = System.out\n val in = new InputReader(inputStream)\n val out = new PrintWriter(outputStream)\n val solver = new Task\n solver.solve(1, in, out)\n out.close()\n }\n\n class Task {\n def solve(testNumber: Int, in: InputReader, out: PrintWriter): Unit = {\n val a = in.nextInt\n val b = in.nextInt\n if (a + b < 10) {\n println(a + b)\n } else {\n println(\"error\")\n }\n }\n }\n\n class InputReader(val stream: InputStream) extends AutoCloseable {\n //reader = new BufferedReader(new FileReader(stream), 32768);\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer = new StringTokenizer(\"\")\n\n\n def next: String = {\n while ( {\n tokenizer == null || !tokenizer.hasMoreTokens\n }) try\n tokenizer = new StringTokenizer(reader.readLine)\n catch {\n case e: IOException =>\n throw new RuntimeException(e)\n }\n tokenizer.nextToken\n }\n\n def nextLine: String = {\n try\n return reader.readLine\n catch {\n case e: IOException =>\n e.printStackTrace()\n }\n \"\"\n }\n\n def nextInt: Int = next.toInt\n\n def nextLong: Long = next.toLong\n\n override def close(): Unit = {\n }\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1559858853, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03697.html", "problem_id": "p03697", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03697/input.txt", "sample_output_relpath": "derived/input_output/data/p03697/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03697/Scala/s447316185.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s447316185", "user_id": "u992675902"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import java.io.{PrintWriter, _}\nimport java.util\nimport java.util._\n\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val inputStream = System.in\n val outputStream = System.out\n val in = new InputReader(inputStream)\n val out = new PrintWriter(outputStream)\n val solver = new Task\n solver.solve(1, in, out)\n out.close()\n }\n\n class Task {\n def solve(testNumber: Int, in: InputReader, out: PrintWriter): Unit = {\n val a = in.nextInt\n val b = in.nextInt\n if (a + b < 10) {\n println(a + b)\n } else {\n println(\"error\")\n }\n }\n }\n\n class InputReader(val stream: InputStream) extends AutoCloseable {\n //reader = new BufferedReader(new FileReader(stream), 32768);\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer = new StringTokenizer(\"\")\n\n\n def next: String = {\n while ( {\n tokenizer == null || !tokenizer.hasMoreTokens\n }) try\n tokenizer = new StringTokenizer(reader.readLine)\n catch {\n case e: IOException =>\n throw new RuntimeException(e)\n }\n tokenizer.nextToken\n }\n\n def nextLine: String = {\n try\n return reader.readLine\n catch {\n case e: IOException =>\n e.printStackTrace()\n }\n \"\"\n }\n\n def nextInt: Int = next.toInt\n\n def nextLong: Long = next.toLong\n\n override def close(): Unit = {\n }\n }\n\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given two integers A and B as the input. Output the value of A + B.\n\nHowever, if A + B is 10 or greater, output error instead.\n\nConstraints\n\nA and B are integers.\n\n1 ≤ A, B ≤ 9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf A + B is 10 or greater, print the string error (case-sensitive); otherwise, print the value of A + B.\n\nSample Input 1\n\n6 3\n\nSample Output 1\n\n9\n\nSample Input 2\n\n6 4\n\nSample Output 2\n\nerror", "sample_input": "6 3\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03697", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given two integers A and B as the input. Output the value of A + B.\n\nHowever, if A + B is 10 or greater, output error instead.\n\nConstraints\n\nA and B are integers.\n\n1 ≤ A, B ≤ 9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf A + B is 10 or greater, print the string error (case-sensitive); otherwise, print the value of A + B.\n\nSample Input 1\n\n6 3\n\nSample Output 1\n\n9\n\nSample Input 2\n\n6 4\n\nSample Output 2\n\nerror", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1453, "cpu_time_ms": 323, "memory_kb": 25284}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s707435175", "group_id": "codeNet:p03697", "input_text": "object Main extends App {\n val a = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n val x = a(0)\n val y = a(1)\n val ret = if (x+y<10) x+y else \"error\" \n println(ret)\n}\n", "language": "Scala", "metadata": {"date": 1496988680, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03697.html", "problem_id": "p03697", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03697/input.txt", "sample_output_relpath": "derived/input_output/data/p03697/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03697/Scala/s707435175.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s707435175", "user_id": "u893154287"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "object Main extends App {\n val a = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n val x = a(0)\n val y = a(1)\n val ret = if (x+y<10) x+y else \"error\" \n println(ret)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given two integers A and B as the input. Output the value of A + B.\n\nHowever, if A + B is 10 or greater, output error instead.\n\nConstraints\n\nA and B are integers.\n\n1 ≤ A, B ≤ 9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf A + B is 10 or greater, print the string error (case-sensitive); otherwise, print the value of A + B.\n\nSample Input 1\n\n6 3\n\nSample Output 1\n\n9\n\nSample Input 2\n\n6 4\n\nSample Output 2\n\nerror", "sample_input": "6 3\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03697", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given two integers A and B as the input. Output the value of A + B.\n\nHowever, if A + B is 10 or greater, output error instead.\n\nConstraints\n\nA and B are integers.\n\n1 ≤ A, B ≤ 9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf A + B is 10 or greater, print the string error (case-sensitive); otherwise, print the value of A + B.\n\nSample Input 1\n\n6 3\n\nSample Output 1\n\n9\n\nSample Input 2\n\n6 4\n\nSample Output 2\n\nerror", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 185, "cpu_time_ms": 320, "memory_kb": 25408}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s245034339", "group_id": "codeNet:p03698", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val s = sc.next\n\n val res = if(s.distinct.length == s.length) \"yes\" else \"no\"\n\n println(res)\n}", "language": "Scala", "metadata": {"date": 1557120901, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s245034339.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s245034339", "user_id": "u829407811"}, "prompt_components": {"gold_output": "yes\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val s = sc.next\n\n val res = if(s.distinct.length == s.length) \"yes\" else \"no\"\n\n println(res)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 185, "cpu_time_ms": 341, "memory_kb": 27332}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s766488776", "group_id": "codeNet:p03699", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val s = List.fill(sc.nextInt())(sc.nextInt()).sorted\n val max = s.sum match {\n case sum if sum % 10 != 0 => sum\n case sum => s.find(_ % 10 != 0).map(sum - _).getOrElse(0)\n }\n println(max)\n}\n", "language": "Scala", "metadata": {"date": 1594258412, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s766488776.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s766488776", "user_id": "u737111725"}, "prompt_components": {"gold_output": "25\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val s = List.fill(sc.nextInt())(sc.nextInt()).sorted\n val max = s.sum match {\n case sum if sum % 10 != 0 => sum\n case sum => s.find(_ % 10 != 0).map(sum - _).getOrElse(0)\n }\n println(max)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 271, "cpu_time_ms": 511, "memory_kb": 55616}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s499472320", "group_id": "codeNet:p03711", "input_text": "object Main extends App {\n\tval Array(x, y) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\n\tval a1 = Set(1,3,5,7,8,10,12)\n\tval a2 = Set(4,6,9,11)\n\tval a3 = Set(2)\n\n\tif(a1.contains(x) && a1.contains(y)){\n\t\tprintln(\"Yes\")\n\t}else if(a2.contains(x) && a2.contains(y)){\n\t\tprintln(\"Yes\")\n\t}else if(a3.contains(x) && a3.contains(y)){\n\t\tprintln(\"Yes\")\n\t}else{\n\t\tprintln(\"No\")\n\t}\n\n\n} \n", "language": "Scala", "metadata": {"date": 1555523793, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03711.html", "problem_id": "p03711", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03711/input.txt", "sample_output_relpath": "derived/input_output/data/p03711/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03711/Scala/s499472320.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s499472320", "user_id": "u675876401"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n\tval Array(x, y) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\n\tval a1 = Set(1,3,5,7,8,10,12)\n\tval a2 = Set(4,6,9,11)\n\tval a3 = Set(2)\n\n\tif(a1.contains(x) && a1.contains(y)){\n\t\tprintln(\"Yes\")\n\t}else if(a2.contains(x) && a2.contains(y)){\n\t\tprintln(\"Yes\")\n\t}else if(a3.contains(x) && a3.contains(y)){\n\t\tprintln(\"Yes\")\n\t}else{\n\t\tprintln(\"No\")\n\t}\n\n\n} \n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nBased on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below.\nGiven two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.\n\nConstraints\n\nx and y are integers.\n\n1 ≤ x < y ≤ 12\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx y\n\nOutput\n\nIf x and y belong to the same group, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n2 4\n\nSample Output 2\n\nNo", "sample_input": "1 3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03711", "source_text": "Score : 100 points\n\nProblem Statement\n\nBased on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below.\nGiven two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.\n\nConstraints\n\nx and y are integers.\n\n1 ≤ x < y ≤ 12\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx y\n\nOutput\n\nIf x and y belong to the same group, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n2 4\n\nSample Output 2\n\nNo", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 333, "memory_kb": 27320}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s422724830", "group_id": "codeNet:p03713", "input_text": "import java.{util => ju}\nimport scala.collection.{mutable => mu}\nimport MyPredef._\n\n\nobject Main extends App {\n val H,W = nextLong\n var h=Math.min(H,W)\n var w=Math.max(H,W)\n //val h=Math.max(H,W)\n //val w=Math.min(H,W)\n //val h=H\n //val w=W\n \n val res = if(h%3==0||w%3==0){\n 0\n }else{\n var res = h\n \n (Math.max(w/3,0) to Math.min(w,w/3+1)).foreach(x => {\n val wx = w-x\n val h0 = h/2\n val h1 = h-h/2\n val can = Seq(x*h,wx*h0,wx*h1)\n res = Math.min(res,can.max-can.min)\n })\n \n (Math.max(h/3,0) to Math.min(h,h/3+1)).foreach(x => {\n val hx = h-x\n val w0 = w/2\n val w1 = w-w/2\n val can = Seq(x*h,hx*w0,hx*w1)\n res = Math.min(res,can.max-can.min)\n })\n /*\n h=Math.max(H,W)\n w=Math.min(H,W)\n \n (Math.max(w/3,0) to Math.min(w,w/3+1)).foreach(x => {\n val wx = w-x\n val h0 = h/2\n val h1 = h-h/2\n val can = Seq(x*h,wx*h0,wx*h1)\n res = Math.min(res,can.max-can.min)\n })\n \n \n (Math.max(h/3,0) to Math.min(h,h/3+1)).foreach(x => {\n val hx = h-x\n val w0 = w/2\n val w1 = w-w/2\n val can = Seq(x*h,hx*w0,hx*w1)\n res = Math.min(res,can.max-can.min)\n })\n */\n \n res\n }\n \n println(res)\n}\n\n\nobject MyPredef {\n @inline def rep(n: Int, f: => Unit): Unit = { var c = 0; while (c < n) { f; c += 1 } }\n @inline def rep(n: Int, f: Int => Unit): Unit = { var c = 0; while (c < n) { f(c); c += 1 } }\n\n private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0\n @inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126\n @inline private def hasNextByte(): Boolean =\n if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else { true }\n @inline private def hasNext(): Boolean = {\n while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1\n hasNextByte()\n }\n @inline private def readByte(): Byte =\n if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else { -1 }\n def next(): String = {\n if(!hasNext()) ???\n val sb = new StringBuilder; var b = readByte()\n while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }\n sb.toString\n }\n def nextInt(): Int = {\n val n = nextLong()\n if (n < Int.MinValue || Int.MaxValue < n) ???\n n.toInt\n }\n def nextLong(): Long = {\n if(!hasNext()) ???\n var minus = false; var b = readByte()\n if (b == '-') { minus = true; b = readByte() }\n def go (b: Byte, n: Long = 0): Long =\n if ('0' <= b && b <= '9') { go(readByte(), n * 10 + b - '0') }\n else if (minus) { -n } else { n }\n go(b)\n }\n def nextDouble(): Double = next.toDouble\n}\nobject MyArray {\n def fillT[T : scala.reflect.ClassTag](dimX: Int, dimY: Int)(f: => T): Array[Array[T]] = {\n val arrs = Array.ofDim[T](dimX, dimY)\n for {\n y <- (0 until dimY)\n x <- (0 until dimX)\n } {\n arrs(x)(y) = f\n }\n arrs\n }\n}", "language": "Scala", "metadata": {"date": 1495351157, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s422724830.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s422724830", "user_id": "u989222035"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "import java.{util => ju}\nimport scala.collection.{mutable => mu}\nimport MyPredef._\n\n\nobject Main extends App {\n val H,W = nextLong\n var h=Math.min(H,W)\n var w=Math.max(H,W)\n //val h=Math.max(H,W)\n //val w=Math.min(H,W)\n //val h=H\n //val w=W\n \n val res = if(h%3==0||w%3==0){\n 0\n }else{\n var res = h\n \n (Math.max(w/3,0) to Math.min(w,w/3+1)).foreach(x => {\n val wx = w-x\n val h0 = h/2\n val h1 = h-h/2\n val can = Seq(x*h,wx*h0,wx*h1)\n res = Math.min(res,can.max-can.min)\n })\n \n (Math.max(h/3,0) to Math.min(h,h/3+1)).foreach(x => {\n val hx = h-x\n val w0 = w/2\n val w1 = w-w/2\n val can = Seq(x*h,hx*w0,hx*w1)\n res = Math.min(res,can.max-can.min)\n })\n /*\n h=Math.max(H,W)\n w=Math.min(H,W)\n \n (Math.max(w/3,0) to Math.min(w,w/3+1)).foreach(x => {\n val wx = w-x\n val h0 = h/2\n val h1 = h-h/2\n val can = Seq(x*h,wx*h0,wx*h1)\n res = Math.min(res,can.max-can.min)\n })\n \n \n (Math.max(h/3,0) to Math.min(h,h/3+1)).foreach(x => {\n val hx = h-x\n val w0 = w/2\n val w1 = w-w/2\n val can = Seq(x*h,hx*w0,hx*w1)\n res = Math.min(res,can.max-can.min)\n })\n */\n \n res\n }\n \n println(res)\n}\n\n\nobject MyPredef {\n @inline def rep(n: Int, f: => Unit): Unit = { var c = 0; while (c < n) { f; c += 1 } }\n @inline def rep(n: Int, f: Int => Unit): Unit = { var c = 0; while (c < n) { f(c); c += 1 } }\n\n private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0\n @inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126\n @inline private def hasNextByte(): Boolean =\n if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else { true }\n @inline private def hasNext(): Boolean = {\n while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1\n hasNextByte()\n }\n @inline private def readByte(): Byte =\n if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else { -1 }\n def next(): String = {\n if(!hasNext()) ???\n val sb = new StringBuilder; var b = readByte()\n while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }\n sb.toString\n }\n def nextInt(): Int = {\n val n = nextLong()\n if (n < Int.MinValue || Int.MaxValue < n) ???\n n.toInt\n }\n def nextLong(): Long = {\n if(!hasNext()) ???\n var minus = false; var b = readByte()\n if (b == '-') { minus = true; b = readByte() }\n def go (b: Byte, n: Long = 0): Long =\n if ('0' <= b && b <= '9') { go(readByte(), n * 10 + b - '0') }\n else if (minus) { -n } else { n }\n go(b)\n }\n def nextDouble(): Double = next.toDouble\n}\nobject MyArray {\n def fillT[T : scala.reflect.ClassTag](dimX: Int, dimY: Int)(f: => T): Array[Array[T]] = {\n val arrs = Array.ofDim[T](dimX, dimY)\n for {\n y <- (0 until dimY)\n x <- (0 until dimX)\n } {\n arrs(x)(y) = f\n }\n arrs\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3135, "cpu_time_ms": 330, "memory_kb": 27328}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s835039950", "group_id": "codeNet:p03716", "input_text": "import java.util.Scanner\nimport scala.collection.mutable.PriorityQueue\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val n = sc.nextInt()\n val a = new Array[Int](3*n + 1)\n\n for(i <- 1 to 3*n)\n a(i) = sc.nextInt()\n\n val left = new Array[Long](n+1)\n val right = new Array[Long](n+1)\n\n\n // left\n left(0) = a.slice(1, n+1).sum\n val pqd = new PriorityQueue[Int]()(Ordering.Int.reverse)\n for(i <- 1 to n)\n pqd.enqueue(a(i))\n for(i <- n+1 to 2*n){\n pqd.enqueue(a(i))\n left(i-n) = left(i-n-1) + a(i) - pqd.dequeue\n }\n\n\n // right\n right(n) = a.slice(2*n+1, 3*n+1).sum\n val pqa = new PriorityQueue[Int]\n for(i <- (2*n+1 to 3*n).reverse)\n pqa.enqueue(a(i))\n for(i <- (n to 2*n-1).reverse){\n pqa.enqueue(a(i+1))\n right(i-n) = right(i-n+1) + a(i+1) - pqa.dequeue\n }\n\n\n var ans = -1e18.toLong\n for(i <- 0 to n){\n ans = Math.max(ans, left(i) - right(i))\n }\n\n println(ans)\n}\n", "language": "Scala", "metadata": {"date": 1506481431, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03716.html", "problem_id": "p03716", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03716/input.txt", "sample_output_relpath": "derived/input_output/data/p03716/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03716/Scala/s835039950.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s835039950", "user_id": "u098968285"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.Scanner\nimport scala.collection.mutable.PriorityQueue\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val n = sc.nextInt()\n val a = new Array[Int](3*n + 1)\n\n for(i <- 1 to 3*n)\n a(i) = sc.nextInt()\n\n val left = new Array[Long](n+1)\n val right = new Array[Long](n+1)\n\n\n // left\n left(0) = a.slice(1, n+1).sum\n val pqd = new PriorityQueue[Int]()(Ordering.Int.reverse)\n for(i <- 1 to n)\n pqd.enqueue(a(i))\n for(i <- n+1 to 2*n){\n pqd.enqueue(a(i))\n left(i-n) = left(i-n-1) + a(i) - pqd.dequeue\n }\n\n\n // right\n right(n) = a.slice(2*n+1, 3*n+1).sum\n val pqa = new PriorityQueue[Int]\n for(i <- (2*n+1 to 3*n).reverse)\n pqa.enqueue(a(i))\n for(i <- (n to 2*n-1).reverse){\n pqa.enqueue(a(i+1))\n right(i-n) = right(i-n+1) + a(i+1) - pqa.dequeue\n }\n\n\n var ans = -1e18.toLong\n for(i <- 0 to n){\n ans = Math.max(ans, left(i) - right(i))\n }\n\n println(ans)\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nLet N be a positive integer.\n\nThere is a numerical sequence of length 3N, a = (a_1, a_2, ..., a_{3N}).\nSnuke is constructing a new sequence of length 2N, a', by removing exactly N elements from a without changing the order of the remaining elements.\nHere, the score of a' is defined as follows: (the sum of the elements in the first half of a') - (the sum of the elements in the second half of a').\n\nFind the maximum possible score of a'.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\na_i is an integer.\n\n1 ≤ a_i ≤ 10^9\n\nPartial Score\n\nIn the test set worth 300 points, N ≤ 1000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_{3N}\n\nOutput\n\nPrint the maximum possible score of a'.\n\nSample Input 1\n\n2\n3 1 4 1 5 9\n\nSample Output 1\n\n1\n\nWhen a_2 and a_6 are removed, a' will be (3, 4, 1, 5), which has a score of (3 + 4) - (1 + 5) = 1.\n\nSample Input 2\n\n1\n1 2 3\n\nSample Output 2\n\n-1\n\nFor example, when a_1 are removed, a' will be (2, 3), which has a score of 2 - 3 = -1.\n\nSample Input 3\n\n3\n8 2 2 7 4 6 5 3 8\n\nSample Output 3\n\n5\n\nFor example, when a_2, a_3 and a_9 are removed, a' will be (8, 7, 4, 6, 5, 3), which has a score of (8 + 7 + 4) - (6 + 5 + 3) = 5.", "sample_input": "2\n3 1 4 1 5 9\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03716", "source_text": "Score : 500 points\n\nProblem Statement\n\nLet N be a positive integer.\n\nThere is a numerical sequence of length 3N, a = (a_1, a_2, ..., a_{3N}).\nSnuke is constructing a new sequence of length 2N, a', by removing exactly N elements from a without changing the order of the remaining elements.\nHere, the score of a' is defined as follows: (the sum of the elements in the first half of a') - (the sum of the elements in the second half of a').\n\nFind the maximum possible score of a'.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\na_i is an integer.\n\n1 ≤ a_i ≤ 10^9\n\nPartial Score\n\nIn the test set worth 300 points, N ≤ 1000.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_{3N}\n\nOutput\n\nPrint the maximum possible score of a'.\n\nSample Input 1\n\n2\n3 1 4 1 5 9\n\nSample Output 1\n\n1\n\nWhen a_2 and a_6 are removed, a' will be (3, 4, 1, 5), which has a score of (3 + 4) - (1 + 5) = 1.\n\nSample Input 2\n\n1\n1 2 3\n\nSample Output 2\n\n-1\n\nFor example, when a_1 are removed, a' will be (2, 3), which has a score of 2 - 3 = -1.\n\nSample Input 3\n\n3\n8 2 2 7 4 6 5 3 8\n\nSample Output 3\n\n5\n\nFor example, when a_2, a_3 and a_9 are removed, a' will be (8, 7, 4, 6, 5, 3), which has a score of (8 + 7 + 4) - (6 + 5 + 3) = 5.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 921, "cpu_time_ms": 1456, "memory_kb": 112656}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s553064357", "group_id": "codeNet:p03719", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val a = sc.nextInt\n val b = sc.nextInt\n val c = sc.nextInt\n\n val res = if(a <= c && c <= b) \"Yes\" else \"No\"\n\n println(res)\n}\n", "language": "Scala", "metadata": {"date": 1557069503, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s553064357.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s553064357", "user_id": "u829407811"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val a = sc.nextInt\n val b = sc.nextInt\n val c = sc.nextInt\n\n val res = if(a <= c && c <= b) \"Yes\" else \"No\"\n\n println(res)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 342, "memory_kb": 25420}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s323233627", "group_id": "codeNet:p03719", "input_text": "object Main extends App{\n val ary = io.StdIn.readLine().split(\" \")\n val ret = if (ary(0)<=ary(2)&&ary(2)<=ary(1)) \"Yes\" else \"No\"\n println(ret)\n}\n", "language": "Scala", "metadata": {"date": 1496440479, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s323233627.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s323233627", "user_id": "u893154287"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App{\n val ary = io.StdIn.readLine().split(\" \")\n val ret = if (ary(0)<=ary(2)&&ary(2)<=ary(1)) \"Yes\" else \"No\"\n println(ret)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 322, "memory_kb": 27220}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s323513441", "group_id": "codeNet:p03721", "input_text": "\nimport java.util.Scanner\n\nimport scala.collection.mutable.PriorityQueue\n\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val n = sc.nextInt()\n val k = sc.nextLong()\n\n var q = PriorityQueue()(Ordering.by((_: (Int, Long))._1).reverse)\n\n for (i <- 1 to n) {\n val a, b = sc.nextInt()\n q.enqueue((a, b))\n }\n\n val (_, ans) = q.foldLeft((0L, -1)) {\n\n case ((cnt, ans), (a, b)) =>\n if (ans > 0) (cnt, ans)\n else if (cnt + b >= k) (cnt, a)\n else (cnt + b, ans)\n }\n\n println(ans)\n}\n", "language": "Scala", "metadata": {"date": 1502756473, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s323513441.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s323513441", "user_id": "u726872801"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "\nimport java.util.Scanner\n\nimport scala.collection.mutable.PriorityQueue\n\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val n = sc.nextInt()\n val k = sc.nextLong()\n\n var q = PriorityQueue()(Ordering.by((_: (Int, Long))._1).reverse)\n\n for (i <- 1 to n) {\n val a, b = sc.nextInt()\n q.enqueue((a, b))\n }\n\n val (_, ans) = q.foldLeft((0L, -1)) {\n\n case ((cnt, ans), (a, b)) =>\n if (ans > 0) (cnt, ans)\n else if (cnt + b >= k) (cnt, a)\n else (cnt + b, ans)\n }\n\n println(ans)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 520, "cpu_time_ms": 936, "memory_kb": 75640}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s116699387", "group_id": "codeNet:p03722", "input_text": "import scala.collection.mutable.Stack\n\nobject Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n, m = sc.nextInt()\n val e = List.fill(m)((sc.nextInt()-1, sc.nextInt()-1, -sc.nextInt()))\n\n def shortestPath(s: Int, n: Int, edges: Seq[(Int, Int, Int)]): Array[Long] = {\n val adj = Array.fill(n)(List[Int]())\n for ((u, v, _) <- edges) {\n adj(u) ::= v\n }\n\n val sp = Array.fill(n)(Long.MaxValue)\n sp(s) = 0\n\n for {\n _ <- 1 until n\n (u, v, l) <- edges if sp(u) != Long.MaxValue\n } {\n sp(v) = sp(v).min(sp(u) + l)\n }\n\n var visited = Set[Int]()\n val stack = Stack[Int]()\n for ((u, v, l) <- edges if sp(u) != Long.MaxValue) {\n if (sp(v) > sp(u) + l) {\n visited += v\n stack.push(v)\n }\n }\n\n while (stack.nonEmpty) {\n val u = stack.pop()\n for (v <- adj(u) if !visited(v)) {\n visited += v\n stack.push(v)\n }\n }\n\n for (u <- visited) {\n sp(u) = Long.MinValue\n }\n\n sp\n }\n\n val sp = shortestPath(0, n, e)\n println(if (sp(n-1) == Long.MinValue) \"inf\" else -sp(n-1))\n}\n", "language": "Scala", "metadata": {"date": 1595691318, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s116699387.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s116699387", "user_id": "u191819389"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "import scala.collection.mutable.Stack\n\nobject Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n, m = sc.nextInt()\n val e = List.fill(m)((sc.nextInt()-1, sc.nextInt()-1, -sc.nextInt()))\n\n def shortestPath(s: Int, n: Int, edges: Seq[(Int, Int, Int)]): Array[Long] = {\n val adj = Array.fill(n)(List[Int]())\n for ((u, v, _) <- edges) {\n adj(u) ::= v\n }\n\n val sp = Array.fill(n)(Long.MaxValue)\n sp(s) = 0\n\n for {\n _ <- 1 until n\n (u, v, l) <- edges if sp(u) != Long.MaxValue\n } {\n sp(v) = sp(v).min(sp(u) + l)\n }\n\n var visited = Set[Int]()\n val stack = Stack[Int]()\n for ((u, v, l) <- edges if sp(u) != Long.MaxValue) {\n if (sp(v) > sp(u) + l) {\n visited += v\n stack.push(v)\n }\n }\n\n while (stack.nonEmpty) {\n val u = stack.pop()\n for (v <- adj(u) if !visited(v)) {\n visited += v\n stack.push(v)\n }\n }\n\n for (u <- visited) {\n sp(u) = Long.MinValue\n }\n\n sp\n }\n\n val sp = shortestPath(0, n, e)\n println(if (sp(n-1) == Long.MinValue) \"inf\" else -sp(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 println(v)\n case _ => println(\"inf\")\n }\n }\n\n def bellmanFord(V: Int, G: Array[ArrayBuffer[Edge]], s: Int): Option[Long] = {\n val dist = Array.fill(V+1)(INF)\n dist(s) = 0\n\n def relax(u: Int, v: Int, w: Int): Boolean =\n if (dist(u) != INF && dist(v) > dist(u) + w) {\n dist(v) = dist(u) + w\n true\n } else false\n\n val sorted = topologicalSort(V, G, 1)\n for {\n u <- sorted\n e <- G(u)\n } relax(u, e.to, e.weight)\n\n if (!sorted.exists(u => G(u).exists(e => relax(u, e.to, e.weight))))\n Some(-dist(V))\n else None\n }\n\n private def topologicalSort(V: Int, G: Array[ArrayBuffer[Edge]], s: Int): List[Int] = {\n val visited = new Array[Boolean](V+1)\n def dfs(stack: List[Int], sorted: List[Int]): List[Int] =\n if (stack.nonEmpty) {\n val u = stack.head\n if (u < 0) dfs(stack.tail, (-u)-1 :: sorted)\n else if (!visited(u)) {\n visited(u) = true\n dfs(\n G(u).foldLeft(-(u+1) :: stack.tail)(\n (stack, e) => e.to :: stack), sorted)\n } else dfs(stack.tail, sorted)\n } else sorted\n dfs(s :: Nil, Nil)\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1581458314, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s843347700.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s843347700", "user_id": "u891387249"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "import scala.collection.mutable.ArrayBuffer\n\nobject Main {\n\n val INF = Long.MaxValue\n case class Edge(to: Int, weight: Int)\n def main(args: Array[String]): Unit = {\n // 仮定, スコアが無限に増えるケースでは閉路が存在するから, inf\n // つまり, 正常な場合は閉路がないことから有効非巡回グラフになっているので\n // トポロジカルソート版ベルマンフォードが有効\n // 閉路検出は, トポロジカルソート順に再度緩和した時, 緩和できるかどうか?\n // なお, 1からVまで必ず到達できることを保証しているが, それ以外が連結かどうかを示していない\n val sc = new java.util.Scanner(System.in)\n\n val V, E = sc.nextInt()\n val G = Array.fill(V+1)(new ArrayBuffer[Edge]())\n for (_ <- 0 until E) {\n val u, v, w = sc.nextInt()\n G(u).append(Edge(v, -w))\n }\n\n bellmanFord(V, G, 1) match {\n case Some(v) => println(v)\n case _ => println(\"inf\")\n }\n }\n\n def bellmanFord(V: Int, G: Array[ArrayBuffer[Edge]], s: Int): Option[Long] = {\n val dist = Array.fill(V+1)(INF)\n dist(s) = 0\n\n def relax(u: Int, v: Int, w: Int): Boolean =\n if (dist(u) != INF && dist(v) > dist(u) + w) {\n dist(v) = dist(u) + w\n true\n } else false\n\n val sorted = topologicalSort(V, G, 1)\n for {\n u <- sorted\n e <- G(u)\n } relax(u, e.to, e.weight)\n\n if (!sorted.exists(u => G(u).exists(e => relax(u, e.to, e.weight))))\n Some(-dist(V))\n else None\n }\n\n private def topologicalSort(V: Int, G: Array[ArrayBuffer[Edge]], s: Int): List[Int] = {\n val visited = new Array[Boolean](V+1)\n def dfs(stack: List[Int], sorted: List[Int]): List[Int] =\n if (stack.nonEmpty) {\n val u = stack.head\n if (u < 0) dfs(stack.tail, (-u)-1 :: sorted)\n else if (!visited(u)) {\n visited(u) = true\n dfs(\n G(u).foldLeft(-(u+1) :: stack.tail)(\n (stack, e) => e.to :: stack), sorted)\n } else dfs(stack.tail, sorted)\n } else sorted\n dfs(s :: Nil, Nil)\n }\n\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 (a % datB) == datC)\n println(if(ans) \"YES\" else \"NO\")\n }\n}\n", "language": "Scala", "metadata": {"date": 1589123247, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03730.html", "problem_id": "p03730", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03730/input.txt", "sample_output_relpath": "derived/input_output/data/p03730/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03730/Scala/s296741862.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s296741862", "user_id": "u014716041"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n import scala.io.StdIn.readLine\n val Array(datA, datB, datC) = readLine.split(\" \").map(_.toInt)\n val ans = (datA to (datA * datB) by datA).exists(a => (a % datB) == datC)\n println(if(ans) \"YES\" else \"NO\")\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe ask you to select some number of positive integers, and calculate the sum of them.\n\nIt is allowed to select as many integers as you like, and as large integers as you wish.\nYou have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer.\n\nYour objective is to make the sum congruent to C modulo B.\nDetermine whether this is possible.\n\nIf the objective is achievable, print YES. Otherwise, print NO.\n\nConstraints\n\n1 ≤ A ≤ 100\n\n1 ≤ B ≤ 100\n\n0 ≤ C < B\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\n7 5 1\n\nSample Output 1\n\nYES\n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\nSample Input 2\n\n2 2 1\n\nSample Output 2\n\nNO\n\nThe sum of even numbers, no matter how many, is never odd.\n\nSample Input 3\n\n1 100 97\n\nSample Output 3\n\nYES\n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\nSample Input 4\n\n40 98 58\n\nSample Output 4\n\nYES\n\nSample Input 5\n\n77 42 36\n\nSample Output 5\n\nNO", "sample_input": "7 5 1\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03730", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe ask you to select some number of positive integers, and calculate the sum of them.\n\nIt is allowed to select as many integers as you like, and as large integers as you wish.\nYou have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer.\n\nYour objective is to make the sum congruent to C modulo B.\nDetermine whether this is possible.\n\nIf the objective is achievable, print YES. Otherwise, print NO.\n\nConstraints\n\n1 ≤ A ≤ 100\n\n1 ≤ B ≤ 100\n\n0 ≤ C < B\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\n7 5 1\n\nSample Output 1\n\nYES\n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\nSample Input 2\n\n2 2 1\n\nSample Output 2\n\nNO\n\nThe sum of even numbers, no matter how many, is never odd.\n\nSample Input 3\n\n1 100 97\n\nSample Output 3\n\nYES\n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\nSample Input 4\n\n40 98 58\n\nSample Output 4\n\nYES\n\nSample Input 5\n\n77 42 36\n\nSample Output 5\n\nNO", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 279, "cpu_time_ms": 328, "memory_kb": 27288}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s293590811", "group_id": "codeNet:p03730", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n import scala.io.StdIn.readLine\n val Array(datA, datB, datC) = readLine.split(\" \").map(_.toInt)\n val ans = (datA to (datA * datB) by datA).exists(a => (a % datB) == datC)\n println(if(ans) \"Yes\" else \"No\")\n }\n}\n", "language": "Scala", "metadata": {"date": 1589123125, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03730.html", "problem_id": "p03730", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03730/input.txt", "sample_output_relpath": "derived/input_output/data/p03730/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03730/Scala/s293590811.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s293590811", "user_id": "u014716041"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n import scala.io.StdIn.readLine\n val Array(datA, datB, datC) = readLine.split(\" \").map(_.toInt)\n val ans = (datA to (datA * datB) by datA).exists(a => (a % datB) == datC)\n println(if(ans) \"Yes\" else \"No\")\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe ask you to select some number of positive integers, and calculate the sum of them.\n\nIt is allowed to select as many integers as you like, and as large integers as you wish.\nYou have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer.\n\nYour objective is to make the sum congruent to C modulo B.\nDetermine whether this is possible.\n\nIf the objective is achievable, print YES. Otherwise, print NO.\n\nConstraints\n\n1 ≤ A ≤ 100\n\n1 ≤ B ≤ 100\n\n0 ≤ C < B\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\n7 5 1\n\nSample Output 1\n\nYES\n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\nSample Input 2\n\n2 2 1\n\nSample Output 2\n\nNO\n\nThe sum of even numbers, no matter how many, is never odd.\n\nSample Input 3\n\n1 100 97\n\nSample Output 3\n\nYES\n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\nSample Input 4\n\n40 98 58\n\nSample Output 4\n\nYES\n\nSample Input 5\n\n77 42 36\n\nSample Output 5\n\nNO", "sample_input": "7 5 1\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03730", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe ask you to select some number of positive integers, and calculate the sum of them.\n\nIt is allowed to select as many integers as you like, and as large integers as you wish.\nYou have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer.\n\nYour objective is to make the sum congruent to C modulo B.\nDetermine whether this is possible.\n\nIf the objective is achievable, print YES. Otherwise, print NO.\n\nConstraints\n\n1 ≤ A ≤ 100\n\n1 ≤ B ≤ 100\n\n0 ≤ C < B\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\n7 5 1\n\nSample Output 1\n\nYES\n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\nSample Input 2\n\n2 2 1\n\nSample Output 2\n\nNO\n\nThe sum of even numbers, no matter how many, is never odd.\n\nSample Input 3\n\n1 100 97\n\nSample Output 3\n\nYES\n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\nSample Input 4\n\n40 98 58\n\nSample Output 4\n\nYES\n\nSample Input 5\n\n77 42 36\n\nSample Output 5\n\nNO", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 279, "cpu_time_ms": 327, "memory_kb": 25504}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s141418036", "group_id": "codeNet:p03730", "input_text": "import scala.io.StdIn._\n\nobject Main{\n def main(args:Array[String]){\n val s = readLine.split(\" \").map(_.toInt)\n var f = false\n for (i <- 1 to s(1)) {\n if (s(0) * i % s(1) == s(2)) {\n f = true\n }\n } \n if (f) {\n printf(\"YES\\n\")\n } else {\n printf(\"NO\\n\")\n }\n }\n}", "language": "Scala", "metadata": {"date": 1493516979, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03730.html", "problem_id": "p03730", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03730/input.txt", "sample_output_relpath": "derived/input_output/data/p03730/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03730/Scala/s141418036.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s141418036", "user_id": "u133886644"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main{\n def main(args:Array[String]){\n val s = readLine.split(\" \").map(_.toInt)\n var f = false\n for (i <- 1 to s(1)) {\n if (s(0) * i % s(1) == s(2)) {\n f = true\n }\n } \n if (f) {\n printf(\"YES\\n\")\n } else {\n printf(\"NO\\n\")\n }\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe ask you to select some number of positive integers, and calculate the sum of them.\n\nIt is allowed to select as many integers as you like, and as large integers as you wish.\nYou have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer.\n\nYour objective is to make the sum congruent to C modulo B.\nDetermine whether this is possible.\n\nIf the objective is achievable, print YES. Otherwise, print NO.\n\nConstraints\n\n1 ≤ A ≤ 100\n\n1 ≤ B ≤ 100\n\n0 ≤ C < B\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\n7 5 1\n\nSample Output 1\n\nYES\n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\nSample Input 2\n\n2 2 1\n\nSample Output 2\n\nNO\n\nThe sum of even numbers, no matter how many, is never odd.\n\nSample Input 3\n\n1 100 97\n\nSample Output 3\n\nYES\n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\nSample Input 4\n\n40 98 58\n\nSample Output 4\n\nYES\n\nSample Input 5\n\n77 42 36\n\nSample Output 5\n\nNO", "sample_input": "7 5 1\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03730", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe ask you to select some number of positive integers, and calculate the sum of them.\n\nIt is allowed to select as many integers as you like, and as large integers as you wish.\nYou have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer.\n\nYour objective is to make the sum congruent to C modulo B.\nDetermine whether this is possible.\n\nIf the objective is achievable, print YES. Otherwise, print NO.\n\nConstraints\n\n1 ≤ A ≤ 100\n\n1 ≤ B ≤ 100\n\n0 ≤ C < B\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\n7 5 1\n\nSample Output 1\n\nYES\n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\nSample Input 2\n\n2 2 1\n\nSample Output 2\n\nNO\n\nThe sum of even numbers, no matter how many, is never odd.\n\nSample Input 3\n\n1 100 97\n\nSample Output 3\n\nYES\n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\nSample Input 4\n\n40 98 58\n\nSample Output 4\n\nYES\n\nSample Input 5\n\n77 42 36\n\nSample Output 5\n\nNO", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 341, "memory_kb": 25412}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s629461905", "group_id": "codeNet:p03731", "input_text": "import scala.io.StdIn._\nobject Main extends App {\n val Array(_, t) = readLine.split(\" \").map(_.toInt)\n val (_, sum) = readLine.split(\" \").map(_.toInt).foldLeft((0, 0)){case ((until, cur), x) =>\n (x + t, cur + t - (if (x < until) until - x else 0))\n }\n println(sum)\n}", "language": "Scala", "metadata": {"date": 1566850877, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s629461905.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s629461905", "user_id": "u132324749"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "import scala.io.StdIn._\nobject Main extends App {\n val Array(_, t) = readLine.split(\" \").map(_.toInt)\n val (_, sum) = readLine.split(\" \").map(_.toInt).foldLeft((0, 0)){case ((until, cur), x) =>\n (x + t, cur + t - (if (x < until) until - x else 0))\n }\n println(sum)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 584, "memory_kb": 52784}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s471522730", "group_id": "codeNet:p03733", "input_text": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n val Array(n, time) = readLine.split(\" \").map(_.toInt)\n val t = readLine.split(\" \").map(_.toInt)\n\n var nextT = 0\n var sum = 0\n for(i <- 0 until n) {\n val ti = t(i)\n if(nextT <= ti) {\n sum += time\n } else {\n sum += ti + time - nextT\n }\n nextT = ti + time\n }\n\n println(sum)\n\n}", "language": "Scala", "metadata": {"date": 1497801758, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03733.html", "problem_id": "p03733", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03733/input.txt", "sample_output_relpath": "derived/input_output/data/p03733/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03733/Scala/s471522730.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s471522730", "user_id": "u185193776"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n val Array(n, time) = readLine.split(\" \").map(_.toInt)\n val t = readLine.split(\" \").map(_.toInt)\n\n var nextT = 0\n var sum = 0\n for(i <- 0 until n) {\n val ti = t(i)\n if(nextT <= ti) {\n sum += time\n } else {\n sum += ti + time - nextT\n }\n nextT = ti + time\n }\n\n println(sum)\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": "p03733", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn a public bath, there is a shower which emits water for T seconds when the switch is pushed.\n\nIf the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds.\nNote that it does not mean that the shower emits water for T additional seconds.\n\nN people will push the switch while passing by the shower.\nThe i-th person will push the switch t_i seconds after the first person pushes it.\n\nHow long will the shower emit water in total?\n\nConstraints\n\n1 ≤ N ≤ 200,000\n\n1 ≤ T ≤ 10^9\n\n0 = t_1 < t_2 < t_3 < , ..., < t_{N-1} < t_N ≤ 10^9\n\nT and each t_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nt_1 t_2 ... t_N\n\nOutput\n\nAssume that the shower will emit water for a total of X seconds. Print X.\n\nSample Input 1\n\n2 4\n0 3\n\nSample Output 1\n\n7\n\nThree seconds after the first person pushes the water, the switch is pushed again and the shower emits water for four more seconds, for a total of seven seconds.\n\nSample Input 2\n\n2 4\n0 5\n\nSample Output 2\n\n8\n\nOne second after the shower stops emission of water triggered by the first person, the switch is pushed again.\n\nSample Input 3\n\n4 1000000000\n0 1000 1000000 1000000000\n\nSample Output 3\n\n2000000000\n\nSample Input 4\n\n1 1\n0\n\nSample Output 4\n\n1\n\nSample Input 5\n\n9 10\n0 3 5 7 100 110 200 300 311\n\nSample Output 5\n\n67", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 533, "memory_kb": 52860}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s762038567", "group_id": "codeNet:p03737", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n println(Array.fill(3)(sc.next()).foldLeft(\"\")((z, x) => z + x(0).toUpper.toString))\n}", "language": "Scala", "metadata": {"date": 1588850929, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03737.html", "problem_id": "p03737", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03737/input.txt", "sample_output_relpath": "derived/input_output/data/p03737/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03737/Scala/s762038567.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s762038567", "user_id": "u786167609"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n println(Array.fill(3)(sc.next()).foldLeft(\"\")((z, x) => z + x(0).toUpper.toString))\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between.\nPrint the acronym formed from the uppercased initial letters of the words.\n\nConstraints\n\ns_1, s_2 and s_3 are composed of lowercase English letters.\n\n1 ≤ |s_i| ≤ 10 (1≤i≤3)\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns_1 s_2 s_3\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\natcoder beginner contest\n\nSample Output 1\n\nABC\n\nThe initial letters of atcoder, beginner and contest are a, b and c. Uppercase and concatenate them to obtain ABC.\n\nSample Input 2\n\nresident register number\n\nSample Output 2\n\nRRN\n\nSample Input 3\n\nk nearest neighbor\n\nSample Output 3\n\nKNN\n\nSample Input 4\n\nasync layered coding\n\nSample Output 4\n\nALC", "sample_input": "atcoder beginner contest\n"}, "reference_outputs": ["ABC\n"], "source_document_id": "p03737", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between.\nPrint the acronym formed from the uppercased initial letters of the words.\n\nConstraints\n\ns_1, s_2 and s_3 are composed of lowercase English letters.\n\n1 ≤ |s_i| ≤ 10 (1≤i≤3)\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns_1 s_2 s_3\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\natcoder beginner contest\n\nSample Output 1\n\nABC\n\nThe initial letters of atcoder, beginner and contest are a, b and c. Uppercase and concatenate them to obtain ABC.\n\nSample Input 2\n\nresident register number\n\nSample Output 2\n\nRRN\n\nSample Input 3\n\nk nearest neighbor\n\nSample Output 3\n\nKNN\n\nSample Input 4\n\nasync layered coding\n\nSample Output 4\n\nALC", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 349, "memory_kb": 27428}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s362789044", "group_id": "codeNet:p03737", "input_text": "import java.io.{PrintWriter, _}\nimport java.util._\n\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val inputStream = System.in\n val outputStream = System.out\n val in = new InputReader(inputStream)\n val out = new PrintWriter(outputStream)\n val solver = new Task\n solver.solve(1, in, out)\n out.close()\n }\n\n class Task {\n def solve(testNumber: Int, in: InputReader, out: PrintWriter): Unit = {\n val a = in.next\n val b = in.next\n val c = in.next\n out.println(a(0).toUpper + \"\" + b(0).toUpper + \"\" + c(0).toUpper)\n }\n }\n\n class InputReader(val stream: InputStream) extends AutoCloseable {\n //reader = new BufferedReader(new FileReader(stream), 32768);\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer = new StringTokenizer(\"\")\n\n\n def next: String = {\n while ( {\n tokenizer == null || !tokenizer.hasMoreTokens\n }) try\n tokenizer = new StringTokenizer(reader.readLine)\n catch {\n case e: IOException =>\n throw new RuntimeException(e)\n }\n tokenizer.nextToken\n }\n\n def nextLine: String = {\n try\n return reader.readLine\n catch {\n case e: IOException =>\n e.printStackTrace()\n }\n \"\"\n }\n\n def nextInt: Int = next.toInt\n\n def nextLong: Long = next.toLong\n\n override def close(): Unit = {\n }\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1559857727, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03737.html", "problem_id": "p03737", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03737/input.txt", "sample_output_relpath": "derived/input_output/data/p03737/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03737/Scala/s362789044.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s362789044", "user_id": "u992675902"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "import java.io.{PrintWriter, _}\nimport java.util._\n\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val inputStream = System.in\n val outputStream = System.out\n val in = new InputReader(inputStream)\n val out = new PrintWriter(outputStream)\n val solver = new Task\n solver.solve(1, in, out)\n out.close()\n }\n\n class Task {\n def solve(testNumber: Int, in: InputReader, out: PrintWriter): Unit = {\n val a = in.next\n val b = in.next\n val c = in.next\n out.println(a(0).toUpper + \"\" + b(0).toUpper + \"\" + c(0).toUpper)\n }\n }\n\n class InputReader(val stream: InputStream) extends AutoCloseable {\n //reader = new BufferedReader(new FileReader(stream), 32768);\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer = new StringTokenizer(\"\")\n\n\n def next: String = {\n while ( {\n tokenizer == null || !tokenizer.hasMoreTokens\n }) try\n tokenizer = new StringTokenizer(reader.readLine)\n catch {\n case e: IOException =>\n throw new RuntimeException(e)\n }\n tokenizer.nextToken\n }\n\n def nextLine: String = {\n try\n return reader.readLine\n catch {\n case e: IOException =>\n e.printStackTrace()\n }\n \"\"\n }\n\n def nextInt: Int = next.toInt\n\n def nextLong: Long = next.toLong\n\n override def close(): Unit = {\n }\n }\n\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between.\nPrint the acronym formed from the uppercased initial letters of the words.\n\nConstraints\n\ns_1, s_2 and s_3 are composed of lowercase English letters.\n\n1 ≤ |s_i| ≤ 10 (1≤i≤3)\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns_1 s_2 s_3\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\natcoder beginner contest\n\nSample Output 1\n\nABC\n\nThe initial letters of atcoder, beginner and contest are a, b and c. Uppercase and concatenate them to obtain ABC.\n\nSample Input 2\n\nresident register number\n\nSample Output 2\n\nRRN\n\nSample Input 3\n\nk nearest neighbor\n\nSample Output 3\n\nKNN\n\nSample Input 4\n\nasync layered coding\n\nSample Output 4\n\nALC", "sample_input": "atcoder beginner contest\n"}, "reference_outputs": ["ABC\n"], "source_document_id": "p03737", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between.\nPrint the acronym formed from the uppercased initial letters of the words.\n\nConstraints\n\ns_1, s_2 and s_3 are composed of lowercase English letters.\n\n1 ≤ |s_i| ≤ 10 (1≤i≤3)\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns_1 s_2 s_3\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\natcoder beginner contest\n\nSample Output 1\n\nABC\n\nThe initial letters of atcoder, beginner and contest are a, b and c. Uppercase and concatenate them to obtain ABC.\n\nSample Input 2\n\nresident register number\n\nSample Output 2\n\nRRN\n\nSample Input 3\n\nk nearest neighbor\n\nSample Output 3\n\nKNN\n\nSample Input 4\n\nasync layered coding\n\nSample Output 4\n\nALC", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 333, "memory_kb": 27332}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s812922183", "group_id": "codeNet:p03738", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val a = sc.next\n val b = sc.next\n \n val res =\n if (a.length != b.length){\n if (a.length > b.length ) \"GREATER\"\n else \"LESS\"\n }\n else {\n val diff = (a zip b).find(t => t._1 != t._2)\n\n diff.map{case (aa, bb) =>\n if (aa > bb) \"GREATER\"\n else \"LESS\"\n }.getOrElse(\"EQUAL\")\n }\n\n println(res)\n}", "language": "Scala", "metadata": {"date": 1556635077, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s812922183.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s812922183", "user_id": "u829407811"}, "prompt_components": {"gold_output": "GREATER\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val a = sc.next\n val b = sc.next\n \n val res =\n if (a.length != b.length){\n if (a.length > b.length ) \"GREATER\"\n else \"LESS\"\n }\n else {\n val diff = (a zip b).find(t => t._1 != t._2)\n\n diff.map{case (aa, bb) =>\n if (aa > bb) \"GREATER\"\n else \"LESS\"\n }.getOrElse(\"EQUAL\")\n }\n\n println(res)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 360, "memory_kb": 25532}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s116969783", "group_id": "codeNet:p03739", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n import scala.io.StdIn.readLine\n val _ = readLine\n val datA = readLine.split(\" \").map(_.toLong).dropWhile(_ == 0)\n\n def judgement(acc: (Long, Long), cur: (Long, Long)): (Long, Long) = {\n val sum = acc._1\n val count = acc._2\n val a = cur._1\n if (sum > 0) {\n if (sum + a >= 0) (-1, count + math.abs(sum + a) + 1)\n else (sum + a, count)\n }\n else if (sum < 0) {\n if (sum + a <= 0) (1, count + math.abs(sum + a) + 1)\n else (sum + a, count)\n } else {\n (a, count)\n }\n }\n val posA = datA.map(a => (a, 0L)).foldLeft((0L, 0L)){ judgement(_, _) }\n val negA = datA.tail.map(a => (a, 0L)).foldLeft(\n if(datA.head > 0) -1L else 1L, math.abs(datA.head)\n ){ judgement(_, _) }\n\n val ans = math.min(posA._2, negA._2)\n println(ans)\n }\n}", "language": "Scala", "metadata": {"date": 1588624845, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s116969783.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s116969783", "user_id": "u014716041"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n import scala.io.StdIn.readLine\n val _ = readLine\n val datA = readLine.split(\" \").map(_.toLong).dropWhile(_ == 0)\n\n def judgement(acc: (Long, Long), cur: (Long, Long)): (Long, Long) = {\n val sum = acc._1\n val count = acc._2\n val a = cur._1\n if (sum > 0) {\n if (sum + a >= 0) (-1, count + math.abs(sum + a) + 1)\n else (sum + a, count)\n }\n else if (sum < 0) {\n if (sum + a <= 0) (1, count + math.abs(sum + a) + 1)\n else (sum + a, count)\n } else {\n (a, count)\n }\n }\n val posA = datA.map(a => (a, 0L)).foldLeft((0L, 0L)){ judgement(_, _) }\n val negA = datA.tail.map(a => (a, 0L)).foldLeft(\n if(datA.head > 0) -1L else 1L, math.abs(datA.head)\n ){ judgement(_, _) }\n\n val ans = math.min(posA._2, negA._2)\n println(ans)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 884, "cpu_time_ms": 673, "memory_kb": 54372}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s718750799", "group_id": "codeNet:p03739", "input_text": "import scala.io.StdIn\nimport scala.annotation.tailrec\n\nobject Main extends App {\n val n = StdIn.readInt\n val a = StdIn.readLine.split(\" \").map(_.toLong)\n\n val init1 = if(a.head < 0) 1 - a.head else 0\n val ans1 = a.tail./:(a.head + init1, init1.abs)((acc,i) => {\n val (bsum, bcnt) = acc\n val sum = bsum + i\n val cnt = if(bsum < 0 && sum < 0) 1 - sum\n else if(bsum > 0 && sum > 0) -1 - sum\n else if(sum == 0) if(bsum < 0) 1 else -1\n else 0\n // println(sum + \" \" + cnt)\n (sum+cnt, bcnt+cnt.abs)\n })._2\n\n val init2 = if(a.head < 0) 0 else -1 - a.head\n val ans2 = a.tail./:(a.head + init2, init2.abs)((acc,i) => {\n val (bsum, bcnt) = acc\n val sum = bsum + i\n val cnt = if(bsum < 0 && sum < 0) 1 - sum\n else if(bsum > 0 && sum > 0) -1 - sum\n else if(sum == 0) if(bsum < 0) 1 else -1\n else 0\n // println(sum + \" \" + cnt)\n (sum+cnt, bcnt+cnt.abs)\n })._2\n\n println(math.min(ans1,ans2))\n}", "language": "Scala", "metadata": {"date": 1547330333, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s718750799.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s718750799", "user_id": "u217010036"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import scala.io.StdIn\nimport scala.annotation.tailrec\n\nobject Main extends App {\n val n = StdIn.readInt\n val a = StdIn.readLine.split(\" \").map(_.toLong)\n\n val init1 = if(a.head < 0) 1 - a.head else 0\n val ans1 = a.tail./:(a.head + init1, init1.abs)((acc,i) => {\n val (bsum, bcnt) = acc\n val sum = bsum + i\n val cnt = if(bsum < 0 && sum < 0) 1 - sum\n else if(bsum > 0 && sum > 0) -1 - sum\n else if(sum == 0) if(bsum < 0) 1 else -1\n else 0\n // println(sum + \" \" + cnt)\n (sum+cnt, bcnt+cnt.abs)\n })._2\n\n val init2 = if(a.head < 0) 0 else -1 - a.head\n val ans2 = a.tail./:(a.head + init2, init2.abs)((acc,i) => {\n val (bsum, bcnt) = acc\n val sum = bsum + i\n val cnt = if(bsum < 0 && sum < 0) 1 - sum\n else if(bsum > 0 && sum > 0) -1 - sum\n else if(sum == 0) if(bsum < 0) 1 else -1\n else 0\n // println(sum + \" \" + cnt)\n (sum+cnt, bcnt+cnt.abs)\n })._2\n\n println(math.min(ans1,ans2))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 935, "cpu_time_ms": 609, "memory_kb": 52420}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s502157331", "group_id": "codeNet:p03764", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n, m = sc.nextInt()\n val x = List.fill(n)(sc.nextLong())\n val y = List.fill(m)(sc.nextLong())\n\n val mod = 1000000007\n\n def plus(a: Long, b: Long): Long = (a + b) % mod\n def times(a: Long, b: Long): Long = (a * b) % mod\n\n val c = x.sliding(2).map{\n case List(x1, x2) => x2 - x1\n }.zipWithIndex.map{\n case (e, idx) => times(times(e, idx+1), n-idx-1)\n }.reduceLeft(plus)\n\n val d = y.sliding(2).map{\n case List(y1, y2) => y2 - y1\n }.zipWithIndex.map{\n case (e, idx) => times(times(e, idx+1), m-idx-1)\n }.reduceLeft(plus)\n\n println(times(c, d))\n}\n", "language": "Scala", "metadata": {"date": 1595565191, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03764.html", "problem_id": "p03764", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03764/input.txt", "sample_output_relpath": "derived/input_output/data/p03764/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03764/Scala/s502157331.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s502157331", "user_id": "u191819389"}, "prompt_components": {"gold_output": "60\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n, m = sc.nextInt()\n val x = List.fill(n)(sc.nextLong())\n val y = List.fill(m)(sc.nextLong())\n\n val mod = 1000000007\n\n def plus(a: Long, b: Long): Long = (a + b) % mod\n def times(a: Long, b: Long): Long = (a * b) % mod\n\n val c = x.sliding(2).map{\n case List(x1, x2) => x2 - x1\n }.zipWithIndex.map{\n case (e, idx) => times(times(e, idx+1), n-idx-1)\n }.reduceLeft(plus)\n\n val d = y.sliding(2).map{\n case List(y1, y2) => y2 - y1\n }.zipWithIndex.map{\n case (e, idx) => times(times(e, idx+1), m-idx-1)\n }.reduceLeft(plus)\n\n println(times(c, d))\n}\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": "p03764", "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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 642, "cpu_time_ms": 1385, "memory_kb": 75964}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s844177921", "group_id": "codeNet:p03767", "input_text": "import io.StdIn.{readInt, readLine}\nobject Main extends App {\n val n = readInt\n val as = readLine.split(\" \").map(_.toLong)\n\n val sorted = as.sorted.reverse\n val result = (0 until n)\n .map(_*2)\n .map(_+1)\n .map(sorted(_))\n .sum\n\n println(result)\n}", "language": "Scala", "metadata": {"date": 1597474086, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s844177921.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s844177921", "user_id": "u104354966"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import io.StdIn.{readInt, readLine}\nobject Main extends App {\n val n = readInt\n val as = readLine.split(\" \").map(_.toLong)\n\n val sorted = as.sorted.reverse\n val result = (0 until n)\n .map(_*2)\n .map(_+1)\n .map(sorted(_))\n .sum\n\n println(result)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 887, "memory_kb": 93488}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s478375184", "group_id": "codeNet:p03767", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val N = sc.nextInt()\n val participants = List.fill(3 * N)(sc.nextLong())\n println(participants.sorted(Ordering[Long].reverse).slice(N, 2 * N).sum)\n}\n", "language": "Scala", "metadata": {"date": 1593865011, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s478375184.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s478375184", "user_id": "u737111725"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val N = sc.nextInt()\n val participants = List.fill(3 * N)(sc.nextLong())\n println(participants.sorted(Ordering[Long].reverse).slice(N, 2 * N).sum)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 223, "cpu_time_ms": 1331, "memory_kb": 83620}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s814105364", "group_id": "codeNet:p03773", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val A, B = sc.nextInt()\n println((A + B) % 24)\n}\n", "language": "Scala", "metadata": {"date": 1596335489, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03773.html", "problem_id": "p03773", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03773/input.txt", "sample_output_relpath": "derived/input_output/data/p03773/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03773/Scala/s814105364.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s814105364", "user_id": "u737111725"}, "prompt_components": {"gold_output": "21\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val A, B = sc.nextInt()\n println((A + B) % 24)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nDolphin loves programming contests. Today, he will take part in a contest in AtCoder.\n\nIn this country, 24-hour clock is used. For example, 9:00 p.m. is referred to as \"21 o'clock\".\n\nThe current time is A o'clock, and a contest will begin in exactly B hours.\nWhen will the contest begin? Answer in 24-hour time.\n\nConstraints\n\n0 \\leq A,B \\leq 23\n\nA and B are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the hour of the starting time of the contest in 24-hour time.\n\nSample Input 1\n\n9 12\n\nSample Output 1\n\n21\n\nIn this input, the current time is 9 o'clock, and 12 hours later it will be 21 o'clock in 24-hour time.\n\nSample Input 2\n\n19 0\n\nSample Output 2\n\n19\n\nThe contest has just started.\n\nSample Input 3\n\n23 2\n\nSample Output 3\n\n1\n\nThe contest will begin at 1 o'clock the next day.", "sample_input": "9 12\n"}, "reference_outputs": ["21\n"], "source_document_id": "p03773", "source_text": "Score : 100 points\n\nProblem Statement\n\nDolphin loves programming contests. Today, he will take part in a contest in AtCoder.\n\nIn this country, 24-hour clock is used. For example, 9:00 p.m. is referred to as \"21 o'clock\".\n\nThe current time is A o'clock, and a contest will begin in exactly B hours.\nWhen will the contest begin? Answer in 24-hour time.\n\nConstraints\n\n0 \\leq A,B \\leq 23\n\nA and B are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the hour of the starting time of the contest in 24-hour time.\n\nSample Input 1\n\n9 12\n\nSample Output 1\n\n21\n\nIn this input, the current time is 9 o'clock, and 12 hours later it will be 21 o'clock in 24-hour time.\n\nSample Input 2\n\n19 0\n\nSample Output 2\n\n19\n\nThe contest has just started.\n\nSample Input 3\n\n23 2\n\nSample Output 3\n\n1\n\nThe contest will begin at 1 o'clock the next day.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 504, "memory_kb": 55272}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s627147644", "group_id": "codeNet:p03773", "input_text": "object Main extends App {\n\tvar a = readLine\n\tvar sum = a.split(\" \")(0).toInt + a.split(\" \")(1).toInt\n\n\tprintln(sum % 24)\n}\n", "language": "Scala", "metadata": {"date": 1492791179, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03773.html", "problem_id": "p03773", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03773/input.txt", "sample_output_relpath": "derived/input_output/data/p03773/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03773/Scala/s627147644.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s627147644", "user_id": "u675876401"}, "prompt_components": {"gold_output": "21\n", "input_to_evaluate": "object Main extends App {\n\tvar a = readLine\n\tvar sum = a.split(\" \")(0).toInt + a.split(\" \")(1).toInt\n\n\tprintln(sum % 24)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nDolphin loves programming contests. Today, he will take part in a contest in AtCoder.\n\nIn this country, 24-hour clock is used. For example, 9:00 p.m. is referred to as \"21 o'clock\".\n\nThe current time is A o'clock, and a contest will begin in exactly B hours.\nWhen will the contest begin? Answer in 24-hour time.\n\nConstraints\n\n0 \\leq A,B \\leq 23\n\nA and B are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the hour of the starting time of the contest in 24-hour time.\n\nSample Input 1\n\n9 12\n\nSample Output 1\n\n21\n\nIn this input, the current time is 9 o'clock, and 12 hours later it will be 21 o'clock in 24-hour time.\n\nSample Input 2\n\n19 0\n\nSample Output 2\n\n19\n\nThe contest has just started.\n\nSample Input 3\n\n23 2\n\nSample Output 3\n\n1\n\nThe contest will begin at 1 o'clock the next day.", "sample_input": "9 12\n"}, "reference_outputs": ["21\n"], "source_document_id": "p03773", "source_text": "Score : 100 points\n\nProblem Statement\n\nDolphin loves programming contests. Today, he will take part in a contest in AtCoder.\n\nIn this country, 24-hour clock is used. For example, 9:00 p.m. is referred to as \"21 o'clock\".\n\nThe current time is A o'clock, and a contest will begin in exactly B hours.\nWhen will the contest begin? Answer in 24-hour time.\n\nConstraints\n\n0 \\leq A,B \\leq 23\n\nA and B are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the hour of the starting time of the contest in 24-hour time.\n\nSample Input 1\n\n9 12\n\nSample Output 1\n\n21\n\nIn this input, the current time is 9 o'clock, and 12 hours later it will be 21 o'clock in 24-hour time.\n\nSample Input 2\n\n19 0\n\nSample Output 2\n\n19\n\nThe contest has just started.\n\nSample Input 3\n\n23 2\n\nSample Output 3\n\n1\n\nThe contest will begin at 1 o'clock the next day.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 321, "memory_kb": 25528}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s303428412", "group_id": "codeNet:p03773", "input_text": "object Main extends App{\n // Here your code !\n val sc = new java.util.Scanner(System.in)\n println((sc.nextInt+sc.nextInt)%24)\n}\n", "language": "Scala", "metadata": {"date": 1490978243, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03773.html", "problem_id": "p03773", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03773/input.txt", "sample_output_relpath": "derived/input_output/data/p03773/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03773/Scala/s303428412.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s303428412", "user_id": "u010863732"}, "prompt_components": {"gold_output": "21\n", "input_to_evaluate": "object Main extends App{\n // Here your code !\n val sc = new java.util.Scanner(System.in)\n println((sc.nextInt+sc.nextInt)%24)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nDolphin loves programming contests. Today, he will take part in a contest in AtCoder.\n\nIn this country, 24-hour clock is used. For example, 9:00 p.m. is referred to as \"21 o'clock\".\n\nThe current time is A o'clock, and a contest will begin in exactly B hours.\nWhen will the contest begin? Answer in 24-hour time.\n\nConstraints\n\n0 \\leq A,B \\leq 23\n\nA and B are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the hour of the starting time of the contest in 24-hour time.\n\nSample Input 1\n\n9 12\n\nSample Output 1\n\n21\n\nIn this input, the current time is 9 o'clock, and 12 hours later it will be 21 o'clock in 24-hour time.\n\nSample Input 2\n\n19 0\n\nSample Output 2\n\n19\n\nThe contest has just started.\n\nSample Input 3\n\n23 2\n\nSample Output 3\n\n1\n\nThe contest will begin at 1 o'clock the next day.", "sample_input": "9 12\n"}, "reference_outputs": ["21\n"], "source_document_id": "p03773", "source_text": "Score : 100 points\n\nProblem Statement\n\nDolphin loves programming contests. Today, he will take part in a contest in AtCoder.\n\nIn this country, 24-hour clock is used. For example, 9:00 p.m. is referred to as \"21 o'clock\".\n\nThe current time is A o'clock, and a contest will begin in exactly B hours.\nWhen will the contest begin? Answer in 24-hour time.\n\nConstraints\n\n0 \\leq A,B \\leq 23\n\nA and B are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the hour of the starting time of the contest in 24-hour time.\n\nSample Input 1\n\n9 12\n\nSample Output 1\n\n21\n\nIn this input, the current time is 9 o'clock, and 12 hours later it will be 21 o'clock in 24-hour time.\n\nSample Input 2\n\n19 0\n\nSample Output 2\n\n19\n\nThe contest has just started.\n\nSample Input 3\n\n23 2\n\nSample Output 3\n\n1\n\nThe contest will begin at 1 o'clock the next day.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 340, "memory_kb": 25532}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s909449359", "group_id": "codeNet:p03775", "input_text": "import io.StdIn.readLong\nobject Main extends App {\n def digitOf(n: Long) = math.log10(n).floor.toInt + 1\n\n val n = readLong\n println(digitOf((for (a <- 1 to math.sqrt(n).toInt; if n % a == 0; b = n / a) yield b).min))\n}\n", "language": "Scala", "metadata": {"date": 1490585617, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s909449359.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s909449359", "user_id": "u158295568"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import io.StdIn.readLong\nobject Main extends App {\n def digitOf(n: Long) = math.log10(n).floor.toInt + 1\n\n val n = readLong\n println(digitOf((for (a <- 1 to math.sqrt(n).toInt; if n % a == 0; b = n / a) yield b).min))\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 223, "cpu_time_ms": 356, "memory_kb": 28104}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s860656593", "group_id": "codeNet:p03776", "input_text": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n def combinationTable(n: Int): Array[Array[Long]] = {\n val C = Array.fill(n+1, n+1)(1L)\n (2 to n) foreach { i =>\n (1 until i) foreach { j =>\n C(i)(j) = C(i-1)(j-1) + C(i-1)(j)\n }\n }\n C\n }\n\n\n // 品物の中で, 大きい順にA個選べば良い?\n // 同じ平均になる選び方が何通りあるか?\n // 最後に取った数と同じものが何個あるか?で決まる?\n\n val N, A, B = sc.nextInt()\n\n val C = combinationTable(N)\n val V = Array.fill(N)(sc.nextLong()).sorted(Ordering.Long.reverse)\n val ave = V.take(A).sum / A.toDouble\n\n println(ave)\n if (V.takeWhile(_ == V(0)).length >= A) {\n val length = V.takeWhile(_ == V(0)).length\n println((A to B).foldLeft(0L)((b, n) =>\n b + C(length)(n)\n ))\n } else {\n val b = V.take(A)\n val r = b.count(_ == V(A-1))\n val n = V.count(_ == V(A-1))\n println(C(n)(r))\n }\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1559280065, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s860656593.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s860656593", "user_id": "u891387249"}, "prompt_components": {"gold_output": "4.500000\n1\n", "input_to_evaluate": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n def combinationTable(n: Int): Array[Array[Long]] = {\n val C = Array.fill(n+1, n+1)(1L)\n (2 to n) foreach { i =>\n (1 until i) foreach { j =>\n C(i)(j) = C(i-1)(j-1) + C(i-1)(j)\n }\n }\n C\n }\n\n\n // 品物の中で, 大きい順にA個選べば良い?\n // 同じ平均になる選び方が何通りあるか?\n // 最後に取った数と同じものが何個あるか?で決まる?\n\n val N, A, B = sc.nextInt()\n\n val C = combinationTable(N)\n val V = Array.fill(N)(sc.nextLong()).sorted(Ordering.Long.reverse)\n val ave = V.take(A).sum / A.toDouble\n\n println(ave)\n if (V.takeWhile(_ == V(0)).length >= A) {\n val length = V.takeWhile(_ == V(0)).length\n println((A to B).foldLeft(0L)((b, n) =>\n b + C(length)(n)\n ))\n } else {\n val b = V.take(A)\n val r = b.count(_ == V(A-1))\n val n = V.count(_ == V(A-1))\n println(C(n)(r))\n }\n }\n\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1058, "cpu_time_ms": 358, "memory_kb": 25556}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s664715289", "group_id": "codeNet:p03776", "input_text": "\nobject Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n def combinationTable(n: Int): Array[Array[Long]] = {\n val C = Array.fill(n+1, n+1)(1L)\n (2 to n) foreach { i =>\n (1 until i) foreach { j =>\n C(i)(j) = C(i-1)(j-1) + C(i-1)(j)\n }\n }\n C\n }\n\n\n // 品物の中で, 大きい順にA個選べば良い?\n // 同じ平均になる選び方が何通りあるか?\n // 最後に取った数と同じものが何個あるか?で決まる?\n\n val N, A, B = sc.nextInt()\n\n val C = combinationTable(N)\n val V = Array.fill(N)(sc.nextLong()).sorted(Ordering.Long.reverse)\n val ave = V.take(A).sum / A.toDouble\n\n println(ave)\n if (V.takeWhile(_ == V(0)).length >= A) {\n val length = V.takeWhile(_ == V(0)).length\n println((A to length).foldLeft(0L)((b, n) =>\n b + C(length)(n)\n ))\n } else {\n val b = V.take(A)\n val r = b.count(_ == V(A-1))\n val n = V.dropWhile(_ != V(A-1)).takeWhile(_ == V(A-1)).length\n println(C(n)(r))\n }\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1559279726, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s664715289.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s664715289", "user_id": "u891387249"}, "prompt_components": {"gold_output": "4.500000\n1\n", "input_to_evaluate": "\nobject Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n def combinationTable(n: Int): Array[Array[Long]] = {\n val C = Array.fill(n+1, n+1)(1L)\n (2 to n) foreach { i =>\n (1 until i) foreach { j =>\n C(i)(j) = C(i-1)(j-1) + C(i-1)(j)\n }\n }\n C\n }\n\n\n // 品物の中で, 大きい順にA個選べば良い?\n // 同じ平均になる選び方が何通りあるか?\n // 最後に取った数と同じものが何個あるか?で決まる?\n\n val N, A, B = sc.nextInt()\n\n val C = combinationTable(N)\n val V = Array.fill(N)(sc.nextLong()).sorted(Ordering.Long.reverse)\n val ave = V.take(A).sum / A.toDouble\n\n println(ave)\n if (V.takeWhile(_ == V(0)).length >= A) {\n val length = V.takeWhile(_ == V(0)).length\n println((A to length).foldLeft(0L)((b, n) =>\n b + C(length)(n)\n ))\n } else {\n val b = V.take(A)\n val r = b.count(_ == V(A-1))\n val n = V.dropWhile(_ != V(A-1)).takeWhile(_ == V(A-1)).length\n println(C(n)(r))\n }\n }\n\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1098, "cpu_time_ms": 353, "memory_kb": 27344}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s175424406", "group_id": "codeNet:p03776", "input_text": "import java.io.{BufferedReader, InputStream, InputStreamReader}\nimport java.util.StringTokenizer\n\nimport scala.collection.mutable\nimport scala.util.Sorting\nimport math.{abs, max, min}\nimport scala.collection.mutable.{ArrayBuffer, ListBuffer}\n\nobject Main {\n val MOD = 1000000007\n def solve(): Unit = {\n val sc = new InputReader(System.in)\n val N, A, B = sc.nextInt()\n val V = Array.fill[Long](N)(sc.nextLong())\n\n val dp = Array.ofDim[Long](N + 1, N + 1)\n val cnt = Array.ofDim[Long](N + 1, N + 1)\n (0 until N) foreach (i => cnt(i)(0) = 1)\n\n for {\n j <- 1 to N\n i <- 1 to N\n } {\n val v = dp(i - 1)(j - 1) + V(i - 1)\n val v0 = dp(i - 1)(j)\n if (v > v0) {\n dp(i)(j) = v\n cnt(i)(j) = cnt(i - 1)(j - 1)\n } else if (v == v0) {\n dp(i)(j) = v0\n cnt(i)(j) = cnt(i - 1)(j) + cnt(i - 1)(j - 1)\n } else {\n dp(i)(j) = v0\n cnt(i)(j) = cnt(i - 1)(j)\n }\n }\n\n val averages = dp(N).zipWithIndex.slice(A, B + 1) map {\n case (v, j) => (v.toDouble / j, cnt(N)(j))\n }\n val (m, count) = averages.groupBy(_._1) mapValues (_.map(_._2).sum) maxBy (_._1)\n\n println(f\"$m%.6f\")\n println(count)\n }\n\n\n def main(args: Array[String]): Unit = {\n solve()\n }\n\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = null\n\n def next: String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next.toInt\n def nextLong(): Long = next.toLong\n def nextChar(): Char = next.charAt(0)\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1529222616, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s175424406.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s175424406", "user_id": "u460609472"}, "prompt_components": {"gold_output": "4.500000\n1\n", "input_to_evaluate": "import java.io.{BufferedReader, InputStream, InputStreamReader}\nimport java.util.StringTokenizer\n\nimport scala.collection.mutable\nimport scala.util.Sorting\nimport math.{abs, max, min}\nimport scala.collection.mutable.{ArrayBuffer, ListBuffer}\n\nobject Main {\n val MOD = 1000000007\n def solve(): Unit = {\n val sc = new InputReader(System.in)\n val N, A, B = sc.nextInt()\n val V = Array.fill[Long](N)(sc.nextLong())\n\n val dp = Array.ofDim[Long](N + 1, N + 1)\n val cnt = Array.ofDim[Long](N + 1, N + 1)\n (0 until N) foreach (i => cnt(i)(0) = 1)\n\n for {\n j <- 1 to N\n i <- 1 to N\n } {\n val v = dp(i - 1)(j - 1) + V(i - 1)\n val v0 = dp(i - 1)(j)\n if (v > v0) {\n dp(i)(j) = v\n cnt(i)(j) = cnt(i - 1)(j - 1)\n } else if (v == v0) {\n dp(i)(j) = v0\n cnt(i)(j) = cnt(i - 1)(j) + cnt(i - 1)(j - 1)\n } else {\n dp(i)(j) = v0\n cnt(i)(j) = cnt(i - 1)(j)\n }\n }\n\n val averages = dp(N).zipWithIndex.slice(A, B + 1) map {\n case (v, j) => (v.toDouble / j, cnt(N)(j))\n }\n val (m, count) = averages.groupBy(_._1) mapValues (_.map(_._2).sum) maxBy (_._1)\n\n println(f\"$m%.6f\")\n println(count)\n }\n\n\n def main(args: Array[String]): Unit = {\n solve()\n }\n\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = null\n\n def next: String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next.toInt\n def nextLong(): Long = next.toLong\n def nextChar(): Char = next.charAt(0)\n }\n\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1741, "cpu_time_ms": 340, "memory_kb": 25420}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s516912564", "group_id": "codeNet:p03785", "input_text": "object Main extends App {\n val Array(n,c,k) = readLine.split(\" \").map{_.toInt}\n val t = (1 to n).map{_ => readInt}.toArray.sorted\n \n var ans = 0\n var i = 0\n var count = 0\n var time = 0\n \n while (i < n) {\n val now = t(i)\n ans += 1\n \n while (i < n && count < c && t(i)-now <= k) {\n count += 1\n i += 1\n }\n \n count = 0\n }\n \n println(ans)\n}", "language": "Scala", "metadata": {"date": 1577121410, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s516912564.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s516912564", "user_id": "u696665136"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main extends App {\n val Array(n,c,k) = readLine.split(\" \").map{_.toInt}\n val t = (1 to n).map{_ => readInt}.toArray.sorted\n \n var ans = 0\n var i = 0\n var count = 0\n var time = 0\n \n while (i < n) {\n val now = t(i)\n ans += 1\n \n while (i < n && count < c && t(i)-now <= k) {\n count += 1\n i += 1\n }\n \n count = 0\n }\n \n println(ans)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 713, "memory_kb": 38916}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s735128226", "group_id": "codeNet:p03795", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt()\n\n println(800 * n - (n / 15) * 200)\n}", "language": "Scala", "metadata": {"date": 1571431764, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s735128226.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s735128226", "user_id": "u519194615"}, "prompt_components": {"gold_output": "15800\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt()\n\n println(800 * n - (n / 15) * 200)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 334, "memory_kb": 25400}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s359284133", "group_id": "codeNet:p03795", "input_text": "import java.io.{PrintWriter, _}\nimport java.util._\n\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val inputStream = System.in\n val outputStream = System.out\n val in = new InputReader(inputStream)\n val out = new PrintWriter(outputStream)\n val solver = new Task\n solver.solve(1, in, out)\n out.close()\n }\n\n class Task {\n def solve(testNumber: Int, in: InputReader, out: PrintWriter): Unit = {\n val s = in.nextInt\n println(s * 600 - s / 15 * 200)\n }\n }\n\n class InputReader(val stream: InputStream) extends AutoCloseable {\n //reader = new BufferedReader(new FileReader(stream), 32768);\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer = new StringTokenizer(\"\")\n\n\n def next: String = {\n while ( {\n tokenizer == null || !tokenizer.hasMoreTokens\n }) try\n tokenizer = new StringTokenizer(reader.readLine)\n catch {\n case e: IOException =>\n throw new RuntimeException(e)\n }\n tokenizer.nextToken\n }\n\n def nextLine: String = {\n try\n return reader.readLine\n catch {\n case e: IOException =>\n e.printStackTrace()\n }\n \"\"\n }\n\n def nextInt: Int = next.toInt\n\n def nextLong: Long = next.toLong\n\n override def close(): Unit = {\n }\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1559856771, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s359284133.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s359284133", "user_id": "u992675902"}, "prompt_components": {"gold_output": "15800\n", "input_to_evaluate": "import java.io.{PrintWriter, _}\nimport java.util._\n\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val inputStream = System.in\n val outputStream = System.out\n val in = new InputReader(inputStream)\n val out = new PrintWriter(outputStream)\n val solver = new Task\n solver.solve(1, in, out)\n out.close()\n }\n\n class Task {\n def solve(testNumber: Int, in: InputReader, out: PrintWriter): Unit = {\n val s = in.nextInt\n println(s * 600 - s / 15 * 200)\n }\n }\n\n class InputReader(val stream: InputStream) extends AutoCloseable {\n //reader = new BufferedReader(new FileReader(stream), 32768);\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer = new StringTokenizer(\"\")\n\n\n def next: String = {\n while ( {\n tokenizer == null || !tokenizer.hasMoreTokens\n }) try\n tokenizer = new StringTokenizer(reader.readLine)\n catch {\n case e: IOException =>\n throw new RuntimeException(e)\n }\n tokenizer.nextToken\n }\n\n def nextLine: String = {\n try\n return reader.readLine\n catch {\n case e: IOException =>\n e.printStackTrace()\n }\n \"\"\n }\n\n def nextInt: Int = next.toInt\n\n def nextLong: Long = next.toLong\n\n override def close(): Unit = {\n }\n }\n\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1354, "cpu_time_ms": 321, "memory_kb": 27184}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s459794140", "group_id": "codeNet:p03796", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n\n val mod: Long = 1000000007L\n val result = (1 to n).foldLeft(1L)((z, v) => z * v % mod)\n println(result)\n}\n", "language": "Scala", "metadata": {"date": 1579139348, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s459794140.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s459794140", "user_id": "u433254839"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n\n val mod: Long = 1000000007L\n val result = (1 to n).foldLeft(1L)((z, v) => z * v % mod)\n println(result)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 369, "memory_kb": 29768}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s795872440", "group_id": "codeNet:p03796", "input_text": "import io.StdIn.readLong\nobject Main extends App {\n val n = readLong\n println(((1L to n) :\\ 1L) {\n case (i, ans) => i * ans % 1000000007\n })\n}\n", "language": "Scala", "metadata": {"date": 1487478642, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s795872440.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s795872440", "user_id": "u158295568"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import io.StdIn.readLong\nobject Main extends App {\n val n = readLong\n println(((1L to n) :\\ 1L) {\n case (i, ans) => i * ans % 1000000007\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 470, "memory_kb": 41628}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s705370813", "group_id": "codeNet:p03803", "input_text": "import java.util.Scanner\n\n/**\n * Created by sonetsuyoshi on 2015/12/16.\n */\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val a = (sc.nextInt + 13) % 15\n val b = (sc.nextInt + 13) % 15\n\n val d = a - b\n\n val ans = if(d == 0) \"Draw\"\n else if(d > 0) \"Alice\"\n else \"Bob\"\n\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1486934685, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03803.html", "problem_id": "p03803", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03803/input.txt", "sample_output_relpath": "derived/input_output/data/p03803/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03803/Scala/s705370813.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s705370813", "user_id": "u185193776"}, "prompt_components": {"gold_output": "Alice\n", "input_to_evaluate": "import java.util.Scanner\n\n/**\n * Created by sonetsuyoshi on 2015/12/16.\n */\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val a = (sc.nextInt + 13) % 15\n val b = (sc.nextInt + 13) % 15\n\n val d = a - b\n\n val ans = if(d == 0) \"Draw\"\n else if(d > 0) \"Alice\"\n else \"Bob\"\n\n println(ans)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAlice and Bob are playing One Card Poker.\n\nOne Card Poker is a two-player game using playing cards.\n\nEach card in this game shows an integer between 1 and 13, inclusive.\n\nThe strength of a card is determined by the number written on it, as follows:\n\nWeak 2 < 3 < 4 < 5 < 6 < 7 < 8 < 9 < 10 < 11 < 12 < 13 < 1 Strong\n\nOne Card Poker is played as follows:\n\nEach player picks one card from the deck. The chosen card becomes the player's hand.\n\nThe players reveal their hands to each other. The player with the stronger card wins the game.\n\nIf their cards are equally strong, the game is drawn.\n\nYou are watching Alice and Bob playing the game, and can see their hands.\n\nThe number written on Alice's card is A, and the number written on Bob's card is B.\n\nWrite a program to determine the outcome of the game.\n\nConstraints\n\n1≦A≦13\n\n1≦B≦13\n\nA and B are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint Alice if Alice will win. Print Bob if Bob will win. Print Draw if the game will be drawn.\n\nSample Input 1\n\n8 6\n\nSample Output 1\n\nAlice\n\n8 is written on Alice's card, and 6 is written on Bob's card.\nAlice has the stronger card, and thus the output should be Alice.\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\nDraw\n\nSince their cards have the same number, the game will be drawn.\n\nSample Input 3\n\n13 1\n\nSample Output 3\n\nBob", "sample_input": "8 6\n"}, "reference_outputs": ["Alice\n"], "source_document_id": "p03803", "source_text": "Score : 100 points\n\nProblem Statement\n\nAlice and Bob are playing One Card Poker.\n\nOne Card Poker is a two-player game using playing cards.\n\nEach card in this game shows an integer between 1 and 13, inclusive.\n\nThe strength of a card is determined by the number written on it, as follows:\n\nWeak 2 < 3 < 4 < 5 < 6 < 7 < 8 < 9 < 10 < 11 < 12 < 13 < 1 Strong\n\nOne Card Poker is played as follows:\n\nEach player picks one card from the deck. The chosen card becomes the player's hand.\n\nThe players reveal their hands to each other. The player with the stronger card wins the game.\n\nIf their cards are equally strong, the game is drawn.\n\nYou are watching Alice and Bob playing the game, and can see their hands.\n\nThe number written on Alice's card is A, and the number written on Bob's card is B.\n\nWrite a program to determine the outcome of the game.\n\nConstraints\n\n1≦A≦13\n\n1≦B≦13\n\nA and B are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint Alice if Alice will win. Print Bob if Bob will win. Print Draw if the game will be drawn.\n\nSample Input 1\n\n8 6\n\nSample Output 1\n\nAlice\n\n8 is written on Alice's card, and 6 is written on Bob's card.\nAlice has the stronger card, and thus the output should be Alice.\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\nDraw\n\nSince their cards have the same number, the game will be drawn.\n\nSample Input 3\n\n13 1\n\nSample Output 3\n\nBob", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 443, "memory_kb": 22308}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s521719878", "group_id": "codeNet:p03804", "input_text": "object Main extends App {\n val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList\n val nums = inputs.head.split(\" \").map(_.toInt)\n val n = nums(0)\n val m = nums(1)\n val images = inputs.tail\n\n println(solve(n, m, images))\n\n private def solve(n: Int, m: Int, images: Seq[String]): String = {\n val loopEnd = n - m\n val imagesTup = images.splitAt(n)\n val nImage = imagesTup._1\n val mImage = imagesTup._2\n val checkStart = mImage(0)(0)\n\n (0 to loopEnd).foreach { i =>\n val line = nImage(i)\n\n (0 to loopEnd).foreach { j =>\n if(line(j) == checkStart) {\n var ok = true\n (0 until m).foreach { k =>\n val checkLine = images(i + k).splitAt(j)._2.splitAt(m)._1\n if( checkLine != mImage(k)) {\n ok = false\n }\n }\n\n if(ok) {\n return \"Yes\"\n }\n }\n }\n\n }\n return \"No\"\n }\n}\n", "language": "Scala", "metadata": {"date": 1592758519, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s521719878.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s521719878", "user_id": "u631102131"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList\n val nums = inputs.head.split(\" \").map(_.toInt)\n val n = nums(0)\n val m = nums(1)\n val images = inputs.tail\n\n println(solve(n, m, images))\n\n private def solve(n: Int, m: Int, images: Seq[String]): String = {\n val loopEnd = n - m\n val imagesTup = images.splitAt(n)\n val nImage = imagesTup._1\n val mImage = imagesTup._2\n val checkStart = mImage(0)(0)\n\n (0 to loopEnd).foreach { i =>\n val line = nImage(i)\n\n (0 to loopEnd).foreach { j =>\n if(line(j) == checkStart) {\n var ok = true\n (0 until m).foreach { k =>\n val checkLine = images(i + k).splitAt(j)._2.splitAt(m)._1\n if( checkLine != mImage(k)) {\n ok = false\n }\n }\n\n if(ok) {\n return \"Yes\"\n }\n }\n }\n\n }\n return \"No\"\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 929, "cpu_time_ms": 527, "memory_kb": 56100}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s065072506", "group_id": "codeNet:p03804", "input_text": "object Main extends App {\n val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList\n val nums = inputs.head.split(\" \").map(_.toInt)\n val n = nums(0)\n val m = nums(1)\n val images = inputs.tail\n\n println(solve(n, m, images))\n\n private def solve(n: Int, m: Int, images: Seq[String]): String = {\n val loopEnd = n - m\n val imagesTup = images.splitAt(n)\n val nImage = imagesTup._1\n val mImage = imagesTup._2\n\n (0 until loopEnd).foreach { i =>\n val line = nImage(i)\n\n (0 until loopEnd).foreach { j =>\n if(line(j) == mImage(0)(0)) {\n var ok = true\n (0 until m).foreach { k =>\n if(images(i + k).splitAt(j)._2.splitAt(m)._1 != mImage(k)) {\n ok = false\n }\n }\n\n if(ok) {\n return \"Yes\"\n }\n }\n }\n\n }\n return \"No\"\n }\n}", "language": "Scala", "metadata": {"date": 1592758301, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s065072506.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s065072506", "user_id": "u631102131"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList\n val nums = inputs.head.split(\" \").map(_.toInt)\n val n = nums(0)\n val m = nums(1)\n val images = inputs.tail\n\n println(solve(n, m, images))\n\n private def solve(n: Int, m: Int, images: Seq[String]): String = {\n val loopEnd = n - m\n val imagesTup = images.splitAt(n)\n val nImage = imagesTup._1\n val mImage = imagesTup._2\n\n (0 until loopEnd).foreach { i =>\n val line = nImage(i)\n\n (0 until loopEnd).foreach { j =>\n if(line(j) == mImage(0)(0)) {\n var ok = true\n (0 until m).foreach { k =>\n if(images(i + k).splitAt(j)._2.splitAt(m)._1 != mImage(k)) {\n ok = false\n }\n }\n\n if(ok) {\n return \"Yes\"\n }\n }\n }\n\n }\n return \"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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 539, "memory_kb": 56212}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s157547570", "group_id": "codeNet:p03804", "input_text": "import scala.util.control.Breaks._\n\nobject Main extends App {\n val Array(n, m) = scala.io.StdIn.readLine().split(' ').map(_.toInt)\n val as = Array.fill(n)(scala.io.StdIn.readLine().split(\"\"))\n val bs = Array.fill(m)(scala.io.StdIn.readLine).mkString\n\n breakable {\n for (w <- 0 until (n * n - m * m)) {\n val tmp = (for (h <- 0 until m) yield {\n as(h).slice(w, w + m).mkString\n }).mkString\n\n if (tmp == bs) {\n println(\"Yes\")\n break()\n }\n }\n\n println(\"No\")\n }\n}\n", "language": "Scala", "metadata": {"date": 1586566929, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s157547570.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s157547570", "user_id": "u393913844"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.util.control.Breaks._\n\nobject Main extends App {\n val Array(n, m) = scala.io.StdIn.readLine().split(' ').map(_.toInt)\n val as = Array.fill(n)(scala.io.StdIn.readLine().split(\"\"))\n val bs = Array.fill(m)(scala.io.StdIn.readLine).mkString\n\n breakable {\n for (w <- 0 until (n * n - m * m)) {\n val tmp = (for (h <- 0 until m) yield {\n as(h).slice(w, w + m).mkString\n }).mkString\n\n if (tmp == bs) {\n println(\"Yes\")\n break()\n }\n }\n\n println(\"No\")\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 514, "cpu_time_ms": 642, "memory_kb": 36708}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s261854163", "group_id": "codeNet:p03804", "input_text": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n val Array(n, m) = readLine.split(\" \").map(_.toInt)\n val a = Picture(List.fill(n)(readLine.toList))\n val b = Picture(List.fill(m)(readLine.toList))\n println(if (a contains b) \"Yes\" else \"No\")\n\n case class Picture(dots: List[List[Char]]) {\n def contains(pic: Picture): Boolean = {\n dots.sliding(m) exists {\n slides => (slides zip pic.dots) forall {\n case (slide, picsRow) => slide.sliding(m) exists (_ == picsRow)\n }\n }\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1486870624, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s261854163.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s261854163", "user_id": "u158295568"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n val Array(n, m) = readLine.split(\" \").map(_.toInt)\n val a = Picture(List.fill(n)(readLine.toList))\n val b = Picture(List.fill(m)(readLine.toList))\n println(if (a contains b) \"Yes\" else \"No\")\n\n case class Picture(dots: List[List[Char]]) {\n def contains(pic: Picture): Boolean = {\n dots.sliding(m) exists {\n slides => (slides zip pic.dots) forall {\n case (slide, picsRow) => slide.sliding(m) exists (_ == picsRow)\n }\n }\n }\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 530, "cpu_time_ms": 410, "memory_kb": 28760}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s755827667", "group_id": "codeNet:p03816", "input_text": "import scala.io.StdIn.{readInt, readLine}\nobject Main extends App {\n val n = readInt\n val as = readLine.split(' ').map(_.toInt).toSet\n println(as.size - 1 | 1)\n}\n", "language": "Scala", "metadata": {"date": 1485658206, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03816.html", "problem_id": "p03816", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03816/input.txt", "sample_output_relpath": "derived/input_output/data/p03816/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03816/Scala/s755827667.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s755827667", "user_id": "u158295568"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.io.StdIn.{readInt, readLine}\nobject Main extends App {\n val n = readInt\n val as = readLine.split(' ').map(_.toInt).toSet\n println(as.size - 1 | 1)\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": "p03816", "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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 763, "memory_kb": 52516}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s581997737", "group_id": "codeNet:p03817", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val x = sc.nextLong - 1\n val ans = if (x == 0) 0 else {\n val (d, m) = (x / 11L, x % 11L)\n d * 2L + (if (m > 6) 2 else 1)\n }\n println(ans)\n}\n", "language": "Scala", "metadata": {"date": 1498517690, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s581997737.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s581997737", "user_id": "u220774651"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val x = sc.nextLong - 1\n val ans = if (x == 0) 0 else {\n val (d, m) = (x / 11L, x % 11L)\n d * 2L + (if (m > 6) 2 else 1)\n }\n println(ans)\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 340, "memory_kb": 25540}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s994250860", "group_id": "codeNet:p03819", "input_text": "object Main {\n import java.io.{BufferedReader, InputStream, InputStreamReader}\n import java.util.StringTokenizer\n import scala.reflect.ClassTag\n\n def main(args: Array[String]): Unit = {\n val out = new java.io.PrintWriter(System.out)\n new Main(out, new InputReader(System.in)).solve()\n out.flush()\n }\n\n private[this] val oj = System.getenv(\"ATCODER_DEBUG\") == null\n @inline private final def DEBUG(f: => Unit): Unit = {\n if (!oj){ f }\n }\n @inline private final def debug(as: Array[Boolean]): Unit = if (!oj){ debug(as.map(x => if(x) \"1\" else \"0\").mkString) }\n @inline private final def debug(as: Array[Int]): Unit = if (!oj){ debug(as.mkString(\" \")) }\n @inline private final def debug(as: Array[Long]): Unit =if (!oj){ debug(as.mkString(\" \")) }\n @inline private final def debugDim(m: Array[Array[Long]]): Unit = if (!oj){\n REP(m.length) { i =>\n debug(m(i))\n }\n }\n @inline private final def debugDimFlip(m: Array[Array[Long]]): Unit = if (!oj){\n REP(m(0).length) { j =>\n REP(m.length) { i =>\n System.err.print(m(i)(j))\n System.err.print(\" \")\n }\n System.err.println()\n }\n }\n @inline private final def debug(s: => String): Unit = DEBUG {\n System.err.println(s)\n }\n @inline private final def debugL(num: => Long): Unit = DEBUG {\n System.err.println(num)\n }\n\n class InputReader(val stream: InputStream) {\n private[this] val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private[this] var tokenizer: StringTokenizer = _\n\n @inline private[this] final def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = Integer.parseInt(next())\n def nextLong(): Long = java.lang.Long.parseLong(next())\n def nextChar(): Char = next().charAt(0)\n\n def ni(): Int = nextInt()\n def nl(): Long = nextLong()\n def nc(): Char = nextChar()\n def ns(): String = next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n }\n\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n def TO(from: Int, to: Int)(f: Int => Unit): Unit = {\n var i = from\n while(i <= to) { f(i); i += 1 }\n }\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n def cumSum(as: Array[Int]): Array[Long] = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n\nclass Main(out: java.io.PrintWriter, sc: Main.InputReader) {\n import sc._\n import Main._\n import java.util.Arrays.sort\n\n import scala.collection.mutable\n import math.{abs, max, min}\n import mutable.ArrayBuffer\n\n // toIntとか+7とかするならvalにしろ\n final private[this] val MOD = 1000000007\n\n def solve(): Unit = {\n val n, m = ni()\n val (l, r) = na2(n)\n\n val ans = Array.ofDim[Int](m + 1)\n val imos = Array.ofDim[Int](m + 2)\n val rt = math.sqrt(m).toInt\n debug(s\"rt:$rt\")\n REP(n) { i =>\n var d = 1\n while (d <= rt) {\n if (l(i) <= r(i) / d * d) {\n ans(d) += 1\n }\n d += 1\n }\n\n var l0 = m + 1\n var x = 1\n while (x <= rt + 1) {\n val l1 = (l(i) + x - 1) / x\n val r1 = r(i) / x\n val l2 = max(rt + 1, l1) // rtまでは√Mで計算ずみ\n val r2 = min(r1, l0 - 1) // l0まではx-1で計算ずみ\n// debug(s\"i:$i x:$x l1:$l1 l2:$l2 r1:$r1\")\n if (l2 <= r2) {\n imos(l2) += 1\n imos(r2 + 1) -= 1\n }\n l0 = l1\n x += 1\n }\n }\n\n REP(m) { i =>\n imos(i + 1) += imos(i)\n }\n\n debug(ans)\n\n REP(m, 1) { d =>\n out.println(ans(d) + imos(d))\n }\n }\n}", "language": "Scala", "metadata": {"date": 1568779033, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03819.html", "problem_id": "p03819", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03819/input.txt", "sample_output_relpath": "derived/input_output/data/p03819/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03819/Scala/s994250860.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s994250860", "user_id": "u460609472"}, "prompt_components": {"gold_output": "3\n2\n2\n", "input_to_evaluate": "object Main {\n import java.io.{BufferedReader, InputStream, InputStreamReader}\n import java.util.StringTokenizer\n import scala.reflect.ClassTag\n\n def main(args: Array[String]): Unit = {\n val out = new java.io.PrintWriter(System.out)\n new Main(out, new InputReader(System.in)).solve()\n out.flush()\n }\n\n private[this] val oj = System.getenv(\"ATCODER_DEBUG\") == null\n @inline private final def DEBUG(f: => Unit): Unit = {\n if (!oj){ f }\n }\n @inline private final def debug(as: Array[Boolean]): Unit = if (!oj){ debug(as.map(x => if(x) \"1\" else \"0\").mkString) }\n @inline private final def debug(as: Array[Int]): Unit = if (!oj){ debug(as.mkString(\" \")) }\n @inline private final def debug(as: Array[Long]): Unit =if (!oj){ debug(as.mkString(\" \")) }\n @inline private final def debugDim(m: Array[Array[Long]]): Unit = if (!oj){\n REP(m.length) { i =>\n debug(m(i))\n }\n }\n @inline private final def debugDimFlip(m: Array[Array[Long]]): Unit = if (!oj){\n REP(m(0).length) { j =>\n REP(m.length) { i =>\n System.err.print(m(i)(j))\n System.err.print(\" \")\n }\n System.err.println()\n }\n }\n @inline private final def debug(s: => String): Unit = DEBUG {\n System.err.println(s)\n }\n @inline private final def debugL(num: => Long): Unit = DEBUG {\n System.err.println(num)\n }\n\n class InputReader(val stream: InputStream) {\n private[this] val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private[this] var tokenizer: StringTokenizer = _\n\n @inline private[this] final def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = Integer.parseInt(next())\n def nextLong(): Long = java.lang.Long.parseLong(next())\n def nextChar(): Char = next().charAt(0)\n\n def ni(): Int = nextInt()\n def nl(): Long = nextLong()\n def nc(): Char = nextChar()\n def ns(): String = next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n }\n\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n def TO(from: Int, to: Int)(f: Int => Unit): Unit = {\n var i = from\n while(i <= to) { f(i); i += 1 }\n }\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n def cumSum(as: Array[Int]): Array[Long] = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n\nclass Main(out: java.io.PrintWriter, sc: Main.InputReader) {\n import sc._\n import Main._\n import java.util.Arrays.sort\n\n import scala.collection.mutable\n import math.{abs, max, min}\n import mutable.ArrayBuffer\n\n // toIntとか+7とかするならvalにしろ\n final private[this] val MOD = 1000000007\n\n def solve(): Unit = {\n val n, m = ni()\n val (l, r) = na2(n)\n\n val ans = Array.ofDim[Int](m + 1)\n val imos = Array.ofDim[Int](m + 2)\n val rt = math.sqrt(m).toInt\n debug(s\"rt:$rt\")\n REP(n) { i =>\n var d = 1\n while (d <= rt) {\n if (l(i) <= r(i) / d * d) {\n ans(d) += 1\n }\n d += 1\n }\n\n var l0 = m + 1\n var x = 1\n while (x <= rt + 1) {\n val l1 = (l(i) + x - 1) / x\n val r1 = r(i) / x\n val l2 = max(rt + 1, l1) // rtまでは√Mで計算ずみ\n val r2 = min(r1, l0 - 1) // l0まではx-1で計算ずみ\n// debug(s\"i:$i x:$x l1:$l1 l2:$l2 r1:$r1\")\n if (l2 <= r2) {\n imos(l2) += 1\n imos(r2 + 1) -= 1\n }\n l0 = l1\n x += 1\n }\n }\n\n REP(m) { i =>\n imos(i + 1) += imos(i)\n }\n\n debug(ans)\n\n REP(m, 1) { d =>\n out.println(ans(d) + imos(d))\n }\n }\n}", "problem_context": "Score : 700 points\n\nProblem Statement\n\nSnuke has decided to play a game, where the player runs a railway company.\nThere are M+1 stations on Snuke Line, numbered 0 through M.\nA train on Snuke Line stops at station 0 and every d-th station thereafter, where d is a predetermined constant for each train.\nFor example, if d = 3, the train stops at station 0, 3, 6, 9, and so forth.\n\nThere are N kinds of souvenirs sold in areas around Snuke Line. The i-th kind of souvenirs can be purchased when the train stops at one of the following stations: stations l_i, l_i+1, l_i+2, ..., r_i.\n\nThere are M values of d, the interval between two stops, for trains on Snuke Line: 1, 2, 3, ..., M.\nFor each of these M values, find the number of the kinds of souvenirs that can be purchased if one takes a train with that value of d at station 0.\nHere, assume that it is not allowed to change trains.\n\nConstraints\n\n1 ≦ N ≦ 3 × 10^{5}\n\n1 ≦ M ≦ 10^{5}\n\n1 ≦ l_i ≦ r_i ≦ M\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nl_1 r_1\n:\nl_{N} r_{N}\n\nOutput\n\nPrint the answer in M lines. The i-th line should contain the maximum number of the kinds of souvenirs that can be purchased if one takes a train stopping every i-th station.\n\nSample Input 1\n\n3 3\n1 2\n2 3\n3 3\n\nSample Output 1\n\n3\n2\n2\n\nIf one takes a train stopping every station, three kinds of souvenirs can be purchased: kind 1, 2 and 3.\n\nIf one takes a train stopping every second station, two kinds of souvenirs can be purchased: kind 1 and 2.\n\nIf one takes a train stopping every third station, two kinds of souvenirs can be purchased: kind 2 and 3.\n\nSample Input 2\n\n7 9\n1 7\n5 9\n5 7\n5 9\n1 1\n6 8\n3 4\n\nSample Output 2\n\n7\n6\n6\n5\n4\n5\n5\n3\n2", "sample_input": "3 3\n1 2\n2 3\n3 3\n"}, "reference_outputs": ["3\n2\n2\n"], "source_document_id": "p03819", "source_text": "Score : 700 points\n\nProblem Statement\n\nSnuke has decided to play a game, where the player runs a railway company.\nThere are M+1 stations on Snuke Line, numbered 0 through M.\nA train on Snuke Line stops at station 0 and every d-th station thereafter, where d is a predetermined constant for each train.\nFor example, if d = 3, the train stops at station 0, 3, 6, 9, and so forth.\n\nThere are N kinds of souvenirs sold in areas around Snuke Line. The i-th kind of souvenirs can be purchased when the train stops at one of the following stations: stations l_i, l_i+1, l_i+2, ..., r_i.\n\nThere are M values of d, the interval between two stops, for trains on Snuke Line: 1, 2, 3, ..., M.\nFor each of these M values, find the number of the kinds of souvenirs that can be purchased if one takes a train with that value of d at station 0.\nHere, assume that it is not allowed to change trains.\n\nConstraints\n\n1 ≦ N ≦ 3 × 10^{5}\n\n1 ≦ M ≦ 10^{5}\n\n1 ≦ l_i ≦ r_i ≦ M\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nl_1 r_1\n:\nl_{N} r_{N}\n\nOutput\n\nPrint the answer in M lines. The i-th line should contain the maximum number of the kinds of souvenirs that can be purchased if one takes a train stopping every i-th station.\n\nSample Input 1\n\n3 3\n1 2\n2 3\n3 3\n\nSample Output 1\n\n3\n2\n2\n\nIf one takes a train stopping every station, three kinds of souvenirs can be purchased: kind 1, 2 and 3.\n\nIf one takes a train stopping every second station, two kinds of souvenirs can be purchased: kind 1 and 2.\n\nIf one takes a train stopping every third station, two kinds of souvenirs can be purchased: kind 2 and 3.\n\nSample Input 2\n\n7 9\n1 7\n5 9\n5 7\n5 9\n1 1\n6 8\n3 4\n\nSample Output 2\n\n7\n6\n6\n5\n4\n5\n5\n3\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4739, "cpu_time_ms": 1993, "memory_kb": 54584}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s399023159", "group_id": "codeNet:p03826", "input_text": "import scala.io.{ StdIn => in}\n\nobject Main extends App {\n val ans = in.readLine.split(\" \").map(_.toInt)\n .grouped(2)\n .map(e => e(0) * e(1))\n .max\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1547946402, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03826.html", "problem_id": "p03826", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03826/input.txt", "sample_output_relpath": "derived/input_output/data/p03826/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03826/Scala/s399023159.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s399023159", "user_id": "u217010036"}, "prompt_components": {"gold_output": "15\n", "input_to_evaluate": "import scala.io.{ StdIn => in}\n\nobject Main extends App {\n val ans = in.readLine.split(\" \").map(_.toInt)\n .grouped(2)\n .map(e => e(0) * e(1))\n .max\n println(ans)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are two rectangles.\nThe lengths of the vertical sides of the first rectangle are A, and the lengths of the horizontal sides of the first rectangle are B.\nThe lengths of the vertical sides of the second rectangle are C, and the lengths of the horizontal sides of the second rectangle are D.\n\nPrint the area of the rectangle with the larger area.\nIf the two rectangles have equal areas, print that area.\n\nConstraints\n\nAll input values are integers.\n\n1≤A≤10^4\n\n1≤B≤10^4\n\n1≤C≤10^4\n\n1≤D≤10^4\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B C D\n\nOutput\n\nPrint the area of the rectangle with the larger area.\nIf the two rectangles have equal areas, print that area.\n\nSample Input 1\n\n3 5 2 7\n\nSample Output 1\n\n15\n\nThe first rectangle has an area of 3×5=15, and the second rectangle has an area of 2×7=14.\nThus, the output should be 15, the larger area.\n\nSample Input 2\n\n100 600 200 300\n\nSample Output 2\n\n60000", "sample_input": "3 5 2 7\n"}, "reference_outputs": ["15\n"], "source_document_id": "p03826", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are two rectangles.\nThe lengths of the vertical sides of the first rectangle are A, and the lengths of the horizontal sides of the first rectangle are B.\nThe lengths of the vertical sides of the second rectangle are C, and the lengths of the horizontal sides of the second rectangle are D.\n\nPrint the area of the rectangle with the larger area.\nIf the two rectangles have equal areas, print that area.\n\nConstraints\n\nAll input values are integers.\n\n1≤A≤10^4\n\n1≤B≤10^4\n\n1≤C≤10^4\n\n1≤D≤10^4\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B C D\n\nOutput\n\nPrint the area of the rectangle with the larger area.\nIf the two rectangles have equal areas, print that area.\n\nSample Input 1\n\n3 5 2 7\n\nSample Output 1\n\n15\n\nThe first rectangle has an area of 3×5=15, and the second rectangle has an area of 2×7=14.\nThus, the output should be 15, the larger area.\n\nSample Input 2\n\n100 600 200 300\n\nSample Output 2\n\n60000", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 329, "memory_kb": 25544}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s644408718", "group_id": "codeNet:p03827", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val _, s = sc.next()\n val f = (c: Char) => if (c == 'I') 1 else -1\n println(s.scanLeft(0)(_ + f(_)).max)\n}\n", "language": "Scala", "metadata": {"date": 1593480283, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s644408718.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s644408718", "user_id": "u737111725"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val _, s = sc.next()\n val f = (c: Char) => if (c == 'I') 1 else -1\n println(s.scanLeft(0)(_ + f(_)).max)\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 514, "memory_kb": 55580}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s947151412", "group_id": "codeNet:p03828", "input_text": "import java.util.Scanner\n\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n val MOD = 1000000007\n def solve(N: Int): Long = {\n val f = {\n val f: ArrayBuffer[Int] = ArrayBuffer.empty\n for {\n i <- 1 to N\n } f ++= factorize(i)\n f.sorted\n }\n\n var res: Long = 1\n var i = 0\n while(i < f.length) {\n var j = i\n while (j < f.length && f(i) == f(j)) j += 1\n val len = j - i\n res = res * (len + 1) % MOD\n i = j\n }\n\n res\n }\n\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n println(solve(sc.nextInt()))\n }\n\n def factorize(n: Int): Array[Int] = {\n // 見つからなかったら-1\n def minFactor(n0: Int, i: Int): Int = {\n if (i > n0) -1\n else if (n0 % i == 0) i\n else minFactor(n0, i + 1)\n }\n\n def step(n0: Int, acc: List[Int]): List[Int] = {\n minFactor(n0, 2) match {\n case -1 => acc\n case f => step(n0 / f, f :: acc)\n }\n }\n\n step(n, Nil).toArray\n }\n}\n", "language": "Scala", "metadata": {"date": 1527114353, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s947151412.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s947151412", "user_id": "u460609472"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n val MOD = 1000000007\n def solve(N: Int): Long = {\n val f = {\n val f: ArrayBuffer[Int] = ArrayBuffer.empty\n for {\n i <- 1 to N\n } f ++= factorize(i)\n f.sorted\n }\n\n var res: Long = 1\n var i = 0\n while(i < f.length) {\n var j = i\n while (j < f.length && f(i) == f(j)) j += 1\n val len = j - i\n res = res * (len + 1) % MOD\n i = j\n }\n\n res\n }\n\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n println(solve(sc.nextInt()))\n }\n\n def factorize(n: Int): Array[Int] = {\n // 見つからなかったら-1\n def minFactor(n0: Int, i: Int): Int = {\n if (i > n0) -1\n else if (n0 % i == 0) i\n else minFactor(n0, i + 1)\n }\n\n def step(n0: Int, acc: List[Int]): List[Int] = {\n minFactor(n0, 2) match {\n case -1 => acc\n case f => step(n0 / f, f :: acc)\n }\n }\n\n step(n, Nil).toArray\n }\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1020, "cpu_time_ms": 378, "memory_kb": 25648}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s620811412", "group_id": "codeNet:p03830", "input_text": "import scala.io.StdIn._\n\n/**\n * Created by sonetsuyoshi on 2015/12/16.\n */\n\nobject Main extends App {\n val MOD = 1000000007\n\n val N = readInt\n\n def primesUnder(n: Int): List[Int] = {\n def rec(i: Int, primes: List[Int]): List[Int] = {\n if (i > n) primes\n else if (prime(i, primes)) rec(i + 1, i :: primes)\n else rec(i + 1, primes)\n }\n\n rec(2, List()).reverse\n }\n\n def prime(num: Int, factors: List[Int]): Boolean = factors.forall(num % _ != 0)\n\n val primes = primesUnder(N)\n\n val expos = primes.map(x => {\n 1.to(N).foldLeft(0.toLong)((s, n) => {\n var m = n\n var count = 0\n while(m % x == 0) {\n m /= x\n count += 1\n }\n (s + count).toLong\n })\n })\n println(expos.foldLeft(1.toLong)((s, n) => s * (n + 1) % MOD))\n}\n", "language": "Scala", "metadata": {"date": 1485062662, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03830.html", "problem_id": "p03830", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03830/input.txt", "sample_output_relpath": "derived/input_output/data/p03830/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03830/Scala/s620811412.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s620811412", "user_id": "u185193776"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import scala.io.StdIn._\n\n/**\n * Created by sonetsuyoshi on 2015/12/16.\n */\n\nobject Main extends App {\n val MOD = 1000000007\n\n val N = readInt\n\n def primesUnder(n: Int): List[Int] = {\n def rec(i: Int, primes: List[Int]): List[Int] = {\n if (i > n) primes\n else if (prime(i, primes)) rec(i + 1, i :: primes)\n else rec(i + 1, primes)\n }\n\n rec(2, List()).reverse\n }\n\n def prime(num: Int, factors: List[Int]): Boolean = factors.forall(num % _ != 0)\n\n val primes = primesUnder(N)\n\n val expos = primes.map(x => {\n 1.to(N).foldLeft(0.toLong)((s, n) => {\n var m = n\n var count = 0\n while(m % x == 0) {\n m /= x\n count += 1\n }\n (s + count).toLong\n })\n })\n println(expos.foldLeft(1.toLong)((s, n) => s * (n + 1) % MOD))\n}\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": "p03830", "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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 787, "cpu_time_ms": 508, "memory_kb": 24512}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s062613715", "group_id": "codeNet:p03834", "input_text": "import scala.math._\n\n// longでrangeの作り方\n\nobject Main extends App {\n\n val YES = \"YES\"\n val Yes = \"Yes\"\n val NO = \"NO\"\n val No = \"No\"\n ///////////////////////////////////////////\n\n val sc = new java.util.Scanner(System.in)\n val s = sc.next\n// val list = List.fill(3)(sc.next)\n\n val ans = s.replace(',', ' ')\n\n println(ans)\n\n\n ///////////////////////////////////////////\n\n def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =\n Iterator.iterate(start)(_ + step).takeWhile(_ <= end)\n\n def lcm(a :Int, b :Int): Int =\n a / gcd(a, b) * b\n\n def lcm(a :Long, b :Long): Long =\n a / gcd(a, b) * b\n\n def gcd(a: Int, b: Int): Int =\n if (b == 0) a else gcd(b, a % b)\n\n def gcd(a: Long, b: Long): Long =\n if (b == 0) a else gcd(b, a % b)\n\n def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =\n a.get(key) match {\n case Some(v) => a.updated(key, f(value, v))\n case _ => a + (key -> value)\n }\n}", "language": "Scala", "metadata": {"date": 1562690886, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03834.html", "problem_id": "p03834", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03834/input.txt", "sample_output_relpath": "derived/input_output/data/p03834/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03834/Scala/s062613715.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s062613715", "user_id": "u040380439"}, "prompt_components": {"gold_output": "happy newyear enjoy\n", "input_to_evaluate": "import scala.math._\n\n// longでrangeの作り方\n\nobject Main extends App {\n\n val YES = \"YES\"\n val Yes = \"Yes\"\n val NO = \"NO\"\n val No = \"No\"\n ///////////////////////////////////////////\n\n val sc = new java.util.Scanner(System.in)\n val s = sc.next\n// val list = List.fill(3)(sc.next)\n\n val ans = s.replace(',', ' ')\n\n println(ans)\n\n\n ///////////////////////////////////////////\n\n def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =\n Iterator.iterate(start)(_ + step).takeWhile(_ <= end)\n\n def lcm(a :Int, b :Int): Int =\n a / gcd(a, b) * b\n\n def lcm(a :Long, b :Long): Long =\n a / gcd(a, b) * b\n\n def gcd(a: Int, b: Int): Int =\n if (b == 0) a else gcd(b, a % b)\n\n def gcd(a: Long, b: Long): Long =\n if (b == 0) a else gcd(b, a % b)\n\n def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =\n a.get(key) match {\n case Some(v) => a.updated(key, f(value, v))\n case _ => a + (key -> value)\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAs a New Year's gift, Dolphin received a string s of length 19.\n\nThe string s has the following format: [five lowercase English letters],[seven lowercase English letters],[five lowercase English letters].\n\nDolphin wants to convert the comma-separated string s into a space-separated string.\n\nWrite a program to perform the conversion for him.\n\nConstraints\n\nThe length of s is 19.\n\nThe sixth and fourteenth characters in s are ,.\n\nThe other characters in s are lowercase English letters.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the string after the conversion.\n\nSample Input 1\n\nhappy,newyear,enjoy\n\nSample Output 1\n\nhappy newyear enjoy\n\nReplace all the commas in happy,newyear,enjoy with spaces to obtain happy newyear enjoy.\n\nSample Input 2\n\nhaiku,atcoder,tasks\n\nSample Output 2\n\nhaiku atcoder tasks\n\nSample Input 3\n\nabcde,fghihgf,edcba\n\nSample Output 3\n\nabcde fghihgf edcba", "sample_input": "happy,newyear,enjoy\n"}, "reference_outputs": ["happy newyear enjoy\n"], "source_document_id": "p03834", "source_text": "Score : 100 points\n\nProblem Statement\n\nAs a New Year's gift, Dolphin received a string s of length 19.\n\nThe string s has the following format: [five lowercase English letters],[seven lowercase English letters],[five lowercase English letters].\n\nDolphin wants to convert the comma-separated string s into a space-separated string.\n\nWrite a program to perform the conversion for him.\n\nConstraints\n\nThe length of s is 19.\n\nThe sixth and fourteenth characters in s are ,.\n\nThe other characters in s are lowercase English letters.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the string after the conversion.\n\nSample Input 1\n\nhappy,newyear,enjoy\n\nSample Output 1\n\nhappy newyear enjoy\n\nReplace all the commas in happy,newyear,enjoy with spaces to obtain happy newyear enjoy.\n\nSample Input 2\n\nhaiku,atcoder,tasks\n\nSample Output 2\n\nhaiku atcoder tasks\n\nSample Input 3\n\nabcde,fghihgf,edcba\n\nSample Output 3\n\nabcde fghihgf edcba", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 964, "cpu_time_ms": 336, "memory_kb": 25632}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s420849187", "group_id": "codeNet:p03844", "input_text": "import scala.math._\n\n// longでrangeの作り方\n\nobject Main extends App {\n\n val YES = \"YES\"\n val Yes = \"Yes\"\n val NO = \"NO\"\n val No = \"No\"\n ///////////////////////////////////////////\n\n val sc = new java.util.Scanner(System.in)\n val a, op, b = sc.next\n// val list = List.fill(3)(sc.next)\n\n val ans = if (op == \"+\") a.toInt + b.toInt else a.toInt - b.toInt\n\n println(ans)\n\n\n ///////////////////////////////////////////\n\n def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =\n Iterator.iterate(start)(_ + step).takeWhile(_ <= end)\n\n def lcm(a :Int, b :Int): Int =\n a / gcd(a, b) * b\n\n def lcm(a :Long, b :Long): Long =\n a / gcd(a, b) * b\n\n def gcd(a: Int, b: Int): Int =\n if (b == 0) a else gcd(b, a % b)\n\n def gcd(a: Long, b: Long): Long =\n if (b == 0) a else gcd(b, a % b)\n\n def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =\n a.get(key) match {\n case Some(v) => a.updated(key, f(value, v))\n case _ => a + (key -> value)\n }\n}", "language": "Scala", "metadata": {"date": 1562691028, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s420849187.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s420849187", "user_id": "u040380439"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.math._\n\n// longでrangeの作り方\n\nobject Main extends App {\n\n val YES = \"YES\"\n val Yes = \"Yes\"\n val NO = \"NO\"\n val No = \"No\"\n ///////////////////////////////////////////\n\n val sc = new java.util.Scanner(System.in)\n val a, op, b = sc.next\n// val list = List.fill(3)(sc.next)\n\n val ans = if (op == \"+\") a.toInt + b.toInt else a.toInt - b.toInt\n\n println(ans)\n\n\n ///////////////////////////////////////////\n\n def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =\n Iterator.iterate(start)(_ + step).takeWhile(_ <= end)\n\n def lcm(a :Int, b :Int): Int =\n a / gcd(a, b) * b\n\n def lcm(a :Long, b :Long): Long =\n a / gcd(a, b) * b\n\n def gcd(a: Int, b: Int): Int =\n if (b == 0) a else gcd(b, a % b)\n\n def gcd(a: Long, b: Long): Long =\n if (b == 0) a else gcd(b, a % b)\n\n def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =\n a.get(key) match {\n case Some(v) => a.updated(key, f(value, v))\n case _ => a + (key -> value)\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1007, "cpu_time_ms": 349, "memory_kb": 25400}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s326053434", "group_id": "codeNet:p03844", "input_text": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val a, op, b = sc.next()\n val ans = op match {\n case \"+\" => a.toInt + b.toInt\n case \"-\" => a.toInt - b.toInt\n }\n println(ans)\n }\n}\n", "language": "Scala", "metadata": {"date": 1515470338, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s326053434.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s326053434", "user_id": "u817142576"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val a, op, b = sc.next()\n val ans = op match {\n case \"+\" => a.toInt + b.toInt\n case \"-\" => a.toInt - b.toInt\n }\n println(ans)\n }\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 353, "memory_kb": 25644}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s462983532", "group_id": "codeNet:p03844", "input_text": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val a = sc.nextLong()\n val op = sc.next()\n val b = sc.nextLong()\n val out = op match {\n case \"+\" => a + b\n case \"-\" => a - b\n }\n println(out)\n }\n}", "language": "Scala", "metadata": {"date": 1486056070, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s462983532.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s462983532", "user_id": "u254527418"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val a = sc.nextLong()\n val op = sc.next()\n val b = sc.nextLong()\n val out = op match {\n case \"+\" => a + b\n case \"-\" => a - b\n }\n println(out)\n }\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 279, "cpu_time_ms": 436, "memory_kb": 22340}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s788995659", "group_id": "codeNet:p03848", "input_text": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\nimport java.lang\n\nimport scala.annotation.tailrec\nimport scala.collection.mutable.ArrayBuffer\nimport scala.reflect.ClassTag\n\nobject Main {\n def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {\n converter(in.readLine)\n }\n\n def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {\n get[String].split(\"\\\\s+\").map[T](converter)\n }\n\n implicit val idConverter: String => String = s => s\n implicit val intConverter: String => Int = s => Integer.parseInt(s)\n implicit val longConverter: String => Long = s => lang.Long.parseLong(s)\n\n def get[T1, T2](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2\n ): (T1, T2) = {\n getArray[String] match {\n case Array(v1, v2) => (converter1(v1), converter2(v2))\n }\n }\n\n def get[T1, T2, T3](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3\n ): (T1, T2, T3) = {\n getArray[String] match {\n case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))\n }\n }\n\n def get[T1, T2, T3, T4](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3,\n converter4: String => T4\n ): (T1, T2, T3, T4) = {\n getArray[String] match {\n case Array(v1, v2, v3, v4) => (converter1(v1), converter2(v2), converter3(v3), converter4(v4))\n }\n }\n\n implicit class TimesInt(val n: Int) {\n def times(f: Int => Unit): Unit = {\n for (i <- 0 until n) {\n f(i)\n }\n }\n }\n\n def primes(n: Long): ArrayBuffer[Long] = {\n val buf = ArrayBuffer.empty[Long]\n val s = Math.sqrt(n).toInt\n\n var v = n\n for (i <- 2 to s) {\n if (v == 1 || v == 0) {\n return buf\n } else {\n while (v % i == 0) {\n buf.append(i)\n v /= i\n }\n }\n }\n if (v > s) {\n buf.append(v)\n }\n buf\n }\n\n def divisors(n: Int): ArrayBuffer[Int] = {\n val buf = ArrayBuffer.empty[Int]\n val s = Math.sqrt(n).toInt\n\n for (i <- 1 to s) {\n if (n % i == 0) {\n buf.append(i)\n if (i != n / i) {\n buf.append(n / i)\n }\n }\n }\n buf\n }\n\n @tailrec\n def gcd(a: Long, b: Long): Long = {\n val reminder = a % b\n if (reminder == 0) {\n b\n } else {\n gcd(b, reminder)\n }\n }\n\n def lcm(a: Long, b: Long): Long = {\n a / gcd(a, b) * b\n }\n\n def toBitArray(n: Int, width: Int): Array[Boolean] = {\n val buf = ArrayBuffer.fill(width)(false)\n\n @tailrec\n def inner(n: Int, i: Int): Array[Boolean] = {\n buf(i) = (n & 1) == 0\n if (i == 0) {\n buf.toArray\n } else {\n inner(n / 2, i - 1)\n }\n }\n\n inner(n, width - 1)\n }\n\n def modpow(n: Long, p: Long, m: Long): Long = {\n @tailrec\n def inner(n: Long, p: Long, acc: Long): Long = {\n if (p == 0) {\n acc\n } else if ((p & 1) == 0) {\n inner(n * n % m, p >> 1, acc)\n } else {\n inner(n * n % m, p >> 1, acc * n % m)\n }\n }\n\n inner(n % m, p, 1)\n }\n\n def main(args: Array[String]): Unit = {\n implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n val n = get[Int]\n val as = getArray[Int].sorted\n\n val MOD = 1000000007\n\n def lazyloop(k: Int): LazyList[Int] = k #:: k #:: lazyloop(k + 2)\n\n out.println(\n if (\n as.zip(n % 2 match {\n case 0 => lazyloop(1)\n case 1 => 0 #:: lazyloop(2)\n }).forall {\n case (a, b) => a == b\n }) {\n modpow(2, n / 2, MOD)\n } else {\n 0\n }\n )\n\n out.flush()\n }\n}", "language": "Scala", "metadata": {"date": 1593299238, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03848.html", "problem_id": "p03848", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03848/input.txt", "sample_output_relpath": "derived/input_output/data/p03848/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03848/Scala/s788995659.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s788995659", "user_id": "u178269371"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\nimport java.lang\n\nimport scala.annotation.tailrec\nimport scala.collection.mutable.ArrayBuffer\nimport scala.reflect.ClassTag\n\nobject Main {\n def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {\n converter(in.readLine)\n }\n\n def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {\n get[String].split(\"\\\\s+\").map[T](converter)\n }\n\n implicit val idConverter: String => String = s => s\n implicit val intConverter: String => Int = s => Integer.parseInt(s)\n implicit val longConverter: String => Long = s => lang.Long.parseLong(s)\n\n def get[T1, T2](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2\n ): (T1, T2) = {\n getArray[String] match {\n case Array(v1, v2) => (converter1(v1), converter2(v2))\n }\n }\n\n def get[T1, T2, T3](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3\n ): (T1, T2, T3) = {\n getArray[String] match {\n case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))\n }\n }\n\n def get[T1, T2, T3, T4](\n implicit in: BufferedReader,\n converter1: String => T1,\n converter2: String => T2,\n converter3: String => T3,\n converter4: String => T4\n ): (T1, T2, T3, T4) = {\n getArray[String] match {\n case Array(v1, v2, v3, v4) => (converter1(v1), converter2(v2), converter3(v3), converter4(v4))\n }\n }\n\n implicit class TimesInt(val n: Int) {\n def times(f: Int => Unit): Unit = {\n for (i <- 0 until n) {\n f(i)\n }\n }\n }\n\n def primes(n: Long): ArrayBuffer[Long] = {\n val buf = ArrayBuffer.empty[Long]\n val s = Math.sqrt(n).toInt\n\n var v = n\n for (i <- 2 to s) {\n if (v == 1 || v == 0) {\n return buf\n } else {\n while (v % i == 0) {\n buf.append(i)\n v /= i\n }\n }\n }\n if (v > s) {\n buf.append(v)\n }\n buf\n }\n\n def divisors(n: Int): ArrayBuffer[Int] = {\n val buf = ArrayBuffer.empty[Int]\n val s = Math.sqrt(n).toInt\n\n for (i <- 1 to s) {\n if (n % i == 0) {\n buf.append(i)\n if (i != n / i) {\n buf.append(n / i)\n }\n }\n }\n buf\n }\n\n @tailrec\n def gcd(a: Long, b: Long): Long = {\n val reminder = a % b\n if (reminder == 0) {\n b\n } else {\n gcd(b, reminder)\n }\n }\n\n def lcm(a: Long, b: Long): Long = {\n a / gcd(a, b) * b\n }\n\n def toBitArray(n: Int, width: Int): Array[Boolean] = {\n val buf = ArrayBuffer.fill(width)(false)\n\n @tailrec\n def inner(n: Int, i: Int): Array[Boolean] = {\n buf(i) = (n & 1) == 0\n if (i == 0) {\n buf.toArray\n } else {\n inner(n / 2, i - 1)\n }\n }\n\n inner(n, width - 1)\n }\n\n def modpow(n: Long, p: Long, m: Long): Long = {\n @tailrec\n def inner(n: Long, p: Long, acc: Long): Long = {\n if (p == 0) {\n acc\n } else if ((p & 1) == 0) {\n inner(n * n % m, p >> 1, acc)\n } else {\n inner(n * n % m, p >> 1, acc * n % m)\n }\n }\n\n inner(n % m, p, 1)\n }\n\n def main(args: Array[String]): Unit = {\n implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))\n val out = new PrintWriter(new BufferedOutputStream(System.out))\n val n = get[Int]\n val as = getArray[Int].sorted\n\n val MOD = 1000000007\n\n def lazyloop(k: Int): LazyList[Int] = k #:: k #:: lazyloop(k + 2)\n\n out.println(\n if (\n as.zip(n % 2 match {\n case 0 => lazyloop(1)\n case 1 => 0 #:: lazyloop(2)\n }).forall {\n case (a, b) => a == b\n }) {\n modpow(2, n / 2, MOD)\n } else {\n 0\n }\n )\n\n out.flush()\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": "p03848", "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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4128, "cpu_time_ms": 848, "memory_kb": 75220}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s301761327", "group_id": "codeNet:p03848", "input_text": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val N = sc.nextInt()\n val A = Array.fill(N)(sc.nextInt())\n\n def solve(N: Int, A: Array[Int]): Int = {\n val MAX = N - 1\n val C = new Array[Int](N)\n (0 to MAX) foreach { n =>\n C(((MAX - n) - n).abs) += 1\n }\n\n val INF = Math.pow(10, 9).toInt + 7\n def ans(n: Int, acm: Int): Int =\n if (n < N / 2) ans(n + 1, acm << 1 % INF)\n else acm\n\n def find(i: Int): Int =\n if (i < N) {\n if (C(A(i)) > 0) {\n C(A(i)) -= 1\n find(i + 1)\n } else 0\n } else ans(0, 1)\n\n find(0)\n }\n\n println(solve(N, A))\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1576877526, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03848.html", "problem_id": "p03848", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03848/input.txt", "sample_output_relpath": "derived/input_output/data/p03848/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03848/Scala/s301761327.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s301761327", "user_id": "u891387249"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val N = sc.nextInt()\n val A = Array.fill(N)(sc.nextInt())\n\n def solve(N: Int, A: Array[Int]): Int = {\n val MAX = N - 1\n val C = new Array[Int](N)\n (0 to MAX) foreach { n =>\n C(((MAX - n) - n).abs) += 1\n }\n\n val INF = Math.pow(10, 9).toInt + 7\n def ans(n: Int, acm: Int): Int =\n if (n < N / 2) ans(n + 1, acm << 1 % INF)\n else acm\n\n def find(i: Int): Int =\n if (i < N) {\n if (C(A(i)) > 0) {\n C(A(i)) -= 1\n find(i + 1)\n } else 0\n } else ans(0, 1)\n\n find(0)\n }\n\n println(solve(N, A))\n }\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": "p03848", "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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 723, "cpu_time_ms": 690, "memory_kb": 51724}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s805411193", "group_id": "codeNet:p03852", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val c = sc.nextLine()\n\n val vs = Set(\"a\", \"i\", \"u\", \"e\", \"o\")\n\n println(if (vs.contains(c)) \"vowel\" else \"consonant\")\n}\n", "language": "Scala", "metadata": {"date": 1588849349, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s805411193.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s805411193", "user_id": "u786167609"}, "prompt_components": {"gold_output": "vowel\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val c = sc.nextLine()\n\n val vs = Set(\"a\", \"i\", \"u\", \"e\", \"o\")\n\n println(if (vs.contains(c)) \"vowel\" else \"consonant\")\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 349, "memory_kb": 25540}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s281363210", "group_id": "codeNet:p03853", "input_text": "import scala.annotation.tailrec\nimport scala.math._\n\nobject Main extends App {\n\n val YES = \"YES\"\n val Yes = \"Yes\"\n val NO = \"NO\"\n val No = \"No\"\n\n val input: Array[Array[Int]] = Array.ofDim(6, 6000000)\n ///////////////////////////////////////////\n\n val sc = new java.util.Scanner(System.in)\n// val a, b, k = sc.nextInt\n val h, w = sc.nextInt\n println(h, w)\n// val d = List.fill(7)(sc.nextInt)\n// val j = List.fill(7)(sc.nextInt)\n val list = List.fill(h)(sc.next)\n\n\n list.foreach(l => {\n l.foreach(print(_))\n println(\"\")\n l.foreach(print(_))\n println(\"\")\n }\n )\n\n ///////////////////////////////////////////\n\n def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =\n Iterator.iterate(start)(_ + step).takeWhile(_ <= end)\n\n def lcm(a :Int, b :Int): Int =\n a / gcd(a, b) * b\n\n def lcm(a :Long, b :Long): Long =\n a / gcd(a, b) * b\n\n def gcd(a: Int, b: Int): Int =\n if (b == 0) a else gcd(b, a % b)\n\n def gcd(a: Long, b: Long): Long =\n if (b == 0) a else gcd(b, a % b)\n\n def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =\n a.get(key) match {\n case Some(v) => a.updated(key, f(value, v))\n case _ => a + (key -> value)\n }\n\n // https://stackoverflow.com/questions/10199171/matcherror-when-match-receives-an-indexedseq-but-not-a-linearseq/10199441#10199441\n object +: {\n def unapply[T](s: Seq[T]) =\n s.headOption.map(head => (head, s.tail))\n }\n\n @tailrec\n def foldLeftWithNext[A, B](seq: Seq[A])(z: B)(op: (B, A, A) => B)(tailOp: (B, A) => B): B = {\n seq match {\n case Nil => z\n case a +: Nil => tailOp(z, a)\n case a +: next +: tail => foldLeftWithNext(next +: tail)(op(z, a, next))(op)(tailOp)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1582766058, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03853.html", "problem_id": "p03853", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03853/input.txt", "sample_output_relpath": "derived/input_output/data/p03853/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03853/Scala/s281363210.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s281363210", "user_id": "u040380439"}, "prompt_components": {"gold_output": "*.\n*.\n.*\n.*\n", "input_to_evaluate": "import scala.annotation.tailrec\nimport scala.math._\n\nobject Main extends App {\n\n val YES = \"YES\"\n val Yes = \"Yes\"\n val NO = \"NO\"\n val No = \"No\"\n\n val input: Array[Array[Int]] = Array.ofDim(6, 6000000)\n ///////////////////////////////////////////\n\n val sc = new java.util.Scanner(System.in)\n// val a, b, k = sc.nextInt\n val h, w = sc.nextInt\n println(h, w)\n// val d = List.fill(7)(sc.nextInt)\n// val j = List.fill(7)(sc.nextInt)\n val list = List.fill(h)(sc.next)\n\n\n list.foreach(l => {\n l.foreach(print(_))\n println(\"\")\n l.foreach(print(_))\n println(\"\")\n }\n )\n\n ///////////////////////////////////////////\n\n def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =\n Iterator.iterate(start)(_ + step).takeWhile(_ <= end)\n\n def lcm(a :Int, b :Int): Int =\n a / gcd(a, b) * b\n\n def lcm(a :Long, b :Long): Long =\n a / gcd(a, b) * b\n\n def gcd(a: Int, b: Int): Int =\n if (b == 0) a else gcd(b, a % b)\n\n def gcd(a: Long, b: Long): Long =\n if (b == 0) a else gcd(b, a % b)\n\n def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =\n a.get(key) match {\n case Some(v) => a.updated(key, f(value, v))\n case _ => a + (key -> value)\n }\n\n // https://stackoverflow.com/questions/10199171/matcherror-when-match-receives-an-indexedseq-but-not-a-linearseq/10199441#10199441\n object +: {\n def unapply[T](s: Seq[T]) =\n s.headOption.map(head => (head, s.tail))\n }\n\n @tailrec\n def foldLeftWithNext[A, B](seq: Seq[A])(z: B)(op: (B, A, A) => B)(tailOp: (B, A) => B): B = {\n seq match {\n case Nil => z\n case a +: Nil => tailOp(z, a)\n case a +: next +: tail => foldLeftWithNext(next +: tail)(op(z, a, next))(op)(tailOp)\n }\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either . or *. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}.\n\nExtend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).\n\nConstraints\n\n1≦H, W≦100\n\nC_{i,j} is either . or *.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nH W\nC_{1,1}...C_{1,W}\n:\nC_{H,1}...C_{H,W}\n\nOutput\n\nPrint the extended image.\n\nSample Input 1\n\n2 2\n*.\n.*\n\nSample Output 1\n\n*.\n*.\n.*\n.*\n\nSample Input 2\n\n1 4\n***.\n\nSample Output 2\n\n***.\n***.\n\nSample Input 3\n\n9 20\n.....***....***.....\n....*...*..*...*....\n...*.....**.....*...\n...*.....*......*...\n....*.....*....*....\n.....**..*...**.....\n.......*..*.*.......\n........**.*........\n.........**.........\n\nSample Output 3\n\n.....***....***.....\n.....***....***.....\n....*...*..*...*....\n....*...*..*...*....\n...*.....**.....*...\n...*.....**.....*...\n...*.....*......*...\n...*.....*......*...\n....*.....*....*....\n....*.....*....*....\n.....**..*...**.....\n.....**..*...**.....\n.......*..*.*.......\n.......*..*.*.......\n........**.*........\n........**.*........\n.........**.........\n.........**.........", "sample_input": "2 2\n*.\n.*\n"}, "reference_outputs": ["*.\n*.\n.*\n.*\n"], "source_document_id": "p03853", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either . or *. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}.\n\nExtend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).\n\nConstraints\n\n1≦H, W≦100\n\nC_{i,j} is either . or *.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nH W\nC_{1,1}...C_{1,W}\n:\nC_{H,1}...C_{H,W}\n\nOutput\n\nPrint the extended image.\n\nSample Input 1\n\n2 2\n*.\n.*\n\nSample Output 1\n\n*.\n*.\n.*\n.*\n\nSample Input 2\n\n1 4\n***.\n\nSample Output 2\n\n***.\n***.\n\nSample Input 3\n\n9 20\n.....***....***.....\n....*...*..*...*....\n...*.....**.....*...\n...*.....*......*...\n....*.....*....*....\n.....**..*...**.....\n.......*..*.*.......\n........**.*........\n.........**.........\n\nSample Output 3\n\n.....***....***.....\n.....***....***.....\n....*...*..*...*....\n....*...*..*...*....\n...*.....**.....*...\n...*.....**.....*...\n...*.....*......*...\n...*.....*......*...\n....*.....*....*....\n....*.....*....*....\n.....**..*...**.....\n.....**..*...**.....\n.......*..*.*.......\n.......*..*.*.......\n........**.*........\n........**.*........\n.........**.........\n.........**.........", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 741, "memory_kb": 175780}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s321895279", "group_id": "codeNet:p03860", "input_text": "object Main extends App {\n import scala.io.StdIn.readLine\n\n val line = io.StdIn.readLine\n val c = line.split(' ')(1)(0)\n println(c)\n}\n", "language": "Scala", "metadata": {"date": 1571875009, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s321895279.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s321895279", "user_id": "u950621657"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "object Main extends App {\n import scala.io.StdIn.readLine\n\n val line = io.StdIn.readLine\n val c = line.split(' ')(1)(0)\n println(c)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 138, "cpu_time_ms": 321, "memory_kb": 25408}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s896792732", "group_id": "codeNet:p03861", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val a, b, x = sc.nextLong()\n if (a == 0) {\n println(b/x + 1)\n } else {\n println(b/x - (a-1)/x)\n }\n}\n", "language": "Scala", "metadata": {"date": 1594580881, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/Scala/s896792732.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s896792732", "user_id": "u191819389"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val a, b, x = sc.nextLong()\n if (a == 0) {\n println(b/x + 1)\n } else {\n println(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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 499, "memory_kb": 55236}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s625286300", "group_id": "codeNet:p03861", "input_text": "object Main extends App{\n // Here your code !\n val scanner = new java.util.Scanner(System.in)\n val a,b,x = scanner.nextInt\n println(((b-a)/x).toInt + 1)\n}", "language": "Scala", "metadata": {"date": 1481209910, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s625286300.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s625286300", "user_id": "u010863732"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main extends App{\n // Here your code !\n val scanner = new java.util.Scanner(System.in)\n val a,b,x = scanner.nextInt\n println(((b-a)/x).toInt + 1)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 168, "cpu_time_ms": 455, "memory_kb": 22300}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s348714434", "group_id": "codeNet:p03912", "input_text": "object Main{\n\tdef main(args:Array[String]){\n\t\tval s = new java.util.Scanner(System.in)\n\t\tval n,m = s.nextInt\n\t\tval c = Array.fill(100001)(0)\n\t\tfor(_ <- 1 to n)\n\t\t\tc(s.nextInt) += 1\n\t\tval a,b = Array.fill(m)(0)\n\t\tfor(i <- 1 to 100000) {\n\t\t\ta(i % m) += c(i) % 2\n\t\t\tb(i % m) += c(i) / 2\n\t\t}\n\t\t//println(a.mkString(\" \"))\n\t\t//println(b.mkString(\" \"))\n\t\tvar r = 0\n\t\tfor(i <- 0 until m) {\n\t\t\tif(i * 2 % m == 0) {\n\t\t\t\tr += a(i) / 2\n\t\t\t\ta(i) %= 2\n\t\t\t} else {\n\t\t\t\t{\n\t\t\t\t\tval t = math.min(a(i),a(m - i))\n\t\t\t\t\tr += t\n\t\t\t\t\ta(i) -= t\n\t\t\t\t\ta(m - i) -= t\n\t\t\t\t}\n\t\t\t\t{\n\t\t\t\t\tval t = math.min(a(i) / 2,b(m - i))\n\t\t\t\t\tr += t * 2\n\t\t\t\t\ta(i) -= t * 2\n\t\t\t\t\tb(m - i) -= t\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(i <- 0 until m) {\n\t\t\tr += b(i)\n\t\t\tb(i) = 0\n\t\t}\n\t\t//println(a.mkString(\" \"))\n\t\t//println(b.mkString(\" \"))\n\t\tprintln(r)\n\t}\n}", "language": "Scala", "metadata": {"date": 1558309087, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03912.html", "problem_id": "p03912", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03912/input.txt", "sample_output_relpath": "derived/input_output/data/p03912/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03912/Scala/s348714434.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s348714434", "user_id": "u374791437"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main{\n\tdef main(args:Array[String]){\n\t\tval s = new java.util.Scanner(System.in)\n\t\tval n,m = s.nextInt\n\t\tval c = Array.fill(100001)(0)\n\t\tfor(_ <- 1 to n)\n\t\t\tc(s.nextInt) += 1\n\t\tval a,b = Array.fill(m)(0)\n\t\tfor(i <- 1 to 100000) {\n\t\t\ta(i % m) += c(i) % 2\n\t\t\tb(i % m) += c(i) / 2\n\t\t}\n\t\t//println(a.mkString(\" \"))\n\t\t//println(b.mkString(\" \"))\n\t\tvar r = 0\n\t\tfor(i <- 0 until m) {\n\t\t\tif(i * 2 % m == 0) {\n\t\t\t\tr += a(i) / 2\n\t\t\t\ta(i) %= 2\n\t\t\t} else {\n\t\t\t\t{\n\t\t\t\t\tval t = math.min(a(i),a(m - i))\n\t\t\t\t\tr += t\n\t\t\t\t\ta(i) -= t\n\t\t\t\t\ta(m - i) -= t\n\t\t\t\t}\n\t\t\t\t{\n\t\t\t\t\tval t = math.min(a(i) / 2,b(m - i))\n\t\t\t\t\tr += t * 2\n\t\t\t\t\ta(i) -= t * 2\n\t\t\t\t\tb(m - i) -= t\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(i <- 0 until m) {\n\t\t\tr += b(i)\n\t\t\tb(i) = 0\n\t\t}\n\t\t//println(a.mkString(\" \"))\n\t\t//println(b.mkString(\" \"))\n\t\tprintln(r)\n\t}\n}", "problem_context": "Score : 700 points\n\nProblem Statement\n\nTakahashi is playing with N cards.\n\nThe i-th card has an integer X_i on it.\n\nTakahashi is trying to create as many pairs of cards as possible satisfying one of the following conditions:\n\nThe integers on the two cards are the same.\n\nThe sum of the integers on the two cards is a multiple of M.\n\nFind the maximum number of pairs that can be created.\n\nNote that a card cannot be used in more than one pair.\n\nConstraints\n\n2≦N≦10^5\n\n1≦M≦10^5\n\n1≦X_i≦10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nX_1 X_2 ... X_N\n\nOutput\n\nPrint the maximum number of pairs that can be created.\n\nSample Input 1\n\n7 5\n3 1 4 1 5 9 2\n\nSample Output 1\n\n3\n\nThree pairs (3,2), (1,4) and (1,9) can be created.\n\nIt is possible to create pairs (3,2) and (1,1), but the number of pairs is not maximized with this.\n\nSample Input 2\n\n15 10\n1 5 6 10 11 11 11 20 21 25 25 26 99 99 99\n\nSample Output 2\n\n6", "sample_input": "7 5\n3 1 4 1 5 9 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03912", "source_text": "Score : 700 points\n\nProblem Statement\n\nTakahashi is playing with N cards.\n\nThe i-th card has an integer X_i on it.\n\nTakahashi is trying to create as many pairs of cards as possible satisfying one of the following conditions:\n\nThe integers on the two cards are the same.\n\nThe sum of the integers on the two cards is a multiple of M.\n\nFind the maximum number of pairs that can be created.\n\nNote that a card cannot be used in more than one pair.\n\nConstraints\n\n2≦N≦10^5\n\n1≦M≦10^5\n\n1≦X_i≦10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nX_1 X_2 ... X_N\n\nOutput\n\nPrint the maximum number of pairs that can be created.\n\nSample Input 1\n\n7 5\n3 1 4 1 5 9 2\n\nSample Output 1\n\n3\n\nThree pairs (3,2), (1,4) and (1,9) can be created.\n\nIt is possible to create pairs (3,2) and (1,1), but the number of pairs is not maximized with this.\n\nSample Input 2\n\n15 10\n1 5 6 10 11 11 11 20 21 25 25 26 99 99 99\n\nSample Output 2\n\n6", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 789, "cpu_time_ms": 739, "memory_kb": 51988}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s731731263", "group_id": "codeNet:p03948", "input_text": "import io.StdIn.readLine\n\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n val Array(n, t) = readLine().split(' ').map(_.toInt)\n val a = readLine().split(' ').map(_.toInt)\n\n val rew = (1 to (n - 1)).groupBy(i => a.slice(i, n).max - a(i - 1))\n println(rew(rew.keys.max).length)\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1478485340, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03948.html", "problem_id": "p03948", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03948/input.txt", "sample_output_relpath": "derived/input_output/data/p03948/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03948/Scala/s731731263.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s731731263", "user_id": "u382513779"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import io.StdIn.readLine\n\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n val Array(n, t) = readLine().split(' ').map(_.toInt)\n val a = readLine().split(' ').map(_.toInt)\n\n val rew = (1 to (n - 1)).groupBy(i => a.slice(i, n).max - a(i - 1))\n println(rew(rew.keys.max).length)\n }\n\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N towns located in a line, conveniently numbered 1 through N. Takahashi the merchant is going on a travel from town 1 to town N, buying and selling apples.\n\nTakahashi will begin the travel at town 1, with no apple in his possession. The actions that can be performed during the travel are as follows:\n\nMove: When at town i (i < N), move to town i + 1.\n\nMerchandise: Buy or sell an arbitrary number of apples at the current town. Here, it is assumed that one apple can always be bought and sold for A_i yen (the currency of Japan) at town i (1 ≦ i ≦ N), where A_i are distinct integers. Also, you can assume that he has an infinite supply of money.\n\nFor some reason, there is a constraint on merchandising apple during the travel: the sum of the number of apples bought and the number of apples sold during the whole travel, must be at most T. (Note that a single apple can be counted in both.)\n\nDuring the travel, Takahashi will perform actions so that the profit of the travel is maximized. Here, the profit of the travel is the amount of money that is gained by selling apples, minus the amount of money that is spent on buying apples. Note that we are not interested in apples in his possession at the end of the travel.\n\nAoki, a business rival of Takahashi, wants to trouble Takahashi by manipulating the market price of apples. Prior to the beginning of Takahashi's travel, Aoki can change A_i into another arbitrary non-negative integer A_i' for any town i, any number of times. The cost of performing this operation is |A_i - A_i'|. After performing this operation, different towns may have equal values of A_i.\n\nAoki's objective is to decrease Takahashi's expected profit by at least 1 yen. Find the minimum total cost to achieve it. You may assume that Takahashi's expected profit is initially at least 1 yen.\n\nConstraints\n\n1 ≦ N ≦ 10^5\n\n1 ≦ A_i ≦ 10^9 (1 ≦ i ≦ N)\n\nA_i are distinct.\n\n2 ≦ T ≦ 10^9\n\nIn the initial state, Takahashi's expected profit is at least 1 yen.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN T\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum total cost to decrease Takahashi's expected profit by at least 1 yen.\n\nSample Input 1\n\n3 2\n100 50 200\n\nSample Output 1\n\n1\n\nIn the initial state, Takahashi can achieve the maximum profit of 150 yen as follows:\n\nMove from town 1 to town 2.\n\nBuy one apple for 50 yen at town 2.\n\nMove from town 2 to town 3.\n\nSell one apple for 200 yen at town 3.\n\nIf, for example, Aoki changes the price of an apple at town 2 from 50 yen to 51 yen, Takahashi will not be able to achieve the profit of 150 yen. The cost of performing this operation is 1, thus the answer is 1.\n\nThere are other ways to decrease Takahashi's expected profit, such as changing the price of an apple at town 3 from 200 yen to 199 yen.\n\nSample Input 2\n\n5 8\n50 30 40 10 20\n\nSample Output 2\n\n2\n\nSample Input 3\n\n10 100\n7 10 4 5 9 3 6 8 2 1\n\nSample Output 3\n\n2", "sample_input": "3 2\n100 50 200\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03948", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N towns located in a line, conveniently numbered 1 through N. Takahashi the merchant is going on a travel from town 1 to town N, buying and selling apples.\n\nTakahashi will begin the travel at town 1, with no apple in his possession. The actions that can be performed during the travel are as follows:\n\nMove: When at town i (i < N), move to town i + 1.\n\nMerchandise: Buy or sell an arbitrary number of apples at the current town. Here, it is assumed that one apple can always be bought and sold for A_i yen (the currency of Japan) at town i (1 ≦ i ≦ N), where A_i are distinct integers. Also, you can assume that he has an infinite supply of money.\n\nFor some reason, there is a constraint on merchandising apple during the travel: the sum of the number of apples bought and the number of apples sold during the whole travel, must be at most T. (Note that a single apple can be counted in both.)\n\nDuring the travel, Takahashi will perform actions so that the profit of the travel is maximized. Here, the profit of the travel is the amount of money that is gained by selling apples, minus the amount of money that is spent on buying apples. Note that we are not interested in apples in his possession at the end of the travel.\n\nAoki, a business rival of Takahashi, wants to trouble Takahashi by manipulating the market price of apples. Prior to the beginning of Takahashi's travel, Aoki can change A_i into another arbitrary non-negative integer A_i' for any town i, any number of times. The cost of performing this operation is |A_i - A_i'|. After performing this operation, different towns may have equal values of A_i.\n\nAoki's objective is to decrease Takahashi's expected profit by at least 1 yen. Find the minimum total cost to achieve it. You may assume that Takahashi's expected profit is initially at least 1 yen.\n\nConstraints\n\n1 ≦ N ≦ 10^5\n\n1 ≦ A_i ≦ 10^9 (1 ≦ i ≦ N)\n\nA_i are distinct.\n\n2 ≦ T ≦ 10^9\n\nIn the initial state, Takahashi's expected profit is at least 1 yen.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN T\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum total cost to decrease Takahashi's expected profit by at least 1 yen.\n\nSample Input 1\n\n3 2\n100 50 200\n\nSample Output 1\n\n1\n\nIn the initial state, Takahashi can achieve the maximum profit of 150 yen as follows:\n\nMove from town 1 to town 2.\n\nBuy one apple for 50 yen at town 2.\n\nMove from town 2 to town 3.\n\nSell one apple for 200 yen at town 3.\n\nIf, for example, Aoki changes the price of an apple at town 2 from 50 yen to 51 yen, Takahashi will not be able to achieve the profit of 150 yen. The cost of performing this operation is 1, thus the answer is 1.\n\nThere are other ways to decrease Takahashi's expected profit, such as changing the price of an apple at town 3 from 200 yen to 199 yen.\n\nSample Input 2\n\n5 8\n50 30 40 10 20\n\nSample Output 2\n\n2\n\nSample Input 3\n\n10 100\n7 10 4 5 9 3 6 8 2 1\n\nSample Output 3\n\n2", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2107, "memory_kb": 114020}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s342357234", "group_id": "codeNet:p03951", "input_text": "\nimport java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val n = sc.nextInt\n val s, t = sc.next\n val ans = (0 until n)\n .map(i => (i, s.substring(i), t.substring(0, n - i)))\n .find(t => t._2 == t._3)\n .map(n + _._1)\n .getOrElse(2 * n)\n println(ans)\n}\n", "language": "Scala", "metadata": {"date": 1553272368, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03951.html", "problem_id": "p03951", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03951/input.txt", "sample_output_relpath": "derived/input_output/data/p03951/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03951/Scala/s342357234.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s342357234", "user_id": "u726872801"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "\nimport java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val n = sc.nextInt\n val s, t = sc.next\n val ans = (0 until n)\n .map(i => (i, s.substring(i), t.substring(0, n - i)))\n .find(t => t._2 == t._3)\n .map(n + _._1)\n .getOrElse(2 * n)\n println(ans)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSnuke is interested in strings that satisfy the following conditions:\n\nThe length of the string is at least N.\n\nThe first N characters equal to the string s.\n\nThe last N characters equal to the string t.\n\nFind the length of the shortest string that satisfies the conditions.\n\nConstraints\n\n1≤N≤100\n\nThe lengths of s and t are both N.\n\ns and t consist of lowercase English letters.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\ns\nt\n\nOutput\n\nPrint the length of the shortest string that satisfies the conditions.\n\nSample Input 1\n\n3\nabc\ncde\n\nSample Output 1\n\n5\n\nThe shortest string is abcde.\n\nSample Input 2\n\n1\na\nz\n\nSample Output 2\n\n2\n\nThe shortest string is az.\n\nSample Input 3\n\n4\nexpr\nexpr\n\nSample Output 3\n\n4\n\nThe shortest string is expr.", "sample_input": "3\nabc\ncde\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03951", "source_text": "Score : 200 points\n\nProblem Statement\n\nSnuke is interested in strings that satisfy the following conditions:\n\nThe length of the string is at least N.\n\nThe first N characters equal to the string s.\n\nThe last N characters equal to the string t.\n\nFind the length of the shortest string that satisfies the conditions.\n\nConstraints\n\n1≤N≤100\n\nThe lengths of s and t are both N.\n\ns and t consist of lowercase English letters.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\ns\nt\n\nOutput\n\nPrint the length of the shortest string that satisfies the conditions.\n\nSample Input 1\n\n3\nabc\ncde\n\nSample Output 1\n\n5\n\nThe shortest string is abcde.\n\nSample Input 2\n\n1\na\nz\n\nSample Output 2\n\n2\n\nThe shortest string is az.\n\nSample Input 3\n\n4\nexpr\nexpr\n\nSample Output 3\n\n4\n\nThe shortest string is expr.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 345, "memory_kb": 25548}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s656355740", "group_id": "codeNet:p03959", "input_text": "object Main extends App {\n import scala.io.StdIn._\n\n val n = readInt\n val t = readLine.trim.split(' ').map(_.toInt)\n val a = readLine.trim.split(' ').map(_.toInt)\n var isParadoxical = false\n val confirmed = Array.tabulate(n){_ ⇒ -1}\n confirmed(0) = t.head\n confirmed(n - 1) = a.last\n for (i ← t.indices.tail){\n if (t(i) != t(i - 1)){\n if (confirmed(i) != -1 && confirmed(i) != t(i)) isParadoxical = true\n confirmed(i) = t(i)\n }\n }\n for (i ← a.indices.reverse.tail){\n if (confirmed(i) != -1 && confirmed(i) > a(i)) isParadoxical = true\n if (a(i) != a(i + 1)){\n if (confirmed(i) != -1 && confirmed(i) != a(i)) isParadoxical = true\n confirmed(i) = a(i)\n }\n }\n val mod = 1000000007L\n if (isParadoxical) println(0)\n else {\n var count = 1L\n val mountains = confirmed.indices.filter(i ⇒ confirmed(i) != -1).toArray\n for (i ← mountains.indices.tail){\n count *= expWithMod(math.min(confirmed(mountains(i)), confirmed(mountains(i - 1))), mountains(i) - mountains(i - 1) - 1)\n count %= mod\n }\n println(count)\n }\n def expWithMod(base: Long, exp: Int): Long = {\n exp match {\n case 0 ⇒ 1\n case 1 ⇒ base\n case _ ⇒ expWithMod(base, exp / 2).let(it ⇒ (it * it % mod) * expWithMod(base, exp % 2)) % mod\n }\n }\n\n implicit class Scope[T](val value: T) extends AnyVal {\n @inline def also(@inline func: T ⇒ Unit): T = {\n func(value)\n value\n }\n @inline def let[A](@inline func: T ⇒ A): A = func(value)\n }\n}", "language": "Scala", "metadata": {"date": 1550034905, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03959.html", "problem_id": "p03959", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03959/input.txt", "sample_output_relpath": "derived/input_output/data/p03959/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03959/Scala/s656355740.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s656355740", "user_id": "u419330815"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "object Main extends App {\n import scala.io.StdIn._\n\n val n = readInt\n val t = readLine.trim.split(' ').map(_.toInt)\n val a = readLine.trim.split(' ').map(_.toInt)\n var isParadoxical = false\n val confirmed = Array.tabulate(n){_ ⇒ -1}\n confirmed(0) = t.head\n confirmed(n - 1) = a.last\n for (i ← t.indices.tail){\n if (t(i) != t(i - 1)){\n if (confirmed(i) != -1 && confirmed(i) != t(i)) isParadoxical = true\n confirmed(i) = t(i)\n }\n }\n for (i ← a.indices.reverse.tail){\n if (confirmed(i) != -1 && confirmed(i) > a(i)) isParadoxical = true\n if (a(i) != a(i + 1)){\n if (confirmed(i) != -1 && confirmed(i) != a(i)) isParadoxical = true\n confirmed(i) = a(i)\n }\n }\n val mod = 1000000007L\n if (isParadoxical) println(0)\n else {\n var count = 1L\n val mountains = confirmed.indices.filter(i ⇒ confirmed(i) != -1).toArray\n for (i ← mountains.indices.tail){\n count *= expWithMod(math.min(confirmed(mountains(i)), confirmed(mountains(i - 1))), mountains(i) - mountains(i - 1) - 1)\n count %= mod\n }\n println(count)\n }\n def expWithMod(base: Long, exp: Int): Long = {\n exp match {\n case 0 ⇒ 1\n case 1 ⇒ base\n case _ ⇒ expWithMod(base, exp / 2).let(it ⇒ (it * it % mod) * expWithMod(base, exp % 2)) % mod\n }\n }\n\n implicit class Scope[T](val value: T) extends AnyVal {\n @inline def also(@inline func: T ⇒ Unit): T = {\n func(value)\n value\n }\n @inline def let[A](@inline func: T ⇒ A): A = func(value)\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nMountaineers Mr. Takahashi and Mr. Aoki recently trekked across a certain famous mountain range.\nThe mountain range consists of N mountains, extending from west to east in a straight line as Mt. 1, Mt. 2, ..., Mt. N.\nMr. Takahashi traversed the range from the west and Mr. Aoki from the east.\n\nThe height of Mt. i is h_i, but they have forgotten the value of each h_i.\nInstead, for each i (1 ≤ i ≤ N), they recorded the maximum height of the mountains climbed up to the time they reached the peak of Mt. i (including Mt. i).\nMr. Takahashi's record is T_i and Mr. Aoki's record is A_i.\n\nWe know that the height of each mountain h_i is a positive integer.\nCompute the number of the possible sequences of the mountains' heights, modulo 10^9 + 7.\n\nNote that the records may be incorrect and thus there may be no possible sequence of the mountains' heights.\nIn such a case, output 0.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n1 ≤ T_i ≤ 10^9\n\n1 ≤ A_i ≤ 10^9\n\nT_i ≤ T_{i+1} (1 ≤ i ≤ N - 1)\n\nA_i ≥ A_{i+1} (1 ≤ i ≤ N - 1)\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nT_1 T_2 ... T_N\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of possible sequences of the mountains' heights, modulo 10^9 + 7.\n\nSample Input 1\n\n5\n1 3 3 3 3\n3 3 2 2 2\n\nSample Output 1\n\n4\n\nThe possible sequences of the mountains' heights are:\n\n1, 3, 2, 2, 2\n\n1, 3, 2, 1, 2\n\n1, 3, 1, 2, 2\n\n1, 3, 1, 1, 2\n\nfor a total of four sequences.\n\nSample Input 2\n\n5\n1 1 1 2 2\n3 2 1 1 1\n\nSample Output 2\n\n0\n\nThe records are contradictory, since Mr. Takahashi recorded 2 as the highest peak after climbing all the mountains but Mr. Aoki recorded 3.\n\nSample Input 3\n\n10\n1 3776 3776 8848 8848 8848 8848 8848 8848 8848\n8848 8848 8848 8848 8848 8848 8848 8848 3776 5\n\nSample Output 3\n\n884111967\n\nDon't forget to compute the number modulo 10^9 + 7.\n\nSample Input 4\n\n1\n17\n17\n\nSample Output 4\n\n1\n\nSome mountain ranges consist of only one mountain.", "sample_input": "5\n1 3 3 3 3\n3 3 2 2 2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03959", "source_text": "Score : 400 points\n\nProblem Statement\n\nMountaineers Mr. Takahashi and Mr. Aoki recently trekked across a certain famous mountain range.\nThe mountain range consists of N mountains, extending from west to east in a straight line as Mt. 1, Mt. 2, ..., Mt. N.\nMr. Takahashi traversed the range from the west and Mr. Aoki from the east.\n\nThe height of Mt. i is h_i, but they have forgotten the value of each h_i.\nInstead, for each i (1 ≤ i ≤ N), they recorded the maximum height of the mountains climbed up to the time they reached the peak of Mt. i (including Mt. i).\nMr. Takahashi's record is T_i and Mr. Aoki's record is A_i.\n\nWe know that the height of each mountain h_i is a positive integer.\nCompute the number of the possible sequences of the mountains' heights, modulo 10^9 + 7.\n\nNote that the records may be incorrect and thus there may be no possible sequence of the mountains' heights.\nIn such a case, output 0.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n1 ≤ T_i ≤ 10^9\n\n1 ≤ A_i ≤ 10^9\n\nT_i ≤ T_{i+1} (1 ≤ i ≤ N - 1)\n\nA_i ≥ A_{i+1} (1 ≤ i ≤ N - 1)\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nT_1 T_2 ... T_N\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of possible sequences of the mountains' heights, modulo 10^9 + 7.\n\nSample Input 1\n\n5\n1 3 3 3 3\n3 3 2 2 2\n\nSample Output 1\n\n4\n\nThe possible sequences of the mountains' heights are:\n\n1, 3, 2, 2, 2\n\n1, 3, 2, 1, 2\n\n1, 3, 1, 2, 2\n\n1, 3, 1, 1, 2\n\nfor a total of four sequences.\n\nSample Input 2\n\n5\n1 1 1 2 2\n3 2 1 1 1\n\nSample Output 2\n\n0\n\nThe records are contradictory, since Mr. Takahashi recorded 2 as the highest peak after climbing all the mountains but Mr. Aoki recorded 3.\n\nSample Input 3\n\n10\n1 3776 3776 8848 8848 8848 8848 8848 8848 8848\n8848 8848 8848 8848 8848 8848 8848 8848 3776 5\n\nSample Output 3\n\n884111967\n\nDon't forget to compute the number modulo 10^9 + 7.\n\nSample Input 4\n\n1\n17\n17\n\nSample Output 4\n\n1\n\nSome mountain ranges consist of only one mountain.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1524, "cpu_time_ms": 768, "memory_kb": 76452}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s573688086", "group_id": "codeNet:p03963", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val N, K = sc.nextLong()\n println(K * math.pow(K - 1, N - 1).toLong)\n}\n", "language": "Scala", "metadata": {"date": 1594001239, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03963.html", "problem_id": "p03963", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03963/input.txt", "sample_output_relpath": "derived/input_output/data/p03963/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03963/Scala/s573688086.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s573688086", "user_id": "u737111725"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val N, K = sc.nextLong()\n println(K * math.pow(K - 1, N - 1).toLong)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N balls placed in a row.\nAtCoDeer the deer is painting each of these in one of the K colors of his paint cans.\nFor aesthetic reasons, any two adjacent balls must be painted in different colors.\n\nFind the number of the possible ways to paint the balls.\n\nConstraints\n\n1≦N≦1000\n\n2≦K≦1000\n\nThe correct answer is at most 2^{31}-1.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of the possible ways to paint the balls.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n2\n\nWe will denote the colors by 0 and 1. There are two possible ways: we can either paint the left ball in color 0 and the right ball in color 1, or paint the left in color 1 and the right in color 0.\n\nSample Input 2\n\n1 10\n\nSample Output 2\n\n10\n\nSince there is only one ball, we can use any of the ten colors to paint it. Thus, the answer is ten.", "sample_input": "2 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03963", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N balls placed in a row.\nAtCoDeer the deer is painting each of these in one of the K colors of his paint cans.\nFor aesthetic reasons, any two adjacent balls must be painted in different colors.\n\nFind the number of the possible ways to paint the balls.\n\nConstraints\n\n1≦N≦1000\n\n2≦K≦1000\n\nThe correct answer is at most 2^{31}-1.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of the possible ways to paint the balls.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n2\n\nWe will denote the colors by 0 and 1. There are two possible ways: we can either paint the left ball in color 0 and the right ball in color 1, or paint the left in color 1 and the right in color 0.\n\nSample Input 2\n\n1 10\n\nSample Output 2\n\n10\n\nSince there is only one ball, we can use any of the ten colors to paint it. Thus, the answer is ten.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 144, "cpu_time_ms": 523, "memory_kb": 55124}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s364503630", "group_id": "codeNet:p03963", "input_text": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val Array(n, k) = sc.nextLine.split(\" \").map(_.toInt)\n if (n == 1) println(k)\n else println((2 to n).foldLeft(k) {\n (acc, _) => acc * (k - 1)\n })\n }\n}\n", "language": "Scala", "metadata": {"date": 1558744667, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03963.html", "problem_id": "p03963", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03963/input.txt", "sample_output_relpath": "derived/input_output/data/p03963/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03963/Scala/s364503630.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s364503630", "user_id": "u629133942"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val Array(n, k) = sc.nextLine.split(\" \").map(_.toInt)\n if (n == 1) println(k)\n else println((2 to n).foldLeft(k) {\n (acc, _) => acc * (k - 1)\n })\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N balls placed in a row.\nAtCoDeer the deer is painting each of these in one of the K colors of his paint cans.\nFor aesthetic reasons, any two adjacent balls must be painted in different colors.\n\nFind the number of the possible ways to paint the balls.\n\nConstraints\n\n1≦N≦1000\n\n2≦K≦1000\n\nThe correct answer is at most 2^{31}-1.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of the possible ways to paint the balls.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n2\n\nWe will denote the colors by 0 and 1. There are two possible ways: we can either paint the left ball in color 0 and the right ball in color 1, or paint the left in color 1 and the right in color 0.\n\nSample Input 2\n\n1 10\n\nSample Output 2\n\n10\n\nSince there is only one ball, we can use any of the ten colors to paint it. Thus, the answer is ten.", "sample_input": "2 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03963", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N balls placed in a row.\nAtCoDeer the deer is painting each of these in one of the K colors of his paint cans.\nFor aesthetic reasons, any two adjacent balls must be painted in different colors.\n\nFind the number of the possible ways to paint the balls.\n\nConstraints\n\n1≦N≦1000\n\n2≦K≦1000\n\nThe correct answer is at most 2^{31}-1.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of the possible ways to paint the balls.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n2\n\nWe will denote the colors by 0 and 1. There are two possible ways: we can either paint the left ball in color 0 and the right ball in color 1, or paint the left in color 1 and the right in color 0.\n\nSample Input 2\n\n1 10\n\nSample Output 2\n\n10\n\nSince there is only one ball, we can use any of the ten colors to paint it. Thus, the answer is ten.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 288, "cpu_time_ms": 337, "memory_kb": 25528}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s707467296", "group_id": "codeNet:p03967", "input_text": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val S = sc.nextLine().toCharArray\n\n // 各プレイヤーは, パーをグーよりも多く出してはいけない\n // 片方の手が全て先にわかっている状態で特点を最大化する\n // つまり, 入力として入ってくる手はそれを満たしている\n // 制約の中でより多く勝てばいい\n // グーかパーしか出せない\n // グーはいつでも出せる\n // 負けとあいこでは, あいこの方がいい\n // あいこでグーの数を稼がないと, パーは出すことができない\n // 途中どこかで負ける方が高いケースがあるか? ..不明\n // とりあえず貪欲に行く\n // 勝ちに行った場所を負けた場所に補填したとして, 結局 +- 0なので変わらなそう\n def solve(S: Array[Char]): Int = {\n @scala.annotation.tailrec\n def loop(i: Int, g: Int, p: Int, point: Int): Int =\n if (i < S.length) {\n S(i) match {\n case 'g' =>\n if (p < g) loop(i + 1, g, p + 1, point + 1)\n else loop(i + 1, g + 1, p, point)\n case 'p' =>\n if (p < g) loop(i + 1, g, p + 1, point)\n else loop(i + 1, g + 1, p, point - 1)\n }\n } else point\n loop(0, 0, 0, 0)\n }\n\n println(solve(S))\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1577483064, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03967.html", "problem_id": "p03967", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03967/input.txt", "sample_output_relpath": "derived/input_output/data/p03967/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03967/Scala/s707467296.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s707467296", "user_id": "u891387249"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val S = sc.nextLine().toCharArray\n\n // 各プレイヤーは, パーをグーよりも多く出してはいけない\n // 片方の手が全て先にわかっている状態で特点を最大化する\n // つまり, 入力として入ってくる手はそれを満たしている\n // 制約の中でより多く勝てばいい\n // グーかパーしか出せない\n // グーはいつでも出せる\n // 負けとあいこでは, あいこの方がいい\n // あいこでグーの数を稼がないと, パーは出すことができない\n // 途中どこかで負ける方が高いケースがあるか? ..不明\n // とりあえず貪欲に行く\n // 勝ちに行った場所を負けた場所に補填したとして, 結局 +- 0なので変わらなそう\n def solve(S: Array[Char]): Int = {\n @scala.annotation.tailrec\n def loop(i: Int, g: Int, p: Int, point: Int): Int =\n if (i < S.length) {\n S(i) match {\n case 'g' =>\n if (p < g) loop(i + 1, g, p + 1, point + 1)\n else loop(i + 1, g + 1, p, point)\n case 'p' =>\n if (p < g) loop(i + 1, g, p + 1, point)\n else loop(i + 1, g + 1, p, point - 1)\n }\n } else point\n loop(0, 0, 0, 0)\n }\n\n println(solve(S))\n }\n\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": "p03967", "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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1435, "cpu_time_ms": 424, "memory_kb": 29760}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s569806206", "group_id": "codeNet:p03972", "input_text": "object Main extends App{\n case class Input(p: Seq[Long], q: Seq[Long])\n\n def kruskal(p: Seq[Long], q: Seq[Long]): Long = {\n type Node = Option[(Int, Int)]\n\n case class Edge(n1: Node, n2: Node, cost: Long)\n case class Graph(vs: Set[Node], es: Set[Edge])\n\n val pn = p.last\n val qn = q.last\n\n import scala.collection.mutable\n val nodes: Set[Node] =\n (0 until p.size map { i => Option((i, q.size - 1)): Node }).toSet ++\n (0 until p.size map { i => Option((p.size - 1, i)): Node }).toSet +\n None\n\n val F = mutable.Set[Graph]() ++ (nodes map { n => Graph(Set(n), Set()) })\n val S = mutable.Set[Edge]()\n S ++= p.init.zipWithIndex map {\n case (cost, index) => Edge(Option((index, q.size - 1)), Option((index + 1, q.size - 1)), cost)\n }\n S ++= q.init.zipWithIndex map {\n case (cost, index) => Edge(Option((p.size - 1, index)), Option((p.size - 1, index + 1)), cost)\n }\n S ++= (0 to p.size - 2) map { index => Edge(Option((index, q.size - 1)), None, qn) }\n S ++= (0 to q.size - 2) map { index => Edge(Option((p.size - 1, index)), None, pn) }\n S += Edge(Option((p.size - 1, q.size - 1)), None, Math.min(pn, qn))\n\n def loop() {\n val edge = S minBy (_.cost)\n S -= edge\n\n val t1 = F find (_.vs contains edge.n1)\n val t2 = F find (_.vs contains edge.n2)\n\n (t1, t2) match {\n case (Some(x1), Some(x2)) if x1 != x2 =>\n F -= x1\n F -= x2\n F += Graph((x1.vs ++ x2.vs), x1.es ++ x2.es + edge)\n case _ =>\n }\n\n if (S.nonEmpty) loop()\n }\n\n loop()\n (F.toSeq(0).es.toSeq map {_.cost}).sum\n }\n\n def solve(input: Input): Long = {\n val Input(p, q) = input\n\n (p.size, q.size) match {\n case (0, _) => q.sum\n case (_, 0) => p.sum\n case _ =>\n val prev = solve(Input(p.init, q.init)) - p.init.sum - q.init.sum\n val b = kruskal(p, q)\n\n prev + p.sum + q.sum + b\n }\n }\n\n def parse() = {\n val lines = io.Source.stdin.getLines().toList\n val regex = \"(\\\\d+) (\\\\d+)\".r\n val (w, h) = lines.head match {\n case regex(w, h) => (w.toInt, h.toInt)\n }\n val p = (lines drop 1 take w) map (_.toLong)\n val q = (lines takeRight h) map (_.toLong)\n\n Input(p, q)\n }\n\n val input = parse()\n val retval = solve(input)\n println(retval)\n}", "language": "Scala", "metadata": {"date": 1477445987, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03972.html", "problem_id": "p03972", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03972/input.txt", "sample_output_relpath": "derived/input_output/data/p03972/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03972/Scala/s569806206.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s569806206", "user_id": "u071730284"}, "prompt_components": {"gold_output": "29\n", "input_to_evaluate": "object Main extends App{\n case class Input(p: Seq[Long], q: Seq[Long])\n\n def kruskal(p: Seq[Long], q: Seq[Long]): Long = {\n type Node = Option[(Int, Int)]\n\n case class Edge(n1: Node, n2: Node, cost: Long)\n case class Graph(vs: Set[Node], es: Set[Edge])\n\n val pn = p.last\n val qn = q.last\n\n import scala.collection.mutable\n val nodes: Set[Node] =\n (0 until p.size map { i => Option((i, q.size - 1)): Node }).toSet ++\n (0 until p.size map { i => Option((p.size - 1, i)): Node }).toSet +\n None\n\n val F = mutable.Set[Graph]() ++ (nodes map { n => Graph(Set(n), Set()) })\n val S = mutable.Set[Edge]()\n S ++= p.init.zipWithIndex map {\n case (cost, index) => Edge(Option((index, q.size - 1)), Option((index + 1, q.size - 1)), cost)\n }\n S ++= q.init.zipWithIndex map {\n case (cost, index) => Edge(Option((p.size - 1, index)), Option((p.size - 1, index + 1)), cost)\n }\n S ++= (0 to p.size - 2) map { index => Edge(Option((index, q.size - 1)), None, qn) }\n S ++= (0 to q.size - 2) map { index => Edge(Option((p.size - 1, index)), None, pn) }\n S += Edge(Option((p.size - 1, q.size - 1)), None, Math.min(pn, qn))\n\n def loop() {\n val edge = S minBy (_.cost)\n S -= edge\n\n val t1 = F find (_.vs contains edge.n1)\n val t2 = F find (_.vs contains edge.n2)\n\n (t1, t2) match {\n case (Some(x1), Some(x2)) if x1 != x2 =>\n F -= x1\n F -= x2\n F += Graph((x1.vs ++ x2.vs), x1.es ++ x2.es + edge)\n case _ =>\n }\n\n if (S.nonEmpty) loop()\n }\n\n loop()\n (F.toSeq(0).es.toSeq map {_.cost}).sum\n }\n\n def solve(input: Input): Long = {\n val Input(p, q) = input\n\n (p.size, q.size) match {\n case (0, _) => q.sum\n case (_, 0) => p.sum\n case _ =>\n val prev = solve(Input(p.init, q.init)) - p.init.sum - q.init.sum\n val b = kruskal(p, q)\n\n prev + p.sum + q.sum + b\n }\n }\n\n def parse() = {\n val lines = io.Source.stdin.getLines().toList\n val regex = \"(\\\\d+) (\\\\d+)\".r\n val (w, h) = lines.head match {\n case regex(w, h) => (w.toInt, h.toInt)\n }\n val p = (lines drop 1 take w) map (_.toLong)\n val q = (lines takeRight h) map (_.toLong)\n\n Input(p, q)\n }\n\n val input = parse()\n val retval = solve(input)\n println(retval)\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nOn an xy plane, in an area satisfying 0 ≤ x ≤ W, 0 ≤ y ≤ H, there is one house at each and every point where both x and y are integers.\n\nThere are unpaved roads between every pair of points for which either the x coordinates are equal and the difference between the y coordinates is 1, or the y coordinates are equal and the difference between the x coordinates is 1.\n\nThe cost of paving a road between houses on coordinates (i,j) and (i+1,j) is p_i for any value of j, while the cost of paving a road between houses on coordinates (i,j) and (i,j+1) is q_j for any value of i.\n\nMr. Takahashi wants to pave some of these roads and be able to travel between any two houses on paved roads only. Find the solution with the minimum total cost.\n\nConstraints\n\n1 ≦ W,H ≦ 10^5\n\n1 ≦ p_i ≦ 10^8(0 ≦ i ≦ W-1)\n\n1 ≦ q_j ≦ 10^8(0 ≦ j ≦ H-1)\n\np_i (0 ≦ i ≦ W−1) is an integer.\n\nq_j (0 ≦ j ≦ H−1) is an integer.\n\nInput\n\nInputs are provided from Standard Input in the following form.\n\nW H\np_0\n:\np_{W-1}\nq_0\n:\nq_{H-1}\n\nOutput\n\nOutput an integer representing the minimum total cost.\n\nSample Input 1\n\n2 2\n3\n5\n2\n7\n\nSample Output 1\n\n29\n\nIt is enough to pave the following eight roads.\n\nRoad connecting houses at (0,0) and (0,1)\n\nRoad connecting houses at (0,1) and (1,1)\n\nRoad connecting houses at (0,2) and (1,2)\n\nRoad connecting houses at (1,0) and (1,1)\n\nRoad connecting houses at (1,0) and (2,0)\n\nRoad connecting houses at (1,1) and (1,2)\n\nRoad connecting houses at (1,2) and (2,2)\n\nRoad connecting houses at (2,0) and (2,1)\n\nSample Input 2\n\n4 3\n2\n4\n8\n1\n2\n9\n3\n\nSample Output 2\n\n60", "sample_input": "2 2\n3\n5\n2\n7\n"}, "reference_outputs": ["29\n"], "source_document_id": "p03972", "source_text": "Score : 500 points\n\nProblem Statement\n\nOn an xy plane, in an area satisfying 0 ≤ x ≤ W, 0 ≤ y ≤ H, there is one house at each and every point where both x and y are integers.\n\nThere are unpaved roads between every pair of points for which either the x coordinates are equal and the difference between the y coordinates is 1, or the y coordinates are equal and the difference between the x coordinates is 1.\n\nThe cost of paving a road between houses on coordinates (i,j) and (i+1,j) is p_i for any value of j, while the cost of paving a road between houses on coordinates (i,j) and (i,j+1) is q_j for any value of i.\n\nMr. Takahashi wants to pave some of these roads and be able to travel between any two houses on paved roads only. Find the solution with the minimum total cost.\n\nConstraints\n\n1 ≦ W,H ≦ 10^5\n\n1 ≦ p_i ≦ 10^8(0 ≦ i ≦ W-1)\n\n1 ≦ q_j ≦ 10^8(0 ≦ j ≦ H-1)\n\np_i (0 ≦ i ≦ W−1) is an integer.\n\nq_j (0 ≦ j ≦ H−1) is an integer.\n\nInput\n\nInputs are provided from Standard Input in the following form.\n\nW H\np_0\n:\np_{W-1}\nq_0\n:\nq_{H-1}\n\nOutput\n\nOutput an integer representing the minimum total cost.\n\nSample Input 1\n\n2 2\n3\n5\n2\n7\n\nSample Output 1\n\n29\n\nIt is enough to pave the following eight roads.\n\nRoad connecting houses at (0,0) and (0,1)\n\nRoad connecting houses at (0,1) and (1,1)\n\nRoad connecting houses at (0,2) and (1,2)\n\nRoad connecting houses at (1,0) and (1,1)\n\nRoad connecting houses at (1,0) and (2,0)\n\nRoad connecting houses at (1,1) and (1,2)\n\nRoad connecting houses at (1,2) and (2,2)\n\nRoad connecting houses at (2,0) and (2,1)\n\nSample Input 2\n\n4 3\n2\n4\n8\n1\n2\n9\n3\n\nSample Output 2\n\n60", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2319, "cpu_time_ms": 2102, "memory_kb": 211500}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s615420205", "group_id": "codeNet:p03992", "input_text": "\n\nimport scala.io.StdIn\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val str = StdIn.readLine()\n println(str.substring(0, 4) + \" \" + str.substring(4, 12))\n }\n}\n", "language": "Scala", "metadata": {"date": 1474765319, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03992.html", "problem_id": "p03992", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03992/input.txt", "sample_output_relpath": "derived/input_output/data/p03992/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03992/Scala/s615420205.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s615420205", "user_id": "u393637574"}, "prompt_components": {"gold_output": "CODE FESTIVAL\n", "input_to_evaluate": "\n\nimport scala.io.StdIn\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val str = StdIn.readLine()\n println(str.substring(0, 4) + \" \" + str.substring(4, 12))\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThis contest is CODE FESTIVAL.\nHowever, Mr. Takahashi always writes it CODEFESTIVAL, omitting the single space between CODE and FESTIVAL.\n\nSo he has decided to make a program that puts the single space he omitted.\n\nYou are given a string s with 12 letters.\nOutput the string putting a single space between the first 4 letters and last 8 letters in the string s.\n\nConstraints\n\ns contains exactly 12 letters.\n\nAll letters in s are uppercase English letters.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the string putting a single space between the first 4 letters and last 8 letters in the string s.\nPut a line break at the end.\n\nSample Input 1\n\nCODEFESTIVAL\n\nSample Output 1\n\nCODE FESTIVAL\n\nPutting a single space between the first 4 letters and last 8 letters in CODEFESTIVAL makes it CODE FESTIVAL.\n\nSample Input 2\n\nPOSTGRADUATE\n\nSample Output 2\n\nPOST GRADUATE\n\nSample Input 3\n\nABCDEFGHIJKL\n\nSample Output 3\n\nABCD EFGHIJKL", "sample_input": "CODEFESTIVAL\n"}, "reference_outputs": ["CODE FESTIVAL\n"], "source_document_id": "p03992", "source_text": "Score : 100 points\n\nProblem Statement\n\nThis contest is CODE FESTIVAL.\nHowever, Mr. Takahashi always writes it CODEFESTIVAL, omitting the single space between CODE and FESTIVAL.\n\nSo he has decided to make a program that puts the single space he omitted.\n\nYou are given a string s with 12 letters.\nOutput the string putting a single space between the first 4 letters and last 8 letters in the string s.\n\nConstraints\n\ns contains exactly 12 letters.\n\nAll letters in s are uppercase English letters.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the string putting a single space between the first 4 letters and last 8 letters in the string s.\nPut a line break at the end.\n\nSample Input 1\n\nCODEFESTIVAL\n\nSample Output 1\n\nCODE FESTIVAL\n\nPutting a single space between the first 4 letters and last 8 letters in CODEFESTIVAL makes it CODE FESTIVAL.\n\nSample Input 2\n\nPOSTGRADUATE\n\nSample Output 2\n\nPOST GRADUATE\n\nSample Input 3\n\nABCDEFGHIJKL\n\nSample Output 3\n\nABCD EFGHIJKL", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 180, "cpu_time_ms": 419, "memory_kb": 21432}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s970660516", "group_id": "codeNet:p03994", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val str = io.StdIn.readLine()\n var k = io.StdIn.readLine().toLong\n\n val newStr = for (i <- 0 to (str.length - 1)) yield {\n val d = 'z' + 1 - str(i)\n if (d <= k) { k = k - d; 'a' }\n else str(i)\n }\n\n val lastChar = ((newStr.last + k - 'a') % 26) + 'a'\n\n val ans = newStr.slice(0, newStr.length - 1).mkString + lastChar.toChar\n println(ans)\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1474769837, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s970660516.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s970660516", "user_id": "u382513779"}, "prompt_components": {"gold_output": "aya\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val str = io.StdIn.readLine()\n var k = io.StdIn.readLine().toLong\n\n val newStr = for (i <- 0 to (str.length - 1)) yield {\n val d = 'z' + 1 - str(i)\n if (d <= k) { k = k - d; 'a' }\n else str(i)\n }\n\n val lastChar = ((newStr.last + k - 'a') % 26) + 'a'\n\n val ans = newStr.slice(0, newStr.length - 1).mkString + lastChar.toChar\n println(ans)\n }\n}\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 578, "memory_kb": 32004}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s917267472", "group_id": "codeNet:p03997", "input_text": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n val a: Int = sc.nextLine.toInt\n val b: Int = sc.nextLine.toInt\n val h: Int = sc.nextLine.toInt\n println((a + b) * h / 2)\n }\n}\n", "language": "Scala", "metadata": {"date": 1557757885, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03997.html", "problem_id": "p03997", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03997/input.txt", "sample_output_relpath": "derived/input_output/data/p03997/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03997/Scala/s917267472.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s917267472", "user_id": "u629133942"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n val a: Int = sc.nextLine.toInt\n val b: Int = sc.nextLine.toInt\n val h: Int = sc.nextLine.toInt\n println((a + b) * h / 2)\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively.\n\nAn example of a trapezoid\n\nFind the area of this trapezoid.\n\nConstraints\n\n1≦a≦100\n\n1≦b≦100\n\n1≦h≦100\n\nAll input values are integers.\n\nh is even.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na\nb\nh\n\nOutput\n\nPrint the area of the given trapezoid. It is guaranteed that the area is an integer.\n\nSample Input 1\n\n3\n4\n2\n\nSample Output 1\n\n7\n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2, respectively, the area of the trapezoid is (3+4)×2/2 = 7.\n\nSample Input 2\n\n4\n4\n4\n\nSample Output 2\n\n16\n\nIn this case, a parallelogram is given, which is also a trapezoid.", "sample_input": "3\n4\n2\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03997", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively.\n\nAn example of a trapezoid\n\nFind the area of this trapezoid.\n\nConstraints\n\n1≦a≦100\n\n1≦b≦100\n\n1≦h≦100\n\nAll input values are integers.\n\nh is even.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na\nb\nh\n\nOutput\n\nPrint the area of the given trapezoid. It is guaranteed that the area is an integer.\n\nSample Input 1\n\n3\n4\n2\n\nSample Output 1\n\n7\n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2, respectively, the area of the trapezoid is (3+4)×2/2 = 7.\n\nSample Input 2\n\n4\n4\n4\n\nSample Output 2\n\n16\n\nIn this case, a parallelogram is given, which is also a trapezoid.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 343, "memory_kb": 25512}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s154932241", "group_id": "codeNet:p03998", "input_text": "object Main extends App {\n val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList\n val userStrMap = scala.collection.mutable.HashMap(('a', inputs(0)),('b', inputs(1)),('c', inputs(2)))\n\n println(solve(userStrMap))\n\n def solve(map: scala.collection.mutable.HashMap[Char, String]): Char = {\n var current = 'a'\n\n while(map(current).size != 0) {\n val next = map(current).head\n map.update(current, map(current).tail)\n current = next\n }\n\n current.toUpper\n }\n}", "language": "Scala", "metadata": {"date": 1592017756, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03998.html", "problem_id": "p03998", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03998/input.txt", "sample_output_relpath": "derived/input_output/data/p03998/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03998/Scala/s154932241.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s154932241", "user_id": "u631102131"}, "prompt_components": {"gold_output": "A\n", "input_to_evaluate": "object Main extends App {\n val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList\n val userStrMap = scala.collection.mutable.HashMap(('a', inputs(0)),('b', inputs(1)),('c', inputs(2)))\n\n println(solve(userStrMap))\n\n def solve(map: scala.collection.mutable.HashMap[Char, String]): Char = {\n var current = 'a'\n\n while(map(current).size != 0) {\n val next = map(current).head\n map.update(current, map(current).tail)\n current = next\n }\n\n current.toUpper\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAlice, Bob and Charlie are playing Card Game for Three, as below:\n\nAt first, each of the three players has a deck consisting of some number of cards. Each card has a letter a, b or c written on it. The orders of the cards in the decks cannot be rearranged.\n\nThe players take turns. Alice goes first.\n\nIf the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says a, Alice takes the next turn.)\n\nIf the current player's deck is empty, the game ends and the current player wins the game.\n\nYou are given the initial decks of the players.\nMore specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way.\n\nDetermine the winner of the game.\n\nConstraints\n\n1≦|S_A|≦100\n\n1≦|S_B|≦100\n\n1≦|S_C|≦100\n\nEach letter in S_A, S_B, S_C is a, b or c.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS_A\nS_B\nS_C\n\nOutput\n\nIf Alice will win, print A. If Bob will win, print B. If Charlie will win, print C.\n\nSample Input 1\n\naca\naccc\nca\n\nSample Output 1\n\nA\n\nThe game will progress as below:\n\nAlice discards the top card in her deck, a. Alice takes the next turn.\n\nAlice discards the top card in her deck, c. Charlie takes the next turn.\n\nCharlie discards the top card in his deck, c. Charlie takes the next turn.\n\nCharlie discards the top card in his deck, a. Alice takes the next turn.\n\nAlice discards the top card in her deck, a. Alice takes the next turn.\n\nAlice's deck is empty. The game ends and Alice wins the game.\n\nSample Input 2\n\nabcb\naacb\nbccc\n\nSample Output 2\n\nC", "sample_input": "aca\naccc\nca\n"}, "reference_outputs": ["A\n"], "source_document_id": "p03998", "source_text": "Score : 200 points\n\nProblem Statement\n\nAlice, Bob and Charlie are playing Card Game for Three, as below:\n\nAt first, each of the three players has a deck consisting of some number of cards. Each card has a letter a, b or c written on it. The orders of the cards in the decks cannot be rearranged.\n\nThe players take turns. Alice goes first.\n\nIf the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says a, Alice takes the next turn.)\n\nIf the current player's deck is empty, the game ends and the current player wins the game.\n\nYou are given the initial decks of the players.\nMore specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way.\n\nDetermine the winner of the game.\n\nConstraints\n\n1≦|S_A|≦100\n\n1≦|S_B|≦100\n\n1≦|S_C|≦100\n\nEach letter in S_A, S_B, S_C is a, b or c.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS_A\nS_B\nS_C\n\nOutput\n\nIf Alice will win, print A. If Bob will win, print B. If Charlie will win, print C.\n\nSample Input 1\n\naca\naccc\nca\n\nSample Output 1\n\nA\n\nThe game will progress as below:\n\nAlice discards the top card in her deck, a. Alice takes the next turn.\n\nAlice discards the top card in her deck, c. Charlie takes the next turn.\n\nCharlie discards the top card in his deck, c. Charlie takes the next turn.\n\nCharlie discards the top card in his deck, a. Alice takes the next turn.\n\nAlice discards the top card in her deck, a. Alice takes the next turn.\n\nAlice's deck is empty. The game ends and Alice wins the game.\n\nSample Input 2\n\nabcb\naacb\nbccc\n\nSample Output 2\n\nC", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 496, "cpu_time_ms": 329, "memory_kb": 25532}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s139702257", "group_id": "codeNet:p04002", "input_text": "object Main extends App {\n val sc = new FastScanner(System.in)\n val h, w = sc.nextLong()\n val n = sc.nextInt()\n val ab = List.fill(n)((sc.nextInt(), sc.nextInt()))\n var m = Map[(Int, Int), Int]().withDefaultValue(0)\n for ((a, b) <- ab) {\n for {\n i <- -1 to 1\n j <- -1 to 1\n if 1 < a+i && a+i < h && 1 < b+j && b+j < w\n } {\n m += (a+i, b+j) -> (m((a+i, b+j)) + 1)\n }\n }\n\n val count = m.values.groupBy(identity).view.mapValues(_.size)\n println((w-2) * (h-2) - count.values.sum)\n for (i <- 1 to 9) {\n println(count.getOrElse(i, 0))\n }\n}\n\nclass FastScanner(source: java.io.InputStream) {\n val buf = new Array[Byte](1024)\n var now, end = 0\n\n def isPrintable(b: Byte): Boolean = 33 <= b && b <= 126\n def isNum(b: Byte): Boolean = 48 <= b && b <= 57\n\n def hasNextByte: Boolean = {\n if (now < end) {\n true\n } else {\n now = 0\n end = source.read(buf)\n end > 0\n }\n }\n\n def nextByte(): Byte = {\n if (hasNextByte) {\n val b = buf(now)\n now += 1\n b\n } else {\n -1\n }\n }\n\n def hasNext: Boolean = {\n while (hasNextByte && !isPrintable(buf(now))) {\n now += 1\n }\n hasNextByte\n }\n\n def next(): String = {\n if (hasNext) {\n val sb = new StringBuilder()\n var b = nextByte()\n while (isPrintable(b)) {\n sb += b.toChar\n b = nextByte()\n }\n sb.toString\n } else {\n throw new NoSuchElementException()\n }\n }\n\n def nextInt(): Int = {\n nextLong().toInt\n }\n\n def nextLong(): Long = {\n if (hasNext) {\n var b = nextByte()\n var sign = 1\n var n = 0L\n if (b == '-') {\n sign = -1\n b = nextByte()\n }\n while (isNum(b)) {\n n = n * 10 + (b - 48)\n b = nextByte()\n }\n sign * n\n } else {\n throw new NoSuchElementException()\n }\n }\n\n def nextDouble(): Double = next().toDouble\n}\n", "language": "Scala", "metadata": {"date": 1594567805, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p04002.html", "problem_id": "p04002", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04002/input.txt", "sample_output_relpath": "derived/input_output/data/p04002/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04002/Scala/s139702257.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s139702257", "user_id": "u191819389"}, "prompt_components": {"gold_output": "0\n0\n0\n2\n4\n0\n0\n0\n0\n0\n", "input_to_evaluate": "object Main extends App {\n val sc = new FastScanner(System.in)\n val h, w = sc.nextLong()\n val n = sc.nextInt()\n val ab = List.fill(n)((sc.nextInt(), sc.nextInt()))\n var m = Map[(Int, Int), Int]().withDefaultValue(0)\n for ((a, b) <- ab) {\n for {\n i <- -1 to 1\n j <- -1 to 1\n if 1 < a+i && a+i < h && 1 < b+j && b+j < w\n } {\n m += (a+i, b+j) -> (m((a+i, b+j)) + 1)\n }\n }\n\n val count = m.values.groupBy(identity).view.mapValues(_.size)\n println((w-2) * (h-2) - count.values.sum)\n for (i <- 1 to 9) {\n println(count.getOrElse(i, 0))\n }\n}\n\nclass FastScanner(source: java.io.InputStream) {\n val buf = new Array[Byte](1024)\n var now, end = 0\n\n def isPrintable(b: Byte): Boolean = 33 <= b && b <= 126\n def isNum(b: Byte): Boolean = 48 <= b && b <= 57\n\n def hasNextByte: Boolean = {\n if (now < end) {\n true\n } else {\n now = 0\n end = source.read(buf)\n end > 0\n }\n }\n\n def nextByte(): Byte = {\n if (hasNextByte) {\n val b = buf(now)\n now += 1\n b\n } else {\n -1\n }\n }\n\n def hasNext: Boolean = {\n while (hasNextByte && !isPrintable(buf(now))) {\n now += 1\n }\n hasNextByte\n }\n\n def next(): String = {\n if (hasNext) {\n val sb = new StringBuilder()\n var b = nextByte()\n while (isPrintable(b)) {\n sb += b.toChar\n b = nextByte()\n }\n sb.toString\n } else {\n throw new NoSuchElementException()\n }\n }\n\n def nextInt(): Int = {\n nextLong().toInt\n }\n\n def nextLong(): Long = {\n if (hasNext) {\n var b = nextByte()\n var sign = 1\n var n = 0L\n if (b == '-') {\n sign = -1\n b = nextByte()\n }\n while (isNum(b)) {\n n = n * 10 + (b - 48)\n b = nextByte()\n }\n sign * n\n } else {\n throw new NoSuchElementException()\n }\n }\n\n def nextDouble(): Double = next().toDouble\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns. At first, all cells were painted white.\n\nSnuke painted N of these cells. The i-th ( 1 \\leq i \\leq N ) cell he painted is the cell at the a_i-th row and b_i-th column.\n\nCompute the following:\n\nFor each integer j ( 0 \\leq j \\leq 9 ), how many subrectangles of size 3×3 of the grid contains exactly j black cells, after Snuke painted N cells?\n\nConstraints\n\n3 \\leq H \\leq 10^9\n\n3 \\leq W \\leq 10^9\n\n0 \\leq N \\leq min(10^5,H×W)\n\n1 \\leq a_i \\leq H (1 \\leq i \\leq N)\n\n1 \\leq b_i \\leq W (1 \\leq i \\leq N)\n\n(a_i, b_i) \\neq (a_j, b_j) (i \\neq j)\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nH W N\na_1 b_1\n:\na_N b_N\n\nOutput\n\nPrint 10 lines.\nThe (j+1)-th ( 0 \\leq j \\leq 9 ) line should contain the number of the subrectangles of size 3×3 of the grid that contains exactly j black cells.\n\nSample Input 1\n\n4 5 8\n1 1\n1 4\n1 5\n2 3\n3 1\n3 2\n3 4\n4 4\n\nSample Output 1\n\n0\n0\n0\n2\n4\n0\n0\n0\n0\n0\n\nThere are six subrectangles of size 3×3. Two of them contain three black cells each, and the remaining four contain four black cells each.\n\nSample Input 2\n\n10 10 20\n1 1\n1 4\n1 9\n2 5\n3 10\n4 2\n4 7\n5 9\n6 4\n6 6\n6 7\n7 1\n7 3\n7 7\n8 1\n8 5\n8 10\n9 2\n10 4\n10 9\n\nSample Output 2\n\n4\n26\n22\n10\n2\n0\n0\n0\n0\n0\n\nSample Input 3\n\n1000000000 1000000000 0\n\nSample Output 3\n\n999999996000000004\n0\n0\n0\n0\n0\n0\n0\n0\n0", "sample_input": "4 5 8\n1 1\n1 4\n1 5\n2 3\n3 1\n3 2\n3 4\n4 4\n"}, "reference_outputs": ["0\n0\n0\n2\n4\n0\n0\n0\n0\n0\n"], "source_document_id": "p04002", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns. At first, all cells were painted white.\n\nSnuke painted N of these cells. The i-th ( 1 \\leq i \\leq N ) cell he painted is the cell at the a_i-th row and b_i-th column.\n\nCompute the following:\n\nFor each integer j ( 0 \\leq j \\leq 9 ), how many subrectangles of size 3×3 of the grid contains exactly j black cells, after Snuke painted N cells?\n\nConstraints\n\n3 \\leq H \\leq 10^9\n\n3 \\leq W \\leq 10^9\n\n0 \\leq N \\leq min(10^5,H×W)\n\n1 \\leq a_i \\leq H (1 \\leq i \\leq N)\n\n1 \\leq b_i \\leq W (1 \\leq i \\leq N)\n\n(a_i, b_i) \\neq (a_j, b_j) (i \\neq j)\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nH W N\na_1 b_1\n:\na_N b_N\n\nOutput\n\nPrint 10 lines.\nThe (j+1)-th ( 0 \\leq j \\leq 9 ) line should contain the number of the subrectangles of size 3×3 of the grid that contains exactly j black cells.\n\nSample Input 1\n\n4 5 8\n1 1\n1 4\n1 5\n2 3\n3 1\n3 2\n3 4\n4 4\n\nSample Output 1\n\n0\n0\n0\n2\n4\n0\n0\n0\n0\n0\n\nThere are six subrectangles of size 3×3. Two of them contain three black cells each, and the remaining four contain four black cells each.\n\nSample Input 2\n\n10 10 20\n1 1\n1 4\n1 9\n2 5\n3 10\n4 2\n4 7\n5 9\n6 4\n6 6\n6 7\n7 1\n7 3\n7 7\n8 1\n8 5\n8 10\n9 2\n10 4\n10 9\n\nSample Output 2\n\n4\n26\n22\n10\n2\n0\n0\n0\n0\n0\n\nSample Input 3\n\n1000000000 1000000000 0\n\nSample Output 3\n\n999999996000000004\n0\n0\n0\n0\n0\n0\n0\n0\n0", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1899, "cpu_time_ms": 2882, "memory_kb": 201616}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s952897809", "group_id": "codeNet:p04003", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val s = new Main()\n s.solve()\n s.out.flush()\n }\n}\n\nclass Main {\n import java.io._\n import java.util.StringTokenizer\n\n import scala.collection.mutable\n import scala.util.Sorting\n import math.{abs, max, min}\n import mutable.{ArrayBuffer, ListBuffer}\n import scala.reflect.ClassTag\n\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n\n def solve(): Unit = {\n val N, M = ni()\n\n case class Edge(v: Long, w: Int)\n\n // 会社に属さないノードは 駅id\n // 会社に属するノードは 会社id * 1e6 + 駅id\n val g: mutable.Map[Long, ArrayBuffer[Edge]] = mutable.Map().withDefaultValue(ArrayBuffer.empty)\n\n // 方向あるよ\n def joint(from: Long, to: Long, w: Int): Unit = {\n if (!g.contains(from)) g(from) = ArrayBuffer()\n g(from) += Edge(to, w)\n }\n\n REP(M) { _ =>\n val from, to = ni() - 1\n val c = ni()\n val fromC = from + c * 1e6.toLong\n val toC = to + c * 1e6.toLong\n\n joint(fromC, toC, 0)\n joint(toC, fromC, 0)\n joint(from, fromC, 1) // 乗るのは1\n joint(fromC, from, 0) // 降りるのは0\n joint(to, toC, 1)\n joint(toC, to, 0)\n }\n\n// g.toSeq.sortBy(_._1).foreach { case (v, es) =>\n// debug(s\"$v ${es.mkString}\")\n// }\n\n val INF = Integer.MAX_VALUE / 2\n def dijk(start: Long, dest: Long): Int = {\n import java.util\n val d = mutable.Map[Long, Int]().withDefaultValue(INF)\n case class Visit(node: Long, cost: Int)\n val queue = new util.ArrayDeque[Visit]()\n d(start) = 0\n queue.add(Visit(start, 0))\n\n while(!queue.isEmpty) {\n val v = queue.poll()\n if (d(v.node) == v.cost) {\n val es = g(v.node)\n REP(es.length) { i =>\n val e = es(i)\n val next = v.cost + e.w\n if (d(e.v) > next) {\n d(e.v) = next\n if (e.w == 0) queue.addFirst(Visit(e.v, next))\n else queue.addLast(Visit(e.v, next))\n }\n }\n }\n }\n\n// d.toSeq.sortBy(_._1).foreach { case (v, cost) =>\n// debug(s\"$v $cost\")\n// }\n\n d(dest)\n }\n\n val ans = dijk(0, N - 1)\n if (ans == INF) out.println(-1)\n else out.println(ans)\n }\n\n\n def debug(as: Array[Boolean]): Unit = {\n System.err.println(as.map(x => if(x) \"1\" else \"0\").mkString)\n }\n\n def debug(as: Array[Int]): Unit = {\n System.err.println(as.mkString(\" \"))\n }\n\n def debug(as: Array[Long]): Unit = {\n System.err.println(as.mkString(\" \"))\n }\n\n def debug(s: String): Unit = {\n System.err.println(s)\n }\n\n def debug(num: Long): Unit = {\n System.err.println(num)\n }\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next().toInt\n def nextLong(): Long = next().toLong\n def nextChar(): Char = next().charAt(0)\n }\n val sc = new InputReader(System.in)\n def ni(): Int = sc.nextInt()\n def nl(): Long = sc.nextLong()\n def nc(): Char = sc.nextChar()\n def ns(): String = sc.next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n\n def cumSum(as: Array[Int]) = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n", "language": "Scala", "metadata": {"date": 1548740033, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p04003.html", "problem_id": "p04003", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04003/input.txt", "sample_output_relpath": "derived/input_output/data/p04003/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04003/Scala/s952897809.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s952897809", "user_id": "u460609472"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val s = new Main()\n s.solve()\n s.out.flush()\n }\n}\n\nclass Main {\n import java.io._\n import java.util.StringTokenizer\n\n import scala.collection.mutable\n import scala.util.Sorting\n import math.{abs, max, min}\n import mutable.{ArrayBuffer, ListBuffer}\n import scala.reflect.ClassTag\n\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n\n def solve(): Unit = {\n val N, M = ni()\n\n case class Edge(v: Long, w: Int)\n\n // 会社に属さないノードは 駅id\n // 会社に属するノードは 会社id * 1e6 + 駅id\n val g: mutable.Map[Long, ArrayBuffer[Edge]] = mutable.Map().withDefaultValue(ArrayBuffer.empty)\n\n // 方向あるよ\n def joint(from: Long, to: Long, w: Int): Unit = {\n if (!g.contains(from)) g(from) = ArrayBuffer()\n g(from) += Edge(to, w)\n }\n\n REP(M) { _ =>\n val from, to = ni() - 1\n val c = ni()\n val fromC = from + c * 1e6.toLong\n val toC = to + c * 1e6.toLong\n\n joint(fromC, toC, 0)\n joint(toC, fromC, 0)\n joint(from, fromC, 1) // 乗るのは1\n joint(fromC, from, 0) // 降りるのは0\n joint(to, toC, 1)\n joint(toC, to, 0)\n }\n\n// g.toSeq.sortBy(_._1).foreach { case (v, es) =>\n// debug(s\"$v ${es.mkString}\")\n// }\n\n val INF = Integer.MAX_VALUE / 2\n def dijk(start: Long, dest: Long): Int = {\n import java.util\n val d = mutable.Map[Long, Int]().withDefaultValue(INF)\n case class Visit(node: Long, cost: Int)\n val queue = new util.ArrayDeque[Visit]()\n d(start) = 0\n queue.add(Visit(start, 0))\n\n while(!queue.isEmpty) {\n val v = queue.poll()\n if (d(v.node) == v.cost) {\n val es = g(v.node)\n REP(es.length) { i =>\n val e = es(i)\n val next = v.cost + e.w\n if (d(e.v) > next) {\n d(e.v) = next\n if (e.w == 0) queue.addFirst(Visit(e.v, next))\n else queue.addLast(Visit(e.v, next))\n }\n }\n }\n }\n\n// d.toSeq.sortBy(_._1).foreach { case (v, cost) =>\n// debug(s\"$v $cost\")\n// }\n\n d(dest)\n }\n\n val ans = dijk(0, N - 1)\n if (ans == INF) out.println(-1)\n else out.println(ans)\n }\n\n\n def debug(as: Array[Boolean]): Unit = {\n System.err.println(as.map(x => if(x) \"1\" else \"0\").mkString)\n }\n\n def debug(as: Array[Int]): Unit = {\n System.err.println(as.mkString(\" \"))\n }\n\n def debug(as: Array[Long]): Unit = {\n System.err.println(as.mkString(\" \"))\n }\n\n def debug(s: String): Unit = {\n System.err.println(s)\n }\n\n def debug(num: Long): Unit = {\n System.err.println(num)\n }\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = _\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next().toInt\n def nextLong(): Long = next().toLong\n def nextChar(): Char = next().charAt(0)\n }\n val sc = new InputReader(System.in)\n def ni(): Int = sc.nextInt()\n def nl(): Long = sc.nextLong()\n def nc(): Char = sc.nextChar()\n def ns(): String = sc.next()\n def ns(n: Int): Array[Char] = ns().toCharArray\n def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n val A1, A2 = Array.ofDim[Int](n)\n REP(n) { i =>\n A1(i) = ni() + offset\n A2(i) = ni() + offset\n }\n (A1, A2)\n }\n def nm(n: Int, m: Int): Array[Array[Int]] = {\n val A = Array.ofDim[Int](n, m)\n REP(n) { i =>\n REP(m) { j =>\n A(i)(j) = ni()\n }\n }\n A\n }\n def nal(n: Int): Array[Long] = map(n)(_ => nl())\n def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = offset\n val N = n + offset\n while(i < N) { f(i); i += 1 }\n }\n def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n var i = n - 1 + offset\n while(i >= offset) { f(i); i -= 1 }\n }\n\n def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n REP(n)(i => res(i) = f(i + offset))\n res\n }\n\n\n def sumL(as: Array[Int]): Long = {\n var s = 0L\n REP(as.length)(i => s += as(i))\n s\n }\n\n def cumSum(as: Array[Int]) = {\n val cum = Array.ofDim[Long](as.length + 1)\n REP(as.length) { i =>\n cum(i + 1) = cum(i) + as(i)\n }\n cum\n }\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nSnuke's town has a subway system, consisting of N stations and M railway lines. The stations are numbered 1 through N. Each line is operated by a company. Each company has an identification number.\n\nThe i-th ( 1 \\leq i \\leq M ) line connects station p_i and q_i bidirectionally. There is no intermediate station. This line is operated by company c_i.\n\nYou can change trains at a station where multiple lines are available.\n\nThe fare system used in this subway system is a bit strange. When a passenger only uses lines that are operated by the same company, the fare is 1 yen (the currency of Japan). Whenever a passenger changes to a line that is operated by a different company from the current line, the passenger is charged an additional fare of 1 yen. In a case where a passenger who changed from some company A's line to another company's line changes to company A's line again, the additional fare is incurred again.\n\nSnuke is now at station 1 and wants to travel to station N by subway. Find the minimum required fare.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n0 \\leq M \\leq 2×10^5\n\n1 \\leq p_i \\leq N (1 \\leq i \\leq M)\n\n1 \\leq q_i \\leq N (1 \\leq i \\leq M)\n\n1 \\leq c_i \\leq 10^6 (1 \\leq i \\leq M)\n\np_i \\neq q_i (1 \\leq i \\leq M)\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\np_1 q_1 c_1\n:\np_M q_M c_M\n\nOutput\n\nPrint the minimum required fare. If it is impossible to get to station N by subway, print -1 instead.\n\nSample Input 1\n\n3 3\n1 2 1\n2 3 1\n3 1 2\n\nSample Output 1\n\n1\n\nUse company 1's lines: 1 → 2 → 3. The fare is 1 yen.\n\nSample Input 2\n\n8 11\n1 3 1\n1 4 2\n2 3 1\n2 5 1\n3 4 3\n3 6 3\n3 7 3\n4 8 4\n5 6 1\n6 7 5\n7 8 5\n\nSample Output 2\n\n2\n\nFirst, use company 1's lines: 1 → 3 → 2 → 5 → 6. Then, use company 5's lines: 6 → 7 → 8. The fare is 2 yen.\n\nSample Input 3\n\n2 0\n\nSample Output 3\n\n-1", "sample_input": "3 3\n1 2 1\n2 3 1\n3 1 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p04003", "source_text": "Score : 600 points\n\nProblem Statement\n\nSnuke's town has a subway system, consisting of N stations and M railway lines. The stations are numbered 1 through N. Each line is operated by a company. Each company has an identification number.\n\nThe i-th ( 1 \\leq i \\leq M ) line connects station p_i and q_i bidirectionally. There is no intermediate station. This line is operated by company c_i.\n\nYou can change trains at a station where multiple lines are available.\n\nThe fare system used in this subway system is a bit strange. When a passenger only uses lines that are operated by the same company, the fare is 1 yen (the currency of Japan). Whenever a passenger changes to a line that is operated by a different company from the current line, the passenger is charged an additional fare of 1 yen. In a case where a passenger who changed from some company A's line to another company's line changes to company A's line again, the additional fare is incurred again.\n\nSnuke is now at station 1 and wants to travel to station N by subway. Find the minimum required fare.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n0 \\leq M \\leq 2×10^5\n\n1 \\leq p_i \\leq N (1 \\leq i \\leq M)\n\n1 \\leq q_i \\leq N (1 \\leq i \\leq M)\n\n1 \\leq c_i \\leq 10^6 (1 \\leq i \\leq M)\n\np_i \\neq q_i (1 \\leq i \\leq M)\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\np_1 q_1 c_1\n:\np_M q_M c_M\n\nOutput\n\nPrint the minimum required fare. If it is impossible to get to station N by subway, print -1 instead.\n\nSample Input 1\n\n3 3\n1 2 1\n2 3 1\n3 1 2\n\nSample Output 1\n\n1\n\nUse company 1's lines: 1 → 2 → 3. The fare is 1 yen.\n\nSample Input 2\n\n8 11\n1 3 1\n1 4 2\n2 3 1\n2 5 1\n3 4 3\n3 6 3\n3 7 3\n4 8 4\n5 6 1\n6 7 5\n7 8 5\n\nSample Output 2\n\n2\n\nFirst, use company 1's lines: 1 → 3 → 2 → 5 → 6. Then, use company 5's lines: 6 → 7 → 8. The fare is 2 yen.\n\nSample Input 3\n\n2 0\n\nSample Output 3\n\n-1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4663, "cpu_time_ms": 3171, "memory_kb": 253400}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s786874408", "group_id": "codeNet:p04014", "input_text": "object Main extends App {\n\n import scala.io.StdIn._\n\n val n = readLong()\n val s = readLong()\n\n val rt = Math.sqrt(n).toLong\n\n def digitSum(b : Long, n : Long) : Long = if (n < b) n else digitSum(b , n / b) + n % b\n\n def checkOne = if (n == s) Some(1) else None\n\n def searchFirstHalf(now : Long):Option[Long] = {\n if (now >= rt) None\n else if (digitSum(now, n) == s) Some(now)\n else searchFirstHalf(now + 1)\n }\n\n def searchSecondHalf(now : Long) : Option[Long] = {\n if (now <= 0) None\n else {\n val b = (n + now - s) / now\n if (digitSum(b, n) == s) {\n Some(b)\n }\n else searchSecondHalf(now - 1)\n }\n }\n\n val calc = if (n < s) None else checkOne orElse searchFirstHalf(2) orElse searchSecondHalf(rt)\n\n println(calc getOrElse -1)\n}", "language": "Scala", "metadata": {"date": 1473465880, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p04014.html", "problem_id": "p04014", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04014/input.txt", "sample_output_relpath": "derived/input_output/data/p04014/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04014/Scala/s786874408.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s786874408", "user_id": "u098781461"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "object Main extends App {\n\n import scala.io.StdIn._\n\n val n = readLong()\n val s = readLong()\n\n val rt = Math.sqrt(n).toLong\n\n def digitSum(b : Long, n : Long) : Long = if (n < b) n else digitSum(b , n / b) + n % b\n\n def checkOne = if (n == s) Some(1) else None\n\n def searchFirstHalf(now : Long):Option[Long] = {\n if (now >= rt) None\n else if (digitSum(now, n) == s) Some(now)\n else searchFirstHalf(now + 1)\n }\n\n def searchSecondHalf(now : Long) : Option[Long] = {\n if (now <= 0) None\n else {\n val b = (n + now - s) / now\n if (digitSum(b, n) == s) {\n Some(b)\n }\n else searchSecondHalf(now - 1)\n }\n }\n\n val calc = if (n < s) None else checkOne orElse searchFirstHalf(2) orElse searchSecondHalf(rt)\n\n println(calc getOrElse -1)\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nFor integers b (b \\geq 2) and n (n \\geq 1), let the function f(b,n) be defined as follows:\n\nf(b,n) = n, when n < b\n\nf(b,n) = f(b,\\,{\\rm floor}(n / b)) + (n \\ {\\rm mod} \\ b), when n \\geq b\n\nHere, {\\rm floor}(n / b) denotes the largest integer not exceeding n / b,\nand n \\ {\\rm mod} \\ b denotes the remainder of n divided by b.\n\nLess formally, f(b,n) is equal to the sum of the digits of n written in base b.\nFor example, the following hold:\n\nf(10,\\,87654)=8+7+6+5+4=30\n\nf(100,\\,87654)=8+76+54=138\n\nYou are given integers n and s.\nDetermine if there exists an integer b (b \\geq 2) such that f(b,n)=s.\nIf the answer is positive, also find the smallest such b.\n\nConstraints\n\n1 \\leq n \\leq 10^{11}\n\n1 \\leq s \\leq 10^{11}\n\nn,\\,s are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nn\ns\n\nOutput\n\nIf there exists an integer b (b \\geq 2) such that f(b,n)=s, print the smallest such b.\nIf such b does not exist, print -1 instead.\n\nSample Input 1\n\n87654\n30\n\nSample Output 1\n\n10\n\nSample Input 2\n\n87654\n138\n\nSample Output 2\n\n100\n\nSample Input 3\n\n87654\n45678\n\nSample Output 3\n\n-1\n\nSample Input 4\n\n31415926535\n1\n\nSample Output 4\n\n31415926535\n\nSample Input 5\n\n1\n31415926535\n\nSample Output 5\n\n-1", "sample_input": "87654\n30\n"}, "reference_outputs": ["10\n"], "source_document_id": "p04014", "source_text": "Score : 500 points\n\nProblem Statement\n\nFor integers b (b \\geq 2) and n (n \\geq 1), let the function f(b,n) be defined as follows:\n\nf(b,n) = n, when n < b\n\nf(b,n) = f(b,\\,{\\rm floor}(n / b)) + (n \\ {\\rm mod} \\ b), when n \\geq b\n\nHere, {\\rm floor}(n / b) denotes the largest integer not exceeding n / b,\nand n \\ {\\rm mod} \\ b denotes the remainder of n divided by b.\n\nLess formally, f(b,n) is equal to the sum of the digits of n written in base b.\nFor example, the following hold:\n\nf(10,\\,87654)=8+7+6+5+4=30\n\nf(100,\\,87654)=8+76+54=138\n\nYou are given integers n and s.\nDetermine if there exists an integer b (b \\geq 2) such that f(b,n)=s.\nIf the answer is positive, also find the smallest such b.\n\nConstraints\n\n1 \\leq n \\leq 10^{11}\n\n1 \\leq s \\leq 10^{11}\n\nn,\\,s are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nn\ns\n\nOutput\n\nIf there exists an integer b (b \\geq 2) such that f(b,n)=s, print the smallest such b.\nIf such b does not exist, print -1 instead.\n\nSample Input 1\n\n87654\n30\n\nSample Output 1\n\n10\n\nSample Input 2\n\n87654\n138\n\nSample Output 2\n\n100\n\nSample Input 3\n\n87654\n45678\n\nSample Output 3\n\n-1\n\nSample Input 4\n\n31415926535\n1\n\nSample Output 4\n\n31415926535\n\nSample Input 5\n\n1\n31415926535\n\nSample Output 5\n\n-1", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 760, "memory_kb": 23312}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s604674375", "group_id": "codeNet:p04015", "input_text": "object Main extends App {\n val scan = new java.util.Scanner(System.in)\n val n = scan.next().toInt\n val a = scan.next().toDouble\n val xs = (1 to n).toArray.map(_ => scan.next().toInt)\n val memo = Array.fill(n+1, n+1,2501)(-1)\n memo(0)(0)(0) = 0\n for (i<-1 to n; j<-0 to n; k<-0 to 2500) {\n if (memo(i-1)(j)(k) != -1) { \n if (memo(i)(j)(k) == -1) memo(i)(j)(k) = 0\n memo(i)(j)(k) = memo(i-1)(j)(k)\n }\n if ((k-xs(i-1)>=0 && j-1>=0 && memo(i-1)(j-1)(k-xs(i-1)) != -1)) {\n if (memo(i)(j)(k) == -1) memo(i)(j)(k) = 0\n memo(i)(j)(k) += 1\n } \n }\n\n println((for (j<-1 to n; k<-0 to 2500; if memo(n)(j)(k) != -1 && k%j==0 && k/j==a) yield memo(n)(j)(k)).sum)\n}", "language": "Scala", "metadata": {"date": 1525823890, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s604674375.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s604674375", "user_id": "u219949952"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "object Main extends App {\n val scan = new java.util.Scanner(System.in)\n val n = scan.next().toInt\n val a = scan.next().toDouble\n val xs = (1 to n).toArray.map(_ => scan.next().toInt)\n val memo = Array.fill(n+1, n+1,2501)(-1)\n memo(0)(0)(0) = 0\n for (i<-1 to n; j<-0 to n; k<-0 to 2500) {\n if (memo(i-1)(j)(k) != -1) { \n if (memo(i)(j)(k) == -1) memo(i)(j)(k) = 0\n memo(i)(j)(k) = memo(i-1)(j)(k)\n }\n if ((k-xs(i-1)>=0 && j-1>=0 && memo(i-1)(j-1)(k-xs(i-1)) != -1)) {\n if (memo(i)(j)(k) == -1) memo(i)(j)(k) = 0\n memo(i)(j)(k) += 1\n } \n }\n\n println((for (j<-1 to n; k<-0 to 2500; if memo(n)(j)(k) != -1 && k%j==0 && k/j==a) yield memo(n)(j)(k)).sum)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 691, "cpu_time_ms": 610, "memory_kb": 67240}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s981213147", "group_id": "codeNet:p04015", "input_text": "import scala.io.StdIn\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n\n val Array(n, a) = readIntArray()\n val xs = readIntArray().map(_.toLong).zipWithIndex.toVector\n\n val alreadyComputed = collection.mutable.Set.empty[Seq[(Long, Int)]]\n\n def solve(ys: Seq[(Long, Int)]): Long = {\n ys match {\n case Nil =>\n 0L\n case head +: Nil =>\n if (head._1 == a && !alreadyComputed(Seq(head))) 1L else 0L\n case head +: tail =>\n// println(s\"--- head : ${head}\")\n var count = 0\n (1 to tail.length).foreach { i =>\n tail.combinations(i).foreach { cb =>\n// println(s\"${i} : ${cb}\")\n if ((cb.map(_._1).sum + head._1).toDouble / (1 + i) == a && !alreadyComputed(head +: cb)) {\n count += 1\n alreadyComputed += (head +: cb)\n } else if (cb.map(_._1).sum.toDouble / i == a && !alreadyComputed(cb)) {\n count += 1\n alreadyComputed += cb\n }\n }\n }\n// println(s\"::: count : ${count}\")\n solve(tail) + count\n }\n }\n\n println(solve(xs))\n }\n\n private def readIntArray(): Array[Int] =\n StdIn.readLine().trim.split(' ').filter(_.nonEmpty).map(_.toInt)\n}\n", "language": "Scala", "metadata": {"date": 1493075298, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s981213147.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s981213147", "user_id": "u863856861"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n\n val Array(n, a) = readIntArray()\n val xs = readIntArray().map(_.toLong).zipWithIndex.toVector\n\n val alreadyComputed = collection.mutable.Set.empty[Seq[(Long, Int)]]\n\n def solve(ys: Seq[(Long, Int)]): Long = {\n ys match {\n case Nil =>\n 0L\n case head +: Nil =>\n if (head._1 == a && !alreadyComputed(Seq(head))) 1L else 0L\n case head +: tail =>\n// println(s\"--- head : ${head}\")\n var count = 0\n (1 to tail.length).foreach { i =>\n tail.combinations(i).foreach { cb =>\n// println(s\"${i} : ${cb}\")\n if ((cb.map(_._1).sum + head._1).toDouble / (1 + i) == a && !alreadyComputed(head +: cb)) {\n count += 1\n alreadyComputed += (head +: cb)\n } else if (cb.map(_._1).sum.toDouble / i == a && !alreadyComputed(cb)) {\n count += 1\n alreadyComputed += cb\n }\n }\n }\n// println(s\"::: count : ${count}\")\n solve(tail) + count\n }\n }\n\n println(solve(xs))\n }\n\n private def readIntArray(): Array[Int] =\n StdIn.readLine().trim.split(' ').filter(_.nonEmpty).map(_.toInt)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1288, "cpu_time_ms": 2111, "memory_kb": 185848}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s349708721", "group_id": "codeNet:p04019", "input_text": "object Main extends App {\n val str = scala.io.StdIn.readLine.toList\n if ((str.exists { _ == 'N' } == str.exists { _ == 'S' }) && (str.exists { _ == 'W' } == str.exists { _ == 'E' })) println(\"Yes\")\n else println(\"No\")\n}", "language": "Scala", "metadata": {"date": 1471833301, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s349708721.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s349708721", "user_id": "u419330815"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n val str = scala.io.StdIn.readLine.toList\n if ((str.exists { _ == 'N' } == str.exists { _ == 'S' }) && (str.exists { _ == 'W' } == str.exists { _ == 'E' })) println(\"Yes\")\n else println(\"No\")\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 808, "memory_kb": 21568}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s859836422", "group_id": "codeNet:p04029", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n println(List.fill(10)(1 + 1).foldLeft(0){(x, acc) => acc + x + acc + 1})\n}\n", "language": "Scala", "metadata": {"date": 1599417354, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p04029.html", "problem_id": "p04029", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04029/input.txt", "sample_output_relpath": "derived/input_output/data/p04029/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04029/Scala/s859836422.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s859836422", "user_id": "u883265039"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n println(List.fill(10)(1 + 1).foldLeft(0){(x, acc) => acc + x + acc + 1})\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?\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 necessary number of candies in total.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n6\n\nThe answer is 1+2+3=6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n55\n\nThe sum of the integers from 1 to 10 is 55.\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1\n\nOnly one child. The answer is 1 in this case.", "sample_input": "3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p04029", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?\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 necessary number of candies in total.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n6\n\nThe answer is 1+2+3=6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n55\n\nThe sum of the integers from 1 to 10 is 55.\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1\n\nOnly one child. The answer is 1 in this case.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 493, "memory_kb": 55472}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s075691589", "group_id": "codeNet:p04029", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n\n val n = StdIn.readLine().toLong\n\n def fact(before: Long, k: Long): Long = {\n if(k == n) before + n\n else {\n fact(before + k, k + 1)\n }\n }\n \n println(fact(0, 0))\n\n}\n", "language": "Scala", "metadata": {"date": 1536163644, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p04029.html", "problem_id": "p04029", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04029/input.txt", "sample_output_relpath": "derived/input_output/data/p04029/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04029/Scala/s075691589.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s075691589", "user_id": "u895032849"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n\n val n = StdIn.readLine().toLong\n\n def fact(before: Long, k: Long): Long = {\n if(k == n) before + n\n else {\n fact(before + k, k + 1)\n }\n }\n \n println(fact(0, 0))\n\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?\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 necessary number of candies in total.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n6\n\nThe answer is 1+2+3=6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n55\n\nThe sum of the integers from 1 to 10 is 55.\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1\n\nOnly one child. The answer is 1 in this case.", "sample_input": "3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p04029", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?\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 necessary number of candies in total.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n6\n\nThe answer is 1+2+3=6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n55\n\nThe sum of the integers from 1 to 10 is 55.\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1\n\nOnly one child. The answer is 1 in this case.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 320, "memory_kb": 25296}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s176668279", "group_id": "codeNet:p04040", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val h, w, a, b = sc.nextInt()\n val mod = 1000000007\n\n def plus(a: Long, b: Long): Long = (a + b) % mod\n def times(a: Long, b: Long): Long = (a * b) % mod\n\n def pow(a: Long, n: Int, res: Long = 1): Long = {\n if (n == 0) {\n res\n } else if ((n&1) == 0) {\n pow(times(a,a), n >> 1, res)\n } else {\n pow(times(a,a), n >> 1, times(res,a))\n }\n }\n\n def inv(a: Long): Long = pow(a, mod-2)\n\n def initFactTable(n: Int): Array[Long] = {\n (1 to n).scanLeft(1L)(times(_,_)).toArray\n }\n\n val fact = initFactTable(h + w)\n\n def initInvFactTable(n: Int): Array[Long] = {\n (1 to n).scanRight(inv(fact(n)))(times(_,_)).toArray\n }\n\n val invFact = initInvFactTable(h + w)\n\n def comb(n: Int, k: Int): Long = {\n times(times(fact(n), invFact(k)), invFact(n-k))\n }\n\n val ans = (0 until (h - a).min(w - b)).map( i =>\n times(comb(b + h - a - 1, b + i), comb(a + w - b - 1, a + i))\n ).reduceLeft(plus)\n\n println(ans)\n}\n", "language": "Scala", "metadata": {"date": 1594512855, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p04040.html", "problem_id": "p04040", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04040/input.txt", "sample_output_relpath": "derived/input_output/data/p04040/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04040/Scala/s176668279.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s176668279", "user_id": "u191819389"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val h, w, a, b = sc.nextInt()\n val mod = 1000000007\n\n def plus(a: Long, b: Long): Long = (a + b) % mod\n def times(a: Long, b: Long): Long = (a * b) % mod\n\n def pow(a: Long, n: Int, res: Long = 1): Long = {\n if (n == 0) {\n res\n } else if ((n&1) == 0) {\n pow(times(a,a), n >> 1, res)\n } else {\n pow(times(a,a), n >> 1, times(res,a))\n }\n }\n\n def inv(a: Long): Long = pow(a, mod-2)\n\n def initFactTable(n: Int): Array[Long] = {\n (1 to n).scanLeft(1L)(times(_,_)).toArray\n }\n\n val fact = initFactTable(h + w)\n\n def initInvFactTable(n: Int): Array[Long] = {\n (1 to n).scanRight(inv(fact(n)))(times(_,_)).toArray\n }\n\n val invFact = initInvFactTable(h + w)\n\n def comb(n: Int, k: Int): Long = {\n times(times(fact(n), invFact(k)), invFact(n-k))\n }\n\n val ans = (0 until (h - a).min(w - b)).map( i =>\n times(comb(b + h - a - 1, b + i), comb(a + w - b - 1, a + i))\n ).reduceLeft(plus)\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": "p04040", "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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1016, "cpu_time_ms": 709, "memory_kb": 73040}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s041380674", "group_id": "codeNet:p04040", "input_text": "import java.io._\nimport java.util.StringTokenizer\n\nimport scala.collection.mutable\nimport scala.util.Sorting\nimport math.{abs, max, min}\nimport scala.collection.mutable.{ArrayBuffer, ListBuffer}\nimport scala.reflect.ClassTag\n\nobject Main {\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n\n def solve(): Unit = {\n val sc = new InputReader(System.in)\n val H, W, A, B = sc.nextInt()\n\n val F = Array.ofDim[Long](H + W)\n F(0) = 1\n (1 until F.length) foreach { i =>\n F(i) = F(i - 1) * i % MOD\n }\n val Inv = Array.ofDim[Long](F.length)\n rep(F.length) { i =>\n Inv(i) = powMod(F(i).toInt, MOD - 2, MOD)\n }\n\n def comb(n: Int, k: Int): Long = {\n F(n) * Inv(n - k) % MOD * Inv(k) % MOD\n }\n\n var ans = 0L\n rep(W - B) { i =>\n val c1 = {\n val n = H - A - 1 + B + i\n val k = H - A - 1\n comb(n, k)\n }\n\n val c2 = {\n val n = A - 1 + W - B - 1 - i\n val k = A - 1\n comb(n, k)\n }\n ans = (ans + c1 * c2) % MOD\n }\n out.println(ans)\n }\n\n def main(args: Array[String]): Unit = {\n solve()\n out.flush()\n }\n\n def powMod(x: Int, n: Int, m: Int): Int = {\n def step(x: Long, n: Int, stack: Long): Long = {\n n match {\n case 0 => stack\n case _ => step(x * x % m, n / 2, if (n % 2 == 1) stack * x % m else stack)\n }\n }\n step(x, n, 1).toInt\n }\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = null\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next().toInt\n def nextLong(): Long = next().toLong\n def nextChar(): Char = next().charAt(0)\n }\n def rep(n: Int)(f: Int => Unit): Unit = {\n var i = 0\n while(i < n) { f(i); i += 1 }\n }\n def rep_r(n: Int)(f: Int => Unit): Unit = {\n var i = n - 1\n while(i >= 0) { f(i); i -= 1 }\n }\n\n def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n rep(n)(i => res(i) = f(i))\n res\n }\n\n implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {\n // todo Orderingだとboxing発生するので自作Orderを用意したい\n def maxByOpt[B: Ordering](f: A => B): Option[A] = {\n if (as.nonEmpty) Some(as.maxBy(f)) else None\n }\n\n def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {\n val map = mutable.Map.empty[K, ArrayBuffer[A]]\n rep(as.length)(i => map.getOrElseUpdate(f(as(i)), ArrayBuffer()) += as(i))\n map\n }\n\n def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {\n var sum = num.zero\n rep(as.length)(i => sum = num.plus(sum, f(as(i))))\n sum\n }\n\n def minByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {\n limit(f, ixRange)(cmp.lt)\n }\n\n def maxByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {\n limit(f, ixRange)(cmp.gt)\n }\n\n private def limit[B](f: A => B, ixRange: Range)(cmp: (B, B) => Boolean): (A, B) = {\n var limA = as(ixRange.head)\n var limB = f(limA)\n\n for (i <- ixRange.tail) {\n val a = as(i)\n val b = f(a)\n if (cmp(b, limB)) {\n limA = a\n limB = b\n }\n }\n (limA, limB)\n }\n }\n\n implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {\n def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {\n as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1532752503, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p04040.html", "problem_id": "p04040", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04040/input.txt", "sample_output_relpath": "derived/input_output/data/p04040/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04040/Scala/s041380674.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s041380674", "user_id": "u460609472"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.io._\nimport java.util.StringTokenizer\n\nimport scala.collection.mutable\nimport scala.util.Sorting\nimport math.{abs, max, min}\nimport scala.collection.mutable.{ArrayBuffer, ListBuffer}\nimport scala.reflect.ClassTag\n\nobject Main {\n val MOD = 1000000007\n val out = new PrintWriter(System.out)\n\n def solve(): Unit = {\n val sc = new InputReader(System.in)\n val H, W, A, B = sc.nextInt()\n\n val F = Array.ofDim[Long](H + W)\n F(0) = 1\n (1 until F.length) foreach { i =>\n F(i) = F(i - 1) * i % MOD\n }\n val Inv = Array.ofDim[Long](F.length)\n rep(F.length) { i =>\n Inv(i) = powMod(F(i).toInt, MOD - 2, MOD)\n }\n\n def comb(n: Int, k: Int): Long = {\n F(n) * Inv(n - k) % MOD * Inv(k) % MOD\n }\n\n var ans = 0L\n rep(W - B) { i =>\n val c1 = {\n val n = H - A - 1 + B + i\n val k = H - A - 1\n comb(n, k)\n }\n\n val c2 = {\n val n = A - 1 + W - B - 1 - i\n val k = A - 1\n comb(n, k)\n }\n ans = (ans + c1 * c2) % MOD\n }\n out.println(ans)\n }\n\n def main(args: Array[String]): Unit = {\n solve()\n out.flush()\n }\n\n def powMod(x: Int, n: Int, m: Int): Int = {\n def step(x: Long, n: Int, stack: Long): Long = {\n n match {\n case 0 => stack\n case _ => step(x * x % m, n / 2, if (n % 2 == 1) stack * x % m else stack)\n }\n }\n step(x, n, 1).toInt\n }\n\n class InputReader(val stream: InputStream) {\n private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n private var tokenizer: StringTokenizer = null\n\n def next(): String = {\n while (tokenizer == null || !tokenizer.hasMoreTokens)\n tokenizer = new StringTokenizer(reader.readLine)\n tokenizer.nextToken\n }\n\n def nextInt(): Int = next().toInt\n def nextLong(): Long = next().toLong\n def nextChar(): Char = next().charAt(0)\n }\n def rep(n: Int)(f: Int => Unit): Unit = {\n var i = 0\n while(i < n) { f(i); i += 1 }\n }\n def rep_r(n: Int)(f: Int => Unit): Unit = {\n var i = n - 1\n while(i >= 0) { f(i); i -= 1 }\n }\n\n def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {\n val res = Array.ofDim[A](n)\n rep(n)(i => res(i) = f(i))\n res\n }\n\n implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {\n // todo Orderingだとboxing発生するので自作Orderを用意したい\n def maxByOpt[B: Ordering](f: A => B): Option[A] = {\n if (as.nonEmpty) Some(as.maxBy(f)) else None\n }\n\n def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {\n val map = mutable.Map.empty[K, ArrayBuffer[A]]\n rep(as.length)(i => map.getOrElseUpdate(f(as(i)), ArrayBuffer()) += as(i))\n map\n }\n\n def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {\n var sum = num.zero\n rep(as.length)(i => sum = num.plus(sum, f(as(i))))\n sum\n }\n\n def minByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {\n limit(f, ixRange)(cmp.lt)\n }\n\n def maxByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {\n limit(f, ixRange)(cmp.gt)\n }\n\n private def limit[B](f: A => B, ixRange: Range)(cmp: (B, B) => Boolean): (A, B) = {\n var limA = as(ixRange.head)\n var limB = f(limA)\n\n for (i <- ixRange.tail) {\n val a = as(i)\n val b = f(a)\n if (cmp(b, limB)) {\n limA = a\n limB = b\n }\n }\n (limA, limB)\n }\n }\n\n implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {\n def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {\n as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))\n }\n }\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": "p04040", "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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3677, "cpu_time_ms": 483, "memory_kb": 29636}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s661595691", "group_id": "codeNet:p04043", "input_text": "object Main extends App {\n val l = io.StdIn.readLine()\n val nums = l.split(\" \").map((s) => s.toInt)\n if (nums.count((i) => i == 5) == 2 && nums.count((i) => i == 7) == 1 ) {\n println(\"YES\")\n } else {\n println(\"NO\")\n }\n}", "language": "Scala", "metadata": {"date": 1470456036, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s661595691.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s661595691", "user_id": "u726693690"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "object Main extends App {\n val l = io.StdIn.readLine()\n val nums = l.split(\" \").map((s) => s.toInt)\n if (nums.count((i) => i == 5) == 2 && nums.count((i) => i == 7) == 1 ) {\n println(\"YES\")\n } else {\n println(\"NO\")\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 674, "memory_kb": 21448}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s668010792", "group_id": "codeNet:p04045", "input_text": "object Main extends App {\n\n\n val sc = new java.util.Scanner(System.in)\n var fee, cols = sc.nextInt\n val xss = List.fill(cols)(sc.nextInt)\n var ten: List[Int] = List(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)\n var cash = 0\n var count = 0\n var n = 10000\n var flag = true\n\n for (i <- 0 to 9) {\n if (xss.contains(i)) {\n ten = ten.filter {\n _ != i\n }\n }\n }\n\n for (j <- 0 to 3) {\n n /= 10\n flag = true\n for (i <- 0 to 9) {\n if (ten.contains(fee / n + i) && flag && cash < fee) {\n cash += (fee / n + i) * n\n flag = false\n }\n }\n fee /= 10\n }\n\n print(cash)\n\n}\n", "language": "Scala", "metadata": {"date": 1585259853, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s668010792.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s668010792", "user_id": "u547865903"}, "prompt_components": {"gold_output": "2000\n", "input_to_evaluate": "object Main extends App {\n\n\n val sc = new java.util.Scanner(System.in)\n var fee, cols = sc.nextInt\n val xss = List.fill(cols)(sc.nextInt)\n var ten: List[Int] = List(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)\n var cash = 0\n var count = 0\n var n = 10000\n var flag = true\n\n for (i <- 0 to 9) {\n if (xss.contains(i)) {\n ten = ten.filter {\n _ != i\n }\n }\n }\n\n for (j <- 0 to 3) {\n n /= 10\n flag = true\n for (i <- 0 to 9) {\n if (ten.contains(fee / n + i) && flag && cash < fee) {\n cash += (fee / n + i) * n\n flag = false\n }\n }\n fee /= 10\n }\n\n print(cash)\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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 613, "cpu_time_ms": 342, "memory_kb": 25432}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s684623135", "group_id": "codeNet:p04047", "input_text": "object Main extends App {\n\n import scala.io.StdIn.{readInt, readLine}\n val n = readInt()\n val arr = readLine().trim.split(\" \").map(_.toInt)\n val sorted = arr.toList.sorted\n var ans = 0\n for (i <- 0 to (sorted.length - 1)) {\n if (i % 2 == 0) ans += sorted(i)\n }\n println(ans)\n\n}", "language": "Scala", "metadata": {"date": 1468718354, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/Scala/s684623135.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s684623135", "user_id": "u392294962"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main extends App {\n\n import scala.io.StdIn.{readInt, readLine}\n val n = readInt()\n val arr = readLine().trim.split(\" \").map(_.toInt)\n val sorted = arr.toList.sorted\n var ans = 0\n for (i <- 0 to (sorted.length - 1)) {\n if (i % 2 == 0) ans += sorted(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": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 288, "cpu_time_ms": 707, "memory_kb": 21568}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s702334918", "group_id": "codeNet:p04048", "input_text": "object Main extends App {\n\timport scala.math._\n\n\tval N = scala.io.StdIn.readLine.split(\" \").map(_.toLong)\n\n\tdef function(a: Long, b: Long): Long = {\n\t\tval aa = min(a,b)\n\t\tval bb = max(a,b)\n\t\t\n\t\tif(aa == 1L){\n\t\t\treturn 2L*bb -1L\n\t\t}else{\n\t\t\treturn 2L*aa + function(aa,bb-aa)\n\t\t}\n\t}\n\n\tprintln(N(0) + function(N(1), N(0)-N(1)))\n\n}", "language": "Scala", "metadata": {"date": 1512857787, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p04048.html", "problem_id": "p04048", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04048/input.txt", "sample_output_relpath": "derived/input_output/data/p04048/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04048/Scala/s702334918.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s702334918", "user_id": "u675876401"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "object Main extends App {\n\timport scala.math._\n\n\tval N = scala.io.StdIn.readLine.split(\" \").map(_.toLong)\n\n\tdef function(a: Long, b: Long): Long = {\n\t\tval aa = min(a,b)\n\t\tval bb = max(a,b)\n\t\t\n\t\tif(aa == 1L){\n\t\t\treturn 2L*bb -1L\n\t\t}else{\n\t\t\treturn 2L*aa + function(aa,bb-aa)\n\t\t}\n\t}\n\n\tprintln(N(0) + function(N(1), N(0)-N(1)))\n\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nSnuke is conducting an optical experiment using mirrors and his new invention, the rifle of Mysterious Light.\n\nThree mirrors of length N are set so that they form an equilateral triangle.\nLet the vertices of the triangle be a, b and c.\n\nInside the triangle, the rifle is placed at the point p on segment ab such that ap = X.\n(The size of the rifle is negligible.)\nNow, the rifle is about to fire a ray of Mysterious Light in the direction of bc.\n\nThe ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as \"ordinary\" light.\nThere is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!\nWhen the ray comes back to the rifle, the ray will be absorbed.\n\nThe following image shows the ray's trajectory where N = 5 and X = 2.\n\nIt can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of N and X.\nFind the total length of the ray's trajectory.\n\nConstraints\n\n2≦N≦10^{12}\n\n1≦X≦N-1\n\nN and X are integers.\n\nPartial Points\n\n300 points will be awarded for passing the test set satisfying N≦1000.\n\nAnother 200 points will be awarded for passing the test set without additional constraints.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN X\n\nOutput\n\nPrint the total length of the ray's trajectory.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n12\n\nRefer to the image in the Problem Statement section.\nThe total length of the trajectory is 2+3+2+2+1+1+1 = 12.", "sample_input": "5 2\n"}, "reference_outputs": ["12\n"], "source_document_id": "p04048", "source_text": "Score : 500 points\n\nProblem Statement\n\nSnuke is conducting an optical experiment using mirrors and his new invention, the rifle of Mysterious Light.\n\nThree mirrors of length N are set so that they form an equilateral triangle.\nLet the vertices of the triangle be a, b and c.\n\nInside the triangle, the rifle is placed at the point p on segment ab such that ap = X.\n(The size of the rifle is negligible.)\nNow, the rifle is about to fire a ray of Mysterious Light in the direction of bc.\n\nThe ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as \"ordinary\" light.\nThere is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!\nWhen the ray comes back to the rifle, the ray will be absorbed.\n\nThe following image shows the ray's trajectory where N = 5 and X = 2.\n\nIt can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of N and X.\nFind the total length of the ray's trajectory.\n\nConstraints\n\n2≦N≦10^{12}\n\n1≦X≦N-1\n\nN and X are integers.\n\nPartial Points\n\n300 points will be awarded for passing the test set satisfying N≦1000.\n\nAnother 200 points will be awarded for passing the test set without additional constraints.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN X\n\nOutput\n\nPrint the total length of the ray's trajectory.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n12\n\nRefer to the image in the Problem Statement section.\nThe total length of the trajectory is 2+3+2+2+1+1+1 = 12.", "split": "test_in_distribution", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 327, "cpu_time_ms": 374, "memory_kb": 27192}, "variant": "medium_resource"}