{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s402248184", "group_id": "codeNet:p00001", "input_text": "object Main extends App{\n io.Source.stdin.toList.map{_.toInt}.sorted.slice(0,3).foreach(println)\n}", "language": "Scala", "metadata": {"date": 1454499594, "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/s402248184.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s402248184", "user_id": "u359672528"}, "prompt_components": {"gold_output": "3776\n2848\n2840\n", "input_to_evaluate": "object Main extends App{\n io.Source.stdin.toList.map{_.toInt}.sorted.slice(0,3).foreach(println)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 99, "cpu_time_ms": 220, "memory_kb": 43884}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s691413812", "group_id": "codeNet:p00001", "input_text": "import scala.collection.mutable.ArrayBuffer\n\nobject Main extends App{\n val ary = ArrayBuffer[Int]()\n (1 to 10).foreach(i=> ary += io.StdIn.readInt)\n ary.sorted.slice(0,3).foreach(println)\n}", "language": "Scala", "metadata": {"date": 1454502003, "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/s691413812.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s691413812", "user_id": "u359672528"}, "prompt_components": {"gold_output": "3776\n2848\n2840\n", "input_to_evaluate": "import scala.collection.mutable.ArrayBuffer\n\nobject Main extends App{\n val ary = ArrayBuffer[Int]()\n (1 to 10).foreach(i=> ary += io.StdIn.readInt)\n ary.sorted.slice(0,3).foreach(println)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43768}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s002125288", "group_id": "codeNet:p00001", "input_text": "import scala.io.Source.stdin\n\nobject Main {\n def main(args: Array[String]) = {\n val it = for(i <- stdin.getLines()) yield i.toInt\n it.toList\n .sorted(Ordering[Int].reverse)\n .slice(0,3)\n .foreach(println)\n }\n}", "language": "Scala", "metadata": {"date": 1475999917, "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/s002125288.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s002125288", "user_id": "u508732591"}, "prompt_components": {"gold_output": "3776\n2848\n2840\n", "input_to_evaluate": "import scala.io.Source.stdin\n\nobject Main {\n def main(args: Array[String]) = {\n val it = for(i <- stdin.getLines()) yield i.toInt\n it.toList\n .sorted(Ordering[Int].reverse)\n .slice(0,3)\n .foreach(println)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 232, "cpu_time_ms": 230, "memory_kb": 43720}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s746066395", "group_id": "codeNet:p00001", "input_text": "import scala.io.Source.stdin\n\nobject Main {\n def main(args: Array[String]) = {\n val it = for(i <- stdin.getLines()) yield i.toInt\n it.toList\n .sorted\n .reverse\n .slice(0,3)\n .foreach(println)\n }\n}", "language": "Scala", "metadata": {"date": 1475999992, "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/s746066395.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s746066395", "user_id": "u508732591"}, "prompt_components": {"gold_output": "3776\n2848\n2840\n", "input_to_evaluate": "import scala.io.Source.stdin\n\nobject Main {\n def main(args: Array[String]) = {\n val it = for(i <- stdin.getLines()) yield i.toInt\n it.toList\n .sorted\n .reverse\n .slice(0,3)\n .foreach(println)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 43764}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s070573030", "group_id": "codeNet:p00001", "input_text": "object Main extends App{\n\n \tvar list = List[Int]()\n \tfor (i <- 1 to 10) {\n \t\tlist = io.StdIn.readLine().toInt :: list\n \t}\n\n \tlist = list.sorted.reverse\n\n \tprintln(list(0) + \"\\n\" + list(1) + \"\\n\" + list(2))\n}", "language": "Scala", "metadata": {"date": 1481037592, "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/s070573030.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s070573030", "user_id": "u918841551"}, "prompt_components": {"gold_output": "3776\n2848\n2840\n", "input_to_evaluate": "object Main extends App{\n\n \tvar list = List[Int]()\n \tfor (i <- 1 to 10) {\n \t\tlist = io.StdIn.readLine().toInt :: list\n \t}\n\n \tlist = list.sorted.reverse\n\n \tprintln(list(0) + \"\\n\" + list(1) + \"\\n\" + list(2))\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43696}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s613084409", "group_id": "codeNet:p00001", "input_text": "import scala.io.Source.stdin\n\nobject Main extends App{\n\tval i = stdin.getLines().map(_.toInt).toList.sorted\n\t\tprintln(0 to 2)\n}", "language": "Scala", "metadata": {"date": 1483691178, "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/s613084409.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s613084409", "user_id": "u996485583"}, "prompt_components": {"gold_output": "3776\n2848\n2840\n", "input_to_evaluate": "import scala.io.Source.stdin\n\nobject Main extends App{\n\tval i = stdin.getLines().map(_.toInt).toList.sorted\n\t\tprintln(0 to 2)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43676}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s923091448", "group_id": "codeNet:p00001", "input_text": "import scala.io.Source.stdin\n\nobject Main extends App{\n\tval i = stdin.getLines().map(_.toInt).toList.sorted.reverse.slice(0,3).foreach{println}\n}", "language": "Scala", "metadata": {"date": 1483693151, "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/s923091448.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s923091448", "user_id": "u996485583"}, "prompt_components": {"gold_output": "3776\n2848\n2840\n", "input_to_evaluate": "import scala.io.Source.stdin\n\nobject Main extends App{\n\tval i = stdin.getLines().map(_.toInt).toList.sorted.reverse.slice(0,3).foreach{println}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 250, "memory_kb": 43720}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s701879629", "group_id": "codeNet:p00002", "input_text": "import scala.io.Source.stdin\n\nobject Main {\n\tdef main (args: Array[String]) = {\n\t\tvar sum = io.StdIn.readLine()\n\t\twhile(sum != null) {\n\t\t\tstdin.getLines()map(_.split(\" \").map(_.toInt).sum.toString.length)\n\t\t\tsum = io.StdIn.readLine()\n\t\t}\n\t}\n}", "language": "Scala", "metadata": {"date": 1487124920, "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/s701879629.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s701879629", "user_id": "u996485583"}, "prompt_components": {"gold_output": "2\n3\n4\n", "input_to_evaluate": "import scala.io.Source.stdin\n\nobject Main {\n\tdef main (args: Array[String]) = {\n\t\tvar sum = io.StdIn.readLine()\n\t\twhile(sum != null) {\n\t\t\tstdin.getLines()map(_.split(\" \").map(_.toInt).sum.toString.length)\n\t\t\tsum = io.StdIn.readLine()\n\t\t}\n\t}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 220, "memory_kb": 45332}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s965034550", "group_id": "codeNet:p00004", "input_text": "import java.util.Scanner\n\nimport scala.math.BigDecimal.RoundingMode._\nobject Main extends App {\n\n val sc = new Scanner(System.in)\n while(sc.hasNext){\n val line = sc.nextLine()\n val n = line.split(\" \").map {_.toInt}\n val a = n(0)\n val b = n(1)\n val c = n(2)\n val d = n(3)\n val e = n(4)\n val f = n(5)\n\n val x :BigDecimal = BigDecimal((b*f-e*c) / (b*d-a*e)).setScale(3, HALF_UP)\n val y :BigDecimal = ((c - a * x) / b).setScale(3, HALF_UP)\n\n println(s\"$x $y\")\n }\n}", "language": "Scala", "metadata": {"date": 1454679801, "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/s965034550.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s965034550", "user_id": "u359672528"}, "prompt_components": {"gold_output": "-1.000 2.000\n1.000 4.000\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.math.BigDecimal.RoundingMode._\nobject Main extends App {\n\n val sc = new Scanner(System.in)\n while(sc.hasNext){\n val line = sc.nextLine()\n val n = line.split(\" \").map {_.toInt}\n val a = n(0)\n val b = n(1)\n val c = n(2)\n val d = n(3)\n val e = n(4)\n val f = n(5)\n\n val x :BigDecimal = BigDecimal((b*f-e*c) / (b*d-a*e)).setScale(3, HALF_UP)\n val y :BigDecimal = ((c - a * x) / b).setScale(3, HALF_UP)\n\n println(s\"$x $y\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 260, "memory_kb": 45340}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s214427797", "group_id": "codeNet:p00004", "input_text": "object Main {\n def main(args: Array[String]) = {\n val in = io.Source.stdin.getLines.map(_.split(\" \").map(_.toDouble))\n in.foreach(x => println(\"%.3f %.3f\".format((x(2)*x(4)-x(1)*x(5))/(x(0)*x(4)-x(1)*x(3))+0, (x(0)*x(5)-x(2)*x(3))/(x(0)*x(4)-x(1)*x(3))+0)))\n }\n}", "language": "Scala", "metadata": {"date": 1481975751, "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/s214427797.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s214427797", "user_id": "u475394465"}, "prompt_components": {"gold_output": "-1.000 2.000\n1.000 4.000\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]) = {\n val in = io.Source.stdin.getLines.map(_.split(\" \").map(_.toDouble))\n in.foreach(x => println(\"%.3f %.3f\".format((x(2)*x(4)-x(1)*x(5))/(x(0)*x(4)-x(1)*x(3))+0, (x(0)*x(5)-x(2)*x(3))/(x(0)*x(4)-x(1)*x(3))+0)))\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 282, "cpu_time_ms": 240, "memory_kb": 44064}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s740623311", "group_id": "codeNet:p00004", "input_text": "import scala.io.StdIn._\nimport scala.annotation.tailrec\n\nobject Main {\n def main(args: Array[String]): Unit = { \n digit(readLine().split(\" \").map(_.toDouble))\n } \n\n @tailrec\n def digit(n: Seq[Double]): Unit = {\n val x: Double = round((n(1)*n(5) - n(4)*n(2)) / (n(1)*n(3) - n(0)*n(4)))\n val y: Double = round((n(0)*n(5) - n(2)*n(3)) / (n(0)*n(4) - n(1)*n(3)))\n println(f\"$x%.3f\" + \" \" + f\"$y%.3f\")\n val next: String = readLine()\n if(next == null) Unit else digit(next.split(\" \").map(_.toDouble))\n }\n\n def round(n: Double): Double = Math.round(n * 1000) / 1000\n}", "language": "Scala", "metadata": {"date": 1507450992, "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/s740623311.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s740623311", "user_id": "u203887348"}, "prompt_components": {"gold_output": "-1.000 2.000\n1.000 4.000\n", "input_to_evaluate": "import scala.io.StdIn._\nimport scala.annotation.tailrec\n\nobject Main {\n def main(args: Array[String]): Unit = { \n digit(readLine().split(\" \").map(_.toDouble))\n } \n\n @tailrec\n def digit(n: Seq[Double]): Unit = {\n val x: Double = round((n(1)*n(5) - n(4)*n(2)) / (n(1)*n(3) - n(0)*n(4)))\n val y: Double = round((n(0)*n(5) - n(2)*n(3)) / (n(0)*n(4) - n(1)*n(3)))\n println(f\"$x%.3f\" + \" \" + f\"$y%.3f\")\n val next: String = readLine()\n if(next == null) Unit else digit(next.split(\" \").map(_.toDouble))\n }\n\n def round(n: Double): Double = Math.round(n * 1000) / 1000\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 250, "memory_kb": 44088}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s043079775", "group_id": "codeNet:p00004", "input_text": "import scala.io.StdIn._\nimport scala.annotation.tailrec\n\nobject Main {\n def main(args: Array[String]): Unit = { \n digit(readLine().split(\" \").map(_.toDouble))\n } \n\n @tailrec\n def digit(n: Seq[Double]): Unit = {\n val x: Double = zero((n(1) * n(5) - n(4) * n(2)) / n(1) * n(3) - n(0) * n(4))\n val y: Double = zero((n(2) - n(0) * x) / n(1))\n println(f\"$x%.3f $y%.3f\")\n val next: String = readLine()\n if(next == null) Unit else digit(next.split(\" \").map(_.toDouble))\n }\n\n def zero(n: Double): Double = if(n == -0) 0 else n\n}", "language": "Scala", "metadata": {"date": 1507453239, "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/s043079775.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s043079775", "user_id": "u203887348"}, "prompt_components": {"gold_output": "-1.000 2.000\n1.000 4.000\n", "input_to_evaluate": "import scala.io.StdIn._\nimport scala.annotation.tailrec\n\nobject Main {\n def main(args: Array[String]): Unit = { \n digit(readLine().split(\" \").map(_.toDouble))\n } \n\n @tailrec\n def digit(n: Seq[Double]): Unit = {\n val x: Double = zero((n(1) * n(5) - n(4) * n(2)) / n(1) * n(3) - n(0) * n(4))\n val y: Double = zero((n(2) - n(0) * x) / n(1))\n println(f\"$x%.3f $y%.3f\")\n val next: String = readLine()\n if(next == null) Unit else digit(next.split(\" \").map(_.toDouble))\n }\n\n def zero(n: Double): Double = if(n == -0) 0 else 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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 44104}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s131991728", "group_id": "codeNet:p00005", "input_text": "import scala.io.Source.stdin\n\nobject Main extends App {\n def gcd(m:Long,n:Long):Long = if(n==0) m else gcd(n, m % n)\n\n for(s <- stdin.getLines.map(_.split(\" \").map(_.toLong))) {\n val g = gcd(s(0),s(1))\n println(g + \" \" + (s(0)/g)*s(1))\n }\n}", "language": "Scala", "metadata": {"date": 1483864813, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00005.html", "problem_id": "p00005", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00005/input.txt", "sample_output_relpath": "derived/input_output/data/p00005/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00005/Scala/s131991728.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s131991728", "user_id": "u508732591"}, "prompt_components": {"gold_output": "2 24\n10000000 150000000\n", "input_to_evaluate": "import scala.io.Source.stdin\n\nobject Main extends App {\n def gcd(m:Long,n:Long):Long = if(n==0) m else gcd(n, m % n)\n\n for(s <- stdin.getLines.map(_.split(\" \").map(_.toLong))) {\n val g = gcd(s(0),s(1))\n println(g + \" \" + (s(0)/g)*s(1))\n }\n}", "problem_context": "GCD and LCM\n\nWrite a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given a and b.\n\nInput\n\nInput consists of several data sets. Each data set contains a and b separated by a single space in a line. The input terminates with EOF.\n\nConstraints\n\n0 < a, b ≤ 2,000,000,000\n\nLCM(a, b) ≤ 2,000,000,000\n\nThe number of data sets ≤ 50\n\nOutput\n\nFor each data set, print GCD and LCM separated by a single space in a line.\n\nSample Input\n\n8 6\n50000000 30000000\n\nOutput for the Sample Input\n\n2 24\n10000000 150000000", "sample_input": "8 6\n50000000 30000000\n"}, "reference_outputs": ["2 24\n10000000 150000000\n"], "source_document_id": "p00005", "source_text": "GCD and LCM\n\nWrite a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given a and b.\n\nInput\n\nInput consists of several data sets. Each data set contains a and b separated by a single space in a line. The input terminates with EOF.\n\nConstraints\n\n0 < a, b ≤ 2,000,000,000\n\nLCM(a, b) ≤ 2,000,000,000\n\nThe number of data sets ≤ 50\n\nOutput\n\nFor each data set, print GCD and LCM separated by a single space in a line.\n\nSample Input\n\n8 6\n50000000 30000000\n\nOutput for the Sample Input\n\n2 24\n10000000 150000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 257, "cpu_time_ms": 240, "memory_kb": 43524}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s464791733", "group_id": "codeNet:p00005", "input_text": "import scala.io.Source.stdin\n\nobject Main extends App {\n def gcd(m:Long,n:Long):Long = if(n==0) m else gcd(n, m % n)\n\n println {\n {\n for(s <- stdin.getLines.map(_.split(\" \").map(_.toLong))) yield {\n val g = gcd(s(0),s(1))\n g + \" \" + (s(0)/g)*s(1)\n }\n }.mkString(\"\\n\")\n }\n}", "language": "Scala", "metadata": {"date": 1483865175, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00005.html", "problem_id": "p00005", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00005/input.txt", "sample_output_relpath": "derived/input_output/data/p00005/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00005/Scala/s464791733.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s464791733", "user_id": "u508732591"}, "prompt_components": {"gold_output": "2 24\n10000000 150000000\n", "input_to_evaluate": "import scala.io.Source.stdin\n\nobject Main extends App {\n def gcd(m:Long,n:Long):Long = if(n==0) m else gcd(n, m % n)\n\n println {\n {\n for(s <- stdin.getLines.map(_.split(\" \").map(_.toLong))) yield {\n val g = gcd(s(0),s(1))\n g + \" \" + (s(0)/g)*s(1)\n }\n }.mkString(\"\\n\")\n }\n}", "problem_context": "GCD and LCM\n\nWrite a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given a and b.\n\nInput\n\nInput consists of several data sets. Each data set contains a and b separated by a single space in a line. The input terminates with EOF.\n\nConstraints\n\n0 < a, b ≤ 2,000,000,000\n\nLCM(a, b) ≤ 2,000,000,000\n\nThe number of data sets ≤ 50\n\nOutput\n\nFor each data set, print GCD and LCM separated by a single space in a line.\n\nSample Input\n\n8 6\n50000000 30000000\n\nOutput for the Sample Input\n\n2 24\n10000000 150000000", "sample_input": "8 6\n50000000 30000000\n"}, "reference_outputs": ["2 24\n10000000 150000000\n"], "source_document_id": "p00005", "source_text": "GCD and LCM\n\nWrite a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given a and b.\n\nInput\n\nInput consists of several data sets. Each data set contains a and b separated by a single space in a line. The input terminates with EOF.\n\nConstraints\n\n0 < a, b ≤ 2,000,000,000\n\nLCM(a, b) ≤ 2,000,000,000\n\nThe number of data sets ≤ 50\n\nOutput\n\nFor each data set, print GCD and LCM separated by a single space in a line.\n\nSample Input\n\n8 6\n50000000 30000000\n\nOutput for the Sample Input\n\n2 24\n10000000 150000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43784}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s271938216", "group_id": "codeNet:p00007", "input_text": "import scala.io.StdIn.readInt\n\nobject Main {\n def round(n:Double) = {\n val m = n % 1000\n if(m>0) n-m+1000 else n\n }\n\n def getDebt(n:Int,m:Double):Int = if(n==0) m.toInt else getDebt(n-1,round(m*1.05))\n\n def main(args:Array[String]) = {\n val y = 100000.0\n val ratio = 1.05\n val n = readInt\n\n println(getDebt(n,y))\n }\n}", "language": "Scala", "metadata": {"date": 1483866397, "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/s271938216.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s271938216", "user_id": "u508732591"}, "prompt_components": {"gold_output": "130000\n", "input_to_evaluate": "import scala.io.StdIn.readInt\n\nobject Main {\n def round(n:Double) = {\n val m = n % 1000\n if(m>0) n-m+1000 else n\n }\n\n def getDebt(n:Int,m:Double):Int = if(n==0) m.toInt else getDebt(n-1,round(m*1.05))\n\n def main(args:Array[String]) = {\n val y = 100000.0\n val ratio = 1.05\n val n = readInt\n\n println(getDebt(n,y))\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43464}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s052795320", "group_id": "codeNet:p00007", "input_text": "import scala.io.StdIn.readInt\n\nobject Main {\n def round(n:Double) = {\n val m = n % 1000\n if(m>0) n-m+1000 else n\n }\n\n def getDebt(n:Int,m:Double):Int = if(n==0) m.toInt else getDebt(n-1,round(m*1.05))\n\n def main(args:Array[String]) = println(getDebt(readInt,100000))\n}", "language": "Scala", "metadata": {"date": 1483866576, "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/s052795320.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s052795320", "user_id": "u508732591"}, "prompt_components": {"gold_output": "130000\n", "input_to_evaluate": "import scala.io.StdIn.readInt\n\nobject Main {\n def round(n:Double) = {\n val m = n % 1000\n if(m>0) n-m+1000 else n\n }\n\n def getDebt(n:Int,m:Double):Int = if(n==0) m.toInt else getDebt(n-1,round(m*1.05))\n\n def main(args:Array[String]) = println(getDebt(readInt,100000))\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43540}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s608231604", "group_id": "codeNet:p00007", "input_text": "/**\n * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0007\n */\nobject Main {\n def main(args: Array[String]): Unit = {\n val n = io.StdIn.readInt()\n println(calc(n, 100000))\n }\n\n def calc(week: Int, balance: Int): Int = {\n val Rate = BigDecimal(1.05)\n if (week > 0) {\n calc(week - 1, (balance * Rate).setScale(-3, BigDecimal.RoundingMode.UP).toInt)\n } else {\n balance\n }\n }\n}", "language": "Scala", "metadata": {"date": 1497681565, "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/s608231604.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s608231604", "user_id": "u757244973"}, "prompt_components": {"gold_output": "130000\n", "input_to_evaluate": "/**\n * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0007\n */\nobject Main {\n def main(args: Array[String]): Unit = {\n val n = io.StdIn.readInt()\n println(calc(n, 100000))\n }\n\n def calc(week: Int, balance: Int): Int = {\n val Rate = BigDecimal(1.05)\n if (week > 0) {\n calc(week - 1, (balance * Rate).setScale(-3, BigDecimal.RoundingMode.UP).toInt)\n } else {\n balance\n }\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43608}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s250109173", "group_id": "codeNet:p00009", "input_text": "import scala.io.StdIn._\nimport scala.annotation.tailrec\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 (cmpsts, sqrtLmtNdx) = (new Array[Int]((top >>> 5) + 1), (Math.sqrt(n).toInt - 3) / 2)\n\n def isCmpst(ci: Int): Boolean = (cmpsts(ci >>> 5) & (1 << (ci & 31))) != 0\n def setCmpst(ci: Int): Unit = cmpsts(ci >>> 5) |= 1 << (ci & 31)\n\n @tailrec\n private def cull(cmpstId: Int, p: Int): Unit = {\n if(cmpstId <= top){\n setCmpst(cmpstId)\n cull(cmpstId + p, p)\n }\n }\n\n @tailrec\n private def get(cndId: Int): Unit = {\n if(cndId <= sqrtLmtNdx){\n if(!isCmpst(cndId)){\n val p = 2 * cndId + 3\n cull((p * p - 3) >>> 1, p)\n }\n get(cndId + 1)\n }\n }\n\n @tailrec\n private def next(cndId: Int): Int =\n if ((cndId > top) || !isCmpst(cndId)) 2 * cndId + 3 else next(cndId + 1)\n\n def exec: Iterator[Int] = {\n get(0)\n Iterator.single(2) ++ Iterator.iterate(3)(p => next((p - 1) >>> 1)).takeWhile(_ <= n)\n }\n }\n\n @tailrec\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": 1435756271, "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/s250109173.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s250109173", "user_id": "u047988051"}, "prompt_components": {"gold_output": "4\n2\n5\n", "input_to_evaluate": "import scala.io.StdIn._\nimport scala.annotation.tailrec\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 (cmpsts, sqrtLmtNdx) = (new Array[Int]((top >>> 5) + 1), (Math.sqrt(n).toInt - 3) / 2)\n\n def isCmpst(ci: Int): Boolean = (cmpsts(ci >>> 5) & (1 << (ci & 31))) != 0\n def setCmpst(ci: Int): Unit = cmpsts(ci >>> 5) |= 1 << (ci & 31)\n\n @tailrec\n private def cull(cmpstId: Int, p: Int): Unit = {\n if(cmpstId <= top){\n setCmpst(cmpstId)\n cull(cmpstId + p, p)\n }\n }\n\n @tailrec\n private def get(cndId: Int): Unit = {\n if(cndId <= sqrtLmtNdx){\n if(!isCmpst(cndId)){\n val p = 2 * cndId + 3\n cull((p * p - 3) >>> 1, p)\n }\n get(cndId + 1)\n }\n }\n\n @tailrec\n private def next(cndId: Int): Int =\n if ((cndId > top) || !isCmpst(cndId)) 2 * cndId + 3 else next(cndId + 1)\n\n def exec: Iterator[Int] = {\n get(0)\n Iterator.single(2) ++ Iterator.iterate(3)(p => next((p - 1) >>> 1)).takeWhile(_ <= n)\n }\n }\n\n @tailrec\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1366, "cpu_time_ms": 360, "memory_kb": 65048}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s707563191", "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{\n i <- 3 to Math.sqrt(n).toInt+1 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 for(i<-stdin.getLines) {\n println(p.take(i.toInt).sum)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1483870379, "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/s707563191.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Memory Limit Exceeded", "submission_id": "s707563191", "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{\n i <- 3 to Math.sqrt(n).toInt+1 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 for(i<-stdin.getLines) {\n println(p.take(i.toInt).sum)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 460, "memory_kb": 349020}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s342412049", "group_id": "codeNet:p00009", "input_text": "/**\n * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009\n * Prime Number\n */\nobject Main {\n def main(args: Array[String]): Unit = {\n val primes = Primes(999999)\n Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null).map(_.toInt)\n .map(n => primes.count(p => p <= n))\n .foreach(println)\n }\n\n object Primes {\n\n def isPrime(n: Int): Boolean = {\n n match {\n case 2 | 3 => true\n case _ => !(2 to n).takeWhile(p => p * p <= n).exists(n % _ == 0)\n }\n }\n\n def apply(n: Int): Seq[Int] = {\n 2 +: (3 to n by 2).filter(isPrime)\n }\n\n }\n\n}", "language": "Scala", "metadata": {"date": 1497799966, "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/s342412049.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s342412049", "user_id": "u757244973"}, "prompt_components": {"gold_output": "4\n2\n5\n", "input_to_evaluate": "/**\n * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009\n * Prime Number\n */\nobject Main {\n def main(args: Array[String]): Unit = {\n val primes = Primes(999999)\n Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null).map(_.toInt)\n .map(n => primes.count(p => p <= n))\n .foreach(println)\n }\n\n object Primes {\n\n def isPrime(n: Int): Boolean = {\n n match {\n case 2 | 3 => true\n case _ => !(2 to n).takeWhile(p => p * p <= n).exists(n % _ == 0)\n }\n }\n\n def apply(n: Int): Seq[Int] = {\n 2 +: (3 to n by 2).filter(isPrime)\n }\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 610, "cpu_time_ms": 860, "memory_kb": 98076}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s572425232", "group_id": "codeNet:p00010", "input_text": "import scala.io.StdIn.{readLine,readInt}\nimport scala.math.BigDecimal\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-m(0))*(x-m(0))+(y-m(1))*(y-m(1))))\n }\n }\n}", "language": "Scala", "metadata": {"date": 1484041294, "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/s572425232.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s572425232", "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 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-m(0))*(x-m(0))+(y-m(1))*(y-m(1))))\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 731, "cpu_time_ms": 240, "memory_kb": 44160}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s417076916", "group_id": "codeNet:p00012", "input_text": "object Main extends App {\n def crossProduct(p1: (Double, Double, Double),\n p2: (Double, Double, Double)): (Double, Double, Double) = {\n (\n p1._3 * p2._2 - p1._2 * p2._3,\n p1._1 * p2._3 - p1._3 * p2._1,\n p1._2 * p2._1 - p1._1 * p2._2\n )\n }\n\n Stream\n .continually(readLine)\n .takeWhile(_ != null)\n .map(_.split(\" \").map(_.toDouble) match {\n case Array(x1, y1, x2, y2, x3, y3, xp, yp) =>\n val (ab, ap, bc, bp, ca, cp) = (\n (x2 - x1, y2 - y1, 0.0),\n (xp - x1, yp - y1, 0.0),\n (x3 - x2, y3 - y2, 0.0),\n (xp - x2, yp - y2, 0.0),\n (x1 - x3, y1 - y3, 0.0),\n (xp - x3, yp - y3, 0.0)\n )\n Seq((ab, ap), (bc, bp), (ca, cp)).map { case (p1, p2) => crossProduct(p1, p2) }\n })\n .map(_.map(_._3 > 0))\n .map(zIsPositives => zIsPositives.forall(_ == zIsPositives.head))\n .foreach(isInner => println(if (isInner) \"YES\" else \"NO\"))\n}\n\n", "language": "Scala", "metadata": {"date": 1529799963, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00012.html", "problem_id": "p00012", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00012/input.txt", "sample_output_relpath": "derived/input_output/data/p00012/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00012/Scala/s417076916.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s417076916", "user_id": "u927478431"}, "prompt_components": {"gold_output": "YES\nNO\n", "input_to_evaluate": "object Main extends App {\n def crossProduct(p1: (Double, Double, Double),\n p2: (Double, Double, Double)): (Double, Double, Double) = {\n (\n p1._3 * p2._2 - p1._2 * p2._3,\n p1._1 * p2._3 - p1._3 * p2._1,\n p1._2 * p2._1 - p1._1 * p2._2\n )\n }\n\n Stream\n .continually(readLine)\n .takeWhile(_ != null)\n .map(_.split(\" \").map(_.toDouble) match {\n case Array(x1, y1, x2, y2, x3, y3, xp, yp) =>\n val (ab, ap, bc, bp, ca, cp) = (\n (x2 - x1, y2 - y1, 0.0),\n (xp - x1, yp - y1, 0.0),\n (x3 - x2, y3 - y2, 0.0),\n (xp - x2, yp - y2, 0.0),\n (x1 - x3, y1 - y3, 0.0),\n (xp - x3, yp - y3, 0.0)\n )\n Seq((ab, ap), (bc, bp), (ca, cp)).map { case (p1, p2) => crossProduct(p1, p2) }\n })\n .map(_.map(_._3 > 0))\n .map(zIsPositives => zIsPositives.forall(_ == zIsPositives.head))\n .foreach(isInner => println(if (isInner) \"YES\" else \"NO\"))\n}\n\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nA Point in a Triangle\n\nThere is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.\n\nWrite a program which prints \"YES\" if a point $P$ $(x_p, y_p)$ is in the triangle and \"NO\" if not.\n\nInput\n\nInput consists of several datasets. Each dataset consists of:\n\n$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$\n\nAll the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.\n\nConstraints\n\nYou can assume that:\n\n$ -100 \\leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \\leq 100$\n\n1.0 $\\leq$ Length of each side of a tringle\n\n0.001 $\\leq$ Distance between $P$ and each side of a triangle\n\nOutput\n\nFor each dataset, print \"YES\" or \"NO\" in a line.\n\nSample Input\n\n0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5\n0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0\n\nOutput for the Sample Input\n\nYES\nNO", "sample_input": "0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5\n0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0\n"}, "reference_outputs": ["YES\nNO\n"], "source_document_id": "p00012", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nA Point in a Triangle\n\nThere is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.\n\nWrite a program which prints \"YES\" if a point $P$ $(x_p, y_p)$ is in the triangle and \"NO\" if not.\n\nInput\n\nInput consists of several datasets. Each dataset consists of:\n\n$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$\n\nAll the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.\n\nConstraints\n\nYou can assume that:\n\n$ -100 \\leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \\leq 100$\n\n1.0 $\\leq$ Length of each side of a tringle\n\n0.001 $\\leq$ Distance between $P$ and each side of a triangle\n\nOutput\n\nFor each dataset, print \"YES\" or \"NO\" in a line.\n\nSample Input\n\n0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5\n0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0\n\nOutput for the Sample Input\n\nYES\nNO", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 958, "cpu_time_ms": 250, "memory_kb": 44704}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s530720346", "group_id": "codeNet:p00013", "input_text": "import scala.io.Source.stdin\n\nobject Main {\n def switchingRailroadCars(t: Iterator[String]): Vector[Int] = {\n def loop(n: Int,\n switchList: Vector[Int] = Vector(),\n exitList: Vector[Int] = Vector()): Vector[Int] = {\n if (t.nonEmpty) {\n n match {\n case 0 => loop(t.next.toInt, switchList.init, exitList :+ switchList.last)\n case _ => loop(t.next.toInt, switchList :+ n, exitList)\n }\n } else exitList\n }\n\n loop(t.next.toInt)\n }\n\n def main(args: Array[String]): Unit = {\n val trains = stdin.getLines\n switchingRailroadCars(trains).foreach(println)\n }\n}", "language": "Scala", "metadata": {"date": 1460091844, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00013.html", "problem_id": "p00013", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00013/input.txt", "sample_output_relpath": "derived/input_output/data/p00013/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00013/Scala/s530720346.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s530720346", "user_id": "u123244675"}, "prompt_components": {"gold_output": "6\n10\n8\n1\n", "input_to_evaluate": "import scala.io.Source.stdin\n\nobject Main {\n def switchingRailroadCars(t: Iterator[String]): Vector[Int] = {\n def loop(n: Int,\n switchList: Vector[Int] = Vector(),\n exitList: Vector[Int] = Vector()): Vector[Int] = {\n if (t.nonEmpty) {\n n match {\n case 0 => loop(t.next.toInt, switchList.init, exitList :+ switchList.last)\n case _ => loop(t.next.toInt, switchList :+ n, exitList)\n }\n } else exitList\n }\n\n loop(t.next.toInt)\n }\n\n def main(args: Array[String]): Unit = {\n val trains = stdin.getLines\n switchingRailroadCars(trains).foreach(println)\n }\n}", "problem_context": "Switching Railroad Cars\n\nThis figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks.\n\nWe can simulate the movement (comings and goings) of the cars as follow:\n\nAn entry of a car is represented by its number.\n\nAn exit of a car is represented by 0\n\nFor example, a sequence\n\n1\n6\n0\n8\n10\n\ndemonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter.\n\nWrite a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks.\n\nInput\n\ncar number\ncar number or 0\ncar number or 0\n.\n.\n.\ncar number or 0\n\nThe number of input lines is less than or equal to 100.\n\nOutput\n\nFor each 0, print the car number.\n\nSample Input\n\n1\n6\n0\n8\n10\n0\n0\n0\n\nOutput for the Sample Input\n\n6\n10\n8\n1", "sample_input": "1\n6\n0\n8\n10\n0\n0\n0\n"}, "reference_outputs": ["6\n10\n8\n1\n"], "source_document_id": "p00013", "source_text": "Switching Railroad Cars\n\nThis figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks.\n\nWe can simulate the movement (comings and goings) of the cars as follow:\n\nAn entry of a car is represented by its number.\n\nAn exit of a car is represented by 0\n\nFor example, a sequence\n\n1\n6\n0\n8\n10\n\ndemonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter.\n\nWrite a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks.\n\nInput\n\ncar number\ncar number or 0\ncar number or 0\n.\n.\n.\ncar number or 0\n\nThe number of input lines is less than or equal to 100.\n\nOutput\n\nFor each 0, print the car number.\n\nSample Input\n\n1\n6\n0\n8\n10\n0\n0\n0\n\nOutput for the Sample Input\n\n6\n10\n8\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 620, "cpu_time_ms": 230, "memory_kb": 43588}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s132656315", "group_id": "codeNet:p00014", "input_text": "object Main extends App {\n\n Stream.continually(readLine)\n .takeWhile(_ != null)\n .map(_.toInt)\n .map(area(x => x * x))\n .foreach(println)\n\n def area(f: Long => Long)(d: Int): Long = {\n Range(0, 600, d).map(dd => d * f(dd.toLong)).sum\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1529939578, "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/s132656315.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s132656315", "user_id": "u927478431"}, "prompt_components": {"gold_output": "68440000\n70210000\n", "input_to_evaluate": "object Main extends App {\n\n Stream.continually(readLine)\n .takeWhile(_ != null)\n .map(_.toInt)\n .map(area(x => x * x))\n .foreach(println)\n\n def area(f: Long => Long)(d: Int): Long = {\n Range(0, 600, d).map(dd => d * f(dd.toLong)).sum\n }\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 44368}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s814419801", "group_id": "codeNet:p00017", "input_text": "object Main {\n\tdef nextAlphabet(c: Char) : Char = {\n\t val list = \"abcdefghijklmnopqrstuvwxyz\".toList\n\t val pos = list.indexOf(c)\n\t if(list(pos) == 'z') return list(0)\n\t else return list(pos+1)\n\t}\n\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n while(sc.hasNext){\n\t val a = sc.nextLine\n\t var c = a.toCharArray\n for(i <- 0 until 26){\n for(j <- 0 until c.length){\n if (c(j) != ' ' && c(j) != '.'){\n c(j) = nextAlphabet(c(j))\n }\n }\n val s = new String(c)\n if(s.contains(\"the\") || s.contains(\"this\") || s.contains(\"that\")) println(s)\n }\n \t}\n }\n}", "language": "Scala", "metadata": {"date": 1448107471, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00017.html", "problem_id": "p00017", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00017/input.txt", "sample_output_relpath": "derived/input_output/data/p00017/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00017/Scala/s814419801.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s814419801", "user_id": "u271453140"}, "prompt_components": {"gold_output": "this is the picture that i took in the trip.\n", "input_to_evaluate": "object Main {\n\tdef nextAlphabet(c: Char) : Char = {\n\t val list = \"abcdefghijklmnopqrstuvwxyz\".toList\n\t val pos = list.indexOf(c)\n\t if(list(pos) == 'z') return list(0)\n\t else return list(pos+1)\n\t}\n\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n while(sc.hasNext){\n\t val a = sc.nextLine\n\t var c = a.toCharArray\n for(i <- 0 until 26){\n for(j <- 0 until c.length){\n if (c(j) != ' ' && c(j) != '.'){\n c(j) = nextAlphabet(c(j))\n }\n }\n val s = new String(c)\n if(s.contains(\"the\") || s.contains(\"this\") || s.contains(\"that\")) println(s)\n }\n \t}\n }\n}", "problem_context": "Caesar Cipher\n\nIn cryptography, Caesar cipher is one of the simplest and most widely known encryption method. Caesar cipher is a type of substitution cipher in which each letter in the text is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 1, 'a' would be replaced by 'b', 'b' would become 'c', 'y' would become 'z', 'z' would become 'a', and so on. In that case, a text:\n\nthis is a pen\n\nis would become:\n\nuijt jt b qfo\n\nWrite a program which reads a text encrypted by Caesar Chipher and prints the corresponding decoded text. The number of shift is secret and it depends on datasets, but you can assume that the decoded text includes any of the following words: \"the\", \"this\", or \"that\".\n\nInput\n\nInput consists of several datasets. Each dataset consists of texts in a line. Input ends with EOF. The text consists of lower-case letters, periods, space, and end-of-lines. Only the letters have been encrypted. A line consists of at most 80 characters.\n\nYou may assume that you can create one decoded text which includes any of \"the\", \"this\", or \"that\" from the given input text.\n\nThe number of datasets is less than or equal to 20.\n\nOutput\n\nPrint decoded texts in a line.\n\nSample Input\n\nxlmw mw xli tmgxyvi xlex m xsso mr xli xvmt.\n\nOutput for the Sample Input\n\nthis is the picture that i took in the trip.", "sample_input": "xlmw mw xli tmgxyvi xlex m xsso mr xli xvmt.\n"}, "reference_outputs": ["this is the picture that i took in the trip.\n"], "source_document_id": "p00017", "source_text": "Caesar Cipher\n\nIn cryptography, Caesar cipher is one of the simplest and most widely known encryption method. Caesar cipher is a type of substitution cipher in which each letter in the text is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 1, 'a' would be replaced by 'b', 'b' would become 'c', 'y' would become 'z', 'z' would become 'a', and so on. In that case, a text:\n\nthis is a pen\n\nis would become:\n\nuijt jt b qfo\n\nWrite a program which reads a text encrypted by Caesar Chipher and prints the corresponding decoded text. The number of shift is secret and it depends on datasets, but you can assume that the decoded text includes any of the following words: \"the\", \"this\", or \"that\".\n\nInput\n\nInput consists of several datasets. Each dataset consists of texts in a line. Input ends with EOF. The text consists of lower-case letters, periods, space, and end-of-lines. Only the letters have been encrypted. A line consists of at most 80 characters.\n\nYou may assume that you can create one decoded text which includes any of \"the\", \"this\", or \"that\" from the given input text.\n\nThe number of datasets is less than or equal to 20.\n\nOutput\n\nPrint decoded texts in a line.\n\nSample Input\n\nxlmw mw xli tmgxyvi xlex m xsso mr xli xvmt.\n\nOutput for the Sample Input\n\nthis is the picture that i took in the trip.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 758, "cpu_time_ms": 310, "memory_kb": 50752}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s187136215", "group_id": "codeNet:p00017", "input_text": "import scala.io.Source.stdin\n\nobject Main extends App {\n for(s<-stdin.getLines) {\n var t:String = s\n while(!t.contains(\"this\") && !t.contains(\"the\") && !t.contains(\"that\")) {\n t = t map { c => if(c.toInt >= 97 && c.toInt <= 121) (c.toInt+1).toChar else if(c==122) 'a' else c }\n }\n println(t)\n }\n}", "language": "Scala", "metadata": {"date": 1484278569, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00017.html", "problem_id": "p00017", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00017/input.txt", "sample_output_relpath": "derived/input_output/data/p00017/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00017/Scala/s187136215.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s187136215", "user_id": "u508732591"}, "prompt_components": {"gold_output": "this is the picture that i took in the trip.\n", "input_to_evaluate": "import scala.io.Source.stdin\n\nobject Main extends App {\n for(s<-stdin.getLines) {\n var t:String = s\n while(!t.contains(\"this\") && !t.contains(\"the\") && !t.contains(\"that\")) {\n t = t map { c => if(c.toInt >= 97 && c.toInt <= 121) (c.toInt+1).toChar else if(c==122) 'a' else c }\n }\n println(t)\n }\n}", "problem_context": "Caesar Cipher\n\nIn cryptography, Caesar cipher is one of the simplest and most widely known encryption method. Caesar cipher is a type of substitution cipher in which each letter in the text is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 1, 'a' would be replaced by 'b', 'b' would become 'c', 'y' would become 'z', 'z' would become 'a', and so on. In that case, a text:\n\nthis is a pen\n\nis would become:\n\nuijt jt b qfo\n\nWrite a program which reads a text encrypted by Caesar Chipher and prints the corresponding decoded text. The number of shift is secret and it depends on datasets, but you can assume that the decoded text includes any of the following words: \"the\", \"this\", or \"that\".\n\nInput\n\nInput consists of several datasets. Each dataset consists of texts in a line. Input ends with EOF. The text consists of lower-case letters, periods, space, and end-of-lines. Only the letters have been encrypted. A line consists of at most 80 characters.\n\nYou may assume that you can create one decoded text which includes any of \"the\", \"this\", or \"that\" from the given input text.\n\nThe number of datasets is less than or equal to 20.\n\nOutput\n\nPrint decoded texts in a line.\n\nSample Input\n\nxlmw mw xli tmgxyvi xlex m xsso mr xli xvmt.\n\nOutput for the Sample Input\n\nthis is the picture that i took in the trip.", "sample_input": "xlmw mw xli tmgxyvi xlex m xsso mr xli xvmt.\n"}, "reference_outputs": ["this is the picture that i took in the trip.\n"], "source_document_id": "p00017", "source_text": "Caesar Cipher\n\nIn cryptography, Caesar cipher is one of the simplest and most widely known encryption method. Caesar cipher is a type of substitution cipher in which each letter in the text is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 1, 'a' would be replaced by 'b', 'b' would become 'c', 'y' would become 'z', 'z' would become 'a', and so on. In that case, a text:\n\nthis is a pen\n\nis would become:\n\nuijt jt b qfo\n\nWrite a program which reads a text encrypted by Caesar Chipher and prints the corresponding decoded text. The number of shift is secret and it depends on datasets, but you can assume that the decoded text includes any of the following words: \"the\", \"this\", or \"that\".\n\nInput\n\nInput consists of several datasets. Each dataset consists of texts in a line. Input ends with EOF. The text consists of lower-case letters, periods, space, and end-of-lines. Only the letters have been encrypted. A line consists of at most 80 characters.\n\nYou may assume that you can create one decoded text which includes any of \"the\", \"this\", or \"that\" from the given input text.\n\nThe number of datasets is less than or equal to 20.\n\nOutput\n\nPrint decoded texts in a line.\n\nSample Input\n\nxlmw mw xli tmgxyvi xlex m xsso mr xli xvmt.\n\nOutput for the Sample Input\n\nthis is the picture that i took in the trip.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 250, "memory_kb": 43740}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s589635755", "group_id": "codeNet:p00018", "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 println(list.sorted.reverse.mkString(\" \"))\n }\n}", "language": "Scala", "metadata": {"date": 1435817233, "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/s589635755.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s589635755", "user_id": "u085441951"}, "prompt_components": {"gold_output": "9 7 6 5 3\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 println(list.sorted.reverse.mkString(\" \"))\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 220, "memory_kb": 43960}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s980642957", "group_id": "codeNet:p00019", "input_text": "object Main {\n\tdef fact(n: Int) : BigInt = n match{\n\t case 0 => 1\n\t case _ => n * fact(n-1)\n\t}\n\t\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n while(sc.hasNext){\n println(fact(sc.nextInt))\n }\n }\n}", "language": "Scala", "metadata": {"date": 1448108596, "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/s980642957.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s980642957", "user_id": "u271453140"}, "prompt_components": {"gold_output": "120\n", "input_to_evaluate": "object Main {\n\tdef fact(n: Int) : BigInt = n match{\n\t case 0 => 1\n\t case _ => n * fact(n-1)\n\t}\n\t\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n while(sc.hasNext){\n println(fact(sc.nextInt))\n }\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 250, "memory_kb": 44940}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s381618456", "group_id": "codeNet:p00019", "input_text": "object Main extends App { println((for (i <- 0 to readInt()) yield i).product) }", "language": "Scala", "metadata": {"date": 1460354423, "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/s381618456.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s381618456", "user_id": "u123244675"}, "prompt_components": {"gold_output": "120\n", "input_to_evaluate": "object Main extends App { println((for (i <- 0 to readInt()) yield i).product) }", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 80, "cpu_time_ms": 230, "memory_kb": 43828}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s591054840", "group_id": "codeNet:p00021", "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 while(sc.hasNext){\n val x1,y1,x2,y2,x3,y3,x4,y4 = sc.nextFloat\n if(Math.abs((x1-x2)/(y1-y2)) - ((x3-x4)/(y3-y4)) < 1e-8) println(\"YES\") else println(\"NO\")\n }\n }\n}", "language": "Scala", "metadata": {"date": 1448119901, "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/s591054840.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s591054840", "user_id": "u271453140"}, "prompt_components": {"gold_output": "YES\nNO\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 while(sc.hasNext){\n val x1,y1,x2,y2,x3,y3,x4,y4 = sc.nextFloat\n if(Math.abs((x1-x2)/(y1-y2)) - ((x3-x4)/(y3-y4)) < 1e-8) println(\"YES\") else println(\"NO\")\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 300, "memory_kb": 48240}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s712098033", "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)\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 if (Math.abs((y2 - y1) * (x4 - x3) - (y4 - y3) * (x2 - x1)) < 1e-10) println(\"YES\") else println(\"NO\")\n }\n}", "language": "Scala", "metadata": {"date": 1464698589, "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/s712098033.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s712098033", "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)\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 if (Math.abs((y2 - y1) * (x4 - x3) - (y4 - y3) * (x2 - x1)) < 1e-10) 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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43972}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s066360117", "group_id": "codeNet:p00022", "input_text": "import scala.util.control.Breaks\n\nobject Main {\n\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val break = new Breaks\n break.breakable{\n \twhile(sc.hasNext){\n\t val n = sc.nextInt\n\t if(n == 0) break.break\n\t var list = List.empty[Int]\n\t for(_ <- 1 to n){\n\t \tval a = sc.nextInt\n\t\t if(list.isEmpty) list = a :: list\n\t\t else list = Math.max(list.take(1)(0) + a, a) :: list\n\t \t}\n\t println(list.max)\n\t }\n }\n }\n}", "language": "Scala", "metadata": {"date": 1448649977, "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/s066360117.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s066360117", "user_id": "u271453140"}, "prompt_components": {"gold_output": "19\n14\n1001\n", "input_to_evaluate": "import scala.util.control.Breaks\n\nobject Main {\n\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val break = new Breaks\n break.breakable{\n \twhile(sc.hasNext){\n\t val n = sc.nextInt\n\t if(n == 0) break.break\n\t var list = List.empty[Int]\n\t for(_ <- 1 to n){\n\t \tval a = sc.nextInt\n\t\t if(list.isEmpty) list = a :: list\n\t\t else list = Math.max(list.take(1)(0) + a, a) :: list\n\t \t}\n\t println(list.max)\n\t }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 578, "cpu_time_ms": 320, "memory_kb": 52904}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s131728745", "group_id": "codeNet:p00025", "input_text": "import scala.io.Source\nimport scala.annotation.tailrec\n\nobject Main{\n def main(args: Array[String]){\n val lines = for{\n in <- Source.stdin.getLines.toList\n }yield in.split(\" \").toList.map(_.toInt)\n\n if(lines.length <= 2){\n val tup = hitAndBlow(lines.head, lines.last)\n println(tup._1 + \" \" + tup._2)\n }\n else{\n mulHitAndBlow(lines, List()).reverse.foreach{tup => println(tup._1 + \" \" + tup._2)}\n }\n }\n\n @tailrec\n def mulHitAndBlow(list: List[List[Int]], tupList: List[(Int, Int)]): List[(Int, Int)]={\n if(list.isEmpty) tupList\n else mulHitAndBlow(list.tail.tail, hitAndBlow(list.head, list.tail.head) :: tupList)\n }\n\n def hitAndBlow(list1: List[Int], list2: List[Int]): (Int, Int) ={\n val hit = numOfHit(list1, list2, 0)\n (hit, numOfBlow(list1, list2, 0) - hit)\n }\n\n @tailrec\n def numOfHit(list1: List[Int], list2: List[Int], n: Int): Int={\n if(list1.isEmpty) n\n else if(list1.head == list2.head) numOfHit(list1.tail, list2.tail, n + 1)\n else numOfHit(list1.tail, list2.tail, n)\n }\n\n @tailrec\n def numOfBlow(list1: List[Int], list2: List[Int], n: Int): Int={\n if(list2.isEmpty) n\n else if(checkBlow(list1, list2.head)) numOfBlow(list1, list2.tail, n + 1)\n else numOfBlow(list1, list2.tail, n)\n }\n\n def checkBlow(list1: List[Int], n :Int): Boolean = list1.contains(n)\n}", "language": "Scala", "metadata": {"date": 1465746517, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00025.html", "problem_id": "p00025", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00025/input.txt", "sample_output_relpath": "derived/input_output/data/p00025/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00025/Scala/s131728745.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s131728745", "user_id": "u085441951"}, "prompt_components": {"gold_output": "1 1\n3 0\n", "input_to_evaluate": "import scala.io.Source\nimport scala.annotation.tailrec\n\nobject Main{\n def main(args: Array[String]){\n val lines = for{\n in <- Source.stdin.getLines.toList\n }yield in.split(\" \").toList.map(_.toInt)\n\n if(lines.length <= 2){\n val tup = hitAndBlow(lines.head, lines.last)\n println(tup._1 + \" \" + tup._2)\n }\n else{\n mulHitAndBlow(lines, List()).reverse.foreach{tup => println(tup._1 + \" \" + tup._2)}\n }\n }\n\n @tailrec\n def mulHitAndBlow(list: List[List[Int]], tupList: List[(Int, Int)]): List[(Int, Int)]={\n if(list.isEmpty) tupList\n else mulHitAndBlow(list.tail.tail, hitAndBlow(list.head, list.tail.head) :: tupList)\n }\n\n def hitAndBlow(list1: List[Int], list2: List[Int]): (Int, Int) ={\n val hit = numOfHit(list1, list2, 0)\n (hit, numOfBlow(list1, list2, 0) - hit)\n }\n\n @tailrec\n def numOfHit(list1: List[Int], list2: List[Int], n: Int): Int={\n if(list1.isEmpty) n\n else if(list1.head == list2.head) numOfHit(list1.tail, list2.tail, n + 1)\n else numOfHit(list1.tail, list2.tail, n)\n }\n\n @tailrec\n def numOfBlow(list1: List[Int], list2: List[Int], n: Int): Int={\n if(list2.isEmpty) n\n else if(checkBlow(list1, list2.head)) numOfBlow(list1, list2.tail, n + 1)\n else numOfBlow(list1, list2.tail, n)\n }\n\n def checkBlow(list1: List[Int], n :Int): Boolean = list1.contains(n)\n}", "problem_context": "Hit and Blow\n\nLet's play Hit and Blow game. A imagines four numbers and B guesses the numbers. After B picks out four numbers, A answers:\n\nThe number of numbers which have the same place with numbers A imagined (Hit)\n\nThe number of numbers included (but different place) in the numbers A imagined (Blow)\n\nFor example, if A imagined numbers:\n\n9 1 8 2\n\nand B chose:\n\n4 1 5 9\n\nA should say 1 Hit and 1 Blow.\n\nWrite a program which reads four numbers A imagined and four numbers B chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9.\n\nInput\n\nThe input consists of multiple datasets. Each dataset set consists of:\n\na1 a2 a3 a4\nb1 b2 b3 b4\n\n, where ai (0 ≤ ai ≤ 9) is i-th number A imagined and bi (0 ≤ bi ≤ 9) is i-th number B chose.\n\nThe input ends with EOF. The number of datasets is less than or equal to 50.\n\nOutput\n\nFor each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space.\n\nSample Input\n\n9 1 8 2\n4 1 5 9\n4 6 8 2\n4 6 3 2\n\nOutput for the Sample Input\n\n1 1\n3 0", "sample_input": "9 1 8 2\n4 1 5 9\n4 6 8 2\n4 6 3 2\n"}, "reference_outputs": ["1 1\n3 0\n"], "source_document_id": "p00025", "source_text": "Hit and Blow\n\nLet's play Hit and Blow game. A imagines four numbers and B guesses the numbers. After B picks out four numbers, A answers:\n\nThe number of numbers which have the same place with numbers A imagined (Hit)\n\nThe number of numbers included (but different place) in the numbers A imagined (Blow)\n\nFor example, if A imagined numbers:\n\n9 1 8 2\n\nand B chose:\n\n4 1 5 9\n\nA should say 1 Hit and 1 Blow.\n\nWrite a program which reads four numbers A imagined and four numbers B chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9.\n\nInput\n\nThe input consists of multiple datasets. Each dataset set consists of:\n\na1 a2 a3 a4\nb1 b2 b3 b4\n\n, where ai (0 ≤ ai ≤ 9) is i-th number A imagined and bi (0 ≤ bi ≤ 9) is i-th number B chose.\n\nThe input ends with EOF. The number of datasets is less than or equal to 50.\n\nOutput\n\nFor each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space.\n\nSample Input\n\n9 1 8 2\n4 1 5 9\n4 6 8 2\n4 6 3 2\n\nOutput for the Sample Input\n\n1 1\n3 0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1350, "cpu_time_ms": 320, "memory_kb": 44116}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s555149981", "group_id": "codeNet:p00029", "input_text": "import scala.collection.mutable._\nimport io.StdIn.readLine\n\nobject Main extends App {\n val map = new HashMap[String,Int]\n val s = readLine.split(\" \")\n s.foreach(e => {\n if(!map.contains(e)) map.put(e,1)\n else map.put(e,map(e)+1)\n })\n val maxF = map.maxBy(_._2)._1\n val maxL = s.map(e => (e.length, e)).max._2\n\n println(maxF + \" \" + maxL)\n}\n", "language": "Scala", "metadata": {"date": 1545305534, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00029.html", "problem_id": "p00029", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00029/input.txt", "sample_output_relpath": "derived/input_output/data/p00029/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00029/Scala/s555149981.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s555149981", "user_id": "u768801062"}, "prompt_components": {"gold_output": "your lectures\n", "input_to_evaluate": "import scala.collection.mutable._\nimport io.StdIn.readLine\n\nobject Main extends App {\n val map = new HashMap[String,Int]\n val s = readLine.split(\" \")\n s.foreach(e => {\n if(!map.contains(e)) map.put(e,1)\n else map.put(e,map(e)+1)\n })\n val maxF = map.maxBy(_._2)._1\n val maxL = s.map(e => (e.length, e)).max._2\n\n println(maxF + \" \" + maxL)\n}\n", "problem_context": "English Sentence\n\nYour task is to write a program which reads a text and prints two words. The first one is the word which is arise most frequently in the text. The second one is the word which has the maximum number of letters.\n\nThe text includes only alphabetical characters and spaces. A word is a sequence of letters which is separated by the spaces.\n\nInput\n\nA text is given in a line. You can assume the following conditions:\n\nThe number of letters in the text is less than or equal to 1000.\n\nThe number of letters in a word is less than or equal to 32.\n\nThere is only one word which is arise most frequently in given text.\n\nThere is only one word which has the maximum number of letters in given text.\n\nOutput\n\nThe two words separated by a space.\n\nSample Input\n\nThank you for your mail and your lectures\n\nOutput for the Sample Input\n\nyour lectures", "sample_input": "Thank you for your mail and your lectures\n"}, "reference_outputs": ["your lectures\n"], "source_document_id": "p00029", "source_text": "English Sentence\n\nYour task is to write a program which reads a text and prints two words. The first one is the word which is arise most frequently in the text. The second one is the word which has the maximum number of letters.\n\nThe text includes only alphabetical characters and spaces. A word is a sequence of letters which is separated by the spaces.\n\nInput\n\nA text is given in a line. You can assume the following conditions:\n\nThe number of letters in the text is less than or equal to 1000.\n\nThe number of letters in a word is less than or equal to 32.\n\nThere is only one word which is arise most frequently in given text.\n\nThere is only one word which has the maximum number of letters in given text.\n\nOutput\n\nThe two words separated by a space.\n\nSample Input\n\nThank you for your mail and your lectures\n\nOutput for the Sample Input\n\nyour lectures", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 220, "memory_kb": 43620}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s281464108", "group_id": "codeNet:p00029", "input_text": "import scala.collection.mutable._\nimport io.StdIn.readLine\n\nobject Main extends App {\n val map = new HashMap[String,Int]\n val s = readLine.split(\" \")\n s.foreach(e => {\n if(!map.contains(e)) map.put(e,1)\n else map.put(e,map(e)+1)\n })\n val maxF = map.maxBy(_._2)._1\n val maxL = s.map(e => (e.length, e)).max._2\n\n println(maxF + \" \" + maxL)\n}\n", "language": "Scala", "metadata": {"date": 1545305551, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00029.html", "problem_id": "p00029", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00029/input.txt", "sample_output_relpath": "derived/input_output/data/p00029/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00029/Scala/s281464108.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s281464108", "user_id": "u768801062"}, "prompt_components": {"gold_output": "your lectures\n", "input_to_evaluate": "import scala.collection.mutable._\nimport io.StdIn.readLine\n\nobject Main extends App {\n val map = new HashMap[String,Int]\n val s = readLine.split(\" \")\n s.foreach(e => {\n if(!map.contains(e)) map.put(e,1)\n else map.put(e,map(e)+1)\n })\n val maxF = map.maxBy(_._2)._1\n val maxL = s.map(e => (e.length, e)).max._2\n\n println(maxF + \" \" + maxL)\n}\n", "problem_context": "English Sentence\n\nYour task is to write a program which reads a text and prints two words. The first one is the word which is arise most frequently in the text. The second one is the word which has the maximum number of letters.\n\nThe text includes only alphabetical characters and spaces. A word is a sequence of letters which is separated by the spaces.\n\nInput\n\nA text is given in a line. You can assume the following conditions:\n\nThe number of letters in the text is less than or equal to 1000.\n\nThe number of letters in a word is less than or equal to 32.\n\nThere is only one word which is arise most frequently in given text.\n\nThere is only one word which has the maximum number of letters in given text.\n\nOutput\n\nThe two words separated by a space.\n\nSample Input\n\nThank you for your mail and your lectures\n\nOutput for the Sample Input\n\nyour lectures", "sample_input": "Thank you for your mail and your lectures\n"}, "reference_outputs": ["your lectures\n"], "source_document_id": "p00029", "source_text": "English Sentence\n\nYour task is to write a program which reads a text and prints two words. The first one is the word which is arise most frequently in the text. The second one is the word which has the maximum number of letters.\n\nThe text includes only alphabetical characters and spaces. A word is a sequence of letters which is separated by the spaces.\n\nInput\n\nA text is given in a line. You can assume the following conditions:\n\nThe number of letters in the text is less than or equal to 1000.\n\nThe number of letters in a word is less than or equal to 32.\n\nThere is only one word which is arise most frequently in given text.\n\nThere is only one word which has the maximum number of letters in given text.\n\nOutput\n\nThe two words separated by a space.\n\nSample Input\n\nThank you for your mail and your lectures\n\nOutput for the Sample Input\n\nyour lectures", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43772}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s224133688", "group_id": "codeNet:p00030", "input_text": "import scala.io.StdIn.readLine\n\nobject Main {\n\n def sum(n:Int, s:Int, x:Int):Int = {\n if(n==1) {\n if(s >= 0 && s<=9 && s > x ) 1 else 0\n } else { for(i <- 0 to 9 if s>=i && i>x) yield sum(n-1,s-i,if(i>x) i else x) }.sum\n }\n\n def getSum(sb:StringBuilder):Unit = {\n val r = readLine.split(\" \").map(_.toInt)\n\n if(r(0)==0 && r(1)==0) print(sb.result)\n else {\n println(sum(r(0),r(1),-1))\n getSum(sb)\n }\n }\n\n def main(args:Array[String]) = getSum(new StringBuilder)\n}", "language": "Scala", "metadata": {"date": 1484732044, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00030.html", "problem_id": "p00030", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00030/input.txt", "sample_output_relpath": "derived/input_output/data/p00030/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00030/Scala/s224133688.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s224133688", "user_id": "u508732591"}, "prompt_components": {"gold_output": "3\n0\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main {\n\n def sum(n:Int, s:Int, x:Int):Int = {\n if(n==1) {\n if(s >= 0 && s<=9 && s > x ) 1 else 0\n } else { for(i <- 0 to 9 if s>=i && i>x) yield sum(n-1,s-i,if(i>x) i else x) }.sum\n }\n\n def getSum(sb:StringBuilder):Unit = {\n val r = readLine.split(\" \").map(_.toInt)\n\n if(r(0)==0 && r(1)==0) print(sb.result)\n else {\n println(sum(r(0),r(1),-1))\n getSum(sb)\n }\n }\n\n def main(args:Array[String]) = getSum(new StringBuilder)\n}", "problem_context": "整数の和\n\n0 から 9 の数字から異なる n 個の数を取り出して合計が s となる組み合わせの数を出力するプログラムを作成してください。n 個の数はおのおの 0 から 9 までとし、1つの組み合わせに同じ数字は使えません。たとえば、n が 3 で s が 6 のとき、3 個の数字の合計が 6 になる組み合わせは、\n\n1 + 2 + 3 = 6\n\n0 + 1 + 5 = 6\n\n0 + 2 + 4 = 6\n\nの 3 通りとなります。\n\nInput\n\n複数のデータセットが与えられます。各データセットに n (1 ≤ n ≤ 9) と s (0 ≤ s ≤ 100) が1つのスペースで区切られて1行に与えられます。n と s が共に 0 のとき入力の最後とします(この場合は処理せずにプログラムを終了する)。\n\nデータセットの数は 50 を超えません。\n\nOutput\n\n各データセットに対して、n 個の整数の和が s になる組み合わせの数を1行に出力して下さい。\n\nSample Input\n\n3 6\n3 1\n0 0\n\nOutput for the Sample Input\n\n3\n0", "sample_input": "3 6\n3 1\n0 0\n"}, "reference_outputs": ["3\n0\n"], "source_document_id": "p00030", "source_text": "整数の和\n\n0 から 9 の数字から異なる n 個の数を取り出して合計が s となる組み合わせの数を出力するプログラムを作成してください。n 個の数はおのおの 0 から 9 までとし、1つの組み合わせに同じ数字は使えません。たとえば、n が 3 で s が 6 のとき、3 個の数字の合計が 6 になる組み合わせは、\n\n1 + 2 + 3 = 6\n\n0 + 1 + 5 = 6\n\n0 + 2 + 4 = 6\n\nの 3 通りとなります。\n\nInput\n\n複数のデータセットが与えられます。各データセットに n (1 ≤ n ≤ 9) と s (0 ≤ s ≤ 100) が1つのスペースで区切られて1行に与えられます。n と s が共に 0 のとき入力の最後とします(この場合は処理せずにプログラムを終了する)。\n\nデータセットの数は 50 を超えません。\n\nOutput\n\n各データセットに対して、n 個の整数の和が s になる組み合わせの数を1行に出力して下さい。\n\nSample Input\n\n3 6\n3 1\n0 0\n\nOutput for the Sample Input\n\n3\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 500, "cpu_time_ms": 260, "memory_kb": 46172}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s947383511", "group_id": "codeNet:p00030", "input_text": "import scala.io.StdIn.readLine\n\nobject Main {\n def sum(n:Int, s:Int, x:Int):Int = {\n if(n==1) { if(s >= 0 && s<=9 && s > x ) 1 else 0 }\n else { for(i <- x+1 to (if(s<9) s else 9) ) yield sum(n-1,s-i,i) }.sum\n }\n\n def getSum(sb:StringBuilder):Unit = {\n val r = readLine.split(\" \").map(_.toInt)\n\n if(r(0)==0 && r(1)==0) print(sb.result)\n else {\n println(sum(r(0),r(1),-1))\n getSum(sb)\n }\n }\n\n def main(args:Array[String]) = getSum(new StringBuilder)\n}", "language": "Scala", "metadata": {"date": 1484877012, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00030.html", "problem_id": "p00030", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00030/input.txt", "sample_output_relpath": "derived/input_output/data/p00030/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00030/Scala/s947383511.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s947383511", "user_id": "u508732591"}, "prompt_components": {"gold_output": "3\n0\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main {\n def sum(n:Int, s:Int, x:Int):Int = {\n if(n==1) { if(s >= 0 && s<=9 && s > x ) 1 else 0 }\n else { for(i <- x+1 to (if(s<9) s else 9) ) yield sum(n-1,s-i,i) }.sum\n }\n\n def getSum(sb:StringBuilder):Unit = {\n val r = readLine.split(\" \").map(_.toInt)\n\n if(r(0)==0 && r(1)==0) print(sb.result)\n else {\n println(sum(r(0),r(1),-1))\n getSum(sb)\n }\n }\n\n def main(args:Array[String]) = getSum(new StringBuilder)\n}", "problem_context": "整数の和\n\n0 から 9 の数字から異なる n 個の数を取り出して合計が s となる組み合わせの数を出力するプログラムを作成してください。n 個の数はおのおの 0 から 9 までとし、1つの組み合わせに同じ数字は使えません。たとえば、n が 3 で s が 6 のとき、3 個の数字の合計が 6 になる組み合わせは、\n\n1 + 2 + 3 = 6\n\n0 + 1 + 5 = 6\n\n0 + 2 + 4 = 6\n\nの 3 通りとなります。\n\nInput\n\n複数のデータセットが与えられます。各データセットに n (1 ≤ n ≤ 9) と s (0 ≤ s ≤ 100) が1つのスペースで区切られて1行に与えられます。n と s が共に 0 のとき入力の最後とします(この場合は処理せずにプログラムを終了する)。\n\nデータセットの数は 50 を超えません。\n\nOutput\n\n各データセットに対して、n 個の整数の和が s になる組み合わせの数を1行に出力して下さい。\n\nSample Input\n\n3 6\n3 1\n0 0\n\nOutput for the Sample Input\n\n3\n0", "sample_input": "3 6\n3 1\n0 0\n"}, "reference_outputs": ["3\n0\n"], "source_document_id": "p00030", "source_text": "整数の和\n\n0 から 9 の数字から異なる n 個の数を取り出して合計が s となる組み合わせの数を出力するプログラムを作成してください。n 個の数はおのおの 0 から 9 までとし、1つの組み合わせに同じ数字は使えません。たとえば、n が 3 で s が 6 のとき、3 個の数字の合計が 6 になる組み合わせは、\n\n1 + 2 + 3 = 6\n\n0 + 1 + 5 = 6\n\n0 + 2 + 4 = 6\n\nの 3 通りとなります。\n\nInput\n\n複数のデータセットが与えられます。各データセットに n (1 ≤ n ≤ 9) と s (0 ≤ s ≤ 100) が1つのスペースで区切られて1行に与えられます。n と s が共に 0 のとき入力の最後とします(この場合は処理せずにプログラムを終了する)。\n\nデータセットの数は 50 を超えません。\n\nOutput\n\n各データセットに対して、n 個の整数の和が s になる組み合わせの数を1行に出力して下さい。\n\nSample Input\n\n3 6\n3 1\n0 0\n\nOutput for the Sample Input\n\n3\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 482, "cpu_time_ms": 260, "memory_kb": 45480}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s428799964", "group_id": "codeNet:p00033", "input_text": "import scala.io.Source.stdin\nimport scala.io.StdIn\nimport scala.util.control.Breaks\n\n/**\n * Created by wintermaples on 2017/06/20.\n */\nobject Main {\n\n def main(args : Array[String]) : Unit = {\n val b = new Breaks\n val n = StdIn.readLine().toInt\n for (i <- 0 until n) {\n val balls = StdIn.readLine().split(\" \").map(_.toInt).reverse\n var ballLine1 = List.empty[Int]\n var ballLine2 = List.empty[Int]\n var success = true\n for (j <- 0 until balls.length) {\n b.breakable {\n\n if (ballLine1.isEmpty) {\n ballLine1 :+= balls(j)\n b.break()\n }\n if (ballLine2.isEmpty) {\n ballLine2 :+= balls(j)\n b.break()\n }\n if (ballLine1(ballLine1.length - 1) > balls(j)) {\n ballLine1 :+= balls(j)\n b.break()\n }\n if(ballLine2(ballLine2.length - 1) > balls(j)) {\n ballLine2 :+= balls(j)\n b.break()\n }\n success = false\n\n }\n }\n if (success)\n println(\"YES\")\n else\n println(\"NO\")\n\n }\n }\n\n}", "language": "Scala", "metadata": {"date": 1498029502, "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/s428799964.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s428799964", "user_id": "u187606290"}, "prompt_components": {"gold_output": "YES\nNO\n", "input_to_evaluate": "import scala.io.Source.stdin\nimport scala.io.StdIn\nimport scala.util.control.Breaks\n\n/**\n * Created by wintermaples on 2017/06/20.\n */\nobject Main {\n\n def main(args : Array[String]) : Unit = {\n val b = new Breaks\n val n = StdIn.readLine().toInt\n for (i <- 0 until n) {\n val balls = StdIn.readLine().split(\" \").map(_.toInt).reverse\n var ballLine1 = List.empty[Int]\n var ballLine2 = List.empty[Int]\n var success = true\n for (j <- 0 until balls.length) {\n b.breakable {\n\n if (ballLine1.isEmpty) {\n ballLine1 :+= balls(j)\n b.break()\n }\n if (ballLine2.isEmpty) {\n ballLine2 :+= balls(j)\n b.break()\n }\n if (ballLine1(ballLine1.length - 1) > balls(j)) {\n ballLine1 :+= balls(j)\n b.break()\n }\n if(ballLine2(ballLine2.length - 1) > balls(j)) {\n ballLine2 :+= balls(j)\n b.break()\n }\n success = false\n\n }\n }\n if (success)\n println(\"YES\")\n else\n println(\"NO\")\n\n }\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1110, "cpu_time_ms": 230, "memory_kb": 43752}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s394754336", "group_id": "codeNet:p00035", "input_text": "import scala.io.Source.stdin\n\nobject Main {\n def v(x:(Double,Double),y:(Double,Double)) = (x,y) match { case ((x0,y0),(x1,y1)) => (x1-x0,y1-y0) }\n def cross(x:(Double,Double),y:(Double,Double)) = (x,y) match { case ((x0,y0),(x1,y1)) => x0*y1-x1*y0 }\n\n def main(args:Array[String]) = {\n val b = new StringBuilder\n\n for(l<-stdin.getLines.map(s=>s.split(\",\").map(_.toDouble))) {\n val v01 = v((l(0),l(1)), (l(2),l(3)))\n val v02 = v((l(0),l(1)), (l(4),l(5)))\n val v03 = v((l(0),l(1)), (l(6),l(7)))\n val v10 = v((l(2),l(3)), (l(0),l(1)))\n val v12 = v((l(2),l(3)), (l(4),l(5)))\n val v13 = v((l(2),l(3)), (l(6),l(7)))\n if(cross(v02, v01)*cross(v02,v03) < 0\n && cross(v13,v12)*cross(v13,v10) < 0)\n b.append(\"YES\\n\")\n else\n b.append(\"NO\\n\")\n }\n print(b.result)\n }\n}", "language": "Scala", "metadata": {"date": 1484905357, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00035.html", "problem_id": "p00035", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00035/input.txt", "sample_output_relpath": "derived/input_output/data/p00035/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00035/Scala/s394754336.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s394754336", "user_id": "u508732591"}, "prompt_components": {"gold_output": "YES\nNO\n", "input_to_evaluate": "import scala.io.Source.stdin\n\nobject Main {\n def v(x:(Double,Double),y:(Double,Double)) = (x,y) match { case ((x0,y0),(x1,y1)) => (x1-x0,y1-y0) }\n def cross(x:(Double,Double),y:(Double,Double)) = (x,y) match { case ((x0,y0),(x1,y1)) => x0*y1-x1*y0 }\n\n def main(args:Array[String]) = {\n val b = new StringBuilder\n\n for(l<-stdin.getLines.map(s=>s.split(\",\").map(_.toDouble))) {\n val v01 = v((l(0),l(1)), (l(2),l(3)))\n val v02 = v((l(0),l(1)), (l(4),l(5)))\n val v03 = v((l(0),l(1)), (l(6),l(7)))\n val v10 = v((l(2),l(3)), (l(0),l(1)))\n val v12 = v((l(2),l(3)), (l(4),l(5)))\n val v13 = v((l(2),l(3)), (l(6),l(7)))\n if(cross(v02, v01)*cross(v02,v03) < 0\n && cross(v13,v12)*cross(v13,v10) < 0)\n b.append(\"YES\\n\")\n else\n b.append(\"NO\\n\")\n }\n print(b.result)\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\n凸?\n\n平面上の異なる 4 点 $A (x_a, y_a)$, $B (x_b, y_b)$, $C (x_c, y_c)$, $D(x_d, y_d)$ の座標を読み込んで、それら 4 点を頂点とした四角形 $ABCD$ に凹みがなければ YES、凹みがあれば NO と出力するプログラムを作成してください。\n\n凹みのある四角形とは図 1 のような四角形です。\n\nInput\n\n複数のデータセットが与えられます。各データセットの形式は以下のとおりです。\n\n$x_a$,$y_a$,$x_b$,$y_b$,$x_c$,$y_c$,$x_d$,$y_d$\n\n$x_a$, $y_a$, $x_b$, $y_b$, $x_c$, $y_c$, $x_d$, $y_d$ はそれぞれ -100 以上 100 以下であり、実数で与えられます。\n\n1 直線上に 3 つ以上点が並ぶことはないものとします。また、入力順に点を結んでいけば、四角形になる順番に点の座標が入力されるものとします。(つまり、図 2 のような形になる順番で点が与えられることはありません。)\n\nデータセットの数は 100 を超えません。\n\nOutput\n\n各データセットごとに、YES または NO を1行に出力します。\n\nSample Input\n\n0.0,0.0,1.0,0.0,1.0,1.0,0.0,1.0\n0.0,0.0,3.0,0.0,1.0,1.0,1.0,3.0\n\nOutput for the Sample Input\n\nYES\nNO", "sample_input": "0.0,0.0,1.0,0.0,1.0,1.0,0.0,1.0\n0.0,0.0,3.0,0.0,1.0,1.0,1.0,3.0\n"}, "reference_outputs": ["YES\nNO\n"], "source_document_id": "p00035", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\n凸?\n\n平面上の異なる 4 点 $A (x_a, y_a)$, $B (x_b, y_b)$, $C (x_c, y_c)$, $D(x_d, y_d)$ の座標を読み込んで、それら 4 点を頂点とした四角形 $ABCD$ に凹みがなければ YES、凹みがあれば NO と出力するプログラムを作成してください。\n\n凹みのある四角形とは図 1 のような四角形です。\n\nInput\n\n複数のデータセットが与えられます。各データセットの形式は以下のとおりです。\n\n$x_a$,$y_a$,$x_b$,$y_b$,$x_c$,$y_c$,$x_d$,$y_d$\n\n$x_a$, $y_a$, $x_b$, $y_b$, $x_c$, $y_c$, $x_d$, $y_d$ はそれぞれ -100 以上 100 以下であり、実数で与えられます。\n\n1 直線上に 3 つ以上点が並ぶことはないものとします。また、入力順に点を結んでいけば、四角形になる順番に点の座標が入力されるものとします。(つまり、図 2 のような形になる順番で点が与えられることはありません。)\n\nデータセットの数は 100 を超えません。\n\nOutput\n\n各データセットごとに、YES または NO を1行に出力します。\n\nSample Input\n\n0.0,0.0,1.0,0.0,1.0,1.0,0.0,1.0\n0.0,0.0,3.0,0.0,1.0,1.0,1.0,3.0\n\nOutput for the Sample Input\n\nYES\nNO", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 834, "cpu_time_ms": 230, "memory_kb": 43764}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s389516067", "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)).toMap\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(a),b) else c })\n }\n }\n}", "language": "Scala", "metadata": {"date": 1486211087, "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/s389516067.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s389516067", "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)).toMap\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(a),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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 250, "memory_kb": 45592}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s283975269", "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 if((u to 8).exists( i=> check(m diff seq1(i),count-3,i,v))) {\n true\n } else {\n (v to 6).exists(i=> check(m diff seq2(i),count-3,u,i) )\n }\n }\n }\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": 1486103637, "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/s283975269.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s283975269", "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 if((u to 8).exists( i=> check(m diff seq1(i),count-3,i,v))) {\n true\n } else {\n (v to 6).exists(i=> check(m diff seq2(i),count-3,u,i) )\n }\n }\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 797, "cpu_time_ms": 390, "memory_kb": 72252}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s934456670", "group_id": "codeNet:p00044", "input_text": "object Main extends App {\n val src: Iterator[Int] = io.Source.stdin.getLines.map(_.toInt)\n\n def isPrime(n: Int) = n >= 2 && (3 to math.sqrt(n).toInt by 2).forall(n%_ != 0)\n def findPrimeOver(curr: Int): Int = if (isPrime(curr)) curr else findPrimeOver(curr + 1)\n def findPrimeUnder(curr: Int): Int = if (isPrime(curr)) curr else findPrimeUnder(curr - 1)\n\n for (num <- src) println(s\"${findPrimeUnder(num-1)} ${findPrimeOver(num+1)}\")\n}", "language": "Scala", "metadata": {"date": 1514513376, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00044.html", "problem_id": "p00044", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00044/input.txt", "sample_output_relpath": "derived/input_output/data/p00044/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00044/Scala/s934456670.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s934456670", "user_id": "u387507798"}, "prompt_components": {"gold_output": "17 23\n3511 3527\n", "input_to_evaluate": "object Main extends App {\n val src: Iterator[Int] = io.Source.stdin.getLines.map(_.toInt)\n\n def isPrime(n: Int) = n >= 2 && (3 to math.sqrt(n).toInt by 2).forall(n%_ != 0)\n def findPrimeOver(curr: Int): Int = if (isPrime(curr)) curr else findPrimeOver(curr + 1)\n def findPrimeUnder(curr: Int): Int = if (isPrime(curr)) curr else findPrimeUnder(curr - 1)\n\n for (num <- src) println(s\"${findPrimeUnder(num-1)} ${findPrimeOver(num+1)}\")\n}", "problem_context": "素数 II\n\n素数というのは、1 よりも大きくそれ自身か 1 でしか割りきれない整数をいいます。例えば、2 は、2 と 1 でしか割り切れないので素数ですが、12 は、12 と 1 のほかに、2, 3, 4, 6 で割りきれる数なので素数ではありません。\n\n整数 n を入力したとき、n より小さい素数のうち最も大きいものと、n より大きい素数のうち最も小さいものを出力するプログラムを作成してください。\n\nInput\n\n複数のデータセットが与えられます。各データセットに n (3 ≤ n ≤ 50,000) が1行に与えられます。\n\nデータセットの数は 50 を超えません。\n\nOutput\n\n各データセットに対して、n より小さい素数のうち最大のものと、n より大きい素数のうち最小のものを1つのスペースで区切って1行に出力して下さい。\n\nSample Input\n\n19\n3517\n\nOutput for the Sample Input\n\n17 23\n3511 3527", "sample_input": "19\n3517\n"}, "reference_outputs": ["17 23\n3511 3527\n"], "source_document_id": "p00044", "source_text": "素数 II\n\n素数というのは、1 よりも大きくそれ自身か 1 でしか割りきれない整数をいいます。例えば、2 は、2 と 1 でしか割り切れないので素数ですが、12 は、12 と 1 のほかに、2, 3, 4, 6 で割りきれる数なので素数ではありません。\n\n整数 n を入力したとき、n より小さい素数のうち最も大きいものと、n より大きい素数のうち最も小さいものを出力するプログラムを作成してください。\n\nInput\n\n複数のデータセットが与えられます。各データセットに n (3 ≤ n ≤ 50,000) が1行に与えられます。\n\nデータセットの数は 50 を超えません。\n\nOutput\n\n各データセットに対して、n より小さい素数のうち最大のものと、n より大きい素数のうち最小のものを1つのスペースで区切って1行に出力して下さい。\n\nSample Input\n\n19\n3517\n\nOutput for the Sample Input\n\n17 23\n3511 3527", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 43972}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s219509175", "group_id": "codeNet:p00050", "input_text": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n println {\n readLine.replace(\"apple\",\"APPLE\")\n .replace(\"peach\",\"apple\")\n .replace(\"APPLE\",\"peach\")\n }\n}", "language": "Scala", "metadata": {"date": 1486140324, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00050.html", "problem_id": "p00050", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00050/input.txt", "sample_output_relpath": "derived/input_output/data/p00050/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00050/Scala/s219509175.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s219509175", "user_id": "u508732591"}, "prompt_components": {"gold_output": "the cost of one apple is higher than that of one peach.\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n println {\n readLine.replace(\"apple\",\"APPLE\")\n .replace(\"peach\",\"apple\")\n .replace(\"APPLE\",\"peach\")\n }\n}", "problem_context": "りんごと桃\n\n福島県は果物の産地としても有名で、その中でも特に桃とりんごは全国でも指折りの生産量を誇っています。ところで、ある販売用の英文パンフレットの印刷原稿を作ったところ、手違いでりんごに関する記述と桃に関する記述を逆に書いてしまいました。\n\nあなたは、apple と peach を修正する仕事を任されましたが、なにぶん面倒です。1行の英文を入力して、そのなかの apple という文字列を全て peach に、peach という文字列を全てapple に交換した英文を出力するプログラムを作成してください。\n\nInput\n\n英文(半角英数字、空白、記号を含む)が1行に与えられます。入力される文字列の長さは 1000 以下です。\n\nOutput\n\napple とpeach という文字列を交換した英文を1行に出力します。\n\nSample Input\n\nthe cost of one peach is higher than that of one apple.\n\nOutput for the Sample Input\n\nthe cost of one apple is higher than that of one peach.", "sample_input": "the cost of one peach is higher than that of one apple.\n"}, "reference_outputs": ["the cost of one apple is higher than that of one peach.\n"], "source_document_id": "p00050", "source_text": "りんごと桃\n\n福島県は果物の産地としても有名で、その中でも特に桃とりんごは全国でも指折りの生産量を誇っています。ところで、ある販売用の英文パンフレットの印刷原稿を作ったところ、手違いでりんごに関する記述と桃に関する記述を逆に書いてしまいました。\n\nあなたは、apple と peach を修正する仕事を任されましたが、なにぶん面倒です。1行の英文を入力して、そのなかの apple という文字列を全て peach に、peach という文字列を全てapple に交換した英文を出力するプログラムを作成してください。\n\nInput\n\n英文(半角英数字、空白、記号を含む)が1行に与えられます。入力される文字列の長さは 1000 以下です。\n\nOutput\n\napple とpeach という文字列を交換した英文を1行に出力します。\n\nSample Input\n\nthe cost of one peach is higher than that of one apple.\n\nOutput for the Sample Input\n\nthe cost of one apple is higher than that of one peach.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 220, "memory_kb": 43636}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s433135820", "group_id": "codeNet:p00051", "input_text": "import scala.io.StdIn\n\nobject Main{\n def main(args: Array[String]){\n val lines = Iterator.continually(StdIn.readLine).takeWhile(_ != null).toList\n lines.tail.map((x:String) => x.sorted.reverse.toInt - x.sorted.toInt).foreach(println)\n }\n}", "language": "Scala", "metadata": {"date": 1440752857, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00051.html", "problem_id": "p00051", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00051/input.txt", "sample_output_relpath": "derived/input_output/data/p00051/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00051/Scala/s433135820.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s433135820", "user_id": "u085441951"}, "prompt_components": {"gold_output": "96417531\n96417531\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main{\n def main(args: Array[String]){\n val lines = Iterator.continually(StdIn.readLine).takeWhile(_ != null).toList\n lines.tail.map((x:String) => x.sorted.reverse.toInt - x.sorted.toInt).foreach(println)\n }\n}", "problem_context": "整数の差\n\n8 個の 0 から 9 までの数字を入力したとき、その 8 個の数字を並べ替えてできる、最大の整数と最小の整数の差を出力するプログラムを作成してください。並び替えてできる数は 00135569 のように 0 から始まってもよいものとします。\n\nInput\n\n複数のデータセットが与えられます。1行目にデータセット数 n (n ≤ 50) が与えられます。続いて n 行のデータが与えられます。各データは 8 個の数字の並び(0 から 9 の数字)です。\n\nOutput\n\n各データセットに対して、入力された数字を並べ替えてできる最大の整数と最小の整数の差を1行に出力して下さい。\n\nSample Input\n\n2\n65539010\n65539010\n\nOutput for the Sample Input\n\n96417531\n96417531", "sample_input": "2\n65539010\n65539010\n"}, "reference_outputs": ["96417531\n96417531\n"], "source_document_id": "p00051", "source_text": "整数の差\n\n8 個の 0 から 9 までの数字を入力したとき、その 8 個の数字を並べ替えてできる、最大の整数と最小の整数の差を出力するプログラムを作成してください。並び替えてできる数は 00135569 のように 0 から始まってもよいものとします。\n\nInput\n\n複数のデータセットが与えられます。1行目にデータセット数 n (n ≤ 50) が与えられます。続いて n 行のデータが与えられます。各データは 8 個の数字の並び(0 から 9 の数字)です。\n\nOutput\n\n各データセットに対して、入力された数字を並べ替えてできる最大の整数と最小の整数の差を1行に出力して下さい。\n\nSample Input\n\n2\n65539010\n65539010\n\nOutput for the Sample Input\n\n96417531\n96417531", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 220, "memory_kb": 43624}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s664921730", "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": 1486393492, "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/s664921730.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s664921730", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 53296}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s060568360", "group_id": "codeNet:p00054", "input_text": "import scala.io.Source.stdin\n\nobject Main {\n def getSum(i:Int,a:Int,b:Int,sum:Int):Int =\n if(i<0) sum else getSum(i-1,(a%b)*10,b,sum+(a/b))\n\n def main(args:Array[String]) = {\n stdin.getLines.foreach { s =>\n val n = s.split(\" \").map(_.toInt)\n val a = if(n(0) >= n(1)) n(0)-(n(0)/n(1))*n(1) else n(0)\n println(getSum(n(2),a,n(1),0))\n }\n }\n}", "language": "Scala", "metadata": {"date": 1486394946, "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/s060568360.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s060568360", "user_id": "u508732591"}, "prompt_components": {"gold_output": "5\n24\n7\n6\n", "input_to_evaluate": "import scala.io.Source.stdin\n\nobject Main {\n def getSum(i:Int,a:Int,b:Int,sum:Int):Int =\n if(i<0) sum else getSum(i-1,(a%b)*10,b,sum+(a/b))\n\n def main(args:Array[String]) = {\n stdin.getLines.foreach { s =>\n val n = s.split(\" \").map(_.toInt)\n val a = if(n(0) >= n(1)) n(0)-(n(0)/n(1))*n(1) else n(0)\n println(getSum(n(2),a,n(1),0))\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 365, "cpu_time_ms": 230, "memory_kb": 43612}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s893059087", "group_id": "codeNet:p00056", "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( i <- 3 to Math.sqrt(n).toInt by 2 )\n if(primes(i) == 1)\n (i*i to n by i*2).foreach { primes(_) = 0 }\n primes\n }\n\n def main(args:Array[String]) = {\n val p = sieve(50000)\n var n = 0\n while( { n = readInt; n} != 0 ) {\n var cnt = 0\n if(p(n-2) == 1) cnt = 1\n else if(n%2==0) {\n for(i<- 3 to n/2 by 2)\n if(p(i) ==1 && p(n-i) ==1)\n cnt += 1\n }\n println(cnt)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1486445964, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00056.html", "problem_id": "p00056", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00056/input.txt", "sample_output_relpath": "derived/input_output/data/p00056/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00056/Scala/s893059087.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s893059087", "user_id": "u508732591"}, "prompt_components": {"gold_output": "2\n0\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( i <- 3 to Math.sqrt(n).toInt by 2 )\n if(primes(i) == 1)\n (i*i to n by i*2).foreach { primes(_) = 0 }\n primes\n }\n\n def main(args:Array[String]) = {\n val p = sieve(50000)\n var n = 0\n while( { n = readInt; n} != 0 ) {\n var cnt = 0\n if(p(n-2) == 1) cnt = 1\n else if(n%2==0) {\n for(i<- 3 to n/2 by 2)\n if(p(i) ==1 && p(n-i) ==1)\n cnt += 1\n }\n println(cnt)\n }\n }\n}", "problem_context": "ゴールドバッハの予想\n\n4 以上の偶数は 2 つの素数の和で表すことができるということが知られています。これはゴールドバッハ予想といい、コンピュータの計算によりかなり大きな数まで正しいことが確かめられています。例えば、10 は、7 + 3、5 + 5 の 2 通りの素数の和で表すことができます。\n\n整数 n を入力し、n を 2 つの素数の和で表す組み合わせ数が何通りあるかを出力するプログラムを作成してください。ただし、n は 4 以上、50,000 以下とします。また、入力される n は偶数であるとはかぎりません。\n\nInput\n\n複数のデータセットが与えられます。各データセットに n が1行に与えられます。n が 0 のとき入力の最後とします。データセットの数は 10,000 を超えません。\n\nOutput\n\n各データセットに対して、n を 2 つの素数の和で表す組み合わせ数を1行に出力して下さい。\n\nSample Input\n\n10\n11\n0\n\nOutput for the Sample Input\n\n2\n0", "sample_input": "10\n11\n0\n"}, "reference_outputs": ["2\n0\n"], "source_document_id": "p00056", "source_text": "ゴールドバッハの予想\n\n4 以上の偶数は 2 つの素数の和で表すことができるということが知られています。これはゴールドバッハ予想といい、コンピュータの計算によりかなり大きな数まで正しいことが確かめられています。例えば、10 は、7 + 3、5 + 5 の 2 通りの素数の和で表すことができます。\n\n整数 n を入力し、n を 2 つの素数の和で表す組み合わせ数が何通りあるかを出力するプログラムを作成してください。ただし、n は 4 以上、50,000 以下とします。また、入力される n は偶数であるとはかぎりません。\n\nInput\n\n複数のデータセットが与えられます。各データセットに n が1行に与えられます。n が 0 のとき入力の最後とします。データセットの数は 10,000 を超えません。\n\nOutput\n\n各データセットに対して、n を 2 つの素数の和で表す組み合わせ数を1行に出力して下さい。\n\nSample Input\n\n10\n11\n0\n\nOutput for the Sample Input\n\n2\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 601, "cpu_time_ms": 520, "memory_kb": 51544}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s177633518", "group_id": "codeNet:p00074", "input_text": "object Main extends App {\n val in = io.Source.stdin.getLines.map(_.trim.split(\" \").map(_.toInt)).toSeq.init\n for (Array(h, m, s) <- in) {\n val x = 7200-h*3600-m*60-s\n println(\"%02d:%02d:%02d\".format(x/3600, x/60%60, x%60))\n println(\"%02d:%02d:%02d\".format(x/1200, x/20%60, x*3%60))\n }\n}", "language": "Scala", "metadata": {"date": 1489637291, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00074.html", "problem_id": "p00074", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00074/input.txt", "sample_output_relpath": "derived/input_output/data/p00074/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00074/Scala/s177633518.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s177633518", "user_id": "u475394465"}, "prompt_components": {"gold_output": "00:30:00\n01:30:00\n", "input_to_evaluate": "object Main extends App {\n val in = io.Source.stdin.getLines.map(_.trim.split(\" \").map(_.toInt)).toSeq.init\n for (Array(h, m, s) <- in) {\n val x = 7200-h*3600-m*60-s\n println(\"%02d:%02d:%02d\".format(x/3600, x/60%60, x%60))\n println(\"%02d:%02d:%02d\".format(x/1200, x/20%60, x*3%60))\n }\n}", "problem_context": "ビデオテープ\n\n標準録画で 120 分のビデオテープがあります。テープを完全に巻き戻した状態でビデオデッキのカウンタを 00:00:00 にし、標準録画モードで録画したところ、あるカウンタ値になりました。このカウンタ値(時、分、秒)を入力し、残りのテープの長さ(録画可能時間)を求め、時:分:秒の形式で出力するプログラムを作成して下さい。\n\nただし、2 時間(120分)以内の入力とします。なお、テープ残量は標準録画モードと 3 倍録画モードの場合の2通りを計算し、出力例のように時、分、秒とも 2 桁ずつ出力します。また \"05\" のように 10 の位が 0 の場合は、\"0\" をつけてください。\n\n入力\n\n複数のデータセットが与えられます。各データセットは以下のとおりです。\n\nT H S\n\nT, H, S はそれぞれ時、分、秒を表す整数です。\n\nT, H, S がすべて -1 のとき入力の終わりとします。データセットの数は 50 を超えません。\n\n出力\n\n各データセットごとに\n\n1 行目に、テープの残りを標準録画した場合の録画可能時間の時、分、秒を半角コロン区切りで、\n\n2 行目に、テープの残りを3倍録画した場合の録画可能時間の時、分、秒を半角コロン区切りで\n\n出力して下さい。\n\nSample Input\n\n1 30 0\n-1 -1 -1\n\nOutput for the Sample Input\n\n00:30:00\n01:30:00", "sample_input": "1 30 0\n-1 -1 -1\n"}, "reference_outputs": ["00:30:00\n01:30:00\n"], "source_document_id": "p00074", "source_text": "ビデオテープ\n\n標準録画で 120 分のビデオテープがあります。テープを完全に巻き戻した状態でビデオデッキのカウンタを 00:00:00 にし、標準録画モードで録画したところ、あるカウンタ値になりました。このカウンタ値(時、分、秒)を入力し、残りのテープの長さ(録画可能時間)を求め、時:分:秒の形式で出力するプログラムを作成して下さい。\n\nただし、2 時間(120分)以内の入力とします。なお、テープ残量は標準録画モードと 3 倍録画モードの場合の2通りを計算し、出力例のように時、分、秒とも 2 桁ずつ出力します。また \"05\" のように 10 の位が 0 の場合は、\"0\" をつけてください。\n\n入力\n\n複数のデータセットが与えられます。各データセットは以下のとおりです。\n\nT H S\n\nT, H, S はそれぞれ時、分、秒を表す整数です。\n\nT, H, S がすべて -1 のとき入力の終わりとします。データセットの数は 50 を超えません。\n\n出力\n\n各データセットごとに\n\n1 行目に、テープの残りを標準録画した場合の録画可能時間の時、分、秒を半角コロン区切りで、\n\n2 行目に、テープの残りを3倍録画した場合の録画可能時間の時、分、秒を半角コロン区切りで\n\n出力して下さい。\n\nSample Input\n\n1 30 0\n-1 -1 -1\n\nOutput for the Sample Input\n\n00:30:00\n01:30:00", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 44456}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s293539180", "group_id": "codeNet:p00074", "input_text": "object Main extends App {\n val in = io.Source.stdin.getLines.map(_.split(\" \").map(_.toInt)).toSeq.init\n for (Array(h, m, s) <- in) {\n val x = 7200-h*3600-m*60-s\n println(\"%02d:%02d:%02d\".format(x/3600, x/60%60, x%60))\n println(\"%02d:%02d:%02d\".format(x/1200, x/20%60, x*3%60))\n }\n}", "language": "Scala", "metadata": {"date": 1489637551, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00074.html", "problem_id": "p00074", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00074/input.txt", "sample_output_relpath": "derived/input_output/data/p00074/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00074/Scala/s293539180.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s293539180", "user_id": "u475394465"}, "prompt_components": {"gold_output": "00:30:00\n01:30:00\n", "input_to_evaluate": "object Main extends App {\n val in = io.Source.stdin.getLines.map(_.split(\" \").map(_.toInt)).toSeq.init\n for (Array(h, m, s) <- in) {\n val x = 7200-h*3600-m*60-s\n println(\"%02d:%02d:%02d\".format(x/3600, x/60%60, x%60))\n println(\"%02d:%02d:%02d\".format(x/1200, x/20%60, x*3%60))\n }\n}", "problem_context": "ビデオテープ\n\n標準録画で 120 分のビデオテープがあります。テープを完全に巻き戻した状態でビデオデッキのカウンタを 00:00:00 にし、標準録画モードで録画したところ、あるカウンタ値になりました。このカウンタ値(時、分、秒)を入力し、残りのテープの長さ(録画可能時間)を求め、時:分:秒の形式で出力するプログラムを作成して下さい。\n\nただし、2 時間(120分)以内の入力とします。なお、テープ残量は標準録画モードと 3 倍録画モードの場合の2通りを計算し、出力例のように時、分、秒とも 2 桁ずつ出力します。また \"05\" のように 10 の位が 0 の場合は、\"0\" をつけてください。\n\n入力\n\n複数のデータセットが与えられます。各データセットは以下のとおりです。\n\nT H S\n\nT, H, S はそれぞれ時、分、秒を表す整数です。\n\nT, H, S がすべて -1 のとき入力の終わりとします。データセットの数は 50 を超えません。\n\n出力\n\n各データセットごとに\n\n1 行目に、テープの残りを標準録画した場合の録画可能時間の時、分、秒を半角コロン区切りで、\n\n2 行目に、テープの残りを3倍録画した場合の録画可能時間の時、分、秒を半角コロン区切りで\n\n出力して下さい。\n\nSample Input\n\n1 30 0\n-1 -1 -1\n\nOutput for the Sample Input\n\n00:30:00\n01:30:00", "sample_input": "1 30 0\n-1 -1 -1\n"}, "reference_outputs": ["00:30:00\n01:30:00\n"], "source_document_id": "p00074", "source_text": "ビデオテープ\n\n標準録画で 120 分のビデオテープがあります。テープを完全に巻き戻した状態でビデオデッキのカウンタを 00:00:00 にし、標準録画モードで録画したところ、あるカウンタ値になりました。このカウンタ値(時、分、秒)を入力し、残りのテープの長さ(録画可能時間)を求め、時:分:秒の形式で出力するプログラムを作成して下さい。\n\nただし、2 時間(120分)以内の入力とします。なお、テープ残量は標準録画モードと 3 倍録画モードの場合の2通りを計算し、出力例のように時、分、秒とも 2 桁ずつ出力します。また \"05\" のように 10 の位が 0 の場合は、\"0\" をつけてください。\n\n入力\n\n複数のデータセットが与えられます。各データセットは以下のとおりです。\n\nT H S\n\nT, H, S はそれぞれ時、分、秒を表す整数です。\n\nT, H, S がすべて -1 のとき入力の終わりとします。データセットの数は 50 を超えません。\n\n出力\n\n各データセットごとに\n\n1 行目に、テープの残りを標準録画した場合の録画可能時間の時、分、秒を半角コロン区切りで、\n\n2 行目に、テープの残りを3倍録画した場合の録画可能時間の時、分、秒を半角コロン区切りで\n\n出力して下さい。\n\nSample Input\n\n1 30 0\n-1 -1 -1\n\nOutput for the Sample Input\n\n00:30:00\n01:30:00", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 250, "memory_kb": 44660}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s989084616", "group_id": "codeNet:p00083", "input_text": "import scala.io.Source.stdin\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main extends App {\n def to(a:Array[Int],y:Int,m:Int,d:Int) =\n (a(0)\n val n = s.split(\" \").map(_.toInt)\n if(to(n,1868,9,8)) b+=\"pre-meiji\"\n else if(to(n,1912,7,29)) b+=\"meiji \" + (n(0)-1867) + \" \" + n(1) + \" \" + n(2)\n else if(to(n,1926,12,24)) b+=\"taisho \" + (n(0)-1911) + \" \" + n(1) + \" \" + n(2)\n else if(to(n,1989,1,7)) b+=\"showa \" + (n(0)-1925) + \" \" + n(1) + \" \" + n(2)\n else b+=\"heisei \" + (n(0)-1988) + \" \" + n(1) + \" \" + n(2)\n }\n println(b.mkString(\"\\n\"))\n}", "language": "Scala", "metadata": {"date": 1488547731, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00083.html", "problem_id": "p00083", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00083/input.txt", "sample_output_relpath": "derived/input_output/data/p00083/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00083/Scala/s989084616.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s989084616", "user_id": "u508732591"}, "prompt_components": {"gold_output": "heisei 17 9 3\nmeiji 1 12 2\npre-meiji\n", "input_to_evaluate": "import scala.io.Source.stdin\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main extends App {\n def to(a:Array[Int],y:Int,m:Int,d:Int) =\n (a(0)\n val n = s.split(\" \").map(_.toInt)\n if(to(n,1868,9,8)) b+=\"pre-meiji\"\n else if(to(n,1912,7,29)) b+=\"meiji \" + (n(0)-1867) + \" \" + n(1) + \" \" + n(2)\n else if(to(n,1926,12,24)) b+=\"taisho \" + (n(0)-1911) + \" \" + n(1) + \" \" + n(2)\n else if(to(n,1989,1,7)) b+=\"showa \" + (n(0)-1925) + \" \" + n(1) + \" \" + n(2)\n else b+=\"heisei \" + (n(0)-1988) + \" \" + n(1) + \" \" + n(2)\n }\n println(b.mkString(\"\\n\"))\n}", "problem_context": "西暦和暦変換\n\n西暦で表された年月日を、元号を用いた和暦に変換し、その年月日を出力するプログラムを作成してください。入力は例に示すように 3 つの整数であり、順に西暦年、月、日です。これを、出力例に示すように変換してください。なお、明治以前の年月日が入力された場合は「pre-meiji」と表示してください。\n\n各年号の最初の年は「元年」ではなく「1年」と出力することとします。\n\n元号\n\n期間\n\nmeiji\n\n1868. 9. 8 〜 1912. 7.29\n\ntaisho\n\n1912. 7.30 〜 1926.12.24\n\nshowa\n\n1926.12.25 〜 1989. 1. 7\n\nheisei\n\n1989. 1. 8 〜\n\n入力\n\n複数のデータが与えられます。各データとして年、月、日を表す3つの整数が空白区切りで1行に与えられます。\n\n入力の終わりまで処理してください。データの数は 50 を超えません。\n\n出力\n\n空白区切りの元号、年、月、日、または「pre-meiji」を1行に出力してください。\n\nSample Input\n\n2005 9 3\n1868 12 2\n1868 9 7\n\nOutput for the Sample Input\n\nheisei 17 9 3\nmeiji 1 12 2\npre-meiji", "sample_input": "2005 9 3\n1868 12 2\n1868 9 7\n"}, "reference_outputs": ["heisei 17 9 3\nmeiji 1 12 2\npre-meiji\n"], "source_document_id": "p00083", "source_text": "西暦和暦変換\n\n西暦で表された年月日を、元号を用いた和暦に変換し、その年月日を出力するプログラムを作成してください。入力は例に示すように 3 つの整数であり、順に西暦年、月、日です。これを、出力例に示すように変換してください。なお、明治以前の年月日が入力された場合は「pre-meiji」と表示してください。\n\n各年号の最初の年は「元年」ではなく「1年」と出力することとします。\n\n元号\n\n期間\n\nmeiji\n\n1868. 9. 8 〜 1912. 7.29\n\ntaisho\n\n1912. 7.30 〜 1926.12.24\n\nshowa\n\n1926.12.25 〜 1989. 1. 7\n\nheisei\n\n1989. 1. 8 〜\n\n入力\n\n複数のデータが与えられます。各データとして年、月、日を表す3つの整数が空白区切りで1行に与えられます。\n\n入力の終わりまで処理してください。データの数は 50 を超えません。\n\n出力\n\n空白区切りの元号、年、月、日、または「pre-meiji」を1行に出力してください。\n\nSample Input\n\n2005 9 3\n1868 12 2\n1868 9 7\n\nOutput for the Sample Input\n\nheisei 17 9 3\nmeiji 1 12 2\npre-meiji", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 695, "cpu_time_ms": 220, "memory_kb": 44100}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s028959120", "group_id": "codeNet:p00109", "input_text": "\nobject Main extends App{\n import scala.io.StdIn.{readLine}\n type Operator = Option[((Int, Int) ⇒ Int, List[Char])]\n type CharParseResult = Option[(Char, List[Char])]\n type ParseResult = Option[(List[Char], List[Char])]\n type CalResult = Option[(Int, List[Char])]\n type CalMidResult = Option[(Int ⇒ Int, List[Char])]\n for (_ ← 0 until readLine().toInt){\n println(readLine().toList match {\n case value AsExpression '='::Nil ⇒ value\n case _ ⇒ ???\n })\n }\n object AsDigit{\n def unapply(arg: List[Char]):CharParseResult = arg match{\n case h::t if h.isDigit ⇒ Some(h, t)\n case _ ⇒ None\n }\n }\n object AsNumber{\n def unapply(arg: List[Char]):ParseResult = arg match{\n case digit AsDigit (number AsNumber rest) ⇒ Some(digit::number, rest)\n case digit AsDigit rest ⇒ Some(digit::Nil, rest)\n case _ ⇒ None\n }\n }\n object AsParenthesis{\n def unapply(arg: List[Char]): CalResult = arg match{\n case '(':: (result AsExpression ')':: rest)⇒ Some(result, rest)\n case _ ⇒ None\n }\n }\n object AsTerm{\n def unapply(arg: List[Char]):CalResult = arg match{\n case number AsNumber rest ⇒ Some(number.mkString.toInt, rest)\n case value AsParenthesis rest ⇒ Some(value, rest)\n case _ ⇒ None\n }\n }\n object AsHighPriorityOperator{\n def unapply(arg: List[Char]):Operator = arg match{\n case '*'::rest ⇒ Some(_ * _ , rest)\n case '/'::rest ⇒ Some(_ / _, rest)\n case _ ⇒ None\n }\n }\n object AsLowPriorityOperator{\n def unapply(arg: List[Char]):Operator = arg match{\n case '+'::rest ⇒ Some(_ + _, rest)\n case '-'::rest ⇒ Some(_ - _, rest)\n case _ ⇒ None\n }\n }\n implicit class BinomialOperator(val operator:(Int, Int) ⇒ Int){\n def <|(num:Int):Int ⇒ Int = operator(_, num)\n }\n implicit class MonomialOperator(val number:Int){\n def |>(op:Int ⇒ Int):Int = op(number)\n }\n object AsHighPriorityOperation{\n def unapply(arg: List[Char]):CalMidResult = arg match{\n case op AsHighPriorityOperator (term AsTerm (converter AsHighPriorityOperation rest)) ⇒ Some(op <| term andThen converter, rest)\n case op AsHighPriorityOperator (term AsTerm rest) ⇒ Some(op <| term, rest)\n case _ ⇒ None\n }\n }\n object AsHighPriorityPartial{\n def unapply(arg: List[Char]):CalResult = arg match{\n case term AsTerm (converter AsHighPriorityOperation rest) ⇒ Some(term |> converter, rest)\n case term AsTerm rest ⇒ Some(term, rest)\n case _ ⇒ None\n }\n }\n object AsLowPriorityOperation{\n def unapply(arg: List[Char]):CalMidResult = arg match{\n case op AsLowPriorityOperator (partial AsHighPriorityPartial (converter AsLowPriorityOperation rest)) ⇒ Some(op <| partial andThen converter, rest)\n case op AsLowPriorityOperator (partial AsHighPriorityPartial rest) ⇒ Some(op <| partial, rest)\n case _ ⇒ None\n }\n }\n object AsExpression{\n def unapply(arg: List[Char]): CalResult = arg match{\n case left AsHighPriorityPartial (right AsLowPriorityOperation rest) ⇒ Some(left |> right, rest)\n case value AsHighPriorityPartial rest ⇒ Some(value, rest)\n case _ ⇒ None\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1527421436, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00109.html", "problem_id": "p00109", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00109/input.txt", "sample_output_relpath": "derived/input_output/data/p00109/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00109/Scala/s028959120.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s028959120", "user_id": "u514597327"}, "prompt_components": {"gold_output": "-2\n60\n", "input_to_evaluate": "\nobject Main extends App{\n import scala.io.StdIn.{readLine}\n type Operator = Option[((Int, Int) ⇒ Int, List[Char])]\n type CharParseResult = Option[(Char, List[Char])]\n type ParseResult = Option[(List[Char], List[Char])]\n type CalResult = Option[(Int, List[Char])]\n type CalMidResult = Option[(Int ⇒ Int, List[Char])]\n for (_ ← 0 until readLine().toInt){\n println(readLine().toList match {\n case value AsExpression '='::Nil ⇒ value\n case _ ⇒ ???\n })\n }\n object AsDigit{\n def unapply(arg: List[Char]):CharParseResult = arg match{\n case h::t if h.isDigit ⇒ Some(h, t)\n case _ ⇒ None\n }\n }\n object AsNumber{\n def unapply(arg: List[Char]):ParseResult = arg match{\n case digit AsDigit (number AsNumber rest) ⇒ Some(digit::number, rest)\n case digit AsDigit rest ⇒ Some(digit::Nil, rest)\n case _ ⇒ None\n }\n }\n object AsParenthesis{\n def unapply(arg: List[Char]): CalResult = arg match{\n case '(':: (result AsExpression ')':: rest)⇒ Some(result, rest)\n case _ ⇒ None\n }\n }\n object AsTerm{\n def unapply(arg: List[Char]):CalResult = arg match{\n case number AsNumber rest ⇒ Some(number.mkString.toInt, rest)\n case value AsParenthesis rest ⇒ Some(value, rest)\n case _ ⇒ None\n }\n }\n object AsHighPriorityOperator{\n def unapply(arg: List[Char]):Operator = arg match{\n case '*'::rest ⇒ Some(_ * _ , rest)\n case '/'::rest ⇒ Some(_ / _, rest)\n case _ ⇒ None\n }\n }\n object AsLowPriorityOperator{\n def unapply(arg: List[Char]):Operator = arg match{\n case '+'::rest ⇒ Some(_ + _, rest)\n case '-'::rest ⇒ Some(_ - _, rest)\n case _ ⇒ None\n }\n }\n implicit class BinomialOperator(val operator:(Int, Int) ⇒ Int){\n def <|(num:Int):Int ⇒ Int = operator(_, num)\n }\n implicit class MonomialOperator(val number:Int){\n def |>(op:Int ⇒ Int):Int = op(number)\n }\n object AsHighPriorityOperation{\n def unapply(arg: List[Char]):CalMidResult = arg match{\n case op AsHighPriorityOperator (term AsTerm (converter AsHighPriorityOperation rest)) ⇒ Some(op <| term andThen converter, rest)\n case op AsHighPriorityOperator (term AsTerm rest) ⇒ Some(op <| term, rest)\n case _ ⇒ None\n }\n }\n object AsHighPriorityPartial{\n def unapply(arg: List[Char]):CalResult = arg match{\n case term AsTerm (converter AsHighPriorityOperation rest) ⇒ Some(term |> converter, rest)\n case term AsTerm rest ⇒ Some(term, rest)\n case _ ⇒ None\n }\n }\n object AsLowPriorityOperation{\n def unapply(arg: List[Char]):CalMidResult = arg match{\n case op AsLowPriorityOperator (partial AsHighPriorityPartial (converter AsLowPriorityOperation rest)) ⇒ Some(op <| partial andThen converter, rest)\n case op AsLowPriorityOperator (partial AsHighPriorityPartial rest) ⇒ Some(op <| partial, rest)\n case _ ⇒ None\n }\n }\n object AsExpression{\n def unapply(arg: List[Char]): CalResult = arg match{\n case left AsHighPriorityPartial (right AsLowPriorityOperation rest) ⇒ Some(left |> right, rest)\n case value AsHighPriorityPartial rest ⇒ Some(value, rest)\n case _ ⇒ None\n }\n }\n}\n", "problem_context": "Smart Calculator\n\nYour task is to write a program which reads an expression and evaluates it.\n\nThe expression consists of numerical values, operators and parentheses, and the ends with '='.\n\nThe operators includes +, - , *, / where respectively represents, addition, subtraction, multiplication and division.\n\nPrecedence of the operators is based on usual laws. That is one should perform all multiplication and division first, then addition and subtraction. When two operators have the same precedence, they are applied from left to right.\n\nYou may assume that there is no division by zero.\n\nAll calculation is performed as integers, and after the decimal point should be truncated\n\nLength of the expression will not exceed 100.\n\n-1 × 109 ≤ intermediate results of computation ≤ 109\n\nInput\n\nThe input is a sequence of datasets. The first line contains an integer n which represents the number of datasets. There will be n lines where each line contains an expression.\n\nOutput\n\nFor each datasets, prints the result of calculation.\n\nSample Input\n\n2\n4-2*3=\n4*(8+4+3)=\n\nOutput for the Sample Input\n\n-2\n60", "sample_input": "2\n4-2*3=\n4*(8+4+3)=\n"}, "reference_outputs": ["-2\n60\n"], "source_document_id": "p00109", "source_text": "Smart Calculator\n\nYour task is to write a program which reads an expression and evaluates it.\n\nThe expression consists of numerical values, operators and parentheses, and the ends with '='.\n\nThe operators includes +, - , *, / where respectively represents, addition, subtraction, multiplication and division.\n\nPrecedence of the operators is based on usual laws. That is one should perform all multiplication and division first, then addition and subtraction. When two operators have the same precedence, they are applied from left to right.\n\nYou may assume that there is no division by zero.\n\nAll calculation is performed as integers, and after the decimal point should be truncated\n\nLength of the expression will not exceed 100.\n\n-1 × 109 ≤ intermediate results of computation ≤ 109\n\nInput\n\nThe input is a sequence of datasets. The first line contains an integer n which represents the number of datasets. There will be n lines where each line contains an expression.\n\nOutput\n\nFor each datasets, prints the result of calculation.\n\nSample Input\n\n2\n4-2*3=\n4*(8+4+3)=\n\nOutput for the Sample Input\n\n-2\n60", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3217, "cpu_time_ms": 310, "memory_kb": 52088}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s098533670", "group_id": "codeNet:p00111", "input_text": "import scala.io.StdIn.{readInt,readLine}\n\nobject Main {\n val codes = {for(i<-'A' to 'Z') yield i->(\"00000\"+(i-65).toBinaryString).takeRight(5)}\n .toMap ++ Map(' '->\"11010\",'.'->\"11011\",','->\"11100\",'-'->\"11101\",'\\''->\"11110\",'?'->\"11111\")\n\n val str = Map(\"101\"->' ',\"000000\"->'\\'', \"000011\"->',',\n \"10010001\"->'-',\"010001\"->'.',\"000001\"->'?',\n \"100101\"->'A',\"10011010\"->'B',\"0101\"->'C',\"0001\"->'D',\n \"110\"->'E',\"01001\"->'F',\"10011011\"->'G',\"010000\"->'H',\n \"0111\"->'I',\"10011000\"->'J',\"0110\"->'K',\"00100\"->'L',\n \"10011001\"->'M',\"10011110\"->'N',\"00101\"->'O',\"111\"->'P',\n \"10011111\"->'Q',\"1000\"->'R',\"00110\"->'S',\"00111\"->'T',\n \"10011100\"->'U',\"10011101\"->'V',\"000010\"->'W',\"10010010\"->'X',\n \"10010011\"->'Y',\"10010000\"->'Z')\n\n def scan(s:String,r:String):String = {\n def loop(i:Int):(String,String) = {\n if(i==9) (s,\"\")\n else{\n val s2 = s.take(i)\n if(str.contains(s2)) (s.drop(i),str(s2).toString)\n else loop(i+1)\n }\n }\n val x=loop(3)\n if(x._2!=\"\") scan(x._1,r+x._2)\n else r\n }\n\n def main(args:Array[String]) = {\n val s = readLine.trim.map(codes(_)).mkString\n println(scan(s,\"\"))\n }\n}", "language": "Scala", "metadata": {"date": 1490007926, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00111.html", "problem_id": "p00111", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00111/input.txt", "sample_output_relpath": "derived/input_output/data/p00111/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00111/Scala/s098533670.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s098533670", "user_id": "u508732591"}, "prompt_components": {"gold_output": "PETER POTTER\n", "input_to_evaluate": "import scala.io.StdIn.{readInt,readLine}\n\nobject Main {\n val codes = {for(i<-'A' to 'Z') yield i->(\"00000\"+(i-65).toBinaryString).takeRight(5)}\n .toMap ++ Map(' '->\"11010\",'.'->\"11011\",','->\"11100\",'-'->\"11101\",'\\''->\"11110\",'?'->\"11111\")\n\n val str = Map(\"101\"->' ',\"000000\"->'\\'', \"000011\"->',',\n \"10010001\"->'-',\"010001\"->'.',\"000001\"->'?',\n \"100101\"->'A',\"10011010\"->'B',\"0101\"->'C',\"0001\"->'D',\n \"110\"->'E',\"01001\"->'F',\"10011011\"->'G',\"010000\"->'H',\n \"0111\"->'I',\"10011000\"->'J',\"0110\"->'K',\"00100\"->'L',\n \"10011001\"->'M',\"10011110\"->'N',\"00101\"->'O',\"111\"->'P',\n \"10011111\"->'Q',\"1000\"->'R',\"00110\"->'S',\"00111\"->'T',\n \"10011100\"->'U',\"10011101\"->'V',\"000010\"->'W',\"10010010\"->'X',\n \"10010011\"->'Y',\"10010000\"->'Z')\n\n def scan(s:String,r:String):String = {\n def loop(i:Int):(String,String) = {\n if(i==9) (s,\"\")\n else{\n val s2 = s.take(i)\n if(str.contains(s2)) (s.drop(i),str(s2).toString)\n else loop(i+1)\n }\n }\n val x=loop(3)\n if(x._2!=\"\") scan(x._1,r+x._2)\n else r\n }\n\n def main(args:Array[String]) = {\n val s = readLine.trim.map(codes(_)).mkString\n println(scan(s,\"\"))\n }\n}", "problem_context": "博士の暗号\n\n博 士 : ?D-C'KOPUA\n\nピーター : どうしたんですか、デビッド博士? わけのわからないことを叫ぶのにはもう慣れましたが、\n今日は文章にすらなっていませんよ。\n\n博 士 : ほれ。\n\nピーター : なんですか? この表は......ああ、予選の問題にこんなのがありました。表を使って文字を置き換え\nると文字数が減るんですよね。まさか予選と本選で同じ問題を出して手を抜こうって気じゃないでし\nょうね。\n\n博 士 : 逆じゃよ。\n\nピーター : 逆? なるほど、今度は短くした文字列を元に戻そうって問題ですか。ということは「?D-C'KOPUA」の\n文字を、この表を使って「文字」から「符号」に置きかえるんですね......できましたよ。\n\n11111 00011 11101 00010 11110 01010 01110 01111 10100 00000\n\n博 士 : うむ。次はこれじゃ。\n\nピーター : そうそう、こんな表もありましたね。これを逆に使うんだから「符号」から「文字」に置き換えればいい\nんですね。でも、最初は「11111」ですが表にありませんよ?\n\n博 士 : そういうときは、もっと短くするか、後ろとつなげるかしてみるのだよ。\n\nピ ー タ ー : じゃあ短くして......あ、 「111」ならあります。じゃあ最初は「P」ですね。そうすると残りは「11」ですが、\nこれはぴったり合うのがないから次の「00011」から 1 文字借りて「110」にすればいいんですね。\n\n博 士 : そうそう。つまり「E」だね。\n\nピ ー タ ー : それで残るのが「0011」なので、これも次から借りて「00111」にして「T」と......。全部できました。最\n後の「0000」は捨てちゃえばいいんですよね?\n\n博 士 : そうじゃ、よろしい。次はこれじゃ。\n\n?D-C'?-C'-LMGZN?FNJKN- WEYN?P'QMRWLPZLKKTPOVRGDI\n\n博 士 : さらにこれじゃ。\n\n?P'QNPY?IXX?IXXK.BI -G?R'RPP'RPOVWDMW?SWUVG'-LCMGQ\n\n博 士 : 仕上げにこうじゃ。\n\n?P'QMDUEQ GADKOQ ?SWUVG'-LCMG?X?IGX,PUL.?UL.VNQQI\n\nピ ー タ ー : しっかし面倒だなあ。博士、今度は自分でプログラムを作って下さいよ。\n\nということで、博士のかわりに、上の文章を置き換えるプログラムを作成してください。\n\nInput\n\n複数のデータセットが与えられます。各データセットとして、1つの文字列(表に含まれる文字からなる 200 文字以下の文字列)が1行に与えられます。入力の終わりまで処理してください。データセットの数は 200 を超えません。\n\nOutput\n\n各データセットごとに、変換後の文字列を1行に出力してください。\n\nSample Input\n\n?D-C'KOPUA\n\nOutput for the Sample Input\n\nPETER POTTER", "sample_input": "?D-C'KOPUA\n"}, "reference_outputs": ["PETER POTTER\n"], "source_document_id": "p00111", "source_text": "博士の暗号\n\n博 士 : ?D-C'KOPUA\n\nピーター : どうしたんですか、デビッド博士? わけのわからないことを叫ぶのにはもう慣れましたが、\n今日は文章にすらなっていませんよ。\n\n博 士 : ほれ。\n\nピーター : なんですか? この表は......ああ、予選の問題にこんなのがありました。表を使って文字を置き換え\nると文字数が減るんですよね。まさか予選と本選で同じ問題を出して手を抜こうって気じゃないでし\nょうね。\n\n博 士 : 逆じゃよ。\n\nピーター : 逆? なるほど、今度は短くした文字列を元に戻そうって問題ですか。ということは「?D-C'KOPUA」の\n文字を、この表を使って「文字」から「符号」に置きかえるんですね......できましたよ。\n\n11111 00011 11101 00010 11110 01010 01110 01111 10100 00000\n\n博 士 : うむ。次はこれじゃ。\n\nピーター : そうそう、こんな表もありましたね。これを逆に使うんだから「符号」から「文字」に置き換えればいい\nんですね。でも、最初は「11111」ですが表にありませんよ?\n\n博 士 : そういうときは、もっと短くするか、後ろとつなげるかしてみるのだよ。\n\nピ ー タ ー : じゃあ短くして......あ、 「111」ならあります。じゃあ最初は「P」ですね。そうすると残りは「11」ですが、\nこれはぴったり合うのがないから次の「00011」から 1 文字借りて「110」にすればいいんですね。\n\n博 士 : そうそう。つまり「E」だね。\n\nピ ー タ ー : それで残るのが「0011」なので、これも次から借りて「00111」にして「T」と......。全部できました。最\n後の「0000」は捨てちゃえばいいんですよね?\n\n博 士 : そうじゃ、よろしい。次はこれじゃ。\n\n?D-C'?-C'-LMGZN?FNJKN- WEYN?P'QMRWLPZLKKTPOVRGDI\n\n博 士 : さらにこれじゃ。\n\n?P'QNPY?IXX?IXXK.BI -G?R'RPP'RPOVWDMW?SWUVG'-LCMGQ\n\n博 士 : 仕上げにこうじゃ。\n\n?P'QMDUEQ GADKOQ ?SWUVG'-LCMG?X?IGX,PUL.?UL.VNQQI\n\nピ ー タ ー : しっかし面倒だなあ。博士、今度は自分でプログラムを作って下さいよ。\n\nということで、博士のかわりに、上の文章を置き換えるプログラムを作成してください。\n\nInput\n\n複数のデータセットが与えられます。各データセットとして、1つの文字列(表に含まれる文字からなる 200 文字以下の文字列)が1行に与えられます。入力の終わりまで処理してください。データセットの数は 200 を超えません。\n\nOutput\n\n各データセットごとに、変換後の文字列を1行に出力してください。\n\nSample Input\n\n?D-C'KOPUA\n\nOutput for the Sample Input\n\nPETER POTTER", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1177, "cpu_time_ms": 250, "memory_kb": 44624}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s194475021", "group_id": "codeNet:p00124", "input_text": "import scala.io.StdIn.{readInt,readLine}\n\nobject Main extends App {\n println {\n Iterator.continually(readInt).takeWhile(_!=0).map { n =>\n { for(i<-1 to n) yield {\n val t = readLine.split(\" \")\n (t(0),t(1).toInt*3 + t(3).toInt*1)\n }\n }.sortWith( _._2 > _._2).map{ e => e._1 + \",\" + e._2 }.mkString(\"\\n\")\n }.mkString(\"\\n\\n\")\n }\n}", "language": "Scala", "metadata": {"date": 1487863330, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00124.html", "problem_id": "p00124", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00124/input.txt", "sample_output_relpath": "derived/input_output/data/p00124/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00124/Scala/s194475021.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s194475021", "user_id": "u508732591"}, "prompt_components": {"gold_output": "Spain,7\nJapan,5\nEgypt,3\nCanada,1\n\nPoland,4\nItaly,4\nIndia,0\n", "input_to_evaluate": "import scala.io.StdIn.{readInt,readLine}\n\nobject Main extends App {\n println {\n Iterator.continually(readInt).takeWhile(_!=0).map { n =>\n { for(i<-1 to n) yield {\n val t = readLine.split(\" \")\n (t(0),t(1).toInt*3 + t(3).toInt*1)\n }\n }.sortWith( _._2 > _._2).map{ e => e._1 + \",\" + e._2 }.mkString(\"\\n\")\n }.mkString(\"\\n\\n\")\n }\n}", "problem_context": "リーグ戦のスコアシート\n\nスポーツの大会にはリーグ戦とトーナメント戦があります。サッカーのリーグ戦では勝・負・引分にそれぞれ点数を付け、その勝ち点で順位を競います。勝ち点はそれぞれ勝(3点)、負(0点)、引分(1点)です。\n\nチーム数とリーグ戦の成績を入力とし、成績の良い順(勝ち点の多い順)に並べ替え、チーム名と勝ち点を出力するプログラムを作成してください。勝ち点が同点の場合は入力順に出力してください。\n\nInput\n\n複数のデータセットが与えられます。各データセットは以下の形式で与えられます。\n\nn\nname1 w1 l1 d1\nname2 w2 l2 d2\n:\nnamen wn ln dn\n\n1行目にチーム数 n (n ≤ 10) が与えられます。続く n 行にチーム i の名前 namei (20文字以内のアルファベット)、勝の数 wi、負の数 li、引分の数 di (0 ≤ wi, li, di ≤ 9) が空白区切りで与えられます。\n\nチーム数が 0 のとき、入力の終了とします。データセットの数は 50 を超えません。\n\nOutput\n\nデータセットごとに、並べ替えたチームのリストを出力してください。i 行目に i 番目のチームの名前と勝ち点をカンマで区切って出力してください。\n\nデータセットの間に1つの空行を入れてください。\n\nSample Input\n\n4\nJapan 1 0 2\nEgypt 1 2 0\nCanada 0 2 1\nSpain 2 0 1\n3\nIndia 0 2 0\nPoland 1 0 1\nItaly 1 0 1\n0\n\nOutput for the Sample Input\n\nSpain,7\nJapan,5\nEgypt,3\nCanada,1\n\nPoland,4\nItaly,4\nIndia,0", "sample_input": "4\nJapan 1 0 2\nEgypt 1 2 0\nCanada 0 2 1\nSpain 2 0 1\n3\nIndia 0 2 0\nPoland 1 0 1\nItaly 1 0 1\n0\n"}, "reference_outputs": ["Spain,7\nJapan,5\nEgypt,3\nCanada,1\n\nPoland,4\nItaly,4\nIndia,0\n"], "source_document_id": "p00124", "source_text": "リーグ戦のスコアシート\n\nスポーツの大会にはリーグ戦とトーナメント戦があります。サッカーのリーグ戦では勝・負・引分にそれぞれ点数を付け、その勝ち点で順位を競います。勝ち点はそれぞれ勝(3点)、負(0点)、引分(1点)です。\n\nチーム数とリーグ戦の成績を入力とし、成績の良い順(勝ち点の多い順)に並べ替え、チーム名と勝ち点を出力するプログラムを作成してください。勝ち点が同点の場合は入力順に出力してください。\n\nInput\n\n複数のデータセットが与えられます。各データセットは以下の形式で与えられます。\n\nn\nname1 w1 l1 d1\nname2 w2 l2 d2\n:\nnamen wn ln dn\n\n1行目にチーム数 n (n ≤ 10) が与えられます。続く n 行にチーム i の名前 namei (20文字以内のアルファベット)、勝の数 wi、負の数 li、引分の数 di (0 ≤ wi, li, di ≤ 9) が空白区切りで与えられます。\n\nチーム数が 0 のとき、入力の終了とします。データセットの数は 50 を超えません。\n\nOutput\n\nデータセットごとに、並べ替えたチームのリストを出力してください。i 行目に i 番目のチームの名前と勝ち点をカンマで区切って出力してください。\n\nデータセットの間に1つの空行を入れてください。\n\nSample Input\n\n4\nJapan 1 0 2\nEgypt 1 2 0\nCanada 0 2 1\nSpain 2 0 1\n3\nIndia 0 2 0\nPoland 1 0 1\nItaly 1 0 1\n0\n\nOutput for the Sample Input\n\nSpain,7\nJapan,5\nEgypt,3\nCanada,1\n\nPoland,4\nItaly,4\nIndia,0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 369, "cpu_time_ms": 240, "memory_kb": 44084}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s601184188", "group_id": "codeNet:p00131", "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 sc.nextLine\n for(i <- 1 to n) {\n val fld = (1 to 10).toList.map(_ => Integer.parseInt(sc.nextLine.split(\" \").mkString(\"\").reverse, 2))\n solve(0, 0, Nil, fld, Nil).foreach(bits => println(Integer.toBinaryString(bits).reverse.padTo(10, '0').split(\"\").mkString(\" \")))\n }\n }\n\n def beam(y: Int, x: Int, fld: List[Int]): List[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 dir.foldLeft(fld)((acc, p) => flip(acc, p._1, p._2) )\n }\n\n def flip(fld: List[Int], y: Int, x: Int): List[Int] = {\n val bits = fld(y) ^ (1 << x)\n (0 to 9).toList.map((i) => if(i == y) bits else fld(i))\n }\n\n def holizontal(y: Int, x: Int, bits: Int, acc: Int, fld: List[Int]): (Int, List[Int]) = {\n if(x == 10) (acc, fld)\n else {\n if((bits & (1 << x)) != 0) holizontal(y, x + 1, bits, acc + (1 << x), beam(y, x, fld))\n else holizontal(y, x + 1, bits, acc, fld)\n }\n }\n\n def solve(bits: Int, y: Int, ans: List[Int], fld: List[Int], nfld: List[Int]): List[Int] = {\n if(y == 0) {\n val ret = holizontal(0, 0, bits, 0, fld)\n solve(bits, y + 1, List(ret._1), fld, ret._2)\n }\n else if(bits == 1024) {\n println(\"no ans\")\n ans\n }\n else if(y == 10) if(nfld(9) == 0) ans else solve(bits + 1, 0, Nil, fld, nfld)\n else {\n val ret = holizontal(y, 0, nfld(y-1), 0, nfld)\n solve(bits, y + 1, ans ::: List(ret._1), fld, ret._2)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1459824025, "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/s601184188.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Memory Limit Exceeded", "submission_id": "s601184188", "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 def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n sc.nextLine\n for(i <- 1 to n) {\n val fld = (1 to 10).toList.map(_ => Integer.parseInt(sc.nextLine.split(\" \").mkString(\"\").reverse, 2))\n solve(0, 0, Nil, fld, Nil).foreach(bits => println(Integer.toBinaryString(bits).reverse.padTo(10, '0').split(\"\").mkString(\" \")))\n }\n }\n\n def beam(y: Int, x: Int, fld: List[Int]): List[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 dir.foldLeft(fld)((acc, p) => flip(acc, p._1, p._2) )\n }\n\n def flip(fld: List[Int], y: Int, x: Int): List[Int] = {\n val bits = fld(y) ^ (1 << x)\n (0 to 9).toList.map((i) => if(i == y) bits else fld(i))\n }\n\n def holizontal(y: Int, x: Int, bits: Int, acc: Int, fld: List[Int]): (Int, List[Int]) = {\n if(x == 10) (acc, fld)\n else {\n if((bits & (1 << x)) != 0) holizontal(y, x + 1, bits, acc + (1 << x), beam(y, x, fld))\n else holizontal(y, x + 1, bits, acc, fld)\n }\n }\n\n def solve(bits: Int, y: Int, ans: List[Int], fld: List[Int], nfld: List[Int]): List[Int] = {\n if(y == 0) {\n val ret = holizontal(0, 0, bits, 0, fld)\n solve(bits, y + 1, List(ret._1), fld, ret._2)\n }\n else if(bits == 1024) {\n println(\"no ans\")\n ans\n }\n else if(y == 10) if(nfld(9) == 0) ans else solve(bits + 1, 0, Nil, fld, nfld)\n else {\n val ret = holizontal(y, 0, nfld(y-1), 0, nfld)\n solve(bits, y + 1, ans ::: List(ret._1), fld, ret._2)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1765, "cpu_time_ms": 1150, "memory_kb": 446968}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s192289203", "group_id": "codeNet:p00131", "input_text": "object Main {\n val fld = Array.ofDim[Int](10)\n val ans = Array.ofDim[Int](10)\n val my = List(0, -1, 0, 1, 0)\n val mx = List(0, 0, -1, 0, 1)\n def beam(y: Int, x: Int) = {\n val target = my.zip(mx).map(mv => (mv._1 + y, mv._2 + x))\n .filter(p => 0 <= p._1 && p._1 < 10 && 0 <= p._2 && p._2 < 10)\n for(p <- target) {\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 => \n println(Integer.toBinaryString(bits).reverse.padTo(10, '0')\n .split(\"\").mkString(\" \")))\n flag = false\n }\n else i += 1\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(_ => \n Integer.parseInt(sc.nextLine.split(\" \").mkString(\"\").reverse, 2))\n solve(orig)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1459845175, "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/s192289203.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Memory Limit Exceeded", "submission_id": "s192289203", "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 val my = List(0, -1, 0, 1, 0)\n val mx = List(0, 0, -1, 0, 1)\n def beam(y: Int, x: Int) = {\n val target = my.zip(mx).map(mv => (mv._1 + y, mv._2 + x))\n .filter(p => 0 <= p._1 && p._1 < 10 && 0 <= p._2 && p._2 < 10)\n for(p <- target) {\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 => \n println(Integer.toBinaryString(bits).reverse.padTo(10, '0')\n .split(\"\").mkString(\" \")))\n flag = false\n }\n else i += 1\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(_ => \n 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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1626, "cpu_time_ms": 630, "memory_kb": 332640}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s951154291", "group_id": "codeNet:p00137", "input_text": "import scala.io.StdIn.readInt\n\nobject Main extends App {\n val n = readInt\n for(i <- 1 to n) {\n var m = readInt\n\n println(\"Case \" + i + \":\")\n for(j <- 1 to 10){\n m = \"%08d\".format(m*m).substring(2,6).toInt\n println(m)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1487598744, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00137.html", "problem_id": "p00137", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00137/input.txt", "sample_output_relpath": "derived/input_output/data/p00137/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00137/Scala/s951154291.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s951154291", "user_id": "u508732591"}, "prompt_components": {"gold_output": "Case 1:\n151\n228\n519\n2693\n2522\n3604\n9888\n7725\n6756\n6435\nCase 2:\n3214\n3297\n8702\n7248\n5335\n4622\n3628\n1623\n6341\n2082\n", "input_to_evaluate": "import scala.io.StdIn.readInt\n\nobject Main extends App {\n val n = readInt\n for(i <- 1 to n) {\n var m = readInt\n\n println(\"Case \" + i + \":\")\n for(j <- 1 to 10){\n m = \"%08d\".format(m*m).substring(2,6).toInt\n println(m)\n }\n }\n}", "problem_context": "平方採中法\n\n古典的な乱数生成方法の一つである平方採中法のプログラムを作成します。平方採中法は、フォンノイマンによって 1940 年代半ばに提案された方法です。\n\n平方採中法は、生成する乱数の桁数を n としたとき、初期値 s の2乗を計算し、その数値を 2n 桁の数値とみて、(下の例のように 2 乗した桁数が足りないときは、0 を補います。)その中央にある n 個の数字を最初の乱数とします。次にこの乱数を 2 乗して、同じ様に、中央にある n 個の数字をとって、次の乱数とします。例えば、123 を初期値とすると\n\n1232 = 00015129 → 0151\n1512 = 00022801 → 0228\n2282 = 00051984 → 0519\n5192 = 00269361 → 2693\n26932 = 07252249 → 2522\n\nの様になります。この方法を用いて、初期値 s(10000未満の正の整数)を入力とし、n = 4 の場合の乱数を 10 個生成し出力するプログラムを作成してください。\n\nInput\n\n複数のデータセットが与えられます。1行目にデータセットの数 d (d ≤ 10) が与えられます。各データセットとして、1行に初期値 s(整数、1 ≤ s < 10000)が与えられます。\n\nOutput\n\n各データセットに対して、\n\nCase x: (x は 1 から始まるデータセット番号)\n1個目の生成した乱数(整数)\n2個目の生成した乱数(整数)\n:\n:\n10個目の生成した乱数(整数)\n\nを出力してください。\n\nSample Input\n\n2\n123\n567\n\nOutput for the Sample Input\n\nCase 1:\n151\n228\n519\n2693\n2522\n3604\n9888\n7725\n6756\n6435\nCase 2:\n3214\n3297\n8702\n7248\n5335\n4622\n3628\n1623\n6341\n2082", "sample_input": "2\n123\n567\n"}, "reference_outputs": ["Case 1:\n151\n228\n519\n2693\n2522\n3604\n9888\n7725\n6756\n6435\nCase 2:\n3214\n3297\n8702\n7248\n5335\n4622\n3628\n1623\n6341\n2082\n"], "source_document_id": "p00137", "source_text": "平方採中法\n\n古典的な乱数生成方法の一つである平方採中法のプログラムを作成します。平方採中法は、フォンノイマンによって 1940 年代半ばに提案された方法です。\n\n平方採中法は、生成する乱数の桁数を n としたとき、初期値 s の2乗を計算し、その数値を 2n 桁の数値とみて、(下の例のように 2 乗した桁数が足りないときは、0 を補います。)その中央にある n 個の数字を最初の乱数とします。次にこの乱数を 2 乗して、同じ様に、中央にある n 個の数字をとって、次の乱数とします。例えば、123 を初期値とすると\n\n1232 = 00015129 → 0151\n1512 = 00022801 → 0228\n2282 = 00051984 → 0519\n5192 = 00269361 → 2693\n26932 = 07252249 → 2522\n\nの様になります。この方法を用いて、初期値 s(10000未満の正の整数)を入力とし、n = 4 の場合の乱数を 10 個生成し出力するプログラムを作成してください。\n\nInput\n\n複数のデータセットが与えられます。1行目にデータセットの数 d (d ≤ 10) が与えられます。各データセットとして、1行に初期値 s(整数、1 ≤ s < 10000)が与えられます。\n\nOutput\n\n各データセットに対して、\n\nCase x: (x は 1 から始まるデータセット番号)\n1個目の生成した乱数(整数)\n2個目の生成した乱数(整数)\n:\n:\n10個目の生成した乱数(整数)\n\nを出力してください。\n\nSample Input\n\n2\n123\n567\n\nOutput for the Sample Input\n\nCase 1:\n151\n228\n519\n2693\n2522\n3604\n9888\n7725\n6756\n6435\nCase 2:\n3214\n3297\n8702\n7248\n5335\n4622\n3628\n1623\n6341\n2082", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 250, "memory_kb": 43952}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s577513484", "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 println(r.map(e =>e._1+\" \"+e._2).mkString(\"\\n\"))\n }\n}", "language": "Scala", "metadata": {"date": 1488111080, "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/s577513484.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s577513484", "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 println(r.map(e =>e._1+\" \"+e._2).mkString(\"\\n\"))\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 478, "cpu_time_ms": 230, "memory_kb": 43940}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s495188890", "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": 1488112605, "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/s495188890.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s495188890", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 44088}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s772086852", "group_id": "codeNet:p00150", "input_text": "import scala.math._\nimport scala.collection.mutable.ListBuffer\n\nobject Main {\n //rt.gc()??§??¬??????????????¬?????????????????????\n //val rt = Runtime.getRuntime()\n val sc = new java.util.Scanner(System.in)\n def isPrime(n: Int): Boolean = {\n if(n == 1) {\n return false\n }\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 twinPrime(n: Int) = {\n var ans = (3,5)\n for(i <- 5 to n) {\n if(isPrime(i) && isPrime(i-2)) {\n ans = (i-2, i)\n }\n }\n ans\n }\n def main(args: Array[String]) {\n while(true) {\n val n = sc.nextInt\n if(n == 0) {\n return\n }\n val (p, q) = twinPrime(n)\n println(p + \" \" + q)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1455432865, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00150.html", "problem_id": "p00150", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00150/input.txt", "sample_output_relpath": "derived/input_output/data/p00150/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00150/Scala/s772086852.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s772086852", "user_id": "u158037864"}, "prompt_components": {"gold_output": "5 7\n71 73\n197 199\n281 283\n", "input_to_evaluate": "import scala.math._\nimport scala.collection.mutable.ListBuffer\n\nobject Main {\n //rt.gc()??§??¬??????????????¬?????????????????????\n //val rt = Runtime.getRuntime()\n val sc = new java.util.Scanner(System.in)\n def isPrime(n: Int): Boolean = {\n if(n == 1) {\n return false\n }\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 twinPrime(n: Int) = {\n var ans = (3,5)\n for(i <- 5 to n) {\n if(isPrime(i) && isPrime(i-2)) {\n ans = (i-2, i)\n }\n }\n ans\n }\n def main(args: Array[String]) {\n while(true) {\n val n = sc.nextInt\n if(n == 0) {\n return\n }\n val (p, q) = twinPrime(n)\n println(p + \" \" + q)\n }\n }\n}", "problem_context": "Twin Prime\n\nPrime numbers are widely applied for cryptographic and communication technology.\nA twin prime is a prime number that differs from another prime number by 2.\nFor example, (5, 7) and (11, 13) are twin prime pairs.\n\nIn this problem, we call the greater number of a twin prime \"size of the twin prime.\"\n\nYour task is to create a program which reads an integer n and prints a twin prime which has the maximum size among twin primes less than or equals to n\n\nYou may assume that 5 ≤ n ≤ 10000.\n\nInput\n\nThe input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset is formatted as follows:\n\nn (integer)\n\nOutput\n\nFor each dataset, print the twin prime p and q (p < q). p and q should be separated by a single space.\n\nSample Input\n\n12\n100\n200\n300\n0\n\nOutput for the Sample Input\n\n5 7\n71 73\n197 199\n281 283", "sample_input": "12\n100\n200\n300\n0\n"}, "reference_outputs": ["5 7\n71 73\n197 199\n281 283\n"], "source_document_id": "p00150", "source_text": "Twin Prime\n\nPrime numbers are widely applied for cryptographic and communication technology.\nA twin prime is a prime number that differs from another prime number by 2.\nFor example, (5, 7) and (11, 13) are twin prime pairs.\n\nIn this problem, we call the greater number of a twin prime \"size of the twin prime.\"\n\nYour task is to create a program which reads an integer n and prints a twin prime which has the maximum size among twin primes less than or equals to n\n\nYou may assume that 5 ≤ n ≤ 10000.\n\nInput\n\nThe input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset is formatted as follows:\n\nn (integer)\n\nOutput\n\nFor each dataset, print the twin prime p and q (p < q). p and q should be separated by a single space.\n\nSample Input\n\n12\n100\n200\n300\n0\n\nOutput for the Sample Input\n\n5 7\n71 73\n197 199\n281 283", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2420, "memory_kb": 101000}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s182799325", "group_id": "codeNet:p00155", "input_text": "\nobject Main extends App {\n\n import scala.io.StdIn._\n solve\n def solve: Unit = {\n val n = readLine.trim.toInt\n if (n != 0){\n val buildings = Array.tabulate(n){_ ⇒\n val Array(b, x, y) = readLine.trim.split(' ').map(_.toInt)\n new Building(b, Coordinate(x, y))\n }.sortBy(_.id)\n val memo = Array.tabulate(n){_ ⇒ Array.tabulate(n){_ ⇒new Route(-1, Double.MaxValue)}}\n val networks = calNetwork(buildings)\n for (from ← networks.indices){\n memo(from)(from).distance = 0\n for (to ← networks(from)){\n memo(from)(to) = new Route(to, buildings(from).distance(buildings(to)))\n memo(to)(from) = new Route(from, buildings(to).distance(buildings(from)))\n }\n }\n for (a ← 0 until n){\n for (i ← 0 until n){\n for (j ← 0 until n){\n if (memo(i)(j).distance - memo(i)(a).distance > memo(a)(j).distance) {\n memo(i)(j) = new Route(memo(i)(a).from, memo(i)(a).distance + memo(a)(j).distance)\n }\n }\n }\n }\n for (_ ← 0 until readLine.trim.toInt){\n val Array(s, g) = readLine.trim.split(' ').map(_.toInt - 1)\n var stack = g::Nil\n while (memo(stack.head)(s).from != -1){\n stack ::= memo(stack.head)(s).from\n }\n println (if (stack.head == s) stack.map(_ + 1).mkString(\" \") else \"NA\")\n }\n solve\n }\n }\n class Route(var from: Int, var distance: Double)\n def calNetwork(buildings: Array[Building]): Array[List[Int]] = {\n val res = Array.tabulate(buildings.length){_ ⇒ Nil: List[Int]}\n for (i ← buildings.indices){\n for (j ← buildings.indices){\n if (i != j && buildings(i).canJumpTo(buildings(j))) {\n res(i) ::= j\n }\n }\n }\n res\n }\n case class Coordinate(x: Int, y: Int) {\n def - (that: Coordinate): Coordinate = Coordinate(this.x - that.x, this.y - that.y)\n }\n class Building(val id: Int, val position: Coordinate)\n {\n def canJumpTo(that: Building): Boolean = (this.position - that.position).let(it ⇒ it.x * it.x + it.y * it.y <= 50 * 50)\n def distance(that: Building): Double = (this.position - that.position).let(it ⇒ math.sqrt(it.x * it.x + it.y * it.y))\n }\n implicit class ScopeFunc[T](val value:T){\n def let[A](func: T ⇒ A): A = func(value)\n }\n}\n", "language": "Scala", "metadata": {"date": 1537801003, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00155.html", "problem_id": "p00155", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00155/input.txt", "sample_output_relpath": "derived/input_output/data/p00155/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00155/Scala/s182799325.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s182799325", "user_id": "u514597327"}, "prompt_components": {"gold_output": "1 2 3\nNA\n1 3 9 20 11 6 22\n", "input_to_evaluate": "\nobject Main extends App {\n\n import scala.io.StdIn._\n solve\n def solve: Unit = {\n val n = readLine.trim.toInt\n if (n != 0){\n val buildings = Array.tabulate(n){_ ⇒\n val Array(b, x, y) = readLine.trim.split(' ').map(_.toInt)\n new Building(b, Coordinate(x, y))\n }.sortBy(_.id)\n val memo = Array.tabulate(n){_ ⇒ Array.tabulate(n){_ ⇒new Route(-1, Double.MaxValue)}}\n val networks = calNetwork(buildings)\n for (from ← networks.indices){\n memo(from)(from).distance = 0\n for (to ← networks(from)){\n memo(from)(to) = new Route(to, buildings(from).distance(buildings(to)))\n memo(to)(from) = new Route(from, buildings(to).distance(buildings(from)))\n }\n }\n for (a ← 0 until n){\n for (i ← 0 until n){\n for (j ← 0 until n){\n if (memo(i)(j).distance - memo(i)(a).distance > memo(a)(j).distance) {\n memo(i)(j) = new Route(memo(i)(a).from, memo(i)(a).distance + memo(a)(j).distance)\n }\n }\n }\n }\n for (_ ← 0 until readLine.trim.toInt){\n val Array(s, g) = readLine.trim.split(' ').map(_.toInt - 1)\n var stack = g::Nil\n while (memo(stack.head)(s).from != -1){\n stack ::= memo(stack.head)(s).from\n }\n println (if (stack.head == s) stack.map(_ + 1).mkString(\" \") else \"NA\")\n }\n solve\n }\n }\n class Route(var from: Int, var distance: Double)\n def calNetwork(buildings: Array[Building]): Array[List[Int]] = {\n val res = Array.tabulate(buildings.length){_ ⇒ Nil: List[Int]}\n for (i ← buildings.indices){\n for (j ← buildings.indices){\n if (i != j && buildings(i).canJumpTo(buildings(j))) {\n res(i) ::= j\n }\n }\n }\n res\n }\n case class Coordinate(x: Int, y: Int) {\n def - (that: Coordinate): Coordinate = Coordinate(this.x - that.x, this.y - that.y)\n }\n class Building(val id: Int, val position: Coordinate)\n {\n def canJumpTo(that: Building): Boolean = (this.position - that.position).let(it ⇒ it.x * it.x + it.y * it.y <= 50 * 50)\n def distance(that: Building): Double = (this.position - that.position).let(it ⇒ math.sqrt(it.x * it.x + it.y * it.y))\n }\n implicit class ScopeFunc[T](val value:T){\n def let[A](func: T ⇒ A): A = func(value)\n }\n}\n", "problem_context": "スパイダー人\n\n正義のヒーロー「スパイダー人」は、腕からロープを出してビルからビルへ飛び移ることができます。しかし、ロープが短いので自分からの距離が 50 以下のビルにしか移動できません。それより遠くのビルに移動するには、一旦別のビルに飛び移らなくてはなりません。\n\nビルの数 n、n 個のビルの情報、スパイダー人の移動開始位置及び目的地を入力とし、その移動の最短経路を出力するプログラムを作成してください。どのようにビルを経由しても目標のビルに移動できない場合は NA と出力してください。各ビルは点として扱い、最短距離で移動するビルの経由方法が2つ以上存在することはないものとします。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。\n各データセットは以下の形式で与えられます。\n\nn\nb1 x1 y1\nb2 x2 y2\n:\nbn xn yn\nm\ns1 g1\ns2 g2\n:\nsm gm\n\n1行目にビルの数 n (1 ≤ n ≤ 100)、続く n 行に i 番目のビルのビル番号 bi (1 ≤ bi ≤ n)、そのビルのx座標とy座標を表す整数 xi, yi (-1000 ≤ xi, yi ≤ 1000) が空白区切りで与えられます。\n\n続く行に移動情報の個数 m (1 ≤ m ≤ 100)、続く m 行にi 番目の移動情報が与えられます。各移動情報として、移動を開始するビルの番号 si と目的地ビルの番号 gi が空白区切りで与えられます。\n\nデータセットの数は 10 を超えません。\n\nOutput\n\n入力データセットごとに次の形式で出力します。\n\ni 行目に i 番目の移動情報に対する経路または NA を1行に出力します。各経路は以下の形式で出力します。\n\nsi bri1 bri2 ... gi\n\nbrij は i 番目の移動情報における、j 番目に経由するビルの番号を表します。\n\nSample Input\n\n4\n1 0 0\n2 30 0\n3 60 40\n4 0 60\n2\n1 3\n1 4\n22\n1 0 0\n2 150 40\n3 30 20\n4 180 150\n5 40 80\n6 130 130\n7 72 28\n8 172 118\n9 50 50\n10 160 82\n11 90 105\n12 144 131\n13 130 64\n14 80 140\n15 38 117\n16 190 90\n17 60 100\n18 100 70\n19 130 100\n20 71 69\n21 200 110\n22 120 150\n1\n1 22\n0\n\nOutput for the Sample Input\n\n1 2 3\nNA\n1 3 9 20 11 6 22", "sample_input": "4\n1 0 0\n2 30 0\n3 60 40\n4 0 60\n2\n1 3\n1 4\n22\n1 0 0\n2 150 40\n3 30 20\n4 180 150\n5 40 80\n6 130 130\n7 72 28\n8 172 118\n9 50 50\n10 160 82\n11 90 105\n12 144 131\n13 130 64\n14 80 140\n15 38 117\n16 190 90\n17 60 100\n18 100 70\n19 130 100\n20 71 69\n21 200 110\n22 120 150\n1\n1 22\n0\n"}, "reference_outputs": ["1 2 3\nNA\n1 3 9 20 11 6 22\n"], "source_document_id": "p00155", "source_text": "スパイダー人\n\n正義のヒーロー「スパイダー人」は、腕からロープを出してビルからビルへ飛び移ることができます。しかし、ロープが短いので自分からの距離が 50 以下のビルにしか移動できません。それより遠くのビルに移動するには、一旦別のビルに飛び移らなくてはなりません。\n\nビルの数 n、n 個のビルの情報、スパイダー人の移動開始位置及び目的地を入力とし、その移動の最短経路を出力するプログラムを作成してください。どのようにビルを経由しても目標のビルに移動できない場合は NA と出力してください。各ビルは点として扱い、最短距離で移動するビルの経由方法が2つ以上存在することはないものとします。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。\n各データセットは以下の形式で与えられます。\n\nn\nb1 x1 y1\nb2 x2 y2\n:\nbn xn yn\nm\ns1 g1\ns2 g2\n:\nsm gm\n\n1行目にビルの数 n (1 ≤ n ≤ 100)、続く n 行に i 番目のビルのビル番号 bi (1 ≤ bi ≤ n)、そのビルのx座標とy座標を表す整数 xi, yi (-1000 ≤ xi, yi ≤ 1000) が空白区切りで与えられます。\n\n続く行に移動情報の個数 m (1 ≤ m ≤ 100)、続く m 行にi 番目の移動情報が与えられます。各移動情報として、移動を開始するビルの番号 si と目的地ビルの番号 gi が空白区切りで与えられます。\n\nデータセットの数は 10 を超えません。\n\nOutput\n\n入力データセットごとに次の形式で出力します。\n\ni 行目に i 番目の移動情報に対する経路または NA を1行に出力します。各経路は以下の形式で出力します。\n\nsi bri1 bri2 ... gi\n\nbrij は i 番目の移動情報における、j 番目に経由するビルの番号を表します。\n\nSample Input\n\n4\n1 0 0\n2 30 0\n3 60 40\n4 0 60\n2\n1 3\n1 4\n22\n1 0 0\n2 150 40\n3 30 20\n4 180 150\n5 40 80\n6 130 130\n7 72 28\n8 172 118\n9 50 50\n10 160 82\n11 90 105\n12 144 131\n13 130 64\n14 80 140\n15 38 117\n16 190 90\n17 60 100\n18 100 70\n19 130 100\n20 71 69\n21 200 110\n22 120 150\n1\n1 22\n0\n\nOutput for the Sample Input\n\n1 2 3\nNA\n1 3 9 20 11 6 22", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2344, "cpu_time_ms": 290, "memory_kb": 47696}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s696324016", "group_id": "codeNet:p00164", "input_text": "import scala.io.StdIn.{readInt,readLine}\n\nobject Main {\n def main(args:Array[String]) = {\n var n = 0\n while({n=readInt;n}!=0) {\n val a = readLine.split(\" \").map(_.toInt)\n var rem = 32\n var i = 0\n while(rem!=0) {\n rem = rem - (rem-1)%5\n println(rem)\n rem = rem - (if(a(i%n)<=rem) a(i%n) else rem)\n println(rem)\n i += 1\n }\n }\n }\n}", "language": "Scala", "metadata": {"date": 1488612961, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00164.html", "problem_id": "p00164", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00164/input.txt", "sample_output_relpath": "derived/input_output/data/p00164/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00164/Scala/s696324016.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s696324016", "user_id": "u508732591"}, "prompt_components": {"gold_output": "31\n28\n26\n25\n21\n17\n16\n14\n11\n8\n6\n5\n1\n0\n31\n27\n26\n23\n21\n19\n16\n12\n11\n8\n6\n4\n1\n0\n", "input_to_evaluate": "import scala.io.StdIn.{readInt,readLine}\n\nobject Main {\n def main(args:Array[String]) = {\n var n = 0\n while({n=readInt;n}!=0) {\n val a = readLine.split(\" \").map(_.toInt)\n var rem = 32\n var i = 0\n while(rem!=0) {\n rem = rem - (rem-1)%5\n println(rem)\n rem = rem - (if(a(i%n)<=rem) a(i%n) else rem)\n println(rem)\n i += 1\n }\n }\n }\n}", "problem_context": "おはじき取り\n\n一郎君と次郎君の兄弟は家でよくおはじき取りをして遊びます。おはじき取りは、一カ所に積まれた複数のおはじきを二人が交互にとっていくゲームです。一度に1〜4個のおはじきを好きな数だけ順に取り、相手に最後の1個を取らせた方が勝ちになります。二人はいつも 32 個のおはじきを使い、兄である一郎君の番からゲームを始めます。\n\nこれまでに何度も戦っている二人ですが、次郎君は兄の一郎君にどうしても勝つことができません。それもそのはず、一郎君はこのゲームの必勝法を知っているからです。一郎君は、残りのおはじきの数を n とすると、必ず (n - 1) % 5 個のおはじきを取ります。ここで x % y は、x を y で割った余りを示します。\n\n一方、次郎君は、残りのおはじきの数にかかわらず、ゲームのはじめに各回で取るおはじきの数を数列として決めてしまうのです。例えば、次郎君が決めた数列が{ 3, 1, 4, 2 } であるならば、彼の取るおはじきの数は順に 3 -> 1 -> 4 -> 2 -> 3 -> 1 -> 4 -> … となります(取ると決めた数が、おはじきの残りの数以上になった場合は、残りのおはじき全てを取ります)。\n\nなんど負けてもやり方を変えようとしない頑固な次郎君の将来が心配になったお母さんは、次郎君がいかなる数列を選んだとしても一郎君には勝てないということを示すために、ゲームをシュミレートするプログラムを書くことにしました。\n\n次郎君の考えた数列 a を入力とし、一郎君と次郎君が順次おはじきを取った後の残りのおはじきの個数を出力するプログラムを作成してください。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。\n各データセットは以下の形式で与えられます。\n\nn\na1 a2 ... an\n\n1行目に次郎君の決めた数列の長さ n (1 ≤ n ≤ 25)、2行目に数列の i 番目の要素 ai (1 ≤ ai ≤ 4) が空白区切りで与えられます。入力はすべて整数で与えられます。\n\nデータセットの数は 100 を超えません。\n\nOutput\n\nデータセットごとに、ゲームの各回でのおはじきが取られた直後のおはじきの数(整数)を出力します。\n\nSample Input\n\n4\n3 1 4 2\n3\n4 3 2\n0\n\nOutput for the Sample Input\n\n31\n28\n26\n25\n21\n17\n16\n14\n11\n8\n6\n5\n1\n0\n31\n27\n26\n23\n21\n19\n16\n12\n11\n8\n6\n4\n1\n0", "sample_input": "4\n3 1 4 2\n3\n4 3 2\n0\n"}, "reference_outputs": ["31\n28\n26\n25\n21\n17\n16\n14\n11\n8\n6\n5\n1\n0\n31\n27\n26\n23\n21\n19\n16\n12\n11\n8\n6\n4\n1\n0\n"], "source_document_id": "p00164", "source_text": "おはじき取り\n\n一郎君と次郎君の兄弟は家でよくおはじき取りをして遊びます。おはじき取りは、一カ所に積まれた複数のおはじきを二人が交互にとっていくゲームです。一度に1〜4個のおはじきを好きな数だけ順に取り、相手に最後の1個を取らせた方が勝ちになります。二人はいつも 32 個のおはじきを使い、兄である一郎君の番からゲームを始めます。\n\nこれまでに何度も戦っている二人ですが、次郎君は兄の一郎君にどうしても勝つことができません。それもそのはず、一郎君はこのゲームの必勝法を知っているからです。一郎君は、残りのおはじきの数を n とすると、必ず (n - 1) % 5 個のおはじきを取ります。ここで x % y は、x を y で割った余りを示します。\n\n一方、次郎君は、残りのおはじきの数にかかわらず、ゲームのはじめに各回で取るおはじきの数を数列として決めてしまうのです。例えば、次郎君が決めた数列が{ 3, 1, 4, 2 } であるならば、彼の取るおはじきの数は順に 3 -> 1 -> 4 -> 2 -> 3 -> 1 -> 4 -> … となります(取ると決めた数が、おはじきの残りの数以上になった場合は、残りのおはじき全てを取ります)。\n\nなんど負けてもやり方を変えようとしない頑固な次郎君の将来が心配になったお母さんは、次郎君がいかなる数列を選んだとしても一郎君には勝てないということを示すために、ゲームをシュミレートするプログラムを書くことにしました。\n\n次郎君の考えた数列 a を入力とし、一郎君と次郎君が順次おはじきを取った後の残りのおはじきの個数を出力するプログラムを作成してください。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。\n各データセットは以下の形式で与えられます。\n\nn\na1 a2 ... an\n\n1行目に次郎君の決めた数列の長さ n (1 ≤ n ≤ 25)、2行目に数列の i 番目の要素 ai (1 ≤ ai ≤ 4) が空白区切りで与えられます。入力はすべて整数で与えられます。\n\nデータセットの数は 100 を超えません。\n\nOutput\n\nデータセットごとに、ゲームの各回でのおはじきが取られた直後のおはじきの数(整数)を出力します。\n\nSample Input\n\n4\n3 1 4 2\n3\n4 3 2\n0\n\nOutput for the Sample Input\n\n31\n28\n26\n25\n21\n17\n16\n14\n11\n8\n6\n5\n1\n0\n31\n27\n26\n23\n21\n19\n16\n12\n11\n8\n6\n4\n1\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 399, "cpu_time_ms": 240, "memory_kb": 43768}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s131570581", "group_id": "codeNet:p00173", "input_text": "import java.util.Scanner\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n while (sc.hasNext) {\n val name = sc.next\n val a, b = sc.nextInt\n println(name + \" \" + (a + b) + \" \" + (a * 200 + b * 300))\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": 1503855294, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00173.html", "problem_id": "p00173", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00173/input.txt", "sample_output_relpath": "derived/input_output/data/p00173/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00173/Scala/s131570581.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s131570581", "user_id": "u018134297"}, "prompt_components": {"gold_output": "1a 375 99300\n1c 507 119700\n1f 292 78300\n2b 535 123300\n2c 522 133700\n2e 597 140000\n3a 286 74000\n3b 556 140500\n3d 383 86800\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n while (sc.hasNext) {\n val name = sc.next\n val a, b = sc.nextInt\n println(name + \" \" + (a + b) + \" \" + (a * 200 + b * 300))\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会津学園高等学校では、毎年学園祭をおこなっています。その中でも一番人気はお化け屋敷です。一番人気の理由は、お化け屋敷をおこなうクラスが 1クラスや 2クラスではなく、9クラスがお化け屋敷をおこなうことです。それぞれが工夫することより、それぞれが個性的なお化け屋敷になっています。そのため、最近では近隣から多くの来場者が訪れます。\n\nそこで、学園祭実行委員会では、お化け屋敷の入場料金を下表のように校内で統一し、これにもとづき各クラスごとに入場者総数と収入の集計をおこなうことにしました。\n\n入場料金表(入場者 1人あたりの入場料)\n\n午前 午後\n200円 300円\n\n各クラス毎の午前と午後の入場者数を入力とし、各クラス毎の入場者総数及び収入の一覧表を作成するプログラムを作成してください。\n\nInput\n\n入力は以下の形式で与えられます。\n\nname1 a1 b1\nname2 a2 b2\n:\nname9 a9 b9\n\n入力は9行からなり、i 行目に第 i のクラスのクラス名 namei (数字とアルファベットを含む 1 文字以上 15 文字以下の半角文字列)、午前の入場者数 ai (0 ≤ ai ≤ 400)、 午後の入場者数 bi (0 ≤ bi ≤ 400) が与えられます。\n\nOutput\n\ni 行目に第 i のクラスのクラス名、 入場者総数、 料金収入を空白区切りで1行に出力してください。\n\nSample Input\n\n1a 132 243\n1c 324 183\n1f 93 199\n2b 372 163\n2c 229 293\n2e 391 206\n3a 118 168\n3b 263 293\n3d 281 102\n\nOutput for the Sample Input\n\n1a 375 99300\n1c 507 119700\n1f 292 78300\n2b 535 123300\n2c 522 133700\n2e 597 140000\n3a 286 74000\n3b 556 140500\n3d 383 86800", "sample_input": "1a 132 243\n1c 324 183\n1f 93 199\n2b 372 163\n2c 229 293\n2e 391 206\n3a 118 168\n3b 263 293\n3d 281 102\n"}, "reference_outputs": ["1a 375 99300\n1c 507 119700\n1f 292 78300\n2b 535 123300\n2c 522 133700\n2e 597 140000\n3a 286 74000\n3b 556 140500\n3d 383 86800\n"], "source_document_id": "p00173", "source_text": "お化け屋敷\n\n会津学園高等学校では、毎年学園祭をおこなっています。その中でも一番人気はお化け屋敷です。一番人気の理由は、お化け屋敷をおこなうクラスが 1クラスや 2クラスではなく、9クラスがお化け屋敷をおこなうことです。それぞれが工夫することより、それぞれが個性的なお化け屋敷になっています。そのため、最近では近隣から多くの来場者が訪れます。\n\nそこで、学園祭実行委員会では、お化け屋敷の入場料金を下表のように校内で統一し、これにもとづき各クラスごとに入場者総数と収入の集計をおこなうことにしました。\n\n入場料金表(入場者 1人あたりの入場料)\n\n午前 午後\n200円 300円\n\n各クラス毎の午前と午後の入場者数を入力とし、各クラス毎の入場者総数及び収入の一覧表を作成するプログラムを作成してください。\n\nInput\n\n入力は以下の形式で与えられます。\n\nname1 a1 b1\nname2 a2 b2\n:\nname9 a9 b9\n\n入力は9行からなり、i 行目に第 i のクラスのクラス名 namei (数字とアルファベットを含む 1 文字以上 15 文字以下の半角文字列)、午前の入場者数 ai (0 ≤ ai ≤ 400)、 午後の入場者数 bi (0 ≤ bi ≤ 400) が与えられます。\n\nOutput\n\ni 行目に第 i のクラスのクラス名、 入場者総数、 料金収入を空白区切りで1行に出力してください。\n\nSample Input\n\n1a 132 243\n1c 324 183\n1f 93 199\n2b 372 163\n2c 229 293\n2e 391 206\n3a 118 168\n3b 263 293\n3d 281 102\n\nOutput for the Sample Input\n\n1a 375 99300\n1c 507 119700\n1f 292 78300\n2b 535 123300\n2c 522 133700\n2e 597 140000\n3a 286 74000\n3b 556 140500\n3d 383 86800", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 45044}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s426562761", "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\") return\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)) {\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": 1521114269, "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/s426562761.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s426562761", "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\") return\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)) {\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1460, "cpu_time_ms": 1700, "memory_kb": 456944}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s180401423", "group_id": "codeNet:p00218", "input_text": "import scala.io.StdIn.{readInt,readLine}\n\nobject Main extends App {\n def eval(math:Int,eng:Int,jp:Int) = {\n if(math == 100 || eng == 100 || jp == 100) \"A\"\n else if((math+eng)/2 >= 90) \"A\"\n else if((math+eng+jp)/3 >= 80) \"A\"\n else if((math+eng+jp)/3 >= 70) \"B\"\n else if((math+eng+jp)/3 >= 50 && (math >= 80 || eng >= 80)) \"B\"\n else \"C\"\n }\n\n println {\n Iterator.continually(readInt).takeWhile(_ != 0).map { n =>\n {\n for(i<- 1 to n) yield {\n val score = readLine.split(\" \").map(_.toInt)\n eval(score(0),score(1),score(2))\n }\n }.mkString(\"\\n\")\n }.mkString(\"\\n\")\n }\n}", "language": "Scala", "metadata": {"date": 1487865034, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00218.html", "problem_id": "p00218", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00218/input.txt", "sample_output_relpath": "derived/input_output/data/p00218/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00218/Scala/s180401423.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s180401423", "user_id": "u508732591"}, "prompt_components": {"gold_output": "A\nA\nB\nC\nA\nB\n", "input_to_evaluate": "import scala.io.StdIn.{readInt,readLine}\n\nobject Main extends App {\n def eval(math:Int,eng:Int,jp:Int) = {\n if(math == 100 || eng == 100 || jp == 100) \"A\"\n else if((math+eng)/2 >= 90) \"A\"\n else if((math+eng+jp)/3 >= 80) \"A\"\n else if((math+eng+jp)/3 >= 70) \"B\"\n else if((math+eng+jp)/3 >= 50 && (math >= 80 || eng >= 80)) \"B\"\n else \"C\"\n }\n\n println {\n Iterator.continually(readInt).takeWhile(_ != 0).map { n =>\n {\n for(i<- 1 to n) yield {\n val score = readLine.split(\" \").map(_.toInt)\n eval(score(0),score(1),score(2))\n }\n }.mkString(\"\\n\")\n }.mkString(\"\\n\")\n }\n}", "problem_context": "クラス分け\n\n会津進学塾では、生徒が塾に入る際に実力テストを行ってクラス分けをします。テストは数学、英語、国語の 3 科目行い、生徒を A,B,C クラスにクラス分けします。A クラスのレベルが一番高く、順に低くなっていきます。\n\nクラス分けの判断は以下の表に基づきます。\n\n条件\n\nクラス\n\n100 点の科目がある\n\nA\n\n数学と英語の平均点が 90 点以上\n\nA\n\n3 科目の平均点が 80 点以上\n\nA\n\n3 科目の平均点が 70 点以上\n\nB\n\n3 科目の平均点が 50 点以上で数学か英語が 80 点以上\n\nB\n\n上の条件を満たさない\n\nC\n\n複数の条件を満たす場合は、よりレベルの高いクラスに分けられます。\n\n生徒の人数 n (1 ≤ n ≤ 10000)、各生徒の数学の点数 pmi (0 ≤ pmi ≤ 100)、英語の点数 pei (0 ≤ pei ≤ 100)、国語の点数 pji (0 ≤ pji ≤ 100) を入力とし、各生徒のクラスA,B,C (半角英字) を出力するプログラムを作成してください。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。\n各データセットは以下の形式で与えられます。\n\nn\npm1 pe1 pj1\npm2 pe2 pj2\n:\npmn pen pjn\n\n入力はすべて整数で与えられます。データセットの数は 1000 を超えません。\n\nOutput\n\n入力データセットごとに、各生徒のクラスを順番に出力します。\n\nSample Input\n\n4\n100 70 20\n98 86 55\n80 34 36\n65 79 65\n2\n99 81 20\n66 72 90\n0\n\nOutput for the Sample Input\n\nA\nA\nB\nC\nA\nB", "sample_input": "4\n100 70 20\n98 86 55\n80 34 36\n65 79 65\n2\n99 81 20\n66 72 90\n0\n"}, "reference_outputs": ["A\nA\nB\nC\nA\nB\n"], "source_document_id": "p00218", "source_text": "クラス分け\n\n会津進学塾では、生徒が塾に入る際に実力テストを行ってクラス分けをします。テストは数学、英語、国語の 3 科目行い、生徒を A,B,C クラスにクラス分けします。A クラスのレベルが一番高く、順に低くなっていきます。\n\nクラス分けの判断は以下の表に基づきます。\n\n条件\n\nクラス\n\n100 点の科目がある\n\nA\n\n数学と英語の平均点が 90 点以上\n\nA\n\n3 科目の平均点が 80 点以上\n\nA\n\n3 科目の平均点が 70 点以上\n\nB\n\n3 科目の平均点が 50 点以上で数学か英語が 80 点以上\n\nB\n\n上の条件を満たさない\n\nC\n\n複数の条件を満たす場合は、よりレベルの高いクラスに分けられます。\n\n生徒の人数 n (1 ≤ n ≤ 10000)、各生徒の数学の点数 pmi (0 ≤ pmi ≤ 100)、英語の点数 pei (0 ≤ pei ≤ 100)、国語の点数 pji (0 ≤ pji ≤ 100) を入力とし、各生徒のクラスA,B,C (半角英字) を出力するプログラムを作成してください。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。\n各データセットは以下の形式で与えられます。\n\nn\npm1 pe1 pj1\npm2 pe2 pj2\n:\npmn pen pjn\n\n入力はすべて整数で与えられます。データセットの数は 1000 を超えません。\n\nOutput\n\n入力データセットごとに、各生徒のクラスを順番に出力します。\n\nSample Input\n\n4\n100 70 20\n98 86 55\n80 34 36\n65 79 65\n2\n99 81 20\n66 72 90\n0\n\nOutput for the Sample Input\n\nA\nA\nB\nC\nA\nB", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 631, "cpu_time_ms": 300, "memory_kb": 48244}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s144057966", "group_id": "codeNet:p00218", "input_text": "import scala.io.StdIn.{readInt,readLine}\n\nobject Main extends App {\n def eval(math:Int,eng:Int,jp:Int) = {\n if(math == 100 || eng == 100 || jp == 100) \"A\"\n else if((math+eng)/2 >= 90) \"A\"\n else if((math+eng+jp)/3 >= 80) \"A\"\n else if((math+eng+jp)/3 >= 70) \"B\"\n else if((math+eng+jp)/3 >= 50 && (math >= 80 || eng >= 80)) \"B\"\n else \"C\"\n }\n\n println {\n Iterator.continually(readInt).takeWhile(_ != 0).map { n =>\n {\n for(i<- 1 to n) yield {\n val score = readLine.split(\" \").map(_.toInt)\n eval(score(0),score(1),score(2))\n }\n }.mkString(\"\\n\")\n }.mkString(\"\\n\")\n }\n}", "language": "Scala", "metadata": {"date": 1487865040, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00218.html", "problem_id": "p00218", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00218/input.txt", "sample_output_relpath": "derived/input_output/data/p00218/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00218/Scala/s144057966.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s144057966", "user_id": "u508732591"}, "prompt_components": {"gold_output": "A\nA\nB\nC\nA\nB\n", "input_to_evaluate": "import scala.io.StdIn.{readInt,readLine}\n\nobject Main extends App {\n def eval(math:Int,eng:Int,jp:Int) = {\n if(math == 100 || eng == 100 || jp == 100) \"A\"\n else if((math+eng)/2 >= 90) \"A\"\n else if((math+eng+jp)/3 >= 80) \"A\"\n else if((math+eng+jp)/3 >= 70) \"B\"\n else if((math+eng+jp)/3 >= 50 && (math >= 80 || eng >= 80)) \"B\"\n else \"C\"\n }\n\n println {\n Iterator.continually(readInt).takeWhile(_ != 0).map { n =>\n {\n for(i<- 1 to n) yield {\n val score = readLine.split(\" \").map(_.toInt)\n eval(score(0),score(1),score(2))\n }\n }.mkString(\"\\n\")\n }.mkString(\"\\n\")\n }\n}", "problem_context": "クラス分け\n\n会津進学塾では、生徒が塾に入る際に実力テストを行ってクラス分けをします。テストは数学、英語、国語の 3 科目行い、生徒を A,B,C クラスにクラス分けします。A クラスのレベルが一番高く、順に低くなっていきます。\n\nクラス分けの判断は以下の表に基づきます。\n\n条件\n\nクラス\n\n100 点の科目がある\n\nA\n\n数学と英語の平均点が 90 点以上\n\nA\n\n3 科目の平均点が 80 点以上\n\nA\n\n3 科目の平均点が 70 点以上\n\nB\n\n3 科目の平均点が 50 点以上で数学か英語が 80 点以上\n\nB\n\n上の条件を満たさない\n\nC\n\n複数の条件を満たす場合は、よりレベルの高いクラスに分けられます。\n\n生徒の人数 n (1 ≤ n ≤ 10000)、各生徒の数学の点数 pmi (0 ≤ pmi ≤ 100)、英語の点数 pei (0 ≤ pei ≤ 100)、国語の点数 pji (0 ≤ pji ≤ 100) を入力とし、各生徒のクラスA,B,C (半角英字) を出力するプログラムを作成してください。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。\n各データセットは以下の形式で与えられます。\n\nn\npm1 pe1 pj1\npm2 pe2 pj2\n:\npmn pen pjn\n\n入力はすべて整数で与えられます。データセットの数は 1000 を超えません。\n\nOutput\n\n入力データセットごとに、各生徒のクラスを順番に出力します。\n\nSample Input\n\n4\n100 70 20\n98 86 55\n80 34 36\n65 79 65\n2\n99 81 20\n66 72 90\n0\n\nOutput for the Sample Input\n\nA\nA\nB\nC\nA\nB", "sample_input": "4\n100 70 20\n98 86 55\n80 34 36\n65 79 65\n2\n99 81 20\n66 72 90\n0\n"}, "reference_outputs": ["A\nA\nB\nC\nA\nB\n"], "source_document_id": "p00218", "source_text": "クラス分け\n\n会津進学塾では、生徒が塾に入る際に実力テストを行ってクラス分けをします。テストは数学、英語、国語の 3 科目行い、生徒を A,B,C クラスにクラス分けします。A クラスのレベルが一番高く、順に低くなっていきます。\n\nクラス分けの判断は以下の表に基づきます。\n\n条件\n\nクラス\n\n100 点の科目がある\n\nA\n\n数学と英語の平均点が 90 点以上\n\nA\n\n3 科目の平均点が 80 点以上\n\nA\n\n3 科目の平均点が 70 点以上\n\nB\n\n3 科目の平均点が 50 点以上で数学か英語が 80 点以上\n\nB\n\n上の条件を満たさない\n\nC\n\n複数の条件を満たす場合は、よりレベルの高いクラスに分けられます。\n\n生徒の人数 n (1 ≤ n ≤ 10000)、各生徒の数学の点数 pmi (0 ≤ pmi ≤ 100)、英語の点数 pei (0 ≤ pei ≤ 100)、国語の点数 pji (0 ≤ pji ≤ 100) を入力とし、各生徒のクラスA,B,C (半角英字) を出力するプログラムを作成してください。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。\n各データセットは以下の形式で与えられます。\n\nn\npm1 pe1 pj1\npm2 pe2 pj2\n:\npmn pen pjn\n\n入力はすべて整数で与えられます。データセットの数は 1000 を超えません。\n\nOutput\n\n入力データセットごとに、各生徒のクラスを順番に出力します。\n\nSample Input\n\n4\n100 70 20\n98 86 55\n80 34 36\n65 79 65\n2\n99 81 20\n66 72 90\n0\n\nOutput for the Sample Input\n\nA\nA\nB\nC\nA\nB", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 631, "cpu_time_ms": 330, "memory_kb": 47760}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s229464688", "group_id": "codeNet:p00239", "input_text": "import scala.io.StdIn.{readInt,readLine}\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n def main(args:Array[String]) = {\n var n = 0\n while( {n=readInt;n} != 0 ) {\n val b = new ArrayBuffer[Array[Int]]\n for(i<-1 to n) {\n b += readLine.split(\" \").map(_.toInt)\n }\n val limit = readLine.split(\" \").map(_.toInt)\n val p = limit(0);val q = limit(1);val r = limit(2);val c = limit(3)\n val list = b.toArray.filter { i => i(1) <= p && i(2) <= q && i(3) <= r && i(1)*4 + i(2)*9 + i(3)*4 <= c }\n if(list.length == 0) println(\"NA\")\n else list.foreach(i=>println(i(0)))\n }\n }\n}", "language": "Scala", "metadata": {"date": 1488011994, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00239.html", "problem_id": "p00239", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00239/input.txt", "sample_output_relpath": "derived/input_output/data/p00239/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00239/Scala/s229464688.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s229464688", "user_id": "u508732591"}, "prompt_components": {"gold_output": "1\n4\nNA\n", "input_to_evaluate": "import scala.io.StdIn.{readInt,readLine}\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n def main(args:Array[String]) = {\n var n = 0\n while( {n=readInt;n} != 0 ) {\n val b = new ArrayBuffer[Array[Int]]\n for(i<-1 to n) {\n b += readLine.split(\" \").map(_.toInt)\n }\n val limit = readLine.split(\" \").map(_.toInt)\n val p = limit(0);val q = limit(1);val r = limit(2);val c = limit(3)\n val list = b.toArray.filter { i => i(1) <= p && i(2) <= q && i(3) <= r && i(1)*4 + i(2)*9 + i(3)*4 <= c }\n if(list.length == 0) println(\"NA\")\n else list.foreach(i=>println(i(0)))\n }\n }\n}", "problem_context": "カロリー計算\n\n食べ物には3大栄養素と呼ばれる「たんぱく質」「脂質」「炭水化物」の3つの栄養素が含まれています。1g(グラム)あたりたんぱく質と炭水化物は 4 kcal(キロカロリー)、脂質は 9 kcal と計算されます。たとえば、下の表によると番号1のケーキにはタンパク質 7 g、脂質 14 g、炭水化物 47 g が含まれています。これをもとに含まれるカロリーを計算すると、4 × 7 + 9 × 14 + 4 × 47 = 342 kcal となります。その他も同様に計算されています。\n\n番号\n\n名前\n\nたんぱく質(g)\n\n脂質(g)\n\n炭水化物(g)\n\nカロリー(kcal)\n\n1\n\nケーキ\n\n7\n\n14\n\n47\n\n342\n\n2\n\nポテトチップス\n\n5\n\n35\n\n55\n\n555\n\n3\n\nどら焼き\n\n6\n\n3\n\n59\n\n287\n\n4\n\nプリン\n\n6\n\n5\n\n15\n\n129\n\n分類の対象となるお菓子の個数 n と各お菓子の情報、制限の情報を入力とし、そのお菓子一つだけなら制限を超えることがない(食べてもよい)お菓子の一覧を出力するプログラムを作成してください。\n\nお菓子の情報は、お菓子の番号 s、そのお菓子に含まれるたんぱく質の重量 p、脂質の重量 q、炭水化物の重量 r から構成されています。制限の情報には、含むことができる最大のたんぱく質の重量 P、脂質の重量 Q、炭水化物の重量 R、および摂取することができる最大のカロリー C からなっており、タンパク質、脂質、炭水化物、カロリーのいずれかの一つでも超えると制限違反となり、「食べてはいけないお菓子」と判断されます。\n\n食べてもよいお菓子の一覧は、食べてもよいお菓子の番号を入力順に出力してください。なお、食べてもよいお菓子がなければ”NA”と出力してください。\n上の表にある4個のお菓子について、P = 10, Q = 15, R = 50, C = 400 という制限の場合、ケーキとプリンはそれぞれの栄養素及びカロリーが制限値以下なので食べてもよいお菓子に分類されますが、ポテトチップスは炭水化物とカロリー、どら焼きは炭水化物の量が制限値を超えているため食べてはいけないお菓子に分類されます。\n\n入力\n\n複数のデータセットの並びが与えられます。入力の終わりはゼロひとつの行で示されます。各データセットは以下の形式で与えられます。\n\nn\ns1 p1 q1 r1\ns2 p2 q2 r2\n:\nsn pn qn rn\nP Q R C\n\n1行目にお菓子の数 n (1 ≤ n ≤ 1000)が与えられます。続く n 行に第 i のお菓子の番号 si (1 ≤ si ≤ 1000)、各栄養素の重量を表す整数 pi, qi, ri (0 ≤ pi, qi, ri ≤ 100) が与えられます。\n\n続く行に各栄養素及びカロリーの制限値を表す整数 P, Q, R (0 ≤ P, Q, R ≤ 100), C (0 ≤ C ≤ 1700) が与えられます。\n\nデータセットの数は 100 を超えません。\n\n出力\n\nデータセットごとに、食べてもよいお菓子の番号または ”NA” を出力します。\n\n入力例\n\n4\n1 7 14 47\n2 5 35 55\n3 6 3 59\n4 6 5 15\n10 15 50 400\n2\n1 8 10 78\n2 4 18 33\n10 10 50 300\n0\n\n出力例\n\n1\n4\nNA", "sample_input": "4\n1 7 14 47\n2 5 35 55\n3 6 3 59\n4 6 5 15\n10 15 50 400\n2\n1 8 10 78\n2 4 18 33\n10 10 50 300\n0\n"}, "reference_outputs": ["1\n4\nNA\n"], "source_document_id": "p00239", "source_text": "カロリー計算\n\n食べ物には3大栄養素と呼ばれる「たんぱく質」「脂質」「炭水化物」の3つの栄養素が含まれています。1g(グラム)あたりたんぱく質と炭水化物は 4 kcal(キロカロリー)、脂質は 9 kcal と計算されます。たとえば、下の表によると番号1のケーキにはタンパク質 7 g、脂質 14 g、炭水化物 47 g が含まれています。これをもとに含まれるカロリーを計算すると、4 × 7 + 9 × 14 + 4 × 47 = 342 kcal となります。その他も同様に計算されています。\n\n番号\n\n名前\n\nたんぱく質(g)\n\n脂質(g)\n\n炭水化物(g)\n\nカロリー(kcal)\n\n1\n\nケーキ\n\n7\n\n14\n\n47\n\n342\n\n2\n\nポテトチップス\n\n5\n\n35\n\n55\n\n555\n\n3\n\nどら焼き\n\n6\n\n3\n\n59\n\n287\n\n4\n\nプリン\n\n6\n\n5\n\n15\n\n129\n\n分類の対象となるお菓子の個数 n と各お菓子の情報、制限の情報を入力とし、そのお菓子一つだけなら制限を超えることがない(食べてもよい)お菓子の一覧を出力するプログラムを作成してください。\n\nお菓子の情報は、お菓子の番号 s、そのお菓子に含まれるたんぱく質の重量 p、脂質の重量 q、炭水化物の重量 r から構成されています。制限の情報には、含むことができる最大のたんぱく質の重量 P、脂質の重量 Q、炭水化物の重量 R、および摂取することができる最大のカロリー C からなっており、タンパク質、脂質、炭水化物、カロリーのいずれかの一つでも超えると制限違反となり、「食べてはいけないお菓子」と判断されます。\n\n食べてもよいお菓子の一覧は、食べてもよいお菓子の番号を入力順に出力してください。なお、食べてもよいお菓子がなければ”NA”と出力してください。\n上の表にある4個のお菓子について、P = 10, Q = 15, R = 50, C = 400 という制限の場合、ケーキとプリンはそれぞれの栄養素及びカロリーが制限値以下なので食べてもよいお菓子に分類されますが、ポテトチップスは炭水化物とカロリー、どら焼きは炭水化物の量が制限値を超えているため食べてはいけないお菓子に分類されます。\n\n入力\n\n複数のデータセットの並びが与えられます。入力の終わりはゼロひとつの行で示されます。各データセットは以下の形式で与えられます。\n\nn\ns1 p1 q1 r1\ns2 p2 q2 r2\n:\nsn pn qn rn\nP Q R C\n\n1行目にお菓子の数 n (1 ≤ n ≤ 1000)が与えられます。続く n 行に第 i のお菓子の番号 si (1 ≤ si ≤ 1000)、各栄養素の重量を表す整数 pi, qi, ri (0 ≤ pi, qi, ri ≤ 100) が与えられます。\n\n続く行に各栄養素及びカロリーの制限値を表す整数 P, Q, R (0 ≤ P, Q, R ≤ 100), C (0 ≤ C ≤ 1700) が与えられます。\n\nデータセットの数は 100 を超えません。\n\n出力\n\nデータセットごとに、食べてもよいお菓子の番号または ”NA” を出力します。\n\n入力例\n\n4\n1 7 14 47\n2 5 35 55\n3 6 3 59\n4 6 5 15\n10 15 50 400\n2\n1 8 10 78\n2 4 18 33\n10 10 50 300\n0\n\n出力例\n\n1\n4\nNA", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 633, "cpu_time_ms": 560, "memory_kb": 73428}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s693660641", "group_id": "codeNet:p00255", "input_text": "object Main extends App {\n import scala.annotation.tailrec\n import scala.io.StdIn._\n loop()\n @tailrec def loop(): Unit = {\n val n = readInt()\n if (n == 0) return\n val pipe = readLine.trim.split(' ').map(_.toInt).sum\n val joint = 0L +: readLine.trim.split(' ').map(_.toLong).sorted(Ordering.Long.reverse)\n for (i ← joint.indices.tail) joint(i) += joint(i - 1)\n println(joint.zipWithIndex.map { case (additional, count) ⇒ (pipe + additional) * (n - count) }.max)\n loop()\n }\n}\n", "language": "Scala", "metadata": {"date": 1567093925, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00255.html", "problem_id": "p00255", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00255/input.txt", "sample_output_relpath": "derived/input_output/data/p00255/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00255/Scala/s693660641.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s693660641", "user_id": "u514597327"}, "prompt_components": {"gold_output": "12\n48\n76\n", "input_to_evaluate": "object Main extends App {\n import scala.annotation.tailrec\n import scala.io.StdIn._\n loop()\n @tailrec def loop(): Unit = {\n val n = readInt()\n if (n == 0) return\n val pipe = readLine.trim.split(' ').map(_.toInt).sum\n val joint = 0L +: readLine.trim.split(' ').map(_.toLong).sorted(Ordering.Long.reverse)\n for (i ← joint.indices.tail) joint(i) += joint(i - 1)\n println(joint.zipWithIndex.map { case (additional, count) ⇒ (pipe + additional) * (n - count) }.max)\n loop()\n }\n}\n", "problem_context": "パイプつなぎ職人の給料\n\nぼくはパイプつなぎ職人です。パイプをつなぐジョイントとパイプさえもらえれば、どんなパイプだってつないでみせます。ぼくは毎日、親方からパイプとジョイントを渡されて、それをつないで親方に渡します。でも、パイプの数が多すぎるときは、1日でそれを全部つなげることはできません。そんなときでも親方はにっこり笑って、ぼくに給料を渡してくれます。\n\nところで、あるとき変なことに気がつきました。全部のパイプをつなげられたときより、つなげられなかったときの方が給料が多いことがしょっちゅうあるんです。あんまり変なので、ある日、親方が来たときに、給料の計算方法が書いてあるメモをこっそり見ちゃいました。そしたら、なんと\n\n\"給料は「パイプの本数×パイプの長さの総和」で支払う。ただし、ジョイントでつなげて、ひとつながりになったものは、それを1本のパイプとみなす。\"\n\nって書いてありました。これで全部つなげた方が給料が安くなることがある理由がわかりました。たとえば下図のように、長さ 1 のパイプ 3 本と長さ 2 のジョイント 2 本を全部つなげると長さ 1+2+1+2+1 = 7 のパイプが 1 本できるので、1 × (7) = 7 です。でも、ジョイントを一つだけ使って長さ 1+2+1 = 4のパイプと長さ 1 のパイプの 2 本にすると2 × (4+1) = 10なので、全部つなげるよりいっぱい給料がもらえます。\n\n親方がなんでこんな方法で給料を決めてるかわからないけど、これでぼくもどうすればもらえる給料を多くできるかわかりました!\n\nそれでは、パイプの本数が与えられたとき、もらえる給料の最大の金額を計算するプログラムを作成してください。\n\n入力\n\n入力は複数のデータセットからなる。入力の終わりはゼロ1つの行で示される。各データセットは以下の形式で与えられる。\n\nn\np1 ... pn\nj1 ... jn-1\n\n1行目にパイプの本数 n (2 ≤ n ≤ 65000) が与えられる。2行目は1つの空白で区切られた n 個の整数からなる。pi (1 ≤ pi ≤ 1000) はi番目のパイプの長さを示す。3行目は1つの空白で区切られた n-1 個の整数からなる。ji (1 ≤ ji ≤ 1000) は i 番目のジョイントの長さを示す。\n\ni番目のジョイントは、i 番目と i+1 番目のパイプだけをつなげることができる。つなげたパイプの長さは、pi + ji + pi+1 になる。\n\nデータセットの数は 100 を超えない。\n\n出力\n\n各データセットごとに、得られる給料の最大の金額を1行に出力する。入力として与えられるデータセットでは、出力される値は必ず32ビット符号無し整数の範囲に収まるものとする。\n\n入力例1\n\n3\n1 1 1\n3 3\n4\n3 3 3 3\n1 1 1\n5\n1 2 3 4 5\n4 3 2 1\n0\n\n出力例\n\n12\n48\n76", "sample_input": "3\n1 1 1\n3 3\n4\n3 3 3 3\n1 1 1\n5\n1 2 3 4 5\n4 3 2 1\n0\n"}, "reference_outputs": ["12\n48\n76\n"], "source_document_id": "p00255", "source_text": "パイプつなぎ職人の給料\n\nぼくはパイプつなぎ職人です。パイプをつなぐジョイントとパイプさえもらえれば、どんなパイプだってつないでみせます。ぼくは毎日、親方からパイプとジョイントを渡されて、それをつないで親方に渡します。でも、パイプの数が多すぎるときは、1日でそれを全部つなげることはできません。そんなときでも親方はにっこり笑って、ぼくに給料を渡してくれます。\n\nところで、あるとき変なことに気がつきました。全部のパイプをつなげられたときより、つなげられなかったときの方が給料が多いことがしょっちゅうあるんです。あんまり変なので、ある日、親方が来たときに、給料の計算方法が書いてあるメモをこっそり見ちゃいました。そしたら、なんと\n\n\"給料は「パイプの本数×パイプの長さの総和」で支払う。ただし、ジョイントでつなげて、ひとつながりになったものは、それを1本のパイプとみなす。\"\n\nって書いてありました。これで全部つなげた方が給料が安くなることがある理由がわかりました。たとえば下図のように、長さ 1 のパイプ 3 本と長さ 2 のジョイント 2 本を全部つなげると長さ 1+2+1+2+1 = 7 のパイプが 1 本できるので、1 × (7) = 7 です。でも、ジョイントを一つだけ使って長さ 1+2+1 = 4のパイプと長さ 1 のパイプの 2 本にすると2 × (4+1) = 10なので、全部つなげるよりいっぱい給料がもらえます。\n\n親方がなんでこんな方法で給料を決めてるかわからないけど、これでぼくもどうすればもらえる給料を多くできるかわかりました!\n\nそれでは、パイプの本数が与えられたとき、もらえる給料の最大の金額を計算するプログラムを作成してください。\n\n入力\n\n入力は複数のデータセットからなる。入力の終わりはゼロ1つの行で示される。各データセットは以下の形式で与えられる。\n\nn\np1 ... pn\nj1 ... jn-1\n\n1行目にパイプの本数 n (2 ≤ n ≤ 65000) が与えられる。2行目は1つの空白で区切られた n 個の整数からなる。pi (1 ≤ pi ≤ 1000) はi番目のパイプの長さを示す。3行目は1つの空白で区切られた n-1 個の整数からなる。ji (1 ≤ ji ≤ 1000) は i 番目のジョイントの長さを示す。\n\ni番目のジョイントは、i 番目と i+1 番目のパイプだけをつなげることができる。つなげたパイプの長さは、pi + ji + pi+1 になる。\n\nデータセットの数は 100 を超えない。\n\n出力\n\n各データセットごとに、得られる給料の最大の金額を1行に出力する。入力として与えられるデータセットでは、出力される値は必ず32ビット符号無し整数の範囲に収まるものとする。\n\n入力例1\n\n3\n1 1 1\n3 3\n4\n3 3 3 3\n1 1 1\n5\n1 2 3 4 5\n4 3 2 1\n0\n\n出力例\n\n12\n48\n76", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 520, "memory_kb": 123820}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s582788409", "group_id": "codeNet:p00261", "input_text": "object Main extends App {\n val w = Seq(1, 3, -1, 2, 4, 5, 1, -1, 5, 3, 3, 1).grouped(2).toSeq.lift\n val in = io.Source.stdin.getLines\n for (p <- in if p != \"#\") {\n val x = p.foldLeft(0)((city, way) => w(city) match {\n case None => -1\n case Some(way0or1) => way0or1(way.asDigit)\n })\n if (x == 5) println(\"Yes\")\n else println(\"No\")\n }\n}", "language": "Scala", "metadata": {"date": 1494340097, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00261.html", "problem_id": "p00261", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00261/input.txt", "sample_output_relpath": "derived/input_output/data/p00261/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00261/Scala/s582788409.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s582788409", "user_id": "u475394465"}, "prompt_components": {"gold_output": "Yes\nNo\nYes\nNo\nYes\nNo\nYes\n", "input_to_evaluate": "object Main extends App {\n val w = Seq(1, 3, -1, 2, 4, 5, 1, -1, 5, 3, 3, 1).grouped(2).toSeq.lift\n val in = io.Source.stdin.getLines\n for (p <- in if p != \"#\") {\n val x = p.foldLeft(0)((city, way) => w(city) match {\n case None => -1\n case Some(way0or1) => way0or1(way.asDigit)\n })\n if (x == 5) println(\"Yes\")\n else println(\"No\")\n }\n}", "problem_context": "アカ・ベコと40人の盗賊\n\n40 人の盗賊から逃れようとしているアカ・ベコは、A 市の街中で道に迷ってしまった。アカ・ベコは新しいアジトがあるB 市に行きたいのだが地図を盗賊に盗まれてしまった。\n\n盗賊の一人であるコボー氏はアカ・ベコに同情し、気の毒に思っていた。そこで、密かにアカ・ベコに、「あなたがB 市に行くお手伝いをしたいが、仲間にばれない様にしなければならないので、直接道順を教えたいが教えることができない。しかし、あなたの質問には答えられる。」と伝言を送った。\n\nコボー氏は、「○○という道順はどうか。」という質問をアカ・ベコから受け取ると、それがA 市からB市までちょうどたどり付ける道順ならYes、そうでなければNo という答えを伝える。道順のチェックは以下の地図に従って行う。\n\n各都市は一方通行の道でつながっており、それぞれの道には、0 か1 の数字が付いている。アカ・ベコは数字の並びで道順を指定する。例えば、0100 は A 市から X、Z、W 市を経由して B 市にちょうどたどり着く道順である。地図にない道順を選ぶと砂漠に迷い込んでしまい、決して B 市にたどり着くことはない。アカ・ベコは自分がいる都市の名前を知ることはできないため、道順をたどり終えたときにちょうど B 市に到達する必要がある。\n\nコボー氏はアカ・ベコからの質問に答えるために、あなたを密かに雇いプログラムの作成を依頼した。アカ・ベコからの質問を入力すると、それがA 市からB 市にちょうどたどり付ける道順なら Yes、そうでなければ No と出力するプログラムを作成してほしい。\n\n入力\n\n入力は複数のデータセットからなる。入力の終わりは #(シャープ)1つの行で示される。各データセットは以下の形式で与えられる。\n\np\n\n1行に道順を示す数字 0, 1 の並び p が与えられる。p は100文字を超えない文字列である。\n\nデータセットの数は 100 を超えない。\n\n出力\n\nデータセットごとに、Yes または No を1行に出力する。\n\n入力例\n\n0100\n0101\n10100\n01000\n0101011\n0011\n011111\n#\n\n出力例\n\nYes\nNo\nYes\nNo\nYes\nNo\nYes\n\n4つ目のデータセットでは、B 市を通りすぎてY 市に到達する道順なので No と出力する。\n\n5つ目のデータセットでは、同じ都市を何度か通っているが、B 市にちょうどたどり着く道順なので Yes と出力する。\n\n6つ目のデータセットでは、X 市から砂漠に迷い込んでしまいB 市にはたどり着けないので No と出力する。\n\n最後のデータセットでは、B 市をいったん通り過ぎてから、X 市とZ 市を経由してB 市にちょうどたどり着く道順なので Yes と出力する。", "sample_input": "0100\n0101\n10100\n01000\n0101011\n0011\n011111\n#\n"}, "reference_outputs": ["Yes\nNo\nYes\nNo\nYes\nNo\nYes\n"], "source_document_id": "p00261", "source_text": "アカ・ベコと40人の盗賊\n\n40 人の盗賊から逃れようとしているアカ・ベコは、A 市の街中で道に迷ってしまった。アカ・ベコは新しいアジトがあるB 市に行きたいのだが地図を盗賊に盗まれてしまった。\n\n盗賊の一人であるコボー氏はアカ・ベコに同情し、気の毒に思っていた。そこで、密かにアカ・ベコに、「あなたがB 市に行くお手伝いをしたいが、仲間にばれない様にしなければならないので、直接道順を教えたいが教えることができない。しかし、あなたの質問には答えられる。」と伝言を送った。\n\nコボー氏は、「○○という道順はどうか。」という質問をアカ・ベコから受け取ると、それがA 市からB市までちょうどたどり付ける道順ならYes、そうでなければNo という答えを伝える。道順のチェックは以下の地図に従って行う。\n\n各都市は一方通行の道でつながっており、それぞれの道には、0 か1 の数字が付いている。アカ・ベコは数字の並びで道順を指定する。例えば、0100 は A 市から X、Z、W 市を経由して B 市にちょうどたどり着く道順である。地図にない道順を選ぶと砂漠に迷い込んでしまい、決して B 市にたどり着くことはない。アカ・ベコは自分がいる都市の名前を知ることはできないため、道順をたどり終えたときにちょうど B 市に到達する必要がある。\n\nコボー氏はアカ・ベコからの質問に答えるために、あなたを密かに雇いプログラムの作成を依頼した。アカ・ベコからの質問を入力すると、それがA 市からB 市にちょうどたどり付ける道順なら Yes、そうでなければ No と出力するプログラムを作成してほしい。\n\n入力\n\n入力は複数のデータセットからなる。入力の終わりは #(シャープ)1つの行で示される。各データセットは以下の形式で与えられる。\n\np\n\n1行に道順を示す数字 0, 1 の並び p が与えられる。p は100文字を超えない文字列である。\n\nデータセットの数は 100 を超えない。\n\n出力\n\nデータセットごとに、Yes または No を1行に出力する。\n\n入力例\n\n0100\n0101\n10100\n01000\n0101011\n0011\n011111\n#\n\n出力例\n\nYes\nNo\nYes\nNo\nYes\nNo\nYes\n\n4つ目のデータセットでは、B 市を通りすぎてY 市に到達する道順なので No と出力する。\n\n5つ目のデータセットでは、同じ都市を何度か通っているが、B 市にちょうどたどり着く道順なので Yes と出力する。\n\n6つ目のデータセットでは、X 市から砂漠に迷い込んでしまいB 市にはたどり着けないので No と出力する。\n\n最後のデータセットでは、B 市をいったん通り過ぎてから、X 市とZ 市を経由してB 市にちょうどたどり着く道順なので Yes と出力する。", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 260, "memory_kb": 44264}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s912335908", "group_id": "codeNet:p00293", "input_text": "\nobject Main extends App {\n import scala.io.StdIn._\n implicit val timeOrdering = TimeOrdering\n val firstLine = readLine.trim.split(' ').map(_.toInt)\n val secondLine = readLine.trim.split(' ').map(_.toInt)\n val times = (0 until firstLine.head).map(i ⇒ Time(firstLine(i * 2 + 1), firstLine(i * 2 + 2))) ++ (0 until secondLine.head).map(i ⇒ Time(secondLine(i * 2 + 1), secondLine(i * 2 + 2)))\n println(times.distinct.sorted.mkString(\" \"))\n\n object TimeOrdering extends Ordering[Time] {\n override def compare(x: Time, y: Time): Int = if (x.hour == y.hour) x.minute.compare(y.minute) else x.hour.compare(y.hour)\n }\n}\ncase class Time(hour: Int, minute: Int) {\n override def toString: String = f\"$hour:$minute%02d\"\n}\n", "language": "Scala", "metadata": {"date": 1567671989, "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/s912335908.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s912335908", "user_id": "u514597327"}, "prompt_components": {"gold_output": "8:27 9:08 15:59\n", "input_to_evaluate": "\nobject Main extends App {\n import scala.io.StdIn._\n implicit val timeOrdering = TimeOrdering\n val firstLine = readLine.trim.split(' ').map(_.toInt)\n val secondLine = readLine.trim.split(' ').map(_.toInt)\n val times = (0 until firstLine.head).map(i ⇒ Time(firstLine(i * 2 + 1), firstLine(i * 2 + 2))) ++ (0 until secondLine.head).map(i ⇒ Time(secondLine(i * 2 + 1), secondLine(i * 2 + 2)))\n println(times.distinct.sorted.mkString(\" \"))\n\n object TimeOrdering extends Ordering[Time] {\n override def compare(x: Time, y: Time): Int = if (x.hour == y.hour) x.minute.compare(y.minute) else x.hour.compare(y.hour)\n }\n}\ncase class Time(hour: Int, minute: Int) {\n override def toString: String = f\"$hour:$minute%02d\"\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 726, "cpu_time_ms": 270, "memory_kb": 44784}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s564380562", "group_id": "codeNet:p00300", "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 recursive(sc, sc.nextLong())\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 1 <= S && S <= 12\n }\n\n var memo: Map[(Long, Long), Long] = Map[(Long, Long), Long]()\n\n def recursive(sc: => Scanner, N: Long): Unit = {\n if (N != 0) {\n val r, t = sc.nextLong()\n\n if (r % 100 == 0) {\n if (t % 30 == 0) {\n println(r / 100 + t / 30 * 5)\n } else {\n println((r / 100 + t / 30 * 5) + \" \" + (r / 100 + t / 30 * 5 + 5))\n }\n } else {\n if (t % 30 == 0) {\n println((r / 100 + t / 30 * 5) + \" \" + (r / 100 + t / 30 * 5 + 1))\n } else {\n println((r / 100 + t / 30 * 5) + \" \" + (r / 100 + t / 30 * 5 + 1) + \" \" + (r / 100 + t / 30 * 5 + 5) + \" \" + (r / 100 + t / 30 * 5 + 6))\n }\n }\n\n recursive(sc, N - 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 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": 1562854624, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00300.html", "problem_id": "p00300", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00300/input.txt", "sample_output_relpath": "derived/input_output/data/p00300/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00300/Scala/s564380562.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s564380562", "user_id": "u018134297"}, "prompt_components": {"gold_output": "23\n18 23\n17 18 22 23\n17 18\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 recursive(sc, sc.nextLong())\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 1 <= S && S <= 12\n }\n\n var memo: Map[(Long, Long), Long] = Map[(Long, Long), Long]()\n\n def recursive(sc: => Scanner, N: Long): Unit = {\n if (N != 0) {\n val r, t = sc.nextLong()\n\n if (r % 100 == 0) {\n if (t % 30 == 0) {\n println(r / 100 + t / 30 * 5)\n } else {\n println((r / 100 + t / 30 * 5) + \" \" + (r / 100 + t / 30 * 5 + 5))\n }\n } else {\n if (t % 30 == 0) {\n println((r / 100 + t / 30 * 5) + \" \" + (r / 100 + t / 30 * 5 + 1))\n } else {\n println((r / 100 + t / 30 * 5) + \" \" + (r / 100 + t / 30 * 5 + 1) + \" \" + (r / 100 + t / 30 * 5 + 5) + \" \" + (r / 100 + t / 30 * 5 + 6))\n }\n }\n\n recursive(sc, N - 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 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": "有益氏のオーディオルーム\n\n数学者である有益氏の趣味は音楽鑑賞で、家に念願のオーディオルームを作りました。完成したオーディオルームで、友人を招いてお披露目会を開きたいと考えています。全員にできるだけ良い音で聴いてもらいたいので、部屋の中の何か所かで音を計測し、友人たちの位置での音の質を計算するつもりです。\n\n計測点は、下の図の円弧と線分の交点である 1 番から 35 番までの点から選択します。1つの線分上にある点は、オーディオシステムからの距離が 100cmから 500cmまで 100cmずつ離れて並んでいます。1つの円弧状にある点は、もっとも右のもの(1 番から 5 番までの点)から反時計回りに、0°から 180°\nの範囲で 30°度刻みに並んでいます。\n\nこのような円弧と線分に囲まれた領域内のどこかに友人が居ることになるので、友人の居る位置によっ\nて必要な計測点を選択します。友人の位置は、円弧に沿って反時計回りに測った角度とオーディオシス\nテムからの距離で与えられます。必要な計測点は以下のように1点か、2点か、4点が選ばれます。\n\n友人がちょうど計測点の位置にいれば、その1点を選びます。この図の例の場合、選ばれるのは 23 番の点です。\n\n友人が円弧(または線分)の上にちょうど乗っていれば、その円弧(または線分)上にある、友人に最も近い2点を選びます。この図の例の場合、選ばれるのは 18 番と 23 番の点です。\n\n友人が円弧と線分によって囲まれた区画の内側(円弧や線分の上ではない)にいれば、区画を作っている4点を選びます。この図の例の場合、選ばれるのは 17、18、22、23 番の点です。\n\n有益氏を助けるために、必要な計測点の番号を求めるプログラムを作成してください。\n\n入力\n\n入力は以下の形式で与えられる。\n\nN\nr1 t1\nr2 t2\n:\nrN tN\n\n1行目に友人の数 N (1 ≤ N ≤ 50)が与えられる。続く N 行に、友人の位置が与えられる。友人の位置 ri (100 ≤ ri ≤ 500) はオーディオシステムからの距離を表す整数、ti (0 ≤ ti ≤ 180) は円弧に沿って反時計回りに測った角度を表す整数である。\n\n出力\n\n各友人の位置について、計測点の番号を昇順で1行に出力する。\n\n入出力例\n\n入力例\n\n4\n300 120\n300 105\n250 105\n250 90\n\n出力例\n\n23\n18 23\n17 18 22 23\n17 18", "sample_input": "4\n300 120\n300 105\n250 105\n250 90\n"}, "reference_outputs": ["23\n18 23\n17 18 22 23\n17 18\n"], "source_document_id": "p00300", "source_text": "有益氏のオーディオルーム\n\n数学者である有益氏の趣味は音楽鑑賞で、家に念願のオーディオルームを作りました。完成したオーディオルームで、友人を招いてお披露目会を開きたいと考えています。全員にできるだけ良い音で聴いてもらいたいので、部屋の中の何か所かで音を計測し、友人たちの位置での音の質を計算するつもりです。\n\n計測点は、下の図の円弧と線分の交点である 1 番から 35 番までの点から選択します。1つの線分上にある点は、オーディオシステムからの距離が 100cmから 500cmまで 100cmずつ離れて並んでいます。1つの円弧状にある点は、もっとも右のもの(1 番から 5 番までの点)から反時計回りに、0°から 180°\nの範囲で 30°度刻みに並んでいます。\n\nこのような円弧と線分に囲まれた領域内のどこかに友人が居ることになるので、友人の居る位置によっ\nて必要な計測点を選択します。友人の位置は、円弧に沿って反時計回りに測った角度とオーディオシス\nテムからの距離で与えられます。必要な計測点は以下のように1点か、2点か、4点が選ばれます。\n\n友人がちょうど計測点の位置にいれば、その1点を選びます。この図の例の場合、選ばれるのは 23 番の点です。\n\n友人が円弧(または線分)の上にちょうど乗っていれば、その円弧(または線分)上にある、友人に最も近い2点を選びます。この図の例の場合、選ばれるのは 18 番と 23 番の点です。\n\n友人が円弧と線分によって囲まれた区画の内側(円弧や線分の上ではない)にいれば、区画を作っている4点を選びます。この図の例の場合、選ばれるのは 17、18、22、23 番の点です。\n\n有益氏を助けるために、必要な計測点の番号を求めるプログラムを作成してください。\n\n入力\n\n入力は以下の形式で与えられる。\n\nN\nr1 t1\nr2 t2\n:\nrN tN\n\n1行目に友人の数 N (1 ≤ N ≤ 50)が与えられる。続く N 行に、友人の位置が与えられる。友人の位置 ri (100 ≤ ri ≤ 500) はオーディオシステムからの距離を表す整数、ti (0 ≤ ti ≤ 180) は円弧に沿って反時計回りに測った角度を表す整数である。\n\n出力\n\n各友人の位置について、計測点の番号を昇順で1行に出力する。\n\n入出力例\n\n入力例\n\n4\n300 120\n300 105\n250 105\n250 90\n\n出力例\n\n23\n18 23\n17 18 22 23\n17 18", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6924, "cpu_time_ms": 230, "memory_kb": 44312}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s295759009", "group_id": "codeNet:p00331", "input_text": "import java.util.Scanner\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n println((sc.nextInt, sc.nextInt) match {\n case (h, r) if -r > h => -1\n case (h, r) if r <= h => 1\n case _ => 0\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": 1505391162, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00331.html", "problem_id": "p00331", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00331/input.txt", "sample_output_relpath": "derived/input_output/data/p00331/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00331/Scala/s295759009.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s295759009", "user_id": "u018134297"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n println((sc.nextInt, sc.nextInt) match {\n case (h, r) if -r > h => -1\n case (h, r) if r <= h => 1\n case _ => 0\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": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\n日の出と日の入り\n\n太陽が現れることを「日の出」、隠れることを「日の入り」と呼びますが、その厳密な時刻は太陽が地平線に対してどのような位置にある時でしょうか。\n\n下の図のように、太陽を円、地平線を直線で表すことにします。このとき、太陽の「日の出」「日の入り」の時刻は、太陽を表す円の上端が地平線を表す直線と一致する瞬間とされています。日の出の時刻を過ぎ、円の上端が直線より上にある時間帯が昼間、円が直線の下へ完全に隠れている時間帯が夜間となります。\n\nある時刻の地平線から太陽の中心までの高さと、太陽の半径を入力とし、その時刻が「昼間」か、「日の出または日の入り」か、「夜間」かを出力するプログラムを作成せよ。\n\nInput\n\n入力は以下の形式で与えられる。\n\nH R\n\n入力は1行からなり、ある時刻の地平線から太陽の中心までの高さを表す整数 H (-1000 ≤ H ≤ 1000) と半径を表す整数 R (1 ≤ R ≤ 1000) が与えられる。ただし、H は太陽の中心が地平線上にあるときを 0 として、それより上にあるときは正、下にあるときは負とする。\n\nOutput\n\n昼間のとき「1」、日の出または日の入りのとき「0」、夜間のとき「-1」を1行に出力する。\n\nSample Input 1\n\n-3 3\n\nSample Output 1\n\n0\n\nSample Input 2\n\n3 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n-4 3\n\nSample Output 3\n\n-1", "sample_input": "-3 3\n"}, "reference_outputs": ["0\n"], "source_document_id": "p00331", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\n日の出と日の入り\n\n太陽が現れることを「日の出」、隠れることを「日の入り」と呼びますが、その厳密な時刻は太陽が地平線に対してどのような位置にある時でしょうか。\n\n下の図のように、太陽を円、地平線を直線で表すことにします。このとき、太陽の「日の出」「日の入り」の時刻は、太陽を表す円の上端が地平線を表す直線と一致する瞬間とされています。日の出の時刻を過ぎ、円の上端が直線より上にある時間帯が昼間、円が直線の下へ完全に隠れている時間帯が夜間となります。\n\nある時刻の地平線から太陽の中心までの高さと、太陽の半径を入力とし、その時刻が「昼間」か、「日の出または日の入り」か、「夜間」かを出力するプログラムを作成せよ。\n\nInput\n\n入力は以下の形式で与えられる。\n\nH R\n\n入力は1行からなり、ある時刻の地平線から太陽の中心までの高さを表す整数 H (-1000 ≤ H ≤ 1000) と半径を表す整数 R (1 ≤ R ≤ 1000) が与えられる。ただし、H は太陽の中心が地平線上にあるときを 0 として、それより上にあるときは正、下にあるときは負とする。\n\nOutput\n\n昼間のとき「1」、日の出または日の入りのとき「0」、夜間のとき「-1」を1行に出力する。\n\nSample Input 1\n\n-3 3\n\nSample Output 1\n\n0\n\nSample Input 2\n\n3 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n-4 3\n\nSample Output 3\n\n-1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 326, "cpu_time_ms": 280, "memory_kb": 44732}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s573598647", "group_id": "codeNet:p00334", "input_text": "\nobject Main extends App {\n\n import scala.io.StdIn._\n import scala.math._\n\n val n = readLine.trim.toInt\n val points = Array.tabulate(n){_ ⇒\n readLine.trim.split(' ').map(_.toInt - 1).sorted.foldLeft(0){case (a, b) ⇒ a * n + b}\n }.groupBy(it ⇒ it)\n println(\n points.toArray.map{case (_, a) ⇒ a.length - 1}.sum\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}\n/*\n\n\n */\n", "language": "Scala", "metadata": {"date": 1545284396, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00334.html", "problem_id": "p00334", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00334/input.txt", "sample_output_relpath": "derived/input_output/data/p00334/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00334/Scala/s573598647.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s573598647", "user_id": "u514597327"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "\nobject Main extends App {\n\n import scala.io.StdIn._\n import scala.math._\n\n val n = readLine.trim.toInt\n val points = Array.tabulate(n){_ ⇒\n readLine.trim.split(' ').map(_.toInt - 1).sorted.foldLeft(0){case (a, b) ⇒ a * n + b}\n }.groupBy(it ⇒ it)\n println(\n points.toArray.map{case (_, a) ⇒ a.length - 1}.sum\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}\n/*\n\n\n */\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\n形状データ処理\n\nコンピュータグラフィクスでは、三次元の形状を表現する方法として、ポリゴンモデルが使われます。ポリゴンモデルとは、頂点座標と、それらの頂点のつなぎ方を与えて面を作るモデルです。\n\n一般のポリゴンモデルでは、任意の多角形を扱えますが、今回は三角形からなるポリゴンモデルを考えることにします。任意のポリゴンモデルは三角形を表す面情報の集まりとして表すことができます。\n\n一つの面情報は、3つの頂点を並べて表します。ただし、並び方が異なるだけで同じ3点からなる場合は、同じ面情報を表すことにします。例えば、下図の四面体で、頂点1,2,3を繋いでできる面は、頂点2,3,1や、頂点3,2,1などのように表すこともできます。このように、同じ面情報が複数あると無駄になるので、1つにまとめてしまった方が良いでしょう。\n\n面情報が与えられたとき、重複した面を無くすために消さなければならない面情報の個数を求めるプログラムを作成せよ。\n\nInput\n\n入力は以下の形式で与えられる。\n\nN\np11 p12 p13\np21 p22 p23\n:\npN1 pN2 pN3\n\n1行目に、ポリゴンモデルの面情報の数 N (1 ≤ N ≤ 1000) が与えられる。続く N 行に、i 番目の面を作るために使う頂点の番号 pij (1 ≤ pij ≤ 1000) が与えられる。ただし、一つの面について、同じ頂点を2度以上使うことはない(pi1 ≠ pi2 かつ pi2 ≠ pi3 かつ pi1 ≠ pi3 である)。\n\nOutput\n\n重複した面を無くすために消さなければならない面情報の個数を1行に出力する。\n\nSample Input 1\n\n4\n1 3 2\n1 2 4\n1 4 3\n2 3 4\n\nSample Output 1\n\n0\n\nSample Input 2\n\n6\n1 3 2\n1 2 4\n1 4 3\n2 3 4\n3 2 1\n2 3 1\n\nSample Output 2\n\n2\n\n入出力例2では、1つ目と5つ目と6つ目の面は頂点1, 3, 2を使って三角形を作っていて、点の順番が異なるだけなので重複している。つまり、重複した面のうち2つの面を消せば重複した面は無くなる。", "sample_input": "4\n1 3 2\n1 2 4\n1 4 3\n2 3 4\n"}, "reference_outputs": ["0\n"], "source_document_id": "p00334", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\n形状データ処理\n\nコンピュータグラフィクスでは、三次元の形状を表現する方法として、ポリゴンモデルが使われます。ポリゴンモデルとは、頂点座標と、それらの頂点のつなぎ方を与えて面を作るモデルです。\n\n一般のポリゴンモデルでは、任意の多角形を扱えますが、今回は三角形からなるポリゴンモデルを考えることにします。任意のポリゴンモデルは三角形を表す面情報の集まりとして表すことができます。\n\n一つの面情報は、3つの頂点を並べて表します。ただし、並び方が異なるだけで同じ3点からなる場合は、同じ面情報を表すことにします。例えば、下図の四面体で、頂点1,2,3を繋いでできる面は、頂点2,3,1や、頂点3,2,1などのように表すこともできます。このように、同じ面情報が複数あると無駄になるので、1つにまとめてしまった方が良いでしょう。\n\n面情報が与えられたとき、重複した面を無くすために消さなければならない面情報の個数を求めるプログラムを作成せよ。\n\nInput\n\n入力は以下の形式で与えられる。\n\nN\np11 p12 p13\np21 p22 p23\n:\npN1 pN2 pN3\n\n1行目に、ポリゴンモデルの面情報の数 N (1 ≤ N ≤ 1000) が与えられる。続く N 行に、i 番目の面を作るために使う頂点の番号 pij (1 ≤ pij ≤ 1000) が与えられる。ただし、一つの面について、同じ頂点を2度以上使うことはない(pi1 ≠ pi2 かつ pi2 ≠ pi3 かつ pi1 ≠ pi3 である)。\n\nOutput\n\n重複した面を無くすために消さなければならない面情報の個数を1行に出力する。\n\nSample Input 1\n\n4\n1 3 2\n1 2 4\n1 4 3\n2 3 4\n\nSample Output 1\n\n0\n\nSample Input 2\n\n6\n1 3 2\n1 2 4\n1 4 3\n2 3 4\n3 2 1\n2 3 1\n\nSample Output 2\n\n2\n\n入出力例2では、1つ目と5つ目と6つ目の面は頂点1, 3, 2を使って三角形を作っていて、点の順番が異なるだけなので重複している。つまり、重複した面のうち2つの面を消せば重複した面は無くなる。", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 513, "cpu_time_ms": 290, "memory_kb": 46560}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s647972803", "group_id": "codeNet:p00335", "input_text": "\nobject Main extends App {\n\n import scala.io.StdIn._\n import scala.math._\n\n val n = readLine.trim.toInt\n val p = readLine.trim.split(' ').map(_.toInt)\n var min = Int.MaxValue\n for (r ← 0 to p.head){\n val arr = p.clone()\n var sum = r\n arr(0) -= r\n for (i ← arr.indices){\n if (arr(i) > 0){\n sum += arr(i)\n if (i + 1 < arr.length) {\n sum += arr(i)\n arr(i + 1) -= arr(i)\n }\n }\n }\n if (sum < min) min = sum\n }\n println(\n min\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}\n/*\n\n\n */\n", "language": "Scala", "metadata": {"date": 1545284077, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00335.html", "problem_id": "p00335", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00335/input.txt", "sample_output_relpath": "derived/input_output/data/p00335/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00335/Scala/s647972803.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s647972803", "user_id": "u514597327"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "\nobject Main extends App {\n\n import scala.io.StdIn._\n import scala.math._\n\n val n = readLine.trim.toInt\n val p = readLine.trim.split(' ').map(_.toInt)\n var min = Int.MaxValue\n for (r ← 0 to p.head){\n val arr = p.clone()\n var sum = r\n arr(0) -= r\n for (i ← arr.indices){\n if (arr(i) > 0){\n sum += arr(i)\n if (i + 1 < arr.length) {\n sum += arr(i)\n arr(i + 1) -= arr(i)\n }\n }\n }\n if (sum < min) min = sum\n }\n println(\n min\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}\n/*\n\n\n */\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nパンケーキ\n\nあなたが勤めているパンケーキ屋では、細長い鉄板にパンケーキの生地を横1列に並べて焼きます。パンケーキはへらで何回か裏返せば完成します。何回以上裏返せば完成するかはパンケーキごとに異なります。\n\nへらは大きいので、隣り合ったパンケーキは2枚同時に裏返されてしまいます。このとき、これら2枚の位置は入れ替わりません。ただし、両端だけは、隣のパンケーキといっしょに裏返すだけでなく、1枚だけ裏返すこともできます。すべてのパンケーキを必要な回数以上裏返したら、全部いっぺんに鉄板からおろして完成です。\n\nパンケーキを必要な回数より多く裏返すと固くなってしまうので、あまり多く裏返したくありません。そこであなたは、すべて完成するまでに、各パンケーキが裏返る回数の総和が最小になるような方法を見つけようと考えました。\n\n鉄板の上のパンケーキの枚数と、完成するまでに何回以上裏返さなければならないかがパンケーキごとに与えられているとき、すべて完成するまでに各パンケーキが裏返る回数(へらを操作する回数ではない)の総和の最小値を計算するプログラムを作成せよ。\n\nInput\n\n入力は以下の形式で与えられる。\n\nN\np1 p2 ... pN\n\n1行目にパンケーキの枚数 N (3 ≤ N ≤ 5000)が与えられる。2行目に各パンケーキが完成するまでに必要な裏返す回数 pi (0 ≤ pi ≤ 3)が与えられる。\n\nOutput\n\nすべて完成するまでに各パンケーキが裏返る回数の総和の最小値を1行に出力する。\n\nSample Input 1\n\n3\n1 2 1\n\nSample Output 1\n\n4\n\nへらを1回操作して左端と真ん中のパンケーキを裏返すと、2個のパンケーキが1回ずつ裏返るので、この操作で裏返る回数は2回。さらに、へらを1回操作して真ん中と右端のパンケーキを裏返すと、2個のパンケーキが1回ずつ裏返るので、この操作で裏返る回数は2回。以上の総和4回が答えになる。\n\nSample Input 2\n\n3\n0 3 0\n\nSample Output 2\n\n6\n\nへらを1回操作して左端と真ん中のパンケーキを裏返すと、この操作で裏返る回数は2回。これを3回繰り返したときの、総和の6回が答えになる(真ん中のパンケーキは、両隣のどちらかのパンケーキと一緒に裏返すことしかできないことに注意)。", "sample_input": "3\n1 2 1\n"}, "reference_outputs": ["4\n"], "source_document_id": "p00335", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nパンケーキ\n\nあなたが勤めているパンケーキ屋では、細長い鉄板にパンケーキの生地を横1列に並べて焼きます。パンケーキはへらで何回か裏返せば完成します。何回以上裏返せば完成するかはパンケーキごとに異なります。\n\nへらは大きいので、隣り合ったパンケーキは2枚同時に裏返されてしまいます。このとき、これら2枚の位置は入れ替わりません。ただし、両端だけは、隣のパンケーキといっしょに裏返すだけでなく、1枚だけ裏返すこともできます。すべてのパンケーキを必要な回数以上裏返したら、全部いっぺんに鉄板からおろして完成です。\n\nパンケーキを必要な回数より多く裏返すと固くなってしまうので、あまり多く裏返したくありません。そこであなたは、すべて完成するまでに、各パンケーキが裏返る回数の総和が最小になるような方法を見つけようと考えました。\n\n鉄板の上のパンケーキの枚数と、完成するまでに何回以上裏返さなければならないかがパンケーキごとに与えられているとき、すべて完成するまでに各パンケーキが裏返る回数(へらを操作する回数ではない)の総和の最小値を計算するプログラムを作成せよ。\n\nInput\n\n入力は以下の形式で与えられる。\n\nN\np1 p2 ... pN\n\n1行目にパンケーキの枚数 N (3 ≤ N ≤ 5000)が与えられる。2行目に各パンケーキが完成するまでに必要な裏返す回数 pi (0 ≤ pi ≤ 3)が与えられる。\n\nOutput\n\nすべて完成するまでに各パンケーキが裏返る回数の総和の最小値を1行に出力する。\n\nSample Input 1\n\n3\n1 2 1\n\nSample Output 1\n\n4\n\nへらを1回操作して左端と真ん中のパンケーキを裏返すと、2個のパンケーキが1回ずつ裏返るので、この操作で裏返る回数は2回。さらに、へらを1回操作して真ん中と右端のパンケーキを裏返すと、2個のパンケーキが1回ずつ裏返るので、この操作で裏返る回数は2回。以上の総和4回が答えになる。\n\nSample Input 2\n\n3\n0 3 0\n\nSample Output 2\n\n6\n\nへらを1回操作して左端と真ん中のパンケーキを裏返すと、この操作で裏返る回数は2回。これを3回繰り返したときの、総和の6回が答えになる(真ん中のパンケーキは、両隣のどちらかのパンケーキと一緒に裏返すことしかできないことに注意)。", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 686, "cpu_time_ms": 250, "memory_kb": 44740}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s709722715", "group_id": "codeNet:p00338", "input_text": "import scala.util.Random\n\nobject Main extends App {\n\n import scala.io.StdIn._\n import scala.math._\n\n val rand = new Random()\n val Array(n, c) = readLine.trim.split(' ').map(_.toInt)\n val team = Array.tabulate(n){id ⇒ Team(id + 1, 0L)}\n var treap = team.foldLeft(Leaf:Treap[Team]){case (treap, team) ⇒ treap.insert(team, rand.nextDouble())}\n for (_ ← 0 until c){\n val command = readLine.trim.split(' ').map(_.toInt)\n command match {\n case Array(0, t, p) ⇒\n val current = team(t - 1)\n treap = treap.erase(current)\n team(t - 1) = Team(t, current.score + p)\n treap = treap.insert(team(t - 1), rand.nextDouble())\n case Array(1, m) ⇒\n println(\n treap.findNth(m).get.let{t ⇒ s\"${t.id} ${t.score}\"}\n )\n case _ ⇒ ???\n }\n }\n case class Team(id: Int, score:Long) extends Ordered[Team] {\n override def compare(that: Team): Int = if (score == that.score) id.compare(that.id) else that.score.compare(score)\n }\n sealed trait Treap[+T] {\n def size: Int\n def findNth(rank: Int): Option[T]\n def insert[TT >: T <: Ordered[TT]](value: TT, priority: Double): Treap[TT]\n def erase[TT >: T <: Ordered[TT]](value: TT): Treap[T]\n }\n case class Node[T <: Ordered[T]](value: T, priority: Double, left: Treap[T], right: Treap[T]) extends Treap[T] {\n override val size: Int = left.size + right.size + 1\n\n override def findNth(rank: Int): Option[T] = {\n if (left.size >= rank) left.findNth(rank)\n else if (left.size + 1 == rank) Some(value)\n else right.findNth(rank - left.size - 1)\n }\n\n override def insert[TT >: T <: Ordered[TT]](value: TT, priority: Double): Treap[TT] = {\n value.compare(this.value) match {\n case 0 ⇒ throw new Error(s\"$value is already exists\")\n case 1 ⇒ right.insert(value, priority) match {\n case Node(v, p, l, r) if p > this.priority ⇒ Node(v, p, Node(this.value, this.priority, left, l), r)\n case r ⇒ Node(this.value, this.priority, left, r)\n }\n case _ ⇒ left.insert(value, priority) match {\n case Node(v, p, l, r) if p > this.priority ⇒ Node(v, p, l, Node(this.value, this.priority, r, right))\n case l ⇒ Node(this.value, this.priority, l, right)\n }\n }\n }\n\n override def erase[TT >: T <: Ordered[TT]](value: TT): Treap[T] = {\n value.compare(this.value) match {\n case 0 ⇒ (left, right) match {\n case (Node(lv, lp, ll, lr), r@Node(_, rp, _, _)) if lp > rp ⇒ Node(lv, lp, ll, Node(this.value, this.priority, lr, r).erase(value))\n case (l@Node(_, lp, _, _), Node(rv, rp, rl, rr)) if lp < rp ⇒ Node(rv, rp, Node(this.value, this.priority, l, rl).erase(value), rr)\n case (Leaf, r) ⇒ r\n case (l, Leaf) ⇒ l\n }\n case 1 ⇒ Node(this.value, this.priority, left, right.erase(value))\n case _ ⇒ Node(this.value, this.priority, left.erase(value), right)\n }\n }\n\n override def toString: String = (if (left.isInstanceOf[Node[_]]) left.toString + \",\" else \"\") + value.toString + (if (right.isInstanceOf[Node[_]]) \",\" + right.toString else \"\")\n }\n case object Leaf extends Treap[Nothing] {\n override val size: Int = 0\n override def findNth(rank: Int): Option[Nothing] = None\n override def insert[TT >: Nothing <: Ordered[TT]](value: TT, priority: Double): Treap[TT] = Node(value, priority, Leaf, Leaf)\n override def erase[TT >: Nothing <: Ordered[TT]](value: TT): Treap[Nothing] = Leaf\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}\n/*\n\n\n */\n", "language": "Scala", "metadata": {"date": 1545297272, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00338.html", "problem_id": "p00338", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00338/input.txt", "sample_output_relpath": "derived/input_output/data/p00338/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00338/Scala/s709722715.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s709722715", "user_id": "u514597327"}, "prompt_components": {"gold_output": "1 5\n2 5\n3 4\n3 6\n3 6\n1 5\n", "input_to_evaluate": "import scala.util.Random\n\nobject Main extends App {\n\n import scala.io.StdIn._\n import scala.math._\n\n val rand = new Random()\n val Array(n, c) = readLine.trim.split(' ').map(_.toInt)\n val team = Array.tabulate(n){id ⇒ Team(id + 1, 0L)}\n var treap = team.foldLeft(Leaf:Treap[Team]){case (treap, team) ⇒ treap.insert(team, rand.nextDouble())}\n for (_ ← 0 until c){\n val command = readLine.trim.split(' ').map(_.toInt)\n command match {\n case Array(0, t, p) ⇒\n val current = team(t - 1)\n treap = treap.erase(current)\n team(t - 1) = Team(t, current.score + p)\n treap = treap.insert(team(t - 1), rand.nextDouble())\n case Array(1, m) ⇒\n println(\n treap.findNth(m).get.let{t ⇒ s\"${t.id} ${t.score}\"}\n )\n case _ ⇒ ???\n }\n }\n case class Team(id: Int, score:Long) extends Ordered[Team] {\n override def compare(that: Team): Int = if (score == that.score) id.compare(that.id) else that.score.compare(score)\n }\n sealed trait Treap[+T] {\n def size: Int\n def findNth(rank: Int): Option[T]\n def insert[TT >: T <: Ordered[TT]](value: TT, priority: Double): Treap[TT]\n def erase[TT >: T <: Ordered[TT]](value: TT): Treap[T]\n }\n case class Node[T <: Ordered[T]](value: T, priority: Double, left: Treap[T], right: Treap[T]) extends Treap[T] {\n override val size: Int = left.size + right.size + 1\n\n override def findNth(rank: Int): Option[T] = {\n if (left.size >= rank) left.findNth(rank)\n else if (left.size + 1 == rank) Some(value)\n else right.findNth(rank - left.size - 1)\n }\n\n override def insert[TT >: T <: Ordered[TT]](value: TT, priority: Double): Treap[TT] = {\n value.compare(this.value) match {\n case 0 ⇒ throw new Error(s\"$value is already exists\")\n case 1 ⇒ right.insert(value, priority) match {\n case Node(v, p, l, r) if p > this.priority ⇒ Node(v, p, Node(this.value, this.priority, left, l), r)\n case r ⇒ Node(this.value, this.priority, left, r)\n }\n case _ ⇒ left.insert(value, priority) match {\n case Node(v, p, l, r) if p > this.priority ⇒ Node(v, p, l, Node(this.value, this.priority, r, right))\n case l ⇒ Node(this.value, this.priority, l, right)\n }\n }\n }\n\n override def erase[TT >: T <: Ordered[TT]](value: TT): Treap[T] = {\n value.compare(this.value) match {\n case 0 ⇒ (left, right) match {\n case (Node(lv, lp, ll, lr), r@Node(_, rp, _, _)) if lp > rp ⇒ Node(lv, lp, ll, Node(this.value, this.priority, lr, r).erase(value))\n case (l@Node(_, lp, _, _), Node(rv, rp, rl, rr)) if lp < rp ⇒ Node(rv, rp, Node(this.value, this.priority, l, rl).erase(value), rr)\n case (Leaf, r) ⇒ r\n case (l, Leaf) ⇒ l\n }\n case 1 ⇒ Node(this.value, this.priority, left, right.erase(value))\n case _ ⇒ Node(this.value, this.priority, left.erase(value), right)\n }\n }\n\n override def toString: String = (if (left.isInstanceOf[Node[_]]) left.toString + \",\" else \"\") + value.toString + (if (right.isInstanceOf[Node[_]]) \",\" + right.toString else \"\")\n }\n case object Leaf extends Treap[Nothing] {\n override val size: Int = 0\n override def findNth(rank: Int): Option[Nothing] = None\n override def insert[TT >: Nothing <: Ordered[TT]](value: TT, priority: Double): Treap[TT] = Node(value, priority, Leaf, Leaf)\n override def erase[TT >: Nothing <: Ordered[TT]](value: TT): Treap[Nothing] = Leaf\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}\n/*\n\n\n */\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nプログラミングコンテスト II\n\n白虎大学では毎年プログラミングコンテストを開催しています。コンテストは全てのチームの得点が 0の状態から開始し、解答状況に応じて得点が加算されていきます。このコンテストでは、得点の高い順に順位付けが行われます。チームの総数を N としたとき、チームには 1 から N の番号がそれぞれ割り当てられています。得点が同じ場合は番号がより小さい方が上位になります。\n\n白虎大学では、コンテストを盛り上げるために観戦用のランキングシステムを開発しています。開発チームの一員であるあなたは、このシステムの一部であるプログラムの作成を任されています。\n\n与えられた命令に従って、得点の更新と、指定された順位のチームの番号と得点を報告するプログラムを作成せよ。\n\nInput\n\n入力は以下の形式で与えられる。\n\nN C\ncommand1\ncommand2\n:\ncommandC\n\n1行目にチーム数 N (2 ≤ N ≤ 100000) と命令の数 C (1 ≤ C ≤ 100000)が与えられる。続く C 行に、1行ずつ命令が与えられる。各命令は以下の形式で与えられる。\n\n0 t p\n\nまたは\n\n1 m\n\n最初の数字が0のとき更新命令、1のとき報告命令を表す。更新命令では指定された番号 t (1 ≤ t ≤ N) のチームに、整数で与えられる得点 p (1 ≤ p ≤ 109) を加算する。報告命令では指定された順位 m (1 ≤ m ≤ N) のチームの番号と得点を報告する。ただし、報告命令は少なくとも1回現れるものとする。\n\nOutput\n\n各報告命令に対して、指定された順位のチームの番号と得点を空白区切りで1行に出力する。\n\nSample Input 1\n\n3 11\n0 2 5\n0 1 5\n0 3 4\n1 1\n1 2\n1 3\n0 3 2\n1 1\n0 2 1\n1 2\n1 3\n\nSample Output 1\n\n1 5\n2 5\n3 4\n3 6\n3 6\n1 5\n\nSample Input 2\n\n5 2\n1 1\n1 2\n\nSample Output 2\n\n1 0\n2 0", "sample_input": "3 11\n0 2 5\n0 1 5\n0 3 4\n1 1\n1 2\n1 3\n0 3 2\n1 1\n0 2 1\n1 2\n1 3\n"}, "reference_outputs": ["1 5\n2 5\n3 4\n3 6\n3 6\n1 5\n"], "source_document_id": "p00338", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nプログラミングコンテスト II\n\n白虎大学では毎年プログラミングコンテストを開催しています。コンテストは全てのチームの得点が 0の状態から開始し、解答状況に応じて得点が加算されていきます。このコンテストでは、得点の高い順に順位付けが行われます。チームの総数を N としたとき、チームには 1 から N の番号がそれぞれ割り当てられています。得点が同じ場合は番号がより小さい方が上位になります。\n\n白虎大学では、コンテストを盛り上げるために観戦用のランキングシステムを開発しています。開発チームの一員であるあなたは、このシステムの一部であるプログラムの作成を任されています。\n\n与えられた命令に従って、得点の更新と、指定された順位のチームの番号と得点を報告するプログラムを作成せよ。\n\nInput\n\n入力は以下の形式で与えられる。\n\nN C\ncommand1\ncommand2\n:\ncommandC\n\n1行目にチーム数 N (2 ≤ N ≤ 100000) と命令の数 C (1 ≤ C ≤ 100000)が与えられる。続く C 行に、1行ずつ命令が与えられる。各命令は以下の形式で与えられる。\n\n0 t p\n\nまたは\n\n1 m\n\n最初の数字が0のとき更新命令、1のとき報告命令を表す。更新命令では指定された番号 t (1 ≤ t ≤ N) のチームに、整数で与えられる得点 p (1 ≤ p ≤ 109) を加算する。報告命令では指定された順位 m (1 ≤ m ≤ N) のチームの番号と得点を報告する。ただし、報告命令は少なくとも1回現れるものとする。\n\nOutput\n\n各報告命令に対して、指定された順位のチームの番号と得点を空白区切りで1行に出力する。\n\nSample Input 1\n\n3 11\n0 2 5\n0 1 5\n0 3 4\n1 1\n1 2\n1 3\n0 3 2\n1 1\n0 2 1\n1 2\n1 3\n\nSample Output 1\n\n1 5\n2 5\n3 4\n3 6\n3 6\n1 5\n\nSample Input 2\n\n5 2\n1 1\n1 2\n\nSample Output 2\n\n1 0\n2 0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3699, "cpu_time_ms": 1500, "memory_kb": 465096}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s064997345", "group_id": "codeNet:p00366", "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 t = A.max\n val B = (1L to t).filter(i => t % i == 0)\n println(A.map(x => B.filter(i => x <= i).min - x).sum)\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 1 <= S && S <= 12\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\n", "language": "Scala", "metadata": {"date": 1561556494, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00366.html", "problem_id": "p00366", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00366/input.txt", "sample_output_relpath": "derived/input_output/data/p00366/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00366/Scala/s064997345.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s064997345", "user_id": "u018134297"}, "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 = Array.fill(sc.nextInt())(sc.nextLong())\n val t = A.max\n val B = (1L to t).filter(i => t % i == 0)\n println(A.map(x => B.filter(i => x <= i).min - x).sum)\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 1 <= S && S <= 12\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\n", "problem_context": "Electric Metronome\n\nA boy PCK is playing with N electric metronomes. The i-th metronome is set to tick every t_i seconds. He started all of them simultaneously.\n\nHe noticed that, even though each metronome has its own ticking interval, all of them tick simultaneously from time to time in certain intervals. To explore this interesting phenomenon more fully, he is now trying to shorten the interval of ticking in unison by adjusting some of the metronomes’ interval settings. Note, however, that the metronomes do not allow any shortening of the intervals.\n\nGiven the number of metronomes and their preset intervals t_i (sec), write a program to make the tick-in-unison interval shortest by adding a non-negative integer d_i to the current interval setting of the i-th metronome, and report the minimum value of the sum of all d_i.\n\nInput\n\nThe input is given in the following format.\n\nN\nt_1\nt_2\n:\nt_N\n\nThe first line provides the number of metronomes N (1 ≤ N ≤ 105). Each of the subsequent N lines provides the preset ticking interval t_i (1 ≤ t_i ≤ 104) of the i-th metronome.\n\nOutput\n\nOutput the minimum value.\n\nSample Input 1\n\n3\n3\n6\n8\n\nSample Output 1\n\n3\n\nIf we have three metronomes each with a ticking interval of 3, 6, and 8 seconds, respectively, simultaneous activation of these will produce a tick in unison every 24 seconds. By extending the interval by 1 second for the first, and 2 seconds for the second metronome, the interval of ticking in unison will be reduced to 8 seconds, which is the shortest possible for the system.\n\nSample Input 2\n\n2\n10\n10\n\nSample Output 2\n\n0\n\nIf two metronomes are both set to 10 seconds, then simultaneous activation will produce a tick in unison every 10 seconds, which is the shortest possible for this system.", "sample_input": "3\n3\n6\n8\n"}, "reference_outputs": ["3\n"], "source_document_id": "p00366", "source_text": "Electric Metronome\n\nA boy PCK is playing with N electric metronomes. The i-th metronome is set to tick every t_i seconds. He started all of them simultaneously.\n\nHe noticed that, even though each metronome has its own ticking interval, all of them tick simultaneously from time to time in certain intervals. To explore this interesting phenomenon more fully, he is now trying to shorten the interval of ticking in unison by adjusting some of the metronomes’ interval settings. Note, however, that the metronomes do not allow any shortening of the intervals.\n\nGiven the number of metronomes and their preset intervals t_i (sec), write a program to make the tick-in-unison interval shortest by adding a non-negative integer d_i to the current interval setting of the i-th metronome, and report the minimum value of the sum of all d_i.\n\nInput\n\nThe input is given in the following format.\n\nN\nt_1\nt_2\n:\nt_N\n\nThe first line provides the number of metronomes N (1 ≤ N ≤ 105). Each of the subsequent N lines provides the preset ticking interval t_i (1 ≤ t_i ≤ 104) of the i-th metronome.\n\nOutput\n\nOutput the minimum value.\n\nSample Input 1\n\n3\n3\n6\n8\n\nSample Output 1\n\n3\n\nIf we have three metronomes each with a ticking interval of 3, 6, and 8 seconds, respectively, simultaneous activation of these will produce a tick in unison every 24 seconds. By extending the interval by 1 second for the first, and 2 seconds for the second metronome, the interval of ticking in unison will be reduced to 8 seconds, which is the shortest possible for the system.\n\nSample Input 2\n\n2\n10\n10\n\nSample Output 2\n\n0\n\nIf two metronomes are both set to 10 seconds, then simultaneous activation will produce a tick in unison every 10 seconds, which is the shortest possible for this system.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6396, "cpu_time_ms": 710, "memory_kb": 141124}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s171073602", "group_id": "codeNet:p00379", "input_text": "import scala.annotation.tailrec\n\nobject Main extends App {\n import scala.io.StdIn._\n\n val Array(a, n, m) = readLine.trim.split(' ').map(_.toInt)\n println(\n count(a, n, m)\n )\n @tailrec def count(a: Int, n: Int, m: Int, y: Long = 1, res: Int = 0): Int = {\n val x = exponent(a + y, n)\n if (x > m) res\n else count(a, n, m, y + 1, if (sumDigits(x) == y) res + 1 else res)\n }\n def sumDigits(x: Long): Long = {\n x match {\n case 0L ⇒ 0\n case _ ⇒ x % 10 + sumDigits(x / 10)\n }\n }\n def exponent(a: Long, e: Int): Long = {\n e match {\n case 1 ⇒ a\n case _ ⇒ a * exponent(a, e - 1)\n }\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1538396589, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00379.html", "problem_id": "p00379", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00379/input.txt", "sample_output_relpath": "derived/input_output/data/p00379/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00379/Scala/s171073602.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s171073602", "user_id": "u514597327"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.annotation.tailrec\n\nobject Main extends App {\n import scala.io.StdIn._\n\n val Array(a, n, m) = readLine.trim.split(' ').map(_.toInt)\n println(\n count(a, n, m)\n )\n @tailrec def count(a: Int, n: Int, m: Int, y: Long = 1, res: Int = 0): Int = {\n val x = exponent(a + y, n)\n if (x > m) res\n else count(a, n, m, y + 1, if (sumDigits(x) == y) res + 1 else res)\n }\n def sumDigits(x: Long): Long = {\n x match {\n case 0L ⇒ 0\n case _ ⇒ x % 10 + sumDigits(x / 10)\n }\n }\n def exponent(a: Long, e: Int): Long = {\n e match {\n case 1 ⇒ a\n case _ ⇒ a * exponent(a, e - 1)\n }\n }\n}\n\n", "problem_context": "Dudeney Number\n\n \n\nA Dudeney number is a positive integer for which the sum of its decimal digits is equal to the cube root of the number. For example, $512$ is a Dudeney number because it is the cube of $8$, which is the sum of its decimal digits ($5 + 1 + 2$).\n\nIn this problem, we think of a type similar to Dudeney numbers and try to enumerate them.\n\nGiven a non-negative integer $a$, an integer $n$ greater than or equal to 2 and an upper limit $m$, make a program to enumerate all $x$’s such that the sum of its decimal digits $y$ satisfies the relation $x = (y + a)^n$, and $x \\leq m$.\n\nInput\n\nThe input is given in the following format.\n\n$a$ $n$ $m$\n\nThe input line provides three integers: $a$ ($0 \\leq a \\leq 50$), $n$ ($2 \\leq n \\leq 10$) and the upper limit $m$ ($1000 \\leq m \\leq 10^8$).\n\nOutput\n\nOutput the number of integers that meet the above criteria.\n\nSample Input 1\n\n16 2 1000\n\nSample Output 1\n\n2\n\nTwo: $400 = (4 + 0 + 0 + 16)^2$ and $841 = (8 + 4 + 1 + 16)^2$\n\nSample Input 2\n\n0 3 5000\n\nSample Output 2\n\n3\n\nThree: $1=1^3$, $512 = (5 + 1 + 2)^3$ and $4913 = (4 + 9 + 1 + 3)^3$.\n\nSample Input 3\n\n2 3 100000\n\nSample Output 3\n\n0\n\nThere is no such number $x$ in the range below $100,000$ such that its sum of decimal digits $y$ satisfies the relation $(y+2)^3 = x$.", "sample_input": "16 2 1000\n"}, "reference_outputs": ["3\n"], "source_document_id": "p00379", "source_text": "Dudeney Number\n\n \n\nA Dudeney number is a positive integer for which the sum of its decimal digits is equal to the cube root of the number. For example, $512$ is a Dudeney number because it is the cube of $8$, which is the sum of its decimal digits ($5 + 1 + 2$).\n\nIn this problem, we think of a type similar to Dudeney numbers and try to enumerate them.\n\nGiven a non-negative integer $a$, an integer $n$ greater than or equal to 2 and an upper limit $m$, make a program to enumerate all $x$’s such that the sum of its decimal digits $y$ satisfies the relation $x = (y + a)^n$, and $x \\leq m$.\n\nInput\n\nThe input is given in the following format.\n\n$a$ $n$ $m$\n\nThe input line provides three integers: $a$ ($0 \\leq a \\leq 50$), $n$ ($2 \\leq n \\leq 10$) and the upper limit $m$ ($1000 \\leq m \\leq 10^8$).\n\nOutput\n\nOutput the number of integers that meet the above criteria.\n\nSample Input 1\n\n16 2 1000\n\nSample Output 1\n\n2\n\nTwo: $400 = (4 + 0 + 0 + 16)^2$ and $841 = (8 + 4 + 1 + 16)^2$\n\nSample Input 2\n\n0 3 5000\n\nSample Output 2\n\n3\n\nThree: $1=1^3$, $512 = (5 + 1 + 2)^3$ and $4913 = (4 + 9 + 1 + 3)^3$.\n\nSample Input 3\n\n2 3 100000\n\nSample Output 3\n\n0\n\nThere is no such number $x$ in the range below $100,000$ such that its sum of decimal digits $y$ satisfies the relation $(y+2)^3 = x$.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 639, "cpu_time_ms": 230, "memory_kb": 43992}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s011459964", "group_id": "codeNet:p00381", "input_text": "\nobject Main extends App {\n import scala.io.StdIn._\n val mod = 1000000007L\n val n = readLine.trim.toInt\n val planets: Array[Planet] = readLine.trim.toCharArray.zip(readLine.trim.toCharArray).map{case (f, t) ⇒ new Planet(f, t)}\n val pattern = Array.tabulate(26){_ ⇒ 0L}.also(a ⇒ a(planets(0).in.toIndex) = 1)\n for (i ← 1 until planets.length - 1){\n pattern(planets(i).in.toIndex) = (pattern(planets(i).out.toIndex) + pattern(planets(i).in.toIndex)) % mod\n }\n println(pattern(planets(n - 1).out.toIndex))\n class Planet(val in: Char, val out: Char)\n implicit class CharToInt(val value: Char){\n def toIndex: Int = value - 'a'\n }\n implicit class ScopedFunc[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//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0386\n", "language": "Scala", "metadata": {"date": 1538115677, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00381.html", "problem_id": "p00381", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00381/input.txt", "sample_output_relpath": "derived/input_output/data/p00381/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00381/Scala/s011459964.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s011459964", "user_id": "u514597327"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "\nobject Main extends App {\n import scala.io.StdIn._\n val mod = 1000000007L\n val n = readLine.trim.toInt\n val planets: Array[Planet] = readLine.trim.toCharArray.zip(readLine.trim.toCharArray).map{case (f, t) ⇒ new Planet(f, t)}\n val pattern = Array.tabulate(26){_ ⇒ 0L}.also(a ⇒ a(planets(0).in.toIndex) = 1)\n for (i ← 1 until planets.length - 1){\n pattern(planets(i).in.toIndex) = (pattern(planets(i).out.toIndex) + pattern(planets(i).in.toIndex)) % mod\n }\n println(pattern(planets(n - 1).out.toIndex))\n class Planet(val in: Char, val out: Char)\n implicit class CharToInt(val value: Char){\n def toIndex: Int = value - 'a'\n }\n implicit class ScopedFunc[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//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0386\n", "problem_context": "Transporter\n\nIn the year 30XX, an expedition team reached a planet and found a warp machine suggesting the existence of a mysterious supercivilization. When you go through one of its entrance gates, you can instantaneously move to the exit irrespective of how far away it is. You can move even to the end of the universe at will with this technology!\n\nThe scientist team started examining the machine and successfully identified all the planets on which the entrances to the machine were located. Each of these N planets (identified by an index from $1$ to $N$) has an entrance to, and an exit from the warp machine. Each of the entrances and exits has a letter inscribed on it.\n\nThe mechanism of spatial mobility through the warp machine is as follows:\n\nIf you go into an entrance gate labeled with c, then you can exit from any gate with label c.\n\nIf you go into an entrance located on the $i$-th planet, then you can exit from any gate located on the $j$-th planet where $i < j$.\n\nOnce you have reached an exit of the warp machine on a planet, you can continue your journey by entering into the warp machine on the same planet. In this way, you can reach a faraway planet. Our human race has decided to dispatch an expedition to the star $N$, starting from Star $1$ and using the warp machine until it reaches Star $N$. To evaluate the possibility of successfully reaching the destination. it is highly desirable for us to know how many different routes are available for the expedition team to track.\n\nGiven information regarding the stars, make a program to enumerate the passages from Star $1$ to Star $N$.\n\nInput\n\nThe input is given in the following format.\n\n$N$\n$s$\n$t$\n\nThe first line provides the number of the stars on which the warp machine is located $N$ ($2 \\leq N \\leq 100,000$). The second line provides a string $s$ of length $N$, each component of which represents the letter inscribed on the entrance of the machine on the star. By the same token, the third line provides a string $t$ of length $N$ consisting of the letters inscribed on the exit of the machine. Two strings $s$ and $t$ consist all of lower-case alphabetical letters, and the $i$-th letter of these strings corresponds respectively to the entrance and exit of Star $i$ machine.\n\nOutput\n\nDivide the number of possible routes from Star $1$ to Star $N$ obtained above by 1,000,000,007, and output the remainder.\n\nSample Input 1\n\n6\nabbaba\nbaabab\n\nSample Output 1\n\n5\n\nSample Input 2\n\n25\nneihsokcpuziafoytisrevinu\nuniversityofaizupckoshien\n\nSample Output 2\n\n4", "sample_input": "6\nabbaba\nbaabab\n"}, "reference_outputs": ["5\n"], "source_document_id": "p00381", "source_text": "Transporter\n\nIn the year 30XX, an expedition team reached a planet and found a warp machine suggesting the existence of a mysterious supercivilization. When you go through one of its entrance gates, you can instantaneously move to the exit irrespective of how far away it is. You can move even to the end of the universe at will with this technology!\n\nThe scientist team started examining the machine and successfully identified all the planets on which the entrances to the machine were located. Each of these N planets (identified by an index from $1$ to $N$) has an entrance to, and an exit from the warp machine. Each of the entrances and exits has a letter inscribed on it.\n\nThe mechanism of spatial mobility through the warp machine is as follows:\n\nIf you go into an entrance gate labeled with c, then you can exit from any gate with label c.\n\nIf you go into an entrance located on the $i$-th planet, then you can exit from any gate located on the $j$-th planet where $i < j$.\n\nOnce you have reached an exit of the warp machine on a planet, you can continue your journey by entering into the warp machine on the same planet. In this way, you can reach a faraway planet. Our human race has decided to dispatch an expedition to the star $N$, starting from Star $1$ and using the warp machine until it reaches Star $N$. To evaluate the possibility of successfully reaching the destination. it is highly desirable for us to know how many different routes are available for the expedition team to track.\n\nGiven information regarding the stars, make a program to enumerate the passages from Star $1$ to Star $N$.\n\nInput\n\nThe input is given in the following format.\n\n$N$\n$s$\n$t$\n\nThe first line provides the number of the stars on which the warp machine is located $N$ ($2 \\leq N \\leq 100,000$). The second line provides a string $s$ of length $N$, each component of which represents the letter inscribed on the entrance of the machine on the star. By the same token, the third line provides a string $t$ of length $N$ consisting of the letters inscribed on the exit of the machine. Two strings $s$ and $t$ consist all of lower-case alphabetical letters, and the $i$-th letter of these strings corresponds respectively to the entrance and exit of Star $i$ machine.\n\nOutput\n\nDivide the number of possible routes from Star $1$ to Star $N$ obtained above by 1,000,000,007, and output the remainder.\n\nSample Input 1\n\n6\nabbaba\nbaabab\n\nSample Output 1\n\n5\n\nSample Input 2\n\n25\nneihsokcpuziafoytisrevinu\nuniversityofaizupckoshien\n\nSample Output 2\n\n4", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 887, "cpu_time_ms": 290, "memory_kb": 53792}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s496188238", "group_id": "codeNet:p00397", "input_text": "object Main extends App {\n import scala.io.StdIn._\n val Array(n, k) = readLine.trim.split(' ').map(_.toLong)\n val numbers = 0 +: readLine.trim.split(' ').map(_.toInt)//numbers(i) == [0, i)の排他的論理和\n for (i ← numbers.indices.tail) numbers(i) ^= numbers(i - 1)\n var rest = k\n var result = 0\n val maxDigit = 20\n val count = Array.tabulate(1 << maxDigit){_ ⇒ 0}\n for (topDigit ← 1 to maxDigit){\n val next = result * 2 + 1\n var sum = 0L\n for (num ← numbers){\n count(num >> (maxDigit - topDigit)) += 1\n sum += count((num >> (maxDigit - topDigit)) ^ next)\n }\n if (sum >= rest){\n result = result * 2 + 1\n }else {\n result = result * 2\n rest -= sum\n }\n (0 until (1 << topDigit)).foreach(i ⇒ count(i) = 0)\n }\n println(result)\n implicit class Scope[T](val value: T) extends AnyVal {\n @inline\n def also(@inline func: T ⇒ Unit): T = {\n func(value)\n value\n }\n @inline\n def let[A](@inline func: T ⇒ A): A = func(value)\n }\n}\n", "language": "Scala", "metadata": {"date": 1551449544, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00397.html", "problem_id": "p00397", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00397/input.txt", "sample_output_relpath": "derived/input_output/data/p00397/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00397/Scala/s496188238.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s496188238", "user_id": "u514597327"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n import scala.io.StdIn._\n val Array(n, k) = readLine.trim.split(' ').map(_.toLong)\n val numbers = 0 +: readLine.trim.split(' ').map(_.toInt)//numbers(i) == [0, i)の排他的論理和\n for (i ← numbers.indices.tail) numbers(i) ^= numbers(i - 1)\n var rest = k\n var result = 0\n val maxDigit = 20\n val count = Array.tabulate(1 << maxDigit){_ ⇒ 0}\n for (topDigit ← 1 to maxDigit){\n val next = result * 2 + 1\n var sum = 0L\n for (num ← numbers){\n count(num >> (maxDigit - topDigit)) += 1\n sum += count((num >> (maxDigit - topDigit)) ^ next)\n }\n if (sum >= rest){\n result = result * 2 + 1\n }else {\n result = result * 2\n rest -= sum\n }\n (0 until (1 << topDigit)).foreach(i ⇒ count(i) = 0)\n }\n println(result)\n implicit class Scope[T](val value: T) extends AnyVal {\n @inline\n def also(@inline func: T ⇒ Unit): T = {\n func(value)\n value\n }\n @inline\n def let[A](@inline func: T ⇒ A): A = func(value)\n }\n}\n", "problem_context": "K-th Exclusive OR\n\nExclusive OR (XOR) is an operation on two binary numbers $x$ and $y$ (0 or 1) that produces 0 if $x = y$ and $1$ if $x \\ne y$. This operation is represented by the symbol $\\oplus$. From the definition: $0 \\oplus 0 = 0$, $0 \\oplus 1 = 1$, $1 \\oplus 0 = 1$, $1 \\oplus 1 = 0$.\n\nExclusive OR on two non-negative integers comprises the following procedures: binary representation of the two integers are XORed on bit by bit bases, and the resultant bit array constitute a new integer. This operation is also represented by the same symbol $\\oplus$. For example, XOR of decimal numbers $3$ and $5$ is equivalent to binary operation $011 \\oplus 101$ which results in $110$, or $6$ in decimal format.\n\nBitwise XOR operation on a sequence $Z$ consisting of $M$ non-negative integers $z_1, z_2, . . . , z_M$ is defined as follows:\n\n$v_0 = 0, v_i = v_{i - 1} \\oplus z_i$ ($1 \\leq i \\leq M$)\n\nBitwise XOR on series $Z$ is defined as $v_M$.\n\nYou have a sequence $A$ consisting of $N$ non-negative integers, ample sheets of papers and an empty box. You performed each of the following operations once on every combinations of integers ($L, R$), where $1 \\leq L \\leq R \\leq N$.\n\nPerform the bitwise XOR operation on the sub-sequence (from $L$-th to $R$-th elements) and name the result as $B$.\n\nSelect a sheet of paper and write $B$ on it, then put it in the box.\n\nAssume that ample sheets of paper are available to complete the trials. You select a positive integer $K$ and line up the sheets of paper inside the box in decreasing order of the number written on them. What you want to know is the number written on the $K$-th sheet of paper.\n\nYou are given a series and perform all the operations described above. Then, you line up the sheets of paper in decreasing order of the numbers written on them. Make a program to determine the $K$-th number in the series.\n\nInput\n\nThe input is given in the following format.\n\n$N$ $K$\n$a_1$ $a_2$ ... $a_N$\n\nThe first line provides the number of elements in the series $N$ ($1 \\leq N \\leq 10^5$) and the selected number $K$ ($1 \\leq K \\leq N(N+1)/2$). The second line provides an array of elements $a_i$ ($0 \\leq a_i \\leq 10^6$).\n\nSample Input 1\n\n3 3\n1 2 3\n\nSample Output 1\n\n2\n\nAfter all operations have been completed, the numbers written on the paper inside the box are as follows (sorted in decreasing order)\n\n$3,3,2,1,1,0$\n\n3番目の数は2であるため、2を出力する。\n\nSample Input 2\n\n7 1\n1 0 1 0 1 0 1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n5 10\n1 2 4 8 16\n\nSample Output 3\n\n7", "sample_input": "3 3\n1 2 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p00397", "source_text": "K-th Exclusive OR\n\nExclusive OR (XOR) is an operation on two binary numbers $x$ and $y$ (0 or 1) that produces 0 if $x = y$ and $1$ if $x \\ne y$. This operation is represented by the symbol $\\oplus$. From the definition: $0 \\oplus 0 = 0$, $0 \\oplus 1 = 1$, $1 \\oplus 0 = 1$, $1 \\oplus 1 = 0$.\n\nExclusive OR on two non-negative integers comprises the following procedures: binary representation of the two integers are XORed on bit by bit bases, and the resultant bit array constitute a new integer. This operation is also represented by the same symbol $\\oplus$. For example, XOR of decimal numbers $3$ and $5$ is equivalent to binary operation $011 \\oplus 101$ which results in $110$, or $6$ in decimal format.\n\nBitwise XOR operation on a sequence $Z$ consisting of $M$ non-negative integers $z_1, z_2, . . . , z_M$ is defined as follows:\n\n$v_0 = 0, v_i = v_{i - 1} \\oplus z_i$ ($1 \\leq i \\leq M$)\n\nBitwise XOR on series $Z$ is defined as $v_M$.\n\nYou have a sequence $A$ consisting of $N$ non-negative integers, ample sheets of papers and an empty box. You performed each of the following operations once on every combinations of integers ($L, R$), where $1 \\leq L \\leq R \\leq N$.\n\nPerform the bitwise XOR operation on the sub-sequence (from $L$-th to $R$-th elements) and name the result as $B$.\n\nSelect a sheet of paper and write $B$ on it, then put it in the box.\n\nAssume that ample sheets of paper are available to complete the trials. You select a positive integer $K$ and line up the sheets of paper inside the box in decreasing order of the number written on them. What you want to know is the number written on the $K$-th sheet of paper.\n\nYou are given a series and perform all the operations described above. Then, you line up the sheets of paper in decreasing order of the numbers written on them. Make a program to determine the $K$-th number in the series.\n\nInput\n\nThe input is given in the following format.\n\n$N$ $K$\n$a_1$ $a_2$ ... $a_N$\n\nThe first line provides the number of elements in the series $N$ ($1 \\leq N \\leq 10^5$) and the selected number $K$ ($1 \\leq K \\leq N(N+1)/2$). The second line provides an array of elements $a_i$ ($0 \\leq a_i \\leq 10^6$).\n\nSample Input 1\n\n3 3\n1 2 3\n\nSample Output 1\n\n2\n\nAfter all operations have been completed, the numbers written on the paper inside the box are as follows (sorted in decreasing order)\n\n$3,3,2,1,1,0$\n\n3番目の数は2であるため、2を出力する。\n\nSample Input 2\n\n7 1\n1 0 1 0 1 0 1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n5 10\n1 2 4 8 16\n\nSample Output 3\n\n7", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1021, "cpu_time_ms": 420, "memory_kb": 100740}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s481440979", "group_id": "codeNet:p00400", "input_text": "object Main extends App {\n import scala.io.StdIn._\n val c = readInt()\n println(\n c match {\n case _ if (65 to 90).contains(c) ⇒ 1\n case _ if (97 to 122).contains(c) ⇒ 2\n case _ ⇒ 0\n }\n )\n}\n\n", "language": "Scala", "metadata": {"date": 1569722537, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00400.html", "problem_id": "p00400", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00400/input.txt", "sample_output_relpath": "derived/input_output/data/p00400/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00400/Scala/s481440979.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s481440979", "user_id": "u514597327"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main extends App {\n import scala.io.StdIn._\n val c = readInt()\n println(\n c match {\n case _ if (65 to 90).contains(c) ⇒ 1\n case _ if (97 to 122).contains(c) ⇒ 2\n case _ ⇒ 0\n }\n )\n}\n\n", "problem_context": "アスキー文字\n\n \n\nコンピュータの内部ではすべての情報が数値として扱われています。たとえば、アスキーコードでは、アルファベットの大文字Aに数値の65が割り当てられています。同様にアルファベットの大文字Bに66、Cに67というように、AからZには連続してそれぞれ65から90が割り当てられています。また、アスキーコードでは、アルファベットの小文字aに97が割り当てられています。同様にアルファベットの小文字bに98、cに99というように、aからzには連続してそれぞれ97から122が割り当てられています。\n\n与えられたアスキーコードの数値が、アルファベットの大文字と小文字のどちらを表すか判定するプログラムを作成せよ。\n\n入力\n\n入力は以下の形式で与えられる。\n\n$N$\n\n1行に数値$N$ ($0 \\leq N \\leq 127$)が与えられる。\n\n出力\n\n大文字なら「1」を、小文字なら「2」を、それ以外なら「0」を1行に出力する。\n\n入出力例\n\n入力例1\n\n67\n\n出力例1\n\n1\n\n入力例2\n\n110\n\n出力例2\n\n2\n\n入力例3\n\n32\n\n出力例3\n\n0", "sample_input": "67\n"}, "reference_outputs": ["1\n"], "source_document_id": "p00400", "source_text": "アスキー文字\n\n \n\nコンピュータの内部ではすべての情報が数値として扱われています。たとえば、アスキーコードでは、アルファベットの大文字Aに数値の65が割り当てられています。同様にアルファベットの大文字Bに66、Cに67というように、AからZには連続してそれぞれ65から90が割り当てられています。また、アスキーコードでは、アルファベットの小文字aに97が割り当てられています。同様にアルファベットの小文字bに98、cに99というように、aからzには連続してそれぞれ97から122が割り当てられています。\n\n与えられたアスキーコードの数値が、アルファベットの大文字と小文字のどちらを表すか判定するプログラムを作成せよ。\n\n入力\n\n入力は以下の形式で与えられる。\n\n$N$\n\n1行に数値$N$ ($0 \\leq N \\leq 127$)が与えられる。\n\n出力\n\n大文字なら「1」を、小文字なら「2」を、それ以外なら「0」を1行に出力する。\n\n入出力例\n\n入力例1\n\n67\n\n出力例1\n\n1\n\n入力例2\n\n110\n\n出力例2\n\n2\n\n入力例3\n\n32\n\n出力例3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 220, "cpu_time_ms": 300, "memory_kb": 43680}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s275113615", "group_id": "codeNet:p00424", "input_text": "import scala.io.Source._\nimport 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 map = scala.collection.mutable.HashMap[Char, Char]()\n for (i <- 0 until n) {\n val s = readLine.split(' ').map(x => x.head)\n map += (s.head -> s(1))\n }\n\n val nn = readInt\n for (i <- 0 until nn) {\n val x = readLine.head\n print(map.get(x).getOrElse(x))\n }\n println\n }\n }\n}", "language": "Scala", "metadata": {"date": 1507306707, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00424.html", "problem_id": "p00424", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00424/input.txt", "sample_output_relpath": "derived/input_output/data/p00424/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00424/Scala/s275113615.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s275113615", "user_id": "u809744987"}, "prompt_components": {"gold_output": "aBC5144aba\naBC5144aba\n", "input_to_evaluate": "import scala.io.Source._\nimport 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 map = scala.collection.mutable.HashMap[Char, Char]()\n for (i <- 0 until n) {\n val s = readLine.split(' ').map(x => x.head)\n map += (s.head -> s(1))\n }\n\n val nn = readInt\n for (i <- 0 until nn) {\n val x = readLine.head\n print(map.get(x).getOrElse(x))\n }\n println\n }\n }\n}", "problem_context": "与えられた変換表にもとづき,データを変換するプログラムを作成しなさい.\n\nデータに使われている文字は英字か数字で,英字は大文字と小文字を区別する.変換表に現れる文字の順序に規則性はない.\n\n変換表は空白をはさんで前と後ろの 2 つの文字がある(文字列ではない).変換方法は,変換表のある行の前の文字がデータに現れたら,そのたびにその文字を後ろの文字に変換し出力する.変換は 1 度だけで,変換した文字がまた変換対象の文字になっても変換しない.変換表に現れない文字は変換せず,そのまま出力する.\n\n入力ファイルには,変換表(最初の n + 1 行)に続き変換するデータ(n + 2 行目以降)が書いてある. 1 行目に変換表の行数 n,続く n 行の各行は,空白をはさんで 2 つの文字,さらに続けて, n + 2 行目に変換するデータの行数 m,続く m 行の各行は 1 文字である. m ≤ 105 とする.出力は,出力例のように途中に空白や改行は入れず 1 行とせよ.\n\n入力例\n\n3\n\nA a\n\n0 5\n\n5 4\n\n10\n\nA\n\nB\n\nC\n\n0\n\n1\n\n4\n\n5\n\na\n\nb\n\nA\n\n \n\n出力例\n\naBC5144aba\n\n入力\n\n入力は複数のデータセットからなる.n が 0 のとき入力が終了する.データセットの数は 5 を超えない.\n\n出力\n\nデータセットごとに、変換後の文字列を1行に出力する.\n\n入力例\n\n3\nA a\n0 5\n5 4\n10\nA\nB\nC\n0\n1\n4\n5\na\nb\nA\n3\nA a\n0 5\n5 4\n10\nA\nB\nC\n0\n1\n4\n5\na\nb\nA\n0\n\n出力例\n\naBC5144aba\naBC5144aba\n\n各データセットの出力(変換後の文字列)の後に改行を入れること.\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "3\nA a\n0 5\n5 4\n10\nA\nB\nC\n0\n1\n4\n5\na\nb\nA\n3\nA a\n0 5\n5 4\n10\nA\nB\nC\n0\n1\n4\n5\na\nb\nA\n0\n"}, "reference_outputs": ["aBC5144aba\naBC5144aba\n"], "source_document_id": "p00424", "source_text": "与えられた変換表にもとづき,データを変換するプログラムを作成しなさい.\n\nデータに使われている文字は英字か数字で,英字は大文字と小文字を区別する.変換表に現れる文字の順序に規則性はない.\n\n変換表は空白をはさんで前と後ろの 2 つの文字がある(文字列ではない).変換方法は,変換表のある行の前の文字がデータに現れたら,そのたびにその文字を後ろの文字に変換し出力する.変換は 1 度だけで,変換した文字がまた変換対象の文字になっても変換しない.変換表に現れない文字は変換せず,そのまま出力する.\n\n入力ファイルには,変換表(最初の n + 1 行)に続き変換するデータ(n + 2 行目以降)が書いてある. 1 行目に変換表の行数 n,続く n 行の各行は,空白をはさんで 2 つの文字,さらに続けて, n + 2 行目に変換するデータの行数 m,続く m 行の各行は 1 文字である. m ≤ 105 とする.出力は,出力例のように途中に空白や改行は入れず 1 行とせよ.\n\n入力例\n\n3\n\nA a\n\n0 5\n\n5 4\n\n10\n\nA\n\nB\n\nC\n\n0\n\n1\n\n4\n\n5\n\na\n\nb\n\nA\n\n \n\n出力例\n\naBC5144aba\n\n入力\n\n入力は複数のデータセットからなる.n が 0 のとき入力が終了する.データセットの数は 5 を超えない.\n\n出力\n\nデータセットごとに、変換後の文字列を1行に出力する.\n\n入力例\n\n3\nA a\n0 5\n5 4\n10\nA\nB\nC\n0\n1\n4\n5\na\nb\nA\n3\nA a\n0 5\n5 4\n10\nA\nB\nC\n0\n1\n4\n5\na\nb\nA\n0\n\n出力例\n\naBC5144aba\naBC5144aba\n\n各データセットの出力(変換後の文字列)の後に改行を入れること.\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 514, "cpu_time_ms": 560, "memory_kb": 68228}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s687231596", "group_id": "codeNet:p00428", "input_text": "object Main extends App {\n val in = io.Source.stdin.getLines.map(_.split(\" \").map(_.toInt))\n for (Array(n, m) <- in if n != 0) {\n println(in.take(n).toList.transpose.zipWithIndex.sortWith((a, b) => a._1.sum > b._1.sum).map(_._2+1).mkString(\" \"))\n }\n}", "language": "Scala", "metadata": {"date": 1492698851, "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/s687231596.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s687231596", "user_id": "u475394465"}, "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 in = io.Source.stdin.getLines.map(_.split(\" \").map(_.toInt))\n for (Array(n, m) <- in if n != 0) {\n println(in.take(n).toList.transpose.zipWithIndex.sortWith((a, b) => a._1.sum > b._1.sum).map(_._2+1).mkString(\" \"))\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 266, "cpu_time_ms": 480, "memory_kb": 91572}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s899970951", "group_id": "codeNet:p00433", "input_text": "object Main {\n def main(args: Array[String]) = {\n val in = io.Source.stdin.getLines.map(_.split(\" \").map(_.toInt))\n println(in.next.sum max in.next.sum)\n }\n}", "language": "Scala", "metadata": {"date": 1481339544, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00433.html", "problem_id": "p00433", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00433/input.txt", "sample_output_relpath": "derived/input_output/data/p00433/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00433/Scala/s899970951.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s899970951", "user_id": "u475394465"}, "prompt_components": {"gold_output": "320\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]) = {\n val in = io.Source.stdin.getLines.map(_.split(\" \").map(_.toInt))\n println(in.next.sum max in.next.sum)\n }\n}", "problem_context": "得点\n\n問題\n\nJOI高校の2人の生徒 A さんと B さんは,情報,数学,理科,英語の4教科の試験を受けた. A さんと B さんのこれら4教科の得点が与えられると, Aさんの合計点 S と Bさんの合計点 T のうち大きな方を出力するプログラムを作成せよ.ただし,同点の場合は S (= T) を出力せよ.\n\n入力\n\n入力は2行からなる.\n\n1行目は4つの整数が1つの空白を区切りとして書かれており,それぞれ順に, A さんの情報の得点,数学の得点,理科の得点,英語の得点を表している.\n\n2行目は4つの整数が1つの空白を区切りとして書かれており,それぞれ順に, B さんの情報の得点,数学の得点,理科の得点,英語の得点を表している.\n\nどの教科の得点も100点満点で,負の得点が与えられることはない.\n\n出力\n\n出力は, 求める1つの整数からなる.\n\n入出力例\n\n入力例1\n\n100 80 70 60\n80 70 80 90\n\n出力例1\n\n320\n\n入力例2\n\n100 80 70 60\n80 70 60 100\n\n出力例2\n\n310\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "100 80 70 60\n80 70 80 90\n"}, "reference_outputs": ["320\n"], "source_document_id": "p00433", "source_text": "得点\n\n問題\n\nJOI高校の2人の生徒 A さんと B さんは,情報,数学,理科,英語の4教科の試験を受けた. A さんと B さんのこれら4教科の得点が与えられると, Aさんの合計点 S と Bさんの合計点 T のうち大きな方を出力するプログラムを作成せよ.ただし,同点の場合は S (= T) を出力せよ.\n\n入力\n\n入力は2行からなる.\n\n1行目は4つの整数が1つの空白を区切りとして書かれており,それぞれ順に, A さんの情報の得点,数学の得点,理科の得点,英語の得点を表している.\n\n2行目は4つの整数が1つの空白を区切りとして書かれており,それぞれ順に, B さんの情報の得点,数学の得点,理科の得点,英語の得点を表している.\n\nどの教科の得点も100点満点で,負の得点が与えられることはない.\n\n出力\n\n出力は, 求める1つの整数からなる.\n\n入出力例\n\n入力例1\n\n100 80 70 60\n80 70 80 90\n\n出力例1\n\n320\n\n入力例2\n\n100 80 70 60\n80 70 60 100\n\n出力例2\n\n310\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 177, "cpu_time_ms": 240, "memory_kb": 44052}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s222641981", "group_id": "codeNet:p00436", "input_text": "import scala.io.StdIn.{readLine,readInt}\n\nobject Main {\n def cut(c:Array[Int],n:Int,k:Int) = {\n c.slice(k,2*n) ++ c.slice(0,k)\n }\n\n def rif(c:Array[Int],n:Int) = {\n val a = c.slice(0,n)\n val b = c.slice(n,n+n)\n (0 until 2*n).map{ i=> if(i%2==0) a(i/2) else b((i-1)/2) }.toArray\n }\n\n def main(args:Array[String]) = {\n val n = readInt\n val m = readInt\n var a = (0 until 2*n).map { i => i+1 }.toArray\n for(i<-0 until m) {\n val k = readInt\n if(k==0) a = rif(a,n)\n else a = cut(a,n,k)\n }\n println(a.mkString(\"\\n\"))\n }\n\n}", "language": "Scala", "metadata": {"date": 1488707700, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00436.html", "problem_id": "p00436", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00436/input.txt", "sample_output_relpath": "derived/input_output/data/p00436/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00436/Scala/s222641981.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s222641981", "user_id": "u508732591"}, "prompt_components": {"gold_output": "2\n4\n3\n1\n", "input_to_evaluate": "import scala.io.StdIn.{readLine,readInt}\n\nobject Main {\n def cut(c:Array[Int],n:Int,k:Int) = {\n c.slice(k,2*n) ++ c.slice(0,k)\n }\n\n def rif(c:Array[Int],n:Int) = {\n val a = c.slice(0,n)\n val b = c.slice(n,n+n)\n (0 until 2*n).map{ i=> if(i%2==0) a(i/2) else b((i-1)/2) }.toArray\n }\n\n def main(args:Array[String]) = {\n val n = readInt\n val m = readInt\n var a = (0 until 2*n).map { i => i+1 }.toArray\n for(i<-0 until m) {\n val k = readInt\n if(k==0) a = rif(a,n)\n else a = cut(a,n,k)\n }\n println(a.mkString(\"\\n\"))\n }\n\n}", "problem_context": "カードの並び替え\n\n問題\n\n1 から 2n の数が書かれた 2n 枚のカードがあり,上から 1, 2, 3, ... , 2n の順に積み重なっている.\n\nこのカードを,次の方法を何回か用いて並べ替える.\n\n整数 k でカット\n\n上から k 枚のカードの山 A と 残りのカードの山 B に分けた後, 山 A の上に山 B をのせる.\n\nリフルシャッフル\n\n上から n 枚の山 A と残りの山 B に分け, 上から A の1枚目, B の1枚目, A の2枚目, B の2枚目, …, A の n枚目, B の n枚目, となるようにして, 1 つの山にする.\n\n入力の指示に従い,カードを並び替えたあとのカードの番号を,上から順番に出力するプログラムを作成せよ.\n\n入力\n\n1 行目には n (1 ≦ n ≦ 100)が書かれている. すなわちカードの枚数は 2n 枚である.\n\n2 行目には操作の回数 m (1 ≦ m ≦ 1000)が書かれている.\n\n3 行目から m + 2 行目までの m 行には, 0 から 2n-1 までのいずれか 1 つの整数 k が書かれており, カードを並べ替える方法を順に指定している.\n\nk = 0 の場合は, リフルシャッフルを行う.\n\n1 ≦ k ≦ 2n-1 の場合は, k でカットを行う.\n\n出力\n\n出力は2n 行からなる. 1 行目には並べ替え終了後の一番上のカードの番号, 2 行目には並べ替え終了後の上から 2 番目のカードの番号というように, i 行目には上から i 番目のカードの番号を出力せよ.\n\n入出力例\n\n入力例 1\n\n2\n2\n1\n0\n\n出力例 1\n\n2\n4\n3\n1\n\n入力例 2\n\n3\n4\n2\n4\n0\n0\n\n出力例 2\n\n1\n5\n4\n3\n2\n6\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "2\n2\n1\n0\n"}, "reference_outputs": ["2\n4\n3\n1\n"], "source_document_id": "p00436", "source_text": "カードの並び替え\n\n問題\n\n1 から 2n の数が書かれた 2n 枚のカードがあり,上から 1, 2, 3, ... , 2n の順に積み重なっている.\n\nこのカードを,次の方法を何回か用いて並べ替える.\n\n整数 k でカット\n\n上から k 枚のカードの山 A と 残りのカードの山 B に分けた後, 山 A の上に山 B をのせる.\n\nリフルシャッフル\n\n上から n 枚の山 A と残りの山 B に分け, 上から A の1枚目, B の1枚目, A の2枚目, B の2枚目, …, A の n枚目, B の n枚目, となるようにして, 1 つの山にする.\n\n入力の指示に従い,カードを並び替えたあとのカードの番号を,上から順番に出力するプログラムを作成せよ.\n\n入力\n\n1 行目には n (1 ≦ n ≦ 100)が書かれている. すなわちカードの枚数は 2n 枚である.\n\n2 行目には操作の回数 m (1 ≦ m ≦ 1000)が書かれている.\n\n3 行目から m + 2 行目までの m 行には, 0 から 2n-1 までのいずれか 1 つの整数 k が書かれており, カードを並べ替える方法を順に指定している.\n\nk = 0 の場合は, リフルシャッフルを行う.\n\n1 ≦ k ≦ 2n-1 の場合は, k でカットを行う.\n\n出力\n\n出力は2n 行からなる. 1 行目には並べ替え終了後の一番上のカードの番号, 2 行目には並べ替え終了後の上から 2 番目のカードの番号というように, i 行目には上から i 番目のカードの番号を出力せよ.\n\n入出力例\n\n入力例 1\n\n2\n2\n1\n0\n\n出力例 1\n\n2\n4\n3\n1\n\n入力例 2\n\n3\n4\n2\n4\n0\n0\n\n出力例 2\n\n1\n5\n4\n3\n2\n6\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 566, "cpu_time_ms": 330, "memory_kb": 53156}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s819210780", "group_id": "codeNet:p00448", "input_text": "import java.util.Scanner\n\nobject Main {\n\n def check(input: Array[Array[Int]]): Int = {\n var ret = 0\n for (j <- 0 until input(0).length) {\n var N = 0\n for (i <- 0 until input.length) {\n N += input(i)(j)\n }\n ret += math.max(N, input.length - N)\n }\n ret\n }\n\n def check2(num: Int, input: Array[Array[Int]]): Int = {\n var ret = 0\n for (j <- 0 until input(0).length) {\n var N = 0\n for (i <- 0 until input.length) {\n if ((num >> i) % 2 == 1) {\n N += 1 - input(i)(j)\n } else {\n N += input(i)(j)\n }\n }\n ret += math.max(N, input.length - N)\n }\n ret\n }\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 // */\n /*\ndef rev(num: Int, input: Array[Array[Int]]): Array[Array[Int]] = {\n for (i <- 0 until input.length) {\n if ((num >> i) % 2 == 1) (\n Array.copy(Array.tabulate(input(i).length)(j => 1 - input(i)(j)), 0, input(i), 0, input(i).length)\n )\n }\n input\n}\n\n// */\n\n def make(input: Array[Array[Int]]): Int = {\n var max: Int = 0\n for (i <- 0 to (1 << (input.length - 2))) {\n max = math.max(max, check2(i, input.clone))\n }\n max\n }\n\n def solve(sc: Scanner): Boolean = {\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 true\n } else {\n false\n }\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n while (solve(sc)) ()\n }\n}", "language": "Scala", "metadata": {"date": 1500732195, "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/s819210780.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s819210780", "user_id": "u018134297"}, "prompt_components": {"gold_output": "9\n15\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n\n def check(input: Array[Array[Int]]): Int = {\n var ret = 0\n for (j <- 0 until input(0).length) {\n var N = 0\n for (i <- 0 until input.length) {\n N += input(i)(j)\n }\n ret += math.max(N, input.length - N)\n }\n ret\n }\n\n def check2(num: Int, input: Array[Array[Int]]): Int = {\n var ret = 0\n for (j <- 0 until input(0).length) {\n var N = 0\n for (i <- 0 until input.length) {\n if ((num >> i) % 2 == 1) {\n N += 1 - input(i)(j)\n } else {\n N += input(i)(j)\n }\n }\n ret += math.max(N, input.length - N)\n }\n ret\n }\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 // */\n /*\ndef rev(num: Int, input: Array[Array[Int]]): Array[Array[Int]] = {\n for (i <- 0 until input.length) {\n if ((num >> i) % 2 == 1) (\n Array.copy(Array.tabulate(input(i).length)(j => 1 - input(i)(j)), 0, input(i), 0, input(i).length)\n )\n }\n input\n}\n\n// */\n\n def make(input: Array[Array[Int]]): Int = {\n var max: Int = 0\n for (i <- 0 to (1 << (input.length - 2))) {\n max = math.max(max, check2(i, input.clone))\n }\n max\n }\n\n def solve(sc: Scanner): Boolean = {\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 true\n } else {\n false\n }\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n while (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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 700, "memory_kb": 166480}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s278374712", "group_id": "codeNet:p00457", "input_text": "import scala.annotation.tailrec\n\nobject Main extends App {\n\n import scala.io.StdIn._\n f\n\n def f: Unit = {\n val n = readLine.trim.toInt\n if (n == 0) return\n val num = toCh(List.tabulate(n){ _ ⇒ readLine.trim.toInt})\n println(n - search(num))\n f\n }\n def search(list: List[Ch]): Int = {\n def sub(prev: List[Ch], current: Ch, post: List[Ch], max: Int = 0): Int = {\n prev match {\n case c::t ⇒ sub(t, c, current::post, List(max, changeFirst(prev, current, post), changeLast(prev, current, post)).max)\n case _ ⇒ List(max, changeFirst(prev, current, post), changeLast(prev, current, post)).max\n }\n }\n list match {\n case Nil ⇒ 0\n case h::t ⇒ sub(t, h, Nil)\n }\n }\n def changeFirst(prev: List[Ch], current: Ch, post: List[Ch]): Int = {\n (prev, current, post) match {\n case (Ch(a, n)::t, Ch(_, 1), Ch(b, m)::u) if a == b && n + m >= 3 ⇒ n + m + 1 + remove(t, u)\n case (Ch(_, n)::t, Ch(a, m), _) if n >= 3 ⇒ if (m == 1) n + 1 + remove(t, post) else n + 1 + remove(t, Ch(a, m - 1)::post)\n case _ ⇒ 0\n }\n }\n def changeLast(prev: List[Ch], current: Ch, post: List[Ch]): Int = {\n (prev, current, post) match {\n case (Ch(a, n)::t, Ch(_, 1), Ch(b, m)::u) if a == b && n + m >= 3 ⇒ n + m + 1 + remove(t, u)\n case (_, Ch(a, n), Ch(_, m)::t) if m >= 3 ⇒ if (n == 1) m + 1 + remove(prev, t) else m + 1 + remove(Ch(a, n - 1)::prev, t)\n case _ ⇒ 0\n }\n }\n def remove(prev: List[Ch], post: List[Ch]): Int = {\n (prev, post) match {\n case (Ch(a, n)::t, Ch(b, m)::u) if a == b && n + m >= 4 ⇒ n + m + remove(t, u)\n case _ ⇒ 0\n }\n }\n @tailrec\n def toCh(list:List[Int], res: List[Ch] = Nil): List[Ch] = {\n list match {\n case Nil ⇒ res\n case h::t ⇒ res match {\n case Nil ⇒ toCh(t, Ch(h, 1)::res)\n case Ch(c, n)::rt if c == h ⇒ toCh(t, Ch(c, n + 1)::rt)\n case _ ⇒ toCh(t, Ch(h, 1)::res)\n }\n }\n }\n case class Ch(color: Int, num: Int)\n}\n\n", "language": "Scala", "metadata": {"date": 1541433183, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00457.html", "problem_id": "p00457", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00457/input.txt", "sample_output_relpath": "derived/input_output/data/p00457/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00457/Scala/s278374712.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s278374712", "user_id": "u514597327"}, "prompt_components": {"gold_output": "3\n12\n", "input_to_evaluate": "import scala.annotation.tailrec\n\nobject Main extends App {\n\n import scala.io.StdIn._\n f\n\n def f: Unit = {\n val n = readLine.trim.toInt\n if (n == 0) return\n val num = toCh(List.tabulate(n){ _ ⇒ readLine.trim.toInt})\n println(n - search(num))\n f\n }\n def search(list: List[Ch]): Int = {\n def sub(prev: List[Ch], current: Ch, post: List[Ch], max: Int = 0): Int = {\n prev match {\n case c::t ⇒ sub(t, c, current::post, List(max, changeFirst(prev, current, post), changeLast(prev, current, post)).max)\n case _ ⇒ List(max, changeFirst(prev, current, post), changeLast(prev, current, post)).max\n }\n }\n list match {\n case Nil ⇒ 0\n case h::t ⇒ sub(t, h, Nil)\n }\n }\n def changeFirst(prev: List[Ch], current: Ch, post: List[Ch]): Int = {\n (prev, current, post) match {\n case (Ch(a, n)::t, Ch(_, 1), Ch(b, m)::u) if a == b && n + m >= 3 ⇒ n + m + 1 + remove(t, u)\n case (Ch(_, n)::t, Ch(a, m), _) if n >= 3 ⇒ if (m == 1) n + 1 + remove(t, post) else n + 1 + remove(t, Ch(a, m - 1)::post)\n case _ ⇒ 0\n }\n }\n def changeLast(prev: List[Ch], current: Ch, post: List[Ch]): Int = {\n (prev, current, post) match {\n case (Ch(a, n)::t, Ch(_, 1), Ch(b, m)::u) if a == b && n + m >= 3 ⇒ n + m + 1 + remove(t, u)\n case (_, Ch(a, n), Ch(_, m)::t) if m >= 3 ⇒ if (n == 1) m + 1 + remove(prev, t) else m + 1 + remove(Ch(a, n - 1)::prev, t)\n case _ ⇒ 0\n }\n }\n def remove(prev: List[Ch], post: List[Ch]): Int = {\n (prev, post) match {\n case (Ch(a, n)::t, Ch(b, m)::u) if a == b && n + m >= 4 ⇒ n + m + remove(t, u)\n case _ ⇒ 0\n }\n }\n @tailrec\n def toCh(list:List[Int], res: List[Ch] = Nil): List[Ch] = {\n list match {\n case Nil ⇒ res\n case h::t ⇒ res match {\n case Nil ⇒ toCh(t, Ch(h, 1)::res)\n case Ch(c, n)::rt if c == h ⇒ toCh(t, Ch(c, n + 1)::rt)\n case _ ⇒ toCh(t, Ch(h, 1)::res)\n }\n }\n }\n case class Ch(color: Int, num: Int)\n}\n\n", "problem_context": "連鎖\n\n問題\n\n次のようなゲームがある.\n\nあるキャラクターが縦 1 列に N 個並んでいる.これらのキャラクターの色は赤,青,黄のいずれかであり,初期状態で同じ色のキャラクターが4つ以上連続して並んでいることはない.プレーヤーは,ある位置のキャラクターを選び他の色に変更することができる.この操作により同じ色のキャラクターが4つ以上連続して並ぶとそれらのキャラクターは消滅する.キャラクターが消滅することにより新たに同じ色のキャラクターが4つ以上連続して並ぶとそれらのキャラクターも消滅し,同じ色のキャラクターが4つ以上連続して並んでいる箇所がなくなるまでこの連鎖は続く.このゲームの目的は,消滅しないで残っているキャラクター数をなるべく少なくすることである.\n\n例えば,下図の左端の状態で,上から6番目のキャラクターの色を黄色から青に変更すると,青のキャラクターが5つ連続するので消滅し,最終的に3つのキャラクターが消滅せずに残る.\n\n初期状態における N 個のキャラクターの色の並びが与えられたとき, 1箇所だけキャラクターの色を変更した場合の,消滅しないで残っているキャラクター数の最小値 M を求めるプログラムを作成せよ.\n\n入力\n\n入力は複数のデータセットからなる.各データセットは以下の形式で与えられる.\n\n1行目はキャラクター数 N (1 ≤ N ≤ 10000) だけからなる.続く N 行には 1, 2, 3 のいずれか1つの整数が書かれており, i + 1 行目 (1 ≤ i ≤ N) は初期状態における上から i 番目のキャラクターの色を表す(1 は赤を,2 は青を,3は黄を表す).\n\nN が 0 のとき入力の終了を示す.データセットの数は 5 を超えない.\n\n出力\n\nデータセットごとに, 消滅しないで残っているキャラクター数の最小値 M を1行に出力せよ.\n\n入出力例\n\n入力例\n\n12\n3\n2\n1\n1\n2\n3\n2\n2\n2\n1\n1\n3\n12\n3\n2\n1\n1\n2\n3\n2\n1\n3\n2\n1\n3\n0\n\n出力例\n\n3\n12\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "12\n3\n2\n1\n1\n2\n3\n2\n2\n2\n1\n1\n3\n12\n3\n2\n1\n1\n2\n3\n2\n1\n3\n2\n1\n3\n0\n"}, "reference_outputs": ["3\n12\n"], "source_document_id": "p00457", "source_text": "連鎖\n\n問題\n\n次のようなゲームがある.\n\nあるキャラクターが縦 1 列に N 個並んでいる.これらのキャラクターの色は赤,青,黄のいずれかであり,初期状態で同じ色のキャラクターが4つ以上連続して並んでいることはない.プレーヤーは,ある位置のキャラクターを選び他の色に変更することができる.この操作により同じ色のキャラクターが4つ以上連続して並ぶとそれらのキャラクターは消滅する.キャラクターが消滅することにより新たに同じ色のキャラクターが4つ以上連続して並ぶとそれらのキャラクターも消滅し,同じ色のキャラクターが4つ以上連続して並んでいる箇所がなくなるまでこの連鎖は続く.このゲームの目的は,消滅しないで残っているキャラクター数をなるべく少なくすることである.\n\n例えば,下図の左端の状態で,上から6番目のキャラクターの色を黄色から青に変更すると,青のキャラクターが5つ連続するので消滅し,最終的に3つのキャラクターが消滅せずに残る.\n\n初期状態における N 個のキャラクターの色の並びが与えられたとき, 1箇所だけキャラクターの色を変更した場合の,消滅しないで残っているキャラクター数の最小値 M を求めるプログラムを作成せよ.\n\n入力\n\n入力は複数のデータセットからなる.各データセットは以下の形式で与えられる.\n\n1行目はキャラクター数 N (1 ≤ N ≤ 10000) だけからなる.続く N 行には 1, 2, 3 のいずれか1つの整数が書かれており, i + 1 行目 (1 ≤ i ≤ N) は初期状態における上から i 番目のキャラクターの色を表す(1 は赤を,2 は青を,3は黄を表す).\n\nN が 0 のとき入力の終了を示す.データセットの数は 5 を超えない.\n\n出力\n\nデータセットごとに, 消滅しないで残っているキャラクター数の最小値 M を1行に出力せよ.\n\n入出力例\n\n入力例\n\n12\n3\n2\n1\n1\n2\n3\n2\n2\n2\n1\n1\n3\n12\n3\n2\n1\n1\n2\n3\n2\n1\n3\n2\n1\n3\n0\n\n出力例\n\n3\n12\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2015, "cpu_time_ms": 310, "memory_kb": 51724}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s731265650", "group_id": "codeNet:p00478", "input_text": "import scala.io.StdIn.{readInt,readLine}\n\nobject Main {\n def main(args:Array[String]) = {\n val s = readLine\n println {\n (1 to readInt).count{ _ => (readLine*2).contains(s) }\n }\n }\n}", "language": "Scala", "metadata": {"date": 1487774869, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00478.html", "problem_id": "p00478", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00478/input.txt", "sample_output_relpath": "derived/input_output/data/p00478/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00478/Scala/s731265650.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s731265650", "user_id": "u508732591"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.io.StdIn.{readInt,readLine}\n\nobject Main {\n def main(args:Array[String]) = {\n val s = readLine\n println {\n (1 to readInt).count{ _ => (readLine*2).contains(s) }\n }\n }\n}", "problem_context": "指輪 (Ring)\n\n問題\n\nあなたは N 個の指輪を持っている.どの指輪にも,アルファベットの大文字 10 文字からなる文字列が刻印されている.指輪には文字列の最初と最後がつながった形で文字が刻印されている.指輪に刻印された文字列を逆順に読む心配はない.\n\n探したい文字列が与えられたとき,その文字列を含む指輪が何個あるかを求めるプログラムを作成せよ.\n\n入力\n\n入力は 2+N 行からなる.\n\n1 行目には,1 文字以上 10 文字以下のアルファベットの大文字からなる探したい文字列が書かれている.\n\n2 行目には,指輪の個数 N ( 1 ≦ N ≦ 100 )が書かれている.\n\n2+i 行目(1 ≤ i ≤ N )には, i 個目の指輪に刻印されている 10 文字からなる文字列が書かれている.\n\n出力\n\n探したい文字列を含む指輪の個数を表す整数を 1 行で出力せよ.\n\n入出力例\n\n入力例 1\n\nABCD\n3\nABCDXXXXXX\nYYYYABCDXX\nDCBAZZZZZZ\n\n出力例 1\n\n2\n\n入力例 2\n\nXYZ\n1\nZAAAAAAAXY\n\n出力例 2\n\n1\n\n入力例 2 の指輪には「XYZ」という文字列が 1 つ含まれている.これは、指輪の文字列の最初と最後がつながっているためである.\n\n入力例 3\n\nPQR\n3\nPQRAAAAPQR\nBBPQRBBBBB\nCCCCCCCCCC\n\n出力例 3\n\n2\n\n入力例 3 の 1 個目の指輪には「PQR」という文字列が 2 つ含まれており, 2 個目の指輪には「PQR」という文字列が 1 個含まれており, 3 個目の指輪には「PQR」という文字列が含まれていない.そのため「PQR」という文字列が含まれている指輪の数は 2 個となる.\n\n問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "ABCD\n3\nABCDXXXXXX\nYYYYABCDXX\nDCBAZZZZZZ\n"}, "reference_outputs": ["2\n"], "source_document_id": "p00478", "source_text": "指輪 (Ring)\n\n問題\n\nあなたは N 個の指輪を持っている.どの指輪にも,アルファベットの大文字 10 文字からなる文字列が刻印されている.指輪には文字列の最初と最後がつながった形で文字が刻印されている.指輪に刻印された文字列を逆順に読む心配はない.\n\n探したい文字列が与えられたとき,その文字列を含む指輪が何個あるかを求めるプログラムを作成せよ.\n\n入力\n\n入力は 2+N 行からなる.\n\n1 行目には,1 文字以上 10 文字以下のアルファベットの大文字からなる探したい文字列が書かれている.\n\n2 行目には,指輪の個数 N ( 1 ≦ N ≦ 100 )が書かれている.\n\n2+i 行目(1 ≤ i ≤ N )には, i 個目の指輪に刻印されている 10 文字からなる文字列が書かれている.\n\n出力\n\n探したい文字列を含む指輪の個数を表す整数を 1 行で出力せよ.\n\n入出力例\n\n入力例 1\n\nABCD\n3\nABCDXXXXXX\nYYYYABCDXX\nDCBAZZZZZZ\n\n出力例 1\n\n2\n\n入力例 2\n\nXYZ\n1\nZAAAAAAAXY\n\n出力例 2\n\n1\n\n入力例 2 の指輪には「XYZ」という文字列が 1 つ含まれている.これは、指輪の文字列の最初と最後がつながっているためである.\n\n入力例 3\n\nPQR\n3\nPQRAAAAPQR\nBBPQRBBBBB\nCCCCCCCCCC\n\n出力例 3\n\n2\n\n入力例 3 の 1 個目の指輪には「PQR」という文字列が 2 つ含まれており, 2 個目の指輪には「PQR」という文字列が 1 個含まれており, 3 個目の指輪には「PQR」という文字列が含まれていない.そのため「PQR」という文字列が含まれている指輪の数は 2 個となる.\n\n問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 197, "cpu_time_ms": 230, "memory_kb": 43864}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s878971005", "group_id": "codeNet:p00489", "input_text": "\nobject Main extends App {\n\n import scala.io.StdIn._\n val n = readLine.trim.toInt\n val points = Array.tabulate(n){_ ⇒ 0}\n for (_ ← 0 until (n * (n - 1) / 2)) {\n val Array(a, b, c, d) = readLine.trim.split(' ').map(_.toInt)\n if (c > d){\n points(a - 1) += 3\n }else if (c < d){\n points(b - 1) += 3\n }else {\n points(a - 1) += 1\n points(b - 1) += 1\n }\n }\n val scores = Array.tabulate(n * 3 + 1){_ ⇒ 0}\n points.foreach(scores(_) += 1)\n for (i ← (1 to 3 * n).reverse){\n scores(i - 1) += scores(i)\n }\n points.foreach{score ⇒\n println(scores(score + 1) + 1)\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1536453271, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00489.html", "problem_id": "p00489", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00489/input.txt", "sample_output_relpath": "derived/input_output/data/p00489/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00489/Scala/s878971005.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s878971005", "user_id": "u514597327"}, "prompt_components": {"gold_output": "2\n1\n4\n2\n", "input_to_evaluate": "\nobject Main extends App {\n\n import scala.io.StdIn._\n val n = readLine.trim.toInt\n val points = Array.tabulate(n){_ ⇒ 0}\n for (_ ← 0 until (n * (n - 1) / 2)) {\n val Array(a, b, c, d) = readLine.trim.split(' ').map(_.toInt)\n if (c > d){\n points(a - 1) += 3\n }else if (c < d){\n points(b - 1) += 3\n }else {\n points(a - 1) += 1\n points(b - 1) += 1\n }\n }\n val scores = Array.tabulate(n * 3 + 1){_ ⇒ 0}\n points.foreach(scores(_) += 1)\n for (i ← (1 to 3 * n).reverse){\n scores(i - 1) += scores(i)\n }\n points.foreach{score ⇒\n println(scores(score + 1) + 1)\n }\n}\n\n", "problem_context": "サッカー (Soccer)\n\n問題\n\nJOI 国ではサッカーが人気であり,JOI リーグというリーグ戦が毎週行われている.\n\nJOI リーグには N 個のチームが所属していて,1 から N までの番号がつけられている.すべての組み合わせの試合がちょうど一度ずつ行われる.つまり, N × (N - 1) / 2 試合が行われる.各試合の勝敗はそれぞれのチームの得点で決まる.勝ったチームの勝ち点は 3 点であり,負けたチームの勝ち点は 0 点である.引き分けの場合,両チームの勝ち点は 1 点である.順位は各チームの獲得した勝ち点の合計で決定し,得失点差は考えない.勝ち点の合計が等しいチームの順位は上位に揃える.\n\n例として, 4 チームでのリーグ戦を考える.4 × (4 - 1) / 2 = 6 試合が行われる.それらの結果が以下の表のようになったとする.ハイフンの左側はその横のチームの得点であり,右側はその縦のチームの得点である.\n\n  チーム 1  \n\n  チーム 2  \n\n  チーム 3  \n\n  チーム 4  \n\n  勝ち数  \n\n  負け数  \n\n  引き分け数  \n\n  勝ち点  \n\n  チーム 1  \n\n---\n\n0 - 1\n\n2 - 1\n\n2 - 2\n\n1\n\n1\n\n1\n\n4\n\n  チーム 2  \n\n1 - 0\n\n---\n\n1 - 1\n\n3 - 0\n\n2\n\n0\n\n1\n\n7\n\n  チーム 3  \n\n1 - 2\n\n1 - 1\n\n---\n\n1 - 3\n\n0\n\n2\n\n1\n\n1\n\n  チーム 4  \n\n2 - 2\n\n0 - 3\n\n3 - 1\n\n---\n\n1\n\n1\n\n1\n\n4\n\nこのとき,勝ち点の最も多いチーム 2 が 1 位である.\n\nその次に勝ち点が多いチームはチーム 1 とチーム 4 であり,これらのチームの順位は共に 2 位である.\n\nそして勝ち点が最も少ないチーム 3 が 4 位である.\n\n全ての試合の結果が与えられたとき,各チームの順位を求めるプログラムを作成せよ.\n\n入力\n\n入力ファイルの 1 行目にはチームの個数 N (2 ≦ N ≦ 100) が書かれている.続く N × (N - 1) / 2 行には各試合の結果が書かれている.i + 1 行目 (1 ≦ i ≦ N × (N - 1) / 2) には整数 Ai,Bi,Ci,Di (1 ≦ Ai ≦ N,1 ≦ Bi ≦ N,0 ≦ Ci ≦ 100,0 ≦ Di ≦ 100) が空白を区切りとして書かれており,チーム Ai とチーム Bi が対戦し,チーム Ai の得点が Ci 点,チーム Bi の得点が Di 点であったことを表す.全ての i について Ai ≠ Bi であり,同じ組み合わせの対戦が書かれていることはない.\n\n出力\n\n出力は N 行からなる.各行は 1 つの整数からなり, i 行目 (1 ≦ i ≦ N) の整数はチーム i の順位を表す.\n\n入出力例\n\n入力例 1\n\n4\n1 2 0 1\n1 3 2 1\n1 4 2 2\n2 3 1 1\n2 4 3 0\n3 4 1 3\n\n出力例 1\n\n2\n1\n4\n2\n\n入出力例 1 は問題文中の例に対応している.\n\n入力例 2\n\n5\n1 2 1 1\n3 4 3 1\n5 1 1 2\n2 3 0 0\n4 5 2 3\n1 3 0 2\n5 2 2 2\n4 1 4 5\n3 5 4 0\n2 4 0 1\n\n出力例 2\n\n2\n4\n1\n4\n3\n\n入出力例 2 における結果は以下の通りである.\n\n  勝ち数  \n\n  負け数  \n\n  引き分け数  \n\n  勝ち点  \n\n  チーム 1  \n\n2\n\n1\n\n1\n\n7\n\n  チーム 2  \n\n0\n\n1\n\n3\n\n3\n\n  チーム 3  \n\n3\n\n0\n\n1\n\n10\n\n  チーム 4  \n\n1\n\n3\n\n0\n\n3\n\n  チーム 5  \n\n1\n\n2\n\n1\n\n4\n\n問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "4\n1 2 0 1\n1 3 2 1\n1 4 2 2\n2 3 1 1\n2 4 3 0\n3 4 1 3\n"}, "reference_outputs": ["2\n1\n4\n2\n"], "source_document_id": "p00489", "source_text": "サッカー (Soccer)\n\n問題\n\nJOI 国ではサッカーが人気であり,JOI リーグというリーグ戦が毎週行われている.\n\nJOI リーグには N 個のチームが所属していて,1 から N までの番号がつけられている.すべての組み合わせの試合がちょうど一度ずつ行われる.つまり, N × (N - 1) / 2 試合が行われる.各試合の勝敗はそれぞれのチームの得点で決まる.勝ったチームの勝ち点は 3 点であり,負けたチームの勝ち点は 0 点である.引き分けの場合,両チームの勝ち点は 1 点である.順位は各チームの獲得した勝ち点の合計で決定し,得失点差は考えない.勝ち点の合計が等しいチームの順位は上位に揃える.\n\n例として, 4 チームでのリーグ戦を考える.4 × (4 - 1) / 2 = 6 試合が行われる.それらの結果が以下の表のようになったとする.ハイフンの左側はその横のチームの得点であり,右側はその縦のチームの得点である.\n\n  チーム 1  \n\n  チーム 2  \n\n  チーム 3  \n\n  チーム 4  \n\n  勝ち数  \n\n  負け数  \n\n  引き分け数  \n\n  勝ち点  \n\n  チーム 1  \n\n---\n\n0 - 1\n\n2 - 1\n\n2 - 2\n\n1\n\n1\n\n1\n\n4\n\n  チーム 2  \n\n1 - 0\n\n---\n\n1 - 1\n\n3 - 0\n\n2\n\n0\n\n1\n\n7\n\n  チーム 3  \n\n1 - 2\n\n1 - 1\n\n---\n\n1 - 3\n\n0\n\n2\n\n1\n\n1\n\n  チーム 4  \n\n2 - 2\n\n0 - 3\n\n3 - 1\n\n---\n\n1\n\n1\n\n1\n\n4\n\nこのとき,勝ち点の最も多いチーム 2 が 1 位である.\n\nその次に勝ち点が多いチームはチーム 1 とチーム 4 であり,これらのチームの順位は共に 2 位である.\n\nそして勝ち点が最も少ないチーム 3 が 4 位である.\n\n全ての試合の結果が与えられたとき,各チームの順位を求めるプログラムを作成せよ.\n\n入力\n\n入力ファイルの 1 行目にはチームの個数 N (2 ≦ N ≦ 100) が書かれている.続く N × (N - 1) / 2 行には各試合の結果が書かれている.i + 1 行目 (1 ≦ i ≦ N × (N - 1) / 2) には整数 Ai,Bi,Ci,Di (1 ≦ Ai ≦ N,1 ≦ Bi ≦ N,0 ≦ Ci ≦ 100,0 ≦ Di ≦ 100) が空白を区切りとして書かれており,チーム Ai とチーム Bi が対戦し,チーム Ai の得点が Ci 点,チーム Bi の得点が Di 点であったことを表す.全ての i について Ai ≠ Bi であり,同じ組み合わせの対戦が書かれていることはない.\n\n出力\n\n出力は N 行からなる.各行は 1 つの整数からなり, i 行目 (1 ≦ i ≦ N) の整数はチーム i の順位を表す.\n\n入出力例\n\n入力例 1\n\n4\n1 2 0 1\n1 3 2 1\n1 4 2 2\n2 3 1 1\n2 4 3 0\n3 4 1 3\n\n出力例 1\n\n2\n1\n4\n2\n\n入出力例 1 は問題文中の例に対応している.\n\n入力例 2\n\n5\n1 2 1 1\n3 4 3 1\n5 1 1 2\n2 3 0 0\n4 5 2 3\n1 3 0 2\n5 2 2 2\n4 1 4 5\n3 5 4 0\n2 4 0 1\n\n出力例 2\n\n2\n4\n1\n4\n3\n\n入出力例 2 における結果は以下の通りである.\n\n  勝ち数  \n\n  負け数  \n\n  引き分け数  \n\n  勝ち点  \n\n  チーム 1  \n\n2\n\n1\n\n1\n\n7\n\n  チーム 2  \n\n0\n\n1\n\n3\n\n3\n\n  チーム 3  \n\n3\n\n0\n\n1\n\n10\n\n  チーム 4  \n\n1\n\n3\n\n0\n\n3\n\n  チーム 5  \n\n1\n\n2\n\n1\n\n4\n\n問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 617, "cpu_time_ms": 340, "memory_kb": 51888}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s278172194", "group_id": "codeNet:p00494", "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 s = sc.next\n var ans = 0\n for (i <- Range(1, 101)) {\n if (s.contains(\"J\" * i + \"O\" * i + \"I\" * i)) (ans = i)\n }\n println(ans)\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": 1517656836, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00494.html", "problem_id": "p00494", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00494/input.txt", "sample_output_relpath": "derived/input_output/data/p00494/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00494/Scala/s278172194.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s278172194", "user_id": "u018134297"}, "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.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 s = sc.next\n var ans = 0\n for (i <- Range(1, 101)) {\n if (s.contains(\"J\" * i + \"O\" * i + \"I\" * i)) (ans = i)\n }\n println(ans)\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": "JJOOII (JJOOII)\n\nJOI (日本情報オリンピック) の本選に向けてプログラミングの練習をしていたあなたは,今年度のJOI の予選の問題には数値を扱う問題ばかりが出題され,文字列を扱う問題がなかったことに気がついた.そこであなたは,こっそり文字列の問題に強くなってライバルたちに差をつけることにした.\n\nJOI の過去問を眺めていると,J, O, I の3 種類の文字からなる文字列に慣れておく必要がありそうなことがわかった.そこで,そのような文字列について考えよう.あなたは「与えられた文字列がJOI という部分文字列をもつかどうかを答えよ」という問題を思いついたものの,これはすぐに解けてしまった.もっとレベルの高い問題を解きたいあなたは,以下のような問題を作った.\n\n文字列t が文字列s の部分文字列であるとは,t の先頭および末尾に何文字か(0 文字でもよい) を付け足すとs になることである.たとえば,JJOOII はOJJOOIIOJOI の部分文字列である.一方,JOI はJOOI の部分文字列ではない.\n\nまた,0 以上の整数k に対し,レベルk のJOI 列とは,k 個の文字J,k 個の文字O,k 個の文字I をこの順に並べた文字列のことであるとする.たとえば,JJOOII はレベル2 のJOI 列である.与えられた文字列の部分文字列であるJOI 列のうち,レベルが最大のものを求めたい.\n\n課題\n\nJ, O, I の3 種類の文字からなる長さN の文字列S が与えられたとき,レベルk のJOI 列がS の部分文字列であるような最大のk の値を求めるプログラムを作成せよ.\n\n制限\n\n1 ≤ N ≤ 1000000 (= 106)   S の長さ\n\n入力\n\n標準入力から以下のデータを読み込め.\n\n1 行目にはJ, O, I の3 種類の文字からなる文字列S が書かれている.\n\n出力\n\n標準出力に,レベルk のJOI 列がS の部分文字列であるような最大のk の値を表す整数を1 行で出力せよ.\n\n採点基準\n\n採点用データのうち,配点の20%分については,N ≤ 100 を満たす.\n\n入出力例\n\n入力例 1\n\nOJJOOIIOJOI\n\n出力例 1\n\n2\n\nOJJOOIIOJOI はレベル2 のJOI 列であるJJOOII を部分文字列として含んでおり,レベル3 以上のJOI列は部分文字列として含まない.\n\n入力例 2\n\nIJJIIJJJ\n\n出力例 2\n\n0\n\n入力例 3\n\nJOIJOIJOIJOIJOI\n\n出力例 3\n\n1\n\n入力例 4\n\nOOJJJJJJJOOOOIIIII\n\n出力例 4\n\n4\n\n問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "OJJOOIIOJOI\n"}, "reference_outputs": ["2\n"], "source_document_id": "p00494", "source_text": "JJOOII (JJOOII)\n\nJOI (日本情報オリンピック) の本選に向けてプログラミングの練習をしていたあなたは,今年度のJOI の予選の問題には数値を扱う問題ばかりが出題され,文字列を扱う問題がなかったことに気がついた.そこであなたは,こっそり文字列の問題に強くなってライバルたちに差をつけることにした.\n\nJOI の過去問を眺めていると,J, O, I の3 種類の文字からなる文字列に慣れておく必要がありそうなことがわかった.そこで,そのような文字列について考えよう.あなたは「与えられた文字列がJOI という部分文字列をもつかどうかを答えよ」という問題を思いついたものの,これはすぐに解けてしまった.もっとレベルの高い問題を解きたいあなたは,以下のような問題を作った.\n\n文字列t が文字列s の部分文字列であるとは,t の先頭および末尾に何文字か(0 文字でもよい) を付け足すとs になることである.たとえば,JJOOII はOJJOOIIOJOI の部分文字列である.一方,JOI はJOOI の部分文字列ではない.\n\nまた,0 以上の整数k に対し,レベルk のJOI 列とは,k 個の文字J,k 個の文字O,k 個の文字I をこの順に並べた文字列のことであるとする.たとえば,JJOOII はレベル2 のJOI 列である.与えられた文字列の部分文字列であるJOI 列のうち,レベルが最大のものを求めたい.\n\n課題\n\nJ, O, I の3 種類の文字からなる長さN の文字列S が与えられたとき,レベルk のJOI 列がS の部分文字列であるような最大のk の値を求めるプログラムを作成せよ.\n\n制限\n\n1 ≤ N ≤ 1000000 (= 106)   S の長さ\n\n入力\n\n標準入力から以下のデータを読み込め.\n\n1 行目にはJ, O, I の3 種類の文字からなる文字列S が書かれている.\n\n出力\n\n標準出力に,レベルk のJOI 列がS の部分文字列であるような最大のk の値を表す整数を1 行で出力せよ.\n\n採点基準\n\n採点用データのうち,配点の20%分については,N ≤ 100 を満たす.\n\n入出力例\n\n入力例 1\n\nOJJOOIIOJOI\n\n出力例 1\n\n2\n\nOJJOOIIOJOI はレベル2 のJOI 列であるJJOOII を部分文字列として含んでおり,レベル3 以上のJOI列は部分文字列として含まない.\n\n入力例 2\n\nIJJIIJJJ\n\n出力例 2\n\n0\n\n入力例 3\n\nJOIJOIJOIJOIJOI\n\n出力例 3\n\n1\n\n入力例 4\n\nOOJJJJJJJOOOOIIIII\n\n出力例 4\n\n4\n\n問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1263, "cpu_time_ms": 300, "memory_kb": 46548}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s465057409", "group_id": "codeNet:p00501", "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) = {\n val N = sc.nextInt\n val S = sc.next\n var count = 0\n for (_ <- Range(0, N)) {\n val s = sc.next\n var flag = true\n for (i <- Range(0, math.max(0, s.length - S.length) + 1)) {\n if (flag) {\n for (j <- Range(1, 200)) {\n if (i + j * (S.length - 1) < s.length) {\n //println(i, j)\n var f = true\n\n for (k <- Range(0, S.length)) {\n if (s(i + j * k) != S(k)) (f = false)\n }\n\n if (f) {\n count += 1\n flag = false\n }\n }\n }\n }\n }\n }\n println(count)\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": 1516982579, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00501.html", "problem_id": "p00501", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00501/input.txt", "sample_output_relpath": "derived/input_output/data/p00501/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00501/Scala/s465057409.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s465057409", "user_id": "u018134297"}, "prompt_components": {"gold_output": "3\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) = {\n val N = sc.nextInt\n val S = sc.next\n var count = 0\n for (_ <- Range(0, N)) {\n val s = sc.next\n var flag = true\n for (i <- Range(0, math.max(0, s.length - S.length) + 1)) {\n if (flag) {\n for (j <- Range(1, 200)) {\n if (i + j * (S.length - 1) < s.length) {\n //println(i, j)\n var f = true\n\n for (k <- Range(0, S.length)) {\n if (s(i + j * k) != S(k)) (f = false)\n }\n\n if (f) {\n count += 1\n flag = false\n }\n }\n }\n }\n }\n }\n println(count)\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": "看板 (Signboard)\n\n問題\n\nJOI 君はお店の看板を作ることにした.\n\n文字が等間隔に書かれた古い看板が N 枚ある.JOI 君は古い看板からいくつかの文字を消すことで看板を作る.残った文字列がお店の名前になっていて,しかも残った文字が等間隔に並んでいるようにしたい.看板は 1 枚の古い看板から作らなければならず,古い看板を切ったりつなげたりしてはならない.\n\nお店の名前と N 枚の古い看板の情報が与えられた時,JOI 君が作ることができる看板の枚数を求めるプログラムを作成せよ.ただし, 1 枚の古い看板から作ることができる看板が複数考えられる場合も,作ることができる看板は 1 枚であると考える.\n\n入力\n\n入力は 2 + N 行からなる.\n\n1 行目には,整数 N (1 ≦ N ≦ 100) が書かれており,古い看板の枚数を表す.\n\n2 行目には,3 文字以上 25 文字以下のアルファベット小文字からなる文字列が書かれており,お店の名前を表す.\n\n続く N 行のうちの i 行目 (1 ≦ i ≦ N) には 1 文字以上 100 文字以下のアルファベット小文字からなる文字列が書かれており,i 枚目の古い看板に書かれている文字列を表す.\n\n出力\n\nJOI 君が作ることができる看板の枚数を表す整数を 1 行で出力せよ.\n\n入出力例\n\n入力例\n\n4\nbar\nabracadabra\nbear\nbar\nbaraxbara\n\n出力例\n\n3\n\nお店の名前は bar である.\n\n1 枚目の古い看板には文字列 abracadabra が書かれている.\nこの古い看板から 2 文字目,6 文字目,10 文字目以外を消すことで看板を作ることができる.\n\n2 枚目は,2 文字目を消すと bar という文字列を作ることができるが,これは残った文字が等間隔に並んでいない.\n\n3 枚目は,文字を何も消さなくても看板になっている.\n\n4 枚目の古い看板から看板を作る方法は 2 通りある.\n1 つの方法は,1 文字目,2 文字目,3 文字目以外を消すことである.\nもう 1 つの方法は,6 文字目,7 文字目,8 文字目以外を消すことである.\n\nよって,JOI 君は 1 枚目,3 枚目,4 枚目の古い看板から看板を作ることができるので,3 を出力する.\n\n問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "4\nbar\nabracadabra\nbear\nbar\nbaraxbara\n"}, "reference_outputs": ["3\n"], "source_document_id": "p00501", "source_text": "看板 (Signboard)\n\n問題\n\nJOI 君はお店の看板を作ることにした.\n\n文字が等間隔に書かれた古い看板が N 枚ある.JOI 君は古い看板からいくつかの文字を消すことで看板を作る.残った文字列がお店の名前になっていて,しかも残った文字が等間隔に並んでいるようにしたい.看板は 1 枚の古い看板から作らなければならず,古い看板を切ったりつなげたりしてはならない.\n\nお店の名前と N 枚の古い看板の情報が与えられた時,JOI 君が作ることができる看板の枚数を求めるプログラムを作成せよ.ただし, 1 枚の古い看板から作ることができる看板が複数考えられる場合も,作ることができる看板は 1 枚であると考える.\n\n入力\n\n入力は 2 + N 行からなる.\n\n1 行目には,整数 N (1 ≦ N ≦ 100) が書かれており,古い看板の枚数を表す.\n\n2 行目には,3 文字以上 25 文字以下のアルファベット小文字からなる文字列が書かれており,お店の名前を表す.\n\n続く N 行のうちの i 行目 (1 ≦ i ≦ N) には 1 文字以上 100 文字以下のアルファベット小文字からなる文字列が書かれており,i 枚目の古い看板に書かれている文字列を表す.\n\n出力\n\nJOI 君が作ることができる看板の枚数を表す整数を 1 行で出力せよ.\n\n入出力例\n\n入力例\n\n4\nbar\nabracadabra\nbear\nbar\nbaraxbara\n\n出力例\n\n3\n\nお店の名前は bar である.\n\n1 枚目の古い看板には文字列 abracadabra が書かれている.\nこの古い看板から 2 文字目,6 文字目,10 文字目以外を消すことで看板を作ることができる.\n\n2 枚目は,2 文字目を消すと bar という文字列を作ることができるが,これは残った文字が等間隔に並んでいない.\n\n3 枚目は,文字を何も消さなくても看板になっている.\n\n4 枚目の古い看板から看板を作る方法は 2 通りある.\n1 つの方法は,1 文字目,2 文字目,3 文字目以外を消すことである.\nもう 1 つの方法は,6 文字目,7 文字目,8 文字目以外を消すことである.\n\nよって,JOI 君は 1 枚目,3 枚目,4 枚目の古い看板から看板を作ることができるので,3 を出力する.\n\n問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1755, "cpu_time_ms": 340, "memory_kb": 57408}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s119112631", "group_id": "codeNet:p00515", "input_text": "import scala.io.StdIn.readInt\n\nobject Main {\n def makeup(n:Int) = if(n<40) 40 else n\n\n def main(args:Array[String]) = {\n println({for(i<-1 to 5) yield makeup(readInt)}.sum/5)\n }\n}", "language": "Scala", "metadata": {"date": 1488463765, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00515.html", "problem_id": "p00515", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00515/input.txt", "sample_output_relpath": "derived/input_output/data/p00515/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00515/Scala/s119112631.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s119112631", "user_id": "u508732591"}, "prompt_components": {"gold_output": "68\n", "input_to_evaluate": "import scala.io.StdIn.readInt\n\nobject Main {\n def makeup(n:Int) = if(n<40) 40 else n\n\n def main(args:Array[String]) = {\n println({for(i<-1 to 5) yield makeup(readInt)}.sum/5)\n }\n}", "problem_context": "問題 1: 平均点 (Average Score)\n\n問題\n\nJOI 高校の授業には,太郎君,次郎君,三郎君,四郎君,花子さんの 5 人の生徒が参加した.\n\nこの授業では,期末試験を実施した.期末試験は,5 人全員が受験した.期末試験の点数が 40 点以上の生徒は,期末試験の点数がそのまま成績になった.期末試験の点数が 40 点未満の生徒は全員,補習を受け,成績が 40 点になった.\n\n5 人の生徒の期末試験の点数が与えられたとき,5 人の成績の平均点を計算するプログラムを作成せよ.\n\n入力\n\n入力は 5 行からなり,1 行に 1 つずつ整数が書かれている.\n\n1 行目には 太郎君の期末試験の点数が書かれている.\n\n2 行目には 次郎君の期末試験の点数が書かれている.\n\n3 行目には 三郎君の期末試験の点数が書かれている.\n\n4 行目には 四郎君の期末試験の点数が書かれている.\n\n5 行目には 花子さんの期末試験の点数が書かれている.\n\n生徒の期末試験の点数はすべて 0 点以上 100 点以下の整数である.\n\n生徒の期末試験の点数はすべて 5 の倍数である.\n\n5 人の生徒の成績の平均点は必ず整数になる.\n\n出力\n\n5 人の生徒の成績の平均点をあらわす整数を 1 行で出力せよ.\n\n入出力例\n\n入力例 1\n\n10\n65\n100\n30\n95\n\n出力例 1\n\n68\n\n入出力例 1 では,太郎君と四郎君の期末試験の点数は 40 点未満なので,太郎君と四郎君の成績は 40 点になる.次郎君と三郎君と花子さんの期末試験の点数は 40 点以上なので,次郎君の成績は 65 点,三郎君の成績は 100 点,花子さんの成績は 95 点となる.5 人の成績の合計は 340 なので,平均点は 68 点となる.\n\n入力例 2\n\n40\n95\n0\n95\n50\n\n出力例 2\n\n64\n\n問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "10\n65\n100\n30\n95\n"}, "reference_outputs": ["68\n"], "source_document_id": "p00515", "source_text": "問題 1: 平均点 (Average Score)\n\n問題\n\nJOI 高校の授業には,太郎君,次郎君,三郎君,四郎君,花子さんの 5 人の生徒が参加した.\n\nこの授業では,期末試験を実施した.期末試験は,5 人全員が受験した.期末試験の点数が 40 点以上の生徒は,期末試験の点数がそのまま成績になった.期末試験の点数が 40 点未満の生徒は全員,補習を受け,成績が 40 点になった.\n\n5 人の生徒の期末試験の点数が与えられたとき,5 人の成績の平均点を計算するプログラムを作成せよ.\n\n入力\n\n入力は 5 行からなり,1 行に 1 つずつ整数が書かれている.\n\n1 行目には 太郎君の期末試験の点数が書かれている.\n\n2 行目には 次郎君の期末試験の点数が書かれている.\n\n3 行目には 三郎君の期末試験の点数が書かれている.\n\n4 行目には 四郎君の期末試験の点数が書かれている.\n\n5 行目には 花子さんの期末試験の点数が書かれている.\n\n生徒の期末試験の点数はすべて 0 点以上 100 点以下の整数である.\n\n生徒の期末試験の点数はすべて 5 の倍数である.\n\n5 人の生徒の成績の平均点は必ず整数になる.\n\n出力\n\n5 人の生徒の成績の平均点をあらわす整数を 1 行で出力せよ.\n\n入出力例\n\n入力例 1\n\n10\n65\n100\n30\n95\n\n出力例 1\n\n68\n\n入出力例 1 では,太郎君と四郎君の期末試験の点数は 40 点未満なので,太郎君と四郎君の成績は 40 点になる.次郎君と三郎君と花子さんの期末試験の点数は 40 点以上なので,次郎君の成績は 65 点,三郎君の成績は 100 点,花子さんの成績は 95 点となる.5 人の成績の合計は 340 なので,平均点は 68 点となる.\n\n入力例 2\n\n40\n95\n0\n95\n50\n\n出力例 2\n\n64\n\n問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 185, "cpu_time_ms": 240, "memory_kb": 43788}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s382013130", "group_id": "codeNet:p00632", "input_text": "\nobject Main extends App {\n\n import scala.io.StdIn._\n import scala.math._\n\n solve\n def solve: Unit ={\n val Array(h, w) = readLine.trim.split(' ').map(_.toInt)\n if (h == 0) return\n val state = Array.tabulate(h){_ ⇒ readLine.trim}\n val girl = state.indices.flatMap(h ⇒ state(h).indices.map{w ⇒ Coordinate(w, h)}).find{c ⇒ state(c.y)(c.x) == 'A'}.get\n val minTime = Array.tabulate(h){_ ⇒ Array.tabulate(w){_ ⇒ Int.MaxValue}}.also{arr ⇒ arr(girl.y)(girl.x) = 0}\n var current = List(girl)\n while (current.nonEmpty){\n var next = Nil: List[Coordinate]\n for {c ← current; n ← c.neighbor} {\n if ((0 until h).contains(n.y) && (0 until w).contains(n.x) && state(n.y)(n.x) != '#' && minTime(n.y)(n.x) > minTime(c.y)(c.x) + 1) {\n minTime(n.y)(n.x) = minTime(c.y)(c.x) + 1\n next ::= n\n }\n }\n current = next\n }\n val pattern = readLine.trim.map{_.asDigit}.toArray\n val count = Array.tabulate(h){_ ⇒ Array.tabulate(w){_ ⇒ 0}}\n var ghost = state.indices.flatMap(h ⇒ state(h).indices.map{w ⇒ Coordinate(w, h)}).find{c ⇒ state(c.y)(c.x) == 'B'}.get\n\n var time = 0\n var firstContact: Option[(Int, Int, Int)] = None\n while (count(ghost.y)(ghost.x) <= pattern.length && firstContact.isEmpty){\n count(ghost.y)(ghost.x) += 1\n if (minTime(ghost.y)(ghost.x) <= time){\n firstContact = Some(time, ghost.y, ghost.x)\n }\n ghost = move(ghost, pattern(time % pattern.length), h, w)\n time += 1\n }\n var additional = 0\n while (firstContact.isEmpty && additional <= h * w){\n if (minTime(ghost.y)(ghost.x) <= time + additional){\n firstContact = Some(time + additional, ghost.y, ghost.x)\n }\n ghost = move(ghost, pattern((time + additional) % pattern.length), h, w)\n additional += 1\n }\n println(\n firstContact match {\n case Some((t, y, x)) ⇒ s\"$t $y $x\"\n case None ⇒ \"impossible\"\n }\n )\n solve\n }\n def move(coordinate: Coordinate, direction: Int, h: Int, w: Int): Coordinate = {\n (direction match {\n case 8 ⇒ Coordinate(0, -1) + coordinate\n case 6 ⇒ Coordinate(1, 0) + coordinate\n case 4 ⇒ Coordinate(-1, 0) + coordinate\n case 2 ⇒ Coordinate(0, 1) + coordinate\n case _ ⇒ coordinate\n }).let{c ⇒\n if ((0 until h).contains(c.y) && (0 until w).contains(c.x)) c\n else coordinate\n }\n }\n case class Coordinate(x: Int, y: Int) {\n def +(that: Coordinate): Coordinate = Coordinate(x + that.x, y + that.y)\n def neighbor: List[Coordinate] = List(Coordinate(x + 1, y), Coordinate(x - 1, y), Coordinate(x, y + 1), Coordinate(x, y - 1))\n def nextPosition: List[Coordinate] = this::neighbor\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": 1545462804, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00632.html", "problem_id": "p00632", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00632/input.txt", "sample_output_relpath": "derived/input_output/data/p00632/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00632/Scala/s382013130.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s382013130", "user_id": "u514597327"}, "prompt_components": {"gold_output": "18 0 6\n15 3 6\n6 0 0\n14 0 4\n72 0 0\nimpossible\n", "input_to_evaluate": "\nobject Main extends App {\n\n import scala.io.StdIn._\n import scala.math._\n\n solve\n def solve: Unit ={\n val Array(h, w) = readLine.trim.split(' ').map(_.toInt)\n if (h == 0) return\n val state = Array.tabulate(h){_ ⇒ readLine.trim}\n val girl = state.indices.flatMap(h ⇒ state(h).indices.map{w ⇒ Coordinate(w, h)}).find{c ⇒ state(c.y)(c.x) == 'A'}.get\n val minTime = Array.tabulate(h){_ ⇒ Array.tabulate(w){_ ⇒ Int.MaxValue}}.also{arr ⇒ arr(girl.y)(girl.x) = 0}\n var current = List(girl)\n while (current.nonEmpty){\n var next = Nil: List[Coordinate]\n for {c ← current; n ← c.neighbor} {\n if ((0 until h).contains(n.y) && (0 until w).contains(n.x) && state(n.y)(n.x) != '#' && minTime(n.y)(n.x) > minTime(c.y)(c.x) + 1) {\n minTime(n.y)(n.x) = minTime(c.y)(c.x) + 1\n next ::= n\n }\n }\n current = next\n }\n val pattern = readLine.trim.map{_.asDigit}.toArray\n val count = Array.tabulate(h){_ ⇒ Array.tabulate(w){_ ⇒ 0}}\n var ghost = state.indices.flatMap(h ⇒ state(h).indices.map{w ⇒ Coordinate(w, h)}).find{c ⇒ state(c.y)(c.x) == 'B'}.get\n\n var time = 0\n var firstContact: Option[(Int, Int, Int)] = None\n while (count(ghost.y)(ghost.x) <= pattern.length && firstContact.isEmpty){\n count(ghost.y)(ghost.x) += 1\n if (minTime(ghost.y)(ghost.x) <= time){\n firstContact = Some(time, ghost.y, ghost.x)\n }\n ghost = move(ghost, pattern(time % pattern.length), h, w)\n time += 1\n }\n var additional = 0\n while (firstContact.isEmpty && additional <= h * w){\n if (minTime(ghost.y)(ghost.x) <= time + additional){\n firstContact = Some(time + additional, ghost.y, ghost.x)\n }\n ghost = move(ghost, pattern((time + additional) % pattern.length), h, w)\n additional += 1\n }\n println(\n firstContact match {\n case Some((t, y, x)) ⇒ s\"$t $y $x\"\n case None ⇒ \"impossible\"\n }\n )\n solve\n }\n def move(coordinate: Coordinate, direction: Int, h: Int, w: Int): Coordinate = {\n (direction match {\n case 8 ⇒ Coordinate(0, -1) + coordinate\n case 6 ⇒ Coordinate(1, 0) + coordinate\n case 4 ⇒ Coordinate(-1, 0) + coordinate\n case 2 ⇒ Coordinate(0, 1) + coordinate\n case _ ⇒ coordinate\n }).let{c ⇒\n if ((0 until h).contains(c.y) && (0 until w).contains(c.x)) c\n else coordinate\n }\n }\n case class Coordinate(x: Int, y: Int) {\n def +(that: Coordinate): Coordinate = Coordinate(x + that.x, y + that.y)\n def neighbor: List[Coordinate] = List(Coordinate(x + 1, y), Coordinate(x - 1, y), Coordinate(x, y + 1), Coordinate(x, y - 1))\n def nextPosition: List[Coordinate] = this::neighbor\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": "Problem 06: Ghost Buster!\n\n一般人には知る由も無いことだが、この街は幽霊で溢れている。そのほとんどは無害なのだが、困ったことに、人を呪う悪霊も少なからずいるのだ。\n\nあるところに、そんな悪霊と戦う少女がいた。彼女は昼間は何食わぬ顔で高校に通いながらも、夜になると街中を歩き回り、彷徨える魂を見付けては成仏させるのだ。\n\n幽霊を成仏させるためにはまずその幽霊に接近する必要があるのだが、それは簡単なことではない。幽霊は物をすり抜けられるからだ。幽霊は民家に壁から侵入して勝手口から出て行ったり、信号の無い大通りを悠々と横断したりする。人間である彼女にはそんなことはできないので、幽霊を追跡するのはとても難しいのだ。\n\n彼女は経験上、幽霊が規則的な動きをすることを知っていた。そこで彼女は、この情報を活用して幽霊を追跡することを考えた。\n\n彼女のいる街は、(H × W)マスのグリッドとして表される。彼女も幽霊も、1分間に1回、次の5つの行動\n\n東へ1マス進む\n\n西へ1マス進む\n\n南へ1マス進む\n\n北へ1マス進む\n\nその場に留まる\n\nのうちどれか1つを行うことができる。ただし、彼女は街の周囲に結界を張ったので、彼女も幽霊も街の外に出ることはできない。また、そのような行動をしようとした場合、代わりにその場に留まる。\n\nそれぞれのマスは '#' または '.' という文字によって表され、前者は幽霊だけが進入できるマスを、後者は両者が進入できるマスを表す。\n\n幽霊の行動パターンは、L個の行動の列として与えられる。幽霊はこれらの行動を最初から順番に実行していき、全ての行動を実行し終わるとまた最初の行動に戻り、順に実行し続ける。\n\n彼女と幽霊が N 分後に同じマスにいたならば、彼女と幽霊は時刻 N で遭遇したと言うことが出来る。幽霊は放っておくとどんな被害をもたらすか分からないので、彼女は出来るだけ早い時刻に幽霊を捕まえたい。なので、彼女は頼れる先輩であるあなたに、彼女と幽霊が遭遇できる最も早い時刻とその遭遇場所を求めるプログラムを書いてほしいと思っている。\n\nさあ、彼女を助けて、彼女のありがたい言葉で彷徨える魂を極楽浄土へと導くのだ!\n\nInput\n\n複数のデータセットが与えられる。\n各データセットの形式を以下に示す。\n\nH W (グリッドの南北方向のマスの数、グリッドの東西方向のマスの数: 空白区切りの2つの整数)\n\nH × W の文字 (マスの種類:'.', '#', 'A', または 'B')\n\npattern (幽霊の行動パタン:文字列)\n\n'A' は少女の初期位置、'B' は幽霊の初期位置を示す。両者の初期位置は、 '.' のマスの上にある。\n\npattern は '5', '2', '4', '6', '8' から成る文字列で、各文字の意味は以下の通りである:\n\n'5'\n\nその場に留まる\n\n'8'\n\n北に1マス進む\n\n'6'\n\n東に1マス進む\n\n'4'\n\n西に1マス進む\n\n'2'\n\n南に1マス進む\n\n例えば、pattern が \"8544\" の場合、幽霊は「北に1マス進む」「その場に留まる」「西に1マス進む」「西に1マス進む」の行動パタンを繰り返す。\n\nH, W は 1 以上 20 以下であり、pattern の長さは 10 以下である。\n\nH, W がともに 0 のとき、入力は終了する。\n\nOutput\n\nもし少女が幽霊と遭遇できるならば、最も早い遭遇時刻と、その遭遇場所の南北方向の座標、東西方向の座標を空白で区切って1行に出力せよ。グリッドの最北西を座標(0, 0)とし、最南東を座標(H-1, W-1) とする。\n\nどのように行動しても絶対に遭遇できない場合は、 \"impossible\" と出力せよ。\n\nSample Input\n\n4 7\nA#...#B\n.#.#.#.\n.#.#.#.\n...#...\n5\n4 7\nA#...#B\n.#.#.#.\n.#.#.#.\n...#...\n2\n4 7\nA#...#B\n.#.#.#.\n.#.#.#.\n...#...\n4\n4 7\nA#...#B\n.#.#.#.\n.#.#.#.\n...#...\n442668\n1 10\nA#.......B\n55555554\n1 10\nA#.......B\n55555555\n0 0\n\nOutput for the Sample Input\n\n18 0 6\n15 3 6\n6 0 0\n14 0 4\n72 0 0\nimpossible", "sample_input": "4 7\nA#...#B\n.#.#.#.\n.#.#.#.\n...#...\n5\n4 7\nA#...#B\n.#.#.#.\n.#.#.#.\n...#...\n2\n4 7\nA#...#B\n.#.#.#.\n.#.#.#.\n...#...\n4\n4 7\nA#...#B\n.#.#.#.\n.#.#.#.\n...#...\n442668\n1 10\nA#.......B\n55555554\n1 10\nA#.......B\n55555555\n0 0\n"}, "reference_outputs": ["18 0 6\n15 3 6\n6 0 0\n14 0 4\n72 0 0\nimpossible\n"], "source_document_id": "p00632", "source_text": "Problem 06: Ghost Buster!\n\n一般人には知る由も無いことだが、この街は幽霊で溢れている。そのほとんどは無害なのだが、困ったことに、人を呪う悪霊も少なからずいるのだ。\n\nあるところに、そんな悪霊と戦う少女がいた。彼女は昼間は何食わぬ顔で高校に通いながらも、夜になると街中を歩き回り、彷徨える魂を見付けては成仏させるのだ。\n\n幽霊を成仏させるためにはまずその幽霊に接近する必要があるのだが、それは簡単なことではない。幽霊は物をすり抜けられるからだ。幽霊は民家に壁から侵入して勝手口から出て行ったり、信号の無い大通りを悠々と横断したりする。人間である彼女にはそんなことはできないので、幽霊を追跡するのはとても難しいのだ。\n\n彼女は経験上、幽霊が規則的な動きをすることを知っていた。そこで彼女は、この情報を活用して幽霊を追跡することを考えた。\n\n彼女のいる街は、(H × W)マスのグリッドとして表される。彼女も幽霊も、1分間に1回、次の5つの行動\n\n東へ1マス進む\n\n西へ1マス進む\n\n南へ1マス進む\n\n北へ1マス進む\n\nその場に留まる\n\nのうちどれか1つを行うことができる。ただし、彼女は街の周囲に結界を張ったので、彼女も幽霊も街の外に出ることはできない。また、そのような行動をしようとした場合、代わりにその場に留まる。\n\nそれぞれのマスは '#' または '.' という文字によって表され、前者は幽霊だけが進入できるマスを、後者は両者が進入できるマスを表す。\n\n幽霊の行動パターンは、L個の行動の列として与えられる。幽霊はこれらの行動を最初から順番に実行していき、全ての行動を実行し終わるとまた最初の行動に戻り、順に実行し続ける。\n\n彼女と幽霊が N 分後に同じマスにいたならば、彼女と幽霊は時刻 N で遭遇したと言うことが出来る。幽霊は放っておくとどんな被害をもたらすか分からないので、彼女は出来るだけ早い時刻に幽霊を捕まえたい。なので、彼女は頼れる先輩であるあなたに、彼女と幽霊が遭遇できる最も早い時刻とその遭遇場所を求めるプログラムを書いてほしいと思っている。\n\nさあ、彼女を助けて、彼女のありがたい言葉で彷徨える魂を極楽浄土へと導くのだ!\n\nInput\n\n複数のデータセットが与えられる。\n各データセットの形式を以下に示す。\n\nH W (グリッドの南北方向のマスの数、グリッドの東西方向のマスの数: 空白区切りの2つの整数)\n\nH × W の文字 (マスの種類:'.', '#', 'A', または 'B')\n\npattern (幽霊の行動パタン:文字列)\n\n'A' は少女の初期位置、'B' は幽霊の初期位置を示す。両者の初期位置は、 '.' のマスの上にある。\n\npattern は '5', '2', '4', '6', '8' から成る文字列で、各文字の意味は以下の通りである:\n\n'5'\n\nその場に留まる\n\n'8'\n\n北に1マス進む\n\n'6'\n\n東に1マス進む\n\n'4'\n\n西に1マス進む\n\n'2'\n\n南に1マス進む\n\n例えば、pattern が \"8544\" の場合、幽霊は「北に1マス進む」「その場に留まる」「西に1マス進む」「西に1マス進む」の行動パタンを繰り返す。\n\nH, W は 1 以上 20 以下であり、pattern の長さは 10 以下である。\n\nH, W がともに 0 のとき、入力は終了する。\n\nOutput\n\nもし少女が幽霊と遭遇できるならば、最も早い遭遇時刻と、その遭遇場所の南北方向の座標、東西方向の座標を空白で区切って1行に出力せよ。グリッドの最北西を座標(0, 0)とし、最南東を座標(H-1, W-1) とする。\n\nどのように行動しても絶対に遭遇できない場合は、 \"impossible\" と出力せよ。\n\nSample Input\n\n4 7\nA#...#B\n.#.#.#.\n.#.#.#.\n...#...\n5\n4 7\nA#...#B\n.#.#.#.\n.#.#.#.\n...#...\n2\n4 7\nA#...#B\n.#.#.#.\n.#.#.#.\n...#...\n4\n4 7\nA#...#B\n.#.#.#.\n.#.#.#.\n...#...\n442668\n1 10\nA#.......B\n55555554\n1 10\nA#.......B\n55555555\n0 0\n\nOutput for the Sample Input\n\n18 0 6\n15 3 6\n6 0 0\n14 0 4\n72 0 0\nimpossible", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2912, "cpu_time_ms": 330, "memory_kb": 52568}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s653704583", "group_id": "codeNet:p00637", "input_text": "import scala.io.StdIn.readLine\nimport scala.io.StdIn.readInt\n\nobject Main {\n def main(args: Array[String]): Unit = {\n loop()\n\n def loop(): Unit = {\n val n = readInt()\n if (n != 0) {\n var t = readLine().split(' ').map(s => s.toInt)\n t = t :+ Int.MaxValue\n var ans: Seq[String] = Seq[String]()\n var preIdx = 0\n\n for (i <- 1 to n) {\n if (t(i - 1) + 1 != t(i)) {\n if (i - preIdx == 1) {\n ans = ans :+ t(i - 1).toString\n } else {\n ans = ans :+ s\"${t(preIdx)}-${t(i - 1)}\"\n }\n preIdx = i\n }\n }\n println(ans.mkString(\" \"))\n loop()\n }\n }\n }\n}", "language": "Scala", "metadata": {"date": 1450349622, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00637.html", "problem_id": "p00637", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00637/input.txt", "sample_output_relpath": "derived/input_output/data/p00637/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00637/Scala/s653704583.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s653704583", "user_id": "u642549559"}, "prompt_components": {"gold_output": "1-3 5-6\n7-9\n", "input_to_evaluate": "import scala.io.StdIn.readLine\nimport scala.io.StdIn.readInt\n\nobject Main {\n def main(args: Array[String]): Unit = {\n loop()\n\n def loop(): Unit = {\n val n = readInt()\n if (n != 0) {\n var t = readLine().split(' ').map(s => s.toInt)\n t = t :+ Int.MaxValue\n var ans: Seq[String] = Seq[String]()\n var preIdx = 0\n\n for (i <- 1 to n) {\n if (t(i - 1) + 1 != t(i)) {\n if (i - preIdx == 1) {\n ans = ans :+ t(i - 1).toString\n } else {\n ans = ans :+ s\"${t(preIdx)}-${t(i - 1)}\"\n }\n preIdx = i\n }\n }\n println(ans.mkString(\" \"))\n loop()\n }\n }\n }\n}", "problem_context": "Problem A: Citation Format\n\nTo write a research paper, you should definitely follow the structured format. This format, in many cases, is strictly defined, and students who try to write their papers have a hard time with it.\n\nOne of such formats is related to citations. If you refer several pages of a material, you should enumerate their page numbers in ascending order. However, enumerating many page numbers waste space, so you should use the following abbreviated notation:\n\nWhen you refer all pages between page a and page b (a < b), you must use the notation \"a-b\". For example, when you refer pages 1, 2, 3, 4, you must write \"1-4\" not \"1 2 3 4\". You must not write, for example, \"1-2 3-4\", \"1-3 4\", \"1-3 2-4\" and so on. When you refer one page and do not refer the previous and the next page of that page, you can write just the number of that page, but you must follow the notation when you refer successive pages (more than or equal to 2). Typically, commas are used to separate page numbers, in this problem we use space to separate the page numbers.\n\nYou, a kind senior, decided to write a program which generates the abbreviated notation for your junior who struggle with the citation.\n\nInput\n\nInput consists of several datasets.\n\nThe first line of the dataset indicates the number of pages n.\n\nNext line consists of n integers. These integers are arranged in ascending order and they are differ from each other.\n\nInput ends when n = 0.\n\nOutput\n\nFor each dataset, output the abbreviated notation in a line. Your program should not print extra space. Especially, be careful about the space at the end of line.\n\nConstraints\n\n1 ≤ n ≤ 50\n\nSample Input\n\n5\n1 2 3 5 6\n3\n7 8 9\n0\n\nOutput for the Sample Input\n\n1-3 5-6\n7-9", "sample_input": "5\n1 2 3 5 6\n3\n7 8 9\n0\n"}, "reference_outputs": ["1-3 5-6\n7-9\n"], "source_document_id": "p00637", "source_text": "Problem A: Citation Format\n\nTo write a research paper, you should definitely follow the structured format. This format, in many cases, is strictly defined, and students who try to write their papers have a hard time with it.\n\nOne of such formats is related to citations. If you refer several pages of a material, you should enumerate their page numbers in ascending order. However, enumerating many page numbers waste space, so you should use the following abbreviated notation:\n\nWhen you refer all pages between page a and page b (a < b), you must use the notation \"a-b\". For example, when you refer pages 1, 2, 3, 4, you must write \"1-4\" not \"1 2 3 4\". You must not write, for example, \"1-2 3-4\", \"1-3 4\", \"1-3 2-4\" and so on. When you refer one page and do not refer the previous and the next page of that page, you can write just the number of that page, but you must follow the notation when you refer successive pages (more than or equal to 2). Typically, commas are used to separate page numbers, in this problem we use space to separate the page numbers.\n\nYou, a kind senior, decided to write a program which generates the abbreviated notation for your junior who struggle with the citation.\n\nInput\n\nInput consists of several datasets.\n\nThe first line of the dataset indicates the number of pages n.\n\nNext line consists of n integers. These integers are arranged in ascending order and they are differ from each other.\n\nInput ends when n = 0.\n\nOutput\n\nFor each dataset, output the abbreviated notation in a line. Your program should not print extra space. Especially, be careful about the space at the end of line.\n\nConstraints\n\n1 ≤ n ≤ 50\n\nSample Input\n\n5\n1 2 3 5 6\n3\n7 8 9\n0\n\nOutput for the Sample Input\n\n1-3 5-6\n7-9", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 704, "cpu_time_ms": 270, "memory_kb": 45164}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s082416171", "group_id": "codeNet:p00670", "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 n, S = sc.nextInt\n if (n != 0 && S != 0) {\n val r = Array.fill(n)(sc.nextInt)\n var ans = 0\n var i = 0\n for (i <- 0 until n) {\n for (j <- i + 1 until n) {\n if (r(i) + r(j) > S) (ans += 1)\n }\n }\n println(ans)\n System.gc()\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": 1510390980, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00670.html", "problem_id": "p00670", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00670/input.txt", "sample_output_relpath": "derived/input_output/data/p00670/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00670/Scala/s082416171.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s082416171", "user_id": "u018134297"}, "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.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 n, S = sc.nextInt\n if (n != 0 && S != 0) {\n val r = Array.fill(n)(sc.nextInt)\n var ans = 0\n var i = 0\n for (i <- 0 until n) {\n for (j <- i + 1 until n) {\n if (r(i) + r(j) > S) (ans += 1)\n }\n }\n println(ans)\n System.gc()\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": "Problem B: Spellcasters\n\nn 人の魔法使いがいる。彼らには 1 から n までの番号があり、i 番目の魔法使いは魔力 ri ( 1 ≤ i ≤ n ) を持っている。いま彼らは強力な魔法使いと対峙しており、その敵の魔力は S である。n 人の魔法使いは協力して戦うのが得意で、特に 2 人で協力して戦うことを好む。2 人の魔法使いが協力した場合、魔力は単純にその和となり、強力な魔法などを駆使してある程度強い敵にも勝てるようになる。あなたの仕事は魔力 S を持つ敵に対して勝つことができる魔法使いのペア (i, j) ( i ≠ j かつ 1 ≤ i ≤ n かつ 1 ≤ j ≤ n ) の総数を出力することである。ただし (i, j) と (j, i) は同じ組として数える。一方の魔力が他方の魔力よりも大きいとき、大きい魔力を持っている側が勝つ。等しい場合は相打ちで勝ったことにならない。\n\nInput\n\n入力は複数のテストケースからなる。 各テストケースは以下の形式に従う。\n\nn S\nr1\nr2\n…\nrn\n\n各変数の意味は問題文中の通りである。\n入力の終わりは、ふたつの0が一文字の空白で区切られる一行で示される。\n\nConstraints\n\n入力はすべて整数\n\n1 ≤ n ≤ 20,000\n\n1 ≤ ri ≤ 100 ( 1 ≤ i ≤ n )\n\n1 ≤ S ≤ 100\n\nテストケースの数は 100 を超えない。\n\nOutput\n\n条件を満たす組 (i, j) (i ≠ j) の総数を各ケースに付き 1 行に出力せよ。\n\nSample Input\n\n3 7\n1\n3\n10\n0 0\n\nSample Output\n\n2", "sample_input": "3 7\n1\n3\n10\n0 0\n"}, "reference_outputs": ["2\n"], "source_document_id": "p00670", "source_text": "Problem B: Spellcasters\n\nn 人の魔法使いがいる。彼らには 1 から n までの番号があり、i 番目の魔法使いは魔力 ri ( 1 ≤ i ≤ n ) を持っている。いま彼らは強力な魔法使いと対峙しており、その敵の魔力は S である。n 人の魔法使いは協力して戦うのが得意で、特に 2 人で協力して戦うことを好む。2 人の魔法使いが協力した場合、魔力は単純にその和となり、強力な魔法などを駆使してある程度強い敵にも勝てるようになる。あなたの仕事は魔力 S を持つ敵に対して勝つことができる魔法使いのペア (i, j) ( i ≠ j かつ 1 ≤ i ≤ n かつ 1 ≤ j ≤ n ) の総数を出力することである。ただし (i, j) と (j, i) は同じ組として数える。一方の魔力が他方の魔力よりも大きいとき、大きい魔力を持っている側が勝つ。等しい場合は相打ちで勝ったことにならない。\n\nInput\n\n入力は複数のテストケースからなる。 各テストケースは以下の形式に従う。\n\nn S\nr1\nr2\n…\nrn\n\n各変数の意味は問題文中の通りである。\n入力の終わりは、ふたつの0が一文字の空白で区切られる一行で示される。\n\nConstraints\n\n入力はすべて整数\n\n1 ≤ n ≤ 20,000\n\n1 ≤ ri ≤ 100 ( 1 ≤ i ≤ n )\n\n1 ≤ S ≤ 100\n\nテストケースの数は 100 を超えない。\n\nOutput\n\n条件を満たす組 (i, j) (i ≠ j) の総数を各ケースに付き 1 行に出力せよ。\n\nSample Input\n\n3 7\n1\n3\n10\n0 0\n\nSample Output\n\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1420, "cpu_time_ms": 11910, "memory_kb": 59936}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s599814480", "group_id": "codeNet:p00670", "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 n, S = sc.nextInt\n val r = Array.fill(20001)(0)\n var count = 0\n while (n != 0 && S != 0) {\n //val r = Array.fill(n)(0)\n for (i <- 0 until n) {\n r(i) = sc.nextInt\n }\n var ans = 0\n var i = 0\n var j = 0\n while (i < n) {\n j = i + 1\n while (j < n) {\n if (r(i) + r(j) > S) (ans += 1)\n j += 1\n }\n i += 1\n }\n println(ans)\n\n if (count % 10 == 0) {\n System.gc()\n }\n n = sc.nextInt\n S = sc.nextInt\n count += 1\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": 1510391489, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00670.html", "problem_id": "p00670", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00670/input.txt", "sample_output_relpath": "derived/input_output/data/p00670/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00670/Scala/s599814480.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s599814480", "user_id": "u018134297"}, "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.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 n, S = sc.nextInt\n val r = Array.fill(20001)(0)\n var count = 0\n while (n != 0 && S != 0) {\n //val r = Array.fill(n)(0)\n for (i <- 0 until n) {\n r(i) = sc.nextInt\n }\n var ans = 0\n var i = 0\n var j = 0\n while (i < n) {\n j = i + 1\n while (j < n) {\n if (r(i) + r(j) > S) (ans += 1)\n j += 1\n }\n i += 1\n }\n println(ans)\n\n if (count % 10 == 0) {\n System.gc()\n }\n n = sc.nextInt\n S = sc.nextInt\n count += 1\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": "Problem B: Spellcasters\n\nn 人の魔法使いがいる。彼らには 1 から n までの番号があり、i 番目の魔法使いは魔力 ri ( 1 ≤ i ≤ n ) を持っている。いま彼らは強力な魔法使いと対峙しており、その敵の魔力は S である。n 人の魔法使いは協力して戦うのが得意で、特に 2 人で協力して戦うことを好む。2 人の魔法使いが協力した場合、魔力は単純にその和となり、強力な魔法などを駆使してある程度強い敵にも勝てるようになる。あなたの仕事は魔力 S を持つ敵に対して勝つことができる魔法使いのペア (i, j) ( i ≠ j かつ 1 ≤ i ≤ n かつ 1 ≤ j ≤ n ) の総数を出力することである。ただし (i, j) と (j, i) は同じ組として数える。一方の魔力が他方の魔力よりも大きいとき、大きい魔力を持っている側が勝つ。等しい場合は相打ちで勝ったことにならない。\n\nInput\n\n入力は複数のテストケースからなる。 各テストケースは以下の形式に従う。\n\nn S\nr1\nr2\n…\nrn\n\n各変数の意味は問題文中の通りである。\n入力の終わりは、ふたつの0が一文字の空白で区切られる一行で示される。\n\nConstraints\n\n入力はすべて整数\n\n1 ≤ n ≤ 20,000\n\n1 ≤ ri ≤ 100 ( 1 ≤ i ≤ n )\n\n1 ≤ S ≤ 100\n\nテストケースの数は 100 を超えない。\n\nOutput\n\n条件を満たす組 (i, j) (i ≠ j) の総数を各ケースに付き 1 行に出力せよ。\n\nSample Input\n\n3 7\n1\n3\n10\n0 0\n\nSample Output\n\n2", "sample_input": "3 7\n1\n3\n10\n0 0\n"}, "reference_outputs": ["2\n"], "source_document_id": "p00670", "source_text": "Problem B: Spellcasters\n\nn 人の魔法使いがいる。彼らには 1 から n までの番号があり、i 番目の魔法使いは魔力 ri ( 1 ≤ i ≤ n ) を持っている。いま彼らは強力な魔法使いと対峙しており、その敵の魔力は S である。n 人の魔法使いは協力して戦うのが得意で、特に 2 人で協力して戦うことを好む。2 人の魔法使いが協力した場合、魔力は単純にその和となり、強力な魔法などを駆使してある程度強い敵にも勝てるようになる。あなたの仕事は魔力 S を持つ敵に対して勝つことができる魔法使いのペア (i, j) ( i ≠ j かつ 1 ≤ i ≤ n かつ 1 ≤ j ≤ n ) の総数を出力することである。ただし (i, j) と (j, i) は同じ組として数える。一方の魔力が他方の魔力よりも大きいとき、大きい魔力を持っている側が勝つ。等しい場合は相打ちで勝ったことにならない。\n\nInput\n\n入力は複数のテストケースからなる。 各テストケースは以下の形式に従う。\n\nn S\nr1\nr2\n…\nrn\n\n各変数の意味は問題文中の通りである。\n入力の終わりは、ふたつの0が一文字の空白で区切られる一行で示される。\n\nConstraints\n\n入力はすべて整数\n\n1 ≤ n ≤ 20,000\n\n1 ≤ ri ≤ 100 ( 1 ≤ i ≤ n )\n\n1 ≤ S ≤ 100\n\nテストケースの数は 100 を超えない。\n\nOutput\n\n条件を満たす組 (i, j) (i ≠ j) の総数を各ケースに付き 1 行に出力せよ。\n\nSample Input\n\n3 7\n1\n3\n10\n0 0\n\nSample Output\n\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1661, "cpu_time_ms": 7000, "memory_kb": 119508}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s038967292", "group_id": "codeNet:p00670", "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 n, S = sc.nextInt\n val r = Array.fill(20001)(0)\n var count = 0\n while (n != 0 && S != 0) {\n //val r = Array.fill(n)(0)\n for (i <- 0 until n) {\n r(i) = sc.nextInt\n }\n var ans = 0\n var i = 0\n var j = 0\n while (i < n) {\n j = i + 1\n while (j < n) {\n if (r(i) + r(j) > S) (ans += 1)\n j += 1\n }\n i += 1\n }\n println(ans)\n\n if (count % 20 == 0) {\n System.gc()\n }\n n = sc.nextInt\n S = sc.nextInt\n count += 1\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": 1510391511, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00670.html", "problem_id": "p00670", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00670/input.txt", "sample_output_relpath": "derived/input_output/data/p00670/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00670/Scala/s038967292.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s038967292", "user_id": "u018134297"}, "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.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 n, S = sc.nextInt\n val r = Array.fill(20001)(0)\n var count = 0\n while (n != 0 && S != 0) {\n //val r = Array.fill(n)(0)\n for (i <- 0 until n) {\n r(i) = sc.nextInt\n }\n var ans = 0\n var i = 0\n var j = 0\n while (i < n) {\n j = i + 1\n while (j < n) {\n if (r(i) + r(j) > S) (ans += 1)\n j += 1\n }\n i += 1\n }\n println(ans)\n\n if (count % 20 == 0) {\n System.gc()\n }\n n = sc.nextInt\n S = sc.nextInt\n count += 1\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": "Problem B: Spellcasters\n\nn 人の魔法使いがいる。彼らには 1 から n までの番号があり、i 番目の魔法使いは魔力 ri ( 1 ≤ i ≤ n ) を持っている。いま彼らは強力な魔法使いと対峙しており、その敵の魔力は S である。n 人の魔法使いは協力して戦うのが得意で、特に 2 人で協力して戦うことを好む。2 人の魔法使いが協力した場合、魔力は単純にその和となり、強力な魔法などを駆使してある程度強い敵にも勝てるようになる。あなたの仕事は魔力 S を持つ敵に対して勝つことができる魔法使いのペア (i, j) ( i ≠ j かつ 1 ≤ i ≤ n かつ 1 ≤ j ≤ n ) の総数を出力することである。ただし (i, j) と (j, i) は同じ組として数える。一方の魔力が他方の魔力よりも大きいとき、大きい魔力を持っている側が勝つ。等しい場合は相打ちで勝ったことにならない。\n\nInput\n\n入力は複数のテストケースからなる。 各テストケースは以下の形式に従う。\n\nn S\nr1\nr2\n…\nrn\n\n各変数の意味は問題文中の通りである。\n入力の終わりは、ふたつの0が一文字の空白で区切られる一行で示される。\n\nConstraints\n\n入力はすべて整数\n\n1 ≤ n ≤ 20,000\n\n1 ≤ ri ≤ 100 ( 1 ≤ i ≤ n )\n\n1 ≤ S ≤ 100\n\nテストケースの数は 100 を超えない。\n\nOutput\n\n条件を満たす組 (i, j) (i ≠ j) の総数を各ケースに付き 1 行に出力せよ。\n\nSample Input\n\n3 7\n1\n3\n10\n0 0\n\nSample Output\n\n2", "sample_input": "3 7\n1\n3\n10\n0 0\n"}, "reference_outputs": ["2\n"], "source_document_id": "p00670", "source_text": "Problem B: Spellcasters\n\nn 人の魔法使いがいる。彼らには 1 から n までの番号があり、i 番目の魔法使いは魔力 ri ( 1 ≤ i ≤ n ) を持っている。いま彼らは強力な魔法使いと対峙しており、その敵の魔力は S である。n 人の魔法使いは協力して戦うのが得意で、特に 2 人で協力して戦うことを好む。2 人の魔法使いが協力した場合、魔力は単純にその和となり、強力な魔法などを駆使してある程度強い敵にも勝てるようになる。あなたの仕事は魔力 S を持つ敵に対して勝つことができる魔法使いのペア (i, j) ( i ≠ j かつ 1 ≤ i ≤ n かつ 1 ≤ j ≤ n ) の総数を出力することである。ただし (i, j) と (j, i) は同じ組として数える。一方の魔力が他方の魔力よりも大きいとき、大きい魔力を持っている側が勝つ。等しい場合は相打ちで勝ったことにならない。\n\nInput\n\n入力は複数のテストケースからなる。 各テストケースは以下の形式に従う。\n\nn S\nr1\nr2\n…\nrn\n\n各変数の意味は問題文中の通りである。\n入力の終わりは、ふたつの0が一文字の空白で区切られる一行で示される。\n\nConstraints\n\n入力はすべて整数\n\n1 ≤ n ≤ 20,000\n\n1 ≤ ri ≤ 100 ( 1 ≤ i ≤ n )\n\n1 ≤ S ≤ 100\n\nテストケースの数は 100 を超えない。\n\nOutput\n\n条件を満たす組 (i, j) (i ≠ j) の総数を各ケースに付き 1 行に出力せよ。\n\nSample Input\n\n3 7\n1\n3\n10\n0 0\n\nSample Output\n\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1661, "cpu_time_ms": 6880, "memory_kb": 182856}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s658497413", "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){\n case (Array(p, c), i) => if (i >= p - 1 + c) i else if (i >= c) i - c else i + p - 1 \n }\n println(n - m)\n }\n}", "language": "Scala", "metadata": {"date": 1497866701, "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/s658497413.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s658497413", "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){\n case (Array(p, c), i) => if (i >= p - 1 + c) i else if (i >= c) i - c else i + p - 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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 320, "memory_kb": 49580}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s246958476", "group_id": "codeNet:p00711", "input_text": "import scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.io.StdIn._\nobject Main extends App {\n loop\n def loop: Unit = {\n val Array(w, h) = readLine.trim.split(' ').map(_.toInt)\n if (w == 0) return\n val state = Array.tabulate(h){_ ⇒ readLine.trim.toCharArray}\n val start = (0 until h).flatMap(y ⇒ (0 until w).find(x ⇒ state(y)(x) == '@').map(x ⇒ Point(x, y))).head\n val queue = mutable.Queue[Point](start)\n var count = 1\n while(queue.nonEmpty){\n val p = queue.dequeue()\n for (n ← p.neighbor if (0 until h).contains(n.y) && (0 until w).contains(n.x) && state(n.y)(n.x) == '.') {\n state(n.y)(n.x) = '#'\n queue.enqueue(n)\n count += 1\n }\n }\n println(count)\n loop\n }\n case class Point(x: Int, y: Int) {\n def neighbor = Array(Point(x + 1, y), Point(x - 1, y), Point(x, y + 1), Point(x, y - 1))\n }\n}\n", "language": "Scala", "metadata": {"date": 1552671210, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00711.html", "problem_id": "p00711", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00711/input.txt", "sample_output_relpath": "derived/input_output/data/p00711/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00711/Scala/s246958476.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s246958476", "user_id": "u514597327"}, "prompt_components": {"gold_output": "45\n59\n6\n13\n", "input_to_evaluate": "import scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.io.StdIn._\nobject Main extends App {\n loop\n def loop: Unit = {\n val Array(w, h) = readLine.trim.split(' ').map(_.toInt)\n if (w == 0) return\n val state = Array.tabulate(h){_ ⇒ readLine.trim.toCharArray}\n val start = (0 until h).flatMap(y ⇒ (0 until w).find(x ⇒ state(y)(x) == '@').map(x ⇒ Point(x, y))).head\n val queue = mutable.Queue[Point](start)\n var count = 1\n while(queue.nonEmpty){\n val p = queue.dequeue()\n for (n ← p.neighbor if (0 until h).contains(n.y) && (0 until w).contains(n.x) && state(n.y)(n.x) == '.') {\n state(n.y)(n.x) = '#'\n queue.enqueue(n)\n count += 1\n }\n }\n println(count)\n loop\n }\n case class Point(x: Int, y: Int) {\n def neighbor = Array(Point(x + 1, y), Point(x - 1, y), Point(x, y + 1), Point(x, y - 1))\n }\n}\n", "problem_context": "Problem B: Red and Black\n\nThere is a rectangular room, covered with square tiles. Each tile is\ncolored either red or black. A man is standing on a black tile.\nFrom a tile, he can move to one of four adjacent tiles. But he can't\nmove on red tiles, he can move only on black tiles.\n\nWrite a program to count the number of black tiles which he can reach\nby repeating the moves described above.\n\nInput\n\nThe input consists of multiple data sets.\nA data set starts with a line containing two positive integers W and H;\nW and H are the numbers of tiles in the x-\nand y- directions, respectively. W and H are\nnot more than 20.\n\nThere are H more lines in the data set, each of which\nincludes W characters. Each character represents the color of a\ntile as follows.\n\n'.' - a black tile\n\n'#' - a red tile\n\n'@' - a man on a black tile(appears exactly once in a data set)\n\nThe end of the input is indicated by a line consisting of two zeros.\n\nOutput\n\nFor each data set, your program\nshould output a line which contains the number of\ntiles he can reach from the initial tile (including itself).\n\nSample Input\n\n6 9\n....#.\n.....#\n......\n......\n......\n......\n......\n#@...#\n.#..#.\n11 9\n.#.........\n.#.#######.\n.#.#.....#.\n.#.#.###.#.\n.#.#..@#.#.\n.#.#####.#.\n.#.......#.\n.#########.\n...........\n11 6\n..#..#..#..\n..#..#..#..\n..#..#..###\n..#..#..#@.\n..#..#..#..\n..#..#..#..\n7 7\n..#.#..\n..#.#..\n###.###\n...@...\n###.###\n..#.#..\n..#.#..\n0 0\n\nOutput for the Sample Input\n\n45\n59\n6\n13", "sample_input": "6 9\n....#.\n.....#\n......\n......\n......\n......\n......\n#@...#\n.#..#.\n11 9\n.#.........\n.#.#######.\n.#.#.....#.\n.#.#.###.#.\n.#.#..@#.#.\n.#.#####.#.\n.#.......#.\n.#########.\n...........\n11 6\n..#..#..#..\n..#..#..#..\n..#..#..###\n..#..#..#@.\n..#..#..#..\n..#..#..#..\n7 7\n..#.#..\n..#.#..\n###.###\n...@...\n###.###\n..#.#..\n..#.#..\n0 0\n"}, "reference_outputs": ["45\n59\n6\n13\n"], "source_document_id": "p00711", "source_text": "Problem B: Red and Black\n\nThere is a rectangular room, covered with square tiles. Each tile is\ncolored either red or black. A man is standing on a black tile.\nFrom a tile, he can move to one of four adjacent tiles. But he can't\nmove on red tiles, he can move only on black tiles.\n\nWrite a program to count the number of black tiles which he can reach\nby repeating the moves described above.\n\nInput\n\nThe input consists of multiple data sets.\nA data set starts with a line containing two positive integers W and H;\nW and H are the numbers of tiles in the x-\nand y- directions, respectively. W and H are\nnot more than 20.\n\nThere are H more lines in the data set, each of which\nincludes W characters. Each character represents the color of a\ntile as follows.\n\n'.' - a black tile\n\n'#' - a red tile\n\n'@' - a man on a black tile(appears exactly once in a data set)\n\nThe end of the input is indicated by a line consisting of two zeros.\n\nOutput\n\nFor each data set, your program\nshould output a line which contains the number of\ntiles he can reach from the initial tile (including itself).\n\nSample Input\n\n6 9\n....#.\n.....#\n......\n......\n......\n......\n......\n#@...#\n.#..#.\n11 9\n.#.........\n.#.#######.\n.#.#.....#.\n.#.#.###.#.\n.#.#..@#.#.\n.#.#####.#.\n.#.......#.\n.#########.\n...........\n11 6\n..#..#..#..\n..#..#..#..\n..#..#..###\n..#..#..#@.\n..#..#..#..\n..#..#..#..\n7 7\n..#.#..\n..#.#..\n###.###\n...@...\n###.###\n..#.#..\n..#.#..\n0 0\n\nOutput for the Sample Input\n\n45\n59\n6\n13", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 896, "cpu_time_ms": 410, "memory_kb": 58448}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s451118720", "group_id": "codeNet:p00728", "input_text": "import scala.io.StdIn.readInt\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n def main(args:Array[String]) = {\n val b = new ArrayBuffer[Int]\n var n = 0\n while({n=readInt;n} != 0) {\n val m = { for(i<-1 to n) yield readInt }.sorted.dropRight(1).drop(1)\n b += m.sum/m.length\n }\n println(b.mkString(\"\\n\"))\n }\n\n}", "language": "Scala", "metadata": {"date": 1488716591, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00728.html", "problem_id": "p00728", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00728/input.txt", "sample_output_relpath": "derived/input_output/data/p00728/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00728/Scala/s451118720.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s451118720", "user_id": "u508732591"}, "prompt_components": {"gold_output": "342\n7\n300\n326\n", "input_to_evaluate": "import scala.io.StdIn.readInt\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n def main(args:Array[String]) = {\n val b = new ArrayBuffer[Int]\n var n = 0\n while({n=readInt;n} != 0) {\n val m = { for(i<-1 to n) yield readInt }.sorted.dropRight(1).drop(1)\n b += m.sum/m.length\n }\n println(b.mkString(\"\\n\"))\n }\n\n}", "problem_context": "Problem A: ICPC Score Totalizer Software\n\nThe International Clown and Pierrot Competition (ICPC), is one of the\nmost distinguished and also the most popular events on earth in the\nshow business.\n\nOne of the unique features of this contest is the great number of\njudges that sometimes counts up to one hundred. The number of judges\nmay differ from one contestant to another, because judges with any\nrelationship whatsoever with a specific contestant are temporarily\nexcluded for scoring his/her performance.\n\nBasically, scores given to a contestant's performance by the judges\nare averaged to decide his/her score. To avoid letting judges with\neccentric viewpoints too much influence the score, the highest and the\nlowest scores are set aside in this calculation. If the same highest\nscore is marked by two or more judges, only one of them is ignored.\nThe same is with the lowest score. The average, which may contain\nfractions, are truncated down to obtain final score as an integer.\n\nYou are asked to write a program that computes the scores of\nperformances, given the scores of all the judges, to speed up the event\nto be suited for a TV program.\n\nInput\n\nThe input consists of a number of datasets, each corresponding to a\ncontestant's performance. There are no more than 20 datasets in the input.\n\nA dataset begins with a line with an integer n, the number of\njudges participated in scoring the performance (3 ≤ n ≤\n100). Each of the n lines following it has an integral\nscore s (0 ≤ s ≤ 1000) marked by a judge. No\nother characters except for digits to express these numbers are in the\ninput. Judges' names are kept secret.\n\nThe end of the input is indicated by a line with a single zero in it.\n\nOutput\n\nFor each dataset, a line containing a single decimal integer\nindicating the score for the corresponding performance should be\noutput. No other characters should be on the output line.\n\nSample Input\n\n3\n1000\n342\n0\n5\n2\n2\n9\n11\n932\n5\n300\n1000\n0\n200\n400\n8\n353\n242\n402\n274\n283\n132\n402\n523\n0\n\nOutput for the Sample Input\n\n342\n7\n300\n326", "sample_input": "3\n1000\n342\n0\n5\n2\n2\n9\n11\n932\n5\n300\n1000\n0\n200\n400\n8\n353\n242\n402\n274\n283\n132\n402\n523\n0\n"}, "reference_outputs": ["342\n7\n300\n326\n"], "source_document_id": "p00728", "source_text": "Problem A: ICPC Score Totalizer Software\n\nThe International Clown and Pierrot Competition (ICPC), is one of the\nmost distinguished and also the most popular events on earth in the\nshow business.\n\nOne of the unique features of this contest is the great number of\njudges that sometimes counts up to one hundred. The number of judges\nmay differ from one contestant to another, because judges with any\nrelationship whatsoever with a specific contestant are temporarily\nexcluded for scoring his/her performance.\n\nBasically, scores given to a contestant's performance by the judges\nare averaged to decide his/her score. To avoid letting judges with\neccentric viewpoints too much influence the score, the highest and the\nlowest scores are set aside in this calculation. If the same highest\nscore is marked by two or more judges, only one of them is ignored.\nThe same is with the lowest score. The average, which may contain\nfractions, are truncated down to obtain final score as an integer.\n\nYou are asked to write a program that computes the scores of\nperformances, given the scores of all the judges, to speed up the event\nto be suited for a TV program.\n\nInput\n\nThe input consists of a number of datasets, each corresponding to a\ncontestant's performance. There are no more than 20 datasets in the input.\n\nA dataset begins with a line with an integer n, the number of\njudges participated in scoring the performance (3 ≤ n ≤\n100). Each of the n lines following it has an integral\nscore s (0 ≤ s ≤ 1000) marked by a judge. No\nother characters except for digits to express these numbers are in the\ninput. Judges' names are kept secret.\n\nThe end of the input is indicated by a line with a single zero in it.\n\nOutput\n\nFor each dataset, a line containing a single decimal integer\nindicating the score for the corresponding performance should be\noutput. No other characters should be on the output line.\n\nSample Input\n\n3\n1000\n342\n0\n5\n2\n2\n9\n11\n932\n5\n300\n1000\n0\n200\n400\n8\n353\n242\n402\n274\n283\n132\n402\n523\n0\n\nOutput for the Sample Input\n\n342\n7\n300\n326", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 346, "cpu_time_ms": 230, "memory_kb": 43768}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s006414642", "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[Byte](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": 1545379592, "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/s006414642.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s006414642", "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[Byte](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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1260, "cpu_time_ms": 690, "memory_kb": 63484}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s376840656", "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 = HashMap.empty[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(l(1))\n log += {( e(0), l(0) )}\n }\n })\n // println(log.mkString)\n\n val time = Array.ofDim[Boolean](721)\n log.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(_) = true)\n })\n time.count(_ == true)\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": 1545381306, "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/s376840656.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s376840656", "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 = HashMap.empty[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(l(1))\n log += {( e(0), l(0) )}\n }\n })\n // println(log.mkString)\n\n val time = Array.ofDim[Boolean](721)\n log.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(_) = true)\n })\n time.count(_ == true)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 440, "memory_kb": 59308}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s625013968", "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 = new ListBuffer[Tuple2[Int,Int]]\n a.foreach(l => {\n if(l(3) == 1) map.put(l(1),l)\n else {\n val e = map(l(1))\n log += {( e(0), l(0) )}\n }\n })\n // println(log.mkString)\n\n val time = Array.ofDim[Boolean](721)\n log.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(_) = true)\n })\n time.count(_ == true)\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": 1545381803, "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/s625013968.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s625013968", "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 = new ListBuffer[Tuple2[Int,Int]]\n a.foreach(l => {\n if(l(3) == 1) map.put(l(1),l)\n else {\n val e = map(l(1))\n log += {( e(0), l(0) )}\n }\n })\n // println(log.mkString)\n\n val time = Array.ofDim[Boolean](721)\n log.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(_) = true)\n })\n time.count(_ == true)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1265, "cpu_time_ms": 410, "memory_kb": 57744}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s166917837", "group_id": "codeNet:p00777", "input_text": "import scala.io.StdIn._\n\n\n\nobject Main extends App {\n var n = readInt()\n while (n != 0) {\n val parents = readLine.trim.split(' ').map(_.toInt - 1)\n val lengths = readLine.trim.split(' ').map(_.toInt)\n val allRemove = lengths.sum\n if (n == 2) {\n println(allRemove)\n }else {\n val islands = Array.fill(n) {\n Nil: List[Bridge]\n }\n for (i ← parents.indices) {\n islands(i + 1) ::= Bridge(parents(i), lengths(i))\n islands(parents(i)) ::= Bridge(i + 1, lengths(i))\n }\n val isLeaf = islands.map {\n _.lengthCompare(1) == 0\n }\n val minLength = Array.fill(n) {\n Int.MaxValue\n }\n\n def setMax(current: Int, len: Int = 0): Unit = {\n if (minLength(current) > len) {\n minLength(current) = len\n for (Bridge(next, length) ← islands(current)) {\n setMax(next, len + length)\n }\n }\n }\n\n setMax(0)\n val start = islands.indices.filterNot(isLeaf).maxBy(minLength)\n minLength.indices.foreach(i ⇒ minLength(i) = Int.MaxValue)\n setMax(start)\n val doubleMove = islands.indices.map { i ⇒ if (isLeaf(i)) 0 else islands(i).filterNot(e ⇒ isLeaf(e.to)).map(_.length).sum }.sum\n val singleMove = islands.indices.filterNot(isLeaf).map(minLength).max\n println(allRemove + doubleMove - singleMove)\n }\n n = readInt()\n }\n\n case class Bridge(to: Int, length: Int)\n\n}\n", "language": "Scala", "metadata": {"date": 1562660442, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00777.html", "problem_id": "p00777", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00777/input.txt", "sample_output_relpath": "derived/input_output/data/p00777/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00777/Scala/s166917837.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s166917837", "user_id": "u514597327"}, "prompt_components": {"gold_output": "80\n136\n2\n", "input_to_evaluate": "import scala.io.StdIn._\n\n\n\nobject Main extends App {\n var n = readInt()\n while (n != 0) {\n val parents = readLine.trim.split(' ').map(_.toInt - 1)\n val lengths = readLine.trim.split(' ').map(_.toInt)\n val allRemove = lengths.sum\n if (n == 2) {\n println(allRemove)\n }else {\n val islands = Array.fill(n) {\n Nil: List[Bridge]\n }\n for (i ← parents.indices) {\n islands(i + 1) ::= Bridge(parents(i), lengths(i))\n islands(parents(i)) ::= Bridge(i + 1, lengths(i))\n }\n val isLeaf = islands.map {\n _.lengthCompare(1) == 0\n }\n val minLength = Array.fill(n) {\n Int.MaxValue\n }\n\n def setMax(current: Int, len: Int = 0): Unit = {\n if (minLength(current) > len) {\n minLength(current) = len\n for (Bridge(next, length) ← islands(current)) {\n setMax(next, len + length)\n }\n }\n }\n\n setMax(0)\n val start = islands.indices.filterNot(isLeaf).maxBy(minLength)\n minLength.indices.foreach(i ⇒ minLength(i) = Int.MaxValue)\n setMax(start)\n val doubleMove = islands.indices.map { i ⇒ if (isLeaf(i)) 0 else islands(i).filterNot(e ⇒ isLeaf(e.to)).map(_.length).sum }.sum\n val singleMove = islands.indices.filterNot(isLeaf).map(minLength).max\n println(allRemove + doubleMove - singleMove)\n }\n n = readInt()\n }\n\n case class Bridge(to: Int, length: Int)\n\n}\n", "problem_context": "Bridge Removal\n\nICPC islands once had been a popular tourist destination.\nFor nature preservation, however, the government decided to prohibit entrance to the islands,\nand to remove all the man-made structures there.\nThe hardest part of the project is to remove all the bridges connecting the islands.\n\nThere are n islands and n-1 bridges.\nThe bridges are built so that all the islands are reachable from all the other islands by\ncrossing one or more bridges.\nThe bridge removal team can choose any island as the starting point, and can repeat either of the\nfollowing steps.\n\nMove to another island by crossing a bridge that is connected to the current island.\n\nRemove one bridge that is connected to the current island, and stay at the same island after the removal.\n\nOf course, a bridge, once removed, cannot be crossed in either direction.\nCrossing or removing a bridge both takes time proportional to the length of the bridge.\nYour task is to compute the shortest time necessary for removing all the bridges.\nNote that the island where the team starts can differ from where the team finishes the work.\n\nInput\n\nThe input consists of at most 100 datasets.\nEach dataset is formatted as follows.\n\nn\n\np2 p3 ... pn\n\nd2 d3 ... dn\n\nThe first integer n (3 ≤ n ≤ 800) is the number of the islands.\nThe islands are numbered from 1 to n.\nThe second line contains n-1 island numbers pi\n(1 ≤ pi < i), and tells that for each i\nfrom 2 to n the island i and the island pi are connected by a bridge.\nThe third line contains n-1 integers di (1 ≤ di ≤ 100,000)\neach denoting the length of the corresponding bridge.\nThat is, the length of the bridge connecting the island i and pi\nis di. It takes di units of time to cross the bridge, and\nalso the same units of time to remove it.\n\nNote that, with this input format, it is assured that all the islands are reachable each other by\ncrossing one or more bridges.\n\nThe input ends with a line with a single zero.\n\nOutput\n\nFor each dataset, print the minimum time units required to remove all the bridges in a single line.\nEach line should not have any character other than this number.\n\nSample Input\n\n4\n1 2 3\n10 20 30\n10\n1 2 2 1 5 5 1 8 8\n10 1 1 20 1 1 30 1 1\n3\n1 1\n1 1\n0\n\nOutput for the Sample Input\n\n80\n136\n2", "sample_input": "4\n1 2 3\n10 20 30\n10\n1 2 2 1 5 5 1 8 8\n10 1 1 20 1 1 30 1 1\n3\n1 1\n1 1\n0\n"}, "reference_outputs": ["80\n136\n2\n"], "source_document_id": "p00777", "source_text": "Bridge Removal\n\nICPC islands once had been a popular tourist destination.\nFor nature preservation, however, the government decided to prohibit entrance to the islands,\nand to remove all the man-made structures there.\nThe hardest part of the project is to remove all the bridges connecting the islands.\n\nThere are n islands and n-1 bridges.\nThe bridges are built so that all the islands are reachable from all the other islands by\ncrossing one or more bridges.\nThe bridge removal team can choose any island as the starting point, and can repeat either of the\nfollowing steps.\n\nMove to another island by crossing a bridge that is connected to the current island.\n\nRemove one bridge that is connected to the current island, and stay at the same island after the removal.\n\nOf course, a bridge, once removed, cannot be crossed in either direction.\nCrossing or removing a bridge both takes time proportional to the length of the bridge.\nYour task is to compute the shortest time necessary for removing all the bridges.\nNote that the island where the team starts can differ from where the team finishes the work.\n\nInput\n\nThe input consists of at most 100 datasets.\nEach dataset is formatted as follows.\n\nn\n\np2 p3 ... pn\n\nd2 d3 ... dn\n\nThe first integer n (3 ≤ n ≤ 800) is the number of the islands.\nThe islands are numbered from 1 to n.\nThe second line contains n-1 island numbers pi\n(1 ≤ pi < i), and tells that for each i\nfrom 2 to n the island i and the island pi are connected by a bridge.\nThe third line contains n-1 integers di (1 ≤ di ≤ 100,000)\neach denoting the length of the corresponding bridge.\nThat is, the length of the bridge connecting the island i and pi\nis di. It takes di units of time to cross the bridge, and\nalso the same units of time to remove it.\n\nNote that, with this input format, it is assured that all the islands are reachable each other by\ncrossing one or more bridges.\n\nThe input ends with a line with a single zero.\n\nOutput\n\nFor each dataset, print the minimum time units required to remove all the bridges in a single line.\nEach line should not have any character other than this number.\n\nSample Input\n\n4\n1 2 3\n10 20 30\n10\n1 2 2 1 5 5 1 8 8\n10 1 1 20 1 1 30 1 1\n3\n1 1\n1 1\n0\n\nOutput for the Sample Input\n\n80\n136\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1437, "cpu_time_ms": 540, "memory_kb": 85000}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s317387065", "group_id": "codeNet:p00898", "input_text": "import scala.annotation.tailrec\n\n\nobject Main extends App {\n\n override def main(args: Array[String]): Unit = {\n val answerMap = Solver.solveAll\n\n import scala.io.{StdIn => in}\n Iterator.continually(in.readLine()).takeWhile(_ != \"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(buttom: Int, southOrNoth: 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.buttom,face.southOrNoth).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 def apply(string: String): CoordinationAndFace = {\n val arr = string.split(\",\")\n CoordinationAndFace(Coordination(arr(0).toInt,arr(1).toInt),Face(arr(2).toInt,arr(3).toInt))\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.buttom)(face.southOrNoth)\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.buttom)(face.southOrNoth)\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 def solve(answerMap: Map[String, Int]): Int = {\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.getOrElse(cf.toKeySring, missing)).min\n }\n\n}\n\nobject Solver {\n\n\n def solveAll: Map[String, Int] = {\n\n val init: CoordinationAndFace = CoordinationAndFace(Coordination(0, 0), Face(0, 5))\n\n val itr =\n Iterator.iterate[(Map[String, Int], Vector[(String, Int)])](Map(init.toKeySring -> 0), Vector(init.toKeySring -> 0))(mv => solveInner(mv._1, mv._2)).takeWhile(_._2.head._2 < 98)\n\n itr.foldLeft((Map[String,Int](), Vector[(String, Int)]()))((z, n) => n)._1\n }\n\n private def solveInner(map: Map[String, Int], queue: Vector[(String, Int)]): (Map[String, Int], Vector[(String, Int)]) =\n queue match {\n case Vector(head, rest@_*) if (head._2 < 98) =>\n val candidate = CoordinationAndFace(head._1).next\n val nextCost = head._2 + 1\n val (newMap, newQueue) =\n candidate.filterNot(cf => map.contains(cf.toKeySring)).foldLeft((map, queue))((mq, next) => {\n (mq._1 + (next.toKeySring -> nextCost), mq._2 :+ (next.toKeySring, nextCost))\n })\n (newMap, newQueue.drop(1))\n case _ => (map, queue)\n }\n}", "language": "Scala", "metadata": {"date": 1491237542, "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/s317387065.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Memory Limit Exceeded", "submission_id": "s317387065", "user_id": "u825684692"}, "prompt_components": {"gold_output": "6\n10\n9\n30\n47\n100\n", "input_to_evaluate": "import scala.annotation.tailrec\n\n\nobject Main extends App {\n\n override def main(args: Array[String]): Unit = {\n val answerMap = Solver.solveAll\n\n import scala.io.{StdIn => in}\n Iterator.continually(in.readLine()).takeWhile(_ != \"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(buttom: Int, southOrNoth: 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.buttom,face.southOrNoth).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 def apply(string: String): CoordinationAndFace = {\n val arr = string.split(\",\")\n CoordinationAndFace(Coordination(arr(0).toInt,arr(1).toInt),Face(arr(2).toInt,arr(3).toInt))\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.buttom)(face.southOrNoth)\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.buttom)(face.southOrNoth)\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 def solve(answerMap: Map[String, Int]): Int = {\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.getOrElse(cf.toKeySring, missing)).min\n }\n\n}\n\nobject Solver {\n\n\n def solveAll: Map[String, Int] = {\n\n val init: CoordinationAndFace = CoordinationAndFace(Coordination(0, 0), Face(0, 5))\n\n val itr =\n Iterator.iterate[(Map[String, Int], Vector[(String, Int)])](Map(init.toKeySring -> 0), Vector(init.toKeySring -> 0))(mv => solveInner(mv._1, mv._2)).takeWhile(_._2.head._2 < 98)\n\n itr.foldLeft((Map[String,Int](), Vector[(String, Int)]()))((z, n) => n)._1\n }\n\n private def solveInner(map: Map[String, Int], queue: Vector[(String, Int)]): (Map[String, Int], Vector[(String, Int)]) =\n queue match {\n case Vector(head, rest@_*) if (head._2 < 98) =>\n val candidate = CoordinationAndFace(head._1).next\n val nextCost = head._2 + 1\n val (newMap, newQueue) =\n candidate.filterNot(cf => map.contains(cf.toKeySring)).foldLeft((map, queue))((mq, next) => {\n (mq._1 + (next.toKeySring -> nextCost), mq._2 :+ (next.toKeySring, nextCost))\n })\n (newMap, newQueue.drop(1))\n case _ => (map, queue)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6374, "cpu_time_ms": 5790, "memory_kb": 709968}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s552837030", "group_id": "codeNet:p00998", "input_text": "import scala.util.Random\n\nobject Main extends App {\n\n import scala.io.StdIn._\n import Tree._\n\n val Array(n, q) = readLine.trim.split(' ').map(_.toInt)\n val elements = List.tabulate(n){_ ⇒ readLine.trim.toInt}\n val tree = treeOf(elements:_*)\n for (_ ← 0 until q){\n val Array(x, y, z) = readLine.trim.split(' ').map(_.toInt)\n x match {\n case 0 ⇒\n val value = tree.find(z)\n tree.erase(z)\n tree.insert(y, value)\n case 1 ⇒\n println(tree.min(y, z))\n case 2 ⇒\n tree.erase(y)\n tree.insert(y, z)\n case _ ⇒ ???\n }\n //println(tree.toList.mkString(\" \"))\n }\n implicit class ScopeFunc[T](val value: T) {\n def let[A](func: T ⇒ A): A = func(value)\n\n def also(func: T ⇒ Unit): T = {\n func(value)\n value\n }\n }\n}\npackage object Tree{\n private val rand: Random = new Random(1)\n def treeOf(elements: Int*): Tree = {\n val tree = new TreeImpl()\n for ((v,i) ← elements.zipWithIndex) {\n tree.insert(i, v)\n }\n tree\n }\n sealed trait Tree{\n def size: Int\n def insert(rank: Int, value: Int): Unit\n def erase(rank: Int): Unit\n def find(rank: Int): Int\n def min(from: Int, to: Int): Int\n def toList: List[Int]\n }\n private class TreeImpl(var tree: Option[Tree] = None) extends Tree{\n override def size: Int = tree.map(_.size).getOrElse(0)\n\n override def insert(rank: Int, value: Int): Unit = {\n tree match {\n case None ⇒ tree = Some(new Node(0.5, value, None, None))\n case Some(t) ⇒ t.insert(rank, value)\n }\n }\n\n override def erase(rank: Int): Unit = {\n tree match {\n case Some(t) if t.size == 1 ⇒ tree = None\n case Some(t) ⇒ t.erase(rank)\n }\n }\n\n override def find(rank: Int): Int = tree.map(_.find(rank)).get\n\n override def min(from: Int, to: Int): Int = tree.map(_.min(from, to)).get\n\n override def toList: List[Int] = tree.map(_.toList).getOrElse(Nil)\n }\n private class Node(var priority: Double, var value: Int, var left: Option[Node], var right: Option[Node]) extends Tree{\n var size: Int = List(left, right).flatMap{_.map(_.size)}.sum + 1\n var min: Int = math.min(value, List(left, right).flatMap(_.map(_.min)).fold(Int.MaxValue){case (a, b) ⇒ if (a > b) b else a})\n private def _renewMin: Unit = {\n min = math.min(value, List(left, right).flatMap(_.map(_.min)).fold(Int.MaxValue){case (a, b) ⇒ if (a > b) b else a})\n }\n private def _isLeaf: Boolean = size == 1\n private def _insert(rank: Int, value: Int, priority: Double): Unit = {\n size += 1\n (left, right) match {\n case (None, None) ⇒ rank match {\n case 0 ⇒\n if (priority > this.priority) {\n right = Some(new Node(this.priority, this.value, None, None))\n this.priority = priority\n this.value = value\n } else {\n left = Some(new Node(priority, value, None, None))\n }\n case 1 ⇒\n if (priority > this.priority){\n left = Some(new Node(this.priority, this.value, None, None))\n this.priority = priority\n this.value = value\n }else{\n right = Some(new Node(priority, value, None, None))\n }\n }\n case (Some(l), None) ⇒\n if (l.size >= rank) {\n l._insert(rank, value, priority)\n if (priority > this.priority) {\n right = Some(new Node(this.priority, this.value, l.right, right))\n this.priority = l.priority\n this.value = l.value\n left = l.left\n }\n } else {\n if (priority > this.priority){\n left = Some(new Node(this.priority, this.value, left, right))\n this.priority = priority\n this.value = value\n }else {\n right = Some(new Node(priority, value, None, None))\n }\n }\n case (None, Some(r)) ⇒\n if (rank == 0){\n if (priority > this.priority){\n right = Some(new Node(this.priority, this.value, left, right))\n this.priority = priority\n this.value = value\n }else {\n left = Some(new Node(priority, value, None, None))\n }\n }else {\n r._insert(rank - 1, value, priority)\n if (priority > this.priority) {\n left = Some(new Node(this.priority, this.value, left, r.left))\n this.priority = priority\n this.value = value\n right = r.right\n }\n }\n case (Some(l), Some(r)) ⇒\n if (l.size >= rank){\n l._insert(rank, value, priority)\n if (priority > this.priority){\n right = Some(new Node(this.priority, this.value, l.right, right))\n this.priority = priority\n this.value = value\n left = l.left\n }\n } else {\n r._insert(rank - l.size - 1, value, priority)\n if (priority > this.priority){\n left = Some(new Node(this.priority, this.value, left, r.left))\n this.priority = priority\n this.value = value\n right = r.right\n }\n }\n }\n _renewMin\n }\n\n override def toString: String = toList.mkString(\" \")\n private def _erase(rank: Int): Unit = {\n //println(s\"rank = $rank, left = (${left.map(_.toString).getOrElse(\"\")}) current = $value right = ${right.map(_.toString).getOrElse(\"\")}\")\n size -= 1\n (left, right) match {\n case (Some(l), Some(r)) ⇒ {\n l.size.compare(rank) match {\n case 1 ⇒ {\n if (l._isLeaf) {\n left = None\n } else {\n l._erase(rank)\n }\n }\n case -1 ⇒ {\n if (r._isLeaf){\n right = None\n }else {\n r._erase(rank - l.size - 1)\n }\n }\n case 0 ⇒ {\n if (l.priority > r.priority) {\n right = Some(new Node(this.priority, this.value, l.right, right))\n this.priority = l.priority\n this.value = l.value\n left = l.left\n right.foreach(_._erase(rank - l.left.map(_.size).getOrElse(0) - 1))\n } else {\n left = Some(new Node(this.priority, this.value, left, r.left))\n this.priority = r.priority\n this.value = r.value\n right = r.right\n left.foreach(_._erase(rank))\n }\n }\n case _ ⇒ ???\n }\n }\n case (Some(l), None) ⇒ {\n l.size.compare(rank) match {\n case 0 ⇒ {\n this.priority = l.priority\n this.value = l.value\n left = l.left\n right = l.right\n }\n case 1 ⇒ {\n if (l._isLeaf) {\n left = None\n }else{\n l._erase(rank)\n }\n }\n case _ ⇒ ???\n }\n }\n case (None, Some(r)) ⇒ {\n 0.compare(rank) match {\n case 0 ⇒ {\n this.priority = r.priority\n this.value = r.value\n left = r.left\n right = r.right\n }\n case -1 ⇒ {\n if (r._isLeaf){\n right = None\n }else{\n r._erase(rank - 1)\n }\n }\n case _ ⇒ ???\n }\n }\n case _ ⇒ ???\n }\n _renewMin\n }\n private def _find(rank: Int): Int = {\n (left, right) match {\n case (Some(l), Some(r)) ⇒ {\n l.size.compare(rank) match {\n case 0 ⇒ value\n case -1 ⇒ r._find(rank - l.size - 1)\n case 1 ⇒ l._find(rank)\n case _ ⇒ ???\n }\n }\n case (Some(l), None) ⇒ {\n l.size.compare(rank) match {\n case 0 ⇒ value\n case 1 ⇒ l._find(rank)\n case _ ⇒ ???\n }\n }\n case (None, Some(r)) ⇒ {\n 0.compare(rank) match {\n case 0 ⇒ value\n case -1 ⇒ r._find(rank - 1)\n case _ ⇒ ???\n }\n }\n case (None, None) ⇒ value\n }\n }\n private def _min(from: Int, to: Int): Int = {\n if (from <= 0 && to >= size - 1) min\n else if (from >= size || to < 0) Int.MaxValue\n else {\n (left, right) match {\n case (Some(l), Some(r)) ⇒\n List(l._min(from, to), r._min(from - l.size - 1, to - l.size - 1), if ((from to to).contains(l.size)) value else Int.MaxValue).min\n case (Some(l), None) ⇒\n List(l._min(from, to), if ((from to to).contains(l.size)) value else Int.MaxValue).min\n case (None, Some(r)) ⇒\n List(r._min(from - 1, to - 1), if ((from to to).contains(0)) value else Int.MaxValue).min\n case (None, None) ⇒ value\n }\n }\n }\n\n private def _toList(list: List[Int]): List[Int] = {\n (left, right) match {\n case (Some(l), Some(r)) ⇒ l._toList(value::r._toList(list))\n case (Some(l), None) ⇒ l._toList(value::list)\n case (None, Some(r)) ⇒ value::r._toList(list)\n case (None, None) ⇒ value::list\n }\n }\n\n override def insert(rank: Int, value: Int): Unit = {\n require((0 to size).contains(rank))\n assert(List(left, right).flatMap(_.map(_.size)).sum + 1 == size)\n val priority = rand.nextDouble()\n _insert(rank, value, priority)\n }\n override def erase(rank: Int): Unit = {\n require((0 to size).contains(rank))\n assert(List(left, right).flatMap(_.map(_.size)).sum + 1 == size)\n _erase(rank)\n }\n def find(rank: Int): Int = {\n require((0 until size).contains(rank))\n _find(rank)\n }\n\n override def min(from: Int, to: Int): Int = {\n require((0 until size).contains(from) && (0 until size).contains(to) && from <= to)\n _min(from, to)\n }\n\n override def toList: List[Int] = {\n _toList(Nil)\n }\n }\n\n}\n/*\n */\n", "language": "Scala", "metadata": {"date": 1541089321, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p00998.html", "problem_id": "p00998", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p00998/input.txt", "sample_output_relpath": "derived/input_output/data/p00998/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00998/Scala/s552837030.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s552837030", "user_id": "u514597327"}, "prompt_components": {"gold_output": "5\n4\n", "input_to_evaluate": "import scala.util.Random\n\nobject Main extends App {\n\n import scala.io.StdIn._\n import Tree._\n\n val Array(n, q) = readLine.trim.split(' ').map(_.toInt)\n val elements = List.tabulate(n){_ ⇒ readLine.trim.toInt}\n val tree = treeOf(elements:_*)\n for (_ ← 0 until q){\n val Array(x, y, z) = readLine.trim.split(' ').map(_.toInt)\n x match {\n case 0 ⇒\n val value = tree.find(z)\n tree.erase(z)\n tree.insert(y, value)\n case 1 ⇒\n println(tree.min(y, z))\n case 2 ⇒\n tree.erase(y)\n tree.insert(y, z)\n case _ ⇒ ???\n }\n //println(tree.toList.mkString(\" \"))\n }\n implicit class ScopeFunc[T](val value: T) {\n def let[A](func: T ⇒ A): A = func(value)\n\n def also(func: T ⇒ Unit): T = {\n func(value)\n value\n }\n }\n}\npackage object Tree{\n private val rand: Random = new Random(1)\n def treeOf(elements: Int*): Tree = {\n val tree = new TreeImpl()\n for ((v,i) ← elements.zipWithIndex) {\n tree.insert(i, v)\n }\n tree\n }\n sealed trait Tree{\n def size: Int\n def insert(rank: Int, value: Int): Unit\n def erase(rank: Int): Unit\n def find(rank: Int): Int\n def min(from: Int, to: Int): Int\n def toList: List[Int]\n }\n private class TreeImpl(var tree: Option[Tree] = None) extends Tree{\n override def size: Int = tree.map(_.size).getOrElse(0)\n\n override def insert(rank: Int, value: Int): Unit = {\n tree match {\n case None ⇒ tree = Some(new Node(0.5, value, None, None))\n case Some(t) ⇒ t.insert(rank, value)\n }\n }\n\n override def erase(rank: Int): Unit = {\n tree match {\n case Some(t) if t.size == 1 ⇒ tree = None\n case Some(t) ⇒ t.erase(rank)\n }\n }\n\n override def find(rank: Int): Int = tree.map(_.find(rank)).get\n\n override def min(from: Int, to: Int): Int = tree.map(_.min(from, to)).get\n\n override def toList: List[Int] = tree.map(_.toList).getOrElse(Nil)\n }\n private class Node(var priority: Double, var value: Int, var left: Option[Node], var right: Option[Node]) extends Tree{\n var size: Int = List(left, right).flatMap{_.map(_.size)}.sum + 1\n var min: Int = math.min(value, List(left, right).flatMap(_.map(_.min)).fold(Int.MaxValue){case (a, b) ⇒ if (a > b) b else a})\n private def _renewMin: Unit = {\n min = math.min(value, List(left, right).flatMap(_.map(_.min)).fold(Int.MaxValue){case (a, b) ⇒ if (a > b) b else a})\n }\n private def _isLeaf: Boolean = size == 1\n private def _insert(rank: Int, value: Int, priority: Double): Unit = {\n size += 1\n (left, right) match {\n case (None, None) ⇒ rank match {\n case 0 ⇒\n if (priority > this.priority) {\n right = Some(new Node(this.priority, this.value, None, None))\n this.priority = priority\n this.value = value\n } else {\n left = Some(new Node(priority, value, None, None))\n }\n case 1 ⇒\n if (priority > this.priority){\n left = Some(new Node(this.priority, this.value, None, None))\n this.priority = priority\n this.value = value\n }else{\n right = Some(new Node(priority, value, None, None))\n }\n }\n case (Some(l), None) ⇒\n if (l.size >= rank) {\n l._insert(rank, value, priority)\n if (priority > this.priority) {\n right = Some(new Node(this.priority, this.value, l.right, right))\n this.priority = l.priority\n this.value = l.value\n left = l.left\n }\n } else {\n if (priority > this.priority){\n left = Some(new Node(this.priority, this.value, left, right))\n this.priority = priority\n this.value = value\n }else {\n right = Some(new Node(priority, value, None, None))\n }\n }\n case (None, Some(r)) ⇒\n if (rank == 0){\n if (priority > this.priority){\n right = Some(new Node(this.priority, this.value, left, right))\n this.priority = priority\n this.value = value\n }else {\n left = Some(new Node(priority, value, None, None))\n }\n }else {\n r._insert(rank - 1, value, priority)\n if (priority > this.priority) {\n left = Some(new Node(this.priority, this.value, left, r.left))\n this.priority = priority\n this.value = value\n right = r.right\n }\n }\n case (Some(l), Some(r)) ⇒\n if (l.size >= rank){\n l._insert(rank, value, priority)\n if (priority > this.priority){\n right = Some(new Node(this.priority, this.value, l.right, right))\n this.priority = priority\n this.value = value\n left = l.left\n }\n } else {\n r._insert(rank - l.size - 1, value, priority)\n if (priority > this.priority){\n left = Some(new Node(this.priority, this.value, left, r.left))\n this.priority = priority\n this.value = value\n right = r.right\n }\n }\n }\n _renewMin\n }\n\n override def toString: String = toList.mkString(\" \")\n private def _erase(rank: Int): Unit = {\n //println(s\"rank = $rank, left = (${left.map(_.toString).getOrElse(\"\")}) current = $value right = ${right.map(_.toString).getOrElse(\"\")}\")\n size -= 1\n (left, right) match {\n case (Some(l), Some(r)) ⇒ {\n l.size.compare(rank) match {\n case 1 ⇒ {\n if (l._isLeaf) {\n left = None\n } else {\n l._erase(rank)\n }\n }\n case -1 ⇒ {\n if (r._isLeaf){\n right = None\n }else {\n r._erase(rank - l.size - 1)\n }\n }\n case 0 ⇒ {\n if (l.priority > r.priority) {\n right = Some(new Node(this.priority, this.value, l.right, right))\n this.priority = l.priority\n this.value = l.value\n left = l.left\n right.foreach(_._erase(rank - l.left.map(_.size).getOrElse(0) - 1))\n } else {\n left = Some(new Node(this.priority, this.value, left, r.left))\n this.priority = r.priority\n this.value = r.value\n right = r.right\n left.foreach(_._erase(rank))\n }\n }\n case _ ⇒ ???\n }\n }\n case (Some(l), None) ⇒ {\n l.size.compare(rank) match {\n case 0 ⇒ {\n this.priority = l.priority\n this.value = l.value\n left = l.left\n right = l.right\n }\n case 1 ⇒ {\n if (l._isLeaf) {\n left = None\n }else{\n l._erase(rank)\n }\n }\n case _ ⇒ ???\n }\n }\n case (None, Some(r)) ⇒ {\n 0.compare(rank) match {\n case 0 ⇒ {\n this.priority = r.priority\n this.value = r.value\n left = r.left\n right = r.right\n }\n case -1 ⇒ {\n if (r._isLeaf){\n right = None\n }else{\n r._erase(rank - 1)\n }\n }\n case _ ⇒ ???\n }\n }\n case _ ⇒ ???\n }\n _renewMin\n }\n private def _find(rank: Int): Int = {\n (left, right) match {\n case (Some(l), Some(r)) ⇒ {\n l.size.compare(rank) match {\n case 0 ⇒ value\n case -1 ⇒ r._find(rank - l.size - 1)\n case 1 ⇒ l._find(rank)\n case _ ⇒ ???\n }\n }\n case (Some(l), None) ⇒ {\n l.size.compare(rank) match {\n case 0 ⇒ value\n case 1 ⇒ l._find(rank)\n case _ ⇒ ???\n }\n }\n case (None, Some(r)) ⇒ {\n 0.compare(rank) match {\n case 0 ⇒ value\n case -1 ⇒ r._find(rank - 1)\n case _ ⇒ ???\n }\n }\n case (None, None) ⇒ value\n }\n }\n private def _min(from: Int, to: Int): Int = {\n if (from <= 0 && to >= size - 1) min\n else if (from >= size || to < 0) Int.MaxValue\n else {\n (left, right) match {\n case (Some(l), Some(r)) ⇒\n List(l._min(from, to), r._min(from - l.size - 1, to - l.size - 1), if ((from to to).contains(l.size)) value else Int.MaxValue).min\n case (Some(l), None) ⇒\n List(l._min(from, to), if ((from to to).contains(l.size)) value else Int.MaxValue).min\n case (None, Some(r)) ⇒\n List(r._min(from - 1, to - 1), if ((from to to).contains(0)) value else Int.MaxValue).min\n case (None, None) ⇒ value\n }\n }\n }\n\n private def _toList(list: List[Int]): List[Int] = {\n (left, right) match {\n case (Some(l), Some(r)) ⇒ l._toList(value::r._toList(list))\n case (Some(l), None) ⇒ l._toList(value::list)\n case (None, Some(r)) ⇒ value::r._toList(list)\n case (None, None) ⇒ value::list\n }\n }\n\n override def insert(rank: Int, value: Int): Unit = {\n require((0 to size).contains(rank))\n assert(List(left, right).flatMap(_.map(_.size)).sum + 1 == size)\n val priority = rand.nextDouble()\n _insert(rank, value, priority)\n }\n override def erase(rank: Int): Unit = {\n require((0 to size).contains(rank))\n assert(List(left, right).flatMap(_.map(_.size)).sum + 1 == size)\n _erase(rank)\n }\n def find(rank: Int): Int = {\n require((0 until size).contains(rank))\n _find(rank)\n }\n\n override def min(from: Int, to: Int): Int = {\n require((0 until size).contains(from) && (0 until size).contains(to) && from <= to)\n _min(from, to)\n }\n\n override def toList: List[Int] = {\n _toList(Nil)\n }\n }\n\n}\n/*\n */\n", "problem_context": "Problem I : RMQ\n\nn 個の数字a0 ,a1 , ... ,an-1 とq が与えられる。\n\nq 個のクエリーに対して適切な処理を行なって欲しい。\n\nクエリーは以下の3種類の操作が存在する。\n\n値のシフトを行う\n\nl とr のペアが与えられる。(l < r )\nal から ar までの値を Circular Shiftさせる。\n\n0 1 2 3 4 5 6 7 8 9\n\nに対してl=2,r=5というクエリーが与えられたとする。\n\nシフトを行った数字列は\n\n0 1 5 2 3 4 6 7 8 9\n\nとなる。\n\n最小値を求める\n\nl とr のペアが与えられる。(l ≤ r )\n\nal から arまでの値の中で最小の値を求める。\n\n値の更新\n\npos と val のペアが与えられる。\napos の値を val に更新する。\n\nInput\n\n入力は以下のフォーマットで与えられる。\n\nn q\na0\na1\n.\n.\n.\nan-1\nx1 y1 z1\nx2 y2 z2\n.\n.\n.\nxq yq zq\n\nxi = 0 なら、シフトのクエリーを表す。このとき、l = yi , r = zi とする。\n\nxi = 1 なら、最小値を求めるクエリーを表す。このとき、l = yi , r = zi とする。\n\nxi = 2 なら、値を更新するクエリーを表す。このとき、pos = yi , val = zi とする。\n\n入力は以下の制約を満たす\n\n1 ≤ n , q ≤ 200,000\n\n0 ≤ ai ≤ 10,000,000\n\n値を更新するクエリーについて、0 ≤ val ≤ 10,000,000\n\nOutput\n\nクエリーとしてxi = 1 が与えられたときに、答えの値を1行に出力せよ。\n\nSample Input 1\n\n10 3\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n1 5 7\n0 2 5\n1 5 7\n\nSample Output 1\n\n5\n4\n\nSample Input 2\n\n10 10\n289383\n930886\n692777\n636915\n747793\n238335\n885386\n760492\n516649\n641421\n2 7 368690\n1 3 6\n0 2 6\n1 1 8\n0 2 9\n2 2 665123\n1 5 9\n0 2 8\n2 7 961393\n1 1 2\n\nSample Output 2\n\n238335\n238335\n238335\n368690", "sample_input": "10 3\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n1 5 7\n0 2 5\n1 5 7\n"}, "reference_outputs": ["5\n4\n"], "source_document_id": "p00998", "source_text": "Problem I : RMQ\n\nn 個の数字a0 ,a1 , ... ,an-1 とq が与えられる。\n\nq 個のクエリーに対して適切な処理を行なって欲しい。\n\nクエリーは以下の3種類の操作が存在する。\n\n値のシフトを行う\n\nl とr のペアが与えられる。(l < r )\nal から ar までの値を Circular Shiftさせる。\n\n0 1 2 3 4 5 6 7 8 9\n\nに対してl=2,r=5というクエリーが与えられたとする。\n\nシフトを行った数字列は\n\n0 1 5 2 3 4 6 7 8 9\n\nとなる。\n\n最小値を求める\n\nl とr のペアが与えられる。(l ≤ r )\n\nal から arまでの値の中で最小の値を求める。\n\n値の更新\n\npos と val のペアが与えられる。\napos の値を val に更新する。\n\nInput\n\n入力は以下のフォーマットで与えられる。\n\nn q\na0\na1\n.\n.\n.\nan-1\nx1 y1 z1\nx2 y2 z2\n.\n.\n.\nxq yq zq\n\nxi = 0 なら、シフトのクエリーを表す。このとき、l = yi , r = zi とする。\n\nxi = 1 なら、最小値を求めるクエリーを表す。このとき、l = yi , r = zi とする。\n\nxi = 2 なら、値を更新するクエリーを表す。このとき、pos = yi , val = zi とする。\n\n入力は以下の制約を満たす\n\n1 ≤ n , q ≤ 200,000\n\n0 ≤ ai ≤ 10,000,000\n\n値を更新するクエリーについて、0 ≤ val ≤ 10,000,000\n\nOutput\n\nクエリーとしてxi = 1 が与えられたときに、答えの値を1行に出力せよ。\n\nSample Input 1\n\n10 3\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n1 5 7\n0 2 5\n1 5 7\n\nSample Output 1\n\n5\n4\n\nSample Input 2\n\n10 10\n289383\n930886\n692777\n636915\n747793\n238335\n885386\n760492\n516649\n641421\n2 7 368690\n1 3 6\n0 2 6\n1 1 8\n0 2 9\n2 2 665123\n1 5 9\n0 2 8\n2 7 961393\n1 1 2\n\nSample Output 2\n\n238335\n238335\n238335\n368690", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 10271, "cpu_time_ms": 7670, "memory_kb": 615168}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s155718378", "group_id": "codeNet:p01060", "input_text": "\nobject Main extends App {\n\n import scala.io.StdIn._\n import scala.math._\n val Array(w, h) = readLine.trim.split(' ').map(_.toInt)\n val n = readLine.trim.toInt\n val order = readLine.trim.split(' ').map(_.toInt == 0)\n var outside = 2 * w + h - 2\n var inside = outside - 4\n var count = 0\n for (isOutside ← order){\n if (isOutside) outside -= 1\n else inside -= 1\n if (isNeighbor(inside, outside)) count += 1\n }\n println(count)\n def isNeighbor(inside:Int, outside: Int): Boolean = {\n if (outside.isOutsideBottom && inside.isInsideBottom) outside.outsideBottomPosition == inside.insideBottomPosition\n else if (outside.isOutsideRight && inside.isInsideRight) outside.outsideRightPosition == inside.insideRightPosition\n else if (outside.isOutsideUp && inside.isInsideUp) outside.outsideUpPosition == inside.insideUpPosition\n else false\n }\n implicit class INT(val value: Int){\n def isOutsideBottom: Boolean = (1 until w).contains(value)\n def outsideBottomPosition: Int = value - 0\n def isOutsideRight: Boolean = (w + 1 to (w + h - 2)).contains(value)\n def outsideRightPosition: Int = value - w\n def isOutsideUp: Boolean = ((w + h) to (2 * w + h - 2)).contains(value)\n def outsideUpPosition: Int = value - w - h + 1\n def isInsideBottom: Boolean = (1 to w - 1).contains(value)\n def insideBottomPosition: Int = value - 0\n def isInsideRight: Boolean = (w - 1 to (w + h - 4)).contains(value)\n def insideRightPosition: Int = value - w + 2\n def isInsideUp: Boolean = (w + h - 4 to 2 * w + h - 6).contains(value)\n def insideUpPosition: Int = value - w - h + 5\n }\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": 1546183032, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01060.html", "problem_id": "p01060", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01060/input.txt", "sample_output_relpath": "derived/input_output/data/p01060/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01060/Scala/s155718378.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s155718378", "user_id": "u514597327"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "\nobject Main extends App {\n\n import scala.io.StdIn._\n import scala.math._\n val Array(w, h) = readLine.trim.split(' ').map(_.toInt)\n val n = readLine.trim.toInt\n val order = readLine.trim.split(' ').map(_.toInt == 0)\n var outside = 2 * w + h - 2\n var inside = outside - 4\n var count = 0\n for (isOutside ← order){\n if (isOutside) outside -= 1\n else inside -= 1\n if (isNeighbor(inside, outside)) count += 1\n }\n println(count)\n def isNeighbor(inside:Int, outside: Int): Boolean = {\n if (outside.isOutsideBottom && inside.isInsideBottom) outside.outsideBottomPosition == inside.insideBottomPosition\n else if (outside.isOutsideRight && inside.isInsideRight) outside.outsideRightPosition == inside.insideRightPosition\n else if (outside.isOutsideUp && inside.isInsideUp) outside.outsideUpPosition == inside.insideUpPosition\n else false\n }\n implicit class INT(val value: Int){\n def isOutsideBottom: Boolean = (1 until w).contains(value)\n def outsideBottomPosition: Int = value - 0\n def isOutsideRight: Boolean = (w + 1 to (w + h - 2)).contains(value)\n def outsideRightPosition: Int = value - w\n def isOutsideUp: Boolean = ((w + h) to (2 * w + h - 2)).contains(value)\n def outsideUpPosition: Int = value - w - h + 1\n def isInsideBottom: Boolean = (1 to w - 1).contains(value)\n def insideBottomPosition: Int = value - 0\n def isInsideRight: Boolean = (w - 1 to (w + h - 4)).contains(value)\n def insideRightPosition: Int = value - w + 2\n def isInsideUp: Boolean = (w + h - 4 to 2 * w + h - 6).contains(value)\n def insideUpPosition: Int = value - w - h + 5\n }\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": "Product Sale Lines\n\nProblem\n\nウニクロ卯月さんと目黒凛さんはSEARIGHT LIVE FESの物販に来ている。下図のように、物販列は二列からなり、横にW人、縦にH人並べる大きさでコの字の形をしている。列の先頭の人は買い物をした後に列からはけ、同じ列の後ろの人々はそれぞれ一人分ずつ列を詰める。\n\n二人は最初に物販列の最後尾に隣同士で、それぞれ違う列に(下図オレンジと濃い青色の位置)並んでいる。二人はとても仲がよいため、常にできるだけ近くにいたい。しかし、人のはけ方は列によって違うため、違う列に並んでいる二人の位置は離れてしまう可能性がある。\n\nあなたの仕事は、列のはけ方が与えられたとき、二人が隣同士になる回数を求めることである。\nただし、二人ともコの字の角にいる(上図の黒色の状態の)ときは、隣同士とみなさない。また、並んだ直後は隣同士に並んでいるが、これは数えない。\n\nInput\n\n入力は以下の形式で与えられる。\n\nW H\nN\np1 p2 ... pN\n\n1行目に列の大きさを表す整数WとHが空白区切りで与えられる。Wはコの字の横に並べる外側の人数を、Hは縦に並べる外側の人数を表す。2行目に人が一人どちらかの列からはける回数Nが与えられる。3行目には列のはけ方についての情報p1...pNが空白区切りで与えられる。piに’0’または’1’であり、’0’のとき、外側の人が一人はけることを、’1’のとき内側の人が一人はけることを表す。ただし、ウニクロ卯月さんまたは目黒凛さんが列から出ることはない。\n\nConstraints\n\n4 ≤ W ≤ 100\n\n4 ≤ H ≤ 100\n\n0 ≤ N ≤ 100\n\nOutput\n\n二人が隣同士になる回数を一行に出力せよ。\n\nSample Input 1\n\n11 11\n5\n0 0 0 0 0\n\nSample Output 1\n\n0\n\nSample Input 2\n\n11 11\n5\n0 0 1 1 1\n\nSample Output 2\n\n1", "sample_input": "11 11\n5\n0 0 0 0 0\n"}, "reference_outputs": ["0\n"], "source_document_id": "p01060", "source_text": "Product Sale Lines\n\nProblem\n\nウニクロ卯月さんと目黒凛さんはSEARIGHT LIVE FESの物販に来ている。下図のように、物販列は二列からなり、横にW人、縦にH人並べる大きさでコの字の形をしている。列の先頭の人は買い物をした後に列からはけ、同じ列の後ろの人々はそれぞれ一人分ずつ列を詰める。\n\n二人は最初に物販列の最後尾に隣同士で、それぞれ違う列に(下図オレンジと濃い青色の位置)並んでいる。二人はとても仲がよいため、常にできるだけ近くにいたい。しかし、人のはけ方は列によって違うため、違う列に並んでいる二人の位置は離れてしまう可能性がある。\n\nあなたの仕事は、列のはけ方が与えられたとき、二人が隣同士になる回数を求めることである。\nただし、二人ともコの字の角にいる(上図の黒色の状態の)ときは、隣同士とみなさない。また、並んだ直後は隣同士に並んでいるが、これは数えない。\n\nInput\n\n入力は以下の形式で与えられる。\n\nW H\nN\np1 p2 ... pN\n\n1行目に列の大きさを表す整数WとHが空白区切りで与えられる。Wはコの字の横に並べる外側の人数を、Hは縦に並べる外側の人数を表す。2行目に人が一人どちらかの列からはける回数Nが与えられる。3行目には列のはけ方についての情報p1...pNが空白区切りで与えられる。piに’0’または’1’であり、’0’のとき、外側の人が一人はけることを、’1’のとき内側の人が一人はけることを表す。ただし、ウニクロ卯月さんまたは目黒凛さんが列から出ることはない。\n\nConstraints\n\n4 ≤ W ≤ 100\n\n4 ≤ H ≤ 100\n\n0 ≤ N ≤ 100\n\nOutput\n\n二人が隣同士になる回数を一行に出力せよ。\n\nSample Input 1\n\n11 11\n5\n0 0 0 0 0\n\nSample Output 1\n\n0\n\nSample Input 2\n\n11 11\n5\n0 0 1 1 1\n\nSample Output 2\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1793, "cpu_time_ms": 250, "memory_kb": 44360}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s721532948", "group_id": "codeNet:p01075", "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 islands = Array.tabulate(n) { _ ⇒ Nil: List[(Int, Int)]}\n for (_ ← 0 until m){\n val Array(a, b, c) = readLine.trim.split(' ').map(_.toInt)\n islands(a - 1) ::= (b - 1, c)\n }\n val minTime = Array.tabulate(n){_ ⇒ Int.MaxValue}.also{ar ⇒ ar(0) = 0}\n val queue = mutable.PriorityQueue()(Ordering.by[(Int, Int), Int](_._2).reverse).also{q ⇒ q.enqueue((0, 0))}\n while (queue.nonEmpty){\n val (current, time) = queue.dequeue()\n if (minTime(current) == time && current != n - 1){\n for ((next, c) ← islands(current)) {\n if (time <= c && minTime(next) > c) {\n minTime(next) = c\n queue.enqueue((next, c))\n }\n }\n }\n }\n\n var lastTime = -1\n for (from ← islands.indices){\n islands(from).filter(_._1 == n - 1).foreach{\n case (_, c) if minTime(from) <= c && lastTime < c ⇒ lastTime = c\n case _ ⇒\n }\n }\n println(lastTime)\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}\n", "language": "Scala", "metadata": {"date": 1546537339, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01075.html", "problem_id": "p01075", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01075/input.txt", "sample_output_relpath": "derived/input_output/data/p01075/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01075/Scala/s721532948.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s721532948", "user_id": "u514597327"}, "prompt_components": {"gold_output": "20\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 islands = Array.tabulate(n) { _ ⇒ Nil: List[(Int, Int)]}\n for (_ ← 0 until m){\n val Array(a, b, c) = readLine.trim.split(' ').map(_.toInt)\n islands(a - 1) ::= (b - 1, c)\n }\n val minTime = Array.tabulate(n){_ ⇒ Int.MaxValue}.also{ar ⇒ ar(0) = 0}\n val queue = mutable.PriorityQueue()(Ordering.by[(Int, Int), Int](_._2).reverse).also{q ⇒ q.enqueue((0, 0))}\n while (queue.nonEmpty){\n val (current, time) = queue.dequeue()\n if (minTime(current) == time && current != n - 1){\n for ((next, c) ← islands(current)) {\n if (time <= c && minTime(next) > c) {\n minTime(next) = c\n queue.enqueue((next, c))\n }\n }\n }\n }\n\n var lastTime = -1\n for (from ← islands.indices){\n islands(from).filter(_._1 == n - 1).foreach{\n case (_, c) if minTime(from) <= c && lastTime < c ⇒ lastTime = c\n case _ ⇒\n }\n }\n println(lastTime)\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}\n", "problem_context": "Problem D: One-Time Path\n\nProblem\n\nN個の島とM本の橋がある。\nN個の島にはそれぞれ1からNまでの番号が割り振られている。\nM本の橋にもそれぞれ1からMまでの番号が割り振られている。\n\nがっちょ君は現在(時刻0の時点で)、1番目の島にいる。\nがっちょ君はi番目の橋を利用することにより、ai番目の島からbi番目の島へと単方向に移動することができる。\n\nしかし、時刻0の時点では、すべての橋は潮が満ちていて海の中に沈んでしまっている。\ni番目の橋は、時刻ciになると潮が引いて渡れるようになる。\nそして、時刻ciを過ぎると、すぐにまた潮が満ちてi番目の橋は再び沈んでしまう。\n再び沈んでしまうと、またいつ潮が引いて渡れるようになるかはわからない。\nそこで、がっちょ君はそうなった橋は永遠に渡れなくなると考えるようにした。\n\nがっちょ君は、できるだけ長い間、1からN-1番目の島の景色を眺めていたいのだが、N番目の島に船を泊めてあるので、最終的にはN番目の島に到着していなければならない。また、船の中で両親を待たせているため、がっちょ君はN番目の島についたらすぐに船で出発して家へと帰らなければならない。\n\nがっちょ君が橋を渡ったり島の中を移動する時間はとても短いので、0と仮定してよい。がっちょ君が1からN-1番目のいずれかの島にいることのできる時間の最大値を求めよ。ただし、どのように移動してもがっちょ君がN番目の島へと移動できない場合は代わりに-1を出力せよ。\n\nInput\n\n入力は以下の形式で与えられる。\n\nN M\na1 b1 c1\na2 b2 c2\n…\naM bM cM\n\n1行目には、2つの整数N, Mが空白区切りで与えられる。\n\n2行目からM+1行目のそれぞれの行iには、3つの整数ai, bi, ciが空白区切りで与えられる。\n\nConstraints\n\n2 ≤ N ≤ 105\n\n1 ≤ M ≤ 2 × 105\n\n1 ≤ ai < N\n\n1 ≤ bi ≤ N\n\n1 ≤ ci ≤ 109\n\nai ≠ bi\n\nOutput\n\nがっちょ君がN番目の島へと移動できる場合は、がっちょ君が1からN-1番目のいずれかの島にいることのできる時間の最大値を出力する。N番目の島へと移動できない場合は、代わりに-1を出力する。\n\nSample Input 1\n\n3 2\n1 2 10\n2 3 20\n\nSample Output 1\n\n20\n\nまず、1番目の島で時刻が10になるまで待ってから、2番目の島へと移動する。\n\n次に、2番目の島で時刻が20になるまで待ってから、3番目の島へと移動する。\n\n以上より、1から2番目のいずれかの島にいる時間は20となる。\n\nSample Input 2\n\n4 4\n1 2 27\n1 3 37\n2 3 47\n3 1 57\n\nSample Output 2\n\n-1\n\n4番目の島に繋がる橋がないため、4番目の島へ移動することができない。\n\nSample Input 3\n\n3 3\n1 2 13\n2 3 17\n2 3 15\n\nSample Output 3\n\n17\n\nSample Input 4\n\n3 2\n1 2 20\n2 3 10\n\nSample Output 4\n\n-1\n\nSample Input 5\n\n3 2\n1 2 10\n2 3 10\n\nSample Output 5\n\n10", "sample_input": "3 2\n1 2 10\n2 3 20\n"}, "reference_outputs": ["20\n"], "source_document_id": "p01075", "source_text": "Problem D: One-Time Path\n\nProblem\n\nN個の島とM本の橋がある。\nN個の島にはそれぞれ1からNまでの番号が割り振られている。\nM本の橋にもそれぞれ1からMまでの番号が割り振られている。\n\nがっちょ君は現在(時刻0の時点で)、1番目の島にいる。\nがっちょ君はi番目の橋を利用することにより、ai番目の島からbi番目の島へと単方向に移動することができる。\n\nしかし、時刻0の時点では、すべての橋は潮が満ちていて海の中に沈んでしまっている。\ni番目の橋は、時刻ciになると潮が引いて渡れるようになる。\nそして、時刻ciを過ぎると、すぐにまた潮が満ちてi番目の橋は再び沈んでしまう。\n再び沈んでしまうと、またいつ潮が引いて渡れるようになるかはわからない。\nそこで、がっちょ君はそうなった橋は永遠に渡れなくなると考えるようにした。\n\nがっちょ君は、できるだけ長い間、1からN-1番目の島の景色を眺めていたいのだが、N番目の島に船を泊めてあるので、最終的にはN番目の島に到着していなければならない。また、船の中で両親を待たせているため、がっちょ君はN番目の島についたらすぐに船で出発して家へと帰らなければならない。\n\nがっちょ君が橋を渡ったり島の中を移動する時間はとても短いので、0と仮定してよい。がっちょ君が1からN-1番目のいずれかの島にいることのできる時間の最大値を求めよ。ただし、どのように移動してもがっちょ君がN番目の島へと移動できない場合は代わりに-1を出力せよ。\n\nInput\n\n入力は以下の形式で与えられる。\n\nN M\na1 b1 c1\na2 b2 c2\n…\naM bM cM\n\n1行目には、2つの整数N, Mが空白区切りで与えられる。\n\n2行目からM+1行目のそれぞれの行iには、3つの整数ai, bi, ciが空白区切りで与えられる。\n\nConstraints\n\n2 ≤ N ≤ 105\n\n1 ≤ M ≤ 2 × 105\n\n1 ≤ ai < N\n\n1 ≤ bi ≤ N\n\n1 ≤ ci ≤ 109\n\nai ≠ bi\n\nOutput\n\nがっちょ君がN番目の島へと移動できる場合は、がっちょ君が1からN-1番目のいずれかの島にいることのできる時間の最大値を出力する。N番目の島へと移動できない場合は、代わりに-1を出力する。\n\nSample Input 1\n\n3 2\n1 2 10\n2 3 20\n\nSample Output 1\n\n20\n\nまず、1番目の島で時刻が10になるまで待ってから、2番目の島へと移動する。\n\n次に、2番目の島で時刻が20になるまで待ってから、3番目の島へと移動する。\n\n以上より、1から2番目のいずれかの島にいる時間は20となる。\n\nSample Input 2\n\n4 4\n1 2 27\n1 3 37\n2 3 47\n3 1 57\n\nSample Output 2\n\n-1\n\n4番目の島に繋がる橋がないため、4番目の島へ移動することができない。\n\nSample Input 3\n\n3 3\n1 2 13\n2 3 17\n2 3 15\n\nSample Output 3\n\n17\n\nSample Input 4\n\n3 2\n1 2 20\n2 3 10\n\nSample Output 4\n\n-1\n\nSample Input 5\n\n3 2\n1 2 10\n2 3 10\n\nSample Output 5\n\n10", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1202, "cpu_time_ms": 1360, "memory_kb": 461588}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s239283895", "group_id": "codeNet:p01085", "input_text": "\nobject Main {\n\n def main(args: Array[String]) {\n val source = scala.io.Source.stdin.getLines\n\n while(true) {\n val input: Array[Int] = source.next().split(\" \").map(_.toInt)\n\n if (input.forall(_ == 0)) {\n return\n }\n\n val datas: Array[Int] = source.take(input(0)).map(_.toInt).toArray\n val maximum: (Int, Int) = (input(1) to input(2)).map(n => (n, datas(n - 1) - datas(n))).reverse.maxBy(v => v._2)\n\n println(maximum._1)\n\n }\n }\n}", "language": "Scala", "metadata": {"date": 1475047228, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01085.html", "problem_id": "p01085", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01085/input.txt", "sample_output_relpath": "derived/input_output/data/p01085/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01085/Scala/s239283895.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s239283895", "user_id": "u073437081"}, "prompt_components": {"gold_output": "3\n4\n2\n2\n3\n2\n", "input_to_evaluate": "\nobject Main {\n\n def main(args: Array[String]) {\n val source = scala.io.Source.stdin.getLines\n\n while(true) {\n val input: Array[Int] = source.next().split(\" \").map(_.toInt)\n\n if (input.forall(_ == 0)) {\n return\n }\n\n val datas: Array[Int] = source.take(input(0)).map(_.toInt).toArray\n val maximum: (Int, Int) = (input(1) to input(2)).map(n => (n, datas(n - 1) - datas(n))).reverse.maxBy(v => v._2)\n\n println(maximum._1)\n\n }\n }\n}", "problem_context": "Entrance Examination\n\nThe International Competitive Programming College (ICPC) is famous\nfor its research on competitive programming.\nApplicants to the college are required to take its entrance examination.\n\nThe successful applicants of the examination are chosen as follows.\n\nThe score of any successful applicant is higher than that of any unsuccessful applicant.\n\nThe number of successful applicants n must be between nmin and nmax, inclusive.\nWe choose n within the specified range that maximizes the gap.\nHere, the gap means the difference between the lowest score of\nsuccessful applicants and the highest score of unsuccessful applicants.\n\nWhen two or more candidates for n make exactly the same gap,\nuse the greatest n among them.\n\nLet's see the first couple of examples given in Sample Input below.\nIn the first example, nmin and nmax are two and four, respectively, and there are five applicants whose scores are 100, 90, 82, 70, and 65.\nFor n of two, three and four, the gaps will be 8, 12, and 5, respectively.\nWe must choose three as n, because it maximizes the gap.\n\nIn the second example, nmin and nmax are two and four, respectively, and there are five applicants whose scores are 100, 90, 80, 75, and 65.\nFor n of two, three and four, the gap will be 10, 5, and 10,\nrespectively. Both two and four maximize the gap, and we must choose the\ngreatest number, four.\n\nYou are requested to write a program that computes the number of successful applicants that satisfies the conditions.\n\nInput\n\nThe input consists of multiple datasets. Each dataset is formatted as follows.\n\nm nmin nmax\n\nP1\n\nP2\n\n...\n\nPm\n\nThe first line of a dataset contains three integers separated by single spaces.\nm represents the number of applicants, nmin represents the minimum number of successful applicants, and nmax represents the maximum number of successful applicants.\nEach of the following m lines contains an integer\nPi, which represents the score of each applicant.\nThe scores are listed in descending order.\nThese numbers satisfy 0 < nmin < nmax < m ≤ 200, 0 ≤ Pi ≤ 10000 (1 ≤ i ≤ m) and Pnmin > Pnmax+1. These ensure that there always exists an n satisfying the conditions.\n\nThe end of the input is represented by a line containing three zeros separated by single spaces.\n\nOutput\n\nFor each dataset, output the number of successful applicants in a line.\n\nSample Input\n\n5 2 4\n100\n90\n82\n70\n65\n5 2 4\n100\n90\n80\n75\n65\n3 1 2\n5000\n4000\n3000\n4 2 3\n10000\n10000\n8000\n8000\n4 2 3\n10000\n10000\n10000\n8000\n5 2 3\n100\n80\n68\n60\n45\n0 0 0\n\nOutput for the Sample Input\n\n3\n4\n2\n2\n3\n2", "sample_input": "5 2 4\n100\n90\n82\n70\n65\n5 2 4\n100\n90\n80\n75\n65\n3 1 2\n5000\n4000\n3000\n4 2 3\n10000\n10000\n8000\n8000\n4 2 3\n10000\n10000\n10000\n8000\n5 2 3\n100\n80\n68\n60\n45\n0 0 0\n"}, "reference_outputs": ["3\n4\n2\n2\n3\n2\n"], "source_document_id": "p01085", "source_text": "Entrance Examination\n\nThe International Competitive Programming College (ICPC) is famous\nfor its research on competitive programming.\nApplicants to the college are required to take its entrance examination.\n\nThe successful applicants of the examination are chosen as follows.\n\nThe score of any successful applicant is higher than that of any unsuccessful applicant.\n\nThe number of successful applicants n must be between nmin and nmax, inclusive.\nWe choose n within the specified range that maximizes the gap.\nHere, the gap means the difference between the lowest score of\nsuccessful applicants and the highest score of unsuccessful applicants.\n\nWhen two or more candidates for n make exactly the same gap,\nuse the greatest n among them.\n\nLet's see the first couple of examples given in Sample Input below.\nIn the first example, nmin and nmax are two and four, respectively, and there are five applicants whose scores are 100, 90, 82, 70, and 65.\nFor n of two, three and four, the gaps will be 8, 12, and 5, respectively.\nWe must choose three as n, because it maximizes the gap.\n\nIn the second example, nmin and nmax are two and four, respectively, and there are five applicants whose scores are 100, 90, 80, 75, and 65.\nFor n of two, three and four, the gap will be 10, 5, and 10,\nrespectively. Both two and four maximize the gap, and we must choose the\ngreatest number, four.\n\nYou are requested to write a program that computes the number of successful applicants that satisfies the conditions.\n\nInput\n\nThe input consists of multiple datasets. Each dataset is formatted as follows.\n\nm nmin nmax\n\nP1\n\nP2\n\n...\n\nPm\n\nThe first line of a dataset contains three integers separated by single spaces.\nm represents the number of applicants, nmin represents the minimum number of successful applicants, and nmax represents the maximum number of successful applicants.\nEach of the following m lines contains an integer\nPi, which represents the score of each applicant.\nThe scores are listed in descending order.\nThese numbers satisfy 0 < nmin < nmax < m ≤ 200, 0 ≤ Pi ≤ 10000 (1 ≤ i ≤ m) and Pnmin > Pnmax+1. These ensure that there always exists an n satisfying the conditions.\n\nThe end of the input is represented by a line containing three zeros separated by single spaces.\n\nOutput\n\nFor each dataset, output the number of successful applicants in a line.\n\nSample Input\n\n5 2 4\n100\n90\n82\n70\n65\n5 2 4\n100\n90\n80\n75\n65\n3 1 2\n5000\n4000\n3000\n4 2 3\n10000\n10000\n8000\n8000\n4 2 3\n10000\n10000\n10000\n8000\n5 2 3\n100\n80\n68\n60\n45\n0 0 0\n\nOutput for the Sample Input\n\n3\n4\n2\n2\n3\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 477, "cpu_time_ms": 400, "memory_kb": 53728}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s515134185", "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 diff h(b)) match {\n case x :: Nil => println(x)\n case _ => println(\"Draw\")\n }\n }\n}", "language": "Scala", "metadata": {"date": 1489755938, "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/s515134185.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s515134185", "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 diff h(b)) match {\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 525, "cpu_time_ms": 640, "memory_kb": 223148}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s747330025", "group_id": "codeNet:p01198", "input_text": "object Main extends App {\n import scala.io.StdIn._\n\n solve(readInt)\n def solve(n: Int): Unit = {\n if (n == 0) return\n val mode = readLine.trim\n if (mode == \"\") readInt()\n val modes = readLine.trim.split(' ').map(_.toDouble)\n val maxMode = modes.max\n val memo = Array.tabulate(201){x ⇒ Array.tabulate(101){v ⇒ if (x == 0 && v == 0) Some(Some(0d)) else None: Option[Option[Double]]}}\n for (_ ← 0 until readInt){\n val Array(x, v) = readLine.trim.split(' ').map(_.toInt)\n if (v * v > 2 * x * maxMode) println(\"crash\")\n else {\n sub(x, v) match {\n case Some(0d) ⇒ println(\"perfect\")\n case Some(d) ⇒ println(s\"good ${d.toInt}.${((d * 1000).toInt%1000+1000).toString.tail}\")\n case None ⇒ println(\"try again\")\n }\n }\n }\n def sub(x: Double, v: Double): Option[Double] = {\n if (x < 0 || v < 0) None\n else memo((x * 2).toInt)(v.toInt) match {\n case Some(r: Option[Double]) ⇒ r\n case None if v == 0 ⇒ Some(x).also(r ⇒ memo((x * 2).toInt)(v.toInt) = Some(r))\n case None ⇒ modes.flatMap(a ⇒ sub(x - v + a / 2, v - a)) match {\n case l if l.nonEmpty ⇒ Some(l.min).also(r ⇒ memo((x * 2).toInt)(v.toInt) = Some(r))\n case _ ⇒ None.also(r ⇒ memo((x * 2).toInt)(v.toInt) = Some(r))\n }\n case _ ⇒ ???\n }\n }\n if (n != 1) println()\n solve(n - 1)\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}\n", "language": "Scala", "metadata": {"date": 1549618076, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01198.html", "problem_id": "p01198", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01198/input.txt", "sample_output_relpath": "derived/input_output/data/p01198/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01198/Scala/s747330025.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s747330025", "user_id": "u514597327"}, "prompt_components": {"gold_output": "crash\ntry again\ngood 1.000\nperfect\n", "input_to_evaluate": "object Main extends App {\n import scala.io.StdIn._\n\n solve(readInt)\n def solve(n: Int): Unit = {\n if (n == 0) return\n val mode = readLine.trim\n if (mode == \"\") readInt()\n val modes = readLine.trim.split(' ').map(_.toDouble)\n val maxMode = modes.max\n val memo = Array.tabulate(201){x ⇒ Array.tabulate(101){v ⇒ if (x == 0 && v == 0) Some(Some(0d)) else None: Option[Option[Double]]}}\n for (_ ← 0 until readInt){\n val Array(x, v) = readLine.trim.split(' ').map(_.toInt)\n if (v * v > 2 * x * maxMode) println(\"crash\")\n else {\n sub(x, v) match {\n case Some(0d) ⇒ println(\"perfect\")\n case Some(d) ⇒ println(s\"good ${d.toInt}.${((d * 1000).toInt%1000+1000).toString.tail}\")\n case None ⇒ println(\"try again\")\n }\n }\n }\n def sub(x: Double, v: Double): Option[Double] = {\n if (x < 0 || v < 0) None\n else memo((x * 2).toInt)(v.toInt) match {\n case Some(r: Option[Double]) ⇒ r\n case None if v == 0 ⇒ Some(x).also(r ⇒ memo((x * 2).toInt)(v.toInt) = Some(r))\n case None ⇒ modes.flatMap(a ⇒ sub(x - v + a / 2, v - a)) match {\n case l if l.nonEmpty ⇒ Some(l.min).also(r ⇒ memo((x * 2).toInt)(v.toInt) = Some(r))\n case _ ⇒ None.also(r ⇒ memo((x * 2).toInt)(v.toInt) = Some(r))\n }\n case _ ⇒ ???\n }\n }\n if (n != 1) println()\n solve(n - 1)\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}\n", "problem_context": "Dock to the Future\n\nYou had long wanted a spaceship, and finally you bought a used one yesterday! You have heard that the most\ndifficult thing on spaceship driving is to stop your ship at the right position in the dock. Of course you are no\nexception. After a dozen of failures, you gave up doing all the docking process manually. You began to write a\nsimple program that helps you to stop a spaceship.\n\nFirst, you somehow put the spaceship on the straight course to the dock manually. Let the distance to the limit\nline be x[m], and the speed against the dock be v[m/s]. Now you turn on the decelerating rocket. Then, your\nprogram will control the rocket to stop the spaceship at the best position.\n\nYour spaceship is equipped with a decelerating rocket with n modes. When the spaceship is in mode-i (0 ≤ i < n),\nthe deceleration rate is ai[m/s2]. You cannot re-accelerate the spaceship. The accelerating rocket is too powerful\nto be used during docking. Also, you cannot turn off-and-on the decelerating rocket, because your spaceship is a\nused and old one, once you stopped the rocket, it is less certain whether you can turn it on again. In other words,\nthe time you turn off the rocket is the time you stop your spaceship at the right position.\n\nAfter turning on the deceleration rocket, your program can change the mode or stop the rocket at every sec-\nond, starting at the very moment the deceleration began. Given x and v, your program have to make a plan of\ndeceleration. The purpose and the priority of your program is as follows:\n\nStop the spaceship exactly at the limit line. If this is possible, print “perfect”.\n\nIf it is impossible, then stop the spaceship at the position nearest possible to the limit line, but before the\nline. In this case, print “good d”, where d is the distance between the limit line and the stopped position.\nPrint three digits after the decimal point.\n\nIf it is impossible again, decelerate the spaceship to have negative speed, and print “try again”.\n\nIf all of these three cases are impossible, then the spaceship cannot avoid overrunning the limit line. In this\ncase, print “crash”.\n\nInput\n\nThe first line of the input consists of a single integer c, the number of test cases.\n\nEach test case begins with a single integer n (1 ≤ n ≤ 10), the number of deceleration modes. The following line\ncontains n positive integers a0, . . . , an-1 (1 ≤ ai ≤ 100), each denoting the deceleration rate of each mode.\n\nThe next line contains a single integer q (1 ≤ q ≤ 20), and then q lines follow. Each of them contains two positive\nintegers x and v (1 ≤ x, v ≤ 100) defined in the problem statement.\n\nOutput\n\nFor each pair of x and v, print the result in one line. A blank line should be inserted between the test cases.\n\nSample Input\n\n1\n3\n2 4 6\n4\n10 100\n2 3\n10 6\n7 6\n\nOutput for the Sample Input\n\ncrash\ntry again\ngood 1.000\nperfect", "sample_input": "1\n3\n2 4 6\n4\n10 100\n2 3\n10 6\n7 6\n"}, "reference_outputs": ["crash\ntry again\ngood 1.000\nperfect\n"], "source_document_id": "p01198", "source_text": "Dock to the Future\n\nYou had long wanted a spaceship, and finally you bought a used one yesterday! You have heard that the most\ndifficult thing on spaceship driving is to stop your ship at the right position in the dock. Of course you are no\nexception. After a dozen of failures, you gave up doing all the docking process manually. You began to write a\nsimple program that helps you to stop a spaceship.\n\nFirst, you somehow put the spaceship on the straight course to the dock manually. Let the distance to the limit\nline be x[m], and the speed against the dock be v[m/s]. Now you turn on the decelerating rocket. Then, your\nprogram will control the rocket to stop the spaceship at the best position.\n\nYour spaceship is equipped with a decelerating rocket with n modes. When the spaceship is in mode-i (0 ≤ i < n),\nthe deceleration rate is ai[m/s2]. You cannot re-accelerate the spaceship. The accelerating rocket is too powerful\nto be used during docking. Also, you cannot turn off-and-on the decelerating rocket, because your spaceship is a\nused and old one, once you stopped the rocket, it is less certain whether you can turn it on again. In other words,\nthe time you turn off the rocket is the time you stop your spaceship at the right position.\n\nAfter turning on the deceleration rocket, your program can change the mode or stop the rocket at every sec-\nond, starting at the very moment the deceleration began. Given x and v, your program have to make a plan of\ndeceleration. The purpose and the priority of your program is as follows:\n\nStop the spaceship exactly at the limit line. If this is possible, print “perfect”.\n\nIf it is impossible, then stop the spaceship at the position nearest possible to the limit line, but before the\nline. In this case, print “good d”, where d is the distance between the limit line and the stopped position.\nPrint three digits after the decimal point.\n\nIf it is impossible again, decelerate the spaceship to have negative speed, and print “try again”.\n\nIf all of these three cases are impossible, then the spaceship cannot avoid overrunning the limit line. In this\ncase, print “crash”.\n\nInput\n\nThe first line of the input consists of a single integer c, the number of test cases.\n\nEach test case begins with a single integer n (1 ≤ n ≤ 10), the number of deceleration modes. The following line\ncontains n positive integers a0, . . . , an-1 (1 ≤ ai ≤ 100), each denoting the deceleration rate of each mode.\n\nThe next line contains a single integer q (1 ≤ q ≤ 20), and then q lines follow. Each of them contains two positive\nintegers x and v (1 ≤ x, v ≤ 100) defined in the problem statement.\n\nOutput\n\nFor each pair of x and v, print the result in one line. A blank line should be inserted between the test cases.\n\nSample Input\n\n1\n3\n2 4 6\n4\n10 100\n2 3\n10 6\n7 6\n\nOutput for the Sample Input\n\ncrash\ntry again\ngood 1.000\nperfect", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 750, "memory_kb": 112348}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s203760161", "group_id": "codeNet:p01224", "input_text": "object Main {\n def perfect_num(n: Int): String = {\n val rn = math.sqrt(n).floor.toInt\n def go(t: Int, res: Array[Int]): Array[Int] = {\n if (rn < t)\n res\n else if (n % t == 0)\n go(t+1, res :+ t)\n else\n go(t+1, res)\n }\n\n val tmp = go(2, Array())\n val prime = Array.concat(tmp.map(n / _), tmp) :+ 1\n val res = prime.distinct.sum\n if (res == n)\n \"perfect number\"\n else if(res > n)\n \"abundant number\"\n else\n \"deficient number\"\n }\n\n def main(args: Array[String]): Unit = {\n var n = io.StdIn.readInt\n while (n != 0) {\n if (n <= 3)\n println(\"deficient number\")\n else\n println(perfect_num(n))\n n = io.StdIn.readInt\n }\n }\n}", "language": "Scala", "metadata": {"date": 1469120128, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01224.html", "problem_id": "p01224", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01224/input.txt", "sample_output_relpath": "derived/input_output/data/p01224/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01224/Scala/s203760161.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s203760161", "user_id": "u890265381"}, "prompt_components": {"gold_output": "deficient number\ndeficient number\ndeficient number\ndeficient number\nperfect number\nabundant number\ndeficient number\nperfect number\nperfect number\ndeficient number\ndeficient number\nabundant number\n", "input_to_evaluate": "object Main {\n def perfect_num(n: Int): String = {\n val rn = math.sqrt(n).floor.toInt\n def go(t: Int, res: Array[Int]): Array[Int] = {\n if (rn < t)\n res\n else if (n % t == 0)\n go(t+1, res :+ t)\n else\n go(t+1, res)\n }\n\n val tmp = go(2, Array())\n val prime = Array.concat(tmp.map(n / _), tmp) :+ 1\n val res = prime.distinct.sum\n if (res == n)\n \"perfect number\"\n else if(res > n)\n \"abundant number\"\n else\n \"deficient number\"\n }\n\n def main(args: Array[String]): Unit = {\n var n = io.StdIn.readInt\n while (n != 0) {\n if (n <= 3)\n println(\"deficient number\")\n else\n println(perfect_num(n))\n n = io.StdIn.readInt\n }\n }\n}", "problem_context": "Problem B: 完全数\n\nある整数 N に対し,その数自身を除く約数の和を S\nとする.\nN = S のとき\nN は完全数 (perfect number),\nN > S のとき\nN は不足数 (deficient number),\nN < S のとき\nN は過剰数 (abundant number) と呼ばれる.\n与えられた整数が,完全数・不足数・過剰数のどれであるかを\n判定するプログラムを作成せよ.\n\nプログラムの実行時間が制限時間を越えないように注意すること.\n\nInput\n\n入力はデータセットの並びからなる.\nデータセットの数は 100 以下である.\n\n各データセットは整数 N\n(0 < N ≤ 100000000) のみを含む1行からなる.\n\n最後のデータセットの後に,入力の終わりを示す 0 と書かれた1行がある.\n\nOutput\n\n各データセットに対し,\n整数 N が完全数ならば “perfect number”,\n不足数ならば “deficient number”,\n過剰数ならば “abundant number” という文字列を\n1行に出力せよ.\n\nSample Input\n\n1\n2\n3\n4\n6\n12\n16\n28\n33550336\n99999998\n99999999\n100000000\n0\n\nOutput for the Sample Input\n\ndeficient number\ndeficient number\ndeficient number\ndeficient number\nperfect number\nabundant number\ndeficient number\nperfect number\nperfect number\ndeficient number\ndeficient number\nabundant number", "sample_input": "1\n2\n3\n4\n6\n12\n16\n28\n33550336\n99999998\n99999999\n100000000\n0\n"}, "reference_outputs": ["deficient number\ndeficient number\ndeficient number\ndeficient number\nperfect number\nabundant number\ndeficient number\nperfect number\nperfect number\ndeficient number\ndeficient number\nabundant number\n"], "source_document_id": "p01224", "source_text": "Problem B: 完全数\n\nある整数 N に対し,その数自身を除く約数の和を S\nとする.\nN = S のとき\nN は完全数 (perfect number),\nN > S のとき\nN は不足数 (deficient number),\nN < S のとき\nN は過剰数 (abundant number) と呼ばれる.\n与えられた整数が,完全数・不足数・過剰数のどれであるかを\n判定するプログラムを作成せよ.\n\nプログラムの実行時間が制限時間を越えないように注意すること.\n\nInput\n\n入力はデータセットの並びからなる.\nデータセットの数は 100 以下である.\n\n各データセットは整数 N\n(0 < N ≤ 100000000) のみを含む1行からなる.\n\n最後のデータセットの後に,入力の終わりを示す 0 と書かれた1行がある.\n\nOutput\n\n各データセットに対し,\n整数 N が完全数ならば “perfect number”,\n不足数ならば “deficient number”,\n過剰数ならば “abundant number” という文字列を\n1行に出力せよ.\n\nSample Input\n\n1\n2\n3\n4\n6\n12\n16\n28\n33550336\n99999998\n99999999\n100000000\n0\n\nOutput for the Sample Input\n\ndeficient number\ndeficient number\ndeficient number\ndeficient number\nperfect number\nabundant number\ndeficient number\nperfect number\nperfect number\ndeficient number\ndeficient number\nabundant number", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 733, "cpu_time_ms": 320, "memory_kb": 44928}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s629279320", "group_id": "codeNet:p01461", "input_text": "import scala.collection.immutable.Nil\nimport scala.collection.mutable\n\nobject Main extends App {\n import scala.io.StdIn._\n\n val n = readInt\n val events = Array.tabulate(n - 1){_ ⇒\n val Array(l, r) = readLine.trim.split(' ').map(_.toInt)\n Event(l, r)\n }\n val branch = Branch(events)\n println(branch.canSaveTime)\n case class Event(left: Int, right: Int)\n object Branch {\n def apply(events: Array[Event]): Branch = {\n val refCount = Array.tabulate(events.length + 1){_ ⇒ 0}\n val reference = Array.tabulate(events.length + 1){_ ⇒ Nil: List[Int]}\n for (i ← events.indices){\n val Event(left, right) = events(i)\n refCount(i) += 2\n reference(left - 1) ::= i\n reference(right - 1) ::= i\n }\n val depth = calDepth(events)\n val branches = Array.tabulate(events.length + 1){_ ⇒ Ending: Branch}\n val queue = mutable.Queue[Int](events.length)\n while (queue.nonEmpty){\n val top = queue.dequeue()\n for (prev ← reference(top)) {\n refCount(prev) -= 1\n if (refCount(prev) == 0){\n queue.enqueue(prev)\n val Event(left, right) = events(prev)\n branches(prev) = Choice(depth(prev), branches(left - 1), branches(right - 1))\n }\n }\n }\n branches(0)\n }\n private[this] def calDepth(events: Array[Event]): Array[Int] = {\n val depth = Array.tabulate(events.length + 1){_ ⇒ -1}.also{d ⇒ d(0) = 0\n d(events.length) = 0}\n val queue = mutable.Queue[Int](0)\n while (queue.nonEmpty){\n val top = queue.dequeue()\n val Event(left, right) = events(top)\n if (depth(left - 1) == -1) {\n depth(left - 1) = depth(top) + 1\n queue.enqueue(left - 1)\n }\n if (depth(right - 1) == -1){\n depth(right - 1) = depth(top) + 1\n queue.enqueue(right - 1)\n }\n }\n depth\n }\n\n }\n sealed trait Branch {\n def endingCount: Int\n def canSaveTime: Long\n def cannotSaveTime: Long\n }\n case object Ending extends Branch {\n override def endingCount: Int = 1\n override def canSaveTime: Long = 0\n override def cannotSaveTime: Long = 0\n }\n case class Choice(depth: Int, left: Branch, right: Branch) extends Branch {\n override val endingCount = left.endingCount + right.endingCount\n override val canSaveTime: Long = List(\n left.cannotSaveTime + right.cannotSaveTime + endingCount,\n left.cannotSaveTime + right.canSaveTime + left.endingCount + 1,\n left.canSaveTime + right.cannotSaveTime + right.endingCount + 1,\n left.canSaveTime + right.canSaveTime + depth + 2\n ).min\n override val cannotSaveTime: Long = left.cannotSaveTime + right.cannotSaveTime + endingCount\n }\n implicit class Scope[T](val value: T) extends AnyVal {\n @inline\n def also(@inline func: T ⇒ Unit): T = {\n func(value)\n value\n }\n @inline\n def let[A](@inline func: T ⇒ A): A = func(value)\n }\n}\n", "language": "Scala", "metadata": {"date": 1551353977, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01461.html", "problem_id": "p01461", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01461/input.txt", "sample_output_relpath": "derived/input_output/data/p01461/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01461/Scala/s629279320.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s629279320", "user_id": "u514597327"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import scala.collection.immutable.Nil\nimport scala.collection.mutable\n\nobject Main extends App {\n import scala.io.StdIn._\n\n val n = readInt\n val events = Array.tabulate(n - 1){_ ⇒\n val Array(l, r) = readLine.trim.split(' ').map(_.toInt)\n Event(l, r)\n }\n val branch = Branch(events)\n println(branch.canSaveTime)\n case class Event(left: Int, right: Int)\n object Branch {\n def apply(events: Array[Event]): Branch = {\n val refCount = Array.tabulate(events.length + 1){_ ⇒ 0}\n val reference = Array.tabulate(events.length + 1){_ ⇒ Nil: List[Int]}\n for (i ← events.indices){\n val Event(left, right) = events(i)\n refCount(i) += 2\n reference(left - 1) ::= i\n reference(right - 1) ::= i\n }\n val depth = calDepth(events)\n val branches = Array.tabulate(events.length + 1){_ ⇒ Ending: Branch}\n val queue = mutable.Queue[Int](events.length)\n while (queue.nonEmpty){\n val top = queue.dequeue()\n for (prev ← reference(top)) {\n refCount(prev) -= 1\n if (refCount(prev) == 0){\n queue.enqueue(prev)\n val Event(left, right) = events(prev)\n branches(prev) = Choice(depth(prev), branches(left - 1), branches(right - 1))\n }\n }\n }\n branches(0)\n }\n private[this] def calDepth(events: Array[Event]): Array[Int] = {\n val depth = Array.tabulate(events.length + 1){_ ⇒ -1}.also{d ⇒ d(0) = 0\n d(events.length) = 0}\n val queue = mutable.Queue[Int](0)\n while (queue.nonEmpty){\n val top = queue.dequeue()\n val Event(left, right) = events(top)\n if (depth(left - 1) == -1) {\n depth(left - 1) = depth(top) + 1\n queue.enqueue(left - 1)\n }\n if (depth(right - 1) == -1){\n depth(right - 1) = depth(top) + 1\n queue.enqueue(right - 1)\n }\n }\n depth\n }\n\n }\n sealed trait Branch {\n def endingCount: Int\n def canSaveTime: Long\n def cannotSaveTime: Long\n }\n case object Ending extends Branch {\n override def endingCount: Int = 1\n override def canSaveTime: Long = 0\n override def cannotSaveTime: Long = 0\n }\n case class Choice(depth: Int, left: Branch, right: Branch) extends Branch {\n override val endingCount = left.endingCount + right.endingCount\n override val canSaveTime: Long = List(\n left.cannotSaveTime + right.cannotSaveTime + endingCount,\n left.cannotSaveTime + right.canSaveTime + left.endingCount + 1,\n left.canSaveTime + right.cannotSaveTime + right.endingCount + 1,\n left.canSaveTime + right.canSaveTime + depth + 2\n ).min\n override val cannotSaveTime: Long = left.cannotSaveTime + right.cannotSaveTime + endingCount\n }\n implicit class Scope[T](val value: T) extends AnyVal {\n @inline\n def also(@inline func: T ⇒ Unit): T = {\n func(value)\n value\n }\n @inline\n def let[A](@inline func: T ⇒ A): A = func(value)\n }\n}\n", "problem_context": "Multi-ending Story\n\nYou are a programmer who loves bishojo games (a sub-genre of dating simulation games).\nA game, which is titled \"I * C * P * C!\" and was released yesterday, has arrived to you just now.\nThis game has multiple endings. When you complete all of those endings, you can get a special figure of the main heroine, Sakuya.\nSo, you want to hurry and play the game!\nBut, let's calm down a bit and think how to complete all of the endings in the shortest time first.\n\nIn fact, you have a special skill that allows you to know the structure of branching points of games.\nBy using the skill, you have found out that all of the branching points in this game are to select two choices \"Yes\" or \"No\", and once a different choice is taken the branched stories flow to different endings; they won't converge any more, like a binary tree.\nYou also noticed that it takes exactly one minute to proceed the game from a branching point to another branching point or to an ending.\nIn addition, you can assume it only takes negligible time to return to the beginning of the game (``reset'') and to play from the beginning to the first branching point.\n\nThe game has an additional feature called \"Quick Save\", which can significantly reduce the playing time for completion.\nThe feature allows you to record the point where you are currently playing and return there at any time later.\nYou can record any number of times, but you can hold only the last recorded point.\nThat is, when you use Quick Save, you overwrite the previous record. If you want to return to the overwritten point, you must play the game from the beginning once again.\n\nWell, let's estimate how long it will take for completing all of the endings in the shortest time.\n\nInput\n\nA data set is given in the following format.\n\nThe first line of the data set contains one integer N (2 \\leq N \\leq 500{,}000), which denotes the number of the endings in this game.\nThe following N-1 lines describe the branching points.\nThe i-th line describes the branching point of ID number i and contains two integers Yes_i and No_i (i + 1 \\leq Yes_i, No_i \\leq N), which denote the ID numbers of the next branching points when you select Yes or No respectively.\nYes_i = N means that you can reach an ending if you select Yes, and so for No_i = N.\nThe branching point with ID 1 is the first branching point.\nThe branching points with ID between 2 and N-1 (inclusive) appear exactly once in Yes_i's and No_i's.\n\nOutput\n\nPrint the shortest time in a line.\n\nSample Input 1\n\n4\n2 3\n4 4\n4 4\n\nOutput for the Sample Input 1\n\n6\n\nSample Input 2\n\n5\n5 2\n3 5\n5 4\n5 5\n\nOutput for the Sample Input 2\n\n8", "sample_input": "4\n2 3\n4 4\n4 4\n"}, "reference_outputs": ["6\n"], "source_document_id": "p01461", "source_text": "Multi-ending Story\n\nYou are a programmer who loves bishojo games (a sub-genre of dating simulation games).\nA game, which is titled \"I * C * P * C!\" and was released yesterday, has arrived to you just now.\nThis game has multiple endings. When you complete all of those endings, you can get a special figure of the main heroine, Sakuya.\nSo, you want to hurry and play the game!\nBut, let's calm down a bit and think how to complete all of the endings in the shortest time first.\n\nIn fact, you have a special skill that allows you to know the structure of branching points of games.\nBy using the skill, you have found out that all of the branching points in this game are to select two choices \"Yes\" or \"No\", and once a different choice is taken the branched stories flow to different endings; they won't converge any more, like a binary tree.\nYou also noticed that it takes exactly one minute to proceed the game from a branching point to another branching point or to an ending.\nIn addition, you can assume it only takes negligible time to return to the beginning of the game (``reset'') and to play from the beginning to the first branching point.\n\nThe game has an additional feature called \"Quick Save\", which can significantly reduce the playing time for completion.\nThe feature allows you to record the point where you are currently playing and return there at any time later.\nYou can record any number of times, but you can hold only the last recorded point.\nThat is, when you use Quick Save, you overwrite the previous record. If you want to return to the overwritten point, you must play the game from the beginning once again.\n\nWell, let's estimate how long it will take for completing all of the endings in the shortest time.\n\nInput\n\nA data set is given in the following format.\n\nThe first line of the data set contains one integer N (2 \\leq N \\leq 500{,}000), which denotes the number of the endings in this game.\nThe following N-1 lines describe the branching points.\nThe i-th line describes the branching point of ID number i and contains two integers Yes_i and No_i (i + 1 \\leq Yes_i, No_i \\leq N), which denote the ID numbers of the next branching points when you select Yes or No respectively.\nYes_i = N means that you can reach an ending if you select Yes, and so for No_i = N.\nThe branching point with ID 1 is the first branching point.\nThe branching points with ID between 2 and N-1 (inclusive) appear exactly once in Yes_i's and No_i's.\n\nOutput\n\nPrint the shortest time in a line.\n\nSample Input 1\n\n4\n2 3\n4 4\n4 4\n\nOutput for the Sample Input 1\n\n6\n\nSample Input 2\n\n5\n5 2\n3 5\n5 4\n5 5\n\nOutput for the Sample Input 2\n\n8", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2978, "cpu_time_ms": 2150, "memory_kb": 554284}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s608757231", "group_id": "codeNet:p01480", "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 expect(sc: => Scanner): Double = {\n val N = sc.nextInt\n val memo = Array.fill(sc.nextInt)((sc.nextDouble, sc.nextDouble))\n memo.map(A => A._1 * A._2).sum / memo.map(A => A._2).sum\n }\n\n def solve(sc: => Scanner): Unit = {\n println(if (Array.fill(sc.nextInt)(expect(sc)).max - expect(sc) > 0.00000000001) (\"YES\") else (\"NO\"))\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": 1510316074, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01480.html", "problem_id": "p01480", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01480/input.txt", "sample_output_relpath": "derived/input_output/data/p01480/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01480/Scala/s608757231.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s608757231", "user_id": "u018134297"}, "prompt_components": {"gold_output": "YES\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 expect(sc: => Scanner): Double = {\n val N = sc.nextInt\n val memo = Array.fill(sc.nextInt)((sc.nextDouble, sc.nextDouble))\n memo.map(A => A._1 * A._2).sum / memo.map(A => A._2).sum\n }\n\n def solve(sc: => Scanner): Unit = {\n println(if (Array.fill(sc.nextInt)(expect(sc)).max - expect(sc) > 0.00000000001) (\"YES\") else (\"NO\"))\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": "Unequal Dice\n\nTime Limit: 8 sec / Memory Limit: 64 MB\n\nB: 不揃いなサイコロ\n\nパチンコや競馬などの賭け事にお金を使いすぎて,借金まみれになったあなたは,\nT愛グループの地下監獄に収容されてしまった.\nここであなたは,借金を返すまで奴隷のように働かなくてはならない.\n\nまたこの監獄にはあなたと同じ境遇の人が多く収容されているので,\nいくつかの班に分けられている.\nある班では,サイコロを3つ転がしてお椀にいれて楽しむ習慣がある.\n最近,そこの班長が大変な目にあったとかいう話を聞いたが,あなたに直接関係はない.\n\nあなたの所属する班ではひとつのサイコロを振って楽しむ習慣がある.\nルールは,サイコロを振って目の大きな値を出せば勝ちという簡単なものである.\nただ特殊なこととしては,用いられるサイコロのある面が出る確率が,同様に確からしくないということである.\nまたサイコロも種類が多く,10面体のものから100面体のものとさまざまに用意されている.\nさらに何も値の書かれていない面まである.\n何の値も書かれていない面が出たときは,再度振りなおしをする.\n\nこのゲームを仕切っている班長から,あらかじめ振っても良いサイコロをいくつか提示されたのだが,どれを使っても勝てる気がしない時がある.\n\nそこで,与えられたサイコロの内,班長が使うサイコロで出る値の期待値より高いサイコロがあるのかどうか調べたい.\n期待値が高いとは班長のサイコロより,0.0000001より大きい時を指す.\n\nInput\n\n入力は以下の形式で与えられる.\n\nt\nn1 m1\nv1 r1\n...\nvm1 rm1\nn2 m2\n...\nnt mt\nv1 r1\n...\nvmt rmt\np q\nv1 r1\n...\nvq rq\n\n入力の形式に含まれる各変数の意味と制約は以下の通りである.\n\nt は与えられるサイコロの数 t (0 < t <=10)\n\nn は何面体であるのかを表す整数 (4 <= n <= 100)\n\nm は数値の振られている面の数 (0 < m <= n)\n\nvi は面に振られている数値 (0<= v <= 100)\n\nri はその面が出る確率 (0 < r <= 1.0)\n\nr1 + r2 + ... + rm <= 1.0は保証される.\n\nまた ri は小数第10位まで与えられることがある.\n\np は班長の使うサイコロが何面体であるかを表す整数\n\nq は班長の使うサイコロに数値の振られている面の数\n\nOutput\n\n班長の使うサイコロよりも期待値の高いサイコロがあればYES,そうでなければNOを出力せよ.\n\nSample Input 1\n\n2\n4 2\n4 0.4000000\n3 0.5000000\n4 1\n5 0.3333333\n5 3\n5 0.7777777\n4 0.1111111\n2 0.0001111\n\nSample Output 1\n\nYES\n\nSample Input 2\n\n2\n4 2\n4 0.5000000\n3 0.4000000\n4 1\n5 0.3333333\n5 3\n8 0.7777777\n4 0.1111111\n2 0.0001111\n\nSample Output 2\n\nNO", "sample_input": "2\n4 2\n4 0.4000000\n3 0.5000000\n4 1\n5 0.3333333\n5 3\n5 0.7777777\n4 0.1111111\n2 0.0001111\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p01480", "source_text": "Unequal Dice\n\nTime Limit: 8 sec / Memory Limit: 64 MB\n\nB: 不揃いなサイコロ\n\nパチンコや競馬などの賭け事にお金を使いすぎて,借金まみれになったあなたは,\nT愛グループの地下監獄に収容されてしまった.\nここであなたは,借金を返すまで奴隷のように働かなくてはならない.\n\nまたこの監獄にはあなたと同じ境遇の人が多く収容されているので,\nいくつかの班に分けられている.\nある班では,サイコロを3つ転がしてお椀にいれて楽しむ習慣がある.\n最近,そこの班長が大変な目にあったとかいう話を聞いたが,あなたに直接関係はない.\n\nあなたの所属する班ではひとつのサイコロを振って楽しむ習慣がある.\nルールは,サイコロを振って目の大きな値を出せば勝ちという簡単なものである.\nただ特殊なこととしては,用いられるサイコロのある面が出る確率が,同様に確からしくないということである.\nまたサイコロも種類が多く,10面体のものから100面体のものとさまざまに用意されている.\nさらに何も値の書かれていない面まである.\n何の値も書かれていない面が出たときは,再度振りなおしをする.\n\nこのゲームを仕切っている班長から,あらかじめ振っても良いサイコロをいくつか提示されたのだが,どれを使っても勝てる気がしない時がある.\n\nそこで,与えられたサイコロの内,班長が使うサイコロで出る値の期待値より高いサイコロがあるのかどうか調べたい.\n期待値が高いとは班長のサイコロより,0.0000001より大きい時を指す.\n\nInput\n\n入力は以下の形式で与えられる.\n\nt\nn1 m1\nv1 r1\n...\nvm1 rm1\nn2 m2\n...\nnt mt\nv1 r1\n...\nvmt rmt\np q\nv1 r1\n...\nvq rq\n\n入力の形式に含まれる各変数の意味と制約は以下の通りである.\n\nt は与えられるサイコロの数 t (0 < t <=10)\n\nn は何面体であるのかを表す整数 (4 <= n <= 100)\n\nm は数値の振られている面の数 (0 < m <= n)\n\nvi は面に振られている数値 (0<= v <= 100)\n\nri はその面が出る確率 (0 < r <= 1.0)\n\nr1 + r2 + ... + rm <= 1.0は保証される.\n\nまた ri は小数第10位まで与えられることがある.\n\np は班長の使うサイコロが何面体であるかを表す整数\n\nq は班長の使うサイコロに数値の振られている面の数\n\nOutput\n\n班長の使うサイコロよりも期待値の高いサイコロがあればYES,そうでなければNOを出力せよ.\n\nSample Input 1\n\n2\n4 2\n4 0.4000000\n3 0.5000000\n4 1\n5 0.3333333\n5 3\n5 0.7777777\n4 0.1111111\n2 0.0001111\n\nSample Output 1\n\nYES\n\nSample Input 2\n\n2\n4 2\n4 0.5000000\n3 0.4000000\n4 1\n5 0.3333333\n5 3\n8 0.7777777\n4 0.1111111\n2 0.0001111\n\nSample Output 2\n\nNO", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1417, "cpu_time_ms": 410, "memory_kb": 61688}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s257899281", "group_id": "codeNet:p01526", "input_text": "object Main extends App {\n\n import scala.io.StdIn._\n val Array(n, r) = readLine.trim.split(' ').map(_.toDouble)\n val points = Array.fill(n.toInt){\n val Array(x, y) = readLine.trim.split(' ').map(_.toDouble)\n Coordinate(x, y)\n }.sortBy(_.x)\n val uft = new UnionFind(n.toInt)\n merge(points.indices.toArray)\n println(points.indices.count(i ⇒ uft.find(i) == i))\n def merge(rest: Array[Int]): Array[Int] = {\n if (rest.length <= 3) {\n for (i ← rest.indices; j ← 0 until i) {\n if (points(rest(i)).distance(points(rest(j))) <= 2 * r) {\n uft.unite(rest(i), rest(j))\n }\n }\n rest.filter(i ⇒ uft.find(i) == i)\n }else {\n val mid = points(rest(rest.length / 2)).x\n val merged = (merge(rest.take(rest.length / 2)) ++ merge(rest.drop(rest.length / 2))).filter(i ⇒ math.abs(points(i).x - mid) <= 1.1 * r).sortBy(i ⇒ points(i).y)\n if (merged.length >= 2) {\n for (i ← merged.indices.tail) {\n if (points(merged(i)).distance(points(merged(i - 1))) <= 2 * r) uft.unite(merged(i), merged(i - 1))\n }\n }\n rest.filter(i ⇒ uft.find(i) == i)\n }\n }\n}\nclass UnionFind(size: Int) {\n private[this] val parent = Array.fill(size){-1}\n def find(a: Int): Int = {\n if (parent(a) < 0) a\n else {\n parent(a) = find(parent(a))\n parent(a)\n }\n }\n def isSame(a: Int, b: Int): Boolean = find(a) == find(b)\n def unite(a: Int, b: Int): Unit = {\n val ar = find(a)\n val br = find(b)\n if (ar != br) {\n if (parent(ar) < parent(br)) {\n parent(ar) += parent(br)\n parent(br) = ar\n }else {\n parent(br) += parent(ar)\n parent(ar) = br\n }\n }\n }\n}\ncase class Coordinate(x: Double, y: Double) {\n def distance(that: Coordinate): Double = math.sqrt((x - that.x) * (x - that.x) + (y - that.y) * (y - that.y))\n}\n", "language": "Scala", "metadata": {"date": 1568194853, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01526.html", "problem_id": "p01526", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01526/input.txt", "sample_output_relpath": "derived/input_output/data/p01526/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01526/Scala/s257899281.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s257899281", "user_id": "u514597327"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main extends App {\n\n import scala.io.StdIn._\n val Array(n, r) = readLine.trim.split(' ').map(_.toDouble)\n val points = Array.fill(n.toInt){\n val Array(x, y) = readLine.trim.split(' ').map(_.toDouble)\n Coordinate(x, y)\n }.sortBy(_.x)\n val uft = new UnionFind(n.toInt)\n merge(points.indices.toArray)\n println(points.indices.count(i ⇒ uft.find(i) == i))\n def merge(rest: Array[Int]): Array[Int] = {\n if (rest.length <= 3) {\n for (i ← rest.indices; j ← 0 until i) {\n if (points(rest(i)).distance(points(rest(j))) <= 2 * r) {\n uft.unite(rest(i), rest(j))\n }\n }\n rest.filter(i ⇒ uft.find(i) == i)\n }else {\n val mid = points(rest(rest.length / 2)).x\n val merged = (merge(rest.take(rest.length / 2)) ++ merge(rest.drop(rest.length / 2))).filter(i ⇒ math.abs(points(i).x - mid) <= 1.1 * r).sortBy(i ⇒ points(i).y)\n if (merged.length >= 2) {\n for (i ← merged.indices.tail) {\n if (points(merged(i)).distance(points(merged(i - 1))) <= 2 * r) uft.unite(merged(i), merged(i - 1))\n }\n }\n rest.filter(i ⇒ uft.find(i) == i)\n }\n }\n}\nclass UnionFind(size: Int) {\n private[this] val parent = Array.fill(size){-1}\n def find(a: Int): Int = {\n if (parent(a) < 0) a\n else {\n parent(a) = find(parent(a))\n parent(a)\n }\n }\n def isSame(a: Int, b: Int): Boolean = find(a) == find(b)\n def unite(a: Int, b: Int): Unit = {\n val ar = find(a)\n val br = find(b)\n if (ar != br) {\n if (parent(ar) < parent(br)) {\n parent(ar) += parent(br)\n parent(br) = ar\n }else {\n parent(br) += parent(ar)\n parent(ar) = br\n }\n }\n }\n}\ncase class Coordinate(x: Double, y: Double) {\n def distance(that: Coordinate): Double = math.sqrt((x - that.x) * (x - that.x) + (y - that.y) * (y - that.y))\n}\n", "problem_context": "G - 村\n\n問題文\n\nきつねのしえるは,休暇でとある小さな村を訪れている.彼女が驚いたのは,その村の表札がもつ性質である.\n\n村には N 個の家屋がある.ここでは簡単のため,村は 2 次元平面であるとし,家屋はこの平面上の点であると見なす.\nそれぞれの家屋には表札が 1 個設けられており,その家の苗字を表していた.しえるは村の中を訪問するにつれて,この村の表札が次のような性質を持っていることに気付いた.\n\nある実数 R が存在する.\n\nもし 2 つの家屋の距離が R 以下であるなら,その 2 つの家屋は同じ表札を持つ.\n\nもし 2 つの家屋の距離が 3R 以上であるなら,その 2 つの家屋は異なる表札を持つ.\n\n任意の 2 つの家屋の距離は R 以下であるか 3R 以上であるかのどちらかである.\n\nここで,家屋同士の距離は,平面上のユークリッド距離によって計測するものとする.\n\nしえるはこの村に表札が全部で何種類あるのかが気になったが,この村は意外に広いということに気付いたので,計算機を使ってこの答えを模索することにした.\n\n入力形式\n\n入力は以下の形式で与えられる.\n\nN R\nx1 y1\nx2 y2\n...\nxN yN\n\nN は家屋の個数である.R は家屋の配置の制約に関する値である.\n(xi, yi) は家屋 i の座標を表す.\n\n出力形式\n\n村に存在する表札の種類の数を求めよ.\n\n制約\n\n1 ≤ N ≤ 2 × 105\n\n1 ≤ R ≤ 103\n\n|xi|, |yi| ≤ 106\n\nN は整数である.R, xi, yi は実数で,小数第 3 位まで表される.\n\n任意の 1 ≤ i < j ≤ N に対して dij = √{(xi - xj)2 + (yi - yj)2} とおくとき,dij ≤ R か 3R ≤ dij のどちらかが満たされる.\n\nこの問題の判定には,15 点分のテストケースのグループが設定されている. このグループに含まれるテストケースは上記の制約に加えて下記の制約も満たす.\n\n答えは 10 以下である.\n\n入出力例\n\n入力例 1\n\n5 3.000\n1.000 0.000\n0.000 0.000\n-1.000 0.000\n10.000 0.000\n-10.000 0.000\n\n出力例 1\n\n3\n\n家屋 1,2,3 と家屋 4 と家屋 5 で表札が異なる.全体で 3 つの表札が存在する.\n\n入力例 2\n\n12 1.234\n0.500 0.000\n-0.500 0.000\n0.000 0.000\n0.000 -0.500\n55.500 55.000\n-55.500 55.000\n55.000 55.000\n55.000 -55.500\n99.500 99.000\n-99.500 99.000\n99.000 99.000\n99.000 -99.500\n\n出力例 2\n\n7\n\n入力例 3\n\n5 99.999\n0.000 0.000\n49.999 0.001\n0.000 0.000\n-49.999 -0.001\n0.000 0.000\n\n出力例 3\n\n1\n\nWriter: 楠本充\nTester: 小浜翔太郎", "sample_input": "5 3.000\n1.000 0.000\n0.000 0.000\n-1.000 0.000\n10.000 0.000\n-10.000 0.000\n"}, "reference_outputs": ["3\n"], "source_document_id": "p01526", "source_text": "G - 村\n\n問題文\n\nきつねのしえるは,休暇でとある小さな村を訪れている.彼女が驚いたのは,その村の表札がもつ性質である.\n\n村には N 個の家屋がある.ここでは簡単のため,村は 2 次元平面であるとし,家屋はこの平面上の点であると見なす.\nそれぞれの家屋には表札が 1 個設けられており,その家の苗字を表していた.しえるは村の中を訪問するにつれて,この村の表札が次のような性質を持っていることに気付いた.\n\nある実数 R が存在する.\n\nもし 2 つの家屋の距離が R 以下であるなら,その 2 つの家屋は同じ表札を持つ.\n\nもし 2 つの家屋の距離が 3R 以上であるなら,その 2 つの家屋は異なる表札を持つ.\n\n任意の 2 つの家屋の距離は R 以下であるか 3R 以上であるかのどちらかである.\n\nここで,家屋同士の距離は,平面上のユークリッド距離によって計測するものとする.\n\nしえるはこの村に表札が全部で何種類あるのかが気になったが,この村は意外に広いということに気付いたので,計算機を使ってこの答えを模索することにした.\n\n入力形式\n\n入力は以下の形式で与えられる.\n\nN R\nx1 y1\nx2 y2\n...\nxN yN\n\nN は家屋の個数である.R は家屋の配置の制約に関する値である.\n(xi, yi) は家屋 i の座標を表す.\n\n出力形式\n\n村に存在する表札の種類の数を求めよ.\n\n制約\n\n1 ≤ N ≤ 2 × 105\n\n1 ≤ R ≤ 103\n\n|xi|, |yi| ≤ 106\n\nN は整数である.R, xi, yi は実数で,小数第 3 位まで表される.\n\n任意の 1 ≤ i < j ≤ N に対して dij = √{(xi - xj)2 + (yi - yj)2} とおくとき,dij ≤ R か 3R ≤ dij のどちらかが満たされる.\n\nこの問題の判定には,15 点分のテストケースのグループが設定されている. このグループに含まれるテストケースは上記の制約に加えて下記の制約も満たす.\n\n答えは 10 以下である.\n\n入出力例\n\n入力例 1\n\n5 3.000\n1.000 0.000\n0.000 0.000\n-1.000 0.000\n10.000 0.000\n-10.000 0.000\n\n出力例 1\n\n3\n\n家屋 1,2,3 と家屋 4 と家屋 5 で表札が異なる.全体で 3 つの表札が存在する.\n\n入力例 2\n\n12 1.234\n0.500 0.000\n-0.500 0.000\n0.000 0.000\n0.000 -0.500\n55.500 55.000\n-55.500 55.000\n55.000 55.000\n55.000 -55.500\n99.500 99.000\n-99.500 99.000\n99.000 99.000\n99.000 -99.500\n\n出力例 2\n\n7\n\n入力例 3\n\n5 99.999\n0.000 0.000\n49.999 0.001\n0.000 0.000\n-49.999 -0.001\n0.000 0.000\n\n出力例 3\n\n1\n\nWriter: 楠本充\nTester: 小浜翔太郎", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1855, "cpu_time_ms": 3110, "memory_kb": 482720}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s221745540", "group_id": "codeNet:p01555", "input_text": "import scala.annotation.tailrec\nimport scala.collection.{immutable, mutable}\n\n\nobject Main extends App {\n\n import scala.io.StdIn._\n\n val idx = readLong()\n var min = 1L\n var max = idx\n while (min < max) {\n val mid = (min + max) / 2\n if (calDigitUnder(mid) < idx) min = mid + 1\n else max = mid\n }\n val rest = idx - calDigitUnder(min - 1) - 1\n println(toSequence(min, min + 20).substring(rest.toInt, rest.toInt + 20))\n def toSequence(from: Long, until: Long): String = {\n (from until until).map{\n case n if n % 15 == 0 ⇒ \"FizzBuzz\"\n case n if n % 3 == 0 ⇒ \"Fizz\"\n case n if n % 5 == 0 ⇒ \"Buzz\"\n case n ⇒ n.toString\n }.mkString(\"\")\n }\n\n def calDigitJustDigit(digit: Int): Long = {\n val value = power(10, digit) - 1\n val nonStr = value - value / 3 - value / 5 + value / 15\n val underValue = value / 10\n val underNonStr = underValue - underValue / 3 - underValue / 5 + underValue / 15\n (nonStr - underNonStr) * digit + (value / 3 - underValue / 3) * 4 + (value / 5 - underValue / 5) * 4\n }\n\n def calDigitUnder(number: Long): Long = {\n val digit = calDigit(number)\n val under = power(10, digit - 1) - 1\n val underDigit = (1 until digit).map(calDigitJustDigit).sum\n val underStr = under / 3 + under / 5 - under / 15\n val str = number / 3 + number / 5 - number / 15 - underStr\n val nonStr = number - under - str\n underDigit + nonStr * digit + (number / 3 - under / 3 + number / 5 - under / 5) * 4\n }\n\n def calDigit(number: Long): Int = {\n if (number < 10) 1 else 1 + calDigit(number / 10)\n }\n\n def power(base: Long, exp: Int): Long = {\n exp match {\n case 0 ⇒ 1L\n case 1 ⇒ base\n case _ ⇒ power(base * base, exp / 2) * power(base, exp % 2)\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1573278047, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01555.html", "problem_id": "p01555", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01555/input.txt", "sample_output_relpath": "derived/input_output/data/p01555/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01555/Scala/s221745540.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s221745540", "user_id": "u514597327"}, "prompt_components": {"gold_output": "12Fizz4BuzzFizz78Fiz\n", "input_to_evaluate": "import scala.annotation.tailrec\nimport scala.collection.{immutable, mutable}\n\n\nobject Main extends App {\n\n import scala.io.StdIn._\n\n val idx = readLong()\n var min = 1L\n var max = idx\n while (min < max) {\n val mid = (min + max) / 2\n if (calDigitUnder(mid) < idx) min = mid + 1\n else max = mid\n }\n val rest = idx - calDigitUnder(min - 1) - 1\n println(toSequence(min, min + 20).substring(rest.toInt, rest.toInt + 20))\n def toSequence(from: Long, until: Long): String = {\n (from until until).map{\n case n if n % 15 == 0 ⇒ \"FizzBuzz\"\n case n if n % 3 == 0 ⇒ \"Fizz\"\n case n if n % 5 == 0 ⇒ \"Buzz\"\n case n ⇒ n.toString\n }.mkString(\"\")\n }\n\n def calDigitJustDigit(digit: Int): Long = {\n val value = power(10, digit) - 1\n val nonStr = value - value / 3 - value / 5 + value / 15\n val underValue = value / 10\n val underNonStr = underValue - underValue / 3 - underValue / 5 + underValue / 15\n (nonStr - underNonStr) * digit + (value / 3 - underValue / 3) * 4 + (value / 5 - underValue / 5) * 4\n }\n\n def calDigitUnder(number: Long): Long = {\n val digit = calDigit(number)\n val under = power(10, digit - 1) - 1\n val underDigit = (1 until digit).map(calDigitJustDigit).sum\n val underStr = under / 3 + under / 5 - under / 15\n val str = number / 3 + number / 5 - number / 15 - underStr\n val nonStr = number - under - str\n underDigit + nonStr * digit + (number / 3 - under / 3 + number / 5 - under / 5) * 4\n }\n\n def calDigit(number: Long): Int = {\n if (number < 10) 1 else 1 + calDigit(number / 10)\n }\n\n def power(base: Long, exp: Int): Long = {\n exp match {\n case 0 ⇒ 1L\n case 1 ⇒ base\n case _ ⇒ power(base * base, exp / 2) * power(base, exp % 2)\n }\n }\n}\n", "problem_context": "FizzBuzz\n\nFizzBuzzとは、1以上の整数を順に、以下のルールに従って発言していくゲームである。\n\n3で割り切れる時には「Fizz」\n\n5で割り切れる時には「Buzz」\n\n3と5の両方で割り切れる時には「FizzBuzz」\n\nそれ以外の時はその数字\n\nゲームの進行状況の例を以下に示す。\n\n1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, FizzBuzz, 16, …\n\n得られた発言を1つの文字列に結合し得られた文字列をFizzBuzz Stringと呼ぶ。インデックスsが与えられるので、FizzBuzz Stringのs文字目から20文字を出力せよ。但し、インデックスは1から始まるものとし、得られた文字列の長さは十分に大きい(s+20以上)としてよい。\n\nInput\n\n入力は以下の形式で与えられる\n\ns\n\nConstraints\n\nsは整数である\n\n1 ≤ s ≤ 1018\n\nOutput\n\nFizzBuzz Stringのs文字目から20文字を1行に出力せよ\n\nSample Input 1\n\n1\n\nOutput for the Sample Input 1\n\n12Fizz4BuzzFizz78Fiz\n\nSample Input 2\n\n20\n\nOutput for the Sample Input 2\n\nzzBuzz11Fizz1314Fizz\n\nSample Input 3\n\n10000000000\n\nOutput for the Sample Input 3\n\n93FizzBuzz1418650796", "sample_input": "1\n"}, "reference_outputs": ["12Fizz4BuzzFizz78Fiz\n"], "source_document_id": "p01555", "source_text": "FizzBuzz\n\nFizzBuzzとは、1以上の整数を順に、以下のルールに従って発言していくゲームである。\n\n3で割り切れる時には「Fizz」\n\n5で割り切れる時には「Buzz」\n\n3と5の両方で割り切れる時には「FizzBuzz」\n\nそれ以外の時はその数字\n\nゲームの進行状況の例を以下に示す。\n\n1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, FizzBuzz, 16, …\n\n得られた発言を1つの文字列に結合し得られた文字列をFizzBuzz Stringと呼ぶ。インデックスsが与えられるので、FizzBuzz Stringのs文字目から20文字を出力せよ。但し、インデックスは1から始まるものとし、得られた文字列の長さは十分に大きい(s+20以上)としてよい。\n\nInput\n\n入力は以下の形式で与えられる\n\ns\n\nConstraints\n\nsは整数である\n\n1 ≤ s ≤ 1018\n\nOutput\n\nFizzBuzz Stringのs文字目から20文字を1行に出力せよ\n\nSample Input 1\n\n1\n\nOutput for the Sample Input 1\n\n12Fizz4BuzzFizz78Fiz\n\nSample Input 2\n\n20\n\nOutput for the Sample Input 2\n\nzzBuzz11Fizz1314Fizz\n\nSample Input 3\n\n10000000000\n\nOutput for the Sample Input 3\n\n93FizzBuzz1418650796", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1764, "cpu_time_ms": 340, "memory_kb": 44664}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s721943681", "group_id": "codeNet:p01600", "input_text": "import scala.io.StdIn._\nobject Main extends App {\n val n = readInt()\n val points = Array.tabulate(n){_ ⇒\n val Array(x, y) = readLine.trim.split(' ').map(_.toInt)\n Point(x, y)\n }\n val memo = Array.tabulate(n){i ⇒ Array.fill(n - i){-1}}\n for (i ← 1 until n / 100) minTree(points, 0, i * 100)(memo)\n println(minTree(points, 0, n)(memo))\n def minTree(points: Array[Point], from: Int, until: Int)(implicit memo: Array[Array[Int]]): Int = {\n if (from + 1 == until) {\n 0\n }else if (until - from == 2) {\n minTree(points(from), points(from + 1))\n }else {\n if (memo(from)(until - from - 1) < 0) {\n memo(from)(until - from - 1) = (from + 1 until until).map{mid ⇒ minTree(points, from, mid) + minTree(root(points, from, mid), root(points, mid, until)) + minTree(points, mid, until)}.min\n }\n memo(from)(until - from - 1)\n }\n }\n def minTree(a: Point, b: Point, c: Point): Int = {\n Math.min(minTree(root(a, b), c) + minTree(a, b), minTree(a, root(b, c)) + minTree(b, c))\n }\n def minTree(a: Point, b: Point): Int = {\n b.x - a.x + a.y - b.y\n }\n def root(points: Array[Point], from: Int, until: Int): Point = root(points(from), points(until - 1))\n def root(a: Point, b: Point): Point = {\n Point(a.x, b.y)\n }\n}\n\ncase class Point(x: Int, y: Int)\n", "language": "Scala", "metadata": {"date": 1563000454, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01600.html", "problem_id": "p01600", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01600/input.txt", "sample_output_relpath": "derived/input_output/data/p01600/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01600/Scala/s721943681.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s721943681", "user_id": "u514597327"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "import scala.io.StdIn._\nobject Main extends App {\n val n = readInt()\n val points = Array.tabulate(n){_ ⇒\n val Array(x, y) = readLine.trim.split(' ').map(_.toInt)\n Point(x, y)\n }\n val memo = Array.tabulate(n){i ⇒ Array.fill(n - i){-1}}\n for (i ← 1 until n / 100) minTree(points, 0, i * 100)(memo)\n println(minTree(points, 0, n)(memo))\n def minTree(points: Array[Point], from: Int, until: Int)(implicit memo: Array[Array[Int]]): Int = {\n if (from + 1 == until) {\n 0\n }else if (until - from == 2) {\n minTree(points(from), points(from + 1))\n }else {\n if (memo(from)(until - from - 1) < 0) {\n memo(from)(until - from - 1) = (from + 1 until until).map{mid ⇒ minTree(points, from, mid) + minTree(root(points, from, mid), root(points, mid, until)) + minTree(points, mid, until)}.min\n }\n memo(from)(until - from - 1)\n }\n }\n def minTree(a: Point, b: Point, c: Point): Int = {\n Math.min(minTree(root(a, b), c) + minTree(a, b), minTree(a, root(b, c)) + minTree(b, c))\n }\n def minTree(a: Point, b: Point): Int = {\n b.x - a.x + a.y - b.y\n }\n def root(points: Array[Point], from: Int, until: Int): Point = root(points(from), points(until - 1))\n def root(a: Point, b: Point): Point = {\n Point(a.x, b.y)\n }\n}\n\ncase class Point(x: Int, y: Int)\n", "problem_context": "Problem J: Tree Construction\n\nConsider a two-dimensional space with a set of points (xi,\nyi) that satisfy xi < xj\nand yi > yj for all i < j.\nWe want to have them all connected by a directed tree whose edges go toward\neither right (x positive) or upward (y positive). The\nfigure below shows an example tree.\n\nFigure 1: An example tree\n\nWrite a program that finds a tree connecting all given points with the\nshortest total length of edges.\n\nInput\n\nThe input begins with a line that contains an integer n (1 <=\nn <= 1000), the number of points. Then n lines follow. The\ni-th line contains two integers xi and yi\n(0 <= xi, yi <= 10000), which give\nthe coordinates of the i-th point.\n\nOutput\n\nPrint the total length of edges in a line.\n\nSample Input 1\n\n5\n1 5\n2 4\n3 3\n4 2\n5 1\n\nOutput for the Sample Input 1\n\n12\n\nSample Input 2\n\n1\n10000 0\n\nOutput for the Sample Input 2\n\n0", "sample_input": "5\n1 5\n2 4\n3 3\n4 2\n5 1\n"}, "reference_outputs": ["12\n"], "source_document_id": "p01600", "source_text": "Problem J: Tree Construction\n\nConsider a two-dimensional space with a set of points (xi,\nyi) that satisfy xi < xj\nand yi > yj for all i < j.\nWe want to have them all connected by a directed tree whose edges go toward\neither right (x positive) or upward (y positive). The\nfigure below shows an example tree.\n\nFigure 1: An example tree\n\nWrite a program that finds a tree connecting all given points with the\nshortest total length of edges.\n\nInput\n\nThe input begins with a line that contains an integer n (1 <=\nn <= 1000), the number of points. Then n lines follow. The\ni-th line contains two integers xi and yi\n(0 <= xi, yi <= 10000), which give\nthe coordinates of the i-th point.\n\nOutput\n\nPrint the total length of edges in a line.\n\nSample Input 1\n\n5\n1 5\n2 4\n3 3\n4 2\n5 1\n\nOutput for the Sample Input 1\n\n12\n\nSample Input 2\n\n1\n10000 0\n\nOutput for the Sample Input 2\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1308, "cpu_time_ms": 6680, "memory_kb": 593304}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s262501841", "group_id": "codeNet:p01601", "input_text": "object Main extends App {\n\n import scala.io.StdIn._\n import scala.math._\n val n = readLine.trim\n println(search(n))\n def search(number: String): Int = {\n def toPalindrone(number: String, digit: Int): Int = {\n (number + number.reverse.takeRight(digit - number.length)).toInt\n }\n List(toPalindrone(number.dropRight(number.length / 2), number.length),\n toPalindrone((number.dropRight(number.length / 2).toInt + 1).toString,number.length),\n toPalindrone((number.dropRight(number.length / 2).toInt - 1).toString, number.length)).sorted.minBy(i ⇒ math.abs(i - number.toInt))\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": 1545638575, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01601.html", "problem_id": "p01601", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01601/input.txt", "sample_output_relpath": "derived/input_output/data/p01601/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01601/Scala/s262501841.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s262501841", "user_id": "u514597327"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "object Main extends App {\n\n import scala.io.StdIn._\n import scala.math._\n val n = readLine.trim\n println(search(n))\n def search(number: String): Int = {\n def toPalindrone(number: String, digit: Int): Int = {\n (number + number.reverse.takeRight(digit - number.length)).toInt\n }\n List(toPalindrone(number.dropRight(number.length / 2), number.length),\n toPalindrone((number.dropRight(number.length / 2).toInt + 1).toString,number.length),\n toPalindrone((number.dropRight(number.length / 2).toInt - 1).toString, number.length)).sorted.minBy(i ⇒ math.abs(i - number.toInt))\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": "回文数\n\nProblem Statement\n\n整数nに最も近い回文数を求めよ.\n\nなお,非負整数xが回文数であるとは,xを十進法で表現した文字列とそれを反転させた文字列が等しいことをいう.\n\n例えば0,7,33,10301などは回文数であり,32,90,1010などは回文数でない.\n\nInput\n\n入力は以下の形式に従う.与えられる数は全て整数である.\n\nn\n\nConstraints\n\n1≦n≦10^4\n\nOutput\n\nnに最も近い回文数を出力せよ.\n\nそのような数が複数ある場合は最も小さいものを出力せよ.\n\nSample Input 1\n\n13\n\nOutput for the Sample Input 1\n\n11\n\n13に最も近い回文数は11である.\n\nSample Input 2\n\n7447\n\nOutput for the Sample Input 2\n\n7447\n\n7447は回文数なのでそのまま出力すればよい.\n\nSample Input 3\n\n106\n\nOutput for the Sample Input 3\n\n101\n\n106に最も近い回文数は111と101のふたつあるが,そのうち小さい方の101を出力する.", "sample_input": "13\n"}, "reference_outputs": ["11\n"], "source_document_id": "p01601", "source_text": "回文数\n\nProblem Statement\n\n整数nに最も近い回文数を求めよ.\n\nなお,非負整数xが回文数であるとは,xを十進法で表現した文字列とそれを反転させた文字列が等しいことをいう.\n\n例えば0,7,33,10301などは回文数であり,32,90,1010などは回文数でない.\n\nInput\n\n入力は以下の形式に従う.与えられる数は全て整数である.\n\nn\n\nConstraints\n\n1≦n≦10^4\n\nOutput\n\nnに最も近い回文数を出力せよ.\n\nそのような数が複数ある場合は最も小さいものを出力せよ.\n\nSample Input 1\n\n13\n\nOutput for the Sample Input 1\n\n11\n\n13に最も近い回文数は11である.\n\nSample Input 2\n\n7447\n\nOutput for the Sample Input 2\n\n7447\n\n7447は回文数なのでそのまま出力すればよい.\n\nSample Input 3\n\n106\n\nOutput for the Sample Input 3\n\n101\n\n106に最も近い回文数は111と101のふたつあるが,そのうち小さい方の101を出力する.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 270, "memory_kb": 44000}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s301076366", "group_id": "codeNet:p01636", "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 check(a: Long, b: Long): Boolean = {\n if ((a + b) % 2 == 0 && (a + b) / 2 >= 0 && b - (a + b) / 2 >= 0) (true) else (false)\n }\n\n def solve(sc: => Scanner): Unit = {\n val A = sc.nextLong()\n var i = 1L\n var ans = 0\n while (i <= A * 10) {\n if ((A % i * 10 >= i) && check(A / i, A % i)) {\n ans += 1\n }\n i *= 10\n }\n println(ans)\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": 1511010357, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01636.html", "problem_id": "p01636", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01636/input.txt", "sample_output_relpath": "derived/input_output/data/p01636/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01636/Scala/s301076366.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s301076366", "user_id": "u018134297"}, "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.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 check(a: Long, b: Long): Boolean = {\n if ((a + b) % 2 == 0 && (a + b) / 2 >= 0 && b - (a + b) / 2 >= 0) (true) else (false)\n }\n\n def solve(sc: => Scanner): Unit = {\n val A = sc.nextLong()\n var i = 1L\n var ans = 0\n while (i <= A * 10) {\n if ((A % i * 10 >= i) && check(A / i, A % i)) {\n ans += 1\n }\n i *= 10\n }\n println(ans)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}", "problem_context": "MathJax.Hub.Config({\ntex2jax: { inlineMath: [['\\\\(','\\\\)']] }\n});\n\nProblem C: Mysterious Operator\n\nケー氏がいつものように某SNSを閲覧していると、\n「解ける人はIQ150以上ある」という問題がタイムラインに流れてきた。\nケー氏はIQが150以上あるので、見るまでもなくその問題を一瞬で解いてしまった。\n彼にしてみれば、このような問題なぞに頭を働かせる必要は無い。 コンピュータに任せれば充分なのである。\n\n問題\n\n問題には以下のような謎の数式が書かれていた。\n\n\\( 5 + 3 = 28 \\)\n\n\\( 9 + 1 = 810 \\)\n\n\\(8 + 6 = 214 \\)\n\n\\( 5 + 4 = 19 \\)\n\n\\( 2 + 2 = 4 \\)\n\n\\( 15 + 8 = 723 \\)\n\n\\( 7 + 9 = -216 \\)\n\n\\( 3 + 0 = 33 \\)\n\n上記の演算子\\( + \\)について考えた時、ある正整数\\( a \\)について\\( x \\geq 0, y \\geq 0 \\)かつ\\( x + y = a \\)になるような整数のペア\\( x,y \\)の個数を求めよ。\n\n入力\n\n正整数\\(a\\)が一行で与えられる。\n\n出力\n\n\\( a = x + y, x \\geq 0, y \\geq 0\\)を満たすペア\\((x,y)\\)の個数を一行に出力せよ。\n\n制約\n\n\\( 1 \\leq a \\leq 10^9(= 1000000000) \\)\n\n入出力例\n\n入力1\n\n19\n\n出力1\n\n1\n\n\\( 5 + 4 \\)の1通りである。\n\n入力2\n\n22\n\n出力2\n\n2\n\n\\( 11 + 11 \\)と、\\( 2 + 0 \\)の2通りが存在する。\n\n入力3\n\n1\n\n出力3\n\n0\n\n\\( 1 + 0 = 11 , 0 + 1 = -11 \\)である。\\( 1 \\)は生成することができない。\n\n入力4\n\n101\n\n出力4\n\n0\n\n\\( 1 - 0 \\)は\\( 101 \\)ではないことに注意すること。\n\n入力5\n\n660233276\n\n出力5\n\n4", "sample_input": "19\n"}, "reference_outputs": ["1\n"], "source_document_id": "p01636", "source_text": "MathJax.Hub.Config({\ntex2jax: { inlineMath: [['\\\\(','\\\\)']] }\n});\n\nProblem C: Mysterious Operator\n\nケー氏がいつものように某SNSを閲覧していると、\n「解ける人はIQ150以上ある」という問題がタイムラインに流れてきた。\nケー氏はIQが150以上あるので、見るまでもなくその問題を一瞬で解いてしまった。\n彼にしてみれば、このような問題なぞに頭を働かせる必要は無い。 コンピュータに任せれば充分なのである。\n\n問題\n\n問題には以下のような謎の数式が書かれていた。\n\n\\( 5 + 3 = 28 \\)\n\n\\( 9 + 1 = 810 \\)\n\n\\(8 + 6 = 214 \\)\n\n\\( 5 + 4 = 19 \\)\n\n\\( 2 + 2 = 4 \\)\n\n\\( 15 + 8 = 723 \\)\n\n\\( 7 + 9 = -216 \\)\n\n\\( 3 + 0 = 33 \\)\n\n上記の演算子\\( + \\)について考えた時、ある正整数\\( a \\)について\\( x \\geq 0, y \\geq 0 \\)かつ\\( x + y = a \\)になるような整数のペア\\( x,y \\)の個数を求めよ。\n\n入力\n\n正整数\\(a\\)が一行で与えられる。\n\n出力\n\n\\( a = x + y, x \\geq 0, y \\geq 0\\)を満たすペア\\((x,y)\\)の個数を一行に出力せよ。\n\n制約\n\n\\( 1 \\leq a \\leq 10^9(= 1000000000) \\)\n\n入出力例\n\n入力1\n\n19\n\n出力1\n\n1\n\n\\( 5 + 4 \\)の1通りである。\n\n入力2\n\n22\n\n出力2\n\n2\n\n\\( 11 + 11 \\)と、\\( 2 + 0 \\)の2通りが存在する。\n\n入力3\n\n1\n\n出力3\n\n0\n\n\\( 1 + 0 = 11 , 0 + 1 = -11 \\)である。\\( 1 \\)は生成することができない。\n\n入力4\n\n101\n\n出力4\n\n0\n\n\\( 1 - 0 \\)は\\( 101 \\)ではないことに注意すること。\n\n入力5\n\n660233276\n\n出力5\n\n4", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1446, "cpu_time_ms": 280, "memory_kb": 45076}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s449435175", "group_id": "codeNet:p01657", "input_text": "object Main extends App {\n\n import scala.io.StdIn._\n import scala.math._\n\n val Array(n, x, m) = readLine.trim.split(' ').map(_.toInt)\n val gages = Array.tabulate(n + 1){_ ⇒ new Gage}\n for (_ ← 0 until m){\n val Array(l, r, s) = readLine.trim.split(' ').map(_.toInt)\n gages(l - 1).addRelation(r, s)\n gages(r).addRelation(l - 1, -s)\n }\n implicit val suspect = Array.tabulate(n + 1){_ ⇒ None: Option[Position]}\n var counter = 0\n val isNonParadoxical = (for (i ← suspect.indices) yield {\n suspect(i) match {\n case None ⇒\n suspect(i) = Some(Absolute(counter))\n counter += 1\n searchSub(gages, suspect, i)\n case _ ⇒ true\n }\n }).forall(i ⇒ i)\n\n val nonOptionalSuspects = suspect.flatten\n val rangesOfOrigin = Array.tabulate(counter){_ ⇒ Nil: List[(Int, Int)]}.also{arr ⇒\n for (i ← 1 until arr.length){\n // i - x <= 0\n // 0 - 0 <= i\n arr(0) ::= (i, x * i)\n arr(i) ::= (0, 0)\n }}\n for (i ← 1 to n){\n val left = nonOptionalSuspects(i - 1)\n val right = nonOptionalSuspects(i)\n val (lOrient, lDiff) = left match {\n case Absolute(id) ⇒ (id, 0)\n case Relation(orient, diff) ⇒ (nonOptionalSuspects(orient).asInstanceOf[Absolute].id, diff)\n }\n val (rOrient, rDiff) = right match {\n case Absolute(id) ⇒ (id, 0)\n case Relation(orient, diff) ⇒ (nonOptionalSuspects(orient).asInstanceOf[Absolute].id, diff)\n }\n // 0 <= rOrient + rDiff - lOrient - lDiff <= x\n //lOrient <= rOrient + rDiff - lDiff\n //rOrient <= lOrient + lDiff - rDiff + x\n rangesOfOrigin(rOrient) ::= (lOrient, rDiff - lDiff)\n rangesOfOrigin(lOrient) ::= (rOrient, lDiff - rDiff + x)\n }\n val memo = Array.tabulate(counter){_ ⇒ Int.MaxValue.toLong}.also{_(0) = 0L}\n var isChanged = false\n for (_ ← 0 to counter){\n isChanged = false\n for (from ← rangesOfOrigin.indices){\n for ((to, diff) ← rangesOfOrigin(from)){\n if (memo(from) + diff < memo(to)){\n isChanged = true\n memo(to) = memo(from) + diff\n }\n }\n }\n }\n val res = nonOptionalSuspects.map{\n case Absolute(id) ⇒ memo(id)\n case Relation(orient, diff) ⇒ memo(nonOptionalSuspects(orient).asInstanceOf[Absolute].id) + diff\n }.let{arr ⇒ for (i ← 1 until arr.length) yield {arr(i) - arr(i - 1)}}\n println(\n if (!isNonParadoxical || res.exists(i ⇒ i < 0 || x < i) || isChanged) -1\n else {\n res.mkString(\" \")\n }\n )\n\n def searchSub(gages: Array[Gage], suspects: Array[Option[Position]], current: Int): Boolean = {\n val (orient, diff) = suspects(current) match {\n case Some(Absolute(_)) ⇒ (current, 0)\n case Some(Relation(o, d)) ⇒ (o, d)\n case None ⇒ ???\n }\n (for (relation ← gages(current).relations) yield {\n suspects(relation.orient) match {\n case Some(r@Relation(_, _)) ⇒ orient == r.orient && diff + relation.diff == r.diff\n case Some(Absolute(_)) ⇒ relation.orient == orient && diff + relation.diff == 0\n case None ⇒\n suspects(relation.orient) = Some(Relation(orient, diff + relation.diff))\n searchSub(gages, suspects, relation.orient)\n }\n }).let{it ⇒ it.isEmpty || it.forall(i ⇒ i)}\n }\n sealed trait Position {\n def getAbsolute(implicit s: Array[Option[Position]]): Option[Int] = {\n this match {\n case Absolute(_) ⇒ Option(0)\n case Relation(orient, diff) ⇒ s(orient).flatMap{_.getAbsolute(s).map{_ + diff}}\n }\n }\n }\n case class Relation(orient: Int, diff: Int) extends Position\n case class Absolute(id: Int) extends Position\n class Gage{\n private var mRelations: List[Relation] = Nil\n def addRelation(to: Int, diff: Int): Unit = {\n mRelations ::= Relation(to, diff)\n }\n def relations: List[Relation] = mRelations\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}\n", "language": "Scala", "metadata": {"date": 1545272036, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01657.html", "problem_id": "p01657", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01657/input.txt", "sample_output_relpath": "derived/input_output/data/p01657/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01657/Scala/s449435175.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s449435175", "user_id": "u514597327"}, "prompt_components": {"gold_output": "2 3 5\n", "input_to_evaluate": "object Main extends App {\n\n import scala.io.StdIn._\n import scala.math._\n\n val Array(n, x, m) = readLine.trim.split(' ').map(_.toInt)\n val gages = Array.tabulate(n + 1){_ ⇒ new Gage}\n for (_ ← 0 until m){\n val Array(l, r, s) = readLine.trim.split(' ').map(_.toInt)\n gages(l - 1).addRelation(r, s)\n gages(r).addRelation(l - 1, -s)\n }\n implicit val suspect = Array.tabulate(n + 1){_ ⇒ None: Option[Position]}\n var counter = 0\n val isNonParadoxical = (for (i ← suspect.indices) yield {\n suspect(i) match {\n case None ⇒\n suspect(i) = Some(Absolute(counter))\n counter += 1\n searchSub(gages, suspect, i)\n case _ ⇒ true\n }\n }).forall(i ⇒ i)\n\n val nonOptionalSuspects = suspect.flatten\n val rangesOfOrigin = Array.tabulate(counter){_ ⇒ Nil: List[(Int, Int)]}.also{arr ⇒\n for (i ← 1 until arr.length){\n // i - x <= 0\n // 0 - 0 <= i\n arr(0) ::= (i, x * i)\n arr(i) ::= (0, 0)\n }}\n for (i ← 1 to n){\n val left = nonOptionalSuspects(i - 1)\n val right = nonOptionalSuspects(i)\n val (lOrient, lDiff) = left match {\n case Absolute(id) ⇒ (id, 0)\n case Relation(orient, diff) ⇒ (nonOptionalSuspects(orient).asInstanceOf[Absolute].id, diff)\n }\n val (rOrient, rDiff) = right match {\n case Absolute(id) ⇒ (id, 0)\n case Relation(orient, diff) ⇒ (nonOptionalSuspects(orient).asInstanceOf[Absolute].id, diff)\n }\n // 0 <= rOrient + rDiff - lOrient - lDiff <= x\n //lOrient <= rOrient + rDiff - lDiff\n //rOrient <= lOrient + lDiff - rDiff + x\n rangesOfOrigin(rOrient) ::= (lOrient, rDiff - lDiff)\n rangesOfOrigin(lOrient) ::= (rOrient, lDiff - rDiff + x)\n }\n val memo = Array.tabulate(counter){_ ⇒ Int.MaxValue.toLong}.also{_(0) = 0L}\n var isChanged = false\n for (_ ← 0 to counter){\n isChanged = false\n for (from ← rangesOfOrigin.indices){\n for ((to, diff) ← rangesOfOrigin(from)){\n if (memo(from) + diff < memo(to)){\n isChanged = true\n memo(to) = memo(from) + diff\n }\n }\n }\n }\n val res = nonOptionalSuspects.map{\n case Absolute(id) ⇒ memo(id)\n case Relation(orient, diff) ⇒ memo(nonOptionalSuspects(orient).asInstanceOf[Absolute].id) + diff\n }.let{arr ⇒ for (i ← 1 until arr.length) yield {arr(i) - arr(i - 1)}}\n println(\n if (!isNonParadoxical || res.exists(i ⇒ i < 0 || x < i) || isChanged) -1\n else {\n res.mkString(\" \")\n }\n )\n\n def searchSub(gages: Array[Gage], suspects: Array[Option[Position]], current: Int): Boolean = {\n val (orient, diff) = suspects(current) match {\n case Some(Absolute(_)) ⇒ (current, 0)\n case Some(Relation(o, d)) ⇒ (o, d)\n case None ⇒ ???\n }\n (for (relation ← gages(current).relations) yield {\n suspects(relation.orient) match {\n case Some(r@Relation(_, _)) ⇒ orient == r.orient && diff + relation.diff == r.diff\n case Some(Absolute(_)) ⇒ relation.orient == orient && diff + relation.diff == 0\n case None ⇒\n suspects(relation.orient) = Some(Relation(orient, diff + relation.diff))\n searchSub(gages, suspects, relation.orient)\n }\n }).let{it ⇒ it.isEmpty || it.forall(i ⇒ i)}\n }\n sealed trait Position {\n def getAbsolute(implicit s: Array[Option[Position]]): Option[Int] = {\n this match {\n case Absolute(_) ⇒ Option(0)\n case Relation(orient, diff) ⇒ s(orient).flatMap{_.getAbsolute(s).map{_ + diff}}\n }\n }\n }\n case class Relation(orient: Int, diff: Int) extends Position\n case class Absolute(id: Int) extends Position\n class Gage{\n private var mRelations: List[Relation] = Nil\n def addRelation(to: Int, diff: Int): Unit = {\n mRelations ::= Relation(to, diff)\n }\n def relations: List[Relation] = mRelations\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}\n", "problem_context": "B - ライオン\n\nあなたは動物園に来てライオンを見ている。\nこの動物園にはn個のライオンのオリがある。\nあなたはライオンが全部で何頭いるのか知りたくなったのだが、\n一人で数えるのは大変だ。\nそこで近くにいた動物園の来園者m人に協力してもらうことにした。\n\nライオンのオリは、それぞれ1番からn番までの数字がついており、\n順番に並んでいる。\n一つのオリには0頭以上x頭以下のライオンがいる。\n\nm人の来園者でi番目の人(1 ≤ i ≤ m)には\nl_i番から\nr_i番までの\n両端を含むすべてのオリのライオンの数の総和を数えてもらった。\n\nこの情報を元に、1からn\n各オリの中のライオンの数を求めることにした。\n\n入力形式\n\n入力は以下の形式で与えられる\n\nn x m\nl_1 r_1 s_1\n...\nl_m r_m s_m\n\n1行目は3つの整数n x mで、\nそれぞれオリの数、一つのオリの中のライオンの最大の数、\n数えるのに協力した人の数である。\n2行目から続くm行は各行3つの整数で、\nそれぞれi番目の人が数えた結果\nl_i r_is_iである。\nl_i番からr_i番までのオリのライオンを数えたら\n合計s_i頭いたことを表している。\n\n出力形式\n\n数えてもらった結果が全て正しいとして、\n1からnの\n各オリの中のライオンの数を空白区切りのn個の整数で出力せよ。\nそのような答が複数あるときは、\nライオンの数の合計が最大になるものをどれでも良いので一つ出力せよ。\n条件を満たすライオンの配置が一つもないときは-1を出力せよ。\n\n制約\n\n1 ≤ n ≤ 6\n\n1 ≤ x ≤ 10\n\n1 ≤ m ≤ 10\n\n1 ≤ l_i ≤ r_i ≤ n\n\n0 ≤ s_i ≤ 60\n\n入力値はすべて整数である。\n\n入出力例\n\n入力例 1\n\n3 5 1\n1 2 5\n\n出力例 1\n\n2 3 5\n\nその他\"4 1 5\"や\"0 5 5\"なども正しい出力である。\n\n入力例 2\n\n4 5 2\n1 3 15\n3 4 3\n\n出力例 2\n\n-1\n\n条件を満たすライオンの配置が一つもないときは-1を出力せよ。", "sample_input": "3 5 1\n1 2 5\n"}, "reference_outputs": ["2 3 5\n"], "source_document_id": "p01657", "source_text": "B - ライオン\n\nあなたは動物園に来てライオンを見ている。\nこの動物園にはn個のライオンのオリがある。\nあなたはライオンが全部で何頭いるのか知りたくなったのだが、\n一人で数えるのは大変だ。\nそこで近くにいた動物園の来園者m人に協力してもらうことにした。\n\nライオンのオリは、それぞれ1番からn番までの数字がついており、\n順番に並んでいる。\n一つのオリには0頭以上x頭以下のライオンがいる。\n\nm人の来園者でi番目の人(1 ≤ i ≤ m)には\nl_i番から\nr_i番までの\n両端を含むすべてのオリのライオンの数の総和を数えてもらった。\n\nこの情報を元に、1からn\n各オリの中のライオンの数を求めることにした。\n\n入力形式\n\n入力は以下の形式で与えられる\n\nn x m\nl_1 r_1 s_1\n...\nl_m r_m s_m\n\n1行目は3つの整数n x mで、\nそれぞれオリの数、一つのオリの中のライオンの最大の数、\n数えるのに協力した人の数である。\n2行目から続くm行は各行3つの整数で、\nそれぞれi番目の人が数えた結果\nl_i r_is_iである。\nl_i番からr_i番までのオリのライオンを数えたら\n合計s_i頭いたことを表している。\n\n出力形式\n\n数えてもらった結果が全て正しいとして、\n1からnの\n各オリの中のライオンの数を空白区切りのn個の整数で出力せよ。\nそのような答が複数あるときは、\nライオンの数の合計が最大になるものをどれでも良いので一つ出力せよ。\n条件を満たすライオンの配置が一つもないときは-1を出力せよ。\n\n制約\n\n1 ≤ n ≤ 6\n\n1 ≤ x ≤ 10\n\n1 ≤ m ≤ 10\n\n1 ≤ l_i ≤ r_i ≤ n\n\n0 ≤ s_i ≤ 60\n\n入力値はすべて整数である。\n\n入出力例\n\n入力例 1\n\n3 5 1\n1 2 5\n\n出力例 1\n\n2 3 5\n\nその他\"4 1 5\"や\"0 5 5\"なども正しい出力である。\n\n入力例 2\n\n4 5 2\n1 3 15\n3 4 3\n\n出力例 2\n\n-1\n\n条件を満たすライオンの配置が一つもないときは-1を出力せよ。", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3997, "cpu_time_ms": 250, "memory_kb": 44776}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s220493183", "group_id": "codeNet:p01706", "input_text": "import scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.mutable.ArrayBuffer\nimport scala.reflect.ClassTag\n\nobject Main extends App {\n\n import scala.io.StdIn._\n solve\n def solve: Unit = {\n val Array(n, m, s, t) = readLine.trim.split(' ').map(_.toInt)\n if (n == 0) return\n val edges = Array.tabulate(m){_ ⇒\n val Array(a, b) = readLine.trim.split(' ').map(_.toInt - 1)\n (a, b)\n }\n val (flow, graph) = maxFlowWithUniCapacityEdge(s - 1, t - 1, n, edges)\n //sからのパスがあれば1、tからのパスがあれば-1\n val sortedGraph = graph.sorted(Ordering.fromLessThan[(Int, Int)]{case ((a, b), (c, d)) ⇒ if (a == c) b < d else a < c})\n val memo = Array.tabulate(n){_ ⇒ 0}\n val nodes = Array.tabulate(n){_ ⇒ ArrayBuffer[Int]()}.let{n ⇒\n for ((from, to) ← graph){\n n(from).append(to)\n }\n n.map{_.toArray}\n }\n val revNodes = Array.tabulate(n){_ ⇒ ArrayBuffer[Int]()}.let{n ⇒\n for ((from, to) ← graph){\n n(to).append(from)\n }\n n.map{_.toArray}\n }\n searchPath(revNodes, memo, t - 1, -1)\n searchPath(nodes, memo, s - 1, 1)\n val initEdge = edges.filter{\n case p ⇒\n val i = lowerBound(sortedGraph, p)\n if (i < sortedGraph.length) sortedGraph(i) == p\n else false\n }\n val count = initEdge.count{case (from, to) ⇒ memo(from) == -1 && memo(to) == 1}\n if (count == 0) println(s\"$flow $count\")\n else println(s\"${flow + 1} $count\")\n solve\n }\n\n def searchPath(graph: Array[Array[Int]], memo: Array[Int], from: Int, marker: Int): Unit = {\n val queue = mutable.Queue[Int](from)\n memo(from) = marker\n while (queue.nonEmpty){\n for (to ← graph(queue.dequeue()) if memo(to) != marker){\n memo(to) = marker\n queue.enqueue(to)\n }\n }\n }\n def lowerBound(array: Array[(Int, Int)], target: (Int, Int)): Int = {\n var left = 0\n var right = array.length\n while (left < right){\n val mid = (left + right) / 2\n if (array(mid)._1 < target._1 || (array(mid)._1 == target._1 && array(mid)._2 < target._2)) {\n left = mid + 1\n }else {\n right = mid\n }\n }\n right\n }\n implicit class Extend[T](value: T){\n def let[R](func: T ⇒ R): R = func(value)\n def also(func: T ⇒ Unit): T = {func(value); value}\n }\n def maxFlowWithUniCapacityEdge(source: Int, drain: Int, size: Int, edges: Array[(Int, Int)]): (Int, Array[(Int, Int)]) = {\n val nodes = makeGraph(size, edges)\n val levels = Array.tabulate(size){_ ⇒ -1}\n val searching = Array.tabulate(size){_ => 0}\n def bfs = {\n searching.indices.foreach(i ⇒ searching(i) = 0)\n levels.indices.foreach(i ⇒ levels(i) = -1)\n levels(source) = 0\n val queue = mutable.Queue[Int](source)\n while (queue.nonEmpty){\n val prev = queue.dequeue()\n for (Edge(to, _, b) ← nodes(prev) if b && levels(to) == -1){\n levels(to) = levels(prev) + 1\n queue.enqueue(to)\n }\n }\n }\n def dfs(from: Int): Boolean = {\n if (from == drain) true\n else {\n (searching(from) until nodes(from).length).find{i ⇒\n nodes(from)(i).flow && levels(from) < levels(nodes(from)(i).to) && dfs(nodes(from)(i).to)\n } match {\n case Some(i) ⇒\n searching(from) = i + 1\n val Edge(to, pair, _) = nodes(from)(i)\n nodes(to)(pair) = nodes(to)(pair).copy(flow = true)\n nodes(from)(i) = Edge(to, pair, false)\n true\n case None ⇒\n searching(from) = nodes(from).length\n false\n }\n }\n }\n var count = 0\n var matching = true\n while (matching){\n bfs\n matching = levels(drain) != -1\n if (matching){\n while(dfs(source)){count += 1}\n }\n }\n (count, nodes.indices.flatMap{from ⇒ nodes(from).withFilter(_.flow).map{e ⇒ (from, e.to)}}.toArray)\n }\n private case class Edge(to: Int, pair: Int, flow: Boolean)\n private def makeGraph(size: Int, edges: Array[(Int, Int)]): Array[Array[Edge]] = {\n val result = Array.tabulate(size){_ ⇒ ArrayBuffer[Edge]()}\n for ((from, to) ← edges){\n result(from).append(Edge(to, result(to).length, true))\n result(to).append(Edge(from, result(from).length - 1, false))\n }\n result.map(_.toArray)\n }\n}\n", "language": "Scala", "metadata": {"date": 1547179247, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01706.html", "problem_id": "p01706", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01706/input.txt", "sample_output_relpath": "derived/input_output/data/p01706/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01706/Scala/s220493183.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s220493183", "user_id": "u514597327"}, "prompt_components": {"gold_output": "1 2\n2 1\n0 0\n4 6\n15 0\n", "input_to_evaluate": "import scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.mutable.ArrayBuffer\nimport scala.reflect.ClassTag\n\nobject Main extends App {\n\n import scala.io.StdIn._\n solve\n def solve: Unit = {\n val Array(n, m, s, t) = readLine.trim.split(' ').map(_.toInt)\n if (n == 0) return\n val edges = Array.tabulate(m){_ ⇒\n val Array(a, b) = readLine.trim.split(' ').map(_.toInt - 1)\n (a, b)\n }\n val (flow, graph) = maxFlowWithUniCapacityEdge(s - 1, t - 1, n, edges)\n //sからのパスがあれば1、tからのパスがあれば-1\n val sortedGraph = graph.sorted(Ordering.fromLessThan[(Int, Int)]{case ((a, b), (c, d)) ⇒ if (a == c) b < d else a < c})\n val memo = Array.tabulate(n){_ ⇒ 0}\n val nodes = Array.tabulate(n){_ ⇒ ArrayBuffer[Int]()}.let{n ⇒\n for ((from, to) ← graph){\n n(from).append(to)\n }\n n.map{_.toArray}\n }\n val revNodes = Array.tabulate(n){_ ⇒ ArrayBuffer[Int]()}.let{n ⇒\n for ((from, to) ← graph){\n n(to).append(from)\n }\n n.map{_.toArray}\n }\n searchPath(revNodes, memo, t - 1, -1)\n searchPath(nodes, memo, s - 1, 1)\n val initEdge = edges.filter{\n case p ⇒\n val i = lowerBound(sortedGraph, p)\n if (i < sortedGraph.length) sortedGraph(i) == p\n else false\n }\n val count = initEdge.count{case (from, to) ⇒ memo(from) == -1 && memo(to) == 1}\n if (count == 0) println(s\"$flow $count\")\n else println(s\"${flow + 1} $count\")\n solve\n }\n\n def searchPath(graph: Array[Array[Int]], memo: Array[Int], from: Int, marker: Int): Unit = {\n val queue = mutable.Queue[Int](from)\n memo(from) = marker\n while (queue.nonEmpty){\n for (to ← graph(queue.dequeue()) if memo(to) != marker){\n memo(to) = marker\n queue.enqueue(to)\n }\n }\n }\n def lowerBound(array: Array[(Int, Int)], target: (Int, Int)): Int = {\n var left = 0\n var right = array.length\n while (left < right){\n val mid = (left + right) / 2\n if (array(mid)._1 < target._1 || (array(mid)._1 == target._1 && array(mid)._2 < target._2)) {\n left = mid + 1\n }else {\n right = mid\n }\n }\n right\n }\n implicit class Extend[T](value: T){\n def let[R](func: T ⇒ R): R = func(value)\n def also(func: T ⇒ Unit): T = {func(value); value}\n }\n def maxFlowWithUniCapacityEdge(source: Int, drain: Int, size: Int, edges: Array[(Int, Int)]): (Int, Array[(Int, Int)]) = {\n val nodes = makeGraph(size, edges)\n val levels = Array.tabulate(size){_ ⇒ -1}\n val searching = Array.tabulate(size){_ => 0}\n def bfs = {\n searching.indices.foreach(i ⇒ searching(i) = 0)\n levels.indices.foreach(i ⇒ levels(i) = -1)\n levels(source) = 0\n val queue = mutable.Queue[Int](source)\n while (queue.nonEmpty){\n val prev = queue.dequeue()\n for (Edge(to, _, b) ← nodes(prev) if b && levels(to) == -1){\n levels(to) = levels(prev) + 1\n queue.enqueue(to)\n }\n }\n }\n def dfs(from: Int): Boolean = {\n if (from == drain) true\n else {\n (searching(from) until nodes(from).length).find{i ⇒\n nodes(from)(i).flow && levels(from) < levels(nodes(from)(i).to) && dfs(nodes(from)(i).to)\n } match {\n case Some(i) ⇒\n searching(from) = i + 1\n val Edge(to, pair, _) = nodes(from)(i)\n nodes(to)(pair) = nodes(to)(pair).copy(flow = true)\n nodes(from)(i) = Edge(to, pair, false)\n true\n case None ⇒\n searching(from) = nodes(from).length\n false\n }\n }\n }\n var count = 0\n var matching = true\n while (matching){\n bfs\n matching = levels(drain) != -1\n if (matching){\n while(dfs(source)){count += 1}\n }\n }\n (count, nodes.indices.flatMap{from ⇒ nodes(from).withFilter(_.flow).map{e ⇒ (from, e.to)}}.toArray)\n }\n private case class Edge(to: Int, pair: Int, flow: Boolean)\n private def makeGraph(size: Int, edges: Array[(Int, Int)]): Array[Array[Edge]] = {\n val result = Array.tabulate(size){_ ⇒ ArrayBuffer[Edge]()}\n for ((from, to) ← edges){\n result(from).append(Edge(to, result(to).length, true))\n result(to).append(Edge(from, result(from).length - 1, false))\n }\n result.map(_.toArray)\n }\n}\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nblockquote {\nfont-family: Menlo, Monaco, \"Courier New\", monospace;\ncolor: #333333;\ndisplay: block;\npadding: 8.5px;\nmargin: 0 0 9px;\nfont-size: 12px;\nline-height: 18px;\nbackground-color: #f5f5f5;\nborder: 1px solid #ccc;\nborder: 1px solid rgba(0, 0, 0, 0.15);\n-webkit-border-radius: 4px;\n-moz-border-radius: 4px;\nborder-radius: 4px;\nwhite-space: pre;\nwhite-space: pre-wrap;\nword-break: break-all;\nword-wrap: break-word;\n}\n\nProblem Statement\n\nJAG Kingdom is a strange kingdom such that its $N$ cities are connected only by one-way roads.\nThe $N$ cities are numbered $1$ through $N$.\nICPC (International Characteristic Product Corporation) transports its products from the factory at the city $S$ to the storehouse at the city $T$ in JAG Kingdom every day.\nFor efficiency, ICPC uses multiple trucks at once.\nEach truck starts from $S$ and reaches $T$ on the one-way road network, passing through some cities (or directly).\nIn order to reduce risks of traffic jams and accidents, no pair of trucks takes the same road.\n\nNow, ICPC wants to improve the efficiency of daily transports, while ICPC operates daily transports by as many trucks as possible under the above constraint.\nJAG Kingdom, whose finances are massively affected by ICPC, considers to change the direction of one-way roads in order to increase the number of trucks for daily transports of ICPC.\nBecause reversal of many roads causes confusion, JAG Kingdom decides to reverse at most a single road.\n\nIf there is no road such that reversal of the road can improve the transport efficiency, JAG Kingdom need not reverse any roads.\nCheck whether reversal of a single road can improve the current maximum number of trucks for daily transports.\nAnd if so, calculate the maximum number of trucks which take disjoint sets of roads when a one-way road can be reversed, and the number of roads which can be chosen as the road to be reversed to realize the maximum.\n\nInput\n\nThe input consists of multiple datasets. The number of dataset is no more than $100$.\n\nEach dataset is formatted as follows.\n\n$N$ $M$ $S$ $T$\n$a_1$ $b_1$\n$a_2$ $b_2$\n:\n:\n$a_M$ $b_M$\n\nThe first line of each dataset contains four integers:\nthe number of cities $N$ ($2 \\le N \\le 1{,}000$), the number of roads $M$ ($1 \\le M \\le 10{,}000$), the city with the factory $S$ and the city with the storehouse $T$ ($1 \\le S, T \\le N$, $S \\neq T$).\n\nThe following $M$ lines describe the information of the roads.\nThe $i$-th line of them contains two integers $a_i$ and $b_i$ ($1 \\le a_i, b_i \\le N$, $a_i \\neq b_i$), meaning that the $i$-th road is directed from $a_i$ to $b_i$.\n\nThe end of input is indicated by a line containing four zeros.\n\nOutput\n\nFor each dataset, output two integers separated by a single space in a line as follows:\nIf reversal of a single road improves the current maximum number of trucks for daily transports, the first output integer is the new maximum after reversal of a road, and the second output integer is the number of roads which can be chosen as the road to be reversed to realize the new maximum.\nOtherwise, i.e. if the current maximum cannot be increased by any reversal of a road, the first output integer is the current maximum and the second output integer is $0$.\n\nSample Input\n\n4 4 1 4\n1 2\n3 1\n4 2\n3 4\n7 8 1 7\n1 2\n1 3\n2 4\n3 4\n4 5\n4 6\n5 7\n7 6\n6 4 5 2\n1 2\n1 3\n4 5\n5 6\n10 21 9 10\n9 1\n9 2\n9 3\n9 4\n10 1\n10 2\n10 3\n10 4\n1 5\n2 5\n2 6\n3 6\n3 7\n4 7\n4 8\n1 8\n5 10\n6 10\n7 10\n10 8\n10 9\n2 15 1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n0 0 0 0\n\nOutput for the Sample Input\n\n1 2\n2 1\n0 0\n4 6\n15 0", "sample_input": "4 4 1 4\n1 2\n3 1\n4 2\n3 4\n7 8 1 7\n1 2\n1 3\n2 4\n3 4\n4 5\n4 6\n5 7\n7 6\n6 4 5 2\n1 2\n1 3\n4 5\n5 6\n10 21 9 10\n9 1\n9 2\n9 3\n9 4\n10 1\n10 2\n10 3\n10 4\n1 5\n2 5\n2 6\n3 6\n3 7\n4 7\n4 8\n1 8\n5 10\n6 10\n7 10\n10 8\n10 9\n2 15 1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n0 0 0 0\n"}, "reference_outputs": ["1 2\n2 1\n0 0\n4 6\n15 0\n"], "source_document_id": "p01706", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nblockquote {\nfont-family: Menlo, Monaco, \"Courier New\", monospace;\ncolor: #333333;\ndisplay: block;\npadding: 8.5px;\nmargin: 0 0 9px;\nfont-size: 12px;\nline-height: 18px;\nbackground-color: #f5f5f5;\nborder: 1px solid #ccc;\nborder: 1px solid rgba(0, 0, 0, 0.15);\n-webkit-border-radius: 4px;\n-moz-border-radius: 4px;\nborder-radius: 4px;\nwhite-space: pre;\nwhite-space: pre-wrap;\nword-break: break-all;\nword-wrap: break-word;\n}\n\nProblem Statement\n\nJAG Kingdom is a strange kingdom such that its $N$ cities are connected only by one-way roads.\nThe $N$ cities are numbered $1$ through $N$.\nICPC (International Characteristic Product Corporation) transports its products from the factory at the city $S$ to the storehouse at the city $T$ in JAG Kingdom every day.\nFor efficiency, ICPC uses multiple trucks at once.\nEach truck starts from $S$ and reaches $T$ on the one-way road network, passing through some cities (or directly).\nIn order to reduce risks of traffic jams and accidents, no pair of trucks takes the same road.\n\nNow, ICPC wants to improve the efficiency of daily transports, while ICPC operates daily transports by as many trucks as possible under the above constraint.\nJAG Kingdom, whose finances are massively affected by ICPC, considers to change the direction of one-way roads in order to increase the number of trucks for daily transports of ICPC.\nBecause reversal of many roads causes confusion, JAG Kingdom decides to reverse at most a single road.\n\nIf there is no road such that reversal of the road can improve the transport efficiency, JAG Kingdom need not reverse any roads.\nCheck whether reversal of a single road can improve the current maximum number of trucks for daily transports.\nAnd if so, calculate the maximum number of trucks which take disjoint sets of roads when a one-way road can be reversed, and the number of roads which can be chosen as the road to be reversed to realize the maximum.\n\nInput\n\nThe input consists of multiple datasets. The number of dataset is no more than $100$.\n\nEach dataset is formatted as follows.\n\n$N$ $M$ $S$ $T$\n$a_1$ $b_1$\n$a_2$ $b_2$\n:\n:\n$a_M$ $b_M$\n\nThe first line of each dataset contains four integers:\nthe number of cities $N$ ($2 \\le N \\le 1{,}000$), the number of roads $M$ ($1 \\le M \\le 10{,}000$), the city with the factory $S$ and the city with the storehouse $T$ ($1 \\le S, T \\le N$, $S \\neq T$).\n\nThe following $M$ lines describe the information of the roads.\nThe $i$-th line of them contains two integers $a_i$ and $b_i$ ($1 \\le a_i, b_i \\le N$, $a_i \\neq b_i$), meaning that the $i$-th road is directed from $a_i$ to $b_i$.\n\nThe end of input is indicated by a line containing four zeros.\n\nOutput\n\nFor each dataset, output two integers separated by a single space in a line as follows:\nIf reversal of a single road improves the current maximum number of trucks for daily transports, the first output integer is the new maximum after reversal of a road, and the second output integer is the number of roads which can be chosen as the road to be reversed to realize the new maximum.\nOtherwise, i.e. if the current maximum cannot be increased by any reversal of a road, the first output integer is the current maximum and the second output integer is $0$.\n\nSample Input\n\n4 4 1 4\n1 2\n3 1\n4 2\n3 4\n7 8 1 7\n1 2\n1 3\n2 4\n3 4\n4 5\n4 6\n5 7\n7 6\n6 4 5 2\n1 2\n1 3\n4 5\n5 6\n10 21 9 10\n9 1\n9 2\n9 3\n9 4\n10 1\n10 2\n10 3\n10 4\n1 5\n2 5\n2 6\n3 6\n3 7\n4 7\n4 8\n1 8\n5 10\n6 10\n7 10\n10 8\n10 9\n2 15 1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n0 0 0 0\n\nOutput for the Sample Input\n\n1 2\n2 1\n0 0\n4 6\n15 0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4369, "cpu_time_ms": 2110, "memory_kb": 453540}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s377518435", "group_id": "codeNet:p01708", "input_text": "import scala.annotation.tailrec\n\nobject Main extends App {\n import scala.io.StdIn._\n\n solve\n def solve: Unit = {\n val expression = readLine.trim\n if (expression == \"#\") return\n expression.toList match {\n case (p: Point) Expression Nil ⇒ println(s\"${p.x} ${p.y}\")\n case _ ⇒ ???\n }\n solve\n }\n\n object Expression {\n def unapply(arg: List[Char]): Option[(Result, List[Char])] = {\n arg match {\n case f Factor rest ⇒\n Some(takeAll(rest, f))\n case _ ⇒ None\n }\n }\n @tailrec\n def takeAll(arg: List[Char], prev: Result): (Result, List[Char]) = {\n arg match {\n case '@'::(f Factor r) ⇒\n takeAll(r, op(prev, f))\n case _ ⇒\n (prev, arg)\n }\n }\n private[this] def op(a: Result, b: Result): Result = {\n (a, b) match {\n case (p1: Point, p2: Point) ⇒\n Line(p1, p2)\n case (p: Point, l: Line) ⇒\n p.flipBy(l)\n case (l: Line, p: Point) ⇒\n p.flipBy(l)\n case (l1: Line, l2: Line) ⇒\n l1.crossPoint(l2)\n case _ ⇒ ???\n }\n }\n }\n object Factor {\n def unapply(arg: List[Char]): Option[(Result, List[Char])] = {\n arg match {\n case p PointFactor r ⇒\n Some(p, r)\n case '('::(e Expression ')'::r) ⇒\n Some(e, r)\n case _ ⇒ None\n }\n }\n }\n object PointFactor {\n def unapply(arg: List[Char]): Option[(Point, List[Char])] = {\n arg match {\n case '('::(x Number ','::(y Number ')'::r)) ⇒ Some(Point(x, y), r)\n case _ ⇒ None\n }\n }\n }\n object Number {\n def unapply(arg: List[Char]): Option[(Double, List[Char])] = {\n arg match {\n case '-'::rest ⇒\n rest.span(_.isDigit) match {\n case (Nil, _) ⇒ None\n case (n, r) ⇒ Some(n.foldLeft(0){(a, b) ⇒ a * 10 - b.asDigit}, r)\n }\n case _ ⇒\n arg.span(_.isDigit) match {\n case (Nil, _) ⇒ None\n case (n, r) ⇒ Some(n.foldLeft(0){(a, b) ⇒ a * 10 + b.asDigit}, r)\n }\n }\n }\n }\n sealed trait Result\n case class Point(x: Double, y: Double) extends Result {\n def -(that: Point): Point = Point(x - that.x, y - that.y)\n def +(that: Point): Point = Point(x + that.x, y + that.y)\n def flipBy(line: Line): Point = {\n Line(this, Angle(line).rotate90Clockwise).crossPoint(line).let(p ⇒ p - this + p)\n }\n }\n object Line {\n def apply(point: Point, angle: Angle): Line = {\n //cos(y - p.y) == sin(x - p.x)\n Line(-angle.sin, angle.cos, angle.sin * point.x - angle.cos * point.y)\n }\n def apply(a: Point, b: Point): Line = {\n //(a.x - b.x)(y - b.y) == (a.y - b.y)(x - b.x)\n Line(b.y - a.y, a.x - b.x, a.y * b.x - a.x * b.y)\n }\n }\n case class Line(a: Double, b: Double, c: Double) extends Result {\n def crossPoint(that: Line): Point = {\n Point((this.b * that.c - that.b * this.c) / (this.a * that.b - that.a * this.b), (that.a * this.c - this.a * that.c) / (this.a * that.b - that.a * this.b))\n }\n\n }\n object Angle {\n def apply(line: Line): Angle = {\n val norm = math.sqrt(line.a * line.a + line.b * line.b)\n new Angle(-line.a / norm, line.b / norm)\n }\n }\n class Angle(val sin: Double, val cos: Double) {\n def + (that: Angle): Angle = new Angle(sin * that.cos + cos * that.sin, cos * that.cos - sin * that.sin)\n def - (that: Angle): Angle = new Angle(sin * that.cos - cos * that.sin, cos * that.cos + sin * that.sin)\n def rotate90Clockwise: Angle = new Angle(-cos, sin)\n }\n implicit class Scope[T](val value: T) extends AnyVal{\n @inline\n def also(@inline func: T ⇒ Unit): T = {\n func(value)\n value\n }\n @inline\n def let[A](func: T ⇒ A): A = func(value)\n }\n}\n", "language": "Scala", "metadata": {"date": 1550937099, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01708.html", "problem_id": "p01708", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01708/input.txt", "sample_output_relpath": "derived/input_output/data/p01708/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01708/Scala/s377518435.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s377518435", "user_id": "u514597327"}, "prompt_components": {"gold_output": "3.00000000 3.00000000\n3.00000000 1.00000000\n1.00000000 4.00000000\n0.00000000 2.00000000\n-10.00000000 10.00000000\n-99.83681795 -91.92248853\n", "input_to_evaluate": "import scala.annotation.tailrec\n\nobject Main extends App {\n import scala.io.StdIn._\n\n solve\n def solve: Unit = {\n val expression = readLine.trim\n if (expression == \"#\") return\n expression.toList match {\n case (p: Point) Expression Nil ⇒ println(s\"${p.x} ${p.y}\")\n case _ ⇒ ???\n }\n solve\n }\n\n object Expression {\n def unapply(arg: List[Char]): Option[(Result, List[Char])] = {\n arg match {\n case f Factor rest ⇒\n Some(takeAll(rest, f))\n case _ ⇒ None\n }\n }\n @tailrec\n def takeAll(arg: List[Char], prev: Result): (Result, List[Char]) = {\n arg match {\n case '@'::(f Factor r) ⇒\n takeAll(r, op(prev, f))\n case _ ⇒\n (prev, arg)\n }\n }\n private[this] def op(a: Result, b: Result): Result = {\n (a, b) match {\n case (p1: Point, p2: Point) ⇒\n Line(p1, p2)\n case (p: Point, l: Line) ⇒\n p.flipBy(l)\n case (l: Line, p: Point) ⇒\n p.flipBy(l)\n case (l1: Line, l2: Line) ⇒\n l1.crossPoint(l2)\n case _ ⇒ ???\n }\n }\n }\n object Factor {\n def unapply(arg: List[Char]): Option[(Result, List[Char])] = {\n arg match {\n case p PointFactor r ⇒\n Some(p, r)\n case '('::(e Expression ')'::r) ⇒\n Some(e, r)\n case _ ⇒ None\n }\n }\n }\n object PointFactor {\n def unapply(arg: List[Char]): Option[(Point, List[Char])] = {\n arg match {\n case '('::(x Number ','::(y Number ')'::r)) ⇒ Some(Point(x, y), r)\n case _ ⇒ None\n }\n }\n }\n object Number {\n def unapply(arg: List[Char]): Option[(Double, List[Char])] = {\n arg match {\n case '-'::rest ⇒\n rest.span(_.isDigit) match {\n case (Nil, _) ⇒ None\n case (n, r) ⇒ Some(n.foldLeft(0){(a, b) ⇒ a * 10 - b.asDigit}, r)\n }\n case _ ⇒\n arg.span(_.isDigit) match {\n case (Nil, _) ⇒ None\n case (n, r) ⇒ Some(n.foldLeft(0){(a, b) ⇒ a * 10 + b.asDigit}, r)\n }\n }\n }\n }\n sealed trait Result\n case class Point(x: Double, y: Double) extends Result {\n def -(that: Point): Point = Point(x - that.x, y - that.y)\n def +(that: Point): Point = Point(x + that.x, y + that.y)\n def flipBy(line: Line): Point = {\n Line(this, Angle(line).rotate90Clockwise).crossPoint(line).let(p ⇒ p - this + p)\n }\n }\n object Line {\n def apply(point: Point, angle: Angle): Line = {\n //cos(y - p.y) == sin(x - p.x)\n Line(-angle.sin, angle.cos, angle.sin * point.x - angle.cos * point.y)\n }\n def apply(a: Point, b: Point): Line = {\n //(a.x - b.x)(y - b.y) == (a.y - b.y)(x - b.x)\n Line(b.y - a.y, a.x - b.x, a.y * b.x - a.x * b.y)\n }\n }\n case class Line(a: Double, b: Double, c: Double) extends Result {\n def crossPoint(that: Line): Point = {\n Point((this.b * that.c - that.b * this.c) / (this.a * that.b - that.a * this.b), (that.a * this.c - this.a * that.c) / (this.a * that.b - that.a * this.b))\n }\n\n }\n object Angle {\n def apply(line: Line): Angle = {\n val norm = math.sqrt(line.a * line.a + line.b * line.b)\n new Angle(-line.a / norm, line.b / norm)\n }\n }\n class Angle(val sin: Double, val cos: Double) {\n def + (that: Angle): Angle = new Angle(sin * that.cos + cos * that.sin, cos * that.cos - sin * that.sin)\n def - (that: Angle): Angle = new Angle(sin * that.cos - cos * that.sin, cos * that.cos + sin * that.sin)\n def rotate90Clockwise: Angle = new Angle(-cos, sin)\n }\n implicit class Scope[T](val value: T) extends AnyVal{\n @inline\n def also(@inline func: T ⇒ Unit): T = {\n func(value)\n value\n }\n @inline\n def let[A](func: T ⇒ A): A = func(value)\n }\n}\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nblockquote {\nfont-family: Menlo, Monaco, \"Courier New\", monospace;\ncolor: #333333;\ndisplay: block;\npadding: 8.5px;\nmargin: 0 0 9px;\nfont-size: 12px;\nline-height: 18px;\nbackground-color: #f5f5f5;\nborder: 1px solid #ccc;\nborder: 1px solid rgba(0, 0, 0, 0.15);\n-webkit-border-radius: 4px;\n-moz-border-radius: 4px;\nborder-radius: 4px;\nwhite-space: pre;\nwhite-space: pre-wrap;\nword-break: break-all;\nword-wrap: break-word;\n}\n\nProblem Statement\n\nOne day, you found an old scroll with strange texts on it.\n\nYou revealed that the text was actually an expression denoting the position of\ntreasure. The expression consists of following three operations:\n\nFrom two points, yield a line on which the points lie.\n\nFrom a point and a line, yield a point that is symmetric to the given point with respect to the line.\n\nFrom two lines, yield a point that is the intersection of the lines.\n\nThe syntax of the expression is denoted by following BNF:\n\n ::= \n ::= | \"@\" | \"@\" | \"@\" \n ::= \"(\" \",\" \")\" | \"(\" \")\"\n ::= | \"@\" \n ::= \"(\" \")\"\n ::= | | \n ::= | \n ::= \"-\" \n ::= | \n ::= \"0\"\n ::= \"1\" | \"2\" | \"3\" | \"4\" | \"5\" | \"6\" | \"7\" | \"8\" | \"9\"\n\nEach or denotes a point, whereas each or denotes a line. The former notion of $(X,Y)$ represents a point which has $X$ for $x$-coordinate and $Y$ for $y$-coordinate on the $2$-dimensional plane.\n\"@\" indicates the operations on two operands. Since each operation is distinguishable from others by its operands' types (i.e. a point or a line),\nall of these operations are denoted by the same character \"@\".\nNote that \"@\" is left-associative, as can be seen from the BNF.\n\nYour task is to determine where the treasure is placed.\n\nInput\n\nThe input consists of multiple datasets. Each dataset is a single line which\ncontains an expression denoting the position of treasure.\n\nIt is guaranteed that each dataset satisfies the following conditions:\n\nThe length of the string never exceeds $10^2$.\n\nIf both operands of \"@\" are points, their distance is greater than $1$.\n\nIf both operands of \"@\" are lines, they are never parallel.\n\nThe absolute values of points' coordinates never exceed $10^2$ at any point of evaluation.\n\nYou can also assume that there are at most $100$ datasets.\n\nThe input ends with a line that contains only a single \"#\".\n\nOutput\n\nFor each dataset, print the $X$ and $Y$ coordinates of the point, denoted by\nthe expression, in this order.\n\nThe output will be considered correct if its absolute or relative error is at most $10^{-2}$.\n\nSample Input\n\n((0,0)@(1,1))@((4,1)@(2,5))\n((0,0)@(3,1))@((1,-3)@(2,-1))\n(0,0)@(1,1)@(4,1)\n(0,0)@((1,1)@(4,1))\n(((0,0)@((10,20)@(((30,40))))))\n((0,0)@(3,1))@((1,-3)@(2,-1))@(100,-100)@(100,100)\n#\n\nOutput for the Sample Input\n\n3.00000000 3.00000000\n3.00000000 1.00000000\n1.00000000 4.00000000\n0.00000000 2.00000000\n-10.00000000 10.00000000\n-99.83681795 -91.92248853", "sample_input": "((0,0)@(1,1))@((4,1)@(2,5))\n((0,0)@(3,1))@((1,-3)@(2,-1))\n(0,0)@(1,1)@(4,1)\n(0,0)@((1,1)@(4,1))\n(((0,0)@((10,20)@(((30,40))))))\n((0,0)@(3,1))@((1,-3)@(2,-1))@(100,-100)@(100,100)\n#\n"}, "reference_outputs": ["3.00000000 3.00000000\n3.00000000 1.00000000\n1.00000000 4.00000000\n0.00000000 2.00000000\n-10.00000000 10.00000000\n-99.83681795 -91.92248853\n"], "source_document_id": "p01708", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nblockquote {\nfont-family: Menlo, Monaco, \"Courier New\", monospace;\ncolor: #333333;\ndisplay: block;\npadding: 8.5px;\nmargin: 0 0 9px;\nfont-size: 12px;\nline-height: 18px;\nbackground-color: #f5f5f5;\nborder: 1px solid #ccc;\nborder: 1px solid rgba(0, 0, 0, 0.15);\n-webkit-border-radius: 4px;\n-moz-border-radius: 4px;\nborder-radius: 4px;\nwhite-space: pre;\nwhite-space: pre-wrap;\nword-break: break-all;\nword-wrap: break-word;\n}\n\nProblem Statement\n\nOne day, you found an old scroll with strange texts on it.\n\nYou revealed that the text was actually an expression denoting the position of\ntreasure. The expression consists of following three operations:\n\nFrom two points, yield a line on which the points lie.\n\nFrom a point and a line, yield a point that is symmetric to the given point with respect to the line.\n\nFrom two lines, yield a point that is the intersection of the lines.\n\nThe syntax of the expression is denoted by following BNF:\n\n ::= \n ::= | \"@\" | \"@\" | \"@\" \n ::= \"(\" \",\" \")\" | \"(\" \")\"\n ::= | \"@\" \n ::= \"(\" \")\"\n ::= | | \n ::= | \n ::= \"-\" \n ::= | \n ::= \"0\"\n ::= \"1\" | \"2\" | \"3\" | \"4\" | \"5\" | \"6\" | \"7\" | \"8\" | \"9\"\n\nEach or denotes a point, whereas each or denotes a line. The former notion of $(X,Y)$ represents a point which has $X$ for $x$-coordinate and $Y$ for $y$-coordinate on the $2$-dimensional plane.\n\"@\" indicates the operations on two operands. Since each operation is distinguishable from others by its operands' types (i.e. a point or a line),\nall of these operations are denoted by the same character \"@\".\nNote that \"@\" is left-associative, as can be seen from the BNF.\n\nYour task is to determine where the treasure is placed.\n\nInput\n\nThe input consists of multiple datasets. Each dataset is a single line which\ncontains an expression denoting the position of treasure.\n\nIt is guaranteed that each dataset satisfies the following conditions:\n\nThe length of the string never exceeds $10^2$.\n\nIf both operands of \"@\" are points, their distance is greater than $1$.\n\nIf both operands of \"@\" are lines, they are never parallel.\n\nThe absolute values of points' coordinates never exceed $10^2$ at any point of evaluation.\n\nYou can also assume that there are at most $100$ datasets.\n\nThe input ends with a line that contains only a single \"#\".\n\nOutput\n\nFor each dataset, print the $X$ and $Y$ coordinates of the point, denoted by\nthe expression, in this order.\n\nThe output will be considered correct if its absolute or relative error is at most $10^{-2}$.\n\nSample Input\n\n((0,0)@(1,1))@((4,1)@(2,5))\n((0,0)@(3,1))@((1,-3)@(2,-1))\n(0,0)@(1,1)@(4,1)\n(0,0)@((1,1)@(4,1))\n(((0,0)@((10,20)@(((30,40))))))\n((0,0)@(3,1))@((1,-3)@(2,-1))@(100,-100)@(100,100)\n#\n\nOutput for the Sample Input\n\n3.00000000 3.00000000\n3.00000000 1.00000000\n1.00000000 4.00000000\n0.00000000 2.00000000\n-10.00000000 10.00000000\n-99.83681795 -91.92248853", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3812, "cpu_time_ms": 250, "memory_kb": 46060}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s050725844", "group_id": "codeNet:p01713", "input_text": "import scala.collection.mutable.ArrayBuffer\nobject Main extends App {\n import scala.io.StdIn._\n val w = readInt\n val a = readLine.trim.split(' ').map(_.toInt)\n val nearestRight: Array[Int] = a.indices.map(i ⇒ if (a(i) != 0) Int.MaxValue else i).toArray.also(arr ⇒ arr.indices.reverse.tail.foreach(i ⇒ arr(i) = math.min(arr(i), arr(i + 1))))\n val nearestLeft: Array[Int] = a.indices.map(i ⇒ if (a(i) != 0) Int.MinValue else i).toArray.also(arr ⇒ arr.indices.tail.foreach(i ⇒ arr(i) = math.max(arr(i), arr(i - 1))))\n val limitFromLeft = MinSegmentTree(a.indices.map(i ⇒ if (a(i) >= 0) Int.MaxValue else a(i).abs + startTimeFromLeft(i)).toArray)\n val limitFromRight = MinSegmentTree(a.indices.map(i ⇒ if (a(i) >= 0) Int.MaxValue else a(i).abs + startTimeFromRight(i)).toArray)\n println(\n a.indices.filter(a(_) > 0).map(i ⇒ math.max(canMoveLeft(i, a(i), nearestLeft, limitFromRight), canMoveRight(i, a(i), nearestRight, limitFromLeft))).sum\n )\n def canMoveRight(position: Int, time: Int, nearestRight: Array[Int], limitFromLeft: MinSegmentTree): Int = {\n if ((0 until w).contains(nearestRight(position)) && startTimeFromLeft(position) <= limitFromLeft.min(position, nearestRight(position))){\n val t = startTimeFromLeft(position)\n val min = limitFromLeft.min(position, nearestRight(position))\n (startTimeFromLeft(position) until math.min(startTimeFromLeft(position) + time, limitFromLeft.min(position, nearestRight(position)))).length\n }else 0\n }\n def canMoveLeft(position: Int, time: Int, nearestLeft: Array[Int], limitFromRight: MinSegmentTree): Int = {\n if ((0 until w).contains(nearestLeft(position)) && startTimeFromRight(position) <= limitFromRight.min(nearestLeft(position), position)){\n (startTimeFromRight(position) until math.min(startTimeFromRight(position) + time, limitFromRight.min(nearestLeft(position), position))).length\n }else 0\n }\n\n def startTimeFromLeft(to: Int): Int = -to\n def startTimeFromRight(to: Int): Int = to + 1 - w\n object MinSegmentTree {\n def apply(array: Array[Int]): MinSegmentTree = {\n val arr = ArrayBuffer[Array[Int]](array)\n while (arr.last.length != 1){\n arr.append(Array.tabulate(arr.last.length / 2){_ ⇒ Int.MaxValue})\n }\n for (depth ← arr.indices.tail; i ← arr(depth).indices){\n arr(depth)(i) = math.min(arr(depth - 1)(i * 2), arr(depth - 1)(i * 2 + 1))\n }\n new MinSegmentTree(arr.toArray)\n }\n }\n class MinSegmentTree private (private val array: Array[Array[Int]]){\n def min(from: Int, to: Int): Int = {\n var depth = 0\n var left = from\n var right = to\n var min = Int.MaxValue\n while (left <= right){\n if (left % 2 == 1){\n min = math.min(min, array(depth)(left))\n left += 2\n }\n if (right % 2 == 0){\n min = math.min(min, array(depth)(right))\n right -= 2\n }\n left /= 2\n right /= 2\n depth += 1\n }\n min\n }\n }\n implicit class Scope[T](val value: T) extends AnyVal {\n @inline\n def let[A](func: T ⇒ A): A = func(value)\n @inline\n def also(func: T ⇒ Unit): T = {\n func(value)\n value\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1552152430, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01713.html", "problem_id": "p01713", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01713/input.txt", "sample_output_relpath": "derived/input_output/data/p01713/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01713/Scala/s050725844.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s050725844", "user_id": "u514597327"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import scala.collection.mutable.ArrayBuffer\nobject Main extends App {\n import scala.io.StdIn._\n val w = readInt\n val a = readLine.trim.split(' ').map(_.toInt)\n val nearestRight: Array[Int] = a.indices.map(i ⇒ if (a(i) != 0) Int.MaxValue else i).toArray.also(arr ⇒ arr.indices.reverse.tail.foreach(i ⇒ arr(i) = math.min(arr(i), arr(i + 1))))\n val nearestLeft: Array[Int] = a.indices.map(i ⇒ if (a(i) != 0) Int.MinValue else i).toArray.also(arr ⇒ arr.indices.tail.foreach(i ⇒ arr(i) = math.max(arr(i), arr(i - 1))))\n val limitFromLeft = MinSegmentTree(a.indices.map(i ⇒ if (a(i) >= 0) Int.MaxValue else a(i).abs + startTimeFromLeft(i)).toArray)\n val limitFromRight = MinSegmentTree(a.indices.map(i ⇒ if (a(i) >= 0) Int.MaxValue else a(i).abs + startTimeFromRight(i)).toArray)\n println(\n a.indices.filter(a(_) > 0).map(i ⇒ math.max(canMoveLeft(i, a(i), nearestLeft, limitFromRight), canMoveRight(i, a(i), nearestRight, limitFromLeft))).sum\n )\n def canMoveRight(position: Int, time: Int, nearestRight: Array[Int], limitFromLeft: MinSegmentTree): Int = {\n if ((0 until w).contains(nearestRight(position)) && startTimeFromLeft(position) <= limitFromLeft.min(position, nearestRight(position))){\n val t = startTimeFromLeft(position)\n val min = limitFromLeft.min(position, nearestRight(position))\n (startTimeFromLeft(position) until math.min(startTimeFromLeft(position) + time, limitFromLeft.min(position, nearestRight(position)))).length\n }else 0\n }\n def canMoveLeft(position: Int, time: Int, nearestLeft: Array[Int], limitFromRight: MinSegmentTree): Int = {\n if ((0 until w).contains(nearestLeft(position)) && startTimeFromRight(position) <= limitFromRight.min(nearestLeft(position), position)){\n (startTimeFromRight(position) until math.min(startTimeFromRight(position) + time, limitFromRight.min(nearestLeft(position), position))).length\n }else 0\n }\n\n def startTimeFromLeft(to: Int): Int = -to\n def startTimeFromRight(to: Int): Int = to + 1 - w\n object MinSegmentTree {\n def apply(array: Array[Int]): MinSegmentTree = {\n val arr = ArrayBuffer[Array[Int]](array)\n while (arr.last.length != 1){\n arr.append(Array.tabulate(arr.last.length / 2){_ ⇒ Int.MaxValue})\n }\n for (depth ← arr.indices.tail; i ← arr(depth).indices){\n arr(depth)(i) = math.min(arr(depth - 1)(i * 2), arr(depth - 1)(i * 2 + 1))\n }\n new MinSegmentTree(arr.toArray)\n }\n }\n class MinSegmentTree private (private val array: Array[Array[Int]]){\n def min(from: Int, to: Int): Int = {\n var depth = 0\n var left = from\n var right = to\n var min = Int.MaxValue\n while (left <= right){\n if (left % 2 == 1){\n min = math.min(min, array(depth)(left))\n left += 2\n }\n if (right % 2 == 0){\n min = math.min(min, array(depth)(right))\n right -= 2\n }\n left /= 2\n right /= 2\n depth += 1\n }\n min\n }\n }\n implicit class Scope[T](val value: T) extends AnyVal {\n @inline\n def let[A](func: T ⇒ A): A = func(value)\n @inline\n def also(func: T ⇒ Unit): T = {\n func(value)\n value\n }\n }\n}\n", "problem_context": "問題 B : Evacuation Route\n\n問題文\n\n日本では防災研究が盛んに行われており,近年その重要性がますます増している.\n避難経路の評価も重要な研究のひとつである.\n今回は直線状の通路の安全評価を行う.\n\n通路は W 個のユニットに分けられており,一方の端のユニットからもう一方の端のユニットまで 0,  1,  2,  … ,  W-1 の番号がつけられている.\n通路内の各ユニットには,入口の扉,出口の扉,防火扉のいずれか1つが存在する.\n入り口の扉,出口の扉,防火扉はそれぞれ通路内に複数個存在しうる.\n\nこの問題では時刻 t=0 で火災が発生したと想定する.\nそれにより,通路の外部にいて避難しようとしている人々が入口の扉を通じて通路へ入り,より安全な場所へ出るために出口の扉へ脱出しようとするものとする.\n避難中のそれぞれの人は単位時刻ごとに 1 つのユニットを移動するか,今のユニットに留まることができる.\nすなわち,時刻 t にある人がユニット i にいたとするとき,その人は時刻 t+1 ではユニット i-1,  i,   i+1 の3つの数字のうち 0 以上 W-1 以下であるものを選択し,その番号のユニットへ移動することができる.\n防火扉があるユニットは,ある一定時刻以降になると完全に遮断されてしまい,避難中の人々はそのユニットに立ち入りできなくなる.また,そのユニット内に居た人々もそこから他のユニットに移動できなくなってしまう.\n\nこの問題における目的は,それぞれの扉の情報が与えられるので,避難中の人々が最適に行動した時に最大で何人が出口の扉へたどり着けるか計算することである.\n\n通路の情報がW個の整数a_iで与えられる.\n\na_i = 0のとき,i 番目のユニットが出口の扉であることをあらわす.\n\na_i < 0のとき,i 番目のユニットが防火扉により時間 |a_i| 以降出入りできなくなることを表す.\n\na_i > 0のとき,時刻 t=0, 1, 2, … , a_{i}-1 のそれぞれにおいて,ちょうど一人の人が i 番目のユニットに現れる.時刻 t に現れた人は,時刻 t+1 以降から移動を開始する.\n\nなお,1つのユニットに複数の人々が存在してもかまわない.\n\n出口の扉へたどり着ける最大の人数を求めよ.\n\n入力形式\n\n入力は以下の形式で与えられる\n\nW\na_0 a_1 ... a_{W-1}\n\n出力形式\n\n最大人数を1行で出力せよ.\n\n制約\n\n1 ≤ W ≤ 10^5\n\n|a_i|   ≤ 10^4\n\n入力値はすべて整数である.\n\n入出力例\n\n入力例 1\n\n7\n2 0 -2 3 2 -2 0\n\n出力例 1\n\n4\n\n0,   3,   5番目のユニットに入り口の扉があり,\n1,   6番目のユニットに出口の扉がある.\n\n0番目のユニットからは,1番目のユニットへ2人出ることができる.\n\n3番目のユニットからは,1番目のユニットへ1人出ることができる.\n\n5番目のユニットからは,6番目のユニットへ1人出ることができる.\n\nよって合わせて4人が出口へとたどり着ける.\n\n入力例 2\n\n4\n1 1 1 1\n\n出力例 2\n\n0\n\n出口がないので誰も脱出できない.\n\n入力例 3\n\n9\n10 -10 10 -10 10 -10 10 -10 0\n\n出力例 3\n\n24", "sample_input": "7\n2 0 -2 3 2 -2 0\n"}, "reference_outputs": ["4\n"], "source_document_id": "p01713", "source_text": "問題 B : Evacuation Route\n\n問題文\n\n日本では防災研究が盛んに行われており,近年その重要性がますます増している.\n避難経路の評価も重要な研究のひとつである.\n今回は直線状の通路の安全評価を行う.\n\n通路は W 個のユニットに分けられており,一方の端のユニットからもう一方の端のユニットまで 0,  1,  2,  … ,  W-1 の番号がつけられている.\n通路内の各ユニットには,入口の扉,出口の扉,防火扉のいずれか1つが存在する.\n入り口の扉,出口の扉,防火扉はそれぞれ通路内に複数個存在しうる.\n\nこの問題では時刻 t=0 で火災が発生したと想定する.\nそれにより,通路の外部にいて避難しようとしている人々が入口の扉を通じて通路へ入り,より安全な場所へ出るために出口の扉へ脱出しようとするものとする.\n避難中のそれぞれの人は単位時刻ごとに 1 つのユニットを移動するか,今のユニットに留まることができる.\nすなわち,時刻 t にある人がユニット i にいたとするとき,その人は時刻 t+1 ではユニット i-1,  i,   i+1 の3つの数字のうち 0 以上 W-1 以下であるものを選択し,その番号のユニットへ移動することができる.\n防火扉があるユニットは,ある一定時刻以降になると完全に遮断されてしまい,避難中の人々はそのユニットに立ち入りできなくなる.また,そのユニット内に居た人々もそこから他のユニットに移動できなくなってしまう.\n\nこの問題における目的は,それぞれの扉の情報が与えられるので,避難中の人々が最適に行動した時に最大で何人が出口の扉へたどり着けるか計算することである.\n\n通路の情報がW個の整数a_iで与えられる.\n\na_i = 0のとき,i 番目のユニットが出口の扉であることをあらわす.\n\na_i < 0のとき,i 番目のユニットが防火扉により時間 |a_i| 以降出入りできなくなることを表す.\n\na_i > 0のとき,時刻 t=0, 1, 2, … , a_{i}-1 のそれぞれにおいて,ちょうど一人の人が i 番目のユニットに現れる.時刻 t に現れた人は,時刻 t+1 以降から移動を開始する.\n\nなお,1つのユニットに複数の人々が存在してもかまわない.\n\n出口の扉へたどり着ける最大の人数を求めよ.\n\n入力形式\n\n入力は以下の形式で与えられる\n\nW\na_0 a_1 ... a_{W-1}\n\n出力形式\n\n最大人数を1行で出力せよ.\n\n制約\n\n1 ≤ W ≤ 10^5\n\n|a_i|   ≤ 10^4\n\n入力値はすべて整数である.\n\n入出力例\n\n入力例 1\n\n7\n2 0 -2 3 2 -2 0\n\n出力例 1\n\n4\n\n0,   3,   5番目のユニットに入り口の扉があり,\n1,   6番目のユニットに出口の扉がある.\n\n0番目のユニットからは,1番目のユニットへ2人出ることができる.\n\n3番目のユニットからは,1番目のユニットへ1人出ることができる.\n\n5番目のユニットからは,6番目のユニットへ1人出ることができる.\n\nよって合わせて4人が出口へとたどり着ける.\n\n入力例 2\n\n4\n1 1 1 1\n\n出力例 2\n\n0\n\n出口がないので誰も脱出できない.\n\n入力例 3\n\n9\n10 -10 10 -10 10 -10 10 -10 0\n\n出力例 3\n\n24", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3203, "cpu_time_ms": 670, "memory_kb": 100216}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s391042405", "group_id": "codeNet:p01722", "input_text": "import scala.io.StdIn._\nobject Main extends App {\n println(readInt match {\n case 0 ⇒ 1\n case 1 ⇒ 2\n case 2 ⇒ 1\n case _ ⇒ 0\n })\n}\n", "language": "Scala", "metadata": {"date": 1565751230, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01722.html", "problem_id": "p01722", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01722/input.txt", "sample_output_relpath": "derived/input_output/data/p01722/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01722/Scala/s391042405.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s391042405", "user_id": "u514597327"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import scala.io.StdIn._\nobject Main extends App {\n println(readInt match {\n case 0 ⇒ 1\n case 1 ⇒ 2\n case 2 ⇒ 1\n case _ ⇒ 0\n })\n}\n", "problem_context": "イクタ君は速いプログラムが大好きである。最近は、除算のプログラムを高速にしようとしている。しかしなかなか速くならないので、「常識的に考えて典型的」な入力に対してのみ高速にすればよいと考えた。イクタ君が解こうとしている問題は次のようなものである。\n\n与えられた非負整数nに対し、10進法でp(n) − 1桁の正整数11...1をp(n)で割ったあまりを求めよ。ただしp(n)は22{ . . . 2}(2がn個)より大きい最小の素数を表すとする。p(0) = 2とする。\n\nあなたの仕事は、イクタ君より速くプログラムを完成させることである。\n\nInput\n\n入力は以下の形式で与えられる。\n\nn\n\n問題の入力の非負整数nがあたえられる。\n\nConstraints\n\n入力中の各変数は以下の制約を満たす。\n\n0 ≤ n < 1000\n\nOutput\n\n問題の解を1行に出力せよ。\n\nSample Input 1\n\n0\n\nOutput for the Sample Input 1\n\n1\n\nn=0のとき、p(n) = 2 なので、1 mod 2 = 1 が解となる。\n\nSample Input 2\n\n1\n\nOutput for the Sample Input 2\n\n2\n\nn=1のとき、p(n) = 3 なので、11 mod 3 = 2が解となる。\n\nSample Input 3\n\n2\n\nOutput for the Sample Input 3\n\n1", "sample_input": "0\n"}, "reference_outputs": ["1\n"], "source_document_id": "p01722", "source_text": "イクタ君は速いプログラムが大好きである。最近は、除算のプログラムを高速にしようとしている。しかしなかなか速くならないので、「常識的に考えて典型的」な入力に対してのみ高速にすればよいと考えた。イクタ君が解こうとしている問題は次のようなものである。\n\n与えられた非負整数nに対し、10進法でp(n) − 1桁の正整数11...1をp(n)で割ったあまりを求めよ。ただしp(n)は22{ . . . 2}(2がn個)より大きい最小の素数を表すとする。p(0) = 2とする。\n\nあなたの仕事は、イクタ君より速くプログラムを完成させることである。\n\nInput\n\n入力は以下の形式で与えられる。\n\nn\n\n問題の入力の非負整数nがあたえられる。\n\nConstraints\n\n入力中の各変数は以下の制約を満たす。\n\n0 ≤ n < 1000\n\nOutput\n\n問題の解を1行に出力せよ。\n\nSample Input 1\n\n0\n\nOutput for the Sample Input 1\n\n1\n\nn=0のとき、p(n) = 2 なので、1 mod 2 = 1 が解となる。\n\nSample Input 2\n\n1\n\nOutput for the Sample Input 2\n\n2\n\nn=1のとき、p(n) = 3 なので、11 mod 3 = 2が解となる。\n\nSample Input 3\n\n2\n\nOutput for the Sample Input 3\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 151, "cpu_time_ms": 270, "memory_kb": 43872}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s183118404", "group_id": "codeNet:p01815", "input_text": "import scala.annotation.tailrec\nimport scala.collection.mutable\n\nobject Main extends App {\n import scala.io.StdIn._\n\n\n val Array(n, m) = readLine.trim.split(' ').map(_.toInt)\n val weights = readLine.trim.split(' ').map(_.toInt)\n val edges = Array.tabulate(n){_ ⇒ Nil: List[Int]}\n val dimensions = Array.tabulate(n){_ ⇒ 0}\n for (_ ← 0 until m){\n val Array(u, v) = readLine.trim.split(' ').map(_.toInt)\n edges(u - 1) ::= v - 1\n dimensions(u - 1) += 1\n edges(v - 1) ::= u - 1\n dimensions(v - 1) += 1\n }\n val singlePathMemo = Array.tabulate(n){_ ⇒ 0}\n dimensions.indices.tail.filter(i ⇒ dimensions(i) == 1).foreach(i ⇒ singlePathCost(i))\n println(singlePathMemo.max + dimensions.indices.filter(i ⇒ i == 0 || dimensions(i) != 1).map(i ⇒ weights(i)).sum)\n @tailrec\n def singlePathCost(current: Int, prev: Int = -1, result: Int = 0): Unit = {\n if (dimensions(current) != 1 || current == 0) {\n singlePathMemo(current) = math.max(singlePathMemo(current), result)\n }\n else {\n edges(current).filter(i ⇒ i == 0 || dimensions(i) != 1) match {\n case next::Nil ⇒\n dimensions(next) -= 1\n singlePathCost(next, current, math.max(singlePathMemo(current), result) + weights(current))\n case _ ⇒ ???\n }\n }\n }\n\n\n case class Cost(any: Int, one: Int)\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 @inline\n def takeIf(@inline predicate: T ⇒ Boolean): Option[T] = Some(value).filter(predicate)\n }\n}\n", "language": "Scala", "metadata": {"date": 1548468110, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01815.html", "problem_id": "p01815", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01815/input.txt", "sample_output_relpath": "derived/input_output/data/p01815/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01815/Scala/s183118404.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s183118404", "user_id": "u514597327"}, "prompt_components": {"gold_output": "21\n", "input_to_evaluate": "import scala.annotation.tailrec\nimport scala.collection.mutable\n\nobject Main extends App {\n import scala.io.StdIn._\n\n\n val Array(n, m) = readLine.trim.split(' ').map(_.toInt)\n val weights = readLine.trim.split(' ').map(_.toInt)\n val edges = Array.tabulate(n){_ ⇒ Nil: List[Int]}\n val dimensions = Array.tabulate(n){_ ⇒ 0}\n for (_ ← 0 until m){\n val Array(u, v) = readLine.trim.split(' ').map(_.toInt)\n edges(u - 1) ::= v - 1\n dimensions(u - 1) += 1\n edges(v - 1) ::= u - 1\n dimensions(v - 1) += 1\n }\n val singlePathMemo = Array.tabulate(n){_ ⇒ 0}\n dimensions.indices.tail.filter(i ⇒ dimensions(i) == 1).foreach(i ⇒ singlePathCost(i))\n println(singlePathMemo.max + dimensions.indices.filter(i ⇒ i == 0 || dimensions(i) != 1).map(i ⇒ weights(i)).sum)\n @tailrec\n def singlePathCost(current: Int, prev: Int = -1, result: Int = 0): Unit = {\n if (dimensions(current) != 1 || current == 0) {\n singlePathMemo(current) = math.max(singlePathMemo(current), result)\n }\n else {\n edges(current).filter(i ⇒ i == 0 || dimensions(i) != 1) match {\n case next::Nil ⇒\n dimensions(next) -= 1\n singlePathCost(next, current, math.max(singlePathMemo(current), result) + weights(current))\n case _ ⇒ ???\n }\n }\n }\n\n\n case class Cost(any: Int, one: Int)\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 @inline\n def takeIf(@inline predicate: T ⇒ Boolean): Option[T] = Some(value).filter(predicate)\n }\n}\n", "problem_context": "Escape\n\n頂点に正の値を持つ無向グラフが与えられる。\n頂点には 1 から N の番号がついており、i 番目の頂点は w_i の値を持っている。\n1 番目の頂点からスタートし、直前に通った辺を通ることができないという制約のもとでグラフ上を移動することができる。\n各頂点では,初めて訪れた時に限りその頂点が持つ値の点数を得られる。\n\n取得できる点数の総和の最大値を求めよ。\n\nConstraints\n\n1 ≤ N ≤ 100000\n\nN − 1 ≤ M ≤ 100000\n\n1 ≤ w_i ≤ 1000\n\n1 ≤ u_i, v_i ≤ N\n\n多重辺・自己辺は存在しない\n\nグラフは連結である\n\nInput Format\n\n入力は以下の形式で標準入力から与えられる。\n\nN M\nw_1 w_2 ... w_N\nu_1 v_1\nu_2 v_2\n...\nu_M v_M\n\n1 行目にはグラフの頂点数 N と辺の数を表す整数 M が入力される。\n\n2 行目には各頂点が持つ値 w_i が入力される。\n\nさらに続けて M 行に、各辺により繋がれる 2 頂点の番号が入力される。\n\nOutput Format\n\n答えを1行に出力せよ。\n\nSample Input 1\n\n6 6\n1 2 3 4 5 6\n1 2\n2 3\n3 4\n1 4\n4 5\n5 6\n\nSample Output 1\n\n21\n\n頂点 1→2→3→4→5→6 と進むことで全ての頂点の点数を集めることができます。\n\nSample Input 2\n\n7 8\n1 3 3 5 2 2 3\n1 2\n2 3\n3 1\n1 4\n1 7\n1 5\n1 6\n5 6\n\nSample Output 2\n\n16\n\n頂点 1→2→3→1→5→6→1→4 と進むことで16点を集めることができます。", "sample_input": "6 6\n1 2 3 4 5 6\n1 2\n2 3\n3 4\n1 4\n4 5\n5 6\n"}, "reference_outputs": ["21\n"], "source_document_id": "p01815", "source_text": "Escape\n\n頂点に正の値を持つ無向グラフが与えられる。\n頂点には 1 から N の番号がついており、i 番目の頂点は w_i の値を持っている。\n1 番目の頂点からスタートし、直前に通った辺を通ることができないという制約のもとでグラフ上を移動することができる。\n各頂点では,初めて訪れた時に限りその頂点が持つ値の点数を得られる。\n\n取得できる点数の総和の最大値を求めよ。\n\nConstraints\n\n1 ≤ N ≤ 100000\n\nN − 1 ≤ M ≤ 100000\n\n1 ≤ w_i ≤ 1000\n\n1 ≤ u_i, v_i ≤ N\n\n多重辺・自己辺は存在しない\n\nグラフは連結である\n\nInput Format\n\n入力は以下の形式で標準入力から与えられる。\n\nN M\nw_1 w_2 ... w_N\nu_1 v_1\nu_2 v_2\n...\nu_M v_M\n\n1 行目にはグラフの頂点数 N と辺の数を表す整数 M が入力される。\n\n2 行目には各頂点が持つ値 w_i が入力される。\n\nさらに続けて M 行に、各辺により繋がれる 2 頂点の番号が入力される。\n\nOutput Format\n\n答えを1行に出力せよ。\n\nSample Input 1\n\n6 6\n1 2 3 4 5 6\n1 2\n2 3\n3 4\n1 4\n4 5\n5 6\n\nSample Output 1\n\n21\n\n頂点 1→2→3→4→5→6 と進むことで全ての頂点の点数を集めることができます。\n\nSample Input 2\n\n7 8\n1 3 3 5 2 2 3\n1 2\n2 3\n3 1\n1 4\n1 7\n1 5\n1 6\n5 6\n\nSample Output 2\n\n16\n\n頂点 1→2→3→1→5→6→1→4 と進むことで16点を集めることができます。", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1673, "cpu_time_ms": 1000, "memory_kb": 185960}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s526283139", "group_id": "codeNet:p01852", "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 println(recursive(sc.nextLong))\n }\n\n def recursive(N: Long): Long = {\n if (N == 0) (0) else (1 + recursive(N >> 1))\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}\n\n", "language": "Scala", "metadata": {"date": 1531922817, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01852.html", "problem_id": "p01852", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01852/input.txt", "sample_output_relpath": "derived/input_output/data/p01852/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01852/Scala/s526283139.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s526283139", "user_id": "u018134297"}, "prompt_components": {"gold_output": "0\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 println(recursive(sc.nextLong))\n }\n\n def recursive(N: Long): Long = {\n if (N == 0) (0) else (1 + recursive(N >> 1))\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}\n\n", "problem_context": "A : 指折り数えて / Finger Counting\n\n問題文\n\n肉西くんは指の数を増やしたり減らしたりできる.\n\n肉西くんの前には n 個のまんじゅうがある.\n\n肉西くんは指を折ってまんじゅうの個数を数えようとしている.\n\n肉西くんの指が取れる形は折れているか折れていないかの 2 つしか無い.\n\n肉西くんは 2 進数を理解している.\n\n肉西くんは各指に 2 進数の桁を対応させて数を数えることが出来る.\n\n肉西くんは対数を理解していない.\n\n肉西くんのかわりにまんじゅうを数え上げるのに必要な指の本数の最小値を求めよ.\n\n入力\n\nn\n\n制約\n\n整数である\n\n0 ≤ n ≤ 1018\n\n出力\n\n答えを 1 行に出力し,最後に改行を出力せよ.\n\nサンプル\n\nサンプル入力1\n\n0\n\nサンプル出力1\n\n0\n\nサンプル入力2\n\n4\n\nサンプル出力2\n\n3\n\nサンプル入力3\n\n31\n\nサンプル出力3\n\n5\n\nサンプル入力4\n\n36028797018963968\n\nサンプル出力4\n\n56", "sample_input": "0\n"}, "reference_outputs": ["0\n"], "source_document_id": "p01852", "source_text": "A : 指折り数えて / Finger Counting\n\n問題文\n\n肉西くんは指の数を増やしたり減らしたりできる.\n\n肉西くんの前には n 個のまんじゅうがある.\n\n肉西くんは指を折ってまんじゅうの個数を数えようとしている.\n\n肉西くんの指が取れる形は折れているか折れていないかの 2 つしか無い.\n\n肉西くんは 2 進数を理解している.\n\n肉西くんは各指に 2 進数の桁を対応させて数を数えることが出来る.\n\n肉西くんは対数を理解していない.\n\n肉西くんのかわりにまんじゅうを数え上げるのに必要な指の本数の最小値を求めよ.\n\n入力\n\nn\n\n制約\n\n整数である\n\n0 ≤ n ≤ 1018\n\n出力\n\n答えを 1 行に出力し,最後に改行を出力せよ.\n\nサンプル\n\nサンプル入力1\n\n0\n\nサンプル出力1\n\n0\n\nサンプル入力2\n\n4\n\nサンプル出力2\n\n3\n\nサンプル入力3\n\n31\n\nサンプル出力3\n\n5\n\nサンプル入力4\n\n36028797018963968\n\nサンプル出力4\n\n56", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4359, "cpu_time_ms": 280, "memory_kb": 45112}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s153841527", "group_id": "codeNet:p01867", "input_text": "import scala.io.StdIn._\nobject Main extends App {\n val n = readInt\n val expression = readLine.trim.split('+')\n val count = ('a' to 'z').map{c ⇒ expression.count{_.head == c}}.toArray\n println(\n if (n == 1) 1 else (1 to 9).map{size ⇒ count.count{_ == size}.let{term ⇒ if (term == 0) 0 else if (size == 1) term else if (term == 1) 3 else term + 4}}.sum + count.count{_ != 0} - 1\n )\n implicit class Extension[T](val value: T) extends AnyVal {\n @inline def let[A](@inline func: T ⇒ A): A = func(value)\n @inline def also(@inline func: T ⇒ Unit): T = {func(value); value}\n }\n}\n", "language": "Scala", "metadata": {"date": 1555256146, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01867.html", "problem_id": "p01867", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01867/input.txt", "sample_output_relpath": "derived/input_output/data/p01867/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01867/Scala/s153841527.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s153841527", "user_id": "u514597327"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.io.StdIn._\nobject Main extends App {\n val n = readInt\n val expression = readLine.trim.split('+')\n val count = ('a' to 'z').map{c ⇒ expression.count{_.head == c}}.toArray\n println(\n if (n == 1) 1 else (1 to 9).map{size ⇒ count.count{_ == size}.let{term ⇒ if (term == 0) 0 else if (size == 1) term else if (term == 1) 3 else term + 4}}.sum + count.count{_ != 0} - 1\n )\n implicit class Extension[T](val value: T) extends AnyVal {\n @inline def let[A](@inline func: T ⇒ A): A = func(value)\n @inline def also(@inline func: T ⇒ Unit): T = {func(value); value}\n }\n}\n", "problem_context": "MathJax.Hub.Config({\ntex2jax: {inlineMath: [['$','$'], ['\\\\(','\\\\)']]}\n});\n\nC: 足し算掛け算 / AddMul\n\n問題文\n\n情太くんは a から z までの文字と,\n足し算の記号 + しか知りません.\n情太くんには姉の立子さんがいます.\n立子さんはそれに加えて,掛け算 * と括弧 (,),\nそして 1 以上 9 以下の整数 (数字) も知っています.\nしかし,括弧を多重に使用すること,括弧の中で掛け算を行うことは知りません.\n\n例えば,次のような数式があったとします.\n\na+a+a\n\na+4*(b+c)\n\na+3*(b+2*(c+d))\n\na-b\n\na/b\n\n11*a\n\nこのうち,情太くんは 1. のみ,立子さんは 1. と 2. を書くことができます.\n3. から 6. は二人とも書くことができません.\n\nある日,情太くんは文字列としての長さが $n$ の多項式 $S$ を書きました.\nショートコーダーの立子さんは,掛け算と括弧と 1 以上 9\n以下の整数を使って,$S$ を文字列としてより短い恒等な多項式 $T$ に書きなおしてやりたいと思っています.\nしかし,そう簡単ではないようです.\n\nさて,立子さんのかわりに,文字列として最も短い $T$ を作り,\nその長さを出力するプログラムを書いてください.\n\n入力\n\n$N$\n\n$S$\n\n制約\n\n$1 \\leq N \\leq 499$\n\n$N$ は奇数である\n\n$S$ は a から z までのアルファベット小文字と\n+ のみからなる\n\n$S$ の最初の文字はアルファベットであり,その後 +\nとアルファベット $1$ 文字が交互に並ぶ\n\n$S$ に同じアルファベットは $9$ 個以下しか含まれない\n\n出力\n\n答えを $1$ 行で出力してください.\n\nサンプル\n\nサンプル入力1\n\n5\na+a+a\n\nサンプル出力1\n\n3\n\na*3 の $3$ 文字が最短です.\n\nサンプル入力2\n\n9\na+a+b+a+b\n\nサンプル出力2\n\n7\n\na*3+2*b または a*3+b+b の $7$ 文字が最短です.\n\nサンプル入力3\n\n11\na+a+b+a+b+b\n\nサンプル出力3\n\n7\n\n(a+b)*3 で $7$ 文字\n\nサンプル入力4\n\n3\na+a\n\nサンプル出力4\n\n3\n\na+a または a*2 で $3$ 文字", "sample_input": "5\na+a+a\n"}, "reference_outputs": ["3\n"], "source_document_id": "p01867", "source_text": "MathJax.Hub.Config({\ntex2jax: {inlineMath: [['$','$'], ['\\\\(','\\\\)']]}\n});\n\nC: 足し算掛け算 / AddMul\n\n問題文\n\n情太くんは a から z までの文字と,\n足し算の記号 + しか知りません.\n情太くんには姉の立子さんがいます.\n立子さんはそれに加えて,掛け算 * と括弧 (,),\nそして 1 以上 9 以下の整数 (数字) も知っています.\nしかし,括弧を多重に使用すること,括弧の中で掛け算を行うことは知りません.\n\n例えば,次のような数式があったとします.\n\na+a+a\n\na+4*(b+c)\n\na+3*(b+2*(c+d))\n\na-b\n\na/b\n\n11*a\n\nこのうち,情太くんは 1. のみ,立子さんは 1. と 2. を書くことができます.\n3. から 6. は二人とも書くことができません.\n\nある日,情太くんは文字列としての長さが $n$ の多項式 $S$ を書きました.\nショートコーダーの立子さんは,掛け算と括弧と 1 以上 9\n以下の整数を使って,$S$ を文字列としてより短い恒等な多項式 $T$ に書きなおしてやりたいと思っています.\nしかし,そう簡単ではないようです.\n\nさて,立子さんのかわりに,文字列として最も短い $T$ を作り,\nその長さを出力するプログラムを書いてください.\n\n入力\n\n$N$\n\n$S$\n\n制約\n\n$1 \\leq N \\leq 499$\n\n$N$ は奇数である\n\n$S$ は a から z までのアルファベット小文字と\n+ のみからなる\n\n$S$ の最初の文字はアルファベットであり,その後 +\nとアルファベット $1$ 文字が交互に並ぶ\n\n$S$ に同じアルファベットは $9$ 個以下しか含まれない\n\n出力\n\n答えを $1$ 行で出力してください.\n\nサンプル\n\nサンプル入力1\n\n5\na+a+a\n\nサンプル出力1\n\n3\n\na*3 の $3$ 文字が最短です.\n\nサンプル入力2\n\n9\na+a+b+a+b\n\nサンプル出力2\n\n7\n\na*3+2*b または a*3+b+b の $7$ 文字が最短です.\n\nサンプル入力3\n\n11\na+a+b+a+b+b\n\nサンプル出力3\n\n7\n\n(a+b)*3 で $7$ 文字\n\nサンプル入力4\n\n3\na+a\n\nサンプル出力4\n\n3\n\na+a または a*2 で $3$ 文字", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 597, "cpu_time_ms": 280, "memory_kb": 44976}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s787460922", "group_id": "codeNet:p01892", "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 A, B, N = sc.nextInt\n var ans = Long.MaxValue\n for (i <- 1 to N) {\n if (B % i == 0) {\n for (j <- 1 to N) {\n ans = math.min(ans, math.abs(A - B / i * j))\n }\n }\n }\n println(ans)\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": 1511480731, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01892.html", "problem_id": "p01892", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01892/input.txt", "sample_output_relpath": "derived/input_output/data/p01892/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01892/Scala/s787460922.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s787460922", "user_id": "u018134297"}, "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.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 A, B, N = sc.nextInt\n var ans = Long.MaxValue\n for (i <- 1 to N) {\n if (B % i == 0) {\n for (j <- 1 to N) {\n ans = math.min(ans, math.abs(A - B / i * j))\n }\n }\n }\n println(ans)\n }\n\n def main(args: Array[String]): Unit = {\n val sc: Scanner = new Scanner(System.in)\n solve(sc)\n }\n}", "problem_context": "MathJax.Hub.Config({\ntex2jax: {inlineMath: [['$','$'], ['\\\\(','\\\\)']]}\n});\n\nB: イカったー / SNS\n\n問題文\n\nAOR イカちゃんは最近少し機嫌が悪い。\nどうやら、”イカったー”のフォロー数とフォロワー数の比が気に入らないようだ\n。現在、AOR イカちゃんのフォロー数は $A$ 人、フォロワー数は $B$ 人であり、比は $A:B$ である。\n\nそこで、AOR イカちゃんはフォロー数とフォロワー数の比が気に入った整数比になるように、フォロー数を増減させることにした。\nなお気に入った整数比とは、比に含まれるどちらの値も $1$ 以上 $N$ 以下の整数となるように表せる比である。\n\nしかし、AOR イカちゃんはできるだけフォロー数を変更したくないので、変更前との差の絶対値をできるだけ小さくしたい。\nAOR イカちゃんの機嫌を良くするために、少なくともフォロー数をいくつ変更する必要があるかを求めるプログラムを作成せよ。\n\n入力\n\n$A \\ B \\ N$\n\n入力の制約\n\n$1 \\le A, \\ B \\le 10^{12}$\n\n$1 \\leq N \\leq 100 $\n\n出力\n\n気に入った整数比にできる、$A$ の変化量の絶対値の最小値を出力せよ。\n\nサンプル\n\nサンプル入力1\n\n19 30 3\n\nサンプル出力1\n\n1\n\nサンプル入力2\n\n3 7 7\n\nサンプル出力2\n\n0\n\nサンプル入力3\n\n3 7 1\n\nサンプル出力3\n\n4\n\nサンプル入力4\n\n102 30 3\n\nサンプル出力4\n\n12\n\nフォローを $12$ 人減らすことで $90:30 \\ (=3:1)$ になり、比の大きい方の数字が $3$ 以下となります。\n\nこのとき、変化量は $12$ です。\n\nサンプル入力5\n\n3 4 2\n\nサンプル出力5\n\n1\n\n一人フォローを外すと $2:4 \\ (=1:2)$ に、フォローすると $4:4 \\ (=1:1)$ になり、どちらも増減の絶対値は $1$ でそれが答えです。\n\nサンプル入力6\n\n1 100 2\n\nサンプル出力6\n\n49\n\n最低でも $1$ 人はフォローしていなければいけない事に注意してください。", "sample_input": "19 30 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p01892", "source_text": "MathJax.Hub.Config({\ntex2jax: {inlineMath: [['$','$'], ['\\\\(','\\\\)']]}\n});\n\nB: イカったー / SNS\n\n問題文\n\nAOR イカちゃんは最近少し機嫌が悪い。\nどうやら、”イカったー”のフォロー数とフォロワー数の比が気に入らないようだ\n。現在、AOR イカちゃんのフォロー数は $A$ 人、フォロワー数は $B$ 人であり、比は $A:B$ である。\n\nそこで、AOR イカちゃんはフォロー数とフォロワー数の比が気に入った整数比になるように、フォロー数を増減させることにした。\nなお気に入った整数比とは、比に含まれるどちらの値も $1$ 以上 $N$ 以下の整数となるように表せる比である。\n\nしかし、AOR イカちゃんはできるだけフォロー数を変更したくないので、変更前との差の絶対値をできるだけ小さくしたい。\nAOR イカちゃんの機嫌を良くするために、少なくともフォロー数をいくつ変更する必要があるかを求めるプログラムを作成せよ。\n\n入力\n\n$A \\ B \\ N$\n\n入力の制約\n\n$1 \\le A, \\ B \\le 10^{12}$\n\n$1 \\leq N \\leq 100 $\n\n出力\n\n気に入った整数比にできる、$A$ の変化量の絶対値の最小値を出力せよ。\n\nサンプル\n\nサンプル入力1\n\n19 30 3\n\nサンプル出力1\n\n1\n\nサンプル入力2\n\n3 7 7\n\nサンプル出力2\n\n0\n\nサンプル入力3\n\n3 7 1\n\nサンプル出力3\n\n4\n\nサンプル入力4\n\n102 30 3\n\nサンプル出力4\n\n12\n\nフォローを $12$ 人減らすことで $90:30 \\ (=3:1)$ になり、比の大きい方の数字が $3$ 以下となります。\n\nこのとき、変化量は $12$ です。\n\nサンプル入力5\n\n3 4 2\n\nサンプル出力5\n\n1\n\n一人フォローを外すと $2:4 \\ (=1:2)$ に、フォローすると $4:4 \\ (=1:1)$ になり、どちらも増減の絶対値は $1$ でそれが答えです。\n\nサンプル入力6\n\n1 100 2\n\nサンプル出力6\n\n49\n\n最低でも $1$ 人はフォローしていなければいけない事に注意してください。", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1338, "cpu_time_ms": 240, "memory_kb": 45140}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s997520400", "group_id": "codeNet:p01906", "input_text": "\nobject Main extends App {\n\n import scala.io.StdIn._\n import scala.math._\n\n\n val Array(n, m) = readLine.trim.split(' ').map(_.toInt)\n val a = readLine.trim.split(' ').map(_.toInt)\n val g = gcd(n, m)\n println(\n (0 until n / g).map{start ⇒ (0 until m).map(diff ⇒ a((start * g + diff) % n)).let{it ⇒ it.max - it.min}}.sum\n )\n\n def gcd(a: Int, b: Int): Int = {\n b match {\n case 0 ⇒ a\n case _ ⇒ gcd(b, a % b)\n }\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": 1545583055, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01906.html", "problem_id": "p01906", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01906/input.txt", "sample_output_relpath": "derived/input_output/data/p01906/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01906/Scala/s997520400.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s997520400", "user_id": "u514597327"}, "prompt_components": {"gold_output": "170\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) = readLine.trim.split(' ').map(_.toInt)\n val a = readLine.trim.split(' ').map(_.toInt)\n val g = gcd(n, m)\n println(\n (0 until n / g).map{start ⇒ (0 until m).map(diff ⇒ a((start * g + diff) % n)).let{it ⇒ it.max - it.min}}.sum\n )\n\n def gcd(a: Int, b: Int): Int = {\n b match {\n case 0 ⇒ a\n case _ ⇒ gcd(b, a % b)\n }\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": "MathJax.Hub.Config({\ntex2jax: {inlineMath: [['$','$'], ['\\\\(','\\\\)']]}\n});\n\nB: 重さの範囲\n\n問題\n\n重さの異なる $N$ 色のボールがキューにたくさん入っています。キューには、先頭から\n$1,2,3, \\dots ,N-1,N,1,2,3, \\dots ,N-1,N,1,2,3, \\dots$ というふうに昇順にボールが並んでいて、\n色 $N$ のボールの後ろにはまた色 $1$ のボールから順に入っています。\n同じ色のボールはそれぞれ同じ重さであり、色 $i$ のボールの重さは $A_i$ です。\n\nこの状態から、キューの先頭からボールを $M$ 個取り出し、これを 1 つのグループとする作業を繰り返します。\nそして、キューから取り出した各色のボールの総数がすべて等しくなったときにグループを作る作業をやめます。\nなお、キューには十分な数のボールが入っており、グループを作る作業をやめるまでにキューの中身が空になることはありません。\n\nたとえば、\n$N=8, M=2$ のとき、{色1,色2}, {色3,色4}, {色5,色6}, {色7,色8} の 4 グループができます\n(このとき各色のボールは 1 つずつ存在する)。\n$N=4, M=3$ のとき、{色1,色2,色3}, {色4,色1,色2}, {色3,色4,色1}, {色2,色3,色4} の $4$\nグループができます (このとき各色のボールはそれぞれ3つずつ存在する)。\n\nこのとき、各グループにおいて、\n含まれるボールの重さの最大値と最小値の差をそのグループの重さの範囲と呼ぶことにします。\n各グループの重さの範囲の総和を出力してください。\n\n制約\n\n$1 \\le N \\le 1000$\n\n$1 \\le M \\le N$\n\n$0 \\le A_i \\le 100$\n\n入力は全て整数である\n\n入力形式\n\n入力は以下の形式で与えられます。\n\n$N \\ M$\n\n$A_1 \\cdots A_N$\n\n出力\n\n答えを 1 行で出力してください。また、末尾に改行も出力してください。\n\nサンプル\n\nサンプル入力 1\n\n8 2\n23 61 57 13 91 41 79 41\n\nサンプル出力 1\n\n170\n\n重さの範囲の総和は $38+44+50+38=170$ となります。\n\nサンプル入力 2\n\n4 3\n72 46 67 5\n\nサンプル出力 2\n\n222\n\n重さの範囲の総和は $26+67+67+62=222$ となります。\n\nサンプル入力 3\n\n4 2\n1 2 3 5\n\nサンプル出力 3\n\n3\n\n重さの範囲の総和は $1+2=3$ となります。", "sample_input": "8 2\n23 61 57 13 91 41 79 41\n"}, "reference_outputs": ["170\n"], "source_document_id": "p01906", "source_text": "MathJax.Hub.Config({\ntex2jax: {inlineMath: [['$','$'], ['\\\\(','\\\\)']]}\n});\n\nB: 重さの範囲\n\n問題\n\n重さの異なる $N$ 色のボールがキューにたくさん入っています。キューには、先頭から\n$1,2,3, \\dots ,N-1,N,1,2,3, \\dots ,N-1,N,1,2,3, \\dots$ というふうに昇順にボールが並んでいて、\n色 $N$ のボールの後ろにはまた色 $1$ のボールから順に入っています。\n同じ色のボールはそれぞれ同じ重さであり、色 $i$ のボールの重さは $A_i$ です。\n\nこの状態から、キューの先頭からボールを $M$ 個取り出し、これを 1 つのグループとする作業を繰り返します。\nそして、キューから取り出した各色のボールの総数がすべて等しくなったときにグループを作る作業をやめます。\nなお、キューには十分な数のボールが入っており、グループを作る作業をやめるまでにキューの中身が空になることはありません。\n\nたとえば、\n$N=8, M=2$ のとき、{色1,色2}, {色3,色4}, {色5,色6}, {色7,色8} の 4 グループができます\n(このとき各色のボールは 1 つずつ存在する)。\n$N=4, M=3$ のとき、{色1,色2,色3}, {色4,色1,色2}, {色3,色4,色1}, {色2,色3,色4} の $4$\nグループができます (このとき各色のボールはそれぞれ3つずつ存在する)。\n\nこのとき、各グループにおいて、\n含まれるボールの重さの最大値と最小値の差をそのグループの重さの範囲と呼ぶことにします。\n各グループの重さの範囲の総和を出力してください。\n\n制約\n\n$1 \\le N \\le 1000$\n\n$1 \\le M \\le N$\n\n$0 \\le A_i \\le 100$\n\n入力は全て整数である\n\n入力形式\n\n入力は以下の形式で与えられます。\n\n$N \\ M$\n\n$A_1 \\cdots A_N$\n\n出力\n\n答えを 1 行で出力してください。また、末尾に改行も出力してください。\n\nサンプル\n\nサンプル入力 1\n\n8 2\n23 61 57 13 91 41 79 41\n\nサンプル出力 1\n\n170\n\n重さの範囲の総和は $38+44+50+38=170$ となります。\n\nサンプル入力 2\n\n4 3\n72 46 67 5\n\nサンプル出力 2\n\n222\n\n重さの範囲の総和は $26+67+67+62=222$ となります。\n\nサンプル入力 3\n\n4 2\n1 2 3 5\n\nサンプル出力 3\n\n3\n\n重さの範囲の総和は $1+2=3$ となります。", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 620, "cpu_time_ms": 340, "memory_kb": 63344}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s552791456", "group_id": "codeNet:p01929", "input_text": "import java.util.Scanner\n\nobject Main {\n private val Mod = (1e9 + 7).toInt\n private val Fact = {\n var cur = 1L\n for (i <- 0 to 200000) yield {\n if (i == 0) {\n 1\n } else {\n cur = (cur * i) % Mod\n cur\n }\n }\n }\n private val Pow = {\n val pow = new Array[Int](200000)\n pow(0) = 1\n for (i <- 1 until pow.length) pow(i) = pow(i - 1) * 2 % Mod\n pow\n }\n\n def main(args: Array[String]): Unit = {\n val in = new Scanner(System.in)\n while (true) {\n val n = in.nextInt()\n println(n)\n if (n == 0) {\n return\n }\n val a = for (_ <- 0 until n) yield {\n in.nextInt() - 1\n }\n println(solve(a.toArray))\n }\n }\n\n def check(parent: Array[Int]): Boolean = {\n val n = parent.length\n var ok = true\n\n val children = Array.fill[Int](n)(0)\n parent.foreach(parent => children(parent) += 1)\n val dist = Array.fill[Int](n)(-1)\n for (i <- children.indices) if (children(i) == 0) {\n var cur = i\n dist(i) = 0\n var finish = false\n while (!finish) {\n val next = parent(cur)\n if (dist(next) == -1) {\n dist(next) = dist(cur) + 1\n cur = next\n } else if (dist(next) != dist(cur) - 1) {\n ok = false\n finish = true\n } else {\n finish = true\n }\n }\n }\n\n for (i <- children.indices) if (dist(i) == -1 && parent(parent(i)) != i) {\n ok = false\n }\n ok\n }\n\n def getSize(array: Array[Int]): (Int, Int) = {\n val N = array.length\n val uf = new UnionFind(N)\n for (i <- array.indices) uf.unite(i, array(i))\n val sizes = for {\n i <- 0 until N\n if i == 0 || !uf.isSame(i, 0)\n } yield {\n if (i == 0) {\n uf.partialSizeOf(i)\n } else {\n val s = uf.partialSizeOf(i)\n uf.unite(i, 0)\n s\n }\n }\n\n var three = 0\n var two = 0\n sizes.foreach(size => if (size == 2) {\n two += 1\n } else {\n three += 1\n })\n\n (two, three)\n }\n\n def solve(array: Array[Int]): Int = {\n val n = array.length\n val combination = new Combination(n + 1, Mod)\n\n if (check(array)) {\n val (two, three) = getSize(array)\n if (three == 0) {\n var cur: Long = ((two + 2) / 2) % Mod\n cur = cur * Pow(two) % Mod\n cur = cur * Fact(two) % Mod\n cur.toInt\n } else {\n var ans = 0L\n for (i <- 0 to math.min(two + three - 2, two)) {\n var cur = combination.get(two + three - i - 2, two - i).toLong\n cur = cur * Fact(two) % Mod\n cur = cur * Fact(three) % Mod\n cur = cur * Pow(two + three) % Mod\n cur = cur * (two + three - i - 1) % Mod\n cur = cur * ((i + 2) / 2) % Mod\n ans = (ans + cur) % Mod\n }\n for (i <- 0 to math.min(two + three - 1, two)) {\n var cur = combination.get(two + three - i - 1, two - i).toLong\n cur = cur * Fact(two) % Mod\n cur = cur * Fact(three) % Mod\n cur = cur * Pow(two + three) % Mod\n cur = cur * ((i + 2) / 2) % Mod\n ans = (ans + cur * 2) % Mod\n }\n ans.toInt\n }\n } else {\n 0\n }\n }\n}\n\nclass UnionFind(n: Int) {\n private val parent = (0 until n).toArray\n private val sizes = Array.fill[Int](n)(1)\n private var _size = n\n\n def find(x: Int): Int = {\n if (x == parent(x)) {\n x\n } else {\n parent(x) = find(parent(x))\n parent(x)\n }\n }\n\n def unite(a: Int, b: Int): Boolean = {\n val fa = find(a)\n val fb = find(b)\n if (fa == fb) {\n false\n } else {\n val (x, y) = if (sizes(fa) >= sizes(fb)) {\n (fa, fb)\n } else {\n (fb, fa)\n }\n\n parent(y) = x\n sizes(x) += sizes(y)\n sizes(y) = 0\n\n _size -= 1\n true\n }\n }\n\n def isSame(x: Int, y: Int): Boolean = find(x) == find(y)\n\n def partialSizeOf(x: Int): Int = sizes(find(x))\n\n def size(): Int = _size\n}\n\nclass Combination(max: Int, mod: Int) {\n private val inv = new Array[Long](max + 1)\n private val fact = new Array[Long](max + 1)\n private val invFact = new Array[Long](max + 1)\n inv(1) = 1\n for (i <- 2 to max) inv(i) = inv(mod % i) * (mod - mod / i) % mod\n fact(0) = 1\n invFact(0) = 1\n for (i <- 1 to max) fact(i) = (fact(i - 1) * i) % mod\n for (i <- 1 to max) invFact(i) = (invFact(i - 1) * inv(i)) % mod\n\n /**\n * get nCm\n */\n def get(n: Int, m: Int): Int = {\n if (n < m) {\n 0\n } else fact(n) * invFact(m) % mod * invFact(n - m) % mod\n }.toInt\n}", "language": "Scala", "metadata": {"date": 1509954084, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01929.html", "problem_id": "p01929", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01929/input.txt", "sample_output_relpath": "derived/input_output/data/p01929/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01929/Scala/s552791456.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s552791456", "user_id": "u568152427"}, "prompt_components": {"gold_output": "2\n0\n0\n144\n633544712\n11520\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n private val Mod = (1e9 + 7).toInt\n private val Fact = {\n var cur = 1L\n for (i <- 0 to 200000) yield {\n if (i == 0) {\n 1\n } else {\n cur = (cur * i) % Mod\n cur\n }\n }\n }\n private val Pow = {\n val pow = new Array[Int](200000)\n pow(0) = 1\n for (i <- 1 until pow.length) pow(i) = pow(i - 1) * 2 % Mod\n pow\n }\n\n def main(args: Array[String]): Unit = {\n val in = new Scanner(System.in)\n while (true) {\n val n = in.nextInt()\n println(n)\n if (n == 0) {\n return\n }\n val a = for (_ <- 0 until n) yield {\n in.nextInt() - 1\n }\n println(solve(a.toArray))\n }\n }\n\n def check(parent: Array[Int]): Boolean = {\n val n = parent.length\n var ok = true\n\n val children = Array.fill[Int](n)(0)\n parent.foreach(parent => children(parent) += 1)\n val dist = Array.fill[Int](n)(-1)\n for (i <- children.indices) if (children(i) == 0) {\n var cur = i\n dist(i) = 0\n var finish = false\n while (!finish) {\n val next = parent(cur)\n if (dist(next) == -1) {\n dist(next) = dist(cur) + 1\n cur = next\n } else if (dist(next) != dist(cur) - 1) {\n ok = false\n finish = true\n } else {\n finish = true\n }\n }\n }\n\n for (i <- children.indices) if (dist(i) == -1 && parent(parent(i)) != i) {\n ok = false\n }\n ok\n }\n\n def getSize(array: Array[Int]): (Int, Int) = {\n val N = array.length\n val uf = new UnionFind(N)\n for (i <- array.indices) uf.unite(i, array(i))\n val sizes = for {\n i <- 0 until N\n if i == 0 || !uf.isSame(i, 0)\n } yield {\n if (i == 0) {\n uf.partialSizeOf(i)\n } else {\n val s = uf.partialSizeOf(i)\n uf.unite(i, 0)\n s\n }\n }\n\n var three = 0\n var two = 0\n sizes.foreach(size => if (size == 2) {\n two += 1\n } else {\n three += 1\n })\n\n (two, three)\n }\n\n def solve(array: Array[Int]): Int = {\n val n = array.length\n val combination = new Combination(n + 1, Mod)\n\n if (check(array)) {\n val (two, three) = getSize(array)\n if (three == 0) {\n var cur: Long = ((two + 2) / 2) % Mod\n cur = cur * Pow(two) % Mod\n cur = cur * Fact(two) % Mod\n cur.toInt\n } else {\n var ans = 0L\n for (i <- 0 to math.min(two + three - 2, two)) {\n var cur = combination.get(two + three - i - 2, two - i).toLong\n cur = cur * Fact(two) % Mod\n cur = cur * Fact(three) % Mod\n cur = cur * Pow(two + three) % Mod\n cur = cur * (two + three - i - 1) % Mod\n cur = cur * ((i + 2) / 2) % Mod\n ans = (ans + cur) % Mod\n }\n for (i <- 0 to math.min(two + three - 1, two)) {\n var cur = combination.get(two + three - i - 1, two - i).toLong\n cur = cur * Fact(two) % Mod\n cur = cur * Fact(three) % Mod\n cur = cur * Pow(two + three) % Mod\n cur = cur * ((i + 2) / 2) % Mod\n ans = (ans + cur * 2) % Mod\n }\n ans.toInt\n }\n } else {\n 0\n }\n }\n}\n\nclass UnionFind(n: Int) {\n private val parent = (0 until n).toArray\n private val sizes = Array.fill[Int](n)(1)\n private var _size = n\n\n def find(x: Int): Int = {\n if (x == parent(x)) {\n x\n } else {\n parent(x) = find(parent(x))\n parent(x)\n }\n }\n\n def unite(a: Int, b: Int): Boolean = {\n val fa = find(a)\n val fb = find(b)\n if (fa == fb) {\n false\n } else {\n val (x, y) = if (sizes(fa) >= sizes(fb)) {\n (fa, fb)\n } else {\n (fb, fa)\n }\n\n parent(y) = x\n sizes(x) += sizes(y)\n sizes(y) = 0\n\n _size -= 1\n true\n }\n }\n\n def isSame(x: Int, y: Int): Boolean = find(x) == find(y)\n\n def partialSizeOf(x: Int): Int = sizes(find(x))\n\n def size(): Int = _size\n}\n\nclass Combination(max: Int, mod: Int) {\n private val inv = new Array[Long](max + 1)\n private val fact = new Array[Long](max + 1)\n private val invFact = new Array[Long](max + 1)\n inv(1) = 1\n for (i <- 2 to max) inv(i) = inv(mod % i) * (mod - mod / i) % mod\n fact(0) = 1\n invFact(0) = 1\n for (i <- 1 to max) fact(i) = (fact(i - 1) * i) % mod\n for (i <- 1 to max) invFact(i) = (invFact(i - 1) * inv(i)) % mod\n\n /**\n * get nCm\n */\n def get(n: Int, m: Int): Int = {\n if (n < m) {\n 0\n } else fact(n) * invFact(m) % mod * invFact(n - m) % mod\n }.toInt\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nへやわり!\n\nN+1 部屋が1列に並んだ新築の建物がある.各部屋はすべて1人用の住居であり,現在どの部屋も空室だが,来月から新たに N 人がここに住む予定である.したがって彼らが暮らし始めると1室は空き部屋になる.\n\nあなたは大家として,彼らの嗜好に合わせた部屋割りを多く提案したいと考えている.ここで部屋割りとは,それぞれの人がどの部屋に住むのかを与える表である.例えば N = 3 のとき,「1人目は4号室,2人目は1号室,3人目は2号室」がありうる一つの部屋割りである.\n\nもちろん,ありうるすべての部屋割りを提案すれば話は早いが,それでは提案の意味がないため,大家の手間と住人の嗜好を考慮していくつか制約を設ける.\n\nまず,提案された部屋割りの一つに彼らが住み始めてから,「別の提案された部屋割りの方に変更したい」と言われるかもしれない.この建物は新築であり,彼らはまだ誰も入居していない新しい部屋が好みであることがわかっているので,単純に誰か1人が空き部屋へ引っ越しをするだけで提案された別の部屋割りに変更できるときに限りこれが起こりうる.しかし大家として,そういう面倒ごとは避けたいため,このような変更が許されないよう,提案する部屋割りをうまく調整したい.\nつまり,提案する部屋割りの集合は次を満たさなければならない.\n「任意の二つの異なる提案された部屋割り A, B に対して,部屋割り A の空き部屋に誰か1人を移しても部屋割り B にならない」\n\n次に,これから住む N 人にはそれぞれちょうど1人好ましい人がいることがわかっている.したがって,提案するすべての部屋割りは,すべての人に対して好ましい人が隣に住むような部屋割りにする.\n\nこれらの条件を満たす部屋割りの集合で,最大の集合の大きさはいくらだろうか?1,000,000,007 で割った余りを求めてほしい.\n\nInput\n\n入力は複数のデータセットからなる.\n各データセットは次の形式で表される.\n\nN\na1 a2 ... aN\n\nデータセットの 1 行目には,来月建物に住む人数を表す整数 N が与えられる.これは 2 ≤ N ≤ 100,000 を満たす.\n2行目には i 番目の人にとって隣の部屋に住んでくれると好ましい人の番号 ai の情報が与えられる.これについては 1 ≤ ai ≤ N かつ ai ≠ i を満たす.\nまた,データセットの数は 50 を超えない.\n入力の終わりは,1個のゼロだけからなる行で表される.\n\nOutput\n\n各データセットに対して,問題文にあるような,同時に提案できる部屋割りの数の最大値を,1,000,000,007 で割った余りを1行で出力せよ.\n\nSample Input\n\n2\n2 1\n3\n3 1 2\n10\n2 1 1 1 1 1 1 1 1 1\n8\n2 1 4 3 3 7 6 6\n25\n2 3 2 5 4 5 8 7 8 11 10 13 12 15 14 17 16 19 18 21 20 23 22 25 24\n10\n2 1 4 3 6 5 8 7 10 9\n0\n\nOutput for Sample Input\n\n2\n0\n0\n144\n633544712\n11520", "sample_input": "2\n2 1\n3\n3 1 2\n10\n2 1 1 1 1 1 1 1 1 1\n8\n2 1 4 3 3 7 6 6\n25\n2 3 2 5 4 5 8 7 8 11 10 13 12 15 14 17 16 19 18 21 20 23 22 25 24\n10\n2 1 4 3 6 5 8 7 10 9\n0\n"}, "reference_outputs": ["2\n0\n0\n144\n633544712\n11520\n"], "source_document_id": "p01929", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nへやわり!\n\nN+1 部屋が1列に並んだ新築の建物がある.各部屋はすべて1人用の住居であり,現在どの部屋も空室だが,来月から新たに N 人がここに住む予定である.したがって彼らが暮らし始めると1室は空き部屋になる.\n\nあなたは大家として,彼らの嗜好に合わせた部屋割りを多く提案したいと考えている.ここで部屋割りとは,それぞれの人がどの部屋に住むのかを与える表である.例えば N = 3 のとき,「1人目は4号室,2人目は1号室,3人目は2号室」がありうる一つの部屋割りである.\n\nもちろん,ありうるすべての部屋割りを提案すれば話は早いが,それでは提案の意味がないため,大家の手間と住人の嗜好を考慮していくつか制約を設ける.\n\nまず,提案された部屋割りの一つに彼らが住み始めてから,「別の提案された部屋割りの方に変更したい」と言われるかもしれない.この建物は新築であり,彼らはまだ誰も入居していない新しい部屋が好みであることがわかっているので,単純に誰か1人が空き部屋へ引っ越しをするだけで提案された別の部屋割りに変更できるときに限りこれが起こりうる.しかし大家として,そういう面倒ごとは避けたいため,このような変更が許されないよう,提案する部屋割りをうまく調整したい.\nつまり,提案する部屋割りの集合は次を満たさなければならない.\n「任意の二つの異なる提案された部屋割り A, B に対して,部屋割り A の空き部屋に誰か1人を移しても部屋割り B にならない」\n\n次に,これから住む N 人にはそれぞれちょうど1人好ましい人がいることがわかっている.したがって,提案するすべての部屋割りは,すべての人に対して好ましい人が隣に住むような部屋割りにする.\n\nこれらの条件を満たす部屋割りの集合で,最大の集合の大きさはいくらだろうか?1,000,000,007 で割った余りを求めてほしい.\n\nInput\n\n入力は複数のデータセットからなる.\n各データセットは次の形式で表される.\n\nN\na1 a2 ... aN\n\nデータセットの 1 行目には,来月建物に住む人数を表す整数 N が与えられる.これは 2 ≤ N ≤ 100,000 を満たす.\n2行目には i 番目の人にとって隣の部屋に住んでくれると好ましい人の番号 ai の情報が与えられる.これについては 1 ≤ ai ≤ N かつ ai ≠ i を満たす.\nまた,データセットの数は 50 を超えない.\n入力の終わりは,1個のゼロだけからなる行で表される.\n\nOutput\n\n各データセットに対して,問題文にあるような,同時に提案できる部屋割りの数の最大値を,1,000,000,007 で割った余りを1行で出力せよ.\n\nSample Input\n\n2\n2 1\n3\n3 1 2\n10\n2 1 1 1 1 1 1 1 1 1\n8\n2 1 4 3 3 7 6 6\n25\n2 3 2 5 4 5 8 7 8 11 10 13 12 15 14 17 16 19 18 21 20 23 22 25 24\n10\n2 1 4 3 6 5 8 7 10 9\n0\n\nOutput for Sample Input\n\n2\n0\n0\n144\n633544712\n11520", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4512, "cpu_time_ms": 1260, "memory_kb": 453152}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s693477931", "group_id": "codeNet:p01939", "input_text": "object Main extends App {\n import scala.collection.mutable\n import scala.io.StdIn._\n\n val mod = 1000000007L\n val Array(n, m) = readLine.trim.split(' ').map(_.toLong)\n if (n == 1) println((m + 1) % mod)\n else {\n val maxDiff = (m / (n - 1)) % mod\n println((((((m + 1) % mod) * maxDiff * 2) % mod + (m + 1) % mod - (maxDiff * (maxDiff + 1) % mod) * (n - 1)) % mod + mod) % mod)\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}\n", "language": "Scala", "metadata": {"date": 1549960713, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01939.html", "problem_id": "p01939", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01939/input.txt", "sample_output_relpath": "derived/input_output/data/p01939/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01939/Scala/s693477931.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s693477931", "user_id": "u514597327"}, "prompt_components": {"gold_output": "50\n", "input_to_evaluate": "object Main extends App {\n import scala.collection.mutable\n import scala.io.StdIn._\n\n val mod = 1000000007L\n val Array(n, m) = readLine.trim.split(' ').map(_.toLong)\n if (n == 1) println((m + 1) % mod)\n else {\n val maxDiff = (m / (n - 1)) % mod\n println((((((m + 1) % mod) * maxDiff * 2) % mod + (m + 1) % mod - (maxDiff * (maxDiff + 1) % mod) * (n - 1)) % mod + mod) % mod)\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}\n", "problem_context": "B: えびちゃんと数列 - Ebi-chan and Integer Sequences -\n\n問題\n\nえびちゃんは数列が好きです。中でも等差数列が特に好きです。\n今回は以下の条件を満たす数列を作ることにしました。\n\n長さ n の等差数列である\n\n数列の i 番目の要素を s_i と定める時、全ての s_i (1 \\leq i \\leq n) が 0 \\leq s_i \\leq m を満たす整数である\n\n上の条件を満たすような数列はいくつあるでしょうか?\nただし答えは非常に大きくなることがあるので、 10^9 + 7 で割った余りを出力してください。\n\n入力形式\n\n入力は一行で与えられる。\n\nn m\n\nn は数列の長さを表す。\n\n制約\n\n1 \\leq n \\leq 10^{15}\n\n0 \\leq m \\leq 10^{15}\n\n出力形式\n\n条件を満たす等差数列の数を 10^9 + 7 で割った余りを一行に出力せよ。\n\n入力例1\n\n3 9\n\n出力例1\n\n50\n\n入力例2\n\n10000000000 10000000000\n\n出力例2\n\n999999942\n\n入力は32bit整数には収まりきらないことに注意してください。", "sample_input": "3 9\n"}, "reference_outputs": ["50\n"], "source_document_id": "p01939", "source_text": "B: えびちゃんと数列 - Ebi-chan and Integer Sequences -\n\n問題\n\nえびちゃんは数列が好きです。中でも等差数列が特に好きです。\n今回は以下の条件を満たす数列を作ることにしました。\n\n長さ n の等差数列である\n\n数列の i 番目の要素を s_i と定める時、全ての s_i (1 \\leq i \\leq n) が 0 \\leq s_i \\leq m を満たす整数である\n\n上の条件を満たすような数列はいくつあるでしょうか?\nただし答えは非常に大きくなることがあるので、 10^9 + 7 で割った余りを出力してください。\n\n入力形式\n\n入力は一行で与えられる。\n\nn m\n\nn は数列の長さを表す。\n\n制約\n\n1 \\leq n \\leq 10^{15}\n\n0 \\leq m \\leq 10^{15}\n\n出力形式\n\n条件を満たす等差数列の数を 10^9 + 7 で割った余りを一行に出力せよ。\n\n入力例1\n\n3 9\n\n出力例1\n\n50\n\n入力例2\n\n10000000000 10000000000\n\n出力例2\n\n999999942\n\n入力は32bit整数には収まりきらないことに注意してください。", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 608, "cpu_time_ms": 270, "memory_kb": 44180}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s472563307", "group_id": "codeNet:p01997", "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 sc.nextLong()\n val A = sc.nextLong()\n println(A * A * A * 4 * scala.math.Pi / 3)\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, sc: => Scanner): Unit = {\n if (X != 0) {\n println(sc.nextString() match {\n case \"Sun\" => \"Mon\"\n case \"Mon\" => \"Tue\"\n case \"Tue\" => \"Wed\"\n case \"Wed\" => \"Thu\"\n case \"Thu\" => \"Fri\"\n case \"Fri\" => \"Sat\"\n case \"Sat\" => \"Sun\"\n })\n recursive(X - 1, sc)\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\n", "language": "Scala", "metadata": {"date": 1542633279, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p01997.html", "problem_id": "p01997", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p01997/input.txt", "sample_output_relpath": "derived/input_output/data/p01997/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p01997/Scala/s472563307.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s472563307", "user_id": "u018134297"}, "prompt_components": {"gold_output": "33.510322\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 sc.nextLong()\n val A = sc.nextLong()\n println(A * A * A * 4 * scala.math.Pi / 3)\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, sc: => Scanner): Unit = {\n if (X != 0) {\n println(sc.nextString() match {\n case \"Sun\" => \"Mon\"\n case \"Mon\" => \"Tue\"\n case \"Tue\" => \"Wed\"\n case \"Wed\" => \"Thu\"\n case \"Thu\" => \"Fri\"\n case \"Fri\" => \"Sat\"\n case \"Sat\" => \"Sun\"\n })\n recursive(X - 1, sc)\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\n", "problem_context": "B: 直角三角形\n\n問題\n\n直角三角形の斜辺でない $2$ 辺の長さ $A$ , $B$ が与えられる。\n長さ $A$ の辺は $x$ 軸と重なっており、長さ $B$ の辺は $y$ 軸と重なっている。\n\n次の操作を行う。\n\n三角形を $x$ 軸周りに回転させる。\n\n操作 $1$ を行ってできた図形を $y$ 軸周りに回転させる。\n\n操作 $2$ を行ってできた図形の体積を求めよ。\n\n制約\n\n入力値は全て整数である。\n\n$1 < A < B < 1000$\n\n入力形式\n\n入力は以下の形式で与えられる。\n\n$A\\ B$\n\n出力\n\n図形の体積を出力せよ。また、末尾に改行も出力せよ。なお、 $0.000001$ 未満の絶対誤差または相対誤差が許容される。\n\nサンプル\n\nサンプル入力 1\n\n1 2\n\nサンプル出力 1\n\n33.510322\n\nサンプル入力 2\n\n7 9\n\nサンプル出力 2\n\n3053.628059", "sample_input": "1 2\n"}, "reference_outputs": ["33.510322\n"], "source_document_id": "p01997", "source_text": "B: 直角三角形\n\n問題\n\n直角三角形の斜辺でない $2$ 辺の長さ $A$ , $B$ が与えられる。\n長さ $A$ の辺は $x$ 軸と重なっており、長さ $B$ の辺は $y$ 軸と重なっている。\n\n次の操作を行う。\n\n三角形を $x$ 軸周りに回転させる。\n\n操作 $1$ を行ってできた図形を $y$ 軸周りに回転させる。\n\n操作 $2$ を行ってできた図形の体積を求めよ。\n\n制約\n\n入力値は全て整数である。\n\n$1 < A < B < 1000$\n\n入力形式\n\n入力は以下の形式で与えられる。\n\n$A\\ B$\n\n出力\n\n図形の体積を出力せよ。また、末尾に改行も出力せよ。なお、 $0.000001$ 未満の絶対誤差または相対誤差が許容される。\n\nサンプル\n\nサンプル入力 1\n\n1 2\n\nサンプル出力 1\n\n33.510322\n\nサンプル入力 2\n\n7 9\n\nサンプル出力 2\n\n3053.628059", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6213, "cpu_time_ms": 270, "memory_kb": 44496}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s309290460", "group_id": "codeNet:p02028", "input_text": "object Main extends App {\n import scala.io.StdIn._\n\n\n val Array(h, w) = readLine.trim.split(' ').map(_.toInt)\n val a = readLine.trim.split(' ').map(_.toInt).sorted\n val b = readLine.trim.split(' ').map(_.toInt).sorted\n\n println(\n b.map(n ⇒ (h - upperBound(a, n)) * n).sum + a.map(n ⇒ (w - lowerBound(b, n)) * n).sum\n )\n\n def upperBound(array: Array[Int], target: Int): Long = {\n var left = 0\n var right = array.length\n while(left < right){\n val mid = (left + right) / 2\n if (array(mid) <= target){\n left = mid + 1\n }else {\n right = mid\n }\n }\n right\n }\n def lowerBound(array: Array[Int], target: Int): Long = {\n var left = 0\n var right = array.length\n while(left < right){\n val mid = (left + right) / 2\n if (array(mid) < target){\n left = mid + 1\n }else {\n right = mid\n }\n }\n right\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": 1551785231, "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/s309290460.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s309290460", "user_id": "u514597327"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "object Main extends App {\n import scala.io.StdIn._\n\n\n val Array(h, w) = readLine.trim.split(' ').map(_.toInt)\n val a = readLine.trim.split(' ').map(_.toInt).sorted\n val b = readLine.trim.split(' ').map(_.toInt).sorted\n\n println(\n b.map(n ⇒ (h - upperBound(a, n)) * n).sum + a.map(n ⇒ (w - lowerBound(b, n)) * n).sum\n )\n\n def upperBound(array: Array[Int], target: Int): Long = {\n var left = 0\n var right = array.length\n while(left < right){\n val mid = (left + right) / 2\n if (array(mid) <= target){\n left = mid + 1\n }else {\n right = mid\n }\n }\n right\n }\n def lowerBound(array: Array[Int], target: Int): Long = {\n var left = 0\n var right = array.length\n while(left < right){\n val mid = (left + right) / 2\n if (array(mid) < target){\n left = mid + 1\n }else {\n right = mid\n }\n }\n right\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": "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 710, "memory_kb": 108008}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s104487020", "group_id": "codeNet:p02032", "input_text": "\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.mutable.ArrayBuffer\nobject Main extends App {\n import scala.io.StdIn._\n\n\n val n = readLong\n val prime = primes(1000000)\n val primeFactor = calPrimeFactor(n)\n if (primeFactor.length == 1 && primeFactor.head == 1){\n println(s\"1 1\")\n }else {\n val divisor = divisors(primeFactor)\n println(s\"${primeFactor.length} $divisor\")\n }\n\n def divisors(primeFactor: List[Int]): Long = {\n var r = 1L\n for (e ← primeFactor){\n r *= (e + 1)\n }\n r - 1\n }\n def calPrimeFactor(number: Long): List[Int] = {\n @tailrec\n def sub(n: Long, i: Int, rest: List[Int] = Nil): List[Int] ={\n if (n == 1) rest\n else if (i == prime.length) 1::rest\n else if (n % prime(i) != 0) sub(n, i + 1, rest)\n else {\n var c = 0\n var nn = n\n while(nn % prime(i) == 0){\n c += 1\n nn /= prime(i)\n }\n sub(nn, i + 1, c::rest)\n }\n }\n sub(number, 0)\n }\n def primes(upper: Int): Array[Int] = {\n val memo = Array.tabulate(upper + 1){_ ⇒ true}\n for (i ← 2 to math.sqrt(upper).toInt if memo(i)){\n for (j ← i * 2 to upper by i){\n memo(j) = false\n }\n }\n (2 to upper).filter(memo).toArray\n }\n implicit class Scope[T](val value: T) extends AnyVal {\n @inline\n def let[A](func: T ⇒ A): A = func(value)\n @inline\n def also(func: T ⇒ Unit): T = {\n func(value)\n value\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1551926838, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02032.html", "problem_id": "p02032", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02032/input.txt", "sample_output_relpath": "derived/input_output/data/p02032/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02032/Scala/s104487020.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s104487020", "user_id": "u514597327"}, "prompt_components": {"gold_output": "2 5\n", "input_to_evaluate": "\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.mutable.ArrayBuffer\nobject Main extends App {\n import scala.io.StdIn._\n\n\n val n = readLong\n val prime = primes(1000000)\n val primeFactor = calPrimeFactor(n)\n if (primeFactor.length == 1 && primeFactor.head == 1){\n println(s\"1 1\")\n }else {\n val divisor = divisors(primeFactor)\n println(s\"${primeFactor.length} $divisor\")\n }\n\n def divisors(primeFactor: List[Int]): Long = {\n var r = 1L\n for (e ← primeFactor){\n r *= (e + 1)\n }\n r - 1\n }\n def calPrimeFactor(number: Long): List[Int] = {\n @tailrec\n def sub(n: Long, i: Int, rest: List[Int] = Nil): List[Int] ={\n if (n == 1) rest\n else if (i == prime.length) 1::rest\n else if (n % prime(i) != 0) sub(n, i + 1, rest)\n else {\n var c = 0\n var nn = n\n while(nn % prime(i) == 0){\n c += 1\n nn /= prime(i)\n }\n sub(nn, i + 1, c::rest)\n }\n }\n sub(number, 0)\n }\n def primes(upper: Int): Array[Int] = {\n val memo = Array.tabulate(upper + 1){_ ⇒ true}\n for (i ← 2 to math.sqrt(upper).toInt if memo(i)){\n for (j ← i * 2 to upper by i){\n memo(j) = false\n }\n }\n (2 to upper).filter(memo).toArray\n }\n implicit class Scope[T](val value: T) extends AnyVal {\n @inline\n def let[A](func: T ⇒ A): A = func(value)\n @inline\n def also(func: T ⇒ Unit): T = {\n func(value)\n value\n }\n }\n}\n", "problem_context": "C: 約数ゲーム / Divisor Game\n\n問題\n\ntsutaj くんは約数ゲームで遊ぼうとしています。\n\n約数ゲームでは、まず 2 以上の自然数 N が与えられ、その後は以下の手順でゲームが進んでいきます。\n\nN 以外の N の約数の中から、整数を 1 つ宣言する。ただしこのとき、既に宣言したことがある整数の約数になるものは宣言できない。\n\n宣言できる整数がある限りこれを繰り返し、宣言できるものがなければゲームは終了する。\n\nゲームを終了させるまでに行われた宣言の回数としてあり得る数の最小値と最大値を求めてください。\n\n入力形式\n\n入力は 1 行で与えられる。\n\nN\n\n制約\n\n2 \\leq N \\leq 10^{12}\n\n出力形式\n\n宣言回数の最小値と最大値を、スペース区切りで 1 行に出力せよ。\n\n入力例1\n\n18\n\n出力例1\n\n2 5\n\n宣言回数を 2 回にする一例は以下の通りです。\n\n9 を宣言する。\n\n6 を宣言する。 (6 は 9 の約数ではないため宣言が可能である)\n\nこれを行うと、18 の約数で 18 でない任意の整数は今まで宣言してきた整数の約数になるため、ゲームが終了します。\n\n既に宣言したことがある整数の約数になるものは宣言できないことに注意してください。例えば、 9 を宣言したあとに 3 を宣言することはできません。なぜなら、3 は 9 の約数になるからです。\n\n入力例2\n\n99\n\n出力例2\n\n2 5\n\n入力例3\n\n10000000019\n\n出力例3\n\n1 1\n\n入力は 32 bit 整数型に収まらない場合があります。", "sample_input": "18\n"}, "reference_outputs": ["2 5\n"], "source_document_id": "p02032", "source_text": "C: 約数ゲーム / Divisor Game\n\n問題\n\ntsutaj くんは約数ゲームで遊ぼうとしています。\n\n約数ゲームでは、まず 2 以上の自然数 N が与えられ、その後は以下の手順でゲームが進んでいきます。\n\nN 以外の N の約数の中から、整数を 1 つ宣言する。ただしこのとき、既に宣言したことがある整数の約数になるものは宣言できない。\n\n宣言できる整数がある限りこれを繰り返し、宣言できるものがなければゲームは終了する。\n\nゲームを終了させるまでに行われた宣言の回数としてあり得る数の最小値と最大値を求めてください。\n\n入力形式\n\n入力は 1 行で与えられる。\n\nN\n\n制約\n\n2 \\leq N \\leq 10^{12}\n\n出力形式\n\n宣言回数の最小値と最大値を、スペース区切りで 1 行に出力せよ。\n\n入力例1\n\n18\n\n出力例1\n\n2 5\n\n宣言回数を 2 回にする一例は以下の通りです。\n\n9 を宣言する。\n\n6 を宣言する。 (6 は 9 の約数ではないため宣言が可能である)\n\nこれを行うと、18 の約数で 18 でない任意の整数は今まで宣言してきた整数の約数になるため、ゲームが終了します。\n\n既に宣言したことがある整数の約数になるものは宣言できないことに注意してください。例えば、 9 を宣言したあとに 3 を宣言することはできません。なぜなら、3 は 9 の約数になるからです。\n\n入力例2\n\n99\n\n出力例2\n\n2 5\n\n入力例3\n\n10000000019\n\n出力例3\n\n1 1\n\n入力は 32 bit 整数型に収まらない場合があります。", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1492, "cpu_time_ms": 320, "memory_kb": 66928}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s678714923", "group_id": "codeNet:p02088", "input_text": "object Main extends App {\n import scala.io.StdIn._\n val n = readInt\n val balls = readLine.trim.split(' ').map(_.toInt)\n val odd = balls.count(_ % 2 == 1)\n val even = balls.count(_ % 2 == 0)\n if (odd == 0 || even == 0){\n println(0)\n }else {\n if (odd % 2 == 0) {\n println(n - 2)\n }else {\n println(n - 1)\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1568652389, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02088.html", "problem_id": "p02088", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02088/input.txt", "sample_output_relpath": "derived/input_output/data/p02088/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02088/Scala/s678714923.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s678714923", "user_id": "u514597327"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n import scala.io.StdIn._\n val n = readInt\n val balls = readLine.trim.split(' ').map(_.toInt)\n val odd = balls.count(_ % 2 == 1)\n val even = balls.count(_ % 2 == 0)\n if (odd == 0 || even == 0){\n println(0)\n }else {\n if (odd % 2 == 0) {\n println(n - 2)\n }else {\n println(n - 1)\n }\n }\n}\n", "problem_context": "A: Union Ball\n\nProblem Statement\n\nThere are N balls in a box. The i-th ball is labeled with a positive integer A_i.\n\nYou can interact with balls in the box by taking actions under the following rules:\n\nIf integers on balls in the box are all odd or all even, you cannot take actions anymore.\n\nOtherwise, you select arbitrary two balls in the box and remove them from the box. Then, you generate a new ball labeled with the sum of the integers on the two balls and put it into the box.\n\nFor given balls, what is the maximum number of actions you can take under the above rules?\n\nInput\n\nN\nA_1 A_2 ... A_N\n\nThe first line gives an integer N representing the initial number of balls in a box.\n\nThe second line contains N integers, the i-th of which is the integer on the i-th ball.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nInputs consist only of integers.\n\nOutput\n\nOutput the maximum number of actions you can take in one line.\n\nSample Input 1\n\n3\n4 5 6\n\nOutput for Sample Input 1\n\n2\n\nFirst, you select and remove balls labeled with 4 and 5, respectively, and add a ball labeled with 9.\nNext, you select and remove balls labeled with 6 and 9, respectively, and add a ball labeled with 15.\nNow, the balls in the box only have odd numbers. So you cannot take any actions anymore. The number of actions you took is two, and there is no way to achieve three actions or more. Thus the maximum is two and the series of the above actions is one of the optimal ways.\n\nSample Input 2\n\n4\n4 2 4 2\n\nOutput for Sample Input 2\n\n0\n\nYou cannot take any actions in this case.", "sample_input": "3\n4 5 6\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02088", "source_text": "A: Union Ball\n\nProblem Statement\n\nThere are N balls in a box. The i-th ball is labeled with a positive integer A_i.\n\nYou can interact with balls in the box by taking actions under the following rules:\n\nIf integers on balls in the box are all odd or all even, you cannot take actions anymore.\n\nOtherwise, you select arbitrary two balls in the box and remove them from the box. Then, you generate a new ball labeled with the sum of the integers on the two balls and put it into the box.\n\nFor given balls, what is the maximum number of actions you can take under the above rules?\n\nInput\n\nN\nA_1 A_2 ... A_N\n\nThe first line gives an integer N representing the initial number of balls in a box.\n\nThe second line contains N integers, the i-th of which is the integer on the i-th ball.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nInputs consist only of integers.\n\nOutput\n\nOutput the maximum number of actions you can take in one line.\n\nSample Input 1\n\n3\n4 5 6\n\nOutput for Sample Input 1\n\n2\n\nFirst, you select and remove balls labeled with 4 and 5, respectively, and add a ball labeled with 9.\nNext, you select and remove balls labeled with 6 and 9, respectively, and add a ball labeled with 15.\nNow, the balls in the box only have odd numbers. So you cannot take any actions anymore. The number of actions you took is two, and there is no way to achieve three actions or more. Thus the maximum is two and the series of the above actions is one of the optimal ways.\n\nSample Input 2\n\n4\n4 2 4 2\n\nOutput for Sample Input 2\n\n0\n\nYou cannot take any actions in this case.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 340, "cpu_time_ms": 410, "memory_kb": 85032}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s111669283", "group_id": "codeNet:p02099", "input_text": "import java.util.Scanner\n\nimport scala.annotation.tailrec\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\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val A = Array.fill(sc.nextInt)(sc.nextDouble)\n for (i <- 0 until A.size) {\n println(A.map(x => if (A(i) < x) (0) else (if (A(i) == x) (1) else (3))).sum - 1)\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": 1508593011, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02099.html", "problem_id": "p02099", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02099/input.txt", "sample_output_relpath": "derived/input_output/data/p02099/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02099/Scala/s111669283.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s111669283", "user_id": "u018134297"}, "prompt_components": {"gold_output": "0\n4\n4\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.annotation.tailrec\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\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val A = Array.fill(sc.nextInt)(sc.nextDouble)\n for (i <- 0 until A.size) {\n println(A.map(x => if (A(i) < x) (0) else (if (A(i) == x) (1) else (3))).sum - 1)\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 B: GPA JANKEN\n\nProblem\n\nGPAとは「Galaxy Point of Aizu」の略で、0から4までの実数値を取る。\n\nGPAじゃんけんは二人で行うゲームである。各々が「じゃんけん、ぽん(ほい)」の合図で互いにグー、チョキ、パーのどれか好きな手を出した後、GPAが高い人が勝者となり、低い人が敗者となる。同じ場合は引き分けとなる。\n\nN 人のGPAのデータが与えられるので、総当たり戦をした時のそれぞれの勝ち点を出力せよ。\n\nただし、勝ち点は勝ちの時3、引き分けの時1、負けの時0とする。\n\n総当たり戦とはすべての参加者が自分以外の参加者と丁度一回ずつ対戦する方式である。\n\nInput\n\n入力は以下の形式で与えられる。\n\nN\na1\na2\n...\naN\n\n一行目にGPAじゃんけんをする人数 N が与えられる。\n\n続く N 行に i 番目の人のGPAのデータ ai が一行に与えられる。\n\nConstraints\n\n入力は以下の条件を満たす。\n\n2 ≤ N ≤ 105\n\nN は整数\n\n0.000 ≤ ai ≤ 4.000 ( 1 ≤ i ≤ N )\n\nai は実数 ( 1 ≤ i ≤ N )\n\n各GPAは小数点以下3桁まで与えられる\n\nOutput\n\ni 行目に i 番目の人の勝ち点を一行に出力せよ。\n( 1 ≤ i ≤ N )\n\nSample Input 1\n\n3\n1.000\n3.000\n3.000\n\nSample Output 1\n\n0\n4\n4\n\nSample Input 2\n\n3\n1.000\n2.000\n3.000\n\nSample Output 2\n\n0\n3\n6", "sample_input": "3\n1.000\n3.000\n3.000\n"}, "reference_outputs": ["0\n4\n4\n"], "source_document_id": "p02099", "source_text": "Problem B: GPA JANKEN\n\nProblem\n\nGPAとは「Galaxy Point of Aizu」の略で、0から4までの実数値を取る。\n\nGPAじゃんけんは二人で行うゲームである。各々が「じゃんけん、ぽん(ほい)」の合図で互いにグー、チョキ、パーのどれか好きな手を出した後、GPAが高い人が勝者となり、低い人が敗者となる。同じ場合は引き分けとなる。\n\nN 人のGPAのデータが与えられるので、総当たり戦をした時のそれぞれの勝ち点を出力せよ。\n\nただし、勝ち点は勝ちの時3、引き分けの時1、負けの時0とする。\n\n総当たり戦とはすべての参加者が自分以外の参加者と丁度一回ずつ対戦する方式である。\n\nInput\n\n入力は以下の形式で与えられる。\n\nN\na1\na2\n...\naN\n\n一行目にGPAじゃんけんをする人数 N が与えられる。\n\n続く N 行に i 番目の人のGPAのデータ ai が一行に与えられる。\n\nConstraints\n\n入力は以下の条件を満たす。\n\n2 ≤ N ≤ 105\n\nN は整数\n\n0.000 ≤ ai ≤ 4.000 ( 1 ≤ i ≤ N )\n\nai は実数 ( 1 ≤ i ≤ N )\n\n各GPAは小数点以下3桁まで与えられる\n\nOutput\n\ni 行目に i 番目の人の勝ち点を一行に出力せよ。\n( 1 ≤ i ≤ N )\n\nSample Input 1\n\n3\n1.000\n3.000\n3.000\n\nSample Output 1\n\n0\n4\n4\n\nSample Input 2\n\n3\n1.000\n2.000\n3.000\n\nSample Output 2\n\n0\n3\n6", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1209, "cpu_time_ms": 250, "memory_kb": 46036}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s640869999", "group_id": "codeNet:p02117", "input_text": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val in = new Scanner(System.in)\n val N = in.nextInt()\n val X = in.nextInt()\n val Y = in.nextInt()\n val foods = (for (_ <- 0 until N) yield {\n val K = in.nextInt()\n (for (_ <- 0 until K) yield {\n val a = in.nextInt()\n val b = in.nextInt()\n val c = in.nextInt()\n (a, b, c)\n }).toArray\n }).toArray\n\n val dist = (for (_ <- 0 until N) yield (for (_ <- 0 until N) yield in.nextInt()).toArray).toArray\n for {\n k <- 0 until N\n i <- 0 until N\n j <- 0 until N\n } dist(i)(j) = math.min(dist(i)(j), dist(i)(k) + dist(k)(j))\n\n val cost = Array.fill(1 << (N + 1), N + 1)(Int.MaxValue / 2)\n cost(1)(0) = 0\n for {\n mask <- 0 until (1 << N)\n current <- 0 until N\n next <- 1 until (N + 1)\n if (mask & (1 << current)) != 0\n if (mask & (1 << next)) == 0\n } {\n val nextMask = mask | (1 << next)\n cost(nextMask)(next) = math.min(cost(nextMask)(next), cost(mask)(current) + dist(current)(next % N))\n }\n\n var max = 0\n for {\n mask <- 0 until (1 << N)\n } {\n val travelCost = cost(mask | (1 << N))(N)\n val budget = math.min(X - travelCost, Y)\n if (budget > 0) {\n val dp = new Array[Int](budget + 1)\n if (dp.length == 0) {\n Thread.sleep(10 * 1000)\n println(11)\n return \n }\n\n for {\n i <- 0 until N\n if ((1 << i) & mask) != 0\n (price, value, remain) <- foods(i)\n current <- budget to 0 by -1\n num <- 1 to remain\n if current + price * num <= budget\n } {\n dp(current + price * num) = math.max(dp(current + price * num), dp(current) + value * num)\n }\n max = math.max(max, dp.max)\n } else {\n 0\n }\n }\n\n println(max)\n }\n}", "language": "Scala", "metadata": {"date": 1505867996, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02117.html", "problem_id": "p02117", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02117/input.txt", "sample_output_relpath": "derived/input_output/data/p02117/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02117/Scala/s640869999.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s640869999", "user_id": "u568152427"}, "prompt_components": {"gold_output": "100\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val in = new Scanner(System.in)\n val N = in.nextInt()\n val X = in.nextInt()\n val Y = in.nextInt()\n val foods = (for (_ <- 0 until N) yield {\n val K = in.nextInt()\n (for (_ <- 0 until K) yield {\n val a = in.nextInt()\n val b = in.nextInt()\n val c = in.nextInt()\n (a, b, c)\n }).toArray\n }).toArray\n\n val dist = (for (_ <- 0 until N) yield (for (_ <- 0 until N) yield in.nextInt()).toArray).toArray\n for {\n k <- 0 until N\n i <- 0 until N\n j <- 0 until N\n } dist(i)(j) = math.min(dist(i)(j), dist(i)(k) + dist(k)(j))\n\n val cost = Array.fill(1 << (N + 1), N + 1)(Int.MaxValue / 2)\n cost(1)(0) = 0\n for {\n mask <- 0 until (1 << N)\n current <- 0 until N\n next <- 1 until (N + 1)\n if (mask & (1 << current)) != 0\n if (mask & (1 << next)) == 0\n } {\n val nextMask = mask | (1 << next)\n cost(nextMask)(next) = math.min(cost(nextMask)(next), cost(mask)(current) + dist(current)(next % N))\n }\n\n var max = 0\n for {\n mask <- 0 until (1 << N)\n } {\n val travelCost = cost(mask | (1 << N))(N)\n val budget = math.min(X - travelCost, Y)\n if (budget > 0) {\n val dp = new Array[Int](budget + 1)\n if (dp.length == 0) {\n Thread.sleep(10 * 1000)\n println(11)\n return \n }\n\n for {\n i <- 0 until N\n if ((1 << i) & mask) != 0\n (price, value, remain) <- foods(i)\n current <- budget to 0 by -1\n num <- 1 to remain\n if current + price * num <= budget\n } {\n dp(current + price * num) = math.max(dp(current + price * num), dp(current) + value * num)\n }\n max = math.max(max, dp.max)\n } else {\n 0\n }\n }\n\n println(max)\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nProblem G: Picnic\n\nProblem\n\n明日はいよいよマイヅ小学校の遠足の日である。マイヅ小学校に通うがっちょ君は、楽しみのあまり明日のお菓子を買い忘れていたことに気づいた。 がっちょ君は遠足を最大限楽しむため、お菓子にもこだわりたい。\n\nがっちょ君はお母さんから$X$円のお小遣いをもらってお菓子を買いに行く。ただし、小学校のルールで遠足に持っていくお菓子の合計金額は$Y$円までと決まっており、$Y$円を上回るとお菓子は全て先生に取り上げられてしまう。\n\nがっちょ君の住む学区には$N$個の町があり、各町には1軒の駄菓子屋がある。各町には1から$N$の番号が割り振られており、がっちょ君は町1に住んでいる。 各駄菓子屋ではいくつかのお菓子が売っており、1つあたりの値段、1つ買うごとにがっちょ君が得られる満足度が決まっている。ただし、各お菓子の在庫数には限りがある。 また、がっちょ君は2つの町の間を移動するとき公共交通機関を利用するため、町$i$から町$j$へ直接移動するには$d_{i,j}$円だけお金がかかる。\n\n最初、がっちょ君は町1にいる。がっちょ君は移動にかかる費用の合計と買ったお菓子の値段の合計の和が$X$円以内で、かつ、買ったお菓子の値段の合計が$Y$円以内になるようにお菓子を買いに行く。最後には町1に到着している必要がある。がっちょ君は買ったお菓子の満足度の合計ができるだけ大きくなるようにしたい。がっちょ君が最適な行動をしたときの満足度の合計を求めよ。\n\nInput\n\n入力は以下の形式ですべて整数で与えられる。\n\n$N$ $X$ $Y$\n\n町1の駄菓子屋の情報\n\n町2の駄菓子屋の情報\n\n...\n\n町$N$の駄菓子屋の情報\n\n$d_{1,1}$ $d_{1,2}$ ... $d_{1,N}$\n\n$d_{2,1}$ $d_{2,2}$ ... $d_{2,N}$\n\n...\n\n$d_{N,1}$ $d_{N,2}$ ... $d_{N,N}$\n\n1行目に町の数$N$と所持金$X$、お菓子を買うために使うことができる上限金額$Y$が空白区切りで与えられる。\n\n2行目からは$N$個の各駄菓子屋の情報が与えられる。\n\n続く$N$行$N$列に町$i$と町$j$を直接行き来するために必要な金額$d_{i,j}$が空白区切りで与えられる。\n\n各町の駄菓子屋の情報は以下の形式で与えられる。\n\n$K$\n\n$a_1$ $b_1$ $c_1$\n\n$a_2$ $b_2$ $c_2$\n\n...\n\n$a_K$ $b_K$ $c_K$\n\n1行目にその駄菓子屋で売っているお菓子の種類の数$K$が与えられる。続く$K$行にお菓子の1つの値段$a_i$、1つあたりの満足度$b_i$、在庫数$c_i$が空白区切りで与えられる。\n\nConstraints\n\n入力は以下の条件を満たす。\n\n$1 \\leq N \\leq 14$\n\n$1 \\leq X \\leq 10000$\n\n$1 \\leq Y \\leq min(1000,X)$\n\n$1 \\leq K \\leq 300$\n\n$1 \\leq a_i \\leq 1000$\n\n$1 \\leq b_i \\leq 1000$\n\n$1 \\leq c_i \\leq 1000$\n\n$0 \\leq d_{i,j} \\leq 10000$\n\n$d_{i,i} = 0$\n\nOutput\n\n満足度の合計の最大値を1行に出力する。\n\nSample Input 1\n\n1 10 10\n3\n1 10 1\n2 20 2\n3 30 3\n0\n\nSample Output 1\n\n100\n\nSample Input 2\n\n2 10 10\n3\n1 10 1\n2 20 2\n3 30 3\n1\n5 200 1\n0 2\n3 0\n\nSample Output 2\n\n200\n\nSample Input 3\n\n3 10 10\n1\n1 1 1\n1\n3 3 3\n1\n5 5 5\n0 1 0\n1 0 0\n0 1 0\n\nSample Output 3\n\n10\n\nSample Input 4\n\n4 59 40\n1\n7 6 3\n1\n10 3 9\n2\n9 8 5\n7 6 10\n4\n8 2 9\n1 7 1\n7 7 9\n1 2 3\n0 28 7 26\n14 0 10 24\n9 6 0 21\n9 24 14 0\n\nSample Output 4\n\n34", "sample_input": "1 10 10\n3\n1 10 1\n2 20 2\n3 30 3\n0\n"}, "reference_outputs": ["100\n"], "source_document_id": "p02117", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nProblem G: Picnic\n\nProblem\n\n明日はいよいよマイヅ小学校の遠足の日である。マイヅ小学校に通うがっちょ君は、楽しみのあまり明日のお菓子を買い忘れていたことに気づいた。 がっちょ君は遠足を最大限楽しむため、お菓子にもこだわりたい。\n\nがっちょ君はお母さんから$X$円のお小遣いをもらってお菓子を買いに行く。ただし、小学校のルールで遠足に持っていくお菓子の合計金額は$Y$円までと決まっており、$Y$円を上回るとお菓子は全て先生に取り上げられてしまう。\n\nがっちょ君の住む学区には$N$個の町があり、各町には1軒の駄菓子屋がある。各町には1から$N$の番号が割り振られており、がっちょ君は町1に住んでいる。 各駄菓子屋ではいくつかのお菓子が売っており、1つあたりの値段、1つ買うごとにがっちょ君が得られる満足度が決まっている。ただし、各お菓子の在庫数には限りがある。 また、がっちょ君は2つの町の間を移動するとき公共交通機関を利用するため、町$i$から町$j$へ直接移動するには$d_{i,j}$円だけお金がかかる。\n\n最初、がっちょ君は町1にいる。がっちょ君は移動にかかる費用の合計と買ったお菓子の値段の合計の和が$X$円以内で、かつ、買ったお菓子の値段の合計が$Y$円以内になるようにお菓子を買いに行く。最後には町1に到着している必要がある。がっちょ君は買ったお菓子の満足度の合計ができるだけ大きくなるようにしたい。がっちょ君が最適な行動をしたときの満足度の合計を求めよ。\n\nInput\n\n入力は以下の形式ですべて整数で与えられる。\n\n$N$ $X$ $Y$\n\n町1の駄菓子屋の情報\n\n町2の駄菓子屋の情報\n\n...\n\n町$N$の駄菓子屋の情報\n\n$d_{1,1}$ $d_{1,2}$ ... $d_{1,N}$\n\n$d_{2,1}$ $d_{2,2}$ ... $d_{2,N}$\n\n...\n\n$d_{N,1}$ $d_{N,2}$ ... $d_{N,N}$\n\n1行目に町の数$N$と所持金$X$、お菓子を買うために使うことができる上限金額$Y$が空白区切りで与えられる。\n\n2行目からは$N$個の各駄菓子屋の情報が与えられる。\n\n続く$N$行$N$列に町$i$と町$j$を直接行き来するために必要な金額$d_{i,j}$が空白区切りで与えられる。\n\n各町の駄菓子屋の情報は以下の形式で与えられる。\n\n$K$\n\n$a_1$ $b_1$ $c_1$\n\n$a_2$ $b_2$ $c_2$\n\n...\n\n$a_K$ $b_K$ $c_K$\n\n1行目にその駄菓子屋で売っているお菓子の種類の数$K$が与えられる。続く$K$行にお菓子の1つの値段$a_i$、1つあたりの満足度$b_i$、在庫数$c_i$が空白区切りで与えられる。\n\nConstraints\n\n入力は以下の条件を満たす。\n\n$1 \\leq N \\leq 14$\n\n$1 \\leq X \\leq 10000$\n\n$1 \\leq Y \\leq min(1000,X)$\n\n$1 \\leq K \\leq 300$\n\n$1 \\leq a_i \\leq 1000$\n\n$1 \\leq b_i \\leq 1000$\n\n$1 \\leq c_i \\leq 1000$\n\n$0 \\leq d_{i,j} \\leq 10000$\n\n$d_{i,i} = 0$\n\nOutput\n\n満足度の合計の最大値を1行に出力する。\n\nSample Input 1\n\n1 10 10\n3\n1 10 1\n2 20 2\n3 30 3\n0\n\nSample Output 1\n\n100\n\nSample Input 2\n\n2 10 10\n3\n1 10 1\n2 20 2\n3 30 3\n1\n5 200 1\n0 2\n3 0\n\nSample Output 2\n\n200\n\nSample Input 3\n\n3 10 10\n1\n1 1 1\n1\n3 3 3\n1\n5 5 5\n0 1 0\n1 0 0\n0 1 0\n\nSample Output 3\n\n10\n\nSample Input 4\n\n4 59 40\n1\n7 6 3\n1\n10 3 9\n2\n9 8 5\n7 6 10\n4\n8 2 9\n1 7 1\n7 7 9\n1 2 3\n0 28 7 26\n14 0 10 24\n9 6 0 21\n9 24 14 0\n\nSample Output 4\n\n34", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1895, "cpu_time_ms": 2350, "memory_kb": 571248}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s436872876", "group_id": "codeNet:p02117", "input_text": "import java.util\n\nimport scala.io.StdIn\nimport scala.util.Try\n\nobject Main extends App {\n val INF: Long = 1e15.toLong\n val (n, x, y) = {\n val in = StdIn.readLine().split(\" \").map(_.toInt)\n (in(0), in(1), in(2))\n }\n val sweets = for (_ <- 0 until n) yield {\n val k = StdIn.readLine().toInt\n for (_ <- 0 until k) yield {\n val in = StdIn.readLine().split(\" \").map(_.toInt)\n Sweet(in(0), in(1), in(2))\n }\n }\n\n val dist = for (_ <- 0 until n) yield StdIn.readLine().split(\" \").map(_.toLong)\n for (k <- 0 until n) for (i <- 0 until n) for (j <- 0 until n) dist(i)(j) = math.min(dist(i)(j), dist(i)(k) + dist(k)(j))\n\n val cost = Array.fill[Long](1 << n, n)(INF)\n cost(0)(0) = 0\n for (mask <- 0 until 1 << n)\n for (cur <- 0 until n)\n for (next <- 0 until n)\n if ((mask & (1 << next)) == 0) {\n val add = dist(cur)(next)\n cost(mask | (1 << next))(next) = math.min(cost(mask | (1 << next))(next), cost(mask)(cur) + add)\n }\n\n\n def knapsack(dp: Array[Long], available: Seq[Sweet]): Unit = Try{\n for {\n sweet <- available\n a <- 0 until sweet.price\n } {\n val deque = new util.ArrayDeque[(Int, Long)]()\n for (j <- 0 to (y - a) / sweet.price) {\n val v = dp(j * sweet.price + a) - j * sweet.value\n while (!deque.isEmpty && deque.peekLast()._2 <= v) deque.pollLast()\n deque.addLast((j, v))\n\n dp(j * sweet.price + a) = deque.peekFirst()._2 + j * sweet.value\n if (deque.peekFirst()._1 == j - sweet.remain) deque.pollFirst()\n }\n }\n for (i <- 1 until dp.length) dp(i) = math.max(dp(i), dp(i - 1))\n }.recover{\n case e:Throwable=>println(e)\n }\n\n\n val prefix = n / 2\n val suffix = n - prefix\n\n val prefixDp = Array.fill[Long](1 << prefix, y + 1)(0)\n for (prefixMask <- 0 until 1 << prefix) {\n val mask = prefixMask << suffix\n val dp = prefixDp(prefixMask)\n val available = for {\n i <- 0 until n\n if (mask & (1 << i)) != 0\n sweet <- sweets(i)\n } yield sweet\n knapsack(dp, available)\n }\n\n val suffixDp = Array.fill[Long](1 << suffix, y + 1)(0)\n for (mask <- 0 until 1 << suffix) {\n val dp = suffixDp(mask)\n val available = for {\n i <- 0 until n\n if (mask & (1 << i)) != 0\n sweet <- sweets(i)\n } yield sweet\n knapsack(dp, available)\n }\n var ans = 0L\n for (mask <- 0 until 1 << n) {\n val suffixMask = mask & ((1 << suffix) - 1)\n val prefixMask = mask >> suffix\n val travelingCost = (for (last <- 0 until n) yield {\n cost(mask)(last) + dist(last)(0)\n }).min\n val money = math.min(x - travelingCost, y).toInt\n for (prefixMoney <- 0 to money) {\n val suffixMoney = money - prefixMoney\n val value = prefixDp(prefixMask)(prefixMoney) + suffixDp(suffixMask)(suffixMoney)\n ans = math.max(ans, value)\n }\n }\n println(ans)\n\n Try {\n\n }.recover {\n case e: Throwable => println(e)\n }\n\n}\n\ncase class Sweet(price: Int, value: Int, remain: Int)", "language": "Scala", "metadata": {"date": 1509528684, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02117.html", "problem_id": "p02117", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02117/input.txt", "sample_output_relpath": "derived/input_output/data/p02117/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02117/Scala/s436872876.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s436872876", "user_id": "u568152427"}, "prompt_components": {"gold_output": "100\n", "input_to_evaluate": "import java.util\n\nimport scala.io.StdIn\nimport scala.util.Try\n\nobject Main extends App {\n val INF: Long = 1e15.toLong\n val (n, x, y) = {\n val in = StdIn.readLine().split(\" \").map(_.toInt)\n (in(0), in(1), in(2))\n }\n val sweets = for (_ <- 0 until n) yield {\n val k = StdIn.readLine().toInt\n for (_ <- 0 until k) yield {\n val in = StdIn.readLine().split(\" \").map(_.toInt)\n Sweet(in(0), in(1), in(2))\n }\n }\n\n val dist = for (_ <- 0 until n) yield StdIn.readLine().split(\" \").map(_.toLong)\n for (k <- 0 until n) for (i <- 0 until n) for (j <- 0 until n) dist(i)(j) = math.min(dist(i)(j), dist(i)(k) + dist(k)(j))\n\n val cost = Array.fill[Long](1 << n, n)(INF)\n cost(0)(0) = 0\n for (mask <- 0 until 1 << n)\n for (cur <- 0 until n)\n for (next <- 0 until n)\n if ((mask & (1 << next)) == 0) {\n val add = dist(cur)(next)\n cost(mask | (1 << next))(next) = math.min(cost(mask | (1 << next))(next), cost(mask)(cur) + add)\n }\n\n\n def knapsack(dp: Array[Long], available: Seq[Sweet]): Unit = Try{\n for {\n sweet <- available\n a <- 0 until sweet.price\n } {\n val deque = new util.ArrayDeque[(Int, Long)]()\n for (j <- 0 to (y - a) / sweet.price) {\n val v = dp(j * sweet.price + a) - j * sweet.value\n while (!deque.isEmpty && deque.peekLast()._2 <= v) deque.pollLast()\n deque.addLast((j, v))\n\n dp(j * sweet.price + a) = deque.peekFirst()._2 + j * sweet.value\n if (deque.peekFirst()._1 == j - sweet.remain) deque.pollFirst()\n }\n }\n for (i <- 1 until dp.length) dp(i) = math.max(dp(i), dp(i - 1))\n }.recover{\n case e:Throwable=>println(e)\n }\n\n\n val prefix = n / 2\n val suffix = n - prefix\n\n val prefixDp = Array.fill[Long](1 << prefix, y + 1)(0)\n for (prefixMask <- 0 until 1 << prefix) {\n val mask = prefixMask << suffix\n val dp = prefixDp(prefixMask)\n val available = for {\n i <- 0 until n\n if (mask & (1 << i)) != 0\n sweet <- sweets(i)\n } yield sweet\n knapsack(dp, available)\n }\n\n val suffixDp = Array.fill[Long](1 << suffix, y + 1)(0)\n for (mask <- 0 until 1 << suffix) {\n val dp = suffixDp(mask)\n val available = for {\n i <- 0 until n\n if (mask & (1 << i)) != 0\n sweet <- sweets(i)\n } yield sweet\n knapsack(dp, available)\n }\n var ans = 0L\n for (mask <- 0 until 1 << n) {\n val suffixMask = mask & ((1 << suffix) - 1)\n val prefixMask = mask >> suffix\n val travelingCost = (for (last <- 0 until n) yield {\n cost(mask)(last) + dist(last)(0)\n }).min\n val money = math.min(x - travelingCost, y).toInt\n for (prefixMoney <- 0 to money) {\n val suffixMoney = money - prefixMoney\n val value = prefixDp(prefixMask)(prefixMoney) + suffixDp(suffixMask)(suffixMoney)\n ans = math.max(ans, value)\n }\n }\n println(ans)\n\n Try {\n\n }.recover {\n case e: Throwable => println(e)\n }\n\n}\n\ncase class Sweet(price: Int, value: Int, remain: Int)", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nProblem G: Picnic\n\nProblem\n\n明日はいよいよマイヅ小学校の遠足の日である。マイヅ小学校に通うがっちょ君は、楽しみのあまり明日のお菓子を買い忘れていたことに気づいた。 がっちょ君は遠足を最大限楽しむため、お菓子にもこだわりたい。\n\nがっちょ君はお母さんから$X$円のお小遣いをもらってお菓子を買いに行く。ただし、小学校のルールで遠足に持っていくお菓子の合計金額は$Y$円までと決まっており、$Y$円を上回るとお菓子は全て先生に取り上げられてしまう。\n\nがっちょ君の住む学区には$N$個の町があり、各町には1軒の駄菓子屋がある。各町には1から$N$の番号が割り振られており、がっちょ君は町1に住んでいる。 各駄菓子屋ではいくつかのお菓子が売っており、1つあたりの値段、1つ買うごとにがっちょ君が得られる満足度が決まっている。ただし、各お菓子の在庫数には限りがある。 また、がっちょ君は2つの町の間を移動するとき公共交通機関を利用するため、町$i$から町$j$へ直接移動するには$d_{i,j}$円だけお金がかかる。\n\n最初、がっちょ君は町1にいる。がっちょ君は移動にかかる費用の合計と買ったお菓子の値段の合計の和が$X$円以内で、かつ、買ったお菓子の値段の合計が$Y$円以内になるようにお菓子を買いに行く。最後には町1に到着している必要がある。がっちょ君は買ったお菓子の満足度の合計ができるだけ大きくなるようにしたい。がっちょ君が最適な行動をしたときの満足度の合計を求めよ。\n\nInput\n\n入力は以下の形式ですべて整数で与えられる。\n\n$N$ $X$ $Y$\n\n町1の駄菓子屋の情報\n\n町2の駄菓子屋の情報\n\n...\n\n町$N$の駄菓子屋の情報\n\n$d_{1,1}$ $d_{1,2}$ ... $d_{1,N}$\n\n$d_{2,1}$ $d_{2,2}$ ... $d_{2,N}$\n\n...\n\n$d_{N,1}$ $d_{N,2}$ ... $d_{N,N}$\n\n1行目に町の数$N$と所持金$X$、お菓子を買うために使うことができる上限金額$Y$が空白区切りで与えられる。\n\n2行目からは$N$個の各駄菓子屋の情報が与えられる。\n\n続く$N$行$N$列に町$i$と町$j$を直接行き来するために必要な金額$d_{i,j}$が空白区切りで与えられる。\n\n各町の駄菓子屋の情報は以下の形式で与えられる。\n\n$K$\n\n$a_1$ $b_1$ $c_1$\n\n$a_2$ $b_2$ $c_2$\n\n...\n\n$a_K$ $b_K$ $c_K$\n\n1行目にその駄菓子屋で売っているお菓子の種類の数$K$が与えられる。続く$K$行にお菓子の1つの値段$a_i$、1つあたりの満足度$b_i$、在庫数$c_i$が空白区切りで与えられる。\n\nConstraints\n\n入力は以下の条件を満たす。\n\n$1 \\leq N \\leq 14$\n\n$1 \\leq X \\leq 10000$\n\n$1 \\leq Y \\leq min(1000,X)$\n\n$1 \\leq K \\leq 300$\n\n$1 \\leq a_i \\leq 1000$\n\n$1 \\leq b_i \\leq 1000$\n\n$1 \\leq c_i \\leq 1000$\n\n$0 \\leq d_{i,j} \\leq 10000$\n\n$d_{i,i} = 0$\n\nOutput\n\n満足度の合計の最大値を1行に出力する。\n\nSample Input 1\n\n1 10 10\n3\n1 10 1\n2 20 2\n3 30 3\n0\n\nSample Output 1\n\n100\n\nSample Input 2\n\n2 10 10\n3\n1 10 1\n2 20 2\n3 30 3\n1\n5 200 1\n0 2\n3 0\n\nSample Output 2\n\n200\n\nSample Input 3\n\n3 10 10\n1\n1 1 1\n1\n3 3 3\n1\n5 5 5\n0 1 0\n1 0 0\n0 1 0\n\nSample Output 3\n\n10\n\nSample Input 4\n\n4 59 40\n1\n7 6 3\n1\n10 3 9\n2\n9 8 5\n7 6 10\n4\n8 2 9\n1 7 1\n7 7 9\n1 2 3\n0 28 7 26\n14 0 10 24\n9 6 0 21\n9 24 14 0\n\nSample Output 4\n\n34", "sample_input": "1 10 10\n3\n1 10 1\n2 20 2\n3 30 3\n0\n"}, "reference_outputs": ["100\n"], "source_document_id": "p02117", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nProblem G: Picnic\n\nProblem\n\n明日はいよいよマイヅ小学校の遠足の日である。マイヅ小学校に通うがっちょ君は、楽しみのあまり明日のお菓子を買い忘れていたことに気づいた。 がっちょ君は遠足を最大限楽しむため、お菓子にもこだわりたい。\n\nがっちょ君はお母さんから$X$円のお小遣いをもらってお菓子を買いに行く。ただし、小学校のルールで遠足に持っていくお菓子の合計金額は$Y$円までと決まっており、$Y$円を上回るとお菓子は全て先生に取り上げられてしまう。\n\nがっちょ君の住む学区には$N$個の町があり、各町には1軒の駄菓子屋がある。各町には1から$N$の番号が割り振られており、がっちょ君は町1に住んでいる。 各駄菓子屋ではいくつかのお菓子が売っており、1つあたりの値段、1つ買うごとにがっちょ君が得られる満足度が決まっている。ただし、各お菓子の在庫数には限りがある。 また、がっちょ君は2つの町の間を移動するとき公共交通機関を利用するため、町$i$から町$j$へ直接移動するには$d_{i,j}$円だけお金がかかる。\n\n最初、がっちょ君は町1にいる。がっちょ君は移動にかかる費用の合計と買ったお菓子の値段の合計の和が$X$円以内で、かつ、買ったお菓子の値段の合計が$Y$円以内になるようにお菓子を買いに行く。最後には町1に到着している必要がある。がっちょ君は買ったお菓子の満足度の合計ができるだけ大きくなるようにしたい。がっちょ君が最適な行動をしたときの満足度の合計を求めよ。\n\nInput\n\n入力は以下の形式ですべて整数で与えられる。\n\n$N$ $X$ $Y$\n\n町1の駄菓子屋の情報\n\n町2の駄菓子屋の情報\n\n...\n\n町$N$の駄菓子屋の情報\n\n$d_{1,1}$ $d_{1,2}$ ... $d_{1,N}$\n\n$d_{2,1}$ $d_{2,2}$ ... $d_{2,N}$\n\n...\n\n$d_{N,1}$ $d_{N,2}$ ... $d_{N,N}$\n\n1行目に町の数$N$と所持金$X$、お菓子を買うために使うことができる上限金額$Y$が空白区切りで与えられる。\n\n2行目からは$N$個の各駄菓子屋の情報が与えられる。\n\n続く$N$行$N$列に町$i$と町$j$を直接行き来するために必要な金額$d_{i,j}$が空白区切りで与えられる。\n\n各町の駄菓子屋の情報は以下の形式で与えられる。\n\n$K$\n\n$a_1$ $b_1$ $c_1$\n\n$a_2$ $b_2$ $c_2$\n\n...\n\n$a_K$ $b_K$ $c_K$\n\n1行目にその駄菓子屋で売っているお菓子の種類の数$K$が与えられる。続く$K$行にお菓子の1つの値段$a_i$、1つあたりの満足度$b_i$、在庫数$c_i$が空白区切りで与えられる。\n\nConstraints\n\n入力は以下の条件を満たす。\n\n$1 \\leq N \\leq 14$\n\n$1 \\leq X \\leq 10000$\n\n$1 \\leq Y \\leq min(1000,X)$\n\n$1 \\leq K \\leq 300$\n\n$1 \\leq a_i \\leq 1000$\n\n$1 \\leq b_i \\leq 1000$\n\n$1 \\leq c_i \\leq 1000$\n\n$0 \\leq d_{i,j} \\leq 10000$\n\n$d_{i,i} = 0$\n\nOutput\n\n満足度の合計の最大値を1行に出力する。\n\nSample Input 1\n\n1 10 10\n3\n1 10 1\n2 20 2\n3 30 3\n0\n\nSample Output 1\n\n100\n\nSample Input 2\n\n2 10 10\n3\n1 10 1\n2 20 2\n3 30 3\n1\n5 200 1\n0 2\n3 0\n\nSample Output 2\n\n200\n\nSample Input 3\n\n3 10 10\n1\n1 1 1\n1\n3 3 3\n1\n5 5 5\n0 1 0\n1 0 0\n0 1 0\n\nSample Output 3\n\n10\n\nSample Input 4\n\n4 59 40\n1\n7 6 3\n1\n10 3 9\n2\n9 8 5\n7 6 10\n4\n8 2 9\n1 7 1\n7 7 9\n1 2 3\n0 28 7 26\n14 0 10 24\n9 6 0 21\n9 24 14 0\n\nSample Output 4\n\n34", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2966, "cpu_time_ms": 270, "memory_kb": 44964}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s166353656", "group_id": "codeNet:p02233", "input_text": "import scala.io.StdIn.readInt\n\nobject Main {\n def fib(a:Int, b:Int, n:Int):Int = {\n if (n == 0)\n a\n else\n fib(a+b, a, n-1)\n }\n\n def main(args: Array[String]) = {\n val n = readInt()\n println(fib(1, 0, n))\n }\n}", "language": "Scala", "metadata": {"date": 1466425456, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02233.html", "problem_id": "p02233", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02233/input.txt", "sample_output_relpath": "derived/input_output/data/p02233/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02233/Scala/s166353656.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s166353656", "user_id": "u935184340"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.io.StdIn.readInt\n\nobject Main {\n def fib(a:Int, b:Int, n:Int):Int = {\n if (n == 0)\n a\n else\n fib(a+b, a, n-1)\n }\n\n def main(args: Array[String]) = {\n val n = readInt()\n println(fib(1, 0, n))\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nFibonacci Number\n\nWrite a program which prints $n$-th fibonacci number for a given integer $n$. The $n$-th fibonacci number is defined by the following recursive formula:\n\n\\begin{equation*}\nfib(n)= \\left \\{\n\\begin{array}{ll}\n1  & (n = 0) \\\\\n1  & (n = 1) \\\\\nfib(n - 1) + fib(n - 2) & \\\\\n\\end{array}\n\\right.\n\\end{equation*}\n\nInput\n\nAn integer $n$ is given.\n\noutput\n\nPrint the $n$-th fibonacci number in a line.\n\nConstraints\n\n$0 \\leq n \\leq 44$\n\nSample Input 1\n\n3\n\nSample Output 1\n\n3", "sample_input": "3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02233", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nFibonacci Number\n\nWrite a program which prints $n$-th fibonacci number for a given integer $n$. The $n$-th fibonacci number is defined by the following recursive formula:\n\n\\begin{equation*}\nfib(n)= \\left \\{\n\\begin{array}{ll}\n1  & (n = 0) \\\\\n1  & (n = 1) \\\\\nfib(n - 1) + fib(n - 2) & \\\\\n\\end{array}\n\\right.\n\\end{equation*}\n\nInput\n\nAn integer $n$ is given.\n\noutput\n\nPrint the $n$-th fibonacci number in a line.\n\nConstraints\n\n$0 \\leq n \\leq 44$\n\nSample Input 1\n\n3\n\nSample Output 1\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 235, "cpu_time_ms": 260, "memory_kb": 43636}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s794397916", "group_id": "codeNet:p02233", "input_text": "import scala.io.StdIn.readInt\n\nobject Main {\n\n def loop(i:Int, x:Int, y:Int):Int = if(i == 0) y else loop(i-1, y, x+y)\n\n def main(args:Array[String]) = {\n val n = readInt\n println(loop(n,0,1))\n }\n}\n", "language": "Scala", "metadata": {"date": 1516633258, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02233.html", "problem_id": "p02233", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02233/input.txt", "sample_output_relpath": "derived/input_output/data/p02233/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02233/Scala/s794397916.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s794397916", "user_id": "u508732591"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.io.StdIn.readInt\n\nobject Main {\n\n def loop(i:Int, x:Int, y:Int):Int = if(i == 0) y else loop(i-1, y, x+y)\n\n def main(args:Array[String]) = {\n val n = readInt\n println(loop(n,0,1))\n }\n}\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nFibonacci Number\n\nWrite a program which prints $n$-th fibonacci number for a given integer $n$. The $n$-th fibonacci number is defined by the following recursive formula:\n\n\\begin{equation*}\nfib(n)= \\left \\{\n\\begin{array}{ll}\n1  & (n = 0) \\\\\n1  & (n = 1) \\\\\nfib(n - 1) + fib(n - 2) & \\\\\n\\end{array}\n\\right.\n\\end{equation*}\n\nInput\n\nAn integer $n$ is given.\n\noutput\n\nPrint the $n$-th fibonacci number in a line.\n\nConstraints\n\n$0 \\leq n \\leq 44$\n\nSample Input 1\n\n3\n\nSample Output 1\n\n3", "sample_input": "3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02233", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nFibonacci Number\n\nWrite a program which prints $n$-th fibonacci number for a given integer $n$. The $n$-th fibonacci number is defined by the following recursive formula:\n\n\\begin{equation*}\nfib(n)= \\left \\{\n\\begin{array}{ll}\n1  & (n = 0) \\\\\n1  & (n = 1) \\\\\nfib(n - 1) + fib(n - 2) & \\\\\n\\end{array}\n\\right.\n\\end{equation*}\n\nInput\n\nAn integer $n$ is given.\n\noutput\n\nPrint the $n$-th fibonacci number in a line.\n\nConstraints\n\n$0 \\leq n \\leq 44$\n\nSample Input 1\n\n3\n\nSample Output 1\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 208, "cpu_time_ms": 230, "memory_kb": 43668}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s425319966", "group_id": "codeNet:p02235", "input_text": "import scala.io.StdIn.{readInt,readLine}\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n def max(x:Int,y:Int) = if(x>y) x else y\n\n def main(args:Array[String]) = {\n val n = readInt\n val b = new ArrayBuffer[Int]\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<-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 b += a(maxN-1)(maxM-1)\n }\n println(b.mkString(\"\\n\"))\n }\n}", "language": "Scala", "metadata": {"date": 1495377359, "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/s425319966.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s425319966", "user_id": "u508732591"}, "prompt_components": {"gold_output": "4\n3\n2\n", "input_to_evaluate": "import scala.io.StdIn.{readInt,readLine}\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n def max(x:Int,y:Int) = if(x>y) x else y\n\n def main(args:Array[String]) = {\n val n = readInt\n val b = new ArrayBuffer[Int]\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<-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 b += a(maxN-1)(maxM-1)\n }\n println(b.mkString(\"\\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 715, "cpu_time_ms": 410, "memory_kb": 124368}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s629022661", "group_id": "codeNet:p02235", "input_text": "import scala.io.StdIn.{readInt, readLine};\nobject Main {\n def main(args: Array[String]): Unit = {\n (0 until readInt).foreach { i =>\n val y = readLine;\n val x = readLine;\n println(longestCommonSubsequence(y, x));\n }\n }\n def longestCommonSubsequence(strY: String, strX: String): Int = {\n val sizeX = strX.length;\n val sizeY = strY.length;\n val arr = Array.ofDim[Int](sizeY + 1, sizeX + 1);\n (1 to sizeY).foreach { y => (1 to sizeX).foreach { x => arr(y)(x) = -1}}\n def go(y: Int, x: Int): Int = {\n val lcs = arr(y)(x);\n if (lcs != -1) {\n lcs;\n } else {\n val lcs1 = go(y - 1, x - 1);\n val lcs2 = go(y - 1, x);\n val lcs3 = go(y, x - 1);\n arr(y)(x) = if (strX(x - 1) == strY(y - 1)) max(lcs1 + 1, lcs2, lcs3) else max(lcs1, lcs2, lcs3);\n arr(y)(x);\n }\n }\n go(sizeY, sizeX);\n }\n\n def max(a: Int, b: Int, c: Int): Int = {\n if (a > b)\n if (a > c) a else c;\n else\n if (b > c) b else c;\n }\n}\n", "language": "Scala", "metadata": {"date": 1521435836, "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/s629022661.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s629022661", "user_id": "u909989059"}, "prompt_components": {"gold_output": "4\n3\n2\n", "input_to_evaluate": "import scala.io.StdIn.{readInt, readLine};\nobject Main {\n def main(args: Array[String]): Unit = {\n (0 until readInt).foreach { i =>\n val y = readLine;\n val x = readLine;\n println(longestCommonSubsequence(y, x));\n }\n }\n def longestCommonSubsequence(strY: String, strX: String): Int = {\n val sizeX = strX.length;\n val sizeY = strY.length;\n val arr = Array.ofDim[Int](sizeY + 1, sizeX + 1);\n (1 to sizeY).foreach { y => (1 to sizeX).foreach { x => arr(y)(x) = -1}}\n def go(y: Int, x: Int): Int = {\n val lcs = arr(y)(x);\n if (lcs != -1) {\n lcs;\n } else {\n val lcs1 = go(y - 1, x - 1);\n val lcs2 = go(y - 1, x);\n val lcs3 = go(y, x - 1);\n arr(y)(x) = if (strX(x - 1) == strY(y - 1)) max(lcs1 + 1, lcs2, lcs3) else max(lcs1, lcs2, lcs3);\n arr(y)(x);\n }\n }\n go(sizeY, sizeX);\n }\n\n def max(a: Int, b: Int, c: Int): Int = {\n if (a > b)\n if (a > c) a else c;\n else\n if (b > c) b else c;\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1167, "cpu_time_ms": 610, "memory_kb": 124604}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s442780397", "group_id": "codeNet:p02238", "input_text": "object Main extends App {\n val n: Int = io.StdIn.readInt()\n val d: Array[Int] = Array.ofDim(n)\n val f: Array[Int] = Array.ofDim(n)\n val adjacencyMatrix: Seq[Array[Int]] =\n for (_ <- (0 until n).toVector)\n yield io.StdIn.readLine().split(\" \").drop(2).map(_.toInt - 1)\n loop(0, 1)\n for (i <- 0 until n) println(s\"${i+1} ${d(i)} ${f(i)}\")\n \n def loop(current: Int, time: Int): Int = {\n var t: Int = time\n d(current) = time\n for(x <- adjacencyMatrix(current)) {\n if (d(x) == 0) t = loop(x, t+1)\n }\n t += 1\n f(current) = t\n t\n }\n}\n", "language": "Scala", "metadata": {"date": 1530795877, "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/s442780397.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s442780397", "user_id": "u995793569"}, "prompt_components": {"gold_output": "1 1 8\n2 2 7\n3 4 5\n4 3 6\n", "input_to_evaluate": "object Main extends App {\n val n: Int = io.StdIn.readInt()\n val d: Array[Int] = Array.ofDim(n)\n val f: Array[Int] = Array.ofDim(n)\n val adjacencyMatrix: Seq[Array[Int]] =\n for (_ <- (0 until n).toVector)\n yield io.StdIn.readLine().split(\" \").drop(2).map(_.toInt - 1)\n loop(0, 1)\n for (i <- 0 until n) println(s\"${i+1} ${d(i)} ${f(i)}\")\n \n def loop(current: Int, time: Int): Int = {\n var t: Int = time\n d(current) = time\n for(x <- adjacencyMatrix(current)) {\n if (d(x) == 0) t = loop(x, t+1)\n }\n t += 1\n f(current) = t\n t\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 569, "cpu_time_ms": 230, "memory_kb": 43964}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s186886007", "group_id": "codeNet:p02238", "input_text": "object Main extends App {\n val in = io.Source.stdin.getLines.map(_.split(\" \").map(_.toInt))\n val n = in.next.head\n val tree = in.map(_.drop(2).map(_ - 1)).toList\n val res = List.fill(n)(Array.fill(3)(0))\n solve(1, 0, tree(0))\n def solve(d: Int, id: Int, ids: Array[Int]): Int = {\n if (res(id)(2) == 1) {\n d - 1\n } else {\n res(id)(0) = d\n res(id)(2) = 1\n val f_chld = ids.foldLeft(d)((_d, _id) => solve(_d + 1, _id, tree(_id)))\n res(id)(1) = f_chld + 1\n f_chld + 1\n }\n }\n res.zipWithIndex.foreach{case (x, i) => println(i + 1 + \" \" + x.init.mkString(\" \"))}\n}", "language": "Scala", "metadata": {"date": 1493962194, "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/s186886007.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s186886007", "user_id": "u475394465"}, "prompt_components": {"gold_output": "1 1 8\n2 2 7\n3 4 5\n4 3 6\n", "input_to_evaluate": "object Main extends App {\n val in = io.Source.stdin.getLines.map(_.split(\" \").map(_.toInt))\n val n = in.next.head\n val tree = in.map(_.drop(2).map(_ - 1)).toList\n val res = List.fill(n)(Array.fill(3)(0))\n solve(1, 0, tree(0))\n def solve(d: Int, id: Int, ids: Array[Int]): Int = {\n if (res(id)(2) == 1) {\n d - 1\n } else {\n res(id)(0) = d\n res(id)(2) = 1\n val f_chld = ids.foldLeft(d)((_d, _id) => solve(_d + 1, _id, tree(_id)))\n res(id)(1) = f_chld + 1\n f_chld + 1\n }\n }\n res.zipWithIndex.foreach{case (x, i) => println(i + 1 + \" \" + x.init.mkString(\" \"))}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 668, "cpu_time_ms": 230, "memory_kb": 43968}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s489206859", "group_id": "codeNet:p02238", "input_text": "object Main extends App {\n val in = io.Source.stdin.getLines.map(_.split(\" \").map(_.toInt))\n val n = in.next.head\n val tree = in.map(_.drop(2).map(_ - 1)).toList\n val res = List.fill(n)(Array.fill(2)(0))\n def solve(d: Int, id: Int, ids: Array[Int]): Int =\n if (res(id)(0) != 0) {\n d - 1\n } else {\n res(id)(0) = d\n val f_chld = ids.foldLeft(d)((_d, _id) => solve(_d + 1, _id, tree(_id)))\n res(id)(1) = f_chld + 1\n f_chld + 1\n }\n\n solve(1, 0, tree(0))\n res.zipWithIndex.foreach{case (x, i) => println(i + 1 + \" \" + x.mkString(\" \"))}\n}", "language": "Scala", "metadata": {"date": 1493963722, "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/s489206859.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s489206859", "user_id": "u475394465"}, "prompt_components": {"gold_output": "1 1 8\n2 2 7\n3 4 5\n4 3 6\n", "input_to_evaluate": "object Main extends App {\n val in = io.Source.stdin.getLines.map(_.split(\" \").map(_.toInt))\n val n = in.next.head\n val tree = in.map(_.drop(2).map(_ - 1)).toList\n val res = List.fill(n)(Array.fill(2)(0))\n def solve(d: Int, id: Int, ids: Array[Int]): Int =\n if (res(id)(0) != 0) {\n d - 1\n } else {\n res(id)(0) = d\n val f_chld = ids.foldLeft(d)((_d, _id) => solve(_d + 1, _id, tree(_id)))\n res(id)(1) = f_chld + 1\n f_chld + 1\n }\n\n solve(1, 0, tree(0))\n res.zipWithIndex.foreach{case (x, i) => println(i + 1 + \" \" + x.mkString(\" \"))}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 629, "cpu_time_ms": 230, "memory_kb": 44396}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s871672695", "group_id": "codeNet:p02239", "input_text": "import scala.io.StdIn.{readInt,readLine}\n \nobject Main {\n def main(args:Array[String]) = {\n val n = readInt\n val d = (1 to n).map(_ => -1).toArray\n\n val g = {\n for(i<-0 until n) yield {\n val v = readLine.split(\" \").map(_.toInt)\n (for(j<-2 until 2+v(1)) yield v(j) ).toArray\n }\n }.toArray\n\n var list = Array(1)\n var cnt = 0\n while(list.length>0) {\n println(\"list=\"+list.mkString(\" \"))\n for(e <- list) {\n if(d(e-1) == -1) { d(e-1) = cnt }\n list = g(e-1)\n }\n cnt += 1\n }\n\n for(i<-0 until n) println((i+1) + \" \" + d(i))\n }\n}", "language": "Scala", "metadata": {"date": 1495271980, "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/s871672695.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s871672695", "user_id": "u508732591"}, "prompt_components": {"gold_output": "1 0\n2 1\n3 2\n4 1\n", "input_to_evaluate": "import scala.io.StdIn.{readInt,readLine}\n \nobject Main {\n def main(args:Array[String]) = {\n val n = readInt\n val d = (1 to n).map(_ => -1).toArray\n\n val g = {\n for(i<-0 until n) yield {\n val v = readLine.split(\" \").map(_.toInt)\n (for(j<-2 until 2+v(1)) yield v(j) ).toArray\n }\n }.toArray\n\n var list = Array(1)\n var cnt = 0\n while(list.length>0) {\n println(\"list=\"+list.mkString(\" \"))\n for(e <- list) {\n if(d(e-1) == -1) { d(e-1) = cnt }\n list = g(e-1)\n }\n cnt += 1\n }\n\n for(i<-0 until n) println((i+1) + \" \" + d(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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 608, "cpu_time_ms": 230, "memory_kb": 43840}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s214474502", "group_id": "codeNet:p02240", "input_text": "import scala.collection.mutable.ArrayBuffer\nimport scala.io.StdIn\n\nobject Main extends App {\n\n val Array(n, m) = StdIn.readLine().split(' ').map(_.toInt)\n val groupIndex = Array.fill[Int](n)(-1)\n val friends = Array.ofDim[ArrayBuffer[Int]](n)\n \n (0 until m).foreach { _ =>\n val a = StdIn.readLine().split(' ').map(_.toInt)\n friends(a(0)) = if(friends(a(0)) == null) ArrayBuffer.empty[Int] else friends(a(0))\n friends(a(0)) += a(1)\n friends(a(1)) = if(friends(a(1)) == null) ArrayBuffer.empty[Int] else friends(a(1))\n friends(a(1)) += a(0)\n }\n\n def dps(r: Int, groupIdx: Int): Unit = {\n var buff = ArrayBuffer.empty[Int]\n buff += r\n groupIndex(r) = groupIdx\n while(buff.nonEmpty){\n val u = buff.head\n buff = buff.tail\n friends(u).foreach{ v =>\n if(groupIndex(v) == -1){\n groupIndex(v) = groupIdx\n buff += v\n }\n }\n }\n }\n\n var idx = 1\n (0 until n).foreach { v =>\n if(groupIndex(v) == -1){\n dps(v, idx + 1)\n idx += 1\n }\n }\n\n val q = StdIn.readLine().toInt\n val sbbuff = new StringBuilder\n //println(s\"q: $q\")\n (0 until q).foreach { _ =>\n val ql = StdIn.readLine().split(' ').map(_.toInt)\n sbbuff.append(if(groupIndex(ql(0)) == groupIndex(ql(1))){\n f\"yes%n\" \n } else {\n f\"no%n\"\n })\n }\n \n println(sbbuff.toString())\n \n}\n\n\n", "language": "Scala", "metadata": {"date": 1525644946, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02240.html", "problem_id": "p02240", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02240/input.txt", "sample_output_relpath": "derived/input_output/data/p02240/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02240/Scala/s214474502.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s214474502", "user_id": "u342234782"}, "prompt_components": {"gold_output": "yes\nyes\nno\n", "input_to_evaluate": "import scala.collection.mutable.ArrayBuffer\nimport scala.io.StdIn\n\nobject Main extends App {\n\n val Array(n, m) = StdIn.readLine().split(' ').map(_.toInt)\n val groupIndex = Array.fill[Int](n)(-1)\n val friends = Array.ofDim[ArrayBuffer[Int]](n)\n \n (0 until m).foreach { _ =>\n val a = StdIn.readLine().split(' ').map(_.toInt)\n friends(a(0)) = if(friends(a(0)) == null) ArrayBuffer.empty[Int] else friends(a(0))\n friends(a(0)) += a(1)\n friends(a(1)) = if(friends(a(1)) == null) ArrayBuffer.empty[Int] else friends(a(1))\n friends(a(1)) += a(0)\n }\n\n def dps(r: Int, groupIdx: Int): Unit = {\n var buff = ArrayBuffer.empty[Int]\n buff += r\n groupIndex(r) = groupIdx\n while(buff.nonEmpty){\n val u = buff.head\n buff = buff.tail\n friends(u).foreach{ v =>\n if(groupIndex(v) == -1){\n groupIndex(v) = groupIdx\n buff += v\n }\n }\n }\n }\n\n var idx = 1\n (0 until n).foreach { v =>\n if(groupIndex(v) == -1){\n dps(v, idx + 1)\n idx += 1\n }\n }\n\n val q = StdIn.readLine().toInt\n val sbbuff = new StringBuilder\n //println(s\"q: $q\")\n (0 until q).foreach { _ =>\n val ql = StdIn.readLine().split(' ').map(_.toInt)\n sbbuff.append(if(groupIndex(ql(0)) == groupIndex(ql(1))){\n f\"yes%n\" \n } else {\n f\"no%n\"\n })\n }\n \n println(sbbuff.toString())\n \n}\n\n\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nConnected Components\n\nWrite a program which reads relations in a SNS (Social Network Service), and judges that given pairs of users are reachable each other through the network.\n\nInput\n\nIn the first line, two integer $n$ and $m$ are given. $n$ is the number of users in the SNS and $m$ is the number of relations in the SNS. The users in the SNS are identified by IDs $0, 1, ..., n-1$.\n\nIn the following $m$ lines, the relations are given. Each relation is given by two integers $s$ and $t$ that represents $s$ and $t$ are friends (and reachable each other).\n\nIn the next line, the number of queries $q$ is given. In the following $q$ lines, $q$ queries are given respectively. Each query consists of two integers $s$ and $t$ separated by a space character.\n\nOutput\n\nFor each query, print \"yes\" if $t$ is reachable from $s$ through the social network, \"no\" otherwise.\n\nConstraints\n\n$2 \\leq n \\leq 100,000$\n\n$0 \\leq m \\leq 100,000$\n\n$1 \\leq q \\leq 10,000$\n\nSample Input\n\n10 9\n0 1\n0 2\n3 4\n5 7\n5 6\n6 7\n6 8\n7 8\n8 9\n3\n0 1\n5 9\n1 3\n\nSample Output\n\nyes\nyes\nno", "sample_input": "10 9\n0 1\n0 2\n3 4\n5 7\n5 6\n6 7\n6 8\n7 8\n8 9\n3\n0 1\n5 9\n1 3\n"}, "reference_outputs": ["yes\nyes\nno\n"], "source_document_id": "p02240", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nConnected Components\n\nWrite a program which reads relations in a SNS (Social Network Service), and judges that given pairs of users are reachable each other through the network.\n\nInput\n\nIn the first line, two integer $n$ and $m$ are given. $n$ is the number of users in the SNS and $m$ is the number of relations in the SNS. The users in the SNS are identified by IDs $0, 1, ..., n-1$.\n\nIn the following $m$ lines, the relations are given. Each relation is given by two integers $s$ and $t$ that represents $s$ and $t$ are friends (and reachable each other).\n\nIn the next line, the number of queries $q$ is given. In the following $q$ lines, $q$ queries are given respectively. Each query consists of two integers $s$ and $t$ separated by a space character.\n\nOutput\n\nFor each query, print \"yes\" if $t$ is reachable from $s$ through the social network, \"no\" otherwise.\n\nConstraints\n\n$2 \\leq n \\leq 100,000$\n\n$0 \\leq m \\leq 100,000$\n\n$1 \\leq q \\leq 10,000$\n\nSample Input\n\n10 9\n0 1\n0 2\n3 4\n5 7\n5 6\n6 7\n6 8\n7 8\n8 9\n3\n0 1\n5 9\n1 3\n\nSample Output\n\nyes\nyes\nno", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1355, "cpu_time_ms": 230, "memory_kb": 44052}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s627727958", "group_id": "codeNet:p02241", "input_text": "import scala.collection.mutable.ArraySeq;\nimport scala.reflect.ClassTag;\nimport scala.io.StdIn.{readInt, readLine};\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val n = readInt;\n val ig = new IntGraph(n);\n (0 until n).foreach { i => \n readLine.trim.split(\" \").map(_.toInt).zipWithIndex.filter( e => e._1 != -1).foreach { e => ig.add(i, e._2, e._1)}\n }\n val ret = ig.mst;\n println(ret._1.sum);\n }\n}\nclass IntGraph(n: Int) {\n case class Node(value: Int, cost: Int);\n val matrix: Array[List[Node]] = new Array[List[Node]](n).map( e => Nil);\n \n override def toString(): String = {\n matrix.zipWithIndex.foldLeft[List[String]](Nil) { (list, e) =>\n val nodes = e._1.map( n => n.value.toString + \"(\" + n.cost.toString + \")\"); \n e._2.toString + \" -> \" + nodes.mkString(\", \") :: list;\n }.reverse.mkString(\"\\n\");\n }\n \n def add(src: Int, dst: Int, cost: Int): Unit = matrix(src) = Node(dst, cost) :: matrix(src);\n \n def mst(): (Array[Int], Array[Int]) = {\n val colors = new Array[Int](n); // 0 : 未探索, 1 : 追加候補, 2 : 追加済み\n val parents = new Array[Int](n);\n val distances = new Array[Int](n).map( e => Int.MaxValue);\n val pq = new PriorityQueue[Node](n * n)(Ordering.by((e: Node) => e.cost).reverse);\n var cnt = 0;\n def _mst(): Unit = {\n pq.dequeue match {\n case None => ();\n case Some(Node(minValue, minCost)) if (colors(minValue) == 2) => _mst;\n case Some(Node(minValue, minCost)) => {\n colors(minValue) = 2;\n cnt += 1;\n if (cnt < n) {\n matrix(minValue).foreach { e =>\n if (e.cost < distances(e.value) && colors(e.value) != 2) {\n colors(e.value) = 1;\n parents(e.value) = minValue;\n distances(e.value) = e.cost;\n pq.enqueue(e);\n }\n }\n _mst;\n }\n }\n }\n }\n parents(0) = -1;\n distances(0) = 0;\n pq.enqueue(Node(0, distances(0)));\n _mst;\n (distances, parents);\n }\n}\n\nclass PriorityQueue[A](len: Int)(implicit ord: Ordering[A]) {\n import ord._;\n private val heap = new ArraySeq[A](len);\n var size = 0;\n \n def isEmpty: Boolean = size == 0;\n \n def isFull: Boolean = size == len;\n \n def enqueue(e: A): Unit = {\n def _enqueue(curr: Int): Unit = {\n // if (curr % 2 == 0) right else left\n val parent = if (curr % 2 == 0) (curr - 2) / 2 else (curr - 1) / 2; \n if (parent >= 0 && heap(curr) > heap(parent)) {\n swap(curr, parent);\n _enqueue(parent);\n }\n }\n if (!isFull) {\n heap(size) = e;\n _enqueue(size);\n size += 1;\n }\n }\n \n def dequeue(): Option[A] = {\n if (isEmpty) {\n None;\n } else {\n val top = heap(0);\n size -= 1;\n heap(0) = heap(size);\n heapify(0);\n Some(top);\n }\n }\n \n private def heapify(curr: Int): Unit = {\n if (curr < size) {\n val left = curr * 2 + 1;\n val right = curr * 2 + 2;\n if (right < size) {\n val maxIdx = max(curr, left, right);\n if (curr < maxIdx) {\n swap(curr, maxIdx);\n heapify(maxIdx);\n }\n } else if (left < size && heap(left) > heap(curr)) {\n swap(curr, left);\n }\n }\n }\n\n private def max(curr: Int, left: Int, right: Int): Int = {\n if (heap(curr) > heap(left)) {\n if (heap(right) > heap(curr)) right else curr;\n } else {\n if (heap(right) > heap(left)) right else left;\n }\n }\n\n private def swap(a: Int, b: Int): Unit = {\n val tmp = heap(a);\n heap(a) = heap(b);\n heap(b) = tmp;\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1523782397, "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/s627727958.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s627727958", "user_id": "u909989059"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import scala.collection.mutable.ArraySeq;\nimport scala.reflect.ClassTag;\nimport scala.io.StdIn.{readInt, readLine};\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val n = readInt;\n val ig = new IntGraph(n);\n (0 until n).foreach { i => \n readLine.trim.split(\" \").map(_.toInt).zipWithIndex.filter( e => e._1 != -1).foreach { e => ig.add(i, e._2, e._1)}\n }\n val ret = ig.mst;\n println(ret._1.sum);\n }\n}\nclass IntGraph(n: Int) {\n case class Node(value: Int, cost: Int);\n val matrix: Array[List[Node]] = new Array[List[Node]](n).map( e => Nil);\n \n override def toString(): String = {\n matrix.zipWithIndex.foldLeft[List[String]](Nil) { (list, e) =>\n val nodes = e._1.map( n => n.value.toString + \"(\" + n.cost.toString + \")\"); \n e._2.toString + \" -> \" + nodes.mkString(\", \") :: list;\n }.reverse.mkString(\"\\n\");\n }\n \n def add(src: Int, dst: Int, cost: Int): Unit = matrix(src) = Node(dst, cost) :: matrix(src);\n \n def mst(): (Array[Int], Array[Int]) = {\n val colors = new Array[Int](n); // 0 : 未探索, 1 : 追加候補, 2 : 追加済み\n val parents = new Array[Int](n);\n val distances = new Array[Int](n).map( e => Int.MaxValue);\n val pq = new PriorityQueue[Node](n * n)(Ordering.by((e: Node) => e.cost).reverse);\n var cnt = 0;\n def _mst(): Unit = {\n pq.dequeue match {\n case None => ();\n case Some(Node(minValue, minCost)) if (colors(minValue) == 2) => _mst;\n case Some(Node(minValue, minCost)) => {\n colors(minValue) = 2;\n cnt += 1;\n if (cnt < n) {\n matrix(minValue).foreach { e =>\n if (e.cost < distances(e.value) && colors(e.value) != 2) {\n colors(e.value) = 1;\n parents(e.value) = minValue;\n distances(e.value) = e.cost;\n pq.enqueue(e);\n }\n }\n _mst;\n }\n }\n }\n }\n parents(0) = -1;\n distances(0) = 0;\n pq.enqueue(Node(0, distances(0)));\n _mst;\n (distances, parents);\n }\n}\n\nclass PriorityQueue[A](len: Int)(implicit ord: Ordering[A]) {\n import ord._;\n private val heap = new ArraySeq[A](len);\n var size = 0;\n \n def isEmpty: Boolean = size == 0;\n \n def isFull: Boolean = size == len;\n \n def enqueue(e: A): Unit = {\n def _enqueue(curr: Int): Unit = {\n // if (curr % 2 == 0) right else left\n val parent = if (curr % 2 == 0) (curr - 2) / 2 else (curr - 1) / 2; \n if (parent >= 0 && heap(curr) > heap(parent)) {\n swap(curr, parent);\n _enqueue(parent);\n }\n }\n if (!isFull) {\n heap(size) = e;\n _enqueue(size);\n size += 1;\n }\n }\n \n def dequeue(): Option[A] = {\n if (isEmpty) {\n None;\n } else {\n val top = heap(0);\n size -= 1;\n heap(0) = heap(size);\n heapify(0);\n Some(top);\n }\n }\n \n private def heapify(curr: Int): Unit = {\n if (curr < size) {\n val left = curr * 2 + 1;\n val right = curr * 2 + 2;\n if (right < size) {\n val maxIdx = max(curr, left, right);\n if (curr < maxIdx) {\n swap(curr, maxIdx);\n heapify(maxIdx);\n }\n } else if (left < size && heap(left) > heap(curr)) {\n swap(curr, left);\n }\n }\n }\n\n private def max(curr: Int, left: Int, right: Int): Int = {\n if (heap(curr) > heap(left)) {\n if (heap(right) > heap(curr)) right else curr;\n } else {\n if (heap(right) > heap(left)) right else left;\n }\n }\n\n private def swap(a: Int, b: Int): Unit = {\n val tmp = heap(a);\n heap(a) = heap(b);\n heap(b) = tmp;\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4242, "cpu_time_ms": 330, "memory_kb": 48720}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s286069329", "group_id": "codeNet:p02249", "input_text": "import scala.io.StdIn.readLine\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n def main(args:Array[String]) = {\n val hw = readLine.split(\" \").map(_.toInt)\n val fld = (for(i<-0 until hw(0)) yield {\n readLine.trim.map(_.asDigit)\n }).toArray\n val rc = readLine.split(\" \").map(_.toInt)\n val pattern = (for(i<-0 until rc(0)) yield {\n readLine.trim.map(_.asDigit)\n }).toArray\n val b = new ArrayBuffer[Array[Int]]\n\n for(i<-0 to (hw(0)-rc(0))) {\n for(j<-0 to (hw(1)-rc(1))) {\n var m = true\n var k = 0\n var l = 0\n while(m && kif(x(0)if(x(0)= 0 && a(j) > v){\n a(j+1) = a(j)\n j = j - 1\n }\n a(j+1) = v\n println(a.mkString(\" \"))\n }\n\n println(a.mkString(\" \"))\n\n }\n}", "language": "Scala", "metadata": {"date": 1435054772, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02255.html", "problem_id": "p02255", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02255/input.txt", "sample_output_relpath": "derived/input_output/data/p02255/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02255/Scala/s981254144.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s981254144", "user_id": "u225502267"}, "prompt_components": {"gold_output": "5 2 4 6 1 3\n2 5 4 6 1 3\n2 4 5 6 1 3\n2 4 5 6 1 3\n1 2 4 5 6 3\n1 2 3 4 5 6\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val input = new java.util.Scanner(System.in)\n val n = input.nextInt\n val a = new Array[Int](n)\n for (i <- 0 until n) {\n a(i) = input.nextInt\n }\n\n for(i <- 1 until n) {\n val v = a(i)\n var j = i - 1\n while(j >= 0 && a(j) > v){\n a(j+1) = a(j)\n j = j - 1\n }\n a(j+1) = v\n println(a.mkString(\" \"))\n }\n\n println(a.mkString(\" \"))\n\n }\n}", "problem_context": "Insertion Sort\n\nWrite a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\nfor i = 1 to A.length-1\nkey = A[i]\n/* insert A[i] into the sorted sequence A[0,...,j-1] */\nj = i - 1\nwhile j >= 0 and A[j] > key\nA[j+1] = A[j]\nj--\nA[j+1] = key\n\nNote that, indices for array elements are based on 0-origin.\n\nTo illustrate the algorithms, your program should trace intermediate result for each step.\n\nInput\n\nThe first line of the input includes an integer N, the number of elements in the sequence.\n\nIn the second line, N elements of the sequence are given separated by a single space.\n\nOutput\n\nThe output consists of N lines. Please output the intermediate sequence in a line for each step. Elements of the sequence should be separated by single space.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nSample Input 1\n\n6\n5 2 4 6 1 3\n\nSample Output 1\n\n5 2 4 6 1 3\n2 5 4 6 1 3\n2 4 5 6 1 3\n2 4 5 6 1 3\n1 2 4 5 6 3\n1 2 3 4 5 6\n\nSample Input 2\n\n3\n1 2 3\n\nSample Output 2\n\n1 2 3\n1 2 3\n1 2 3\n\nHint\n\nTemplate in C", "sample_input": "6\n5 2 4 6 1 3\n"}, "reference_outputs": ["5 2 4 6 1 3\n2 5 4 6 1 3\n2 4 5 6 1 3\n2 4 5 6 1 3\n1 2 4 5 6 3\n1 2 3 4 5 6\n"], "source_document_id": "p02255", "source_text": "Insertion Sort\n\nWrite a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\nfor i = 1 to A.length-1\nkey = A[i]\n/* insert A[i] into the sorted sequence A[0,...,j-1] */\nj = i - 1\nwhile j >= 0 and A[j] > key\nA[j+1] = A[j]\nj--\nA[j+1] = key\n\nNote that, indices for array elements are based on 0-origin.\n\nTo illustrate the algorithms, your program should trace intermediate result for each step.\n\nInput\n\nThe first line of the input includes an integer N, the number of elements in the sequence.\n\nIn the second line, N elements of the sequence are given separated by a single space.\n\nOutput\n\nThe output consists of N lines. Please output the intermediate sequence in a line for each step. Elements of the sequence should be separated by single space.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nSample Input 1\n\n6\n5 2 4 6 1 3\n\nSample Output 1\n\n5 2 4 6 1 3\n2 5 4 6 1 3\n2 4 5 6 1 3\n2 4 5 6 1 3\n1 2 4 5 6 3\n1 2 3 4 5 6\n\nSample Input 2\n\n3\n1 2 3\n\nSample Output 2\n\n1 2 3\n1 2 3\n1 2 3\n\nHint\n\nTemplate in C", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 458, "cpu_time_ms": 240, "memory_kb": 42144}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s849905596", "group_id": "codeNet:p02256", "input_text": "import scala.io.StdIn\n\nobject Main {\n def main(args: Array[String]){\n val input = StdIn.readLine().split(\" \").map(_.toInt)\n println(gcd(input(0),input(1)))\n }\n\n def gcd(x: Int, y: Int):Int = {\n return if(1 < y && y < x) { gcd(y, x % y) } else { x }\n }\n}", "language": "Scala", "metadata": {"date": 1444662161, "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/s849905596.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s849905596", "user_id": "u274875240"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main {\n def main(args: Array[String]){\n val input = StdIn.readLine().split(\" \").map(_.toInt)\n println(gcd(input(0),input(1)))\n }\n\n def gcd(x: Int, y: Int):Int = {\n return if(1 < y && y < x) { gcd(y, x % y) } else { x }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 266, "cpu_time_ms": 270, "memory_kb": 43488}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s708738802", "group_id": "codeNet:p02257", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n\n val n = StdIn.readLine().trim.toInt\n \n def isPrime(x: Int): Boolean = {\n if (x == 2) {\n true\n }\n else if (x < 2 || x % 2 == 0) {\n false\n } else {\n !(3 to scala.math.sqrt(x).toInt by 2).exists(i => x % i == 0)\n }\n }\n\n println((0 until n).foldLeft(0){ (acc, _) =>\n val x = StdIn.readLine().trim.toInt\n acc + (if(isPrime(x)) 1 else 0)\n })\n\n}\n\n", "language": "Scala", "metadata": {"date": 1528378106, "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/s708738802.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s708738802", "user_id": "u342234782"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n\n val n = StdIn.readLine().trim.toInt\n \n def isPrime(x: Int): Boolean = {\n if (x == 2) {\n true\n }\n else if (x < 2 || x % 2 == 0) {\n false\n } else {\n !(3 to scala.math.sqrt(x).toInt by 2).exists(i => x % i == 0)\n }\n }\n\n println((0 until n).foldLeft(0){ (acc, _) =>\n val x = StdIn.readLine().trim.toInt\n acc + (if(isPrime(x)) 1 else 0)\n })\n\n}\n\n", "problem_context": "Prime Numbers\n\nA prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.\n\nWrite a program which reads a list of N integers and prints the number of prime numbers in the list.\n\nInput\n\nThe first line contains an integer N, the number of elements in the list.\n\nN numbers are given in the following lines.\n\nOutput\n\nPrint the number of prime numbers in the given list.\n\nConstraints\n\n1 ≤ N ≤ 10000\n\n2 ≤ an element of the list ≤ 108\n\nSample Input 1\n\n5\n2\n3\n4\n5\n6\n\nSample Output 1\n\n3\n\nSample Input 2\n\n11\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n\nSample Output 2\n\n4", "sample_input": "5\n2\n3\n4\n5\n6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02257", "source_text": "Prime Numbers\n\nA prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.\n\nWrite a program which reads a list of N integers and prints the number of prime numbers in the list.\n\nInput\n\nThe first line contains an integer N, the number of elements in the list.\n\nN numbers are given in the following lines.\n\nOutput\n\nPrint the number of prime numbers in the given list.\n\nConstraints\n\n1 ≤ N ≤ 10000\n\n2 ≤ an element of the list ≤ 108\n\nSample Input 1\n\n5\n2\n3\n4\n5\n6\n\nSample Output 1\n\n3\n\nSample Input 2\n\n11\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n\nSample Output 2\n\n4", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 433, "cpu_time_ms": 360, "memory_kb": 90332}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s686098898", "group_id": "codeNet:p02258", "input_text": "import scala.io.Source\n\nobject Main{\n def main(args: Array[String]){\n val lines = for{\n in <- Source.stdin.getLines.toList\n }yield in.toInt\n\n println(rec(lines.tail).max)\n }\n\n def rec(list: List[Int]): List[Int] =\n if(list.length == 1) Nil\n else list.last - list.init.min :: rec(list.init)\n}", "language": "Scala", "metadata": {"date": 1461648397, "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/s686098898.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Memory Limit Exceeded", "submission_id": "s686098898", "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.toList\n }yield in.toInt\n\n println(rec(lines.tail).max)\n }\n\n def rec(list: List[Int]): List[Int] =\n if(list.length == 1) Nil\n else list.last - list.init.min :: rec(list.init)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 830, "memory_kb": 468000}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s436214497", "group_id": "codeNet:p02258", "input_text": "import scala.io.Source\nimport scala.annotation.tailrec\n\nobject Main{\n def main(args: Array[String]){\n val lines = for{\n in <- Source.stdin.getLines.toList\n }yield in.toInt\n\n println(rec(lines.tail, Int.MinValue))\n }\n\n @tailrec\n def rec(list: List[Int], max: Int): Int ={\n if(list.length == 1) max\n else rec(list.init, Math.max(list.last - list.init.min, max))\n }\n}", "language": "Scala", "metadata": {"date": 1461663522, "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/s436214497.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Memory Limit Exceeded", "submission_id": "s436214497", "user_id": "u085441951"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.io.Source\nimport scala.annotation.tailrec\n\nobject Main{\n def main(args: Array[String]){\n val lines = for{\n in <- Source.stdin.getLines.toList\n }yield in.toInt\n\n println(rec(lines.tail, Int.MinValue))\n }\n\n @tailrec\n def rec(list: List[Int], max: Int): Int ={\n if(list.length == 1) max\n else rec(list.init, Math.max(list.last - list.init.min, 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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 389, "cpu_time_ms": 670, "memory_kb": 437696}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s424325553", "group_id": "codeNet:p02258", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\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/*\n for(i <- 1 to sz) {\n for(j <- i+1 to sz) {\n val temp = intArray(j) - intArray(i)\n if(temp>ret) ret = temp\n }\n }\n*/\n println(ret)\n }\n}", "language": "Scala", "metadata": {"date": 1497404938, "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/s424325553.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s424325553", "user_id": "u256600337"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\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/*\n for(i <- 1 to sz) {\n for(j <- i+1 to sz) {\n val temp = intArray(j) - intArray(i)\n if(temp>ret) ret = temp\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43552}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s002436304", "group_id": "codeNet:p02258", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\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/*\n val temp = intArray(j) - intArray(i)\n if(temp>ret) ret = temp\n*/\n }\n }\n println(ret)\n }\n}", "language": "Scala", "metadata": {"date": 1497404999, "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/s002436304.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s002436304", "user_id": "u256600337"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\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/*\n val temp = intArray(j) - intArray(i)\n if(temp>ret) ret = temp\n*/\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43396}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s804581590", "group_id": "codeNet:p02258", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val sz = sc.nextInt\n val list = List.fill(sz)(sc.nextInt)\n\n val max = list.max\n val maxi = list.indexOf(max)\n val min = list.min\n val mini = list.indexOf(min)\n if(mini <= maxi) {\n println(max-min)\n return\n }\n\n var ret = Int.MinValue\n for (i <- 0 until list.length-1) {\n var maxv = Int.MinValue\n (i+1 to list.length-1).foreach( index => if(list(index)>maxv)maxv=list(index))\n val t = maxv - list(i)\n if(t>ret) ret = t\n }\n \n println(ret)\n }\n}", "language": "Scala", "metadata": {"date": 1497845635, "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/s804581590.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s804581590", "user_id": "u256600337"}, "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 sz = sc.nextInt\n val list = List.fill(sz)(sc.nextInt)\n\n val max = list.max\n val maxi = list.indexOf(max)\n val min = list.min\n val mini = list.indexOf(min)\n if(mini <= maxi) {\n println(max-min)\n return\n }\n\n var ret = Int.MinValue\n for (i <- 0 until list.length-1) {\n var maxv = Int.MinValue\n (i+1 to list.length-1).foreach( index => if(list(index)>maxv)maxv=list(index))\n val t = maxv - list(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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 622, "cpu_time_ms": 13970, "memory_kb": 51176}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s155423370", "group_id": "codeNet:p02258", "input_text": "import scala.annotation.tailrec\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val n = readLine.toInt\n val input = (1 to n map { _ => readLine.toInt }).toList\n // println(input)\n println(calMaxProf(input))\n }\n\n @tailrec def calMaxProf(input: List[Int], maxProf: Int = Int.MinValue): Int = input match {\n case head :: Nil =>\n maxProf\n case head :: tail =>\n val prof = tail.map(_ - head).max\n if (prof > maxProf) {\n calMaxProf(tail, prof)\n } else {\n calMaxProf(tail, maxProf)\n }\n case Nil =>\n maxProf\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1516879775, "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/s155423370.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s155423370", "user_id": "u921825999"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.annotation.tailrec\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val n = readLine.toInt\n val input = (1 to n map { _ => readLine.toInt }).toList\n // println(input)\n println(calMaxProf(input))\n }\n\n @tailrec def calMaxProf(input: List[Int], maxProf: Int = Int.MinValue): Int = input match {\n case head :: Nil =>\n maxProf\n case head :: tail =>\n val prof = tail.map(_ - head).max\n if (prof > maxProf) {\n calMaxProf(tail, prof)\n } else {\n calMaxProf(tail, maxProf)\n }\n case Nil =>\n maxProf\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 584, "cpu_time_ms": 950, "memory_kb": 442824}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s046788064", "group_id": "codeNet:p02258", "input_text": "import scala.annotation.tailrec\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val n = readLine.toInt\n val _input = new Array[Int](n)\n 1 to n foreach { i =>\n _input(i-1) = readLine.toInt\n }\n val input = _input.toList\n println(input)\n\n println(calMaxProf(input))\n }\n\n @tailrec def calMaxProf(input: List[Int], maxProf: Int = Int.MinValue): Int = input match {\n case head :: Nil =>\n maxProf\n case head :: tail =>\n val prof = tail.map(_ - head).max\n if (prof > maxProf) {\n calMaxProf(tail, prof)\n } else {\n calMaxProf(tail, maxProf)\n }\n case Nil =>\n maxProf\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1516880253, "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/s046788064.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s046788064", "user_id": "u921825999"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.annotation.tailrec\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val n = readLine.toInt\n val _input = new Array[Int](n)\n 1 to n foreach { i =>\n _input(i-1) = readLine.toInt\n }\n val input = _input.toList\n println(input)\n\n println(calMaxProf(input))\n }\n\n @tailrec def calMaxProf(input: List[Int], maxProf: Int = Int.MinValue): Int = input match {\n case head :: Nil =>\n maxProf\n case head :: tail =>\n val prof = tail.map(_ - head).max\n if (prof > maxProf) {\n calMaxProf(tail, prof)\n } else {\n calMaxProf(tail, maxProf)\n }\n case Nil =>\n maxProf\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 654, "cpu_time_ms": 230, "memory_kb": 43888}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s607981020", "group_id": "codeNet:p02258", "input_text": "import scala.io.Source\n\nobject Main {\n def calcMaxProfit(numbers: Seq[Int]): Int = {\n if (numbers.size == 2) {\n numbers(1) - numbers(0)\n } else {\n val maxProfit: Int = (1 to numbers.size-2)\n .map{i =>\n val as = numbers.take(i)\n val bs = numbers.drop(i)\n bs.max - as.last\n }\n .max\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)\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": 1528693979, "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/s607981020.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s607981020", "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 if (numbers.size == 2) {\n numbers(1) - numbers(0)\n } else {\n val maxProfit: Int = (1 to numbers.size-2)\n .map{i =>\n val as = numbers.take(i)\n val bs = numbers.drop(i)\n bs.max - as.last\n }\n .max\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)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 745, "cpu_time_ms": 290, "memory_kb": 50896}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s430710806", "group_id": "codeNet:p02258", "input_text": "import java.util.Scanner\n\n\n\nobject Main extends App {\n\n def read(): Array[Int] = {\n val sc: Scanner = new Scanner(System.in)\n val n = sc.nextInt\n val arr = Array.fill(n)(sc.nextInt)\n sc.close()\n arr\n }\n\n def solve() = {\n val arr = read()\n var max = Long.MinValue\n var min = arr.head\n for(i <- 1 until arr.length) {\n max = Math.max(max, arr(i)-min)\n min = Math.min(min, arr(i))\n }\n max\n }\n println(solve)\n\n}\n\n", "language": "Scala", "metadata": {"date": 1570880349, "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/s430710806.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s430710806", "user_id": "u704463122"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Scanner\n\n\n\nobject Main extends App {\n\n def read(): Array[Int] = {\n val sc: Scanner = new Scanner(System.in)\n val n = sc.nextInt\n val arr = Array.fill(n)(sc.nextInt)\n sc.close()\n arr\n }\n\n def solve() = {\n val arr = read()\n var max = Long.MinValue\n var min = arr.head\n for(i <- 1 until arr.length) {\n max = Math.max(max, arr(i)-min)\n min = Math.min(min, arr(i))\n }\n max\n }\n println(solve)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 457, "cpu_time_ms": 750, "memory_kb": 205564}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s894978819", "group_id": "codeNet:p02260", "input_text": "\nobject Main {\n def SelectionSort(A: Array[Int]):(Int,Array[Int]) = {\n var count = 0\n def swap(i: Int, j: Int){\n if(i != j){\n count += 1\n }\n val tmp = A(i)\n A(i) = A(j)\n A(j) = tmp\n }\n\n for(i <- 0 to A.length - 1){\n var mini = i\n for(j <- i + 1 to A.length - 1){\n if (A(j) < A(mini)){\n mini = j\n }\n }\n swap(i,mini)\n }\n (count,A)\n }\n\n\n def main(args: Array[String]){\n val N = readLine().map(_.toInt)\n val input = readLine().split(\" \").map(_.toInt).toArray\n val result = SelectionSort(input)\n println(result._2.mkString(\" \"))\n println(result._1)\n }\n}", "language": "Scala", "metadata": {"date": 1446336147, "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/s894978819.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s894978819", "user_id": "u274875240"}, "prompt_components": {"gold_output": "1 2 3 4 5 6\n4\n", "input_to_evaluate": "\nobject Main {\n def SelectionSort(A: Array[Int]):(Int,Array[Int]) = {\n var count = 0\n def swap(i: Int, j: Int){\n if(i != j){\n count += 1\n }\n val tmp = A(i)\n A(i) = A(j)\n A(j) = tmp\n }\n\n for(i <- 0 to A.length - 1){\n var mini = i\n for(j <- i + 1 to A.length - 1){\n if (A(j) < A(mini)){\n mini = j\n }\n }\n swap(i,mini)\n }\n (count,A)\n }\n\n\n def main(args: Array[String]){\n val N = readLine().map(_.toInt)\n val input = readLine().split(\" \").map(_.toInt).toArray\n val result = SelectionSort(input)\n println(result._2.mkString(\" \"))\n println(result._1)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 250, "memory_kb": 44004}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s352106784", "group_id": "codeNet:p02260", "input_text": "import scala.io.StdIn\nimport scala.annotation.tailrec\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 sSort(sorted :+ unsorted.min, deleteOneList(unsorted, unsorted.min), n+1)\n }\n\n def deleteOneList(list: List[Int], target: Int): List[Int] =\n list.filter(_ != target) ::: List.fill(list.filter(_ == target).length - 1)(target)\n}", "language": "Scala", "metadata": {"date": 1461945902, "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/s352106784.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s352106784", "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\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 sSort(sorted :+ unsorted.min, deleteOneList(unsorted, unsorted.min), n+1)\n }\n\n def deleteOneList(list: List[Int], target: Int): List[Int] =\n list.filter(_ != target) ::: List.fill(list.filter(_ == target).length - 1)(target)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43580}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s495897337", "group_id": "codeNet:p02260", "input_text": "import scala.io.StdIn\nimport scala.annotation.tailrec\n\nobject Main{\n def main(args: Array[String]){\n StdIn.readLine()\n val line = StdIn.readLine().split(\" \").toList.map(_.toInt)\n\n sSort(List(), line, 0)\n }\n\n @tailrec\n def sSort(sorted: List[Int], unsorted: List[Int], n: Int){\n if((sorted ::: unsorted).length == 1)\n println(unsorted.mkString(\" \") + \"\\n\" + (n+1))\n else if(unsorted.length == 1)\n println((sorted ::: unsorted).mkString(\" \") + \"\\n\" + n)\n else if(unsorted.sorted == unsorted)\n println((sorted ::: unsorted).mkString(\" \") + \"\\n\" + n)\n else if(unsorted.indexWhere(_ == unsorted.min) == 0)\n sSort(sorted :+ unsorted.head, unsorted.tail, n)\n else {\n val pos = unsorted.indexWhere(_ == unsorted.min)\n // pos??¨head???????´????swap?????????\n val swapped = unsorted.updated(0, unsorted(pos)).updated(pos, unsorted.head)\n\n sSort(sorted :+ unsorted.min, swapped.tail, n+1)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1461954239, "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/s495897337.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s495897337", "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\n\nobject Main{\n def main(args: Array[String]){\n StdIn.readLine()\n val line = StdIn.readLine().split(\" \").toList.map(_.toInt)\n\n sSort(List(), line, 0)\n }\n\n @tailrec\n def sSort(sorted: List[Int], unsorted: List[Int], n: Int){\n if((sorted ::: unsorted).length == 1)\n println(unsorted.mkString(\" \") + \"\\n\" + (n+1))\n else if(unsorted.length == 1)\n println((sorted ::: unsorted).mkString(\" \") + \"\\n\" + n)\n else if(unsorted.sorted == unsorted)\n println((sorted ::: unsorted).mkString(\" \") + \"\\n\" + n)\n else if(unsorted.indexWhere(_ == unsorted.min) == 0)\n sSort(sorted :+ unsorted.head, unsorted.tail, n)\n else {\n val pos = unsorted.indexWhere(_ == unsorted.min)\n // pos??¨head???????´????swap?????????\n val swapped = unsorted.updated(0, unsorted(pos)).updated(pos, unsorted.head)\n\n sSort(sorted :+ unsorted.min, swapped.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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 959, "cpu_time_ms": 230, "memory_kb": 43376}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s821601050", "group_id": "codeNet:p02260", "input_text": "import scala.io.StdIn\nimport scala.annotation.tailrec\n\nobject Main{\n def main(args: Array[String]){\n StdIn.readLine()\n val line = StdIn.readLine().split(\" \").toList.map(_.toInt)\n\n sSort(List(), line, 0)\n }\n\n @tailrec\n def sSort(sorted: List[Int], unsorted: List[Int], n: Int){\n if((sorted ::: unsorted).length == 1)\n println(unsorted.mkString(\" \") + \"\\n\" + n)\n else if(unsorted.sorted == unsorted)\n println((sorted ::: unsorted).mkString(\" \") + \"\\n\" + n)\n else if(unsorted.indexWhere(_ == unsorted.min) == 0)\n sSort(sorted :+ unsorted.head, unsorted.tail, n)\n else {\n val pos = unsorted.indexWhere(_ == unsorted.min)\n // pos??¨head???????´????swap?????????\n val swapped = unsorted.updated(0, unsorted(pos)).updated(pos, unsorted.head)\n\n sSort(sorted :+ unsorted.min, swapped.tail, n+1)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1461954295, "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/s821601050.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s821601050", "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\n\nobject Main{\n def main(args: Array[String]){\n StdIn.readLine()\n val line = StdIn.readLine().split(\" \").toList.map(_.toInt)\n\n sSort(List(), line, 0)\n }\n\n @tailrec\n def sSort(sorted: List[Int], unsorted: List[Int], n: Int){\n if((sorted ::: unsorted).length == 1)\n println(unsorted.mkString(\" \") + \"\\n\" + n)\n else if(unsorted.sorted == unsorted)\n println((sorted ::: unsorted).mkString(\" \") + \"\\n\" + n)\n else if(unsorted.indexWhere(_ == unsorted.min) == 0)\n sSort(sorted :+ unsorted.head, unsorted.tail, n)\n else {\n val pos = unsorted.indexWhere(_ == unsorted.min)\n // pos??¨head???????´????swap?????????\n val swapped = unsorted.updated(0, unsorted(pos)).updated(pos, unsorted.head)\n\n sSort(sorted :+ unsorted.min, swapped.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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 859, "cpu_time_ms": 380, "memory_kb": 45664}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s719310267", "group_id": "codeNet:p02264", "input_text": "import scala.io.StdIn\nimport scala.annotation.tailrec\nimport scala.collection.immutable.{Queue => EmQueue}\n\ncase class Process(name: String, time: Int){\n override def toString(): String = s\"$name $time\"\n}\n\nobject Main extends App {\n val Array(_, quantum) = StdIn.readLine().split(\" \").map(_.toInt)\n\n val queue = Iterator.continually(StdIn.readLine()).takeWhile(_ != null).foldLeft(Queue.empty) {\n (queue, line) => {\n line.split(\" \") match {\n case Array(name: String,time: String) => queue.enqueue(Process(name, time.toInt))\n }\n }\n }\n\n @tailrec\n def loop(queue: Queue, out: EmQueue[Process] = EmQueue(), curTime: Int = 0): EmQueue[Process] = {\n if(queue.isEmpty) out\n else {\n val(process, nextQueue) = queue.dequeue\n if(process.time > quantum){\n loop(nextQueue.enqueue(process.copy(time = process.time - quantum)), out, curTime + quantum)\n }else{\n loop(\n nextQueue,\n out :+ process.copy(time = curTime + process.time),\n curTime + process.time\n )\n }\n }\n }\n\n println(loop(queue).mkString(\"\\n\"))\n}\n\nclass Queue private(val in: List[Process], val out: List[Process]){\n def enqueue(elem: Process) = new Queue(elem :: in, out)\n\n def dequeue: (Process, Queue) = out match {\n case Nil if !in.isEmpty => val rev = in.reverse ; (rev.head, new Queue(Nil, rev.tail))\n case x :: xs => (x, new Queue(in, xs))\n case _ => throw new NoSuchElementException(\"dequeue on empty queue\")\n }\n\n def isEmpty: Boolean = in.isEmpty && out.isEmpty\n\n override def toString() = in.toString\n}\n\nobject Queue {\n def empty: Queue = new Queue(Nil, Nil)\n def apply(xs: Process*): Queue = new Queue(Nil, xs.toList)\n}", "language": "Scala", "metadata": {"date": 1462029067, "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/s719310267.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s719310267", "user_id": "u389172382"}, "prompt_components": {"gold_output": "p2 180\np5 400\np1 450\np3 550\np4 800\n", "input_to_evaluate": "import scala.io.StdIn\nimport scala.annotation.tailrec\nimport scala.collection.immutable.{Queue => EmQueue}\n\ncase class Process(name: String, time: Int){\n override def toString(): String = s\"$name $time\"\n}\n\nobject Main extends App {\n val Array(_, quantum) = StdIn.readLine().split(\" \").map(_.toInt)\n\n val queue = Iterator.continually(StdIn.readLine()).takeWhile(_ != null).foldLeft(Queue.empty) {\n (queue, line) => {\n line.split(\" \") match {\n case Array(name: String,time: String) => queue.enqueue(Process(name, time.toInt))\n }\n }\n }\n\n @tailrec\n def loop(queue: Queue, out: EmQueue[Process] = EmQueue(), curTime: Int = 0): EmQueue[Process] = {\n if(queue.isEmpty) out\n else {\n val(process, nextQueue) = queue.dequeue\n if(process.time > quantum){\n loop(nextQueue.enqueue(process.copy(time = process.time - quantum)), out, curTime + quantum)\n }else{\n loop(\n nextQueue,\n out :+ process.copy(time = curTime + process.time),\n curTime + process.time\n )\n }\n }\n }\n\n println(loop(queue).mkString(\"\\n\"))\n}\n\nclass Queue private(val in: List[Process], val out: List[Process]){\n def enqueue(elem: Process) = new Queue(elem :: in, out)\n\n def dequeue: (Process, Queue) = out match {\n case Nil if !in.isEmpty => val rev = in.reverse ; (rev.head, new Queue(Nil, rev.tail))\n case x :: xs => (x, new Queue(in, xs))\n case _ => throw new NoSuchElementException(\"dequeue on empty queue\")\n }\n\n def isEmpty: Boolean = in.isEmpty && out.isEmpty\n\n override def toString() = in.toString\n}\n\nobject Queue {\n def empty: Queue = new Queue(Nil, Nil)\n def apply(xs: Process*): Queue = new Queue(Nil, xs.toList)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1729, "cpu_time_ms": 790, "memory_kb": 149724}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s207704406", "group_id": "codeNet:p02264", "input_text": "import scala.io.StdIn.readLine\ncase class Queue[T](in: List[T], out: List[T]) {\n def isEmpty(): Boolean = if (in.isEmpty && out.isEmpty) true else false\n def head(): T = out match {\n case x :: xs => x\n case _ => throw new RuntimeException(\"error...\")\n }\n def enque(e: T): Queue[T] = {\n val newIn = e :: in\n new Queue[T](newIn, newIn.reverse)\n }\n def deque(): Queue[T] = out match {\n case x :: xs => new Queue[T](xs.reverse, xs)\n case _ => throw new RuntimeException(\"error...\")\n }\n}\nobject Queue {\n def apply[T](): Queue[T] = new Queue[T](Nil, Nil)\n}\ncase class Proc(name: String, time: Int) {\n def exec(t: Int): (Proc, Int) = {\n if (time - t < 0) (new Proc(name, 0), time)\n else (new Proc(name, time - t), t)\n }\n def finished(): Boolean = if (time == 0) true else false\n}\nobject Main {\n def main(args: Array[String]): Unit = {\n val line = readLine.split(\" \").map(_.toInt)\n val procNum = line(0)\n val quantum = line(1)\n val que: Queue[Proc] = (1 to procNum).foldLeft(Queue[Proc]()) { (que, a) => \n val p = readLine.split(\" \")\n que.enque(new Proc(p(0), p(1).toInt))\n }\n println(process(que, quantum).mkString(\"\\n\"))\n }\n \n def process(que: Queue[Proc], quantum: Int): List[String] = {\n def go(que: Queue[Proc], total: Int, result: List[String]): List[String] = que match {\n case que if que.isEmpty => result\n case que => que.head.exec(quantum) match {\n case (pProc, time) if pProc.finished => go(que.deque, total + time, s\"${pProc.name} ${total + time}\" :: result)\n case (pProc, time) => go(que.deque.enque(pProc), total + time, result)\n }\n }\n go(que, 0, Nil).reverse\n }\n}\n", "language": "Scala", "metadata": {"date": 1515479260, "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/s207704406.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s207704406", "user_id": "u909989059"}, "prompt_components": {"gold_output": "p2 180\np5 400\np1 450\np3 550\np4 800\n", "input_to_evaluate": "import scala.io.StdIn.readLine\ncase class Queue[T](in: List[T], out: List[T]) {\n def isEmpty(): Boolean = if (in.isEmpty && out.isEmpty) true else false\n def head(): T = out match {\n case x :: xs => x\n case _ => throw new RuntimeException(\"error...\")\n }\n def enque(e: T): Queue[T] = {\n val newIn = e :: in\n new Queue[T](newIn, newIn.reverse)\n }\n def deque(): Queue[T] = out match {\n case x :: xs => new Queue[T](xs.reverse, xs)\n case _ => throw new RuntimeException(\"error...\")\n }\n}\nobject Queue {\n def apply[T](): Queue[T] = new Queue[T](Nil, Nil)\n}\ncase class Proc(name: String, time: Int) {\n def exec(t: Int): (Proc, Int) = {\n if (time - t < 0) (new Proc(name, 0), time)\n else (new Proc(name, time - t), t)\n }\n def finished(): Boolean = if (time == 0) true else false\n}\nobject Main {\n def main(args: Array[String]): Unit = {\n val line = readLine.split(\" \").map(_.toInt)\n val procNum = line(0)\n val quantum = line(1)\n val que: Queue[Proc] = (1 to procNum).foldLeft(Queue[Proc]()) { (que, a) => \n val p = readLine.split(\" \")\n que.enque(new Proc(p(0), p(1).toInt))\n }\n println(process(que, quantum).mkString(\"\\n\"))\n }\n \n def process(que: Queue[Proc], quantum: Int): List[String] = {\n def go(que: Queue[Proc], total: Int, result: List[String]): List[String] = que match {\n case que if que.isEmpty => result\n case que => que.head.exec(quantum) match {\n case (pProc, time) if pProc.finished => go(que.deque, total + time, s\"${pProc.name} ${total + time}\" :: result)\n case (pProc, time) => go(que.deque.enque(pProc), total + time, result)\n }\n }\n go(que, 0, Nil).reverse\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 640, "memory_kb": 437504}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s622487816", "group_id": "codeNet:p02268", "input_text": "import scala.io.StdIn._\nimport scala.annotation.tailrec\n\nobject Main {\n\n //f(x) => (-1,0,1)\n @tailrec\n def binarySearch(f: Int => Int,l: Int, r: Int): Int = {\n if(r-l<=1)f(l)\n else if(f((l+r)/2) < 1)binarySearch(f,(l+r)/2,r)\n else binarySearch(f,l,(l+r)/2)\n }\n\n def main(args: Array[String]): Unit = {\n val n = readInt\n val list = readLine.split(\" \").map(_.toInt).toList\n\n val f = (ar: List[Int]) => (a: Int) => (x: Int) => ar(x)-a\n\n val q = readInt\n val qlist = readLine.split(\" \").map(_.toInt)\n\n val res = for(e <- qlist)yield(0 == binarySearch(f(list)(e),0,n))\n println(res.toList.map(if(_) 1 else 0).sum)\n }\n}", "language": "Scala", "metadata": {"date": 1435982589, "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/s622487816.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s622487816", "user_id": "u047988051"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.io.StdIn._\nimport scala.annotation.tailrec\n\nobject Main {\n\n //f(x) => (-1,0,1)\n @tailrec\n def binarySearch(f: Int => Int,l: Int, r: Int): Int = {\n if(r-l<=1)f(l)\n else if(f((l+r)/2) < 1)binarySearch(f,(l+r)/2,r)\n else binarySearch(f,l,(l+r)/2)\n }\n\n def main(args: Array[String]): Unit = {\n val n = readInt\n val list = readLine.split(\" \").map(_.toInt).toList\n\n val f = (ar: List[Int]) => (a: Int) => (x: Int) => ar(x)-a\n\n val q = readInt\n val qlist = readLine.split(\" \").map(_.toInt)\n\n val res = for(e <- qlist)yield(0 == binarySearch(f(list)(e),0,n))\n println(res.toList.map(if(_) 1 else 0).sum)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 649, "cpu_time_ms": 400, "memory_kb": 49196}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s541993244", "group_id": "codeNet:p02268", "input_text": "import scala.io.StdIn._\nimport scala.annotation.tailrec\n\nobject Main {\n\n val f = (ar: List[Int]) => (a: Int) => (x: Int) => ar(x)-a\n\n //f(x) => (-1,0,1)\n @tailrec\n def binarySearch(f: Int => Int,l: Int, r: Int): Int = {\n if(r-l<=1)f(l)\n else if(f((l+r)/2) < 1)binarySearch(f,(l+r)/2,r)\n else binarySearch(f,l,(l+r)/2)\n }\n\n def loop(n: Int,in: Int, q: Int, cnt:Int,f: Int => Int => Int):Int = {\n if(q==0)cnt\n else loop(n,readInt,q-1,cnt+(if(0==binarySearch(f(in),0,n)) 1 else 0),f )\n }\n\n def main(args: Array[String]): Unit = {\n val n = readInt\n val list = readLine.split(\" \").map(_.toInt).toList\n\n val q = readInt\n val qlist = readLine.split(\" \").map(_.toInt)\n var res:Int = 0\n for(e <- qlist)res=res+(if(0 == binarySearch(f(list)(e),0,n)) 1 else 0)\n println(res)\n //val res = for(e <- qlist)yield(0 == binarySearch(f(list)(e),0,n))\n //println(res.toList.map(if(_) 1 else 0).sum)\n //println(loop(n,readInt,q,0,f(list)))\n }\n}", "language": "Scala", "metadata": {"date": 1435983472, "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/s541993244.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s541993244", "user_id": "u047988051"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.io.StdIn._\nimport scala.annotation.tailrec\n\nobject Main {\n\n val f = (ar: List[Int]) => (a: Int) => (x: Int) => ar(x)-a\n\n //f(x) => (-1,0,1)\n @tailrec\n def binarySearch(f: Int => Int,l: Int, r: Int): Int = {\n if(r-l<=1)f(l)\n else if(f((l+r)/2) < 1)binarySearch(f,(l+r)/2,r)\n else binarySearch(f,l,(l+r)/2)\n }\n\n def loop(n: Int,in: Int, q: Int, cnt:Int,f: Int => Int => Int):Int = {\n if(q==0)cnt\n else loop(n,readInt,q-1,cnt+(if(0==binarySearch(f(in),0,n)) 1 else 0),f )\n }\n\n def main(args: Array[String]): Unit = {\n val n = readInt\n val list = readLine.split(\" \").map(_.toInt).toList\n\n val q = readInt\n val qlist = readLine.split(\" \").map(_.toInt)\n var res:Int = 0\n for(e <- qlist)res=res+(if(0 == binarySearch(f(list)(e),0,n)) 1 else 0)\n println(res)\n //val res = for(e <- qlist)yield(0 == binarySearch(f(list)(e),0,n))\n //println(res.toList.map(if(_) 1 else 0).sum)\n //println(loop(n,readInt,q,0,f(list)))\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 978, "cpu_time_ms": 470, "memory_kb": 48168}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s215385016", "group_id": "codeNet:p02268", "input_text": "import scala.io.StdIn.readLine\n \nobject Main {\n def search(a:Array[Int],len:Int,value:Int) = {\n def scan(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 if(a(mid) search(s,len,i) ))\n }\n}", "language": "Scala", "metadata": {"date": 1489238066, "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/s215385016.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s215385016", "user_id": "u508732591"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n \nobject Main {\n def search(a:Array[Int],len:Int,value:Int) = {\n def scan(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 if(a(mid) search(s,len,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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 430, "memory_kb": 71048}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s734377924", "group_id": "codeNet:p02268", "input_text": "import scala.io.StdIn\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val n = StdIn.readLine.toInt\n val S = StdIn.readLine.split(' ').map(_.toInt)\n val q = StdIn.readLine.toInt\n val T = StdIn.readLine.split(' ').map(_.toInt)\n val C = new Array[Int](100000)\n var len = 0\n\n val res = T filter { m => binSearch(S, n, m) }\n println(res.mkString(\" \"))\n }\n\n def binSearch(S: Array[Int], len: Int, i: Int): Boolean = {\n var l = 0\n var r = len\n while (l < r) {\n val indice = (r + l) / 2\n if (S(indice) < i) {\n r = indice\n } else if (S(indice) > i) {\n l = indice + 1\n } else {\n return true\n }\n }\n false\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1518694274, "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/s734377924.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s734377924", "user_id": "u921825999"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val n = StdIn.readLine.toInt\n val S = StdIn.readLine.split(' ').map(_.toInt)\n val q = StdIn.readLine.toInt\n val T = StdIn.readLine.split(' ').map(_.toInt)\n val C = new Array[Int](100000)\n var len = 0\n\n val res = T filter { m => binSearch(S, n, m) }\n println(res.mkString(\" \"))\n }\n\n def binSearch(S: Array[Int], len: Int, i: Int): Boolean = {\n var l = 0\n var r = len\n while (l < r) {\n val indice = (r + l) / 2\n if (S(indice) < i) {\n r = indice\n } else if (S(indice) > i) {\n l = indice + 1\n } else {\n return true\n }\n }\n false\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 698, "cpu_time_ms": 230, "memory_kb": 44264}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s714571565", "group_id": "codeNet:p02271", "input_text": "object Main extends App {\n\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt \n val a = List.fill(n)(sc.nextInt) \n val q = sc.nextInt \n val m = List.fill(q)(sc.nextInt)\n \n def solve(i: Int, m: Int): Boolean = if(m == 0) true\n else if(i >= n) false\n else solve(i+1, m) || solve(i+1, m - a(i))\n \n val result = m.map(p => if(solve(0, p)) \"yes\" else \"no\")\n\n print(result.mkString(f\"%n\"))\n\n}\n", "language": "Scala", "metadata": {"date": 1522445191, "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/s714571565.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s714571565", "user_id": "u342234782"}, "prompt_components": {"gold_output": "no\nno\nyes\nyes\nyes\nyes\nno\nno\n", "input_to_evaluate": "object Main extends App {\n\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt \n val a = List.fill(n)(sc.nextInt) \n val q = sc.nextInt \n val m = List.fill(q)(sc.nextInt)\n \n def solve(i: Int, m: Int): Boolean = if(m == 0) true\n else if(i >= n) false\n else solve(i+1, m) || solve(i+1, m - a(i))\n \n val result = m.map(p => if(solve(0, p)) \"yes\" else \"no\")\n\n print(result.mkString(f\"%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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 415, "cpu_time_ms": 240, "memory_kb": 45068}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s039495375", "group_id": "codeNet:p02271", "input_text": "object Main extends App {\n\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt \n val a = List.fill(n)(sc.nextInt) \n val q = sc.nextInt \n val m = List.fill(q)(sc.nextInt)\n \n def solve(i: Int, m: Int): Boolean = if(m == 0) true\n else if(i >= n) false\n else solve(i+1, m) || solve(i+1, m - a(i))\n \n val result = m.map(p => if(solve(0, p)) \"yes\" else \"no\")\n\n print(result.mkString(f\"%n\") + f\"%n\")\n\n}\n\n", "language": "Scala", "metadata": {"date": 1522445255, "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/s039495375.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s039495375", "user_id": "u342234782"}, "prompt_components": {"gold_output": "no\nno\nyes\nyes\nyes\nyes\nno\nno\n", "input_to_evaluate": "object Main extends App {\n\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt \n val a = List.fill(n)(sc.nextInt) \n val q = sc.nextInt \n val m = List.fill(q)(sc.nextInt)\n \n def solve(i: Int, m: Int): Boolean = if(m == 0) true\n else if(i >= n) false\n else solve(i+1, m) || solve(i+1, m - a(i))\n \n val result = m.map(p => if(solve(0, p)) \"yes\" else \"no\")\n\n print(result.mkString(f\"%n\") + f\"%n\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 424, "cpu_time_ms": 2300, "memory_kb": 45772}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s587926821", "group_id": "codeNet:p02272", "input_text": "import scala.io.StdIn.{readLine,readInt}\nimport scala.language.postfixOps\n\nobject Main {\n var cnt = 0\n val l = new Array[Int](250001)\n val r = new Array[Int](250001)\n\n def merge(a:Array[Int],left:Int,mid:Int,right:Int) = {\n 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 getSortIndex(n:Int):Iterator[IndexedSeq[(Int,Int)]] = {\n var w = n\n var h = 0\n while(w>1) {\n h += 1\n w /= 2\n }\n\n def scan(h:Int,l:List[IndexedSeq[(Int,Int)]]):List[IndexedSeq[(Int,Int)]] = {\n if(h==0) l\n else\n scan(h-1,(for(i<-l.head;j<-List((i._1,(i._2+i._1)/2),((i._2+i._1)/2,i._2))) yield j)::l)\n }\n scan(h-1,List(IndexedSeq((0,n/2),(n/2,n)))).to[Iterator]\n }\n\n def main(args:Array[String]) = {\n val n = readInt\n val l = getSortIndex(n)\n val a = readLine.split(\" \").map(_.toInt)\n\n for(e2<-l) {\n for(e<-e2) {\n val mid = (e._2+e._1)/2\n if(e._2-e._1>1)\n merge(a,e._1,mid,e._2)\n }\n }\n merge(a,0,n/2,n)\n println(a.mkString(\" \"))\n println(cnt)\n }\n}", "language": "Scala", "metadata": {"date": 1490450079, "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/s587926821.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s587926821", "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.language.postfixOps\n\nobject Main {\n var cnt = 0\n val l = new Array[Int](250001)\n val r = new Array[Int](250001)\n\n def merge(a:Array[Int],left:Int,mid:Int,right:Int) = {\n 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 getSortIndex(n:Int):Iterator[IndexedSeq[(Int,Int)]] = {\n var w = n\n var h = 0\n while(w>1) {\n h += 1\n w /= 2\n }\n\n def scan(h:Int,l:List[IndexedSeq[(Int,Int)]]):List[IndexedSeq[(Int,Int)]] = {\n if(h==0) l\n else\n scan(h-1,(for(i<-l.head;j<-List((i._1,(i._2+i._1)/2),((i._2+i._1)/2,i._2))) yield j)::l)\n }\n scan(h-1,List(IndexedSeq((0,n/2),(n/2,n)))).to[Iterator]\n }\n\n def main(args:Array[String]) = {\n val n = readInt\n val l = getSortIndex(n)\n val a = readLine.split(\" \").map(_.toInt)\n\n for(e2<-l) {\n for(e<-e2) {\n val mid = (e._2+e._1)/2\n if(e._2-e._1>1)\n merge(a,e._1,mid,e._2)\n }\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1335, "cpu_time_ms": 940, "memory_kb": 314864}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s997658717", "group_id": "codeNet:p02272", "input_text": "import scala.io.StdIn.{readLine,readInt}\nimport scala.language.postfixOps\n\nobject Main {\n var cnt = 0\n val l = new Array[Int](250001)\n val r = new Array[Int](250001)\n var a:Array[Int] = null\n\n def merge(left:Int,mid:Int,right:Int) = {\n 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 getSortIndex(n:Int):Iterator[IndexedSeq[(Int,Int)]] = {\n var w = n\n var h = 0\n while(w>1) {\n h += 1\n w /= 2\n }\n\n def scan(h:Int,l:List[IndexedSeq[(Int,Int)]]):List[IndexedSeq[(Int,Int)]] = {\n if(h==0) l\n else\n scan(h-1,(for(i<-l.head;j<-List((i._1,(i._2+i._1)/2),((i._2+i._1)/2,i._2))) yield j)::l)\n }\n scan(h-1,List(IndexedSeq((0,n/2),(n/2,n)))).to[Iterator]\n }\n\n def main(args:Array[String]) = {\n val n = readInt\n a = readLine.split(\" \").map(_.toInt)\n val l = getSortIndex(n)\n for(e2<-l) {\n for(e<-e2) {\n val mid = (e._2+e._1)/2\n if(e._2-e._1>1)\n merge(e._1,mid,e._2)\n }\n }\n merge(0,n/2,n)\n println(a.mkString(\" \"))\n println(cnt)\n }\n}", "language": "Scala", "metadata": {"date": 1490450313, "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/s997658717.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s997658717", "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.language.postfixOps\n\nobject Main {\n var cnt = 0\n val l = new Array[Int](250001)\n val r = new Array[Int](250001)\n var a:Array[Int] = null\n\n def merge(left:Int,mid:Int,right:Int) = {\n 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 getSortIndex(n:Int):Iterator[IndexedSeq[(Int,Int)]] = {\n var w = n\n var h = 0\n while(w>1) {\n h += 1\n w /= 2\n }\n\n def scan(h:Int,l:List[IndexedSeq[(Int,Int)]]):List[IndexedSeq[(Int,Int)]] = {\n if(h==0) l\n else\n scan(h-1,(for(i<-l.head;j<-List((i._1,(i._2+i._1)/2),((i._2+i._1)/2,i._2))) yield j)::l)\n }\n scan(h-1,List(IndexedSeq((0,n/2),(n/2,n)))).to[Iterator]\n }\n\n def main(args:Array[String]) = {\n val n = readInt\n a = readLine.split(\" \").map(_.toInt)\n val l = getSortIndex(n)\n for(e2<-l) {\n for(e<-e2) {\n val mid = (e._2+e._1)/2\n if(e._2-e._1>1)\n merge(e._1,mid,e._2)\n }\n }\n merge(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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1339, "cpu_time_ms": 950, "memory_kb": 319876}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s903638599", "group_id": "codeNet:p02273", "input_text": "import scala.math.BigDecimal\nimport scala.math.BigDecimal.RoundingMode\nimport scala.io.StdIn.readInt\nobject Main {\n def main(args: Array[String]): Unit = {\n koch(new Point(0.0, 0.0), 0, 100, readInt)\n }\n def koch(point: Point, angle: Int, len: Double, count: Int): Point = {\n if (count == 0) {\n val p = point.add(len * cos(angle), len * sin(angle))\n println(p)\n p\n } else {\n val nextLen = len / 3.0\n List(0, 60, 300, 360).foldLeft(point) { (p, a) =>\n koch(p, angle + a, nextLen, count - 1)\n }\n }\n }\n def cos(angle: Int) = Math.cos(Math.toRadians(angle % 360))\n def sin(angle: Int) = Math.sin(Math.toRadians(angle % 360))\n}\ncase class Point(x: Double, y: Double) {\n override def toString(): String = {\n val a = \"%.8f\".format(BigDecimal(x).setScale(8, RoundingMode.HALF_UP))\n val b = \"%.8f\".format(BigDecimal(y).setScale(8, RoundingMode.HALF_UP))\n a + \" \" + b\n }\n def add(xx: Double, yy: Double): Point = new Point(x + xx, y + yy)\n}\n", "language": "Scala", "metadata": {"date": 1516254243, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02273.html", "problem_id": "p02273", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02273/input.txt", "sample_output_relpath": "derived/input_output/data/p02273/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02273/Scala/s903638599.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s903638599", "user_id": "u909989059"}, "prompt_components": {"gold_output": "0.00000000 0.00000000\n33.33333333 0.00000000\n50.00000000 28.86751346\n66.66666667 0.00000000\n100.00000000 0.00000000\n", "input_to_evaluate": "import scala.math.BigDecimal\nimport scala.math.BigDecimal.RoundingMode\nimport scala.io.StdIn.readInt\nobject Main {\n def main(args: Array[String]): Unit = {\n koch(new Point(0.0, 0.0), 0, 100, readInt)\n }\n def koch(point: Point, angle: Int, len: Double, count: Int): Point = {\n if (count == 0) {\n val p = point.add(len * cos(angle), len * sin(angle))\n println(p)\n p\n } else {\n val nextLen = len / 3.0\n List(0, 60, 300, 360).foldLeft(point) { (p, a) =>\n koch(p, angle + a, nextLen, count - 1)\n }\n }\n }\n def cos(angle: Int) = Math.cos(Math.toRadians(angle % 360))\n def sin(angle: Int) = Math.sin(Math.toRadians(angle % 360))\n}\ncase class Point(x: Double, y: Double) {\n override def toString(): String = {\n val a = \"%.8f\".format(BigDecimal(x).setScale(8, RoundingMode.HALF_UP))\n val b = \"%.8f\".format(BigDecimal(y).setScale(8, RoundingMode.HALF_UP))\n a + \" \" + b\n }\n def add(xx: Double, yy: Double): Point = new Point(x + xx, y + yy)\n}\n", "problem_context": "Koch Curve\n\nWrite a program which reads an integer n and draws a Koch curve based on recursive calles of depth n.\n\nThe Koch curve is well known as a kind of fractals.\n\nYou can draw a Koch curve in the following algorithm:\n\nDivide a given segment (p1, p2) into three equal segments.\n\nReplace the middle segment by the two sides of an equilateral triangle (s, u, t) of the same length as the segment.\n\nRepeat this procedure recursively for new segments (p1, s), (s, u), (u, t), (t, p2).\n\nYou should start (0, 0), (100, 0) as the first segment.\n\nInput\n\nAn integer n is given.\n\nOutput\n\nPrint each point (x, y) of the Koch curve. Print a point in a line. You should start the point(0, 0), which is the endpoint of the first segment and end with the point (100, 0), the other endpoint so that you can draw the Koch curve as an unbroken line. Each solution should be given as a decimal with an arbitrary number of fractional digits, and with an absolute error of at most 10-4.\n\nConstraints\n\n0 ≤ n ≤ 6\n\nSample Input 1\n\n1\n\nSample Output 1\n\n0.00000000 0.00000000\n33.33333333 0.00000000\n50.00000000 28.86751346\n66.66666667 0.00000000\n100.00000000 0.00000000\n\nSample Input 2\n\n2\n\nSample Output 2\n\n0.00000000 0.00000000\n11.11111111 0.00000000\n16.66666667 9.62250449\n22.22222222 0.00000000\n33.33333333 0.00000000\n38.88888889 9.62250449\n33.33333333 19.24500897\n44.44444444 19.24500897\n50.00000000 28.86751346\n55.55555556 19.24500897\n66.66666667 19.24500897\n61.11111111 9.62250449\n66.66666667 0.00000000\n77.77777778 0.00000000\n83.33333333 9.62250449\n88.88888889 0.00000000\n100.00000000 0.00000000\n\nNotes", "sample_input": "1\n"}, "reference_outputs": ["0.00000000 0.00000000\n33.33333333 0.00000000\n50.00000000 28.86751346\n66.66666667 0.00000000\n100.00000000 0.00000000\n"], "source_document_id": "p02273", "source_text": "Koch Curve\n\nWrite a program which reads an integer n and draws a Koch curve based on recursive calles of depth n.\n\nThe Koch curve is well known as a kind of fractals.\n\nYou can draw a Koch curve in the following algorithm:\n\nDivide a given segment (p1, p2) into three equal segments.\n\nReplace the middle segment by the two sides of an equilateral triangle (s, u, t) of the same length as the segment.\n\nRepeat this procedure recursively for new segments (p1, s), (s, u), (u, t), (t, p2).\n\nYou should start (0, 0), (100, 0) as the first segment.\n\nInput\n\nAn integer n is given.\n\nOutput\n\nPrint each point (x, y) of the Koch curve. Print a point in a line. You should start the point(0, 0), which is the endpoint of the first segment and end with the point (100, 0), the other endpoint so that you can draw the Koch curve as an unbroken line. Each solution should be given as a decimal with an arbitrary number of fractional digits, and with an absolute error of at most 10-4.\n\nConstraints\n\n0 ≤ n ≤ 6\n\nSample Input 1\n\n1\n\nSample Output 1\n\n0.00000000 0.00000000\n33.33333333 0.00000000\n50.00000000 28.86751346\n66.66666667 0.00000000\n100.00000000 0.00000000\n\nSample Input 2\n\n2\n\nSample Output 2\n\n0.00000000 0.00000000\n11.11111111 0.00000000\n16.66666667 9.62250449\n22.22222222 0.00000000\n33.33333333 0.00000000\n38.88888889 9.62250449\n33.33333333 19.24500897\n44.44444444 19.24500897\n50.00000000 28.86751346\n55.55555556 19.24500897\n66.66666667 19.24500897\n61.11111111 9.62250449\n66.66666667 0.00000000\n77.77777778 0.00000000\n83.33333333 9.62250449\n88.88888889 0.00000000\n100.00000000 0.00000000\n\nNotes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1088, "cpu_time_ms": 230, "memory_kb": 44144}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s181190983", "group_id": "codeNet:p02273", "input_text": "import scala.io.StdIn\nimport scala.collection.mutable.ArrayBuffer\n\n/*\n ret\n http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2232735#1\n */\nobject Main {\n class Point(val x: Double, val y: Double){\n override def toString: String = {\n f\"$x%.8f $y%.8f\"\n }\n }\n \n final val start = new Point(0, 0)\n final val end = new Point(100, 0)\n final val th = scala.math.Pi * 60.0 / 180.0\n final val cos = math.cos(th)\n final val sin = math.sin(th)\n\n\n @inline def calcuPoint(p1: Point, p2: Point, a: Double, b: Double) = new Point((a*p1.x+b*p2.x)/3.0, (a*p1.y+b*p2.y)/3.0)\n \n \n def koch(d: Double, p1: Point, p2: Point, ret: ArrayBuffer[Point]): Unit = {\n if(d != 0){\n val s = calcuPoint(p1, p2, 2.0, 1.0)\n val t = calcuPoint(p1, p2, 1.0, 2.0)\n val tsx = t.x - s.x\n val tsy = t.y - s.y\n val u = new Point(tsx*cos - tsy*sin + s.x,\n tsx*sin + tsy*cos + s.y)\n \n koch(d-1, p1, s, ret)\n // println(s)\n ret += s\n \n koch(d-1, s, u, ret)\n //println(u)\n ret += u\n \n koch(d-1, u, t, ret)\n // println(t)\n ret += t\n\n koch(d-1, t, p2, ret)\n\n }\n }\n \n def main(args:Array[String]) = {\n var result = ArrayBuffer.empty[Point]\n val n = StdIn.readLine().trim.toInt\n\n //println(start)\n result += start\n koch(n, start, end, result)\n result += end\n\n //result.foreach(println)\n println(result.mkString(f\"%n\"))\n \n }\n \n}\n", "language": "Scala", "metadata": {"date": 1522542568, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02273.html", "problem_id": "p02273", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02273/input.txt", "sample_output_relpath": "derived/input_output/data/p02273/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02273/Scala/s181190983.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s181190983", "user_id": "u342234782"}, "prompt_components": {"gold_output": "0.00000000 0.00000000\n33.33333333 0.00000000\n50.00000000 28.86751346\n66.66666667 0.00000000\n100.00000000 0.00000000\n", "input_to_evaluate": "import scala.io.StdIn\nimport scala.collection.mutable.ArrayBuffer\n\n/*\n ret\n http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2232735#1\n */\nobject Main {\n class Point(val x: Double, val y: Double){\n override def toString: String = {\n f\"$x%.8f $y%.8f\"\n }\n }\n \n final val start = new Point(0, 0)\n final val end = new Point(100, 0)\n final val th = scala.math.Pi * 60.0 / 180.0\n final val cos = math.cos(th)\n final val sin = math.sin(th)\n\n\n @inline def calcuPoint(p1: Point, p2: Point, a: Double, b: Double) = new Point((a*p1.x+b*p2.x)/3.0, (a*p1.y+b*p2.y)/3.0)\n \n \n def koch(d: Double, p1: Point, p2: Point, ret: ArrayBuffer[Point]): Unit = {\n if(d != 0){\n val s = calcuPoint(p1, p2, 2.0, 1.0)\n val t = calcuPoint(p1, p2, 1.0, 2.0)\n val tsx = t.x - s.x\n val tsy = t.y - s.y\n val u = new Point(tsx*cos - tsy*sin + s.x,\n tsx*sin + tsy*cos + s.y)\n \n koch(d-1, p1, s, ret)\n // println(s)\n ret += s\n \n koch(d-1, s, u, ret)\n //println(u)\n ret += u\n \n koch(d-1, u, t, ret)\n // println(t)\n ret += t\n\n koch(d-1, t, p2, ret)\n\n }\n }\n \n def main(args:Array[String]) = {\n var result = ArrayBuffer.empty[Point]\n val n = StdIn.readLine().trim.toInt\n\n //println(start)\n result += start\n koch(n, start, end, result)\n result += end\n\n //result.foreach(println)\n println(result.mkString(f\"%n\"))\n \n }\n \n}\n", "problem_context": "Koch Curve\n\nWrite a program which reads an integer n and draws a Koch curve based on recursive calles of depth n.\n\nThe Koch curve is well known as a kind of fractals.\n\nYou can draw a Koch curve in the following algorithm:\n\nDivide a given segment (p1, p2) into three equal segments.\n\nReplace the middle segment by the two sides of an equilateral triangle (s, u, t) of the same length as the segment.\n\nRepeat this procedure recursively for new segments (p1, s), (s, u), (u, t), (t, p2).\n\nYou should start (0, 0), (100, 0) as the first segment.\n\nInput\n\nAn integer n is given.\n\nOutput\n\nPrint each point (x, y) of the Koch curve. Print a point in a line. You should start the point(0, 0), which is the endpoint of the first segment and end with the point (100, 0), the other endpoint so that you can draw the Koch curve as an unbroken line. Each solution should be given as a decimal with an arbitrary number of fractional digits, and with an absolute error of at most 10-4.\n\nConstraints\n\n0 ≤ n ≤ 6\n\nSample Input 1\n\n1\n\nSample Output 1\n\n0.00000000 0.00000000\n33.33333333 0.00000000\n50.00000000 28.86751346\n66.66666667 0.00000000\n100.00000000 0.00000000\n\nSample Input 2\n\n2\n\nSample Output 2\n\n0.00000000 0.00000000\n11.11111111 0.00000000\n16.66666667 9.62250449\n22.22222222 0.00000000\n33.33333333 0.00000000\n38.88888889 9.62250449\n33.33333333 19.24500897\n44.44444444 19.24500897\n50.00000000 28.86751346\n55.55555556 19.24500897\n66.66666667 19.24500897\n61.11111111 9.62250449\n66.66666667 0.00000000\n77.77777778 0.00000000\n83.33333333 9.62250449\n88.88888889 0.00000000\n100.00000000 0.00000000\n\nNotes", "sample_input": "1\n"}, "reference_outputs": ["0.00000000 0.00000000\n33.33333333 0.00000000\n50.00000000 28.86751346\n66.66666667 0.00000000\n100.00000000 0.00000000\n"], "source_document_id": "p02273", "source_text": "Koch Curve\n\nWrite a program which reads an integer n and draws a Koch curve based on recursive calles of depth n.\n\nThe Koch curve is well known as a kind of fractals.\n\nYou can draw a Koch curve in the following algorithm:\n\nDivide a given segment (p1, p2) into three equal segments.\n\nReplace the middle segment by the two sides of an equilateral triangle (s, u, t) of the same length as the segment.\n\nRepeat this procedure recursively for new segments (p1, s), (s, u), (u, t), (t, p2).\n\nYou should start (0, 0), (100, 0) as the first segment.\n\nInput\n\nAn integer n is given.\n\nOutput\n\nPrint each point (x, y) of the Koch curve. Print a point in a line. You should start the point(0, 0), which is the endpoint of the first segment and end with the point (100, 0), the other endpoint so that you can draw the Koch curve as an unbroken line. Each solution should be given as a decimal with an arbitrary number of fractional digits, and with an absolute error of at most 10-4.\n\nConstraints\n\n0 ≤ n ≤ 6\n\nSample Input 1\n\n1\n\nSample Output 1\n\n0.00000000 0.00000000\n33.33333333 0.00000000\n50.00000000 28.86751346\n66.66666667 0.00000000\n100.00000000 0.00000000\n\nSample Input 2\n\n2\n\nSample Output 2\n\n0.00000000 0.00000000\n11.11111111 0.00000000\n16.66666667 9.62250449\n22.22222222 0.00000000\n33.33333333 0.00000000\n38.88888889 9.62250449\n33.33333333 19.24500897\n44.44444444 19.24500897\n50.00000000 28.86751346\n55.55555556 19.24500897\n66.66666667 19.24500897\n61.11111111 9.62250449\n66.66666667 0.00000000\n77.77777778 0.00000000\n83.33333333 9.62250449\n88.88888889 0.00000000\n100.00000000 0.00000000\n\nNotes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 440, "memory_kb": 59216}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s995405480", "group_id": "codeNet:p02274", "input_text": "import scala.io.StdIn.{readLine,readInt}\nimport scala.language.postfixOps\n\nobject Main {\n var cnt = 0\n val l = new Array[Int](100002)\n val r = new Array[Int](100002)\n\n def merge(a:Array[Int],left:Int,mid:Int,right:Int) = {\n 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 cnt = cnt+n1-i\n j += 1\n }\n }\n }\n\n def scan(h:Int,l:List[IndexedSeq[(Int,Int)]]):List[IndexedSeq[(Int,Int)]] =\n if(h==0) l\n else scan(h-1,(for(i<-l.head;j<-List((i._1,(i._2+i._1)/2),((i._2+i._1)/2,i._2))) yield j)::l)\n\n def getSortIndex(n:Int):Iterator[IndexedSeq[(Int,Int)]] = {\n var w = n\n var h = 0\n while(w>1) {\n h += 1; w /= 2\n }\n scan(h-1,List(IndexedSeq((0,n/2),(n/2,n)))).to[Iterator]\n }\n\n def main(args:Array[String]) = {\n val n = readInt\n val a = readLine.split(\" \").map(_.toInt)\n val l = getSortIndex(n)\n for(e2<-l) {\n for(e<-e2) {\n val mid = (e._2+e._1)/2\n if(e._2-e._1>1)\n merge(a,e._1,mid,e._2)\n }\n }\n merge(a,0,n/2,n)\n println(cnt)\n }\n}", "language": "Scala", "metadata": {"date": 1491043818, "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/s995405480.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s995405480", "user_id": "u508732591"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import scala.io.StdIn.{readLine,readInt}\nimport scala.language.postfixOps\n\nobject Main {\n var cnt = 0\n val l = new Array[Int](100002)\n val r = new Array[Int](100002)\n\n def merge(a:Array[Int],left:Int,mid:Int,right:Int) = {\n 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 cnt = cnt+n1-i\n j += 1\n }\n }\n }\n\n def scan(h:Int,l:List[IndexedSeq[(Int,Int)]]):List[IndexedSeq[(Int,Int)]] =\n if(h==0) l\n else scan(h-1,(for(i<-l.head;j<-List((i._1,(i._2+i._1)/2),((i._2+i._1)/2,i._2))) yield j)::l)\n\n def getSortIndex(n:Int):Iterator[IndexedSeq[(Int,Int)]] = {\n var w = n\n var h = 0\n while(w>1) {\n h += 1; w /= 2\n }\n scan(h-1,List(IndexedSeq((0,n/2),(n/2,n)))).to[Iterator]\n }\n\n def main(args:Array[String]) = {\n val n = readInt\n val a = readLine.split(\" \").map(_.toInt)\n val l = getSortIndex(n)\n for(e2<-l) {\n for(e<-e2) {\n val mid = (e._2+e._1)/2\n if(e._2-e._1>1)\n merge(a,e._1,mid,e._2)\n }\n }\n merge(a,0,n/2,n)\n println(cnt)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 250, "memory_kb": 44844}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s855347353", "group_id": "codeNet:p02275", "input_text": "import scala.io.StdIn.readLine\n\nobject Main {\n def sort(a:Array[Int],k:Int) = {\n val count = new Array[Int](k+1)\n val buf = new Array[Int](a.length)\n a.map( x=> count(x) += 1 )\n for(i<-1 to k) count(i) += count(i-1)\n for(i<-0 until a.length) {\n val j = a.length-1-i\n buf(count(a(j))-1) = a(j)\n count(a(j)) = count(a(j))-1\n }\n buf\n }\n\n def main(args:Array[String]) = {\n readLine\n val a = readLine.split(\" \").map(_.toInt)\n val result = sort(a,10000)\n println(result.mkString(\" \"))\n }\n}", "language": "Scala", "metadata": {"date": 1491049799, "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/s855347353.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s855347353", "user_id": "u508732591"}, "prompt_components": {"gold_output": "0 1 2 2 3 3 5\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main {\n def sort(a:Array[Int],k:Int) = {\n val count = new Array[Int](k+1)\n val buf = new Array[Int](a.length)\n a.map( x=> count(x) += 1 )\n for(i<-1 to k) count(i) += count(i-1)\n for(i<-0 until a.length) {\n val j = a.length-1-i\n buf(count(a(j))-1) = a(j)\n count(a(j)) = count(a(j))-1\n }\n buf\n }\n\n def main(args:Array[String]) = {\n readLine\n val a = readLine.split(\" \").map(_.toInt)\n val result = sort(a,10000)\n println(result.mkString(\" \"))\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 940, "memory_kb": 481452}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s264361942", "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 = (first to pivot).map(arr(_)).toArray;\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": 1525648502, "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/s264361942.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s264361942", "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 = (first to pivot).map(arr(_)).toArray;\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3282, "cpu_time_ms": 2640, "memory_kb": 581720}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s132757768", "group_id": "codeNet:p02279", "input_text": "import scala.io.StdIn.{readInt, readLine}\ncase class Node[T](value: T, parent: Node[T], var children: List[Node[T]], depth: Int) {\n override def toString(): String = {\n val p = if (parent == null) -1 else parent.value\n val t = if (parent == null) \"root\" else if (children == Nil) \"leaf\" else \"internal node\"\n val c = children.map(_.value).mkString(\",\")\n s\"node ${value}: parent = ${p}, depth = ${depth}, ${t}, [${c}]\"\n }\n}\nclass IntTree() {\n var node: Node[Int] = null\n \n def add(target: Int, c: List[Int]): Unit = {\n if (node == null) {\n node = new Node[Int](target, null, Nil, 0)\n node.children = c.map(new Node[Int](_, node, Nil, 1))\n } else search(target) match {\n case n => n.children = c.map(new Node[Int](_, n, Nil, n.depth + 1))\n }\n }\n\n def search(target: Int): Node[Int] = {\n def go(nodes: List[Node[Int]]): Node[Int] = nodes match {\n case Nil => null\n case x :: xs if x.value == target => x\n case x :: xs => go(x.children) match {\n case null => go(xs)\n case ret => ret\n }\n }\n if (node.value == target) node else go(node.children)\n }\n}\nobject Main {\n def main(args: Array[String]): Unit = {\n val len = readInt\n val t = new IntTree()\n val l = (0 until len).foldLeft(Nil: List[Int]) { (list, i) =>\n val line = readLine.split(\" \").map(_.toInt)\n val c = line.slice(2, line.length).toList\n val p = line.head\n t.add(p, c)\n if (i == 0) (p :: c) ::: list\n else c ::: list\n }\n println(l.sorted.map(t.search(_)).mkString(\"\\n\"))\n }\n}\n", "language": "Scala", "metadata": {"date": 1516871104, "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/s132757768.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s132757768", "user_id": "u909989059"}, "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": "import scala.io.StdIn.{readInt, readLine}\ncase class Node[T](value: T, parent: Node[T], var children: List[Node[T]], depth: Int) {\n override def toString(): String = {\n val p = if (parent == null) -1 else parent.value\n val t = if (parent == null) \"root\" else if (children == Nil) \"leaf\" else \"internal node\"\n val c = children.map(_.value).mkString(\",\")\n s\"node ${value}: parent = ${p}, depth = ${depth}, ${t}, [${c}]\"\n }\n}\nclass IntTree() {\n var node: Node[Int] = null\n \n def add(target: Int, c: List[Int]): Unit = {\n if (node == null) {\n node = new Node[Int](target, null, Nil, 0)\n node.children = c.map(new Node[Int](_, node, Nil, 1))\n } else search(target) match {\n case n => n.children = c.map(new Node[Int](_, n, Nil, n.depth + 1))\n }\n }\n\n def search(target: Int): Node[Int] = {\n def go(nodes: List[Node[Int]]): Node[Int] = nodes match {\n case Nil => null\n case x :: xs if x.value == target => x\n case x :: xs => go(x.children) match {\n case null => go(xs)\n case ret => ret\n }\n }\n if (node.value == target) node else go(node.children)\n }\n}\nobject Main {\n def main(args: Array[String]): Unit = {\n val len = readInt\n val t = new IntTree()\n val l = (0 until len).foldLeft(Nil: List[Int]) { (list, i) =>\n val line = readLine.split(\" \").map(_.toInt)\n val c = line.slice(2, line.length).toList\n val p = line.head\n t.add(p, c)\n if (i == 0) (p :: c) ::: list\n else c ::: list\n }\n println(l.sorted.map(t.search(_)).mkString(\"\\n\"))\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 220, "memory_kb": 44068}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s253957761", "group_id": "codeNet:p02279", "input_text": "import scala.collection.mutable\nimport scala.io.StdIn.{readInt, readLine}\n\ncase class Node(id: Int, parent: Int, depth: Int, children: List[Int])\n\nobject Main extends App {\n import Solver.solve\n\n val n = readInt()\n val lines = Iterator.fill(n)(readLine())\n\n val xs = solve(lines, n)\n\n xs.foreach {\n case Node(id, parent, depth, children) =>\n val typeName =\n if (parent == -1) \"root\"\n else if (children.isEmpty) \"leaf\"\n else \"internal node\"\n\n val cs = children.mkString(\"[\", \", \", \"]\")\n println(s\"node $id: parent = $parent, depth = $depth, $typeName, $cs\")\n }\n}\n\nobject Solver {\n def solve(lines: Iterator[String], n: Int): Array[Node] = {\n\n val (childrenMap, rootId) = {\n val childrenMap = mutable.Map.empty[Int, List[Int]]\n val allChildren = mutable.Set(0 until n: _*)\n for {\n line <- lines\n id :: _ :: children = line.split(' ').map { _.toInt }.toList\n } {\n childrenMap(id) = children\n allChildren --= children\n }\n\n val rootId = allChildren.head\n (childrenMap, rootId)\n }\n\n val xs = new Array[Node](n)\n def setDepth(id: Int, parent: Int, depth: Int): Unit = {\n val children = childrenMap(id)\n xs(id) = Node(id, parent, depth, children)\n\n val d = depth + 1\n for (childNodeId <- children) {\n setDepth(childNodeId, id, d)\n }\n }\n\n setDepth(rootId, -1, 0)\n\n xs\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1591436240, "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/s253957761.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s253957761", "user_id": "u912124184"}, "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": "import scala.collection.mutable\nimport scala.io.StdIn.{readInt, readLine}\n\ncase class Node(id: Int, parent: Int, depth: Int, children: List[Int])\n\nobject Main extends App {\n import Solver.solve\n\n val n = readInt()\n val lines = Iterator.fill(n)(readLine())\n\n val xs = solve(lines, n)\n\n xs.foreach {\n case Node(id, parent, depth, children) =>\n val typeName =\n if (parent == -1) \"root\"\n else if (children.isEmpty) \"leaf\"\n else \"internal node\"\n\n val cs = children.mkString(\"[\", \", \", \"]\")\n println(s\"node $id: parent = $parent, depth = $depth, $typeName, $cs\")\n }\n}\n\nobject Solver {\n def solve(lines: Iterator[String], n: Int): Array[Node] = {\n\n val (childrenMap, rootId) = {\n val childrenMap = mutable.Map.empty[Int, List[Int]]\n val allChildren = mutable.Set(0 until n: _*)\n for {\n line <- lines\n id :: _ :: children = line.split(' ').map { _.toInt }.toList\n } {\n childrenMap(id) = children\n allChildren --= children\n }\n\n val rootId = allChildren.head\n (childrenMap, rootId)\n }\n\n val xs = new Array[Node](n)\n def setDepth(id: Int, parent: Int, depth: Int): Unit = {\n val children = childrenMap(id)\n xs(id) = Node(id, parent, depth, children)\n\n val d = depth + 1\n for (childNodeId <- children) {\n setDepth(childNodeId, id, d)\n }\n }\n\n setDepth(rootId, -1, 0)\n\n xs\n }\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1446, "cpu_time_ms": 1910, "memory_kb": 280620}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s494802339", "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 getNodeToInsert(node:Node):Node =\n if(node.key > keyNode.key) {\n if(node.left == null) node\n else getNodeToInsert(node.left)\n } else {\n if(node.right == null) node\n else getNodeToInsert(node.right)\n }\n\n val target = getNodeToInsert(tree)\n\n if(keyNode.key < target.key) target.left = keyNode\n else target.right = keyNode\n }\n\n def inOrder(tree:Node):Unit =\n if(tree == null) return\n else {\n inOrder(tree.left)\n out.write(\" \")\n out.write(tree.key.toString)\n if(count<100) count += 1\n else {\n out.flush\n count = 0\n }\n inOrder(tree.right)\n }\n\n def preOrder(tree:Node):Unit =\n if(tree == null) return\n else {\n out.write(\" \")\n out.write(tree.key.toString)\n if(count<100) count += 1\n else {\n out.flush\n count = 0\n }\n preOrder(tree.left)\n preOrder(tree.right)\n }\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": 1494023029, "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/s494802339.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s494802339", "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 getNodeToInsert(node:Node):Node =\n if(node.key > keyNode.key) {\n if(node.left == null) node\n else getNodeToInsert(node.left)\n } else {\n if(node.right == null) node\n else getNodeToInsert(node.right)\n }\n\n val target = getNodeToInsert(tree)\n\n if(keyNode.key < target.key) target.left = keyNode\n else target.right = keyNode\n }\n\n def inOrder(tree:Node):Unit =\n if(tree == null) return\n else {\n inOrder(tree.left)\n out.write(\" \")\n out.write(tree.key.toString)\n if(count<100) count += 1\n else {\n out.flush\n count = 0\n }\n inOrder(tree.right)\n }\n\n def preOrder(tree:Node):Unit =\n if(tree == null) return\n else {\n out.write(\" \")\n out.write(tree.key.toString)\n if(count<100) count += 1\n else {\n out.flush\n count = 0\n }\n preOrder(tree.left)\n preOrder(tree.right)\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1779, "cpu_time_ms": 1130, "memory_kb": 286768}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s643617319", "group_id": "codeNet:p02289", "input_text": "import scala.io.StdIn.{readLine,readInt}\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n var size = 0\n\n def swap(a:Array[Long],i:Int,j:Int) = {\n val temp = a(i)\n a(i) = a(j)\n a(j) = temp\n }\n\n def maxHeapify(a:Array[Long], i:Int):Unit = {\n var largest = i\n if(i*2 <= size) {\n if(a(i*2-1) > a(i-1)) largest = i*2\n if(i*2+1<=size && a(i*2) > a(largest-1)) largest = i*2+1\n if(largest != i) {\n swap(a,i-1,largest-1)\n maxHeapify(a,largest)\n }\n }\n }\n\n def extract(a:Array[Long]):Long = {\n val max = a(0)\n if(size>0) {\n a(0) = a(size-1)\n size -= 1\n for(i<-size/2 to 1 by -1) {\n maxHeapify(a,i)\n }\n }\n max\n }\n\n def insert(a:Array[Long], n:Long) = {\n a(size) = n\n size += 1\n def upHeap(i:Int):Unit =\n if(i/2>0) {\n if(a(i/2-1) < a(i-1)) {\n swap(a,i/2-1,i-1)\n upHeap(i/2)\n }\n }\n upHeap(size)\n }\n\n def main(args:Array[String]) = {\n val a = new Array[Long](2100000)\n Iterator.continually(readLine).takeWhile(_.trim!=\"end\").foreach { s=>\n val op = s.split(\" \")\n if(op(0) == \"insert\") {\n insert(a, op(1).toLong)\n } else if(op(0) == \"extract\") {\n println(extract(a))\n }\n }\n }\n}", "language": "Scala", "metadata": {"date": 1496239254, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02289.html", "problem_id": "p02289", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02289/input.txt", "sample_output_relpath": "derived/input_output/data/p02289/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02289/Scala/s643617319.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s643617319", "user_id": "u508732591"}, "prompt_components": {"gold_output": "8\n10\n11\n2\n", "input_to_evaluate": "import scala.io.StdIn.{readLine,readInt}\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n var size = 0\n\n def swap(a:Array[Long],i:Int,j:Int) = {\n val temp = a(i)\n a(i) = a(j)\n a(j) = temp\n }\n\n def maxHeapify(a:Array[Long], i:Int):Unit = {\n var largest = i\n if(i*2 <= size) {\n if(a(i*2-1) > a(i-1)) largest = i*2\n if(i*2+1<=size && a(i*2) > a(largest-1)) largest = i*2+1\n if(largest != i) {\n swap(a,i-1,largest-1)\n maxHeapify(a,largest)\n }\n }\n }\n\n def extract(a:Array[Long]):Long = {\n val max = a(0)\n if(size>0) {\n a(0) = a(size-1)\n size -= 1\n for(i<-size/2 to 1 by -1) {\n maxHeapify(a,i)\n }\n }\n max\n }\n\n def insert(a:Array[Long], n:Long) = {\n a(size) = n\n size += 1\n def upHeap(i:Int):Unit =\n if(i/2>0) {\n if(a(i/2-1) < a(i-1)) {\n swap(a,i/2-1,i-1)\n upHeap(i/2)\n }\n }\n upHeap(size)\n }\n\n def main(args:Array[String]) = {\n val a = new Array[Long](2100000)\n Iterator.continually(readLine).takeWhile(_.trim!=\"end\").foreach { s=>\n val op = s.split(\" \")\n if(op(0) == \"insert\") {\n insert(a, op(1).toLong)\n } else if(op(0) == \"extract\") {\n println(extract(a))\n }\n }\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nPriority Queue\n\nA priority queue is a data structure which maintains a set $S$ of elements, each of with an associated value (key), and supports the following operations:\n\n$insert(S, k)$: insert an element $k$ into the set $S$\n\n$extractMax(S)$: remove and return the element of $S$ with the largest key\n\nWrite a program which performs the $insert(S, k)$ and $extractMax(S)$ operations to a priority queue $S$.\nThe priority queue manages a set of integers, which are also keys for the priority.\n\nInput\n\nMultiple operations to the priority queue $S$ are given. Each operation is given by \"insert $k$\", \"extract\" or \"end\" in a line. Here, $k$ represents an integer element to be inserted to the priority queue.\n\nThe input ends with \"end\" operation.\n\nOutput\n\nFor each \"extract\" operation, print the element extracted from the priority queue $S$ in a line.\n\nConstraints\n\nThe number of operations $\\leq 2,000,000$\n\n$0 \\leq k \\leq 2,000,000,000$\n\nSample Input 1\n\ninsert 8\ninsert 2\nextract\ninsert 10\nextract\ninsert 11\nextract\nextract\nend\n\nSample Output 1\n\n8\n10\n11\n2", "sample_input": "insert 8\ninsert 2\nextract\ninsert 10\nextract\ninsert 11\nextract\nextract\nend\n"}, "reference_outputs": ["8\n10\n11\n2\n"], "source_document_id": "p02289", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nPriority Queue\n\nA priority queue is a data structure which maintains a set $S$ of elements, each of with an associated value (key), and supports the following operations:\n\n$insert(S, k)$: insert an element $k$ into the set $S$\n\n$extractMax(S)$: remove and return the element of $S$ with the largest key\n\nWrite a program which performs the $insert(S, k)$ and $extractMax(S)$ operations to a priority queue $S$.\nThe priority queue manages a set of integers, which are also keys for the priority.\n\nInput\n\nMultiple operations to the priority queue $S$ are given. Each operation is given by \"insert $k$\", \"extract\" or \"end\" in a line. Here, $k$ represents an integer element to be inserted to the priority queue.\n\nThe input ends with \"end\" operation.\n\nOutput\n\nFor each \"extract\" operation, print the element extracted from the priority queue $S$ in a line.\n\nConstraints\n\nThe number of operations $\\leq 2,000,000$\n\n$0 \\leq k \\leq 2,000,000,000$\n\nSample Input 1\n\ninsert 8\ninsert 2\nextract\ninsert 10\nextract\ninsert 11\nextract\nextract\nend\n\nSample Output 1\n\n8\n10\n11\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1273, "cpu_time_ms": 310, "memory_kb": 62500}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s812795686", "group_id": "codeNet:p02289", "input_text": "import scala.io.StdIn.{readLine,readInt}\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n var size = 0\n\n def swap(a:Array[Long],i:Int,j:Int) = {\n val temp = a(i)\n a(i) = a(j)\n a(j) = temp\n }\n\n def maxHeapify(a:Array[Long], i:Int):Unit = {\n var largest = i\n if(i*2 <= size) {\n if(a(i*2-1) > a(i-1)) largest = i*2\n if(i*2+1<=size && a(i*2) > a(largest-1)) largest = i*2+1\n if(largest != i) {\n swap(a,i-1,largest-1)\n maxHeapify(a,largest)\n }\n }\n }\n\n def extract(a:Array[Long]):String = {\n val max = a(0)\n if(size>0) {\n a(0) = a(size-1)\n size -= 1\n for(i<-size/2 to 1 by -1) {\n maxHeapify(a,i)\n }\n }\n max.toString\n }\n\n def insert(a:Array[Long], n:Long) = {\n a(size) = n\n size += 1\n def upHeap(i:Int):Unit =\n if(i/2>0) {\n if(a(i/2-1) < a(i-1)) {\n swap(a,i/2-1,i-1)\n upHeap(i/2)\n }\n }\n upHeap(size)\n }\n\n def main(args:Array[String]) = {\n val a = new Array[Long](3100000)\n val b = new ArrayBuffer[String]\n Iterator.continually(readLine).takeWhile(s=>s!=null && s.trim!=\"end\").foreach { s=>\n val op = s.split(\" \")\n if(op(0) == \"insert\") {\n insert(a, op(1).toLong)\n } else if(op(0) == \"extract\") {\n b+=extract(a)\n }\n }\n println(b.mkString(\"\\n\"))\n }\n}", "language": "Scala", "metadata": {"date": 1496240486, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02289.html", "problem_id": "p02289", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02289/input.txt", "sample_output_relpath": "derived/input_output/data/p02289/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02289/Scala/s812795686.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s812795686", "user_id": "u508732591"}, "prompt_components": {"gold_output": "8\n10\n11\n2\n", "input_to_evaluate": "import scala.io.StdIn.{readLine,readInt}\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n var size = 0\n\n def swap(a:Array[Long],i:Int,j:Int) = {\n val temp = a(i)\n a(i) = a(j)\n a(j) = temp\n }\n\n def maxHeapify(a:Array[Long], i:Int):Unit = {\n var largest = i\n if(i*2 <= size) {\n if(a(i*2-1) > a(i-1)) largest = i*2\n if(i*2+1<=size && a(i*2) > a(largest-1)) largest = i*2+1\n if(largest != i) {\n swap(a,i-1,largest-1)\n maxHeapify(a,largest)\n }\n }\n }\n\n def extract(a:Array[Long]):String = {\n val max = a(0)\n if(size>0) {\n a(0) = a(size-1)\n size -= 1\n for(i<-size/2 to 1 by -1) {\n maxHeapify(a,i)\n }\n }\n max.toString\n }\n\n def insert(a:Array[Long], n:Long) = {\n a(size) = n\n size += 1\n def upHeap(i:Int):Unit =\n if(i/2>0) {\n if(a(i/2-1) < a(i-1)) {\n swap(a,i/2-1,i-1)\n upHeap(i/2)\n }\n }\n upHeap(size)\n }\n\n def main(args:Array[String]) = {\n val a = new Array[Long](3100000)\n val b = new ArrayBuffer[String]\n Iterator.continually(readLine).takeWhile(s=>s!=null && s.trim!=\"end\").foreach { s=>\n val op = s.split(\" \")\n if(op(0) == \"insert\") {\n insert(a, op(1).toLong)\n } else if(op(0) == \"extract\") {\n b+=extract(a)\n }\n }\n println(b.mkString(\"\\n\"))\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nPriority Queue\n\nA priority queue is a data structure which maintains a set $S$ of elements, each of with an associated value (key), and supports the following operations:\n\n$insert(S, k)$: insert an element $k$ into the set $S$\n\n$extractMax(S)$: remove and return the element of $S$ with the largest key\n\nWrite a program which performs the $insert(S, k)$ and $extractMax(S)$ operations to a priority queue $S$.\nThe priority queue manages a set of integers, which are also keys for the priority.\n\nInput\n\nMultiple operations to the priority queue $S$ are given. Each operation is given by \"insert $k$\", \"extract\" or \"end\" in a line. Here, $k$ represents an integer element to be inserted to the priority queue.\n\nThe input ends with \"end\" operation.\n\nOutput\n\nFor each \"extract\" operation, print the element extracted from the priority queue $S$ in a line.\n\nConstraints\n\nThe number of operations $\\leq 2,000,000$\n\n$0 \\leq k \\leq 2,000,000,000$\n\nSample Input 1\n\ninsert 8\ninsert 2\nextract\ninsert 10\nextract\ninsert 11\nextract\nextract\nend\n\nSample Output 1\n\n8\n10\n11\n2", "sample_input": "insert 8\ninsert 2\nextract\ninsert 10\nextract\ninsert 11\nextract\nextract\nend\n"}, "reference_outputs": ["8\n10\n11\n2\n"], "source_document_id": "p02289", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nPriority Queue\n\nA priority queue is a data structure which maintains a set $S$ of elements, each of with an associated value (key), and supports the following operations:\n\n$insert(S, k)$: insert an element $k$ into the set $S$\n\n$extractMax(S)$: remove and return the element of $S$ with the largest key\n\nWrite a program which performs the $insert(S, k)$ and $extractMax(S)$ operations to a priority queue $S$.\nThe priority queue manages a set of integers, which are also keys for the priority.\n\nInput\n\nMultiple operations to the priority queue $S$ are given. Each operation is given by \"insert $k$\", \"extract\" or \"end\" in a line. Here, $k$ represents an integer element to be inserted to the priority queue.\n\nThe input ends with \"end\" operation.\n\nOutput\n\nFor each \"extract\" operation, print the element extracted from the priority queue $S$ in a line.\n\nConstraints\n\nThe number of operations $\\leq 2,000,000$\n\n$0 \\leq k \\leq 2,000,000,000$\n\nSample Input 1\n\ninsert 8\ninsert 2\nextract\ninsert 10\nextract\ninsert 11\nextract\nextract\nend\n\nSample Output 1\n\n8\n10\n11\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1359, "cpu_time_ms": 270, "memory_kb": 69028}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s515847075", "group_id": "codeNet:p02289", "input_text": "import java.io._\nimport scala.io.Source\n\nobject Main {\n var size = 0\n var size2 = 0\n var count = 0\n val out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(FileDescriptor.out), \"ASCII\"), 512)\n\n def swap(a:Array[Int],i:Int,j:Int,ai:Int,aj:Int) = {\n a(i) = aj\n a(j) = ai\n }\n\n def up(a:Array[Int], i:Int):Unit = {\n val j = i/2\n if(j>0 && a(j-1) < a(i-1)) { swap(a,j-1,i-1,a(j-1),a(i-1)); up(a,j) }\n }\n\n def down(a:Array[Int], i:Int, temp:Int):Unit = {\n var largest = i\n val j = (i+1)*2\n if(j>size) a(i) = temp\n else {\n val max = if(j==size) j-1 else if(a(j-1) >= a(j)) j-1 else j\n if(a(max)>temp) { a(i) = a(max); down(a,max,temp) }\n else a(i) = temp\n }\n }\n\n def extract(a:Array[Int]):Int = {\n val max = a(0)\n if(size>0) {\n a(0) = a(size-1)\n size -= 1\n down(a,0,a(0))\n a(size) = 0\n }\n max\n }\n\n def insert(a:Array[Int], n:Int) = {\n a(size) = n\n size += 1\n up(a,size)\n }\n\n def main(args:Array[String]) = {\n val a = new Array[Int](2000000)\n var s = \"\"\n Source.stdin.getLines.takeWhile(_!=\"end\").foreach { s =>\n val op = s.split(\" \")\n if(op(0) == \"insert\") {\n insert(a, op(1).toInt)\n } else if(op(0) == \"extract\") {\n val x = extract(a).toString\n out.write(x)\n out.write(\"\\n\")\n if(count<100) count += 1\n else {\n out.flush\n count = 0\n }\n }\n }\n out.flush\n }\n}", "language": "Scala", "metadata": {"date": 1496891346, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02289.html", "problem_id": "p02289", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02289/input.txt", "sample_output_relpath": "derived/input_output/data/p02289/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02289/Scala/s515847075.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s515847075", "user_id": "u508732591"}, "prompt_components": {"gold_output": "8\n10\n11\n2\n", "input_to_evaluate": "import java.io._\nimport scala.io.Source\n\nobject Main {\n var size = 0\n var size2 = 0\n var count = 0\n val out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(FileDescriptor.out), \"ASCII\"), 512)\n\n def swap(a:Array[Int],i:Int,j:Int,ai:Int,aj:Int) = {\n a(i) = aj\n a(j) = ai\n }\n\n def up(a:Array[Int], i:Int):Unit = {\n val j = i/2\n if(j>0 && a(j-1) < a(i-1)) { swap(a,j-1,i-1,a(j-1),a(i-1)); up(a,j) }\n }\n\n def down(a:Array[Int], i:Int, temp:Int):Unit = {\n var largest = i\n val j = (i+1)*2\n if(j>size) a(i) = temp\n else {\n val max = if(j==size) j-1 else if(a(j-1) >= a(j)) j-1 else j\n if(a(max)>temp) { a(i) = a(max); down(a,max,temp) }\n else a(i) = temp\n }\n }\n\n def extract(a:Array[Int]):Int = {\n val max = a(0)\n if(size>0) {\n a(0) = a(size-1)\n size -= 1\n down(a,0,a(0))\n a(size) = 0\n }\n max\n }\n\n def insert(a:Array[Int], n:Int) = {\n a(size) = n\n size += 1\n up(a,size)\n }\n\n def main(args:Array[String]) = {\n val a = new Array[Int](2000000)\n var s = \"\"\n Source.stdin.getLines.takeWhile(_!=\"end\").foreach { s =>\n val op = s.split(\" \")\n if(op(0) == \"insert\") {\n insert(a, op(1).toInt)\n } else if(op(0) == \"extract\") {\n val x = extract(a).toString\n out.write(x)\n out.write(\"\\n\")\n if(count<100) count += 1\n else {\n out.flush\n count = 0\n }\n }\n }\n out.flush\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nPriority Queue\n\nA priority queue is a data structure which maintains a set $S$ of elements, each of with an associated value (key), and supports the following operations:\n\n$insert(S, k)$: insert an element $k$ into the set $S$\n\n$extractMax(S)$: remove and return the element of $S$ with the largest key\n\nWrite a program which performs the $insert(S, k)$ and $extractMax(S)$ operations to a priority queue $S$.\nThe priority queue manages a set of integers, which are also keys for the priority.\n\nInput\n\nMultiple operations to the priority queue $S$ are given. Each operation is given by \"insert $k$\", \"extract\" or \"end\" in a line. Here, $k$ represents an integer element to be inserted to the priority queue.\n\nThe input ends with \"end\" operation.\n\nOutput\n\nFor each \"extract\" operation, print the element extracted from the priority queue $S$ in a line.\n\nConstraints\n\nThe number of operations $\\leq 2,000,000$\n\n$0 \\leq k \\leq 2,000,000,000$\n\nSample Input 1\n\ninsert 8\ninsert 2\nextract\ninsert 10\nextract\ninsert 11\nextract\nextract\nend\n\nSample Output 1\n\n8\n10\n11\n2", "sample_input": "insert 8\ninsert 2\nextract\ninsert 10\nextract\ninsert 11\nextract\nextract\nend\n"}, "reference_outputs": ["8\n10\n11\n2\n"], "source_document_id": "p02289", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nPriority Queue\n\nA priority queue is a data structure which maintains a set $S$ of elements, each of with an associated value (key), and supports the following operations:\n\n$insert(S, k)$: insert an element $k$ into the set $S$\n\n$extractMax(S)$: remove and return the element of $S$ with the largest key\n\nWrite a program which performs the $insert(S, k)$ and $extractMax(S)$ operations to a priority queue $S$.\nThe priority queue manages a set of integers, which are also keys for the priority.\n\nInput\n\nMultiple operations to the priority queue $S$ are given. Each operation is given by \"insert $k$\", \"extract\" or \"end\" in a line. Here, $k$ represents an integer element to be inserted to the priority queue.\n\nThe input ends with \"end\" operation.\n\nOutput\n\nFor each \"extract\" operation, print the element extracted from the priority queue $S$ in a line.\n\nConstraints\n\nThe number of operations $\\leq 2,000,000$\n\n$0 \\leq k \\leq 2,000,000,000$\n\nSample Input 1\n\ninsert 8\ninsert 2\nextract\ninsert 10\nextract\ninsert 11\nextract\nextract\nend\n\nSample Output 1\n\n8\n10\n11\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1469, "cpu_time_ms": 1130, "memory_kb": 461640}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s585243339", "group_id": "codeNet:p02300", "input_text": "import scala.collection.mutable.ArrayBuffer\nimport scala.io.StdIn\n\nobject Main {\n\n case class Point(x: Double = 0, y: Double = 0) {\n\n def +(p: Point): Point = Point(this.x + p.x, this.y + p.y)\n\n def -(p: Point): Point = Point(this.x - p.x, this.y - p.y)\n\n def *(a: Double): Point = Point(this.x * a, this.y * a)\n\n def /(a: Double): Point = {\n assert(a != 0)\n Point(this.x / a, this.y / a)\n }\n\n def norm(): Double = this.x * this.x + this.y * this.y\n\n def abs(): Double = scala.math.sqrt(norm())\n\n def <(p: Point): Boolean = this.x < p.x && this.y < p.y\n\n\n def ==(p: Point): Boolean = scala.math.abs(this.x - p.x) < Cgl0A.EPS &&\n scala.math.abs(this.y - p.y) < Cgl0A.EPS\n\n\n }\n\n case class Circle(center: Point, r: Int)\n\n case class Segment(p1: Point, p2: Point)\n\n case class Line(p1: Point, p2: Point)\n\n type GeoVector = Point\n\n object Cgl0A {\n val EPS: Double = scala.math.pow(10, -10)\n\n // 内積\n def dot(a: Point, b: Point): Double = a.x * b.x + a.y * b.y\n\n def isOrthogonal(a: GeoVector, b: GeoVector): Boolean = dot(a, b) == 0.0\n\n def isOrthogonal(a1: Point, a2: Point, b1: Point, b2: Point): Boolean = {\n isOrthogonal(a1 - a2, b1 - b2)\n }\n\n def isOrthogonal(s1: Segment, s2: Segment): Boolean = {\n dot(s1.p2 - s1.p1, s2.p2 - s2.p1) == 0.0\n }\n\n // 外積\n def cross(a: Point, b: Point): Double = a.x * b.y - a.y * b.x\n\n def isParallel(a: GeoVector, b: GeoVector): Boolean = cross(a, b) == 0.0\n\n def isParallel(a1: Point, a2: Point, b1: Point, b2: Point): Boolean = {\n isParallel(a1 - a2, b1 - b2)\n }\n\n def isParallel(s1: Segment, s2: Segment): Boolean = {\n cross(s1.p2 - s1.p1, s2.p2 - s2.p1) == 0.0\n }\n\n def project(s: Segment, p: Point): Point = {\n val base: GeoVector = s.p2 - s.p1\n val r: Double = Cgl0A.dot(p - s.p1, base) / base.norm()\n s.p1 + base * r\n }\n\n def reflect(s: Segment, p: Point): Point = {\n p + (project(s, p) - p) * 2.0\n }\n\n def getDistance(a: Point, b: Point): Double = (a - b).abs()\n\n def getDistanceLP(l: Line, a: Point): Double = {\n scala.math.abs(cross(l.p2 - l.p1, a - l.p1) / (l.p2 - l.p1).abs())\n }\n\n def getDistanceSP(s: Segment, a: Point): Double = {\n if (dot(s.p2 - s.p1, a - s.p1) < 0.0) (a - s.p1).abs()\n else if (dot(s.p1 - s.p2, a - s.p2) < 0.0) (a - s.p2).abs()\n else getDistanceLP(Line(s.p1, s.p2), a)\n }\n\n def getDistance(s1: Segment, s2: Segment): Double = {\n if (intersect(s1, s2)) {\n 0.0\n }\n else {\n math.min(math.min(getDistanceSP(s1, s2.p1), getDistanceSP(s1, s2.p2)),\n math.min(getDistanceSP(s2, s1.p1), getDistanceSP(s2, s1.p2)))\n }\n }\n\n val COUNTER_CLOCKWISE: Int = 1\n val CLOCKWISE: Int = -1\n val ONLINE_BACK: Int = 2\n val ONLINE_FRONT: Int = -2\n val ON_SEGMENT: Int = 0\n\n def ccw(p0: Point, p1: Point, p2: Point): Int = {\n val a: GeoVector = p1 - p0\n val b: GeoVector = p2 - p0\n\n if (cross(a, b) > EPS) COUNTER_CLOCKWISE\n else if (cross(a, b) < -1 * EPS) CLOCKWISE\n else if (dot(a, b) < -1 * EPS) ONLINE_BACK\n else if (a.norm() < b.norm()) ONLINE_FRONT\n else ON_SEGMENT\n\n }\n\n def intersect(p1: Point, p2: Point, p3: Point, p4: Point): Boolean = {\n Cgl0A.ccw(p1, p2, p3) * Cgl0A.ccw(p1, p2, p4) <= 0 &&\n Cgl0A.ccw(p3, p4, p1) * Cgl0A.ccw(p3, p4, p2) <= 0\n }\n\n def intersect(s1: Segment, s2: Segment): Boolean = {\n Cgl0A.intersect(s1.p1, s1.p2, s2.p1, s2.p2)\n }\n\n def getCrossPoint(s1: Segment, s2: Segment): Point = {\n val base: GeoVector = s2.p2 - s2.p1\n val d1 = scala.math.abs(cross(base, s1.p1 - s2.p2))\n val d2 = scala.math.abs(cross(base, s1.p2 - s2.p1))\n val t = d1 / (d1 + d2)\n s1.p1 + (s1.p2 - s1.p1) * t\n }\n\n def getCrossPoint(c: Circle, l: Line): Array[Point] = {\n val pr: GeoVector = project(Segment(l.p1, l.p2), c.center)\n val e: GeoVector = (l.p2 - l.p1) / (l.p2 - l.p1).abs()\n val base: Double = scala.math.sqrt(c.r * c.r - (pr - c.center).norm())\n Array(pr + e * base, pr - e * base).sortBy(p => (p.x, p.y))\n }\n\n // arq tangent\n def arg(p: GeoVector): Double = scala.math.atan2(p.y, p.x)\n\n // \n def polar(a: Double, r: Double): GeoVector = {\n // x * 角度ラジアン\n Point(scala.math.cos(r) * a, scala.math.sin(r) * a)\n }\n\n def getCrossPoint(c1: Circle, c2: Circle): Array[Point] = {\n val d: Double = (c1.center - c2.center).abs()\n val cos: Double = (c1.r * c1.r + d * d - c2.r * c2.r) / (2 * c1.r * d)\n val a: Double = scala.math.acos(cos) // radian\n\n val t: Double = arg(c2.center - c1.center) // radian\n Array(c1.center + polar(c1.r, t + a),\n c1.center + polar(c1.r, t - a)).sortBy(p => (p.x, p.y))\n\n }\n\n val IN: Int = 2\n val ON: Int = 1\n val OUT: Int = 0\n\n def contains(g: IndexedSeq[Point], target: Point): Int = {\n val n = g.size\n var i = 0\n var onJudge = false\n var parity = false\n while (!onJudge && i < n) {\n var a: Point = g(i) - target\n var b: Point = g((i + 1) % n) - target\n if (cross(a, b).abs < EPS && dot(a, b) < EPS) {\n onJudge = true\n } else {\n if (a.y > b.y) {\n val temp = a\n a = b\n b = temp\n }\n parity = if (a.y < EPS && EPS < b.y && cross(a, b) > EPS) !parity else parity\n }\n i += 1\n }\n\n if (onJudge) {\n ON\n } else {\n if (parity) IN else OUT\n }\n }\n\n\n def andrewScan(s: Array[Point]): Array[Point] = {\n val u: ArrayBuffer[Point] = ArrayBuffer.empty[Point]\n val l: ArrayBuffer[Point] = ArrayBuffer.empty[Point]\n\n val sSize = s.length\n if (sSize < 3) {\n s\n } else {\n val temp = s.sortBy(p => (p.x, p.y))\n u.append(temp(0))\n u.append(temp(1))\n\n l.append(temp(sSize - 1))\n l.append(temp(sSize - 2))\n\n (2 until sSize).foreach { i =>\n var n = u.size\n while (n >= 2 && ccw(u(n - 2), u(n - 1), temp(i)) == COUNTER_CLOCKWISE) {\n u.remove(n - 1)\n n -= 1\n }\n u.append(temp(i))\n }\n\n (sSize - 3 to 0 by -1).foreach { i =>\n var n = l.size\n while (n >= 2 && ccw(l(n - 2), l(n - 1), temp(i)) == COUNTER_CLOCKWISE) {\n l.remove(n - 1)\n n -= 1\n }\n l.append(temp(i))\n }\n\n //println(\"U: \" + u.toList)\n //println(\"L: \" + l.toList)\n\n val r: ArrayBuffer[Point] = l.reverse\n u.reverse.slice(1, u.size - 1).foreach( e => r.append(e))\n \n r.toArray\n }\n\n }\n\n\n }\n\n\n def main(args: Array[String]): Unit = {\n val n = StdIn.readLine().toInt\n val polygon = (0 until n).map { _ =>\n val point = StdIn.readLine().split(' ').map(_.toInt)\n Point(point(0), point(1))\n }.toArray\n\n val r = Cgl0A.andrewScan(polygon)\n r.foreach { e =>\n println(f\"${e.x.toInt} ${e.y.toInt}\")\n }\n\n }\n\n}\n\n", "language": "Scala", "metadata": {"date": 1526992950, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02300.html", "problem_id": "p02300", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02300/input.txt", "sample_output_relpath": "derived/input_output/data/p02300/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02300/Scala/s585243339.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s585243339", "user_id": "u342234782"}, "prompt_components": {"gold_output": "5\n0 0\n2 1\n4 2\n3 3\n1 3\n", "input_to_evaluate": "import scala.collection.mutable.ArrayBuffer\nimport scala.io.StdIn\n\nobject Main {\n\n case class Point(x: Double = 0, y: Double = 0) {\n\n def +(p: Point): Point = Point(this.x + p.x, this.y + p.y)\n\n def -(p: Point): Point = Point(this.x - p.x, this.y - p.y)\n\n def *(a: Double): Point = Point(this.x * a, this.y * a)\n\n def /(a: Double): Point = {\n assert(a != 0)\n Point(this.x / a, this.y / a)\n }\n\n def norm(): Double = this.x * this.x + this.y * this.y\n\n def abs(): Double = scala.math.sqrt(norm())\n\n def <(p: Point): Boolean = this.x < p.x && this.y < p.y\n\n\n def ==(p: Point): Boolean = scala.math.abs(this.x - p.x) < Cgl0A.EPS &&\n scala.math.abs(this.y - p.y) < Cgl0A.EPS\n\n\n }\n\n case class Circle(center: Point, r: Int)\n\n case class Segment(p1: Point, p2: Point)\n\n case class Line(p1: Point, p2: Point)\n\n type GeoVector = Point\n\n object Cgl0A {\n val EPS: Double = scala.math.pow(10, -10)\n\n // 内積\n def dot(a: Point, b: Point): Double = a.x * b.x + a.y * b.y\n\n def isOrthogonal(a: GeoVector, b: GeoVector): Boolean = dot(a, b) == 0.0\n\n def isOrthogonal(a1: Point, a2: Point, b1: Point, b2: Point): Boolean = {\n isOrthogonal(a1 - a2, b1 - b2)\n }\n\n def isOrthogonal(s1: Segment, s2: Segment): Boolean = {\n dot(s1.p2 - s1.p1, s2.p2 - s2.p1) == 0.0\n }\n\n // 外積\n def cross(a: Point, b: Point): Double = a.x * b.y - a.y * b.x\n\n def isParallel(a: GeoVector, b: GeoVector): Boolean = cross(a, b) == 0.0\n\n def isParallel(a1: Point, a2: Point, b1: Point, b2: Point): Boolean = {\n isParallel(a1 - a2, b1 - b2)\n }\n\n def isParallel(s1: Segment, s2: Segment): Boolean = {\n cross(s1.p2 - s1.p1, s2.p2 - s2.p1) == 0.0\n }\n\n def project(s: Segment, p: Point): Point = {\n val base: GeoVector = s.p2 - s.p1\n val r: Double = Cgl0A.dot(p - s.p1, base) / base.norm()\n s.p1 + base * r\n }\n\n def reflect(s: Segment, p: Point): Point = {\n p + (project(s, p) - p) * 2.0\n }\n\n def getDistance(a: Point, b: Point): Double = (a - b).abs()\n\n def getDistanceLP(l: Line, a: Point): Double = {\n scala.math.abs(cross(l.p2 - l.p1, a - l.p1) / (l.p2 - l.p1).abs())\n }\n\n def getDistanceSP(s: Segment, a: Point): Double = {\n if (dot(s.p2 - s.p1, a - s.p1) < 0.0) (a - s.p1).abs()\n else if (dot(s.p1 - s.p2, a - s.p2) < 0.0) (a - s.p2).abs()\n else getDistanceLP(Line(s.p1, s.p2), a)\n }\n\n def getDistance(s1: Segment, s2: Segment): Double = {\n if (intersect(s1, s2)) {\n 0.0\n }\n else {\n math.min(math.min(getDistanceSP(s1, s2.p1), getDistanceSP(s1, s2.p2)),\n math.min(getDistanceSP(s2, s1.p1), getDistanceSP(s2, s1.p2)))\n }\n }\n\n val COUNTER_CLOCKWISE: Int = 1\n val CLOCKWISE: Int = -1\n val ONLINE_BACK: Int = 2\n val ONLINE_FRONT: Int = -2\n val ON_SEGMENT: Int = 0\n\n def ccw(p0: Point, p1: Point, p2: Point): Int = {\n val a: GeoVector = p1 - p0\n val b: GeoVector = p2 - p0\n\n if (cross(a, b) > EPS) COUNTER_CLOCKWISE\n else if (cross(a, b) < -1 * EPS) CLOCKWISE\n else if (dot(a, b) < -1 * EPS) ONLINE_BACK\n else if (a.norm() < b.norm()) ONLINE_FRONT\n else ON_SEGMENT\n\n }\n\n def intersect(p1: Point, p2: Point, p3: Point, p4: Point): Boolean = {\n Cgl0A.ccw(p1, p2, p3) * Cgl0A.ccw(p1, p2, p4) <= 0 &&\n Cgl0A.ccw(p3, p4, p1) * Cgl0A.ccw(p3, p4, p2) <= 0\n }\n\n def intersect(s1: Segment, s2: Segment): Boolean = {\n Cgl0A.intersect(s1.p1, s1.p2, s2.p1, s2.p2)\n }\n\n def getCrossPoint(s1: Segment, s2: Segment): Point = {\n val base: GeoVector = s2.p2 - s2.p1\n val d1 = scala.math.abs(cross(base, s1.p1 - s2.p2))\n val d2 = scala.math.abs(cross(base, s1.p2 - s2.p1))\n val t = d1 / (d1 + d2)\n s1.p1 + (s1.p2 - s1.p1) * t\n }\n\n def getCrossPoint(c: Circle, l: Line): Array[Point] = {\n val pr: GeoVector = project(Segment(l.p1, l.p2), c.center)\n val e: GeoVector = (l.p2 - l.p1) / (l.p2 - l.p1).abs()\n val base: Double = scala.math.sqrt(c.r * c.r - (pr - c.center).norm())\n Array(pr + e * base, pr - e * base).sortBy(p => (p.x, p.y))\n }\n\n // arq tangent\n def arg(p: GeoVector): Double = scala.math.atan2(p.y, p.x)\n\n // \n def polar(a: Double, r: Double): GeoVector = {\n // x * 角度ラジアン\n Point(scala.math.cos(r) * a, scala.math.sin(r) * a)\n }\n\n def getCrossPoint(c1: Circle, c2: Circle): Array[Point] = {\n val d: Double = (c1.center - c2.center).abs()\n val cos: Double = (c1.r * c1.r + d * d - c2.r * c2.r) / (2 * c1.r * d)\n val a: Double = scala.math.acos(cos) // radian\n\n val t: Double = arg(c2.center - c1.center) // radian\n Array(c1.center + polar(c1.r, t + a),\n c1.center + polar(c1.r, t - a)).sortBy(p => (p.x, p.y))\n\n }\n\n val IN: Int = 2\n val ON: Int = 1\n val OUT: Int = 0\n\n def contains(g: IndexedSeq[Point], target: Point): Int = {\n val n = g.size\n var i = 0\n var onJudge = false\n var parity = false\n while (!onJudge && i < n) {\n var a: Point = g(i) - target\n var b: Point = g((i + 1) % n) - target\n if (cross(a, b).abs < EPS && dot(a, b) < EPS) {\n onJudge = true\n } else {\n if (a.y > b.y) {\n val temp = a\n a = b\n b = temp\n }\n parity = if (a.y < EPS && EPS < b.y && cross(a, b) > EPS) !parity else parity\n }\n i += 1\n }\n\n if (onJudge) {\n ON\n } else {\n if (parity) IN else OUT\n }\n }\n\n\n def andrewScan(s: Array[Point]): Array[Point] = {\n val u: ArrayBuffer[Point] = ArrayBuffer.empty[Point]\n val l: ArrayBuffer[Point] = ArrayBuffer.empty[Point]\n\n val sSize = s.length\n if (sSize < 3) {\n s\n } else {\n val temp = s.sortBy(p => (p.x, p.y))\n u.append(temp(0))\n u.append(temp(1))\n\n l.append(temp(sSize - 1))\n l.append(temp(sSize - 2))\n\n (2 until sSize).foreach { i =>\n var n = u.size\n while (n >= 2 && ccw(u(n - 2), u(n - 1), temp(i)) == COUNTER_CLOCKWISE) {\n u.remove(n - 1)\n n -= 1\n }\n u.append(temp(i))\n }\n\n (sSize - 3 to 0 by -1).foreach { i =>\n var n = l.size\n while (n >= 2 && ccw(l(n - 2), l(n - 1), temp(i)) == COUNTER_CLOCKWISE) {\n l.remove(n - 1)\n n -= 1\n }\n l.append(temp(i))\n }\n\n //println(\"U: \" + u.toList)\n //println(\"L: \" + l.toList)\n\n val r: ArrayBuffer[Point] = l.reverse\n u.reverse.slice(1, u.size - 1).foreach( e => r.append(e))\n \n r.toArray\n }\n\n }\n\n\n }\n\n\n def main(args: Array[String]): Unit = {\n val n = StdIn.readLine().toInt\n val polygon = (0 until n).map { _ =>\n val point = StdIn.readLine().split(' ').map(_.toInt)\n Point(point(0), point(1))\n }.toArray\n\n val r = Cgl0A.andrewScan(polygon)\n r.foreach { e =>\n println(f\"${e.x.toInt} ${e.y.toInt}\")\n }\n\n }\n\n}\n\n", "problem_context": "Convex Hull\n\nFind the convex hull of a given set of points P. In other words, find the smallest convex polygon containing all the points of P. Here, in a convex polygon, all interior angles are less than or equal to 180 degrees.\n\nPlease note that you should find all the points of P on both corner and boundary of the convex polygon.\n\nInput\n\nn\nx1 y1\nx2 y2\n:\nxn yn\n\nThe first integer n is the number of points in P. The coordinate of the i-th point pi is given by two integers xi and yi.\n\nOutput\n\nIn the first line, print the number of points on the corner/boundary of the convex polygon. In the following lines, print x y coordinates of the set of points.\nThe coordinates should be given in the order of counter-clockwise visit of them starting from the point in P with the minimum y-coordinate, or the leftmost such point in case of a tie.\n\nConstraints\n\n3 ≤ n ≤ 100000\n\n-10000 ≤ xi, yi ≤ 10000\n\nNo point in the P will occur more than once.\n\nSample Input 1\n\n7\n2 1\n0 0\n1 2\n2 2\n4 2\n1 3\n3 3\n\nSample Output 1\n\n5\n0 0\n2 1\n4 2\n3 3\n1 3\n\nSample Input 2\n\n4\n0 0\n2 2\n0 2\n0 1\n\nSample Output 2\n\n4\n0 0\n2 2\n0 2\n0 1", "sample_input": "7\n2 1\n0 0\n1 2\n2 2\n4 2\n1 3\n3 3\n"}, "reference_outputs": ["5\n0 0\n2 1\n4 2\n3 3\n1 3\n"], "source_document_id": "p02300", "source_text": "Convex Hull\n\nFind the convex hull of a given set of points P. In other words, find the smallest convex polygon containing all the points of P. Here, in a convex polygon, all interior angles are less than or equal to 180 degrees.\n\nPlease note that you should find all the points of P on both corner and boundary of the convex polygon.\n\nInput\n\nn\nx1 y1\nx2 y2\n:\nxn yn\n\nThe first integer n is the number of points in P. The coordinate of the i-th point pi is given by two integers xi and yi.\n\nOutput\n\nIn the first line, print the number of points on the corner/boundary of the convex polygon. In the following lines, print x y coordinates of the set of points.\nThe coordinates should be given in the order of counter-clockwise visit of them starting from the point in P with the minimum y-coordinate, or the leftmost such point in case of a tie.\n\nConstraints\n\n3 ≤ n ≤ 100000\n\n-10000 ≤ xi, yi ≤ 10000\n\nNo point in the P will occur more than once.\n\nSample Input 1\n\n7\n2 1\n0 0\n1 2\n2 2\n4 2\n1 3\n3 3\n\nSample Output 1\n\n5\n0 0\n2 1\n4 2\n3 3\n1 3\n\nSample Input 2\n\n4\n0 0\n2 2\n0 2\n0 1\n\nSample Output 2\n\n4\n0 0\n2 2\n0 2\n0 1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 7053, "cpu_time_ms": 230, "memory_kb": 44092}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s048728425", "group_id": "codeNet:p02320", "input_text": "import java.util.Scanner\n\nobject Main extends App { \n val sc = new Scanner(System.in)\n val N, W = sc.nextInt()\n val ls = (for (i <- 1 to N) yield (sc.nextInt, sc.nextInt, sc.nextInt)).toList\n\n type Item = (Int,Int) // (value, Weight)\n\n def mkItems(t:(Int,Int,Int)):List[Item] = {\n def iter(v:Int, w:Int, m:Int, s:Int, acc:List[Item]):(Int, List[Item]) = {\n if (m > 1) {\n iter(v << 1,w << 1,m >> 1, s << 1, (v, w)::acc)\n } else (s,acc)\n }\n val (v,w,m) = t\n val (s, items) = iter(v, w, m, 1, Nil)\n val k = m - (s -1)\n if (k > 0) (v*k,w*k)::items else items\n }\n \n class DP(num:Int, wgt:Int, items:Array[Item]) {\n val memo = Array.fill(wgt+1)(0)\n override def toString:String = (for (e <- memo) yield f\" $e%3d\").foldLeft(\"\")(_+_)\n def solver():Int = {\n for (i <- 1 to num) {\n val (v, w) = items(i-1)\n for (j <- wgt to 0 by -1) {\n if (j >= w) {\n val v0 = memo(j)\n val v1 = memo(j-w) + v\n memo(j)= v0 max v1\n }\n }\n }\n memo(wgt)\n }\n }\n \n val items = (for (e <- ls) yield mkItems(e)).flatten.toArray\n\n val dp = new DP(items.length, W, items)\n println(dp.solver())\n\n}\n", "language": "Scala", "metadata": {"date": 1595331110, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02320.html", "problem_id": "p02320", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02320/input.txt", "sample_output_relpath": "derived/input_output/data/p02320/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02320/Scala/s048728425.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s048728425", "user_id": "u497503269"}, "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, W = sc.nextInt()\n val ls = (for (i <- 1 to N) yield (sc.nextInt, sc.nextInt, sc.nextInt)).toList\n\n type Item = (Int,Int) // (value, Weight)\n\n def mkItems(t:(Int,Int,Int)):List[Item] = {\n def iter(v:Int, w:Int, m:Int, s:Int, acc:List[Item]):(Int, List[Item]) = {\n if (m > 1) {\n iter(v << 1,w << 1,m >> 1, s << 1, (v, w)::acc)\n } else (s,acc)\n }\n val (v,w,m) = t\n val (s, items) = iter(v, w, m, 1, Nil)\n val k = m - (s -1)\n if (k > 0) (v*k,w*k)::items else items\n }\n \n class DP(num:Int, wgt:Int, items:Array[Item]) {\n val memo = Array.fill(wgt+1)(0)\n override def toString:String = (for (e <- memo) yield f\" $e%3d\").foldLeft(\"\")(_+_)\n def solver():Int = {\n for (i <- 1 to num) {\n val (v, w) = items(i-1)\n for (j <- wgt to 0 by -1) {\n if (j >= w) {\n val v0 = memo(j)\n val v1 = memo(j-w) + v\n memo(j)= v0 max v1\n }\n }\n }\n memo(wgt)\n }\n }\n \n val items = (for (e <- ls) yield mkItems(e)).flatten.toArray\n\n val dp = new DP(items.length, W, items)\n println(dp.solver())\n\n}\n", "problem_context": "Knapsack Problem with Limitations\n\nYou have N items that you want to put them into a knapsack. Item i has value vi, weight wi and limitation mi.\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 at most mi items for ith item.\n\nFind the maximum total value of items in the knapsack.\n\nInput\n\nN W\nv1 w1 m1\nv2 w2 m2\n:\nvN wN mN\n\nThe first line consists of the integers N and W. In the following N lines, the value, weight and limitation 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 ≤ 1,000\n\n1 ≤ wi ≤ 1,000\n\n1 ≤ mi ≤ 10,000\n\n1 ≤ W ≤ 10,000\n\nSample Input 1\n\n4 8\n4 3 2\n2 1 1\n1 2 4\n3 2 2\n\nSample Output 1\n\n12\n\nSample Input 2\n\n2 100\n1 1 100\n2 1 50\n\nSample Output 2\n\n150", "sample_input": "4 8\n4 3 2\n2 1 1\n1 2 4\n3 2 2\n"}, "reference_outputs": ["12\n"], "source_document_id": "p02320", "source_text": "Knapsack Problem with Limitations\n\nYou have N items that you want to put them into a knapsack. Item i has value vi, weight wi and limitation mi.\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 at most mi items for ith item.\n\nFind the maximum total value of items in the knapsack.\n\nInput\n\nN W\nv1 w1 m1\nv2 w2 m2\n:\nvN wN mN\n\nThe first line consists of the integers N and W. In the following N lines, the value, weight and limitation 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 ≤ 1,000\n\n1 ≤ wi ≤ 1,000\n\n1 ≤ mi ≤ 10,000\n\n1 ≤ W ≤ 10,000\n\nSample Input 1\n\n4 8\n4 3 2\n2 1 1\n1 2 4\n3 2 2\n\nSample Output 1\n\n12\n\nSample Input 2\n\n2 100\n1 1 100\n2 1 50\n\nSample Output 2\n\n150", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1205, "cpu_time_ms": 400, "memory_kb": 46756}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s003641562", "group_id": "codeNet:p02343", "input_text": "object Main extends App {\n val Seq(n,q): Seq[Int] = io.StdIn.readLine().split(\" \").map(_.toInt)\n val ds = new DisjointSets(n)\n (0 until q) foreach {_ =>\n io.StdIn.readLine().split(\" \").map(_.toInt) match {\n case Array(0, x, y) => ds.union(x, y)\n case Array(1, x, y) => println(if (ds.same(x,y)) 1 else 0)\n }\n }\n}\nclass DisjointSets(size: Int) {\n val parent: Array[Int] = Array.tabulate(size)(i => i)\n val rank: Array[Int] = Array.fill(size)(0)\n def union(x: Int, y: Int): Unit = {\n val i = find(x)\n val j = find(y)\n if (rank(i) > rank(j)) parent(j) = i\n else {\n parent(i) = j\n rank(i) += (if (rank(i) == rank(j)) 1 else 0)\n }\n }\n def find(x: Int): Int = parent(x) match {\n case p if x == p => x\n case p =>\n val i = find(p)\n parent(x) = i\n rank(x) = 0\n i\n }\n def same(x: Int, y: Int):Boolean = find(x) == find(y)\n}", "language": "Scala", "metadata": {"date": 1511985725, "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/s003641562.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s003641562", "user_id": "u995793569"}, "prompt_components": {"gold_output": "0\n0\n1\n1\n1\n0\n1\n1\n", "input_to_evaluate": "object Main extends App {\n val Seq(n,q): Seq[Int] = io.StdIn.readLine().split(\" \").map(_.toInt)\n val ds = new DisjointSets(n)\n (0 until q) foreach {_ =>\n io.StdIn.readLine().split(\" \").map(_.toInt) match {\n case Array(0, x, y) => ds.union(x, y)\n case Array(1, x, y) => println(if (ds.same(x,y)) 1 else 0)\n }\n }\n}\nclass DisjointSets(size: Int) {\n val parent: Array[Int] = Array.tabulate(size)(i => i)\n val rank: Array[Int] = Array.fill(size)(0)\n def union(x: Int, y: Int): Unit = {\n val i = find(x)\n val j = find(y)\n if (rank(i) > rank(j)) parent(j) = i\n else {\n parent(i) = j\n rank(i) += (if (rank(i) == rank(j)) 1 else 0)\n }\n }\n def find(x: Int): Int = parent(x) match {\n case p if x == p => x\n case p =>\n val i = find(p)\n parent(x) = i\n rank(x) = 0\n i\n }\n def same(x: Int, y: Int):Boolean = find(x) == find(y)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 870, "memory_kb": 162360}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s485649494", "group_id": "codeNet:p02346", "input_text": "import scala.annotation.tailrec\nimport net.pushl.io.MyConsole\n\npackage net.pushl {\n package number {\n // Prime (Prime.scala)\n // Number (Number.scala)\n // Combi (Combi.scala)\n // Optimize (Optimize.scala)\n }\n package string {\n // RollingHash (RollingHash.scala)\n }\n package geometry {\n // Point (Geometry.scala)\n // Segment (Geometry.scala)\n // Line (Geometry.scala)\n }\n package datastructure {\n // UnionFindTree (UnionFind.scala)\n }\n package io {\n }\n}\n\n\npackage net.pushl.datastructure {\n import scala.reflect.ClassTag\n abstract class ASegmentTree[T: ClassTag](_n: Int) {\n protected val init: T\n protected def calc(left: T, right: T): T\n private val n = calcDataSize(_n)\n private val data = {\n val d = implicitly[ClassTag[T]].newArray(2*n-1)\n (0 until n).foreach(d(_) = init)\n d\n }\n // Array.fill[implicitly[ClassTag[T]]](calcDataSize(n))(init)\n\n def update(i: Int, v: T) : Unit = {\n val k = i+n-1\n data(k) = v\n @tailrec\n def updateAux(k: Int) : Unit =\n if(k > 0) {\n val p = parent(k)\n data(p) = calc(data(getLeft(p)),data(getRight(p)))\n updateAux(p)\n }\n updateAux(k)\n }\n // get data of [a,b)\n def get(a: Int, b: Int) : T = get(a,b,0,0,n)\n\n // l,r is segment of node k.\n private def get(a: Int, b: Int, k: Int, l: Int, r: Int) : T = {\n if(r <= a || b <= l) init\n else if(a <= l && r <= b) data(k)\n else calc(get(a,b,getLeft(k) ,l,(l+r)/2),\n get(a,b,getRight(k),(l+r)/2,r))\n }\n\n final private def getLeft (i: Int) = 2*i+1\n final private def getRight(i: Int) = 2*i+2\n final private def parent (i: Int) = (i-1)/2\n final private def calcDataSize(n: Int) = {\n @tailrec\n def calcDataSizeAux(k: Int) : Int = {\n if(k >= n) k\n else calcDataSizeAux(k*2)\n }\n calcDataSizeAux(1)\n }\n override def toString() = data.foldLeft(\"[\")(_ + \",\" + _) + \"]\"\n }\n class RangeSumQueryTree[T: ClassTag](n: Int)(implicit num: Numeric[T])\n extends ASegmentTree[T](n) {\n override val init = num.zero\n override def calc(left: T, right: T) = num.plus(left,right)\n }\n}\n\n// Document: http://www.scala-lang.org/api/current/#package\n// -----------------------------------------------------------------------------\nimport net.pushl.datastructure.RangeSumQueryTree\nclass Solver(val stdio: MyConsole){\n import stdio._ // shadow Console.~\n def main() : Unit = {\n val n,q = nextInt\n val rsq = new RangeSumQueryTree[Int](n)\n for(i <- 1 to q){\n val com,_x,_y = nextInt\n if(com == 0){\n val (x,y) = (_x-1,_y)\n rsq(x) = rsq.get(x,x+1) + y\n } else {\n val (x,y) = (_x-1,_y-1)\n println(rsq.get(x,y+1))\n }\n }\n }\n}\n\n\n\n\n\n\n\n\n\n// ----------------------------------------------------------------------------0\n// ----------------------------------------------------------------------------0\nobject Main {\n def main(args: Array[String]) : Unit = {\n val console = new MyConsole(Console.in, Console.out, Console.err)\n val solver = new Solver(console)\n solver.main()\n console.flush()\n }\n}\npackage net.pushl.io {\n import java.io.{BufferedReader, PrintWriter, PrintStream, PushbackReader}\n class MyConsole(val in: BufferedReader, val _out: PrintStream,\n val err: PrintStream) {\n // PrintWriter do not flush automatically\n val out = new PrintWriter(_out,false)\n // If argument is null, there are ambiguous which function will be called\n def print(obj: Any) = out.print(if(obj == null) \"null\" else obj.toString)\n def println() = out.println()\n def println(obj: Any) = out.println(obj)\n def printf(text: String, args: Any*) = out.printf(text.format(args : _*))\n // NOTE: YOU MUST FLUSH BEFORE END OF MAIN\n def flush() = out.flush()\n def debugln(obj: Any) = err.println(obj)\n\n def readIntVector() : Vector[Int] = parseLineToVector(() => nextInt)\n def readLongVector() : Vector[Long] = parseLineToVector(() => nextLong)\n def readStringVector() : Vector[String] = parseLineToVector(() => nextString)\n def nextInt() : Int = nextLong().toInt\n def nextBigInt() : BigInt = BigInt(nextString())\n def nextBigDecimal( ) : BigDecimal = BigDecimal(nextString())\n def nextDouble() : Double = nextString().toDouble\n def nextLong() : Long = {\n if(!goNextValuable())\n throw new NoSuchElementException(\"Reading long failed\")\n val sgn = if(peek == '-') -1l else 1\n if(sgn == -1l) read()\n if(peek < '0' || '9' < peek)\n throw new NumberFormatException(s\"readLong found only '-' or no number\")\n @tailrec\n def readLong(next: Int, cur: Long) : Long =\n if('0' <= next && next <= '9')\n readLong(readWithoutCheckingPeeked(), cur*10 + next-'0')\n else if(isEnd(next) || isSpaceOrControl(next))\n sgn*cur\n else\n throw new NumberFormatException(s\"readLong found strange byte $next\")\n val res = readLong(read(),0)\n skipTrailingSpaces()\n res\n }\n def nextString() : String = {\n if(!goNextValuable())\n throw new NoSuchElementException(\"Reading String failed\")\n val builder = new StringBuilder\n @tailrec\n def appendCode(next: Int) : String = {\n if(isEnd(next) || isSpaceOrControl(next)){\n builder.toString\n }else{\n builder.append(next.toChar)\n appendCode(readWithoutCheckingPeeked())\n }\n }\n val res = appendCode(read())\n skipTrailingSpaces()\n res\n }\n // TODO: refactoring to marge nextString\n def readLine() : String = {\n if(isEnd(peek))\n throw new NoSuchElementException(\"Reading Line failed\")\n val builder = new StringBuilder\n @tailrec\n def appendCode(next: Int) : String = {\n if(isEnd(next) || isNewLine(next)){\n builder.toString\n }else{\n builder.append(next.toChar)\n appendCode(read())\n }\n }\n appendCode(read())\n }\n // helpers\n private[this] var peeked: Option[Int] = None\n private[this] var last = -1\n private def read() = {\n val res = peeked match {\n case None => in.read()\n case Some(a) => { peeked = None; a }\n }\n last = res\n res\n }\n @inline private def readWithoutCheckingPeeked() = {\n val res = in.read()\n last = res\n res\n }\n @inline private def peek() =\n peeked match {\n case None => {\n val res = in.read()\n peeked = Some(res)\n res\n }\n case Some(a) => a\n }\n @inline private def isEnd(c: Int) = c == -1\n @inline private def isNewLine(c: Int) = c == 10 || c == 13 // LF and CR\n @inline private def isThereReadable() = !isEnd(peek)\n // XXX: this limits c is ASCII?\n @inline private def isSpaceOrControl(c: Int) = (0 <= c && c <= 32) || c == 127\n @tailrec\n final private def goNextNotSpaceNorControl() : Unit =\n if(isSpaceOrControl(peek)){\n read()\n goNextNotSpaceNorControl()\n }\n final private def skipTrailingSpaces() : Unit = {\n @tailrec\n def skipTrailingSpacesAux() : Unit = {\n if(!isNewLine(last) && !isNewLine(peek) && isSpaceOrControl(peek)){\n read()\n skipTrailingSpacesAux()\n }\n }\n skipTrailingSpacesAux\n if(!isNewLine(last) && isNewLine(peek)) {\n val _ = read()\n }\n }\n @tailrec\n final private def skipTrailingSpacesAndNewline() : Unit =\n if(isNewLine(peek)){\n val _ = read() // windows causes error. maybe.\n }else if(isSpaceOrControl(peek)){\n read()\n skipTrailingSpacesAndNewline()\n }\n @inline private def goNextValuable() = {\n goNextNotSpaceNorControl()\n isThereReadable()\n }\n @inline private def parseLineToVector[X](parser: () => X) : Vector[X] = {\n import scala.collection.immutable.VectorBuilder\n val vb = new VectorBuilder[X]()\n @tailrec\n def parseLineToVectorAux(first: Boolean=false) : Vector[X] =\n if((!first && isNewLine(last)) || isNewLine(peek) || isEnd(peek)) {\n vb.result\n }else{\n vb += parser()\n parseLineToVectorAux()\n }\n parseLineToVectorAux(true)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1437414099, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02346.html", "problem_id": "p02346", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02346/input.txt", "sample_output_relpath": "derived/input_output/data/p02346/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02346/Scala/s485649494.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s485649494", "user_id": "u636586431"}, "prompt_components": {"gold_output": "3\n2\n", "input_to_evaluate": "import scala.annotation.tailrec\nimport net.pushl.io.MyConsole\n\npackage net.pushl {\n package number {\n // Prime (Prime.scala)\n // Number (Number.scala)\n // Combi (Combi.scala)\n // Optimize (Optimize.scala)\n }\n package string {\n // RollingHash (RollingHash.scala)\n }\n package geometry {\n // Point (Geometry.scala)\n // Segment (Geometry.scala)\n // Line (Geometry.scala)\n }\n package datastructure {\n // UnionFindTree (UnionFind.scala)\n }\n package io {\n }\n}\n\n\npackage net.pushl.datastructure {\n import scala.reflect.ClassTag\n abstract class ASegmentTree[T: ClassTag](_n: Int) {\n protected val init: T\n protected def calc(left: T, right: T): T\n private val n = calcDataSize(_n)\n private val data = {\n val d = implicitly[ClassTag[T]].newArray(2*n-1)\n (0 until n).foreach(d(_) = init)\n d\n }\n // Array.fill[implicitly[ClassTag[T]]](calcDataSize(n))(init)\n\n def update(i: Int, v: T) : Unit = {\n val k = i+n-1\n data(k) = v\n @tailrec\n def updateAux(k: Int) : Unit =\n if(k > 0) {\n val p = parent(k)\n data(p) = calc(data(getLeft(p)),data(getRight(p)))\n updateAux(p)\n }\n updateAux(k)\n }\n // get data of [a,b)\n def get(a: Int, b: Int) : T = get(a,b,0,0,n)\n\n // l,r is segment of node k.\n private def get(a: Int, b: Int, k: Int, l: Int, r: Int) : T = {\n if(r <= a || b <= l) init\n else if(a <= l && r <= b) data(k)\n else calc(get(a,b,getLeft(k) ,l,(l+r)/2),\n get(a,b,getRight(k),(l+r)/2,r))\n }\n\n final private def getLeft (i: Int) = 2*i+1\n final private def getRight(i: Int) = 2*i+2\n final private def parent (i: Int) = (i-1)/2\n final private def calcDataSize(n: Int) = {\n @tailrec\n def calcDataSizeAux(k: Int) : Int = {\n if(k >= n) k\n else calcDataSizeAux(k*2)\n }\n calcDataSizeAux(1)\n }\n override def toString() = data.foldLeft(\"[\")(_ + \",\" + _) + \"]\"\n }\n class RangeSumQueryTree[T: ClassTag](n: Int)(implicit num: Numeric[T])\n extends ASegmentTree[T](n) {\n override val init = num.zero\n override def calc(left: T, right: T) = num.plus(left,right)\n }\n}\n\n// Document: http://www.scala-lang.org/api/current/#package\n// -----------------------------------------------------------------------------\nimport net.pushl.datastructure.RangeSumQueryTree\nclass Solver(val stdio: MyConsole){\n import stdio._ // shadow Console.~\n def main() : Unit = {\n val n,q = nextInt\n val rsq = new RangeSumQueryTree[Int](n)\n for(i <- 1 to q){\n val com,_x,_y = nextInt\n if(com == 0){\n val (x,y) = (_x-1,_y)\n rsq(x) = rsq.get(x,x+1) + y\n } else {\n val (x,y) = (_x-1,_y-1)\n println(rsq.get(x,y+1))\n }\n }\n }\n}\n\n\n\n\n\n\n\n\n\n// ----------------------------------------------------------------------------0\n// ----------------------------------------------------------------------------0\nobject Main {\n def main(args: Array[String]) : Unit = {\n val console = new MyConsole(Console.in, Console.out, Console.err)\n val solver = new Solver(console)\n solver.main()\n console.flush()\n }\n}\npackage net.pushl.io {\n import java.io.{BufferedReader, PrintWriter, PrintStream, PushbackReader}\n class MyConsole(val in: BufferedReader, val _out: PrintStream,\n val err: PrintStream) {\n // PrintWriter do not flush automatically\n val out = new PrintWriter(_out,false)\n // If argument is null, there are ambiguous which function will be called\n def print(obj: Any) = out.print(if(obj == null) \"null\" else obj.toString)\n def println() = out.println()\n def println(obj: Any) = out.println(obj)\n def printf(text: String, args: Any*) = out.printf(text.format(args : _*))\n // NOTE: YOU MUST FLUSH BEFORE END OF MAIN\n def flush() = out.flush()\n def debugln(obj: Any) = err.println(obj)\n\n def readIntVector() : Vector[Int] = parseLineToVector(() => nextInt)\n def readLongVector() : Vector[Long] = parseLineToVector(() => nextLong)\n def readStringVector() : Vector[String] = parseLineToVector(() => nextString)\n def nextInt() : Int = nextLong().toInt\n def nextBigInt() : BigInt = BigInt(nextString())\n def nextBigDecimal( ) : BigDecimal = BigDecimal(nextString())\n def nextDouble() : Double = nextString().toDouble\n def nextLong() : Long = {\n if(!goNextValuable())\n throw new NoSuchElementException(\"Reading long failed\")\n val sgn = if(peek == '-') -1l else 1\n if(sgn == -1l) read()\n if(peek < '0' || '9' < peek)\n throw new NumberFormatException(s\"readLong found only '-' or no number\")\n @tailrec\n def readLong(next: Int, cur: Long) : Long =\n if('0' <= next && next <= '9')\n readLong(readWithoutCheckingPeeked(), cur*10 + next-'0')\n else if(isEnd(next) || isSpaceOrControl(next))\n sgn*cur\n else\n throw new NumberFormatException(s\"readLong found strange byte $next\")\n val res = readLong(read(),0)\n skipTrailingSpaces()\n res\n }\n def nextString() : String = {\n if(!goNextValuable())\n throw new NoSuchElementException(\"Reading String failed\")\n val builder = new StringBuilder\n @tailrec\n def appendCode(next: Int) : String = {\n if(isEnd(next) || isSpaceOrControl(next)){\n builder.toString\n }else{\n builder.append(next.toChar)\n appendCode(readWithoutCheckingPeeked())\n }\n }\n val res = appendCode(read())\n skipTrailingSpaces()\n res\n }\n // TODO: refactoring to marge nextString\n def readLine() : String = {\n if(isEnd(peek))\n throw new NoSuchElementException(\"Reading Line failed\")\n val builder = new StringBuilder\n @tailrec\n def appendCode(next: Int) : String = {\n if(isEnd(next) || isNewLine(next)){\n builder.toString\n }else{\n builder.append(next.toChar)\n appendCode(read())\n }\n }\n appendCode(read())\n }\n // helpers\n private[this] var peeked: Option[Int] = None\n private[this] var last = -1\n private def read() = {\n val res = peeked match {\n case None => in.read()\n case Some(a) => { peeked = None; a }\n }\n last = res\n res\n }\n @inline private def readWithoutCheckingPeeked() = {\n val res = in.read()\n last = res\n res\n }\n @inline private def peek() =\n peeked match {\n case None => {\n val res = in.read()\n peeked = Some(res)\n res\n }\n case Some(a) => a\n }\n @inline private def isEnd(c: Int) = c == -1\n @inline private def isNewLine(c: Int) = c == 10 || c == 13 // LF and CR\n @inline private def isThereReadable() = !isEnd(peek)\n // XXX: this limits c is ASCII?\n @inline private def isSpaceOrControl(c: Int) = (0 <= c && c <= 32) || c == 127\n @tailrec\n final private def goNextNotSpaceNorControl() : Unit =\n if(isSpaceOrControl(peek)){\n read()\n goNextNotSpaceNorControl()\n }\n final private def skipTrailingSpaces() : Unit = {\n @tailrec\n def skipTrailingSpacesAux() : Unit = {\n if(!isNewLine(last) && !isNewLine(peek) && isSpaceOrControl(peek)){\n read()\n skipTrailingSpacesAux()\n }\n }\n skipTrailingSpacesAux\n if(!isNewLine(last) && isNewLine(peek)) {\n val _ = read()\n }\n }\n @tailrec\n final private def skipTrailingSpacesAndNewline() : Unit =\n if(isNewLine(peek)){\n val _ = read() // windows causes error. maybe.\n }else if(isSpaceOrControl(peek)){\n read()\n skipTrailingSpacesAndNewline()\n }\n @inline private def goNextValuable() = {\n goNextNotSpaceNorControl()\n isThereReadable()\n }\n @inline private def parseLineToVector[X](parser: () => X) : Vector[X] = {\n import scala.collection.immutable.VectorBuilder\n val vb = new VectorBuilder[X]()\n @tailrec\n def parseLineToVectorAux(first: Boolean=false) : Vector[X] =\n if((!first && isNewLine(last)) || isNewLine(peek) || isEnd(peek)) {\n vb.result\n }else{\n vb += parser()\n parseLineToVectorAux()\n }\n parseLineToVectorAux(true)\n }\n }\n}", "problem_context": "Range Sum Query\n\nWrite a program which manipulates a sequence A = {a1, a2, . . . , an} with the following operations:\n\nadd(i, x): add x to ai.\n\ngetSum(s, t): print the sum of as, as+1,...,at.\n\nNote that the initial values of ai (i = 1, 2, . . . , n) are 0.\n\nInput\n\nn q\ncom1 x1 y1\ncom2 x2 y2\n...\ncomq xq yq\n\nIn the first line, n (the number of elements in A) and q (the number of queries) are given. Then, q queries are given where com represents the type of queries. '0' denotes add(xi, yi) and '1' denotes getSum(xi, yi).\n\nOutput\n\nFor each getSum operation, print the sum in a line.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n1 ≤ q ≤ 100000\n\nIf comi is 0, then 1 ≤ xi ≤ n, 0 ≤ yi ≤ 1000.\n\nIf comi is 1, then 1 ≤ xi ≤ n, 1 ≤ yi ≤ n.\n\nSample Input 1\n\n3 5\n0 1 1\n0 2 2\n0 3 3\n1 1 2\n1 2 2\n\nSample Output 1\n\n3\n2", "sample_input": "3 5\n0 1 1\n0 2 2\n0 3 3\n1 1 2\n1 2 2\n"}, "reference_outputs": ["3\n2\n"], "source_document_id": "p02346", "source_text": "Range Sum Query\n\nWrite a program which manipulates a sequence A = {a1, a2, . . . , an} with the following operations:\n\nadd(i, x): add x to ai.\n\ngetSum(s, t): print the sum of as, as+1,...,at.\n\nNote that the initial values of ai (i = 1, 2, . . . , n) are 0.\n\nInput\n\nn q\ncom1 x1 y1\ncom2 x2 y2\n...\ncomq xq yq\n\nIn the first line, n (the number of elements in A) and q (the number of queries) are given. Then, q queries are given where com represents the type of queries. '0' denotes add(xi, yi) and '1' denotes getSum(xi, yi).\n\nOutput\n\nFor each getSum operation, print the sum in a line.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n1 ≤ q ≤ 100000\n\nIf comi is 0, then 1 ≤ xi ≤ n, 0 ≤ yi ≤ 1000.\n\nIf comi is 1, then 1 ≤ xi ≤ n, 1 ≤ yi ≤ n.\n\nSample Input 1\n\n3 5\n0 1 1\n0 2 2\n0 3 3\n1 1 2\n1 2 2\n\nSample Output 1\n\n3\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 8522, "cpu_time_ms": 780, "memory_kb": 163924}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s175714211", "group_id": "codeNet:p02346", "input_text": "import scala.annotation.tailrec\nimport net.pushl.io.MyConsole\n\npackage net.pushl.datastructure {\n import scala.reflect.ClassTag\n abstract class ASegmentTree[T: ClassTag](_n: Int) {\n protected val init: T\n protected def calc(left: T, right: T): T\n private val n = smallest2Powered(_n)\n private val data = {\n val d = implicitly[ClassTag[T]].newArray(2*n-1)\n (0 until n).foreach(d(_) = init)\n d\n }\n def update(i: Int, v: T) : Unit = {\n val k = i+n-1\n data(k) = v\n @tailrec\n def updateAux(k: Int) : Unit =\n if(k > 0) {\n val p = parent(k)\n data(p) = calc(data(getLeft(p)),data(getRight(p)))\n updateAux(p)\n }\n updateAux(k)\n }\n // get data of [a,b)\n def get(a: Int, b: Int) : T = get(a,b,0,0,n)\n\n // l,r is segment of node k.\n protected def get(a: Int, b: Int, k: Int, l: Int, r: Int) : T = {\n if(r <= a || b <= l) init\n else if(a <= l && r <= b) data(k)\n else calc(get(a,b,getLeft(k) ,l,(l+r)/2),\n get(a,b,getRight(k),(l+r)/2,r))\n }\n\n final private def getLeft (i: Int) = 2*i+1\n final private def getRight(i: Int) = 2*i+2\n final private def parent (i: Int) = (i-1)/2\n final private def smallest2Powered(n: Int) = {\n @tailrec\n def smallest2PoweredAux(k: Int) : Int = {\n if(k >= n) k\n else smallest2PoweredAux(k*2)\n }\n smallest2PoweredAux(1)\n }\n override def toString() = data.foldLeft(\"[\")(_ + \",\" + _) + \"]\"\n }\n class RangeSumQueryTree[T: ClassTag](n: Int)(implicit num: Numeric[T])\n extends ASegmentTree[T](n) {\n override val init = num.zero\n override def calc(left: T, right: T) = num.plus(left,right)\n }\n // Numeric does not have INF.\n class RangeMinimumQueryTree(n: Int) extends ASegmentTree[Long](n) {\n override val init = 1l << 30\n override def calc(left: Long, right: Long) = left min right\n }\n}\n\n// Document: http://www.scala-lang.org/api/current/#package\n// -----------------------------------------------------------------------------\nimport net.pushl.datastructure.RangeSumQueryTree\nclass Solver(val stdio: MyConsole){\n import stdio._ // shadow Console.~\n def main() : Unit = {\n val n,q = nextInt\n val rsq = new RangeSumQueryTree[Int](n)\n for(i <- 1 to q){\n val com,_x,_y = nextInt\n if(com == 0){\n val (x,y) = (_x-1,_y)\n rsq(x) = rsq.get(x,x+1) + y\n } else {\n val (x,y) = (_x-1,_y-1)\n println(rsq.get(x,y+1))\n }\n }\n }\n}\n\n\n\n\n\n\n\n\n\n// -----------------------------------------------------------------------------\n// -----------------------------------------------------------------------------\nobject Main {\n def main(args: Array[String]) : Unit = {\n val console = new MyConsole(Console.in, Console.out, Console.err)\n val solver = new Solver(console)\n solver.main()\n console.flush()\n }\n}\npackage net.pushl.io {\n import java.io.{BufferedReader, PrintWriter, PrintStream, PushbackReader}\n class MyConsole(val in: BufferedReader, val _out: PrintStream,\n val err: PrintStream) {\n // PrintWriter do not flush automatically\n val out = new PrintWriter(_out,false)\n // If argument is null, there are ambiguous which function will be called\n def print(obj: Any) = out.print(if(obj == null) \"null\" else obj.toString)\n def println() = out.println()\n def println(obj: Any) = out.println(obj)\n def printf(text: String, args: Any*) = out.printf(text.format(args : _*))\n // NOTE: YOU MUST FLUSH BEFORE END OF MAIN\n def flush() = out.flush()\n def debugln(obj: Any) = err.println(\"\\u001b[36m\" + obj + \"\\u001b[0m\")\n\n def readIntVector() : Vector[Int] = parseLineToVector(() => nextInt)\n def readLongVector() : Vector[Long] = parseLineToVector(() => nextLong)\n def readStringVector() : Vector[String] = parseLineToVector(() => nextString)\n def nextInt() : Int = nextLong().toInt\n def nextBigInt() : BigInt = BigInt(nextString())\n def nextBigDecimal( ) : BigDecimal = BigDecimal(nextString())\n def nextDouble() : Double = nextString().toDouble\n def nextLong() : Long = {\n if(!goNextValuable())\n throw new NoSuchElementException(\"Reading long failed\")\n val sgn = if(peek == '-') -1l else 1\n if(sgn == -1l) ignore(read())\n if(peek < '0' || '9' < peek)\n throw new NumberFormatException(s\"readLong found only '-' or no number\")\n @tailrec\n def readLong(next: Int, cur: Long) : Long =\n if('0' <= next && next <= '9'){\n ignore(read()) // is equal to next\n readLong(peek, cur*10 + next-'0')\n }\n else if(isEnd(next) || isSpaceOrControl(next))\n sgn*cur\n else\n throw new NumberFormatException(s\"readLong found strange byte $next\")\n val res = readLong(peek,0)\n skipTrailingSpaces()\n res\n }\n def nextString() : String = {\n if(!goNextValuable())\n throw new NoSuchElementException(\"Reading String failed\")\n val builder = new StringBuilder\n @tailrec\n def appendCode(next: Int) : String = {\n if(isEnd(next) || isSpaceOrControl(next)){\n builder.toString\n }else{\n builder.append(read().toChar) // here we skip.\n appendCode(peek)\n }\n }\n val res = appendCode(peek)\n skipTrailingSpaces()\n res\n }\n // TODO: refactoring to marge nextString\n def readLine() : String = {\n if(isEnd(peek))\n throw new NoSuchElementException(\"Reading Line failed\")\n skipNewline()\n val builder = new StringBuilder\n @tailrec\n def appendCode(next: Int) : String = {\n if(isEnd(next) || isNewLine(next)){\n builder.toString\n }else{\n builder.append(next.toChar)\n appendCode(read())\n }\n }\n appendCode(read())\n }\n // helpers\n private def ignore[T](x: => T) : Unit = { x; () }\n private[this] var peeked: Option[Int] = None\n private[this] var is_first = true\n protected def read() = {\n val res = peeked match {\n case None => in.read()\n case Some(a) => { peeked = None; a }\n }\n is_first = false\n res\n }\n private def peek() =\n peeked match {\n case None => {\n val res = in.read()\n peeked = Some(res)\n res\n }\n case Some(a) => a\n }\n private def isEnd(c: Int) = c == -1\n private def isCR(c: Int) = c == 13\n private def isLF(c: Int) = c == 10\n private def isNewLine(c: Int) = isLF(c) || isCR(c)\n private def isThereReadable() = !isEnd(peek)\n private def isSpaceOrControl(c: Int) = (0 <= c && c <= 32) || c == 127\n @tailrec\n final private def goNextNotSpaceNorControl() : Unit =\n if(isSpaceOrControl(peek)){\n ignore(read())\n goNextNotSpaceNorControl()\n }\n final private def skipTrailingSpaces() : Unit = {\n @tailrec\n def skipTrailingSpacesAux() : Unit = {\n if(!isNewLine(peek) && isSpaceOrControl(peek)){\n ignore(read())\n skipTrailingSpacesAux()\n }\n }\n skipTrailingSpacesAux()\n }\n final private def skipNewline() : Unit =\n if(!is_first){\n if(isCR(peek))\n ignore(read())\n if(isLF(peek))\n ignore(read())\n }\n private def goNextValuable() : Boolean = {\n goNextNotSpaceNorControl()\n isThereReadable()\n }\n\n private def parseLineToVector[X](parser: () => X) : Vector[X] = {\n import scala.collection.immutable.VectorBuilder\n val vb = new VectorBuilder[X]()\n skipNewline()\n @tailrec\n def parseLineToVectorAux() : Vector[X] =\n if(isNewLine(peek) || isEnd(peek)) {\n vb.result\n }else{\n vb += parser()\n parseLineToVectorAux()\n }\n parseLineToVectorAux()\n }\n }\n}", "language": "Scala", "metadata": {"date": 1440511403, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02346.html", "problem_id": "p02346", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02346/input.txt", "sample_output_relpath": "derived/input_output/data/p02346/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02346/Scala/s175714211.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s175714211", "user_id": "u636586431"}, "prompt_components": {"gold_output": "3\n2\n", "input_to_evaluate": "import scala.annotation.tailrec\nimport net.pushl.io.MyConsole\n\npackage net.pushl.datastructure {\n import scala.reflect.ClassTag\n abstract class ASegmentTree[T: ClassTag](_n: Int) {\n protected val init: T\n protected def calc(left: T, right: T): T\n private val n = smallest2Powered(_n)\n private val data = {\n val d = implicitly[ClassTag[T]].newArray(2*n-1)\n (0 until n).foreach(d(_) = init)\n d\n }\n def update(i: Int, v: T) : Unit = {\n val k = i+n-1\n data(k) = v\n @tailrec\n def updateAux(k: Int) : Unit =\n if(k > 0) {\n val p = parent(k)\n data(p) = calc(data(getLeft(p)),data(getRight(p)))\n updateAux(p)\n }\n updateAux(k)\n }\n // get data of [a,b)\n def get(a: Int, b: Int) : T = get(a,b,0,0,n)\n\n // l,r is segment of node k.\n protected def get(a: Int, b: Int, k: Int, l: Int, r: Int) : T = {\n if(r <= a || b <= l) init\n else if(a <= l && r <= b) data(k)\n else calc(get(a,b,getLeft(k) ,l,(l+r)/2),\n get(a,b,getRight(k),(l+r)/2,r))\n }\n\n final private def getLeft (i: Int) = 2*i+1\n final private def getRight(i: Int) = 2*i+2\n final private def parent (i: Int) = (i-1)/2\n final private def smallest2Powered(n: Int) = {\n @tailrec\n def smallest2PoweredAux(k: Int) : Int = {\n if(k >= n) k\n else smallest2PoweredAux(k*2)\n }\n smallest2PoweredAux(1)\n }\n override def toString() = data.foldLeft(\"[\")(_ + \",\" + _) + \"]\"\n }\n class RangeSumQueryTree[T: ClassTag](n: Int)(implicit num: Numeric[T])\n extends ASegmentTree[T](n) {\n override val init = num.zero\n override def calc(left: T, right: T) = num.plus(left,right)\n }\n // Numeric does not have INF.\n class RangeMinimumQueryTree(n: Int) extends ASegmentTree[Long](n) {\n override val init = 1l << 30\n override def calc(left: Long, right: Long) = left min right\n }\n}\n\n// Document: http://www.scala-lang.org/api/current/#package\n// -----------------------------------------------------------------------------\nimport net.pushl.datastructure.RangeSumQueryTree\nclass Solver(val stdio: MyConsole){\n import stdio._ // shadow Console.~\n def main() : Unit = {\n val n,q = nextInt\n val rsq = new RangeSumQueryTree[Int](n)\n for(i <- 1 to q){\n val com,_x,_y = nextInt\n if(com == 0){\n val (x,y) = (_x-1,_y)\n rsq(x) = rsq.get(x,x+1) + y\n } else {\n val (x,y) = (_x-1,_y-1)\n println(rsq.get(x,y+1))\n }\n }\n }\n}\n\n\n\n\n\n\n\n\n\n// -----------------------------------------------------------------------------\n// -----------------------------------------------------------------------------\nobject Main {\n def main(args: Array[String]) : Unit = {\n val console = new MyConsole(Console.in, Console.out, Console.err)\n val solver = new Solver(console)\n solver.main()\n console.flush()\n }\n}\npackage net.pushl.io {\n import java.io.{BufferedReader, PrintWriter, PrintStream, PushbackReader}\n class MyConsole(val in: BufferedReader, val _out: PrintStream,\n val err: PrintStream) {\n // PrintWriter do not flush automatically\n val out = new PrintWriter(_out,false)\n // If argument is null, there are ambiguous which function will be called\n def print(obj: Any) = out.print(if(obj == null) \"null\" else obj.toString)\n def println() = out.println()\n def println(obj: Any) = out.println(obj)\n def printf(text: String, args: Any*) = out.printf(text.format(args : _*))\n // NOTE: YOU MUST FLUSH BEFORE END OF MAIN\n def flush() = out.flush()\n def debugln(obj: Any) = err.println(\"\\u001b[36m\" + obj + \"\\u001b[0m\")\n\n def readIntVector() : Vector[Int] = parseLineToVector(() => nextInt)\n def readLongVector() : Vector[Long] = parseLineToVector(() => nextLong)\n def readStringVector() : Vector[String] = parseLineToVector(() => nextString)\n def nextInt() : Int = nextLong().toInt\n def nextBigInt() : BigInt = BigInt(nextString())\n def nextBigDecimal( ) : BigDecimal = BigDecimal(nextString())\n def nextDouble() : Double = nextString().toDouble\n def nextLong() : Long = {\n if(!goNextValuable())\n throw new NoSuchElementException(\"Reading long failed\")\n val sgn = if(peek == '-') -1l else 1\n if(sgn == -1l) ignore(read())\n if(peek < '0' || '9' < peek)\n throw new NumberFormatException(s\"readLong found only '-' or no number\")\n @tailrec\n def readLong(next: Int, cur: Long) : Long =\n if('0' <= next && next <= '9'){\n ignore(read()) // is equal to next\n readLong(peek, cur*10 + next-'0')\n }\n else if(isEnd(next) || isSpaceOrControl(next))\n sgn*cur\n else\n throw new NumberFormatException(s\"readLong found strange byte $next\")\n val res = readLong(peek,0)\n skipTrailingSpaces()\n res\n }\n def nextString() : String = {\n if(!goNextValuable())\n throw new NoSuchElementException(\"Reading String failed\")\n val builder = new StringBuilder\n @tailrec\n def appendCode(next: Int) : String = {\n if(isEnd(next) || isSpaceOrControl(next)){\n builder.toString\n }else{\n builder.append(read().toChar) // here we skip.\n appendCode(peek)\n }\n }\n val res = appendCode(peek)\n skipTrailingSpaces()\n res\n }\n // TODO: refactoring to marge nextString\n def readLine() : String = {\n if(isEnd(peek))\n throw new NoSuchElementException(\"Reading Line failed\")\n skipNewline()\n val builder = new StringBuilder\n @tailrec\n def appendCode(next: Int) : String = {\n if(isEnd(next) || isNewLine(next)){\n builder.toString\n }else{\n builder.append(next.toChar)\n appendCode(read())\n }\n }\n appendCode(read())\n }\n // helpers\n private def ignore[T](x: => T) : Unit = { x; () }\n private[this] var peeked: Option[Int] = None\n private[this] var is_first = true\n protected def read() = {\n val res = peeked match {\n case None => in.read()\n case Some(a) => { peeked = None; a }\n }\n is_first = false\n res\n }\n private def peek() =\n peeked match {\n case None => {\n val res = in.read()\n peeked = Some(res)\n res\n }\n case Some(a) => a\n }\n private def isEnd(c: Int) = c == -1\n private def isCR(c: Int) = c == 13\n private def isLF(c: Int) = c == 10\n private def isNewLine(c: Int) = isLF(c) || isCR(c)\n private def isThereReadable() = !isEnd(peek)\n private def isSpaceOrControl(c: Int) = (0 <= c && c <= 32) || c == 127\n @tailrec\n final private def goNextNotSpaceNorControl() : Unit =\n if(isSpaceOrControl(peek)){\n ignore(read())\n goNextNotSpaceNorControl()\n }\n final private def skipTrailingSpaces() : Unit = {\n @tailrec\n def skipTrailingSpacesAux() : Unit = {\n if(!isNewLine(peek) && isSpaceOrControl(peek)){\n ignore(read())\n skipTrailingSpacesAux()\n }\n }\n skipTrailingSpacesAux()\n }\n final private def skipNewline() : Unit =\n if(!is_first){\n if(isCR(peek))\n ignore(read())\n if(isLF(peek))\n ignore(read())\n }\n private def goNextValuable() : Boolean = {\n goNextNotSpaceNorControl()\n isThereReadable()\n }\n\n private def parseLineToVector[X](parser: () => X) : Vector[X] = {\n import scala.collection.immutable.VectorBuilder\n val vb = new VectorBuilder[X]()\n skipNewline()\n @tailrec\n def parseLineToVectorAux() : Vector[X] =\n if(isNewLine(peek) || isEnd(peek)) {\n vb.result\n }else{\n vb += parser()\n parseLineToVectorAux()\n }\n parseLineToVectorAux()\n }\n }\n}", "problem_context": "Range Sum Query\n\nWrite a program which manipulates a sequence A = {a1, a2, . . . , an} with the following operations:\n\nadd(i, x): add x to ai.\n\ngetSum(s, t): print the sum of as, as+1,...,at.\n\nNote that the initial values of ai (i = 1, 2, . . . , n) are 0.\n\nInput\n\nn q\ncom1 x1 y1\ncom2 x2 y2\n...\ncomq xq yq\n\nIn the first line, n (the number of elements in A) and q (the number of queries) are given. Then, q queries are given where com represents the type of queries. '0' denotes add(xi, yi) and '1' denotes getSum(xi, yi).\n\nOutput\n\nFor each getSum operation, print the sum in a line.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n1 ≤ q ≤ 100000\n\nIf comi is 0, then 1 ≤ xi ≤ n, 0 ≤ yi ≤ 1000.\n\nIf comi is 1, then 1 ≤ xi ≤ n, 1 ≤ yi ≤ n.\n\nSample Input 1\n\n3 5\n0 1 1\n0 2 2\n0 3 3\n1 1 2\n1 2 2\n\nSample Output 1\n\n3\n2", "sample_input": "3 5\n0 1 1\n0 2 2\n0 3 3\n1 1 2\n1 2 2\n"}, "reference_outputs": ["3\n2\n"], "source_document_id": "p02346", "source_text": "Range Sum Query\n\nWrite a program which manipulates a sequence A = {a1, a2, . . . , an} with the following operations:\n\nadd(i, x): add x to ai.\n\ngetSum(s, t): print the sum of as, as+1,...,at.\n\nNote that the initial values of ai (i = 1, 2, . . . , n) are 0.\n\nInput\n\nn q\ncom1 x1 y1\ncom2 x2 y2\n...\ncomq xq yq\n\nIn the first line, n (the number of elements in A) and q (the number of queries) are given. Then, q queries are given where com represents the type of queries. '0' denotes add(xi, yi) and '1' denotes getSum(xi, yi).\n\nOutput\n\nFor each getSum operation, print the sum in a line.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n1 ≤ q ≤ 100000\n\nIf comi is 0, then 1 ≤ xi ≤ n, 0 ≤ yi ≤ 1000.\n\nIf comi is 1, then 1 ≤ xi ≤ n, 1 ≤ yi ≤ n.\n\nSample Input 1\n\n3 5\n0 1 1\n0 2 2\n0 3 3\n1 1 2\n1 2 2\n\nSample Output 1\n\n3\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 8053, "cpu_time_ms": 1120, "memory_kb": 187356}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s268705385", "group_id": "codeNet:p02361", "input_text": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val INF = Int.MaxValue / 10\n val Vs, Es, root = sc.nextInt()\n val E = (0 until Es) map { _ =>\n val s, t, d = sc.nextInt()\n (s, t, d)\n }\n val W = Array.fill(Vs)(INF)\n W(root) = 0\n // ベルマンフォード, |V|-1回, 全ての辺を緩和させる\n (0 until Vs - 1) foreach { _ =>\n E foreach { case (u, v, w) =>\n if (W(v) > W(u) + w) {\n W(v) = W(u) + w\n }\n }\n }\n\n println(W. map { w =>\n if (w == INF) \"INF\" else w.toString\n }. mkString(\"\\n\"))\n }\n\n}\n\n", "language": "Scala", "metadata": {"date": 1559289225, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02361.html", "problem_id": "p02361", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02361/input.txt", "sample_output_relpath": "derived/input_output/data/p02361/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02361/Scala/s268705385.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s268705385", "user_id": "u389570999"}, "prompt_components": {"gold_output": "0\n1\n3\n4\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 INF = Int.MaxValue / 10\n val Vs, Es, root = sc.nextInt()\n val E = (0 until Es) map { _ =>\n val s, t, d = sc.nextInt()\n (s, t, d)\n }\n val W = Array.fill(Vs)(INF)\n W(root) = 0\n // ベルマンフォード, |V|-1回, 全ての辺を緩和させる\n (0 until Vs - 1) foreach { _ =>\n E foreach { case (u, v, w) =>\n if (W(v) > W(u) + w) {\n W(v) = W(u) + w\n }\n }\n }\n\n println(W. map { w =>\n if (w == INF) \"INF\" else w.toString\n }. mkString(\"\\n\"))\n }\n\n}\n\n", "problem_context": "Single Source Shortest Path\n\nFor a given weighted graph G(V, E) and a source r, find the source shortest path to each vertex from the source (SSSP: Single Source Shortest Path).\n\nInput\n\nAn edge-weighted graph G (V, E) and the source r.\n\n|V| |E| r\ns0 t0 d0\ns1 t1 d1\n:\ns|E|-1 t|E|-1 d|E|-1\n\n|V| is the number of vertices and |E| is the number of edges in G. The graph vertices are named with the numbers 0, 1,..., |V|-1 respectively. r is the source of the graph.\n\nsi and ti represent source and target vertices of i-th edge (directed) and di represents the cost of the i-th edge.\n\nOutput\n\nPrint the costs of SSSP in the following format.\n\nc0\nc1\n:\nc|V|-1\n\nThe output consists of |V| lines. Print the cost of the shortest path from the source r to each vertex 0, 1, ... |V|-1 in order. If there is no path from the source to a vertex, print INF.\n\nConstraints\n\n1 ≤ |V| ≤ 100000\n\n0 ≤ di ≤ 10000\n\n0 ≤ |E| ≤ 500000\n\nThere are no parallel edges\n\nThere are no self-loops\n\nSample Input 1\n\n4 5 0\n0 1 1\n0 2 4\n1 2 2\n2 3 1\n1 3 5\n\nSample Output 1\n\n0\n1\n3\n4\n\nSample Input 2\n\n4 6 1\n0 1 1\n0 2 4\n2 0 1\n1 2 2\n3 1 1\n3 2 5\n\nSample Output 2\n\n3\n0\n2\nINF", "sample_input": "4 5 0\n0 1 1\n0 2 4\n1 2 2\n2 3 1\n1 3 5\n"}, "reference_outputs": ["0\n1\n3\n4\n"], "source_document_id": "p02361", "source_text": "Single Source Shortest Path\n\nFor a given weighted graph G(V, E) and a source r, find the source shortest path to each vertex from the source (SSSP: Single Source Shortest Path).\n\nInput\n\nAn edge-weighted graph G (V, E) and the source r.\n\n|V| |E| r\ns0 t0 d0\ns1 t1 d1\n:\ns|E|-1 t|E|-1 d|E|-1\n\n|V| is the number of vertices and |E| is the number of edges in G. The graph vertices are named with the numbers 0, 1,..., |V|-1 respectively. r is the source of the graph.\n\nsi and ti represent source and target vertices of i-th edge (directed) and di represents the cost of the i-th edge.\n\nOutput\n\nPrint the costs of SSSP in the following format.\n\nc0\nc1\n:\nc|V|-1\n\nThe output consists of |V| lines. Print the cost of the shortest path from the source r to each vertex 0, 1, ... |V|-1 in order. If there is no path from the source to a vertex, print INF.\n\nConstraints\n\n1 ≤ |V| ≤ 100000\n\n0 ≤ di ≤ 10000\n\n0 ≤ |E| ≤ 500000\n\nThere are no parallel edges\n\nThere are no self-loops\n\nSample Input 1\n\n4 5 0\n0 1 1\n0 2 4\n1 2 2\n2 3 1\n1 3 5\n\nSample Output 1\n\n0\n1\n3\n4\n\nSample Input 2\n\n4 6 1\n0 1 1\n0 2 4\n2 0 1\n1 2 2\n3 1 1\n3 2 5\n\nSample Output 2\n\n3\n0\n2\nINF", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 638, "cpu_time_ms": 4560, "memory_kb": 105540}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s580222384", "group_id": "codeNet:p02361", "input_text": "object Main{\n class Edge(val from:Int,val to:Int,val cost:Long){}\n\n // v:????????°\n // s:?§????\n // graph:??£??\\?????????\n def dijkstra(v:Int,s:Int,graph:Array[Array[Edge]],inf:Long= Long.MaxValue / 10) : Array[Long] = {\n val d : Array[Long] = Array.fill(v)(inf)\n val que = new scala.collection.mutable.PriorityQueue[Tuple2[Long,Int]]()(Ordering.Tuple2[Long,Int].reverse)\n que += Tuple2(0,s)\n d(s) = 0\n while(que.nonEmpty){\n val (cost,node) = que.dequeue\n if(d(node) >= cost){\n for(e <- graph(node)){\n if(d(e.to) > d(node)+e.cost){\n d(e.to) = d(node)+e.cost\n que+=Tuple2(d(e.to),e.to)\n }\n }\n }\n }\n return d\n }\n\n def main(args : Array[String]){\n val inf = Long.MaxValue / 10\n val sc = new java.util.Scanner(System.in)\n val v,e,r = sc.nextInt\n val g : Array[Array[Edge]] = Array.fill(v)(Array.empty)\n\n for(i <- 0 to e-1){\n val s,t,d = sc.nextInt\n g(s) :+= new Edge(s,t,d)\n }\n\n val res = dijkstra(v,r,g,inf)\n res.foreach(x => if(x==inf) println(\"INF\") else println(x))\n }\n}", "language": "Scala", "metadata": {"date": 1514730117, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02361.html", "problem_id": "p02361", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02361/input.txt", "sample_output_relpath": "derived/input_output/data/p02361/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02361/Scala/s580222384.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s580222384", "user_id": "u371289566"}, "prompt_components": {"gold_output": "0\n1\n3\n4\n", "input_to_evaluate": "object Main{\n class Edge(val from:Int,val to:Int,val cost:Long){}\n\n // v:????????°\n // s:?§????\n // graph:??£??\\?????????\n def dijkstra(v:Int,s:Int,graph:Array[Array[Edge]],inf:Long= Long.MaxValue / 10) : Array[Long] = {\n val d : Array[Long] = Array.fill(v)(inf)\n val que = new scala.collection.mutable.PriorityQueue[Tuple2[Long,Int]]()(Ordering.Tuple2[Long,Int].reverse)\n que += Tuple2(0,s)\n d(s) = 0\n while(que.nonEmpty){\n val (cost,node) = que.dequeue\n if(d(node) >= cost){\n for(e <- graph(node)){\n if(d(e.to) > d(node)+e.cost){\n d(e.to) = d(node)+e.cost\n que+=Tuple2(d(e.to),e.to)\n }\n }\n }\n }\n return d\n }\n\n def main(args : Array[String]){\n val inf = Long.MaxValue / 10\n val sc = new java.util.Scanner(System.in)\n val v,e,r = sc.nextInt\n val g : Array[Array[Edge]] = Array.fill(v)(Array.empty)\n\n for(i <- 0 to e-1){\n val s,t,d = sc.nextInt\n g(s) :+= new Edge(s,t,d)\n }\n\n val res = dijkstra(v,r,g,inf)\n res.foreach(x => if(x==inf) println(\"INF\") else println(x))\n }\n}", "problem_context": "Single Source Shortest Path\n\nFor a given weighted graph G(V, E) and a source r, find the source shortest path to each vertex from the source (SSSP: Single Source Shortest Path).\n\nInput\n\nAn edge-weighted graph G (V, E) and the source r.\n\n|V| |E| r\ns0 t0 d0\ns1 t1 d1\n:\ns|E|-1 t|E|-1 d|E|-1\n\n|V| is the number of vertices and |E| is the number of edges in G. The graph vertices are named with the numbers 0, 1,..., |V|-1 respectively. r is the source of the graph.\n\nsi and ti represent source and target vertices of i-th edge (directed) and di represents the cost of the i-th edge.\n\nOutput\n\nPrint the costs of SSSP in the following format.\n\nc0\nc1\n:\nc|V|-1\n\nThe output consists of |V| lines. Print the cost of the shortest path from the source r to each vertex 0, 1, ... |V|-1 in order. If there is no path from the source to a vertex, print INF.\n\nConstraints\n\n1 ≤ |V| ≤ 100000\n\n0 ≤ di ≤ 10000\n\n0 ≤ |E| ≤ 500000\n\nThere are no parallel edges\n\nThere are no self-loops\n\nSample Input 1\n\n4 5 0\n0 1 1\n0 2 4\n1 2 2\n2 3 1\n1 3 5\n\nSample Output 1\n\n0\n1\n3\n4\n\nSample Input 2\n\n4 6 1\n0 1 1\n0 2 4\n2 0 1\n1 2 2\n3 1 1\n3 2 5\n\nSample Output 2\n\n3\n0\n2\nINF", "sample_input": "4 5 0\n0 1 1\n0 2 4\n1 2 2\n2 3 1\n1 3 5\n"}, "reference_outputs": ["0\n1\n3\n4\n"], "source_document_id": "p02361", "source_text": "Single Source Shortest Path\n\nFor a given weighted graph G(V, E) and a source r, find the source shortest path to each vertex from the source (SSSP: Single Source Shortest Path).\n\nInput\n\nAn edge-weighted graph G (V, E) and the source r.\n\n|V| |E| r\ns0 t0 d0\ns1 t1 d1\n:\ns|E|-1 t|E|-1 d|E|-1\n\n|V| is the number of vertices and |E| is the number of edges in G. The graph vertices are named with the numbers 0, 1,..., |V|-1 respectively. r is the source of the graph.\n\nsi and ti represent source and target vertices of i-th edge (directed) and di represents the cost of the i-th edge.\n\nOutput\n\nPrint the costs of SSSP in the following format.\n\nc0\nc1\n:\nc|V|-1\n\nThe output consists of |V| lines. Print the cost of the shortest path from the source r to each vertex 0, 1, ... |V|-1 in order. If there is no path from the source to a vertex, print INF.\n\nConstraints\n\n1 ≤ |V| ≤ 100000\n\n0 ≤ di ≤ 10000\n\n0 ≤ |E| ≤ 500000\n\nThere are no parallel edges\n\nThere are no self-loops\n\nSample Input 1\n\n4 5 0\n0 1 1\n0 2 4\n1 2 2\n2 3 1\n1 3 5\n\nSample Output 1\n\n0\n1\n3\n4\n\nSample Input 2\n\n4 6 1\n0 1 1\n0 2 4\n2 0 1\n1 2 2\n3 1 1\n3 2 5\n\nSample Output 2\n\n3\n0\n2\nINF", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1105, "cpu_time_ms": 2100, "memory_kb": 484944}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s314352065", "group_id": "codeNet:p02379", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val Array(x1, y1, x2, y2, _*) = io.StdIn.readLine().split(\" \").map(_.toDouble)\n\n val dx = Math.abs(x2 - x1)\n val dy = Math.abs(y2 - y1)\n val d = Math.sqrt(dx * dx + dy * dy)\n println(f\"$d%.8f\")\n }\n}", "language": "Scala", "metadata": {"date": 1489739076, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02379.html", "problem_id": "p02379", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02379/input.txt", "sample_output_relpath": "derived/input_output/data/p02379/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02379/Scala/s314352065.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s314352065", "user_id": "u959441351"}, "prompt_components": {"gold_output": "1.41421356\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val Array(x1, y1, x2, y2, _*) = io.StdIn.readLine().split(\" \").map(_.toDouble)\n\n val dx = Math.abs(x2 - x1)\n val dy = Math.abs(y2 - y1)\n val d = Math.sqrt(dx * dx + dy * dy)\n println(f\"$d%.8f\")\n }\n}", "problem_context": "Distance\n\nWrite a program which calculates the distance between two points P1(x1, y1) and P2(x2, y2).\n\nInput\n\nFour real numbers x1, y1, x2 and y2 are given in a line.\n\nOutput\n\nPrint the distance in real number. The output should not contain an absolute error greater than 10-4.\n\nSample Input\n\n0 0 1 1\n\nSample Output\n\n1.41421356", "sample_input": "0 0 1 1\n"}, "reference_outputs": ["1.41421356\n"], "source_document_id": "p02379", "source_text": "Distance\n\nWrite a program which calculates the distance between two points P1(x1, y1) and P2(x2, y2).\n\nInput\n\nFour real numbers x1, y1, x2 and y2 are given in a line.\n\nOutput\n\nPrint the distance in real number. The output should not contain an absolute error greater than 10-4.\n\nSample Input\n\n0 0 1 1\n\nSample Output\n\n1.41421356", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 271, "cpu_time_ms": 240, "memory_kb": 44216}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s722433538", "group_id": "codeNet:p02380", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val scanner = new java.util.Scanner(System.in)\n val a, b = scanner.nextDouble\n val ca = math.toRadians(scanner.nextDouble)\n\n val h = b * math.sin(ca)\n val s = a * h / 2\n val c = math.sqrt(a * a + b * b * math.sin(ca) * math.sin(ca))\n println(f\"$s%.5f\")\n println(f\"${a + b + c}%.5f\")\n println(f\"$h%.5f\")\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1523849929, "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/s722433538.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s722433538", "user_id": "u250696856"}, "prompt_components": {"gold_output": "6.00000000\n12.00000000\n3.00000000\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val scanner = new java.util.Scanner(System.in)\n val a, b = scanner.nextDouble\n val ca = math.toRadians(scanner.nextDouble)\n\n val h = b * math.sin(ca)\n val s = a * h / 2\n val c = math.sqrt(a * a + b * b * math.sin(ca) * math.sin(ca))\n println(f\"$s%.5f\")\n println(f\"${a + b + c}%.5f\")\n println(f\"$h%.5f\")\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 250, "memory_kb": 45700}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s289195359", "group_id": "codeNet:p02381", "input_text": "import java.util.Scanner\n\nobject Main {\n\n def solve(sc: => Scanner): Unit = {\n val N = sc.nextInt\n if (N != 0) {\n val A = Array.fill[Double](N)(sc.nextInt)\n val ave = A.sum / N: Double\n println(math.sqrt(A.map(X => (X - ave) * (X - ave)).sum / 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": 1505136616, "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/s289195359.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s289195359", "user_id": "u018134297"}, "prompt_components": {"gold_output": "27.85677655\n0.00000000\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n\n def solve(sc: => Scanner): Unit = {\n val N = sc.nextInt\n if (N != 0) {\n val A = Array.fill[Double](N)(sc.nextInt)\n val ave = A.sum / N: Double\n println(math.sqrt(A.map(X => (X - ave) * (X - ave)).sum / 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": "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 403, "cpu_time_ms": 320, "memory_kb": 49680}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s430632863", "group_id": "codeNet:p02381", "input_text": "object Main extends App {\n val in = io.Source.stdin.getLines.map(_.split(\" \").map(_.toInt))\n while (in.next.head != 0) {\n val x = in.next.foldLeft((0.0, 0.0, 0)){case ((m, mean, n), d) =>\n (m - ((d + n * mean) / (n + 1) - d) * (d - mean), mean + (d - mean) / (n + 1), n + 1)\n }\n println(math.sqrt(x._1 / x._3))\n }\n}", "language": "Scala", "metadata": {"date": 1505268817, "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/s430632863.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s430632863", "user_id": "u475394465"}, "prompt_components": {"gold_output": "27.85677655\n0.00000000\n", "input_to_evaluate": "object Main extends App {\n val in = io.Source.stdin.getLines.map(_.split(\" \").map(_.toInt))\n while (in.next.head != 0) {\n val x = in.next.foldLeft((0.0, 0.0, 0)){case ((m, mean, n), d) =>\n (m - ((d + n * mean) / (n + 1) - d) * (d - mean), mean + (d - mean) / (n + 1), n + 1)\n }\n println(math.sqrt(x._1 / x._3))\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 356, "cpu_time_ms": 250, "memory_kb": 44724}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s384143831", "group_id": "codeNet:p02385", "input_text": "import scala.io.StdIn.{readLine,readInt}\n/**\n * AOJ\n */\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n\n var dice1 = read\n val dice2 = read\n\n for(side <- dice1){\n if(!dice2.contains(side)){println(\"No\");return}\n }\n\n dice1 = findSide(dice2(4),4,\"HHH\",findSide(dice2(0),0,\"WNNNW\",dice1))\n println(\n dice1 match {\n case null => \"No\"\n case dice1 if((dice1 zip dice2).forall(x => x._1 == x._2)) => \"Yes\"\n case _ => \"No\"\n }\n )\n }\n\n def findSide(sideNum:Int, findSide:Int, searchCommands:String, dice:Array[Int]) : Array[Int] = {\n if(dice(findSide) == sideNum){return dice}\n var d = dice\n for(c <- searchCommands.toCharArray){\n d = getNextStatus(c,d)\n if(d(findSide) == sideNum){return d}\n }\n return null\n }\n\n def getNextStatus(cmd:Char,dice:Array[Int]): Array[Int] = cmd\n match {\n case 'N' => Array(dice(1),dice(5),dice(2),dice(3),dice(0),dice(4))\n case 'W' => Array(dice(2),dice(1),dice(5),dice(0),dice(4),dice(3))\n case 'H' => Array(dice(0),dice(3),dice(1),dice(4),dice(2),dice(5))\n }\n\n def read() : Array[Int] = {\n readLine().split(\" \").map(_.toInt)\n }\n}", "language": "Scala", "metadata": {"date": 1500203426, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02385.html", "problem_id": "p02385", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02385/input.txt", "sample_output_relpath": "derived/input_output/data/p02385/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02385/Scala/s384143831.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s384143831", "user_id": "u048060093"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.io.StdIn.{readLine,readInt}\n/**\n * AOJ\n */\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n\n var dice1 = read\n val dice2 = read\n\n for(side <- dice1){\n if(!dice2.contains(side)){println(\"No\");return}\n }\n\n dice1 = findSide(dice2(4),4,\"HHH\",findSide(dice2(0),0,\"WNNNW\",dice1))\n println(\n dice1 match {\n case null => \"No\"\n case dice1 if((dice1 zip dice2).forall(x => x._1 == x._2)) => \"Yes\"\n case _ => \"No\"\n }\n )\n }\n\n def findSide(sideNum:Int, findSide:Int, searchCommands:String, dice:Array[Int]) : Array[Int] = {\n if(dice(findSide) == sideNum){return dice}\n var d = dice\n for(c <- searchCommands.toCharArray){\n d = getNextStatus(c,d)\n if(d(findSide) == sideNum){return d}\n }\n return null\n }\n\n def getNextStatus(cmd:Char,dice:Array[Int]): Array[Int] = cmd\n match {\n case 'N' => Array(dice(1),dice(5),dice(2),dice(3),dice(0),dice(4))\n case 'W' => Array(dice(2),dice(1),dice(5),dice(0),dice(4),dice(3))\n case 'H' => Array(dice(0),dice(3),dice(1),dice(4),dice(2),dice(5))\n }\n\n def read() : Array[Int] = {\n readLine().split(\" \").map(_.toInt)\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nDice III\n\nWrite a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical.\n\nInput\n\nIn the first line, six integers assigned to faces of a dice are given in ascending order of their corresponding labels.\n\nIn the second line, six integers assigned to faces of another dice are given in ascending order of their corresponding labels.\n\nOutput\n\nPrint \"Yes\" if two dices are identical, otherwise \"No\" in a line.\n\nConstraints\n\n$0 \\leq $ the integer assigned to a face $ \\leq 100$\n\nSample Input 1\n\n1 2 3 4 5 6\n6 2 4 3 5 1\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n1 2 3 4 5 6\n6 5 4 3 2 1\n\nSample Output 2\n\nNo", "sample_input": "1 2 3 4 5 6\n6 2 4 3 5 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02385", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nDice III\n\nWrite a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical.\n\nInput\n\nIn the first line, six integers assigned to faces of a dice are given in ascending order of their corresponding labels.\n\nIn the second line, six integers assigned to faces of another dice are given in ascending order of their corresponding labels.\n\nOutput\n\nPrint \"Yes\" if two dices are identical, otherwise \"No\" in a line.\n\nConstraints\n\n$0 \\leq $ the integer assigned to a face $ \\leq 100$\n\nSample Input 1\n\n1 2 3 4 5 6\n6 2 4 3 5 1\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n1 2 3 4 5 6\n6 5 4 3 2 1\n\nSample Output 2\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1176, "cpu_time_ms": 230, "memory_kb": 44016}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s136919335", "group_id": "codeNet:p02385", "input_text": "/**\n * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_11_C&lang=jp\n * Structure and Class - Dice III\n */\nobject Main {\n\n case 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' => Dice(IndexedSeq(numbers(1), numbers(5), numbers(2), numbers(3), numbers(0), numbers(4)))\n case 'S' => Dice(IndexedSeq(numbers(4), numbers(0), numbers(2), numbers(3), numbers(5), numbers(1)))\n case 'W' => Dice(IndexedSeq(numbers(2), numbers(1), numbers(5), numbers(0), numbers(4), numbers(3)))\n case 'E' => 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 def adjustWith(dice: Dice): Dice = {\n val operationsToTop = Seq(\"\", \"N\", \"W\", \"E\", \"S\", \"NN\")\n val operationsToFront = Seq(\"S\", \"\", \"WSE\", \"ESW\", \"SEEN\", \"N\")\n val dice2 = operationsToTop(this.find(dice(0))).foldLeft(this)(_.rotateTo(_))\n val dice3 = operationsToFront(dice2.find(dice(1))).foldLeft(dice2)(_.rotateTo(_))\n dice3\n }\n }\n\n def main(args: Array[String]): Unit = {\n val dice1 = Dice(io.StdIn.readLine().split(\" \").map(_.toInt))\n val dice2 = Dice(io.StdIn.readLine().split(\" \").map(_.toInt))\n if (dice1 == dice2.adjustWith(dice1))\n println(\"Yes\")\n else\n println(\"No\")\n }\n}", "language": "Scala", "metadata": {"date": 1506225779, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02385.html", "problem_id": "p02385", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02385/input.txt", "sample_output_relpath": "derived/input_output/data/p02385/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02385/Scala/s136919335.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s136919335", "user_id": "u757244973"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "/**\n * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_11_C&lang=jp\n * Structure and Class - Dice III\n */\nobject Main {\n\n case 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' => Dice(IndexedSeq(numbers(1), numbers(5), numbers(2), numbers(3), numbers(0), numbers(4)))\n case 'S' => Dice(IndexedSeq(numbers(4), numbers(0), numbers(2), numbers(3), numbers(5), numbers(1)))\n case 'W' => Dice(IndexedSeq(numbers(2), numbers(1), numbers(5), numbers(0), numbers(4), numbers(3)))\n case 'E' => 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 def adjustWith(dice: Dice): Dice = {\n val operationsToTop = Seq(\"\", \"N\", \"W\", \"E\", \"S\", \"NN\")\n val operationsToFront = Seq(\"S\", \"\", \"WSE\", \"ESW\", \"SEEN\", \"N\")\n val dice2 = operationsToTop(this.find(dice(0))).foldLeft(this)(_.rotateTo(_))\n val dice3 = operationsToFront(dice2.find(dice(1))).foldLeft(dice2)(_.rotateTo(_))\n dice3\n }\n }\n\n def main(args: Array[String]): Unit = {\n val dice1 = Dice(io.StdIn.readLine().split(\" \").map(_.toInt))\n val dice2 = Dice(io.StdIn.readLine().split(\" \").map(_.toInt))\n if (dice1 == dice2.adjustWith(dice1))\n println(\"Yes\")\n else\n println(\"No\")\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nDice III\n\nWrite a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical.\n\nInput\n\nIn the first line, six integers assigned to faces of a dice are given in ascending order of their corresponding labels.\n\nIn the second line, six integers assigned to faces of another dice are given in ascending order of their corresponding labels.\n\nOutput\n\nPrint \"Yes\" if two dices are identical, otherwise \"No\" in a line.\n\nConstraints\n\n$0 \\leq $ the integer assigned to a face $ \\leq 100$\n\nSample Input 1\n\n1 2 3 4 5 6\n6 2 4 3 5 1\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n1 2 3 4 5 6\n6 5 4 3 2 1\n\nSample Output 2\n\nNo", "sample_input": "1 2 3 4 5 6\n6 2 4 3 5 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02385", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nDice III\n\nWrite a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical.\n\nInput\n\nIn the first line, six integers assigned to faces of a dice are given in ascending order of their corresponding labels.\n\nIn the second line, six integers assigned to faces of another dice are given in ascending order of their corresponding labels.\n\nOutput\n\nPrint \"Yes\" if two dices are identical, otherwise \"No\" in a line.\n\nConstraints\n\n$0 \\leq $ the integer assigned to a face $ \\leq 100$\n\nSample Input 1\n\n1 2 3 4 5 6\n6 2 4 3 5 1\n\nSample Output 1\n\nYes\n\nSample Input 2\n\n1 2 3 4 5 6\n6 5 4 3 2 1\n\nSample Output 2\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1487, "cpu_time_ms": 250, "memory_kb": 44084}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s928669433", "group_id": "codeNet:p02388", "input_text": "object Main{\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val x = sc.nextInt\n println(x*x*x)\n }\n}", "language": "Scala", "metadata": {"date": 1436444222, "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/s928669433.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s928669433", "user_id": "u840828069"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "object Main{\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val x = sc.nextInt\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 45096}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s830048638", "group_id": "codeNet:p02388", "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(scala.math.pow(readLine.i(0), 3).toInt)\n }\n}", "language": "Scala", "metadata": {"date": 1480669911, "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/s830048638.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s830048638", "user_id": "u767513951"}, "prompt_components": {"gold_output": "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(scala.math.pow(readLine.i(0), 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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 459, "cpu_time_ms": 240, "memory_kb": 43576}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s672128407", "group_id": "codeNet:p02388", "input_text": "object Main{\n def main(args:Array[String]) ={\n val scanner = new java.util.Scanner(System.in)\n val a = scanner.nextInt\n println(a * a * a)\n }\n}", "language": "Scala", "metadata": {"date": 1493305054, "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/s672128407.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s672128407", "user_id": "u808689778"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "object Main{\n def main(args:Array[String]) ={\n val scanner = new java.util.Scanner(System.in)\n val a = scanner.nextInt\n println(a * a * a)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 154, "cpu_time_ms": 240, "memory_kb": 45060}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s098247328", "group_id": "codeNet:p02388", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val x = sc.nextInt\n println(x * x * x)\n}\n", "language": "Scala", "metadata": {"date": 1550154311, "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/s098247328.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s098247328", "user_id": "u338068150"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val x = sc.nextInt\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 114, "cpu_time_ms": 250, "memory_kb": 44912}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s577385937", "group_id": "codeNet:p02389", "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, b = sc.nextInt\n println(a * b + \" \" + (a * 2 + b * 2))\n }\n}", "language": "Scala", "metadata": {"date": 1489205805, "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/s577385937.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s577385937", "user_id": "u119127920"}, "prompt_components": {"gold_output": "15 16\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, b = sc.nextInt\n println(a * b + \" \" + (a * 2 + b * 2))\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 250, "memory_kb": 45032}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s989910318", "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": 1490097613, "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/s989910318.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s989910318", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 44972}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s799043640", "group_id": "codeNet:p02390", "input_text": "import java.util.Scanner\nimport java.util.concurrent.TimeUnit\n \nobject Main {\n def main (args: Array[String]) = {\n val in = new Scanner(System.in)\n val s = in.nextInt\n val hh = TimeUnit.SECONDS.toHours(s)\n val mm = TimeUnit.SECONDS.toMinutes(s) - TimeUnit.HOURS.toMinutes(hh)\n val ss = TimeUnit.SECONDS.toSeconds(s) - TimeUnit.HOURS.toSeconds(hh) - TimeUnit.MINUTES.toSeconds(mm)\n \n println(\"%d:%d:%d\" format(hh, mm, ss))\n }\n}", "language": "Scala", "metadata": {"date": 1448803904, "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/s799043640.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s799043640", "user_id": "u188848609"}, "prompt_components": {"gold_output": "13:2:59\n", "input_to_evaluate": "import java.util.Scanner\nimport java.util.concurrent.TimeUnit\n \nobject Main {\n def main (args: Array[String]) = {\n val in = new Scanner(System.in)\n val s = in.nextInt\n val hh = TimeUnit.SECONDS.toHours(s)\n val mm = TimeUnit.SECONDS.toMinutes(s) - TimeUnit.HOURS.toMinutes(hh)\n val ss = TimeUnit.SECONDS.toSeconds(s) - TimeUnit.HOURS.toSeconds(hh) - TimeUnit.MINUTES.toSeconds(mm)\n \n println(\"%d:%d:%d\" format(hh, mm, 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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 250, "memory_kb": 45172}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s980136720", "group_id": "codeNet:p02390", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val sIn = sc.nextInt()\n println(calc(sIn))\n\n def calc(s:Int): String = s\"${s/3600}:${s%3600/60}:${s%60}\"\n}", "language": "Scala", "metadata": {"date": 1451341866, "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/s980136720.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s980136720", "user_id": "u223249350"}, "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 sIn = sc.nextInt()\n println(calc(sIn))\n\n def calc(s:Int): String = s\"${s/3600}:${s%3600/60}:${s%60}\"\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nWatch\n\nWrite a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.\n\nInput\n\nAn integer $S$ is given in a line.\n\nOutput\n\nPrint $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.\n\nConstraints\n\n$0 \\leq S \\leq 86400$\n\nSample Input 1\n\n46979\n\nSample Output 1\n\n13:2:59", "sample_input": "46979\n"}, "reference_outputs": ["13:2:59\n"], "source_document_id": "p02390", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nWatch\n\nWrite a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.\n\nInput\n\nAn integer $S$ is given in a line.\n\nOutput\n\nPrint $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.\n\nConstraints\n\n$0 \\leq S \\leq 86400$\n\nSample Input 1\n\n46979\n\nSample Output 1\n\n13:2:59", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 180, "cpu_time_ms": 250, "memory_kb": 45128}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s161357642", "group_id": "codeNet:p02390", "input_text": "object Main extends App {\n import scala.io.StdIn.readLine;\n val toTime:(Int) => String = (s:Int) => {\n (s / 3600).toString + ':' + (s % 3600 / 60) + ':' + (s % 60)\n }\n println(toTime(readLine.toInt))\n}", "language": "Scala", "metadata": {"date": 1453992577, "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/s161357642.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s161357642", "user_id": "u514597327"}, "prompt_components": {"gold_output": "13:2:59\n", "input_to_evaluate": "object Main extends App {\n import scala.io.StdIn.readLine;\n val toTime:(Int) => String = (s:Int) => {\n (s / 3600).toString + ':' + (s % 3600 / 60) + ':' + (s % 60)\n }\n println(toTime(readLine.toInt))\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nWatch\n\nWrite a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.\n\nInput\n\nAn integer $S$ is given in a line.\n\nOutput\n\nPrint $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.\n\nConstraints\n\n$0 \\leq S \\leq 86400$\n\nSample Input 1\n\n46979\n\nSample Output 1\n\n13:2:59", "sample_input": "46979\n"}, "reference_outputs": ["13:2:59\n"], "source_document_id": "p02390", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nWatch\n\nWrite a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.\n\nInput\n\nAn integer $S$ is given in a line.\n\nOutput\n\nPrint $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.\n\nConstraints\n\n$0 \\leq S \\leq 86400$\n\nSample Input 1\n\n46979\n\nSample Output 1\n\n13:2:59", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 208, "cpu_time_ms": 290, "memory_kb": 43896}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s590152200", "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 s = S % 60\n val mm = S / 60\n val m = mm % 60\n val h = mm / 60\n println(s\"$h:$m:$s\")\n}", "language": "Scala", "metadata": {"date": 1457588291, "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/s590152200.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s590152200", "user_id": "u768322169"}, "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 s = S % 60\n val mm = S / 60\n val m = mm % 60\n val h = mm / 60\n println(s\"$h:$m:$s\")\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nWatch\n\nWrite a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.\n\nInput\n\nAn integer $S$ is given in a line.\n\nOutput\n\nPrint $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.\n\nConstraints\n\n$0 \\leq S \\leq 86400$\n\nSample Input 1\n\n46979\n\nSample Output 1\n\n13:2:59", "sample_input": "46979\n"}, "reference_outputs": ["13:2:59\n"], "source_document_id": "p02390", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nWatch\n\nWrite a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.\n\nInput\n\nAn integer $S$ is given in a line.\n\nOutput\n\nPrint $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.\n\nConstraints\n\n$0 \\leq S \\leq 86400$\n\nSample Input 1\n\n46979\n\nSample Output 1\n\n13:2:59", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 188, "cpu_time_ms": 250, "memory_kb": 45024}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s962767710", "group_id": "codeNet:p02390", "input_text": "import scala.io.StdIn._\nobject Main {\n def main(args :Array[String]) = {\n\tvar mtrl = readInt\n\tval (i, j, k) = (mtrl/3600, (mtrl%3600)/60, mtrl%60)\n\tprintln(i+\":\"+j+\":\"+k)\n }\n}", "language": "Scala", "metadata": {"date": 1461469487, "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/s962767710.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s962767710", "user_id": "u116590310"}, "prompt_components": {"gold_output": "13:2:59\n", "input_to_evaluate": "import scala.io.StdIn._\nobject Main {\n def main(args :Array[String]) = {\n\tvar mtrl = readInt\n\tval (i, j, k) = (mtrl/3600, (mtrl%3600)/60, mtrl%60)\n\tprintln(i+\":\"+j+\":\"+k)\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nWatch\n\nWrite a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.\n\nInput\n\nAn integer $S$ is given in a line.\n\nOutput\n\nPrint $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.\n\nConstraints\n\n$0 \\leq S \\leq 86400$\n\nSample Input 1\n\n46979\n\nSample Output 1\n\n13:2:59", "sample_input": "46979\n"}, "reference_outputs": ["13:2:59\n"], "source_document_id": "p02390", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nWatch\n\nWrite a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.\n\nInput\n\nAn integer $S$ is given in a line.\n\nOutput\n\nPrint $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.\n\nConstraints\n\n$0 \\leq S \\leq 86400$\n\nSample Input 1\n\n46979\n\nSample Output 1\n\n13:2:59", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 175, "cpu_time_ms": 260, "memory_kb": 43436}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s762395676", "group_id": "codeNet:p02390", "input_text": "\nobject Main{\n def main(args:Array[String]):Unit ={\n val S = readInt\n val s = S%60\n val m = (S - s)/60%60\n val h = ((S - s) - m*60)/(60*60)\n println(s\"$h:$m:$s\")\n }\n}", "language": "Scala", "metadata": {"date": 1461850607, "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/s762395676.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s762395676", "user_id": "u994169680"}, "prompt_components": {"gold_output": "13:2:59\n", "input_to_evaluate": "\nobject Main{\n def main(args:Array[String]):Unit ={\n val S = readInt\n val s = S%60\n val m = (S - s)/60%60\n val h = ((S - s) - m*60)/(60*60)\n println(s\"$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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 270, "memory_kb": 43360}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s097289461", "group_id": "codeNet:p02390", "input_text": "\nobject Main {\n def main(args: Array[String]): Unit = {\n val S = io.StdIn.readInt()\n var s = S % 60\n var m = S / 60\n var h = m / 60\n m -= h * 60\n println(h + \":\" + m + \":\" + s)\n\n }\n}", "language": "Scala", "metadata": {"date": 1489206209, "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/s097289461.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s097289461", "user_id": "u119127920"}, "prompt_components": {"gold_output": "13:2:59\n", "input_to_evaluate": "\nobject Main {\n def main(args: Array[String]): Unit = {\n val S = io.StdIn.readInt()\n var s = S % 60\n var m = S / 60\n var h = m / 60\n m -= h * 60\n println(h + \":\" + m + \":\" + s)\n\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nWatch\n\nWrite a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.\n\nInput\n\nAn integer $S$ is given in a line.\n\nOutput\n\nPrint $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.\n\nConstraints\n\n$0 \\leq S \\leq 86400$\n\nSample Input 1\n\n46979\n\nSample Output 1\n\n13:2:59", "sample_input": "46979\n"}, "reference_outputs": ["13:2:59\n"], "source_document_id": "p02390", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nWatch\n\nWrite a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.\n\nInput\n\nAn integer $S$ is given in a line.\n\nOutput\n\nPrint $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.\n\nConstraints\n\n$0 \\leq S \\leq 86400$\n\nSample Input 1\n\n46979\n\nSample Output 1\n\n13:2:59", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 202, "cpu_time_ms": 260, "memory_kb": 43752}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s617873316", "group_id": "codeNet:p02390", "input_text": "object Main {\n def main(args:Array[String]) {\n val time = readLine().toInt\n val h = time / 3600\n val m = (time / 60) - h\n val s = time % 60\n println(h + \":\" + m + \":\" + s)\n }\n}", "language": "Scala", "metadata": {"date": 1509628741, "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/s617873316.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s617873316", "user_id": "u072097554"}, "prompt_components": {"gold_output": "13:2:59\n", "input_to_evaluate": "object Main {\n def main(args:Array[String]) {\n val time = readLine().toInt\n val h = time / 3600\n val m = (time / 60) - h\n val s = time % 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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 194, "cpu_time_ms": 230, "memory_kb": 43500}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s213252686", "group_id": "codeNet:p02391", "input_text": "object Main extends App {\n val arr = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n\n val ans =\n if (arr(0) == arr(1)) \"a == b\"\n else if( arr(0) < arr(1)) \"a < b\"\n else \"a > b\"\n\n println(ans)\n}\n", "language": "Scala", "metadata": {"date": 1540797664, "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/s213252686.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s213252686", "user_id": "u768801062"}, "prompt_components": {"gold_output": "a\n", "input_to_evaluate": "object Main extends App {\n val arr = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n\n val ans =\n if (arr(0) == arr(1)) \"a == b\"\n else if( arr(0) < arr(1)) \"a < b\"\n else \"a > b\"\n\n println(ans)\n}\n", "problem_context": "Small, Large, or Equal\n\nWrite a program which prints small/large/equal relation of given two integers a and b.\n\nInput\n\nTwo integers a and b separated by a single space are given in a line.\n\nOutput\n\nFor given two integers a and b, print\n\na < b\n\nif a is less than b,\n\na > b\n\nif a is greater than b, and\n\na == b\n\nif a equals to b.\n\nConstraints\n\n-1000 ≤ a, b ≤ 1000\n\nSample Input 1\n\n1 2\n\nSample Output 1\n\na < b\n\nSample Input 2\n\n4 3\n\nSample Output 2\n\na > b\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\na == b", "sample_input": "1 2\n"}, "reference_outputs": ["a\n"], "source_document_id": "p02391", "source_text": "Small, Large, or Equal\n\nWrite a program which prints small/large/equal relation of given two integers a and b.\n\nInput\n\nTwo integers a and b separated by a single space are given in a line.\n\nOutput\n\nFor given two integers a and b, print\n\na < b\n\nif a is less than b,\n\na > b\n\nif a is greater than b, and\n\na == b\n\nif a equals to b.\n\nConstraints\n\n-1000 ≤ a, b ≤ 1000\n\nSample Input 1\n\n1 2\n\nSample Output 1\n\na < b\n\nSample Input 2\n\n4 3\n\nSample Output 2\n\na > b\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\na == b", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 208, "cpu_time_ms": 220, "memory_kb": 43976}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s954055790", "group_id": "codeNet:p02391", "input_text": "import scala.io.StdIn.readLine\n\nobject Main{\n\tdef main(args: Array[String]){\n\t\tval input = readLine().split(\" \").map(_.toInt)\n\t\tval a: Int = input(0)\n\t\tval b: Int = input(1)\n\t\t\n\t\tif(a > b){\n\t\t\tprintln(\"a > b\")\n\t\t}else if(a < b){\n\t\t\tprintln(\"a < b\")\n\t\t}else{\n\t\t\tprintln(\"a == b\")\n\t\t}\n\t}\n}", "language": "Scala", "metadata": {"date": 1483667983, "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/s954055790.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s954055790", "user_id": "u996485583"}, "prompt_components": {"gold_output": "a\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main{\n\tdef main(args: Array[String]){\n\t\tval input = readLine().split(\" \").map(_.toInt)\n\t\tval a: Int = input(0)\n\t\tval b: Int = input(1)\n\t\t\n\t\tif(a > b){\n\t\t\tprintln(\"a > b\")\n\t\t}else if(a < b){\n\t\t\tprintln(\"a < b\")\n\t\t}else{\n\t\t\tprintln(\"a == b\")\n\t\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 43676}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s691376639", "group_id": "codeNet:p02391", "input_text": "import scala.io.Source\n\nobject Main{\n def main(args: Array[String]){\n val list =\n for{\n in <- Source.stdin.getLines.toList\n } yield in.map(_.toInt).toList\n\n boc(list.flatten)\n }\n\n def boc(a: List[Int])={\n if(a(0) - a(1) == 0) println(\"a == b\")\n else if(a(0) - a(1) > 0) println(\"a > b\")\n else if(a(0) - a(1) < 0) println(\"a < b\")\n else println()\n }\n}", "language": "Scala", "metadata": {"date": 1497600091, "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/s691376639.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s691376639", "user_id": "u085441951"}, "prompt_components": {"gold_output": "a\n", "input_to_evaluate": "import scala.io.Source\n\nobject Main{\n def main(args: Array[String]){\n val list =\n for{\n in <- Source.stdin.getLines.toList\n } yield in.map(_.toInt).toList\n\n boc(list.flatten)\n }\n\n def boc(a: List[Int])={\n if(a(0) - a(1) == 0) println(\"a == b\")\n else if(a(0) - a(1) > 0) println(\"a > b\")\n else if(a(0) - a(1) < 0) println(\"a < b\")\n else println()\n }\n}", "problem_context": "Small, Large, or Equal\n\nWrite a program which prints small/large/equal relation of given two integers a and b.\n\nInput\n\nTwo integers a and b separated by a single space are given in a line.\n\nOutput\n\nFor given two integers a and b, print\n\na < b\n\nif a is less than b,\n\na > b\n\nif a is greater than b, and\n\na == b\n\nif a equals to b.\n\nConstraints\n\n-1000 ≤ a, b ≤ 1000\n\nSample Input 1\n\n1 2\n\nSample Output 1\n\na < b\n\nSample Input 2\n\n4 3\n\nSample Output 2\n\na > b\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\na == b", "sample_input": "1 2\n"}, "reference_outputs": ["a\n"], "source_document_id": "p02391", "source_text": "Small, Large, or Equal\n\nWrite a program which prints small/large/equal relation of given two integers a and b.\n\nInput\n\nTwo integers a and b separated by a single space are given in a line.\n\nOutput\n\nFor given two integers a and b, print\n\na < b\n\nif a is less than b,\n\na > b\n\nif a is greater than b, and\n\na == b\n\nif a equals to b.\n\nConstraints\n\n-1000 ≤ a, b ≤ 1000\n\nSample Input 1\n\n1 2\n\nSample Output 1\n\na < b\n\nSample Input 2\n\n4 3\n\nSample Output 2\n\na > b\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\na == b", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 389, "cpu_time_ms": 230, "memory_kb": 43872}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s829576462", "group_id": "codeNet:p02392", "input_text": "import scala.io.StdIn\n \nobject Main {\n def main(args: Array[String]){\n\n\tval Array(a, b, c) = StdIn.readLine().split(\" \").map(_.toInt)\n println(if (a < b && b < c) \"Yes\" else \"No\")\n }\n}\n", "language": "Scala", "metadata": {"date": 1531153351, "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/s829576462.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s829576462", "user_id": "u912124184"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.io.StdIn\n \nobject Main {\n def main(args: Array[String]){\n\n\tval Array(a, b, c) = StdIn.readLine().split(\" \").map(_.toInt)\n println(if (a < b && b < c) \"Yes\" else \"No\")\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43764}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s679207616", "group_id": "codeNet:p02393", "input_text": "object Main extends App {\n println(scala.io.StdIn.readLine.split(\" \").map(_.toInt).sorted.mkString(\" \"))\n}", "language": "Scala", "metadata": {"date": 1440226922, "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/s679207616.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s679207616", "user_id": "u490032117"}, "prompt_components": {"gold_output": "1 3 8\n", "input_to_evaluate": "object Main extends App {\n println(scala.io.StdIn.readLine.split(\" \").map(_.toInt).sorted.mkString(\" \"))\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43928}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s883753287", "group_id": "codeNet:p02393", "input_text": "import scala.io.StdIn._\nobject Main {\n \n def main(args: Array[String]): Unit = {\n println(readLine.split(\" \").map(_.toInt).sorted.mkString(\" \"))\n }\n}", "language": "Scala", "metadata": {"date": 1467477199, "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/s883753287.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s883753287", "user_id": "u778333573"}, "prompt_components": {"gold_output": "1 3 8\n", "input_to_evaluate": "import scala.io.StdIn._\nobject Main {\n \n def main(args: Array[String]): Unit = {\n println(readLine.split(\" \").map(_.toInt).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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 220, "memory_kb": 43776}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s878815915", "group_id": "codeNet:p02394", "input_text": "import scala.io.StdIn\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val Array(w, h, x, y, r, _*) = StdIn.readLine().split(\" \").map(_.toInt)\n if(x - r >= 0 && x + r <= w && y - r >=0 && y + r <= h) println(\"Yes\")\n else println(\"No\")\n }\n}", "language": "Scala", "metadata": {"date": 1436102091, "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/s878815915.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s878815915", "user_id": "u389172382"}, "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 Array(w, h, x, y, r, _*) = StdIn.readLine().split(\" \").map(_.toInt)\n if(x - r >= 0 && x + r <= w && y - r >=0 && y + r <= h) println(\"Yes\")\n else println(\"No\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43920}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s223089754", "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)\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": 1436969756, "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/s223089754.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s223089754", "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)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 270, "memory_kb": 43988}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s105887481", "group_id": "codeNet:p02394", "input_text": "import java.util.Scanner\n\nobject Main extends App{\n val sc = new Scanner(System.in)\n val w,h,x,y,r = sc.nextInt()\n println(if(x-r >= 0 & x+r <= w & y-r >= 0 & y+r <= h) \"Yes\" else \"No\")\n}", "language": "Scala", "metadata": {"date": 1440178326, "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/s105887481.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s105887481", "user_id": "u121003333"}, "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 w,h,x,y,r = sc.nextInt()\n println(if(x-r >= 0 & x+r <= w & y-r >= 0 & y+r <= h) \"Yes\" else \"No\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 250, "memory_kb": 45060}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s691429425", "group_id": "codeNet:p02394", "input_text": "import scala.io.StdIn.readLine\n\nobject Main {\n\n def main(args: Array[String]) = {\n val n = readLine().split(\" \").map(_.toInt)\n val (w,h,x,y,r) = (n(0),n(1),n(2),n(3),n(4))\n val s = if(x-r < 0 || y - r < 0 || x + r > w || y + r > h) \"No\" else \"Yes\"\n println(s)\n }\n}", "language": "Scala", "metadata": {"date": 1476437546, "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/s691429425.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s691429425", "user_id": "u508732591"}, "prompt_components": {"gold_output": "Yes\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)\n val (w,h,x,y,r) = (n(0),n(1),n(2),n(3),n(4))\n val s = if(x-r < 0 || y - r < 0 || x + r > w || y + r > h) \"No\" else \"Yes\"\n println(s)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 43776}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s866528243", "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 (w, h, 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": 1510551468, "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/s866528243.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s866528243", "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 (w, h, 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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 270, "memory_kb": 43836}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s531596389", "group_id": "codeNet:p02394", "input_text": "import scala.io.StdIn.readLine\nobject Main extends App{\n val a = readLine().split(\" \").map(_.toInt)\n val (w, h, x, y, r) = (a(0), a(1), a(2), a(3), a(4))\n if (0 <= x - r && x + r <= w && 0 <= y - r && y + r <= h)\n {\n println(\"Yes\")\n }\n else\n {\n println(\"No\")\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1569335422, "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/s531596389.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s531596389", "user_id": "u128808587"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.io.StdIn.readLine\nobject Main extends App{\n val a = readLine().split(\" \").map(_.toInt)\n val (w, h, x, y, r) = (a(0), a(1), a(2), a(3), a(4))\n if (0 <= x - r && x + r <= w && 0 <= y - r && y + r <= h)\n {\n println(\"Yes\")\n }\n else\n {\n 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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 303, "cpu_time_ms": 310, "memory_kb": 43940}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s890650658", "group_id": "codeNet:p02396", "input_text": "\nobject Main {\n\tdef main(args: Array[String]): Unit = {\n\t\t\tval in = new java.util.Scanner(System.in)\n\t\t\trec(in,1)\n\t}\n\tdef rec(in:java.util.Scanner,count:Int):Unit = {\n\t val a = in.nextInt()\n\t if(a == 0) return\n\t println(\"Case \"+count+\": \"+a)\n\t rec(in,count+1)\n\t}\n}", "language": "Scala", "metadata": {"date": 1458063494, "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/s890650658.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s890650658", "user_id": "u892831253"}, "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": "\nobject Main {\n\tdef main(args: Array[String]): Unit = {\n\t\t\tval in = new java.util.Scanner(System.in)\n\t\t\trec(in,1)\n\t}\n\tdef rec(in:java.util.Scanner,count:Int):Unit = {\n\t val a = in.nextInt()\n\t if(a == 0) return\n\t println(\"Case \"+count+\": \"+a)\n\t rec(in,count+1)\n\t}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 470, "memory_kb": 61980}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s989515963", "group_id": "codeNet:p02396", "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(i: Int = 1, n: Int = sc.nextInt): Unit = {\n if( n != 0 ) {\n pw.println(\"Case \"+i+\": \"+n)\n output(i=i+1)\n }\n }\n\n output()\n pw.flush\n}\n", "language": "Scala", "metadata": {"date": 1547871624, "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/s989515963.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s989515963", "user_id": "u634490486"}, "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 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(i: Int = 1, n: Int = sc.nextInt): Unit = {\n if( n != 0 ) {\n pw.println(\"Case \"+i+\": \"+n)\n output(i=i+1)\n }\n }\n\n output()\n pw.flush\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 370, "memory_kb": 62220}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s884157645", "group_id": "codeNet:p02397", "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\n\n println(line.map{str => str.split(\" \").map(_.toInt).sorted.mkString(\" \")}.init.mkString(\"\\n\"))\n }\n}", "language": "Scala", "metadata": {"date": 1497523506, "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/s884157645.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s884157645", "user_id": "u085441951"}, "prompt_components": {"gold_output": "2 3\n2 2\n3 5\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\n\n println(line.map{str => str.split(\" \").map(_.toInt).sorted.mkString(\" \")}.init.mkString(\"\\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 261, "cpu_time_ms": 300, "memory_kb": 48416}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s607944441", "group_id": "codeNet:p02398", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n try {\n val a = sc.nextInt\n val b = sc.nextInt\n val c = sc.nextInt\n\n def sub(x:Int):Int = {\n if(c % x == 0) 1 else 0\n } \n val ab = List(a,b)\n println(ab.map(sub).sum)\n } catch {\n case e: NoSuchElementException =>\n println(\"error: stdin is not found. Please take numbers.\")\n }\n }\n}", "language": "Scala", "metadata": {"date": 1436579849, "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/s607944441.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s607944441", "user_id": "u840828069"}, "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\n try {\n val a = sc.nextInt\n val b = sc.nextInt\n val c = sc.nextInt\n\n def sub(x:Int):Int = {\n if(c % x == 0) 1 else 0\n } \n val ab = List(a,b)\n println(ab.map(sub).sum)\n } catch {\n case e: NoSuchElementException =>\n println(\"error: stdin is not found. Please take numbers.\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 447, "cpu_time_ms": 230, "memory_kb": 45008}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s230579485", "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 val divisors = getDivisorList(c,1)\n val range = (a to b).toList\n println(range.intersect(divisors).size)\n\n def getDivisorList(target: Int, start: Int): List[Int] = {\n if (target == start)\n List(target)\n else if (target % start == 0)\n start :: getDivisorList(target, start + 1)\n else\n getDivisorList(target, start + 1)\n }\n}", "language": "Scala", "metadata": {"date": 1451382975, "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/s230579485.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s230579485", "user_id": "u223249350"}, "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 val divisors = getDivisorList(c,1)\n val range = (a to b).toList\n println(range.intersect(divisors).size)\n\n def getDivisorList(target: Int, start: Int): List[Int] = {\n if (target == start)\n List(target)\n else if (target % start == 0)\n start :: getDivisorList(target, start + 1)\n else\n getDivisorList(target, start + 1)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 310, "memory_kb": 46924}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s887837791", "group_id": "codeNet:p02398", "input_text": "import scala.io.StdIn.readLine\nimport Math.sqrt\n\nobject Main {\n\n def main(args: Array[String]) = {\n val Array(a,b,c) = readLine.split(\" \").map(_.toInt)\n var cnt = 0\n for(i <- a to b)\n if(c % i == 0)\n cnt += 1\n println(cnt)\n }\n}", "language": "Scala", "metadata": {"date": 1478224906, "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/s887837791.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s887837791", "user_id": "u508732591"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.io.StdIn.readLine\nimport Math.sqrt\n\nobject Main {\n\n def main(args: Array[String]) = {\n val Array(a,b,c) = readLine.split(\" \").map(_.toInt)\n var cnt = 0\n for(i <- a to b)\n if(c % i == 0)\n cnt += 1\n println(cnt)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 43944}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s092591478", "group_id": "codeNet:p02398", "input_text": "object Main {\n def divisors(n: Int) =\n (1 to math.sqrt(n).toInt).flatMap(m =>\n if (n % m == 0 && m * m == n) List(m)\n else if (n % m == 0) List(m, n / m)\n else Nil\n )\n def main(args: Array[String]) = {\n val in = io.StdIn.readLine.split(\" \").map(_.toInt)\n println((in(0) to in(1)).count(divisors(in(2)).contains))\n }\n}", "language": "Scala", "metadata": {"date": 1481541946, "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/s092591478.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s092591478", "user_id": "u475394465"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main {\n def divisors(n: Int) =\n (1 to math.sqrt(n).toInt).flatMap(m =>\n if (n % m == 0 && m * m == n) List(m)\n else if (n % m == 0) List(m, n / m)\n else Nil\n )\n def main(args: Array[String]) = {\n val in = io.StdIn.readLine.split(\" \").map(_.toInt)\n println((in(0) to in(1)).count(divisors(in(2)).contains))\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 270, "memory_kb": 45844}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s043322310", "group_id": "codeNet:p02398", "input_text": "import scala.io.StdIn\n\nobject Main{\n def main(args: Array[String]){\n val line = StdIn.readLine.split(\" \").toList.map(_.toInt)\n\n println((line.head to line.tail.head).map{i => line.last % i == 0}.filter{_ == true}.length)\n }\n}", "language": "Scala", "metadata": {"date": 1497599839, "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/s043322310.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s043322310", "user_id": "u085441951"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main{\n def main(args: Array[String]){\n val line = StdIn.readLine.split(\" \").toList.map(_.toInt)\n\n println((line.head to line.tail.head).map{i => line.last % i == 0}.filter{_ == true}.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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 250, "memory_kb": 45044}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s101852673", "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(f\"${a / b} ${a % b} ${a * 1.0 / b}%.5f\")\n }\n}", "language": "Scala", "metadata": {"date": 1489214270, "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/s101852673.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s101852673", "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(f\"${a / b} ${a % b} ${a * 1.0 / b}%.5f\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 250, "memory_kb": 45212}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s931179219", "group_id": "codeNet:p02399", "input_text": "\nimport scala.io.StdIn\n\nobject Main extends App {\n \n val a = StdIn.readLine().trim.split(' ').map(_.toInt)\n val f: Int = a(0)/a(1)\n val e: Int = a(0)/a(1)\n val d: Double = a(0).toDouble/a(1).toDouble\n \n println(f)\n println(e)\n println(f\"$d%.5f\")\n\n}\n", "language": "Scala", "metadata": {"date": 1523776259, "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/s931179219.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s931179219", "user_id": "u342234782"}, "prompt_components": {"gold_output": "1 1 1.50000\n", "input_to_evaluate": "\nimport scala.io.StdIn\n\nobject Main extends App {\n \n val a = StdIn.readLine().trim.split(' ').map(_.toInt)\n val f: Int = a(0)/a(1)\n val e: Int = a(0)/a(1)\n val d: Double = a(0).toDouble/a(1).toDouble\n \n println(f)\n println(e)\n println(f\"$d%.5f\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 220, "memory_kb": 43896}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s968253058", "group_id": "codeNet:p02400", "input_text": "object Main{\n def main(args: Array[String]): Unit ={\n var in = scala.io.StdIn.readDouble()\n var a = in * in * 3.141592653D\n var c = (in + in) * 3.141592653D\n println(f\"$a%.7f\" + \" \" + f\"$c%.7f\")\n }\n}", "language": "Scala", "metadata": {"date": 1479978030, "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/s968253058.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s968253058", "user_id": "u803981213"}, "prompt_components": {"gold_output": "12.566371 12.566371\n", "input_to_evaluate": "object Main{\n def main(args: Array[String]): Unit ={\n var in = scala.io.StdIn.readDouble()\n var a = in * in * 3.141592653D\n var c = (in + in) * 3.141592653D\n println(f\"$a%.7f\" + \" \" + f\"$c%.7f\")\n }\n}", "problem_context": "Circle\n\nWrite a program which calculates the area and circumference of a circle for given radius r.\n\nInput\n\nA real number r is given.\n\nOutput\n\nPrint the area and circumference of the circle in a line. Put a single space between them. The output should not contain an absolute error greater than 10-5.\n\nConstraints\n\n0 < r < 10000\n\nSample Input 1\n\n2\n\nSample Output 1\n\n12.566371 12.566371\n\nSample Input 2\n\n3\n\nSample Output 2\n\n28.274334 18.849556", "sample_input": "2\n"}, "reference_outputs": ["12.566371 12.566371\n"], "source_document_id": "p02400", "source_text": "Circle\n\nWrite a program which calculates the area and circumference of a circle for given radius r.\n\nInput\n\nA real number r is given.\n\nOutput\n\nPrint the area and circumference of the circle in a line. Put a single space between them. The output should not contain an absolute error greater than 10-5.\n\nConstraints\n\n0 < r < 10000\n\nSample Input 1\n\n2\n\nSample Output 1\n\n12.566371 12.566371\n\nSample Input 2\n\n3\n\nSample Output 2\n\n28.274334 18.849556", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 234, "cpu_time_ms": 230, "memory_kb": 43836}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s023072529", "group_id": "codeNet:p02400", "input_text": "object Main extends App {\n val r = BigDecimal(scala.io.StdIn.readLine().toDouble)\n\n println(r * r * Math.PI + \" \" + 2 * r * Math.PI)\n}\n", "language": "Scala", "metadata": {"date": 1555068744, "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/s023072529.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s023072529", "user_id": "u385991569"}, "prompt_components": {"gold_output": "12.566371 12.566371\n", "input_to_evaluate": "object Main extends App {\n val r = BigDecimal(scala.io.StdIn.readLine().toDouble)\n\n println(r * r * Math.PI + \" \" + 2 * r * Math.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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 44012}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s957456317", "group_id": "codeNet:p02402", "input_text": "object Main{\n def main(args: Array[String]){\n val sc = new java.util.Scanner(System.in)\n val num = sc.nextInt\n var sum = 0\n var list = List[Int]()\n var min = 0L\n var max = 0L\n for(i <- 1 to num){\n val in = sc.nextInt\n if(i == 1){\n min = in\n max = in\n }\n\n if(in < min){\n min = in\n }\n if(in > max){\n max = in\n }\n sum = in + sum\n }\n\n println(min + \" \" + max + \" \" + sum)\n }\n}", "language": "Scala", "metadata": {"date": 1435806251, "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/s957456317.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s957456317", "user_id": "u085441951"}, "prompt_components": {"gold_output": "1 17 37\n", "input_to_evaluate": "object Main{\n def main(args: Array[String]){\n val sc = new java.util.Scanner(System.in)\n val num = sc.nextInt\n var sum = 0\n var list = List[Int]()\n var min = 0L\n var max = 0L\n for(i <- 1 to num){\n val in = sc.nextInt\n if(i == 1){\n min = in\n max = in\n }\n\n if(in < min){\n min = in\n }\n if(in > max){\n max = in\n }\n sum = in + sum\n }\n\n println(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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 350, "memory_kb": 58980}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s662580313", "group_id": "codeNet:p02402", "input_text": "object Main {\n def main (args: Array[String]) {\n val num = scala.io.StdIn.readLine.toInt;\n val list = scala.io.StdIn.readLine.split(\" \").map(_.toLong).toList;\n \n println(list.min + \" \" + list.max + \" \" + list.sum)\n }\n}", "language": "Scala", "metadata": {"date": 1437034566, "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/s662580313.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s662580313", "user_id": "u012178320"}, "prompt_components": {"gold_output": "1 17 37\n", "input_to_evaluate": "object Main {\n def main (args: Array[String]) {\n val num = scala.io.StdIn.readLine.toInt;\n val list = scala.io.StdIn.readLine.split(\" \").map(_.toLong).toList;\n \n println(list.min + \" \" + list.max + \" \" + list.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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 310, "memory_kb": 49424}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s406232509", "group_id": "codeNet:p02402", "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 longs: Seq[Long] = strings.map(_.toLong)\n def doubles: Seq[Double] = strings.map(_.toDouble)\n def i(n: Int): Int = ints(n)\n def d(n: Int): Double = doubles(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]): Unit = {\n val m: Int = readLine.i(0)\n val ns: Seq[Long] = readLine.longs\n\n println(List(ns.min, ns.max, ns.sum).mkString(\" \"))\n }\n}", "language": "Scala", "metadata": {"date": 1480678973, "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/s406232509.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s406232509", "user_id": "u767513951"}, "prompt_components": {"gold_output": "1 17 37\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 longs: Seq[Long] = strings.map(_.toLong)\n def doubles: Seq[Double] = strings.map(_.toDouble)\n def i(n: Int): Int = ints(n)\n def d(n: Int): Double = doubles(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]): Unit = {\n val m: Int = readLine.i(0)\n val ns: Seq[Long] = readLine.longs\n\n println(List(ns.min, ns.max, ns.sum).mkString(\" \"))\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 685, "cpu_time_ms": 300, "memory_kb": 48304}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s647238815", "group_id": "codeNet:p02402", "input_text": "\nobject Main extends App {\n val n = readLine().toInt\n val a = readLine().split(' ').map(_.toLong).toList.take(n)\n println(\"%d %d %d\".format(a.min, a.max, a.sum))\n}\n", "language": "Scala", "metadata": {"date": 1548254764, "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/s647238815.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s647238815", "user_id": "u488896135"}, "prompt_components": {"gold_output": "1 17 37\n", "input_to_evaluate": "\nobject Main extends App {\n val n = readLine().toInt\n val a = readLine().split(' ').map(_.toLong).toList.take(n)\n println(\"%d %d %d\".format(a.min, a.max, a.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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 310, "memory_kb": 49916}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s132379621", "group_id": "codeNet:p02403", "input_text": "object Main extends App {\n for (line <- scala.io.Source.stdin.getLines() if line.size > 0 && line != \"0 0\") {\n var cnt = 1\n if (cnt != 1) println()\n for (h <- 1 to line.split(\" \")(0).toInt) {\n val horizon: String = \"\"\"???\"\"\" * line.split(\" \")(1).toInt\n println(horizon)\n }\n cnt += 1\n }\n}", "language": "Scala", "metadata": {"date": 1451392196, "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/s132379621.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s132379621", "user_id": "u223249350"}, "prompt_components": {"gold_output": "####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##\n", "input_to_evaluate": "object Main extends App {\n for (line <- scala.io.Source.stdin.getLines() if line.size > 0 && line != \"0 0\") {\n var cnt = 1\n if (cnt != 1) println()\n for (h <- 1 to line.split(\" \")(0).toInt) {\n val horizon: String = \"\"\"???\"\"\" * line.split(\" \")(1).toInt\n println(horizon)\n }\n cnt += 1\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 43852}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s899378540", "group_id": "codeNet:p02403", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val in = new java.util.Scanner(System.in)\n val a = in.nextInt\n val b = in.nextInt\n for(i <- 1 to a){\n for(j <- 1 to b){\n print(\"#\")\n }\n println(\"\")\n }\n }\n \n}", "language": "Scala", "metadata": {"date": 1458098141, "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/s899378540.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s899378540", "user_id": "u892831253"}, "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]): Unit = {\n val in = new java.util.Scanner(System.in)\n val a = in.nextInt\n val b = in.nextInt\n for(i <- 1 to a){\n for(j <- 1 to b){\n print(\"#\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 253, "cpu_time_ms": 240, "memory_kb": 45136}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s122504942", "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 println()\n while(true){\n val h,w=sc.nextInt\n if(h==0&&w==0) return\n if(tmp) println()\n for(i<-1 to h;j<-1 to w){\n if(j==w){\n if(i==h) println(\"# \")\n else println(\"#\")\n }\n else print(\"#\")\n }\n tmp=true\n }\n }\n}", "language": "Scala", "metadata": {"date": 1471601963, "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/s122504942.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s122504942", "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 println()\n while(true){\n val h,w=sc.nextInt\n if(h==0&&w==0) return\n if(tmp) println()\n for(i<-1 to h;j<-1 to w){\n if(j==w){\n if(i==h) println(\"# \")\n else 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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 240, "memory_kb": 44912}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s165783329", "group_id": "codeNet:p02403", "input_text": "import scala.io.StdIn\n\n/**\n * AOJ\n */\nobject Main {\n\n def main(args: Array[String]): Unit = {\n\n while(true) {\n val in = StdIn.readLine().split(\" \").map(_.toInt)\n if(in(0) == 0 && in(1) == 0) return\n for(i <- 1 to in(0)){println(\"#\" * in(1))}\n println()\n }\n }\n}", "language": "Scala", "metadata": {"date": 1498299011, "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/s165783329.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s165783329", "user_id": "u048060093"}, "prompt_components": {"gold_output": "####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##\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 while(true) {\n val in = StdIn.readLine().split(\" \").map(_.toInt)\n if(in(0) == 0 && in(1) == 0) return\n for(i <- 1 to in(0)){println(\"#\" * in(1))}\n println()\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 260, "memory_kb": 45124}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s126614135", "group_id": "codeNet:p02403", "input_text": "object Main {\n def main(args:Array[String]):Unit = {\n for (line <- scala.io.Source.stdin.getLines() if line != \"0 0\") {\n val Array(h, w) = line.split(\" \").map(_.toInt)\n for (i <- 1 to h) {\n println(\"#\" * w)\n }\n println()\n }\n }\n}", "language": "Scala", "metadata": {"date": 1510568869, "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/s126614135.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s126614135", "user_id": "u343251190"}, "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]):Unit = {\n for (line <- scala.io.Source.stdin.getLines() if line != \"0 0\") {\n val Array(h, w) = line.split(\" \").map(_.toInt)\n for (i <- 1 to h) {\n println(\"#\" * w)\n }\n println()\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 290, "memory_kb": 45188}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s918848944", "group_id": "codeNet:p02403", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n\n var hw = StdIn.readLine().split(' ').map(_.toInt)\n while(hw(0) != 0 && hw(1) != 0){\n (0 until hw(0)).foreach{ _ =>\n (0 until hw(1)).foreach( _ => print(\"#\"))\n println(\"\")\n }\n println(\"\")\n hw = StdIn.readLine().split(' ').map(_.toInt)\n }\n\n}\n\n", "language": "Scala", "metadata": {"date": 1523831918, "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/s918848944.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s918848944", "user_id": "u342234782"}, "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 extends App {\n\n var hw = StdIn.readLine().split(' ').map(_.toInt)\n while(hw(0) != 0 && hw(1) != 0){\n (0 until hw(0)).foreach{ _ =>\n (0 until hw(1)).foreach( _ => print(\"#\"))\n println(\"\")\n }\n println(\"\")\n hw = StdIn.readLine().split(' ').map(_.toInt)\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 400, "memory_kb": 51396}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s700191427", "group_id": "codeNet:p02404", "input_text": "import scala.io.StdIn.readLine\n\nobject Main {\n def main(args: Array[String]) {\n def printFrame: Unit = {\n val Array(a, b) = readLine().split(\" \").map(_.toInt)\n if(a != 0 && b != 0) {\n for(i <- 1 to a) {\n if(i == 1 || i == a) println(\"#\" * b)\n else println(\"#\" + \".\" * (b - 2) + \"#\")\n }\n println()\n printFrame\n }\n }\n\n printFrame\n }\n}", "language": "Scala", "metadata": {"date": 1457906359, "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/s700191427.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s700191427", "user_id": "u123244675"}, "prompt_components": {"gold_output": "####\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 def main(args: Array[String]) {\n def printFrame: Unit = {\n val Array(a, b) = readLine().split(\" \").map(_.toInt)\n if(a != 0 && b != 0) {\n for(i <- 1 to a) {\n if(i == 1 || i == a) println(\"#\" * b)\n else println(\"#\" + \".\" * (b - 2) + \"#\")\n }\n println()\n printFrame\n }\n }\n\n printFrame\n }\n}", "problem_context": "Print a Frame\n\nDraw a frame which has a height of H cm and a width of W cm. For example, the following figure shows a frame which has a height of 6 cm and a width of 10 cm.\n\n##########\n#........#\n#........#\n#........#\n#........#\n##########\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.\n\nThe input ends with two 0 (when both H and W are zero).\n\nOutput\n\nFor each dataset, print the frame made of '#' and '.'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n3 ≤ H ≤ 300\n\n3 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n3 3\n0 0\n\nSample Output\n\n####\n#..#\n####\n\n######\n#....#\n#....#\n#....#\n######\n\n###\n#.#\n###", "sample_input": "3 4\n5 6\n3 3\n0 0\n"}, "reference_outputs": ["####\n#..#\n####\n\n######\n#....#\n#....#\n#....#\n######\n\n###\n#.#\n###\n"], "source_document_id": "p02404", "source_text": "Print a Frame\n\nDraw a frame which has a height of H cm and a width of W cm. For example, the following figure shows a frame which has a height of 6 cm and a width of 10 cm.\n\n##########\n#........#\n#........#\n#........#\n#........#\n##########\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.\n\nThe input ends with two 0 (when both H and W are zero).\n\nOutput\n\nFor each dataset, print the frame made of '#' and '.'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n3 ≤ H ≤ 300\n\n3 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n3 3\n0 0\n\nSample Output\n\n####\n#..#\n####\n\n######\n#....#\n#....#\n#....#\n######\n\n###\n#.#\n###", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 404, "cpu_time_ms": 250, "memory_kb": 45276}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s539012893", "group_id": "codeNet:p02404", "input_text": "import scala.io.StdIn.readLine\n\nobject Main {\n\n def main(args: Array[String]) = {\n var n = readLine.split(\" \").map(_.toInt)\n while( n(0) != 0 || n(1) != 0) {\n println(\"#\"*n(1))\n\n (2 to n(0)-1).foreach(s=> { print(\"#\");print(\".\"*(n(1)-2));print(\"#\\n\") })\n\n if(n(0)>1) {\n println(\"#\"*n(1))\n }\n println(\"\")\n n = readLine.split(\" \").map(_.toInt)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1480401705, "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/s539012893.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s539012893", "user_id": "u508732591"}, "prompt_components": {"gold_output": "####\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 var n = readLine.split(\" \").map(_.toInt)\n while( n(0) != 0 || n(1) != 0) {\n println(\"#\"*n(1))\n\n (2 to n(0)-1).foreach(s=> { print(\"#\");print(\".\"*(n(1)-2));print(\"#\\n\") })\n\n if(n(0)>1) {\n println(\"#\"*n(1))\n }\n println(\"\")\n n = readLine.split(\" \").map(_.toInt)\n }\n }\n}", "problem_context": "Print a Frame\n\nDraw a frame which has a height of H cm and a width of W cm. For example, the following figure shows a frame which has a height of 6 cm and a width of 10 cm.\n\n##########\n#........#\n#........#\n#........#\n#........#\n##########\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.\n\nThe input ends with two 0 (when both H and W are zero).\n\nOutput\n\nFor each dataset, print the frame made of '#' and '.'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n3 ≤ H ≤ 300\n\n3 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n3 3\n0 0\n\nSample Output\n\n####\n#..#\n####\n\n######\n#....#\n#....#\n#....#\n######\n\n###\n#.#\n###", "sample_input": "3 4\n5 6\n3 3\n0 0\n"}, "reference_outputs": ["####\n#..#\n####\n\n######\n#....#\n#....#\n#....#\n######\n\n###\n#.#\n###\n"], "source_document_id": "p02404", "source_text": "Print a Frame\n\nDraw a frame which has a height of H cm and a width of W cm. For example, the following figure shows a frame which has a height of 6 cm and a width of 10 cm.\n\n##########\n#........#\n#........#\n#........#\n#........#\n##########\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.\n\nThe input ends with two 0 (when both H and W are zero).\n\nOutput\n\nFor each dataset, print the frame made of '#' and '.'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n3 ≤ H ≤ 300\n\n3 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n3 3\n0 0\n\nSample Output\n\n####\n#..#\n####\n\n######\n#....#\n#....#\n#....#\n######\n\n###\n#.#\n###", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 417, "cpu_time_ms": 250, "memory_kb": 44528}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s905897723", "group_id": "codeNet:p02404", "input_text": "import scala.io.Source\n\nobject Main{\n def main(args: Array[String]){\n val list =\n for{\n in <- Source.stdin.getLines.toList\n } yield in\n\n list.map(_.split(\" \").map(_.toInt).toList).init.foreach{ list =>\n val height = list.head\n val width = list.last\n\n println(\"#\" * width)\n (2 to height-1).foreach{ i =>\n println(s\"#${\".\" * (width - 2)}#\")\n }\n println(\"#\" * width)\n println\n }\n }\n}", "language": "Scala", "metadata": {"date": 1497705966, "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/s905897723.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s905897723", "user_id": "u085441951"}, "prompt_components": {"gold_output": "####\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 val list =\n for{\n in <- Source.stdin.getLines.toList\n } yield in\n\n list.map(_.split(\" \").map(_.toInt).toList).init.foreach{ list =>\n val height = list.head\n val width = list.last\n\n println(\"#\" * width)\n (2 to height-1).foreach{ i =>\n println(s\"#${\".\" * (width - 2)}#\")\n }\n println(\"#\" * width)\n println\n }\n }\n}", "problem_context": "Print a Frame\n\nDraw a frame which has a height of H cm and a width of W cm. For example, the following figure shows a frame which has a height of 6 cm and a width of 10 cm.\n\n##########\n#........#\n#........#\n#........#\n#........#\n##########\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.\n\nThe input ends with two 0 (when both H and W are zero).\n\nOutput\n\nFor each dataset, print the frame made of '#' and '.'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n3 ≤ H ≤ 300\n\n3 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n3 3\n0 0\n\nSample Output\n\n####\n#..#\n####\n\n######\n#....#\n#....#\n#....#\n######\n\n###\n#.#\n###", "sample_input": "3 4\n5 6\n3 3\n0 0\n"}, "reference_outputs": ["####\n#..#\n####\n\n######\n#....#\n#....#\n#....#\n######\n\n###\n#.#\n###\n"], "source_document_id": "p02404", "source_text": "Print a Frame\n\nDraw a frame which has a height of H cm and a width of W cm. For example, the following figure shows a frame which has a height of 6 cm and a width of 10 cm.\n\n##########\n#........#\n#........#\n#........#\n#........#\n##########\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.\n\nThe input ends with two 0 (when both H and W are zero).\n\nOutput\n\nFor each dataset, print the frame made of '#' and '.'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n3 ≤ H ≤ 300\n\n3 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n3 3\n0 0\n\nSample Output\n\n####\n#..#\n####\n\n######\n#....#\n#....#\n#....#\n######\n\n###\n#.#\n###", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 450, "cpu_time_ms": 260, "memory_kb": 45940}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s634886217", "group_id": "codeNet:p02404", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val scanner = new java.util.Scanner(System.in)\n while(true) {\n val h, w = scanner.nextInt\n if((h == 0) && (w == 0)) System.exit(0)\n println(\"#\" * w)\n println((\"#\" + \".\" * (w - 2) + \"#\") * (h - 2))\n println(\"#\" * w)\n println()\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1523790309, "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/s634886217.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s634886217", "user_id": "u250696856"}, "prompt_components": {"gold_output": "####\n#..#\n####\n\n######\n#....#\n#....#\n#....#\n######\n\n###\n#.#\n###\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val scanner = new java.util.Scanner(System.in)\n while(true) {\n val h, w = scanner.nextInt\n if((h == 0) && (w == 0)) System.exit(0)\n println(\"#\" * w)\n println((\"#\" + \".\" * (w - 2) + \"#\") * (h - 2))\n println(\"#\" * w)\n println()\n }\n }\n}\n", "problem_context": "Print a Frame\n\nDraw a frame which has a height of H cm and a width of W cm. For example, the following figure shows a frame which has a height of 6 cm and a width of 10 cm.\n\n##########\n#........#\n#........#\n#........#\n#........#\n##########\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.\n\nThe input ends with two 0 (when both H and W are zero).\n\nOutput\n\nFor each dataset, print the frame made of '#' and '.'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n3 ≤ H ≤ 300\n\n3 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n3 3\n0 0\n\nSample Output\n\n####\n#..#\n####\n\n######\n#....#\n#....#\n#....#\n######\n\n###\n#.#\n###", "sample_input": "3 4\n5 6\n3 3\n0 0\n"}, "reference_outputs": ["####\n#..#\n####\n\n######\n#....#\n#....#\n#....#\n######\n\n###\n#.#\n###\n"], "source_document_id": "p02404", "source_text": "Print a Frame\n\nDraw a frame which has a height of H cm and a width of W cm. For example, the following figure shows a frame which has a height of 6 cm and a width of 10 cm.\n\n##########\n#........#\n#........#\n#........#\n#........#\n##########\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.\n\nThe input ends with two 0 (when both H and W are zero).\n\nOutput\n\nFor each dataset, print the frame made of '#' and '.'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n3 ≤ H ≤ 300\n\n3 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n3 3\n0 0\n\nSample Output\n\n####\n#..#\n####\n\n######\n#....#\n#....#\n#....#\n######\n\n###\n#.#\n###", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 331, "cpu_time_ms": 240, "memory_kb": 45176}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s595354669", "group_id": "codeNet:p02404", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val scanner = new java.util.Scanner(System.in)\n while(true) {\n val h, w = scanner.nextInt\n if((h == 0) && (w == 0)) System.exit(0)\n println(\"#\" * w)\n print((\"#\" + \".\" * (w - 2) + \"#\\n\") * (h - 2))\n println(\"#\" * w)\n println()\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1523790562, "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/s595354669.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s595354669", "user_id": "u250696856"}, "prompt_components": {"gold_output": "####\n#..#\n####\n\n######\n#....#\n#....#\n#....#\n######\n\n###\n#.#\n###\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val scanner = new java.util.Scanner(System.in)\n while(true) {\n val h, w = scanner.nextInt\n if((h == 0) && (w == 0)) System.exit(0)\n println(\"#\" * w)\n print((\"#\" + \".\" * (w - 2) + \"#\\n\") * (h - 2))\n println(\"#\" * w)\n println()\n }\n }\n}\n", "problem_context": "Print a Frame\n\nDraw a frame which has a height of H cm and a width of W cm. For example, the following figure shows a frame which has a height of 6 cm and a width of 10 cm.\n\n##########\n#........#\n#........#\n#........#\n#........#\n##########\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.\n\nThe input ends with two 0 (when both H and W are zero).\n\nOutput\n\nFor each dataset, print the frame made of '#' and '.'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n3 ≤ H ≤ 300\n\n3 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n3 3\n0 0\n\nSample Output\n\n####\n#..#\n####\n\n######\n#....#\n#....#\n#....#\n######\n\n###\n#.#\n###", "sample_input": "3 4\n5 6\n3 3\n0 0\n"}, "reference_outputs": ["####\n#..#\n####\n\n######\n#....#\n#....#\n#....#\n######\n\n###\n#.#\n###\n"], "source_document_id": "p02404", "source_text": "Print a Frame\n\nDraw a frame which has a height of H cm and a width of W cm. For example, the following figure shows a frame which has a height of 6 cm and a width of 10 cm.\n\n##########\n#........#\n#........#\n#........#\n#........#\n##########\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.\n\nThe input ends with two 0 (when both H and W are zero).\n\nOutput\n\nFor each dataset, print the frame made of '#' and '.'.\n\nPrint a blank line after each dataset.\n\nConstraints\n\n3 ≤ H ≤ 300\n\n3 ≤ W ≤ 300\n\nSample Input\n\n3 4\n5 6\n3 3\n0 0\n\nSample Output\n\n####\n#..#\n####\n\n######\n#....#\n#....#\n#....#\n######\n\n###\n#.#\n###", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 331, "cpu_time_ms": 310, "memory_kb": 45372}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s614390433", "group_id": "codeNet:p02405", "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 println((List.tabulate(h, w){(i, j) =>\n val isSharp = (i % 2 == 0 && j % 2 == 0) || (i % 2 != 0 && j % 2 != 0)\n val isDot = !isSharp\n val EOL = j == w-1\n\n if(isSharp && EOL) \"#\\n\"\n else if(isDot && EOL) \".\\n\"\n else if(isSharp) \"#\"\n else \".\"\n }).flatten.mkString)\n }\n }\n }\n}", "language": "Scala", "metadata": {"date": 1439310068, "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/s614390433.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s614390433", "user_id": "u389172382"}, "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\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 println((List.tabulate(h, w){(i, j) =>\n val isSharp = (i % 2 == 0 && j % 2 == 0) || (i % 2 != 0 && j % 2 != 0)\n val isDot = !isSharp\n val EOL = j == w-1\n\n if(isSharp && EOL) \"#\\n\"\n else if(isDot && EOL) \".\\n\"\n else if(isSharp) \"#\"\n else \".\"\n }).flatten.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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 270, "memory_kb": 48532}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s152350548", "group_id": "codeNet:p02405", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n printChessboard(sc.nextInt(), sc.nextInt())\n\n def printChessboard(h: Int, w: Int): Unit = {\n (h, w) match {\n case (0, 0) => sc.close()\n case _ =>\n for (i <- 1 to h) i match {\n case _ if i % 2 != 0 => printOddRow(w)\n case _ if i % 2 == 0 => printEvenRow(w)\n }\n println()\n printChessboard(sc.nextInt(), sc.nextInt())\n }\n }\n\n def printOddRow(w: Int): Unit = {\n for (i <- 1 to w) i match {\n case _ if i % 2 != 0 => print(\"#\")\n case _ if i % 2 == 0 => print(\".\")\n }\n print(\"\\n\")\n }\n\n def printEvenRow(w: Int): Unit = {\n for (i <- 1 to w) i match {\n case _ if i % 2 != 0 => print(\".\")\n case _ if i % 2 == 0 => print(\"#\")\n }\n print(\"\\n\")\n }\n}", "language": "Scala", "metadata": {"date": 1451414929, "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/s152350548.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s152350548", "user_id": "u223249350"}, "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": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n printChessboard(sc.nextInt(), sc.nextInt())\n\n def printChessboard(h: Int, w: Int): Unit = {\n (h, w) match {\n case (0, 0) => sc.close()\n case _ =>\n for (i <- 1 to h) i match {\n case _ if i % 2 != 0 => printOddRow(w)\n case _ if i % 2 == 0 => printEvenRow(w)\n }\n println()\n printChessboard(sc.nextInt(), sc.nextInt())\n }\n }\n\n def printOddRow(w: Int): Unit = {\n for (i <- 1 to w) i match {\n case _ if i % 2 != 0 => print(\"#\")\n case _ if i % 2 == 0 => print(\".\")\n }\n print(\"\\n\")\n }\n\n def printEvenRow(w: Int): Unit = {\n for (i <- 1 to w) i match {\n case _ if i % 2 != 0 => print(\".\")\n case _ if i % 2 == 0 => print(\"#\")\n }\n print(\"\\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 813, "cpu_time_ms": 420, "memory_kb": 53096}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s434258235", "group_id": "codeNet:p02406", "input_text": "object Main extends App {\n val n = scala.io.StdIn.readLine.toInt\n println((1 to n).filter(x => x % 3 == 0 | x.toString.exists(_ == '3')).map(\" \" + _).mkString(\"\"))\n}", "language": "Scala", "metadata": {"date": 1440260108, "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/s434258235.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s434258235", "user_id": "u490032117"}, "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 n = scala.io.StdIn.readLine.toInt\n println((1 to n).filter(x => x % 3 == 0 | x.toString.exists(_ == '3')).map(\" \" + _).mkString(\"\"))\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 290, "memory_kb": 50068}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s215391497", "group_id": "codeNet:p02406", "input_text": "object Main extends App {\n val scanner = new java.util.Scanner(System.in)\n val n = scanner.nextInt()\n\n val outputs = (1 to n).filter { i =>\n i % 3 == 0 || (i.toString).contains('3')\n }\n\n println(\" \" + outputs.mkString(\" \"))\n}", "language": "Scala", "metadata": {"date": 1500740665, "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/s215391497.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s215391497", "user_id": "u561540748"}, "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 scanner = new java.util.Scanner(System.in)\n val n = scanner.nextInt()\n\n val outputs = (1 to n).filter { i =>\n i % 3 == 0 || (i.toString).contains('3')\n }\n\n println(\" \" + outputs.mkString(\" \"))\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 280, "memory_kb": 49632}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s373751382", "group_id": "codeNet:p02406", "input_text": "/**\n * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_5_D\n * Structured Program I - Structured Programming\n */\nobject Main {\n def main(args: Array[String]): Unit = {\n val n = io.StdIn.readInt()\n val result = (1 to n).foldLeft(\"\") {\n (str, i) => {\n str + {\n if (i % 3 == 0 || i.toString.contains(\"3\"))\n s\" $i\"\n else\n \"\"\n }\n }\n }\n println(result)\n }\n}", "language": "Scala", "metadata": {"date": 1502522125, "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/s373751382.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Memory Limit Exceeded", "submission_id": "s373751382", "user_id": "u757244973"}, "prompt_components": {"gold_output": " 3 6 9 12 13 15 18 21 23 24 27 30\n", "input_to_evaluate": "/**\n * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_5_D\n * Structured Program I - Structured Programming\n */\nobject Main {\n def main(args: Array[String]): Unit = {\n val n = io.StdIn.readInt()\n val result = (1 to n).foldLeft(\"\") {\n (str, i) => {\n str + {\n if (i % 3 == 0 || i.toString.contains(\"3\"))\n s\" $i\"\n else\n \"\"\n }\n }\n }\n println(result)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 445, "cpu_time_ms": 790, "memory_kb": 460748}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s279849211", "group_id": "codeNet:p02407", "input_text": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n readLine()\n\n val xs = readLine().split(\" \")\n println(xs.reverse.mkString(\" \"))\n}\n\n", "language": "Scala", "metadata": {"date": 1590189350, "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/s279849211.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s279849211", "user_id": "u912124184"}, "prompt_components": {"gold_output": "5 4 3 2 1\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n readLine()\n\n val xs = readLine().split(\" \")\n println(xs.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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 300, "memory_kb": 43572}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s548880525", "group_id": "codeNet:p02408", "input_text": "object Main {\n def main(args: Array[String]) = {\n val in = io.Source.stdin.getLines.toList.tail\n val ans = \"SHCD\".flatMap(c => (1 to 13).map(c + \" \" + _)) diff in\n ans.foreach(println)\n }\n}", "language": "Scala", "metadata": {"date": 1482457246, "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/s548880525.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s548880525", "user_id": "u475394465"}, "prompt_components": {"gold_output": "S 1\nH 3\nH 7\nC 12\nD 8\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]) = {\n val in = io.Source.stdin.getLines.toList.tail\n val ans = \"SHCD\".flatMap(c => (1 to 13).map(c + \" \" + _)) diff in\n ans.foreach(println)\n }\n}", "problem_context": "Finding Missing Cards\n\nTaro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers).\n\nThe 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.\n\nInput\n\nIn the first line, the number of cards n (n ≤ 52) is given.\n\nIn the following n lines, data of the n cards are given. Each card is given by a pair of a character and an integer which represent its suit and rank respectively. A suit is represented by 'S', 'H', 'C' and 'D' for spades, hearts, clubs and diamonds respectively. A rank is represented by an integer from 1 to 13.\n\nOutput\n\nPrint the missing cards. The same as the input format, each card should be printed with a character and an integer separated by a space character in a line.\nArrange the missing cards in the following priorities:\n\nPrint cards of spades, hearts, clubs and diamonds in this order.\n\nIf the suits are equal, print cards with lower ranks first.\n\nSample Input\n\n47\nS 10\nS 11\nS 12\nS 13\nH 1\nH 2\nS 6\nS 7\nS 8\nS 9\nH 6\nH 8\nH 9\nH 10\nH 11\nH 4\nH 5\nS 2\nS 3\nS 4\nS 5\nH 12\nH 13\nC 1\nC 2\nD 1\nD 2\nD 3\nD 4\nD 5\nD 6\nD 7\nC 3\nC 4\nC 5\nC 6\nC 7\nC 8\nC 9\nC 10\nC 11\nC 13\nD 9\nD 10\nD 11\nD 12\nD 13\n\nSample Output\n\nS 1\nH 3\nH 7\nC 12\nD 8\n\nNote\n\n      解説", "sample_input": "47\nS 10\nS 11\nS 12\nS 13\nH 1\nH 2\nS 6\nS 7\nS 8\nS 9\nH 6\nH 8\nH 9\nH 10\nH 11\nH 4\nH 5\nS 2\nS 3\nS 4\nS 5\nH 12\nH 13\nC 1\nC 2\nD 1\nD 2\nD 3\nD 4\nD 5\nD 6\nD 7\nC 3\nC 4\nC 5\nC 6\nC 7\nC 8\nC 9\nC 10\nC 11\nC 13\nD 9\nD 10\nD 11\nD 12\nD 13\n"}, "reference_outputs": ["S 1\nH 3\nH 7\nC 12\nD 8\n"], "source_document_id": "p02408", "source_text": "Finding Missing Cards\n\nTaro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers).\n\nThe 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.\n\nInput\n\nIn the first line, the number of cards n (n ≤ 52) is given.\n\nIn the following n lines, data of the n cards are given. Each card is given by a pair of a character and an integer which represent its suit and rank respectively. A suit is represented by 'S', 'H', 'C' and 'D' for spades, hearts, clubs and diamonds respectively. A rank is represented by an integer from 1 to 13.\n\nOutput\n\nPrint the missing cards. The same as the input format, each card should be printed with a character and an integer separated by a space character in a line.\nArrange the missing cards in the following priorities:\n\nPrint cards of spades, hearts, clubs and diamonds in this order.\n\nIf the suits are equal, print cards with lower ranks first.\n\nSample Input\n\n47\nS 10\nS 11\nS 12\nS 13\nH 1\nH 2\nS 6\nS 7\nS 8\nS 9\nH 6\nH 8\nH 9\nH 10\nH 11\nH 4\nH 5\nS 2\nS 3\nS 4\nS 5\nH 12\nH 13\nC 1\nC 2\nD 1\nD 2\nD 3\nD 4\nD 5\nD 6\nD 7\nC 3\nC 4\nC 5\nC 6\nC 7\nC 8\nC 9\nC 10\nC 11\nC 13\nD 9\nD 10\nD 11\nD 12\nD 13\n\nSample Output\n\nS 1\nH 3\nH 7\nC 12\nD 8\n\nNote\n\n      解説", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 216, "cpu_time_ms": 240, "memory_kb": 43940}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s046777111", "group_id": "codeNet:p02408", "input_text": "object Main {\n def main(args: Array[String]) = {\n val in = io.Source.stdin.getLines.toList.tail\n (\"SHCD\".flatMap(c => (1 to 13).map(c + \" \" + _)) diff in).foreach(println)\n }\n}", "language": "Scala", "metadata": {"date": 1482457739, "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/s046777111.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s046777111", "user_id": "u475394465"}, "prompt_components": {"gold_output": "S 1\nH 3\nH 7\nC 12\nD 8\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]) = {\n val in = io.Source.stdin.getLines.toList.tail\n (\"SHCD\".flatMap(c => (1 to 13).map(c + \" \" + _)) diff in).foreach(println)\n }\n}", "problem_context": "Finding Missing Cards\n\nTaro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers).\n\nThe 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.\n\nInput\n\nIn the first line, the number of cards n (n ≤ 52) is given.\n\nIn the following n lines, data of the n cards are given. Each card is given by a pair of a character and an integer which represent its suit and rank respectively. A suit is represented by 'S', 'H', 'C' and 'D' for spades, hearts, clubs and diamonds respectively. A rank is represented by an integer from 1 to 13.\n\nOutput\n\nPrint the missing cards. The same as the input format, each card should be printed with a character and an integer separated by a space character in a line.\nArrange the missing cards in the following priorities:\n\nPrint cards of spades, hearts, clubs and diamonds in this order.\n\nIf the suits are equal, print cards with lower ranks first.\n\nSample Input\n\n47\nS 10\nS 11\nS 12\nS 13\nH 1\nH 2\nS 6\nS 7\nS 8\nS 9\nH 6\nH 8\nH 9\nH 10\nH 11\nH 4\nH 5\nS 2\nS 3\nS 4\nS 5\nH 12\nH 13\nC 1\nC 2\nD 1\nD 2\nD 3\nD 4\nD 5\nD 6\nD 7\nC 3\nC 4\nC 5\nC 6\nC 7\nC 8\nC 9\nC 10\nC 11\nC 13\nD 9\nD 10\nD 11\nD 12\nD 13\n\nSample Output\n\nS 1\nH 3\nH 7\nC 12\nD 8\n\nNote\n\n      解説", "sample_input": "47\nS 10\nS 11\nS 12\nS 13\nH 1\nH 2\nS 6\nS 7\nS 8\nS 9\nH 6\nH 8\nH 9\nH 10\nH 11\nH 4\nH 5\nS 2\nS 3\nS 4\nS 5\nH 12\nH 13\nC 1\nC 2\nD 1\nD 2\nD 3\nD 4\nD 5\nD 6\nD 7\nC 3\nC 4\nC 5\nC 6\nC 7\nC 8\nC 9\nC 10\nC 11\nC 13\nD 9\nD 10\nD 11\nD 12\nD 13\n"}, "reference_outputs": ["S 1\nH 3\nH 7\nC 12\nD 8\n"], "source_document_id": "p02408", "source_text": "Finding Missing Cards\n\nTaro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers).\n\nThe 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.\n\nInput\n\nIn the first line, the number of cards n (n ≤ 52) is given.\n\nIn the following n lines, data of the n cards are given. Each card is given by a pair of a character and an integer which represent its suit and rank respectively. A suit is represented by 'S', 'H', 'C' and 'D' for spades, hearts, clubs and diamonds respectively. A rank is represented by an integer from 1 to 13.\n\nOutput\n\nPrint the missing cards. The same as the input format, each card should be printed with a character and an integer separated by a space character in a line.\nArrange the missing cards in the following priorities:\n\nPrint cards of spades, hearts, clubs and diamonds in this order.\n\nIf the suits are equal, print cards with lower ranks first.\n\nSample Input\n\n47\nS 10\nS 11\nS 12\nS 13\nH 1\nH 2\nS 6\nS 7\nS 8\nS 9\nH 6\nH 8\nH 9\nH 10\nH 11\nH 4\nH 5\nS 2\nS 3\nS 4\nS 5\nH 12\nH 13\nC 1\nC 2\nD 1\nD 2\nD 3\nD 4\nD 5\nD 6\nD 7\nC 3\nC 4\nC 5\nC 6\nC 7\nC 8\nC 9\nC 10\nC 11\nC 13\nD 9\nD 10\nD 11\nD 12\nD 13\n\nSample Output\n\nS 1\nH 3\nH 7\nC 12\nD 8\n\nNote\n\n      解説", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 196, "cpu_time_ms": 230, "memory_kb": 44004}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s698806863", "group_id": "codeNet:p02409", "input_text": "import scala.io.StdIn\nimport scala.annotation.tailrec\n\n/**\n * AOJ\n */\nobject Main {\n\n def main(args: Array[String]): Unit = {\n\n val house = Array.ofDim[Int](House.building, House.floor, House.room)\n for (_ <- 1 to StdIn.readInt()) {\n val in = StdIn.readLine().split(\" \").map(_.toInt)\n house(in(0) - 1)(in(1) - 1)(in(2) - 1) += in(3)\n }\n for(i <- 0 to House.building - 1; j <- 0 to House.floor - 1){\n println(\" \" + house(i)(j).mkString(\" \"))\n if(j == House.floor - 1){println(\"#\" * 20)}\n }\n }\n}\n\nobject House {\n val building = 4\n val floor = 3\n val room = 10\n}", "language": "Scala", "metadata": {"date": 1498376750, "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/s698806863.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s698806863", "user_id": "u048060093"}, "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": "import scala.io.StdIn\nimport scala.annotation.tailrec\n\n/**\n * AOJ\n */\nobject Main {\n\n def main(args: Array[String]): Unit = {\n\n val house = Array.ofDim[Int](House.building, House.floor, House.room)\n for (_ <- 1 to StdIn.readInt()) {\n val in = StdIn.readLine().split(\" \").map(_.toInt)\n house(in(0) - 1)(in(1) - 1)(in(2) - 1) += in(3)\n }\n for(i <- 0 to House.building - 1; j <- 0 to House.floor - 1){\n println(\" \" + house(i)(j).mkString(\" \"))\n if(j == House.floor - 1){println(\"#\" * 20)}\n }\n }\n}\n\nobject House {\n val building = 4\n val floor = 3\n val room = 10\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 230, "memory_kb": 44124}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s972260318", "group_id": "codeNet:p02410", "input_text": "object Main extends App {\n val x :: y = io.Source.stdin.getLines.map(_.split(\" \").map(_.toInt)).toList\n val a = y.take(x(0))\n val b = y.drop(x(0)).flatten\n a.foreach(x => println(x.zip(b).map(p => p._1 * p._2).sum))\n}", "language": "Scala", "metadata": {"date": 1486526743, "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/s972260318.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s972260318", "user_id": "u475394465"}, "prompt_components": {"gold_output": "5\n6\n9\n", "input_to_evaluate": "object Main extends App {\n val x :: y = io.Source.stdin.getLines.map(_.split(\" \").map(_.toInt)).toList\n val a = y.take(x(0))\n val b = y.drop(x(0)).flatten\n a.foreach(x => println(x.zip(b).map(p => p._1 * p._2).sum))\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMatrix Vector Multiplication\n\nWrite a program which reads a $ n \\times m$ matrix $A$ and a $m \\times 1$ vector $b$, and prints their product $Ab$.\n\nA column vector with m elements is represented by the following equation.\n\n\\[\nb = \\left(\n\\begin{array}{c}\nb_1 \\\\\nb_2 \\\\\n: \\\\\nb_m \\\\\n\\end{array}\n\\right)\n\\]\n\nA $n \\times m$ matrix with $m$ column vectors, each of which consists of $n$ elements, is represented by the following equation.\n\n\\[\nA = \\left(\n\\begin{array}{cccc}\na_{11} & a_{12} & ... & a_{1m} \\\\\na_{21} & a_{22} & ... & a_{2m} \\\\\n: & : & : & : \\\\\na_{n1} & a_{n2} & ... & a_{nm} \\\\\n\\end{array}\n\\right)\n\\]\n\n$i$-th element of a $m \\times 1$ column vector $b$ is represented by $b_i$ ($i = 1, 2, ..., m$), and the element in $i$-th row and $j$-th column of a matrix $A$ is represented by $a_{ij}$ ($i = 1, 2, ..., n,$ $j = 1, 2, ..., m$).\n\nThe product of a $n \\times m$ matrix $A$ and a $m \\times 1$ column vector $b$ is a $n \\times 1$ column vector $c$, and $c_i$ is obtained by the following formula:\n\n\\[\nc_i = \\sum_{j=1}^m a_{ij}b_j = a_{i1}b_1 + a_{i2}b_2 + ... + a_{im}b_m\n\\]\n\nInput\n\nIn the first line, two integers $n$ and $m$ are given. In the following $n$ lines, $a_{ij}$ are given separated by a single space character. In the next $m$ lines, $b_i$ is given in a line.\n\nOutput\n\nThe output consists of $n$ lines. Print $c_i$ in a line.\n\nConstraints\n\n$1 \\leq n, m \\leq 100$\n\n$0 \\leq b_i, a_{ij} \\leq 1000$\n\nSample Input\n\n3 4\n1 2 0 1\n0 3 0 1\n4 1 1 0\n1\n2\n3\n0\n\nSample Output\n\n5\n6\n9", "sample_input": "3 4\n1 2 0 1\n0 3 0 1\n4 1 1 0\n1\n2\n3\n0\n"}, "reference_outputs": ["5\n6\n9\n"], "source_document_id": "p02410", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nMatrix Vector Multiplication\n\nWrite a program which reads a $ n \\times m$ matrix $A$ and a $m \\times 1$ vector $b$, and prints their product $Ab$.\n\nA column vector with m elements is represented by the following equation.\n\n\\[\nb = \\left(\n\\begin{array}{c}\nb_1 \\\\\nb_2 \\\\\n: \\\\\nb_m \\\\\n\\end{array}\n\\right)\n\\]\n\nA $n \\times m$ matrix with $m$ column vectors, each of which consists of $n$ elements, is represented by the following equation.\n\n\\[\nA = \\left(\n\\begin{array}{cccc}\na_{11} & a_{12} & ... & a_{1m} \\\\\na_{21} & a_{22} & ... & a_{2m} \\\\\n: & : & : & : \\\\\na_{n1} & a_{n2} & ... & a_{nm} \\\\\n\\end{array}\n\\right)\n\\]\n\n$i$-th element of a $m \\times 1$ column vector $b$ is represented by $b_i$ ($i = 1, 2, ..., m$), and the element in $i$-th row and $j$-th column of a matrix $A$ is represented by $a_{ij}$ ($i = 1, 2, ..., n,$ $j = 1, 2, ..., m$).\n\nThe product of a $n \\times m$ matrix $A$ and a $m \\times 1$ column vector $b$ is a $n \\times 1$ column vector $c$, and $c_i$ is obtained by the following formula:\n\n\\[\nc_i = \\sum_{j=1}^m a_{ij}b_j = a_{i1}b_1 + a_{i2}b_2 + ... + a_{im}b_m\n\\]\n\nInput\n\nIn the first line, two integers $n$ and $m$ are given. In the following $n$ lines, $a_{ij}$ are given separated by a single space character. In the next $m$ lines, $b_i$ is given in a line.\n\nOutput\n\nThe output consists of $n$ lines. Print $c_i$ in a line.\n\nConstraints\n\n$1 \\leq n, m \\leq 100$\n\n$0 \\leq b_i, a_{ij} \\leq 1000$\n\nSample Input\n\n3 4\n1 2 0 1\n0 3 0 1\n4 1 1 0\n1\n2\n3\n0\n\nSample Output\n\n5\n6\n9", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 229, "cpu_time_ms": 330, "memory_kb": 49144}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s890248822", "group_id": "codeNet:p02412", "input_text": "import scala.io.StdIn\n\nobject Main{\n def main(args: Array[String]){\n val num = StdIn.readLine().split(\" \").map(_.toInt)\n var count = 0\n\n for(i <- 1 to num(0)){\n for(j <- i+1 to num(0)){\n for(k <- j+1 to num(0)){\n if(i + j + k == num(1)){\n count += 1\n }\n }\n }\n }\n if(num(0) > 0){\n println(count)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1439076958, "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/s890248822.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s890248822", "user_id": "u085441951"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main{\n def main(args: Array[String]){\n val num = StdIn.readLine().split(\" \").map(_.toInt)\n var count = 0\n\n for(i <- 1 to num(0)){\n for(j <- i+1 to num(0)){\n for(k <- j+1 to num(0)){\n if(i + j + k == num(1)){\n count += 1\n }\n }\n }\n }\n if(num(0) > 0){\n println(count)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 385, "cpu_time_ms": 240, "memory_kb": 44288}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s896436763", "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": 1482337175, "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/s896436763.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s896436763", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 44148}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s888056075", "group_id": "codeNet:p02413", "input_text": "object Main extends App {\n val scanner = new java.util.Scanner(System.in)\n\n val r = scanner.nextInt()\n val c = scanner.nextInt()\n\n val inputs = (1 to r).map {\n _ => (1 to c).map(_ => scanner.nextInt())\n }\n\n val row_sum = inputs.map { row =>\n row :+ row.sum\n }\n val column_sum = row_sum.foldLeft(Vector.fill(c+1)(0)) { (acc, row) =>\n (acc zip row).map(t => t._1 + t._2)\n }\n\n val outputs = row_sum :+ column_sum\n\n outputs.map(_.mkString(\" \")).foreach(println)\n}", "language": "Scala", "metadata": {"date": 1500802514, "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/s888056075.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s888056075", "user_id": "u561540748"}, "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 extends App {\n val scanner = new java.util.Scanner(System.in)\n\n val r = scanner.nextInt()\n val c = scanner.nextInt()\n\n val inputs = (1 to r).map {\n _ => (1 to c).map(_ => scanner.nextInt())\n }\n\n val row_sum = inputs.map { row =>\n row :+ row.sum\n }\n val column_sum = row_sum.foldLeft(Vector.fill(c+1)(0)) { (acc, row) =>\n (acc zip row).map(t => t._1 + t._2)\n }\n\n val outputs = row_sum :+ column_sum\n\n outputs.map(_.mkString(\" \")).foreach(println)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 420, "memory_kb": 60184}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s288982797", "group_id": "codeNet:p02413", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n\n val Array(r, c) = StdIn.readLine().split(' ').map(_.toInt)\n val result = Array.fill(r, c+1)(0) \n val temp = Array.fill(c+1)(0)\n \n (0 until r).foreach{ i =>\n result(i) = (StdIn.readLine() + \" 0\").split(' ').map(_.toInt)\n result(i)(c) = result(i).sum\n\n (0 to c).foreach{ k =>\n temp(k) += result(i)(k)\n }\n }\n\n (0 until r).foreach{ i =>\n println(result(i).toList.mkString(\" \"))\n }\n println(temp.toList.mkString(\" \"))\n \n}\n\n", "language": "Scala", "metadata": {"date": 1524355361, "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/s288982797.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s288982797", "user_id": "u342234782"}, "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.StdIn\n\nobject Main extends App {\n\n val Array(r, c) = StdIn.readLine().split(' ').map(_.toInt)\n val result = Array.fill(r, c+1)(0) \n val temp = Array.fill(c+1)(0)\n \n (0 until r).foreach{ i =>\n result(i) = (StdIn.readLine() + \" 0\").split(' ').map(_.toInt)\n result(i)(c) = result(i).sum\n\n (0 to c).foreach{ k =>\n temp(k) += result(i)(k)\n }\n }\n\n (0 until r).foreach{ i =>\n println(result(i).toList.mkString(\" \"))\n }\n println(temp.toList.mkString(\" \"))\n \n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 330, "memory_kb": 48884}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s837567288", "group_id": "codeNet:p02415", "input_text": "object Main{\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n while (sc.hasNext()){\n sc.next.toCharArray.foreach(x => print(swap_case_as_int(x.toInt).toChar))\n print(\" \")\n }\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": 1446140817, "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/s837567288.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "WA: Presentation Error", "submission_id": "s837567288", "user_id": "u879226672"}, "prompt_components": {"gold_output": "Fair, later, occasionally cloudy.\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 sc.next.toCharArray.foreach(x => print(swap_case_as_int(x.toInt).toChar))\n print(\" \")\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 390, "cpu_time_ms": 260, "memory_kb": 45080}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s951876178", "group_id": "codeNet:p02416", "input_text": "object Main extends App {\n io.Source.stdin.getLines.toList.init.map(_.map(_.toString.toInt).sum).map(println)\n}\n\n", "language": "Scala", "metadata": {"date": 1517275753, "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/s951876178.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s951876178", "user_id": "u387507798"}, "prompt_components": {"gold_output": "6\n10\n1\n", "input_to_evaluate": "object Main extends App {\n io.Source.stdin.getLines.toList.init.map(_.map(_.toString.toInt).sum).map(println)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 114, "cpu_time_ms": 250, "memory_kb": 44500}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s576034697", "group_id": "codeNet:p02416", "input_text": "import scala.collection.mutable.ListBuffer\nimport scala.io.StdIn\n\nobject Main extends App {\n\n var target = \"-1\"\n val buff = ListBuffer.empty[String]\n while(target != \"0\"){\n target = StdIn.readLine()\n buff += target.foldLeft(0){ (acc, f) =>\n acc + f.toString.toInt\n }.toString\n }\n \n println(buff.dropRight(1).mkString(f\"%n\"))\n}\n", "language": "Scala", "metadata": {"date": 1524536270, "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/s576034697.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s576034697", "user_id": "u342234782"}, "prompt_components": {"gold_output": "6\n10\n1\n", "input_to_evaluate": "import scala.collection.mutable.ListBuffer\nimport scala.io.StdIn\n\nobject Main extends App {\n\n var target = \"-1\"\n val buff = ListBuffer.empty[String]\n while(target != \"0\"){\n target = StdIn.readLine()\n buff += target.foldLeft(0){ (acc, f) =>\n acc + f.toString.toInt\n }.toString\n }\n \n println(buff.dropRight(1).mkString(f\"%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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 44316}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s741897892", "group_id": "codeNet:p02417", "input_text": "object Main {\n def main(args: Array[String]) = {\n val a = io.StdIn.readLine.toLowerCase\n ('a' to 'z').foreach(c => println(c + \" : \" + a.count(_ == c)))\n }\n}", "language": "Scala", "metadata": {"date": 1482398939, "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/s741897892.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s741897892", "user_id": "u475394465"}, "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": "object Main {\n def main(args: Array[String]) = {\n val a = io.StdIn.readLine.toLowerCase\n ('a' to 'z').foreach(c => println(c + \" : \" + a.count(_ == c)))\n }\n}", "problem_context": "Counting Characters\n\nWrite a program which counts and reports the number of each alphabetical letter. Ignore the case of characters.\n\nInput\n\nA sentence in English is given in several lines.\n\nOutput\n\nPrints the number of alphabetical letters in the following format:\n\na : The number of 'a'\nb : The number of 'b'\nc : The number of 'c'\n.\n.\nz : The number of 'z'\n\nConstraints\n\nThe number of characters in the sentence < 1200\n\nSample Input\n\nThis is a pen.\n\nSample Output\n\na : 1\nb : 0\nc : 0\nd : 0\ne : 1\nf : 0\ng : 0\nh : 1\ni : 2\nj : 0\nk : 0\nl : 0\nm : 0\nn : 1\no : 0\np : 1\nq : 0\nr : 0\ns : 2\nt : 1\nu : 0\nv : 0\nw : 0\nx : 0\ny : 0\nz : 0", "sample_input": "This is a pen.\n"}, "reference_outputs": ["a : 1\nb : 0\nc : 0\nd : 0\ne : 1\nf : 0\ng : 0\nh : 1\ni : 2\nj : 0\nk : 0\nl : 0\nm : 0\nn : 1\no : 0\np : 1\nq : 0\nr : 0\ns : 2\nt : 1\nu : 0\nv : 0\nw : 0\nx : 0\ny : 0\nz : 0\n"], "source_document_id": "p02417", "source_text": "Counting Characters\n\nWrite a program which counts and reports the number of each alphabetical letter. Ignore the case of characters.\n\nInput\n\nA sentence in English is given in several lines.\n\nOutput\n\nPrints the number of alphabetical letters in the following format:\n\na : The number of 'a'\nb : The number of 'b'\nc : The number of 'c'\n.\n.\nz : The number of 'z'\n\nConstraints\n\nThe number of characters in the sentence < 1200\n\nSample Input\n\nThis is a pen.\n\nSample Output\n\na : 1\nb : 0\nc : 0\nd : 0\ne : 1\nf : 0\ng : 0\nh : 1\ni : 2\nj : 0\nk : 0\nl : 0\nm : 0\nn : 1\no : 0\np : 1\nq : 0\nr : 0\ns : 2\nt : 1\nu : 0\nv : 0\nw : 0\nx : 0\ny : 0\nz : 0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 177, "cpu_time_ms": 240, "memory_kb": 44644}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s583540801", "group_id": "codeNet:p02417", "input_text": "object Main extends App {\n val scanner = new java.util.Scanner(System.in)\n scanner.useDelimiter(\"\")\n\n val input = Iterator.continually{\n scanner.next().head\n }.filter(_ != ' ').takeWhile(_ != '.')\n\n val outputs = input.foldLeft(List.fill('z' - 'a' + 1)(0)) { (list, c) =>\n val lower = c.toLower\n val index = lower - 'a'\n\n println(lower)\n\n list.updated(index, list(index) + 1)\n }.zipWithIndex\n\n outputs.foreach { t =>\n println(s\"${('a' + t._2).toChar} : ${t._1}\")\n }\n}", "language": "Scala", "metadata": {"date": 1500841209, "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/s583540801.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s583540801", "user_id": "u561540748"}, "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": "object Main extends App {\n val scanner = new java.util.Scanner(System.in)\n scanner.useDelimiter(\"\")\n\n val input = Iterator.continually{\n scanner.next().head\n }.filter(_ != ' ').takeWhile(_ != '.')\n\n val outputs = input.foldLeft(List.fill('z' - 'a' + 1)(0)) { (list, c) =>\n val lower = c.toLower\n val index = lower - 'a'\n\n println(lower)\n\n list.updated(index, list(index) + 1)\n }.zipWithIndex\n\n outputs.foreach { t =>\n println(s\"${('a' + t._2).toChar} : ${t._1}\")\n }\n}", "problem_context": "Counting Characters\n\nWrite a program which counts and reports the number of each alphabetical letter. Ignore the case of characters.\n\nInput\n\nA sentence in English is given in several lines.\n\nOutput\n\nPrints the number of alphabetical letters in the following format:\n\na : The number of 'a'\nb : The number of 'b'\nc : The number of 'c'\n.\n.\nz : The number of 'z'\n\nConstraints\n\nThe number of characters in the sentence < 1200\n\nSample Input\n\nThis is a pen.\n\nSample Output\n\na : 1\nb : 0\nc : 0\nd : 0\ne : 1\nf : 0\ng : 0\nh : 1\ni : 2\nj : 0\nk : 0\nl : 0\nm : 0\nn : 1\no : 0\np : 1\nq : 0\nr : 0\ns : 2\nt : 1\nu : 0\nv : 0\nw : 0\nx : 0\ny : 0\nz : 0", "sample_input": "This is a pen.\n"}, "reference_outputs": ["a : 1\nb : 0\nc : 0\nd : 0\ne : 1\nf : 0\ng : 0\nh : 1\ni : 2\nj : 0\nk : 0\nl : 0\nm : 0\nn : 1\no : 0\np : 1\nq : 0\nr : 0\ns : 2\nt : 1\nu : 0\nv : 0\nw : 0\nx : 0\ny : 0\nz : 0\n"], "source_document_id": "p02417", "source_text": "Counting Characters\n\nWrite a program which counts and reports the number of each alphabetical letter. Ignore the case of characters.\n\nInput\n\nA sentence in English is given in several lines.\n\nOutput\n\nPrints the number of alphabetical letters in the following format:\n\na : The number of 'a'\nb : The number of 'b'\nc : The number of 'c'\n.\n.\nz : The number of 'z'\n\nConstraints\n\nThe number of characters in the sentence < 1200\n\nSample Input\n\nThis is a pen.\n\nSample Output\n\na : 1\nb : 0\nc : 0\nd : 0\ne : 1\nf : 0\ng : 0\nh : 1\ni : 2\nj : 0\nk : 0\nl : 0\nm : 0\nn : 1\no : 0\np : 1\nq : 0\nr : 0\ns : 2\nt : 1\nu : 0\nv : 0\nw : 0\nx : 0\ny : 0\nz : 0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 493, "cpu_time_ms": 250, "memory_kb": 45332}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s045889446", "group_id": "codeNet:p02417", "input_text": "import scala.collection.mutable.ListBuffer\n\nobject Main extends App {\n\n private val alphabets = Array.ofDim[Int](26)\n private val buff = ListBuffer.empty[String]\n val sc = new java.util.Scanner(System.in)\n while(sc.hasNext){\n buff += sc.next\n }\n \n buff.mkString(\"\").foreach{ c =>\n val idx = c.toLower - 'a'\n if(idx >= 0) alphabets(idx) += 1\n }\n println(('a' to 'z').map(f => f.toString + \" : \" + alphabets(f - 'a')).mkString(f\"%n\"))\n \n}\n", "language": "Scala", "metadata": {"date": 1524696968, "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/s045889446.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s045889446", "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.collection.mutable.ListBuffer\n\nobject Main extends App {\n\n private val alphabets = Array.ofDim[Int](26)\n private val buff = ListBuffer.empty[String]\n val sc = new java.util.Scanner(System.in)\n while(sc.hasNext){\n buff += sc.next\n }\n \n buff.mkString(\"\").foreach{ c =>\n val idx = c.toLower - 'a'\n if(idx >= 0) alphabets(idx) += 1\n }\n println(('a' to 'z').map(f => f.toString + \" : \" + alphabets(f - 'a')).mkString(f\"%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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 260, "memory_kb": 45752}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s755512935", "group_id": "codeNet:p02417", "input_text": "import scala.collection.mutable\nimport scala.io.Source.stdin\n\nobject Main extends App {\n\n val lines = stdin.getLines()\n val xs = {\n val nums = ('a' to 'z').map { (_, 0) }\n\n val m = mutable.Map(nums: _*)\n for {\n line <- lines\n c <- line.map { _.toLower }\n if c.isLetter && c <= 'z'\n } {\n m(c) += 1\n }\n m.toSeq.sorted\n }\n\n for ((k, v) <- xs) {\n println(s\"$k : $v\")\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1590192057, "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/s755512935.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s755512935", "user_id": "u912124184"}, "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.collection.mutable\nimport scala.io.Source.stdin\n\nobject Main extends App {\n\n val lines = stdin.getLines()\n val xs = {\n val nums = ('a' to 'z').map { (_, 0) }\n\n val m = mutable.Map(nums: _*)\n for {\n line <- lines\n c <- line.map { _.toLower }\n if c.isLetter && c <= 'z'\n } {\n m(c) += 1\n }\n m.toSeq.sorted\n }\n\n for ((k, v) <- xs) {\n println(s\"$k : $v\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 330, "memory_kb": 44708}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s432703903", "group_id": "codeNet:p02418", "input_text": "import java.util.Scanner;\nobject Main {\n def main(args: Array[String]): Unit = {\n var sc = new Scanner(System.in)\n var s = sc.next * 2\n var p = sc.next\n println(if(s.contains(p)) \"Yes\" else \"No\")\n }\n}", "language": "Scala", "metadata": {"date": 1466260066, "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/s432703903.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s432703903", "user_id": "u765849500"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner;\nobject Main {\n def main(args: Array[String]): Unit = {\n var sc = new Scanner(System.in)\n var s = sc.next * 2\n var p = sc.next\n println(if(s.contains(p)) \"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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 214, "cpu_time_ms": 280, "memory_kb": 44960}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s893460675", "group_id": "codeNet:p02418", "input_text": "object Main {\n def main(args: Array[String]) = {\n val in = io.Source.stdin.getLines\n if (in.next * 2 contains in.next) println(\"Yes\")\n else println(\"No\")\n }\n}", "language": "Scala", "metadata": {"date": 1482376349, "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/s893460675.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s893460675", "user_id": "u475394465"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]) = {\n val in = io.Source.stdin.getLines\n if (in.next * 2 contains in.next) println(\"Yes\")\n else println(\"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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 280, "memory_kb": 43892}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s251162197", "group_id": "codeNet:p02418", "input_text": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n val s = readLine.trim\n val w = readLine.trim\n\n if ((s+s).contains(w)) println(\"Yes\") else println(\"No\")\n}", "language": "Scala", "metadata": {"date": 1482504376, "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/s251162197.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s251162197", "user_id": "u508732591"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n val s = readLine.trim\n val w = readLine.trim\n\n if ((s+s).contains(w)) println(\"Yes\") else println(\"No\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 270, "memory_kb": 43832}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s075022610", "group_id": "codeNet:p02419", "input_text": "import scala.io.Source\n\nobject Main extends App {\n val src = Source.stdin.getLines.toList.flatMap(_.split(\" \").map(_.toLowerCase).toList)\n println(src.tail.filter(str => str == src(0)).length)\n}", "language": "Scala", "metadata": {"date": 1511770745, "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/s075022610.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s075022610", "user_id": "u387507798"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.io.Source\n\nobject Main extends App {\n val src = Source.stdin.getLines.toList.flatMap(_.split(\" \").map(_.toLowerCase).toList)\n println(src.tail.filter(str => str == src(0)).length)\n}", "problem_context": "Finding a Word\n\nWrite a program which reads a word W and a text T, and prints the number of word W which appears in text T\n\nT consists of string Ti separated by space characters and newlines. Count the number of Ti which equals to W. The word and text are case insensitive.\n\nConstraints\n\nThe length of W ≤ 10\n\nW consists of lower case letters\n\nThe length of T in a line ≤ 1000\n\nInput\n\nIn the first line, the word W is given. In the following lines, the text T is given separated by space characters and newlines.\n\n\"END_OF_TEXT\" indicates the end of the text.\n\nOutput\n\nPrint the number of W in the text.\n\nSample Input\n\ncomputer\nNurtures computer scientists and highly-skilled computer engineers\nwho will create and exploit \"knowledge\" for the new era.\nProvides an outstanding computer environment.\nEND_OF_TEXT\n\nSample Output\n\n3", "sample_input": "computer\nNurtures computer scientists and highly-skilled computer engineers\nwho will create and exploit \"knowledge\" for the new era.\nProvides an outstanding computer environment.\nEND_OF_TEXT\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02419", "source_text": "Finding a Word\n\nWrite a program which reads a word W and a text T, and prints the number of word W which appears in text T\n\nT consists of string Ti separated by space characters and newlines. Count the number of Ti which equals to W. The word and text are case insensitive.\n\nConstraints\n\nThe length of W ≤ 10\n\nW consists of lower case letters\n\nThe length of T in a line ≤ 1000\n\nInput\n\nIn the first line, the word W is given. In the following lines, the text T is given separated by space characters and newlines.\n\n\"END_OF_TEXT\" indicates the end of the text.\n\nOutput\n\nPrint the number of W in the text.\n\nSample Input\n\ncomputer\nNurtures computer scientists and highly-skilled computer engineers\nwho will create and exploit \"knowledge\" for the new era.\nProvides an outstanding computer environment.\nEND_OF_TEXT\n\nSample Output\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 196, "cpu_time_ms": 280, "memory_kb": 43936}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s408385239", "group_id": "codeNet:p02420", "input_text": "import scala.io.StdIn.{readLine,readInt}\n\nobject Main extends App {\n var w = \"\"\n\n def shuffle(cnt:Int, w:String):String =\n if(cnt == 0) w else { val m = readInt;shuffle(cnt-1, (w drop m)+(w take m)) }\n\n def exec(w:String):Unit =\n if(w==\"-\") return else { val n = readInt;println(shuffle(n,w));exec(readLine) }\n\n exec(readLine.trim)\n}", "language": "Scala", "metadata": {"date": 1482597236, "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/s408385239.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s408385239", "user_id": "u508732591"}, "prompt_components": {"gold_output": "aabc\nxyzvw\n", "input_to_evaluate": "import scala.io.StdIn.{readLine,readInt}\n\nobject Main extends App {\n var w = \"\"\n\n def shuffle(cnt:Int, w:String):String =\n if(cnt == 0) w else { val m = readInt;shuffle(cnt-1, (w drop m)+(w take m)) }\n\n def exec(w:String):Unit =\n if(w==\"-\") return else { val n = readInt;println(shuffle(n,w));exec(readLine) }\n\n exec(readLine.trim)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 270, "memory_kb": 43840}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s936305915", "group_id": "codeNet:p02420", "input_text": "import scala.io.StdIn.{readLine,readInt}\n\nobject Main extends App {\n\n\n def exec(w:String):Unit = {\n val len = w.length\n\n if(w==\"-\") return else {\n val n = readInt\n var cnt = 0\n\n for(i <- 1 to n) cnt += readInt\n println((w drop (cnt%len)) + (w take (cnt%len)))\n exec(readLine)\n }\n }\n\n exec(readLine)\n}", "language": "Scala", "metadata": {"date": 1482601023, "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/s936305915.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s936305915", "user_id": "u508732591"}, "prompt_components": {"gold_output": "aabc\nxyzvw\n", "input_to_evaluate": "import scala.io.StdIn.{readLine,readInt}\n\nobject Main extends App {\n\n\n def exec(w:String):Unit = {\n val len = w.length\n\n if(w==\"-\") return else {\n val n = readInt\n var cnt = 0\n\n for(i <- 1 to n) cnt += readInt\n println((w drop (cnt%len)) + (w take (cnt%len)))\n exec(readLine)\n }\n }\n\n exec(readLine)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 338, "cpu_time_ms": 240, "memory_kb": 43884}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s541762650", "group_id": "codeNet:p02422", "input_text": "import scala.io.StdIn._\n\nobject Main {\n def transformation(s: String, n: Int, l: List[String] = Nil): List[String] = {\n if (n > 0) {\n val transformType = readLine().split(\" \")\n val start = transformType(1).toInt\n val end = transformType(2).toInt + 1\n val to = transformType(2).toInt - start + 1\n transformType(0) match {\n case \"print\" => transformation(s, n - 1, l :+ s.slice(start, end))\n case \"replace\" => transformation(s.patch(start, transformType(3), to), n - 1, l)\n case \"reverse\" =>\n val reverseText = s.slice(start, end).reverse\n val sReverse = s.patch(start, reverseText, to)\n transformation(sReverse, n - 1, l)\n }\n } else l\n }\n\n def main(args: Array[String]): Unit = {\n val originText = readLine()\n val transformNum = readInt()\n transformation(originText, transformNum).foreach(println)\n }\n}", "language": "Scala", "metadata": {"date": 1459755264, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02422.html", "problem_id": "p02422", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02422/input.txt", "sample_output_relpath": "derived/input_output/data/p02422/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02422/Scala/s541762650.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s541762650", "user_id": "u123244675"}, "prompt_components": {"gold_output": "xaze\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main {\n def transformation(s: String, n: Int, l: List[String] = Nil): List[String] = {\n if (n > 0) {\n val transformType = readLine().split(\" \")\n val start = transformType(1).toInt\n val end = transformType(2).toInt + 1\n val to = transformType(2).toInt - start + 1\n transformType(0) match {\n case \"print\" => transformation(s, n - 1, l :+ s.slice(start, end))\n case \"replace\" => transformation(s.patch(start, transformType(3), to), n - 1, l)\n case \"reverse\" =>\n val reverseText = s.slice(start, end).reverse\n val sReverse = s.patch(start, reverseText, to)\n transformation(sReverse, n - 1, l)\n }\n } else l\n }\n\n def main(args: Array[String]): Unit = {\n val originText = readLine()\n val transformNum = readInt()\n transformation(originText, transformNum).foreach(println)\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nTransformation\n\nWrite a program which performs a sequence of commands to a given string $str$. The command is one of:\n\nprint a b: print from the a-th character to the b-th character of $str$\n\nreverse a b: reverse from the a-th character to the b-th character of $str$\n\nreplace a b p: replace from the a-th character to the b-th character of $str$ with p\n\nNote that the indices of $str$ start with 0.\n\nInput\n\nIn the first line, a string $str$ is given. $str$ consists of lowercase letters. In the second line, the number of commands q is given. In the next q lines, each command is given in the above mentioned format.\n\nOutput\n\nFor each print command, print a string in a line.\n\nConstraints\n\n$1 \\leq $ length of $str \\leq 1000$\n\n$1 \\leq q \\leq 100$\n\n$0 \\leq a \\leq b < $ length of $str$\n\nfor replace command, $b - a + 1 = $ length of $p$\n\nSample Input 1\n\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n\nSample Output 1\n\nxaze\n\nSample Input 2\n\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n\nSample Output 2\n\nxyz\nabc", "sample_input": "abcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n"}, "reference_outputs": ["xaze\n"], "source_document_id": "p02422", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nTransformation\n\nWrite a program which performs a sequence of commands to a given string $str$. The command is one of:\n\nprint a b: print from the a-th character to the b-th character of $str$\n\nreverse a b: reverse from the a-th character to the b-th character of $str$\n\nreplace a b p: replace from the a-th character to the b-th character of $str$ with p\n\nNote that the indices of $str$ start with 0.\n\nInput\n\nIn the first line, a string $str$ is given. $str$ consists of lowercase letters. In the second line, the number of commands q is given. In the next q lines, each command is given in the above mentioned format.\n\nOutput\n\nFor each print command, print a string in a line.\n\nConstraints\n\n$1 \\leq $ length of $str \\leq 1000$\n\n$1 \\leq q \\leq 100$\n\n$0 \\leq a \\leq b < $ length of $str$\n\nfor replace command, $b - a + 1 = $ length of $p$\n\nSample Input 1\n\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n\nSample Output 1\n\nxaze\n\nSample Input 2\n\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n\nSample Output 2\n\nxyz\nabc", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 900, "cpu_time_ms": 260, "memory_kb": 45836}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s690399104", "group_id": "codeNet:p02422", "input_text": "object Main {\n def step(s: String, cmd: Array[String]) = cmd(0) match {\n case \"print\" => {println(s.slice(cmd(1).toInt, cmd(2).toInt+1)); s}\n case \"reverse\" => s.take(cmd(1).toInt) + s.slice(cmd(1).toInt, cmd(2).toInt+1).reverse +s.drop(cmd(2).toInt+1)\n case \"replace\" => s.take(cmd(1).toInt) + cmd(3) +s.drop(cmd(2).toInt+1)\n }\n def main(args: Array[String]): Unit = {\n val in = io.Source.stdin.getLines\n val s = in.next\n in.next\n in.map(_.split(\" \")).foldLeft(s)(step)\n }\n}", "language": "Scala", "metadata": {"date": 1483754124, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02422.html", "problem_id": "p02422", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02422/input.txt", "sample_output_relpath": "derived/input_output/data/p02422/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02422/Scala/s690399104.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s690399104", "user_id": "u475394465"}, "prompt_components": {"gold_output": "xaze\n", "input_to_evaluate": "object Main {\n def step(s: String, cmd: Array[String]) = cmd(0) match {\n case \"print\" => {println(s.slice(cmd(1).toInt, cmd(2).toInt+1)); s}\n case \"reverse\" => s.take(cmd(1).toInt) + s.slice(cmd(1).toInt, cmd(2).toInt+1).reverse +s.drop(cmd(2).toInt+1)\n case \"replace\" => s.take(cmd(1).toInt) + cmd(3) +s.drop(cmd(2).toInt+1)\n }\n def main(args: Array[String]): Unit = {\n val in = io.Source.stdin.getLines\n val s = in.next\n in.next\n in.map(_.split(\" \")).foldLeft(s)(step)\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nTransformation\n\nWrite a program which performs a sequence of commands to a given string $str$. The command is one of:\n\nprint a b: print from the a-th character to the b-th character of $str$\n\nreverse a b: reverse from the a-th character to the b-th character of $str$\n\nreplace a b p: replace from the a-th character to the b-th character of $str$ with p\n\nNote that the indices of $str$ start with 0.\n\nInput\n\nIn the first line, a string $str$ is given. $str$ consists of lowercase letters. In the second line, the number of commands q is given. In the next q lines, each command is given in the above mentioned format.\n\nOutput\n\nFor each print command, print a string in a line.\n\nConstraints\n\n$1 \\leq $ length of $str \\leq 1000$\n\n$1 \\leq q \\leq 100$\n\n$0 \\leq a \\leq b < $ length of $str$\n\nfor replace command, $b - a + 1 = $ length of $p$\n\nSample Input 1\n\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n\nSample Output 1\n\nxaze\n\nSample Input 2\n\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n\nSample Output 2\n\nxyz\nabc", "sample_input": "abcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n"}, "reference_outputs": ["xaze\n"], "source_document_id": "p02422", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nTransformation\n\nWrite a program which performs a sequence of commands to a given string $str$. The command is one of:\n\nprint a b: print from the a-th character to the b-th character of $str$\n\nreverse a b: reverse from the a-th character to the b-th character of $str$\n\nreplace a b p: replace from the a-th character to the b-th character of $str$ with p\n\nNote that the indices of $str$ start with 0.\n\nInput\n\nIn the first line, a string $str$ is given. $str$ consists of lowercase letters. In the second line, the number of commands q is given. In the next q lines, each command is given in the above mentioned format.\n\nOutput\n\nFor each print command, print a string in a line.\n\nConstraints\n\n$1 \\leq $ length of $str \\leq 1000$\n\n$1 \\leq q \\leq 100$\n\n$0 \\leq a \\leq b < $ length of $str$\n\nfor replace command, $b - a + 1 = $ length of $p$\n\nSample Input 1\n\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n\nSample Output 1\n\nxaze\n\nSample Input 2\n\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n\nSample Output 2\n\nxyz\nabc", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 536, "cpu_time_ms": 240, "memory_kb": 45164}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s980653110", "group_id": "codeNet:p02422", "input_text": "import scala.io.StdIn\n\n/**\n * AOJ\n */\nobject Main {\n\n def main(args: Array[String]): Unit = {\n\n var str = StdIn.readLine()\n val q = StdIn.readInt()\n\n for(_ <- 1 to q){\n\n val line = StdIn.readLine().split(\" \")\n val a = line(1).toInt\n val b = line(2).toInt\n\n line(0) match {\n case \"replace\" => {\n str = str.take(a) + line(3) + str.takeRight(str.length - b - 1)\n }\n case \"reverse\" => {\n str = str.take(a) + str.slice(a,b + 1).reverse + str.takeRight(str.length - b - 1)\n }\n case \"print\" => println(str.slice(a,b + 1))\n }\n }\n }\n}", "language": "Scala", "metadata": {"date": 1500127816, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02422.html", "problem_id": "p02422", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02422/input.txt", "sample_output_relpath": "derived/input_output/data/p02422/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02422/Scala/s980653110.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s980653110", "user_id": "u048060093"}, "prompt_components": {"gold_output": "xaze\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 var str = StdIn.readLine()\n val q = StdIn.readInt()\n\n for(_ <- 1 to q){\n\n val line = StdIn.readLine().split(\" \")\n val a = line(1).toInt\n val b = line(2).toInt\n\n line(0) match {\n case \"replace\" => {\n str = str.take(a) + line(3) + str.takeRight(str.length - b - 1)\n }\n case \"reverse\" => {\n str = str.take(a) + str.slice(a,b + 1).reverse + str.takeRight(str.length - b - 1)\n }\n case \"print\" => println(str.slice(a,b + 1))\n }\n }\n }\n}", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nTransformation\n\nWrite a program which performs a sequence of commands to a given string $str$. The command is one of:\n\nprint a b: print from the a-th character to the b-th character of $str$\n\nreverse a b: reverse from the a-th character to the b-th character of $str$\n\nreplace a b p: replace from the a-th character to the b-th character of $str$ with p\n\nNote that the indices of $str$ start with 0.\n\nInput\n\nIn the first line, a string $str$ is given. $str$ consists of lowercase letters. In the second line, the number of commands q is given. In the next q lines, each command is given in the above mentioned format.\n\nOutput\n\nFor each print command, print a string in a line.\n\nConstraints\n\n$1 \\leq $ length of $str \\leq 1000$\n\n$1 \\leq q \\leq 100$\n\n$0 \\leq a \\leq b < $ length of $str$\n\nfor replace command, $b - a + 1 = $ length of $p$\n\nSample Input 1\n\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n\nSample Output 1\n\nxaze\n\nSample Input 2\n\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n\nSample Output 2\n\nxyz\nabc", "sample_input": "abcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n"}, "reference_outputs": ["xaze\n"], "source_document_id": "p02422", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nTransformation\n\nWrite a program which performs a sequence of commands to a given string $str$. The command is one of:\n\nprint a b: print from the a-th character to the b-th character of $str$\n\nreverse a b: reverse from the a-th character to the b-th character of $str$\n\nreplace a b p: replace from the a-th character to the b-th character of $str$ with p\n\nNote that the indices of $str$ start with 0.\n\nInput\n\nIn the first line, a string $str$ is given. $str$ consists of lowercase letters. In the second line, the number of commands q is given. In the next q lines, each command is given in the above mentioned format.\n\nOutput\n\nFor each print command, print a string in a line.\n\nConstraints\n\n$1 \\leq $ length of $str \\leq 1000$\n\n$1 \\leq q \\leq 100$\n\n$0 \\leq a \\leq b < $ length of $str$\n\nfor replace command, $b - a + 1 = $ length of $p$\n\nSample Input 1\n\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n\nSample Output 1\n\nxaze\n\nSample Input 2\n\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n\nSample Output 2\n\nxyz\nabc", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 622, "cpu_time_ms": 230, "memory_kb": 44832}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s092507287", "group_id": "codeNet:p02422", "input_text": "import scala.io.StdIn.{readLine, readInt}\n\nsealed trait Order\ncase class Print(a: Int, b: Int) extends Order\ncase class Reverse(a: Int, b: Int) extends Order\ncase class Replace(a: Int, b: Int, p: String) extends Order\n\nobject Main extends App {\n val str = readLine()\n val n = readInt()\n val lines = Iterator.fill(n)(readLine())\n val orders = lines.map { _.split(\" \") }.map {\n case Array(\"print\", a, b) => Print(a.toInt, b.toInt)\n case Array(\"reverse\", a, b) => Reverse(a.toInt, b.toInt)\n case Array(\"replace\", a, b, p) => Replace(a.toInt, b.toInt, p)\n }\n\n val printStrings = {\n val (_, printStrings) = orders.foldLeft((str, Nil: List[String])) { (accum, order) =>\n val (s, printStrings) = accum\n order match {\n case Print(a, b) =>\n val ps = s.slice(a, b + 1)\n (s, ps :: printStrings)\n case Reverse(a, b) =>\n val rev = s.slice(a, b + 1).reverse\n (s.patch(a, rev, b - a + 1), printStrings)\n case Replace(a, b, p) =>\n (s.patch(a, p, b - a + 1), printStrings)\n }\n }\n printStrings.reverse\n }\n\n printStrings.foreach(println)\n}\n\n", "language": "Scala", "metadata": {"date": 1590193735, "filename_ext": "scala", "original_language": "Scala", "problem_description_relpath": "problem_descriptions/p02422.html", "problem_id": "p02422", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02422/input.txt", "sample_output_relpath": "derived/input_output/data/p02422/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02422/Scala/s092507287.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s092507287", "user_id": "u912124184"}, "prompt_components": {"gold_output": "xaze\n", "input_to_evaluate": "import scala.io.StdIn.{readLine, readInt}\n\nsealed trait Order\ncase class Print(a: Int, b: Int) extends Order\ncase class Reverse(a: Int, b: Int) extends Order\ncase class Replace(a: Int, b: Int, p: String) extends Order\n\nobject Main extends App {\n val str = readLine()\n val n = readInt()\n val lines = Iterator.fill(n)(readLine())\n val orders = lines.map { _.split(\" \") }.map {\n case Array(\"print\", a, b) => Print(a.toInt, b.toInt)\n case Array(\"reverse\", a, b) => Reverse(a.toInt, b.toInt)\n case Array(\"replace\", a, b, p) => Replace(a.toInt, b.toInt, p)\n }\n\n val printStrings = {\n val (_, printStrings) = orders.foldLeft((str, Nil: List[String])) { (accum, order) =>\n val (s, printStrings) = accum\n order match {\n case Print(a, b) =>\n val ps = s.slice(a, b + 1)\n (s, ps :: printStrings)\n case Reverse(a, b) =>\n val rev = s.slice(a, b + 1).reverse\n (s.patch(a, rev, b - a + 1), printStrings)\n case Replace(a, b, p) =>\n (s.patch(a, p, b - a + 1), printStrings)\n }\n }\n printStrings.reverse\n }\n\n printStrings.foreach(println)\n}\n\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nTransformation\n\nWrite a program which performs a sequence of commands to a given string $str$. The command is one of:\n\nprint a b: print from the a-th character to the b-th character of $str$\n\nreverse a b: reverse from the a-th character to the b-th character of $str$\n\nreplace a b p: replace from the a-th character to the b-th character of $str$ with p\n\nNote that the indices of $str$ start with 0.\n\nInput\n\nIn the first line, a string $str$ is given. $str$ consists of lowercase letters. In the second line, the number of commands q is given. In the next q lines, each command is given in the above mentioned format.\n\nOutput\n\nFor each print command, print a string in a line.\n\nConstraints\n\n$1 \\leq $ length of $str \\leq 1000$\n\n$1 \\leq q \\leq 100$\n\n$0 \\leq a \\leq b < $ length of $str$\n\nfor replace command, $b - a + 1 = $ length of $p$\n\nSample Input 1\n\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n\nSample Output 1\n\nxaze\n\nSample Input 2\n\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n\nSample Output 2\n\nxyz\nabc", "sample_input": "abcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n"}, "reference_outputs": ["xaze\n"], "source_document_id": "p02422", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nTransformation\n\nWrite a program which performs a sequence of commands to a given string $str$. The command is one of:\n\nprint a b: print from the a-th character to the b-th character of $str$\n\nreverse a b: reverse from the a-th character to the b-th character of $str$\n\nreplace a b p: replace from the a-th character to the b-th character of $str$ with p\n\nNote that the indices of $str$ start with 0.\n\nInput\n\nIn the first line, a string $str$ is given. $str$ consists of lowercase letters. In the second line, the number of commands q is given. In the next q lines, each command is given in the above mentioned format.\n\nOutput\n\nFor each print command, print a string in a line.\n\nConstraints\n\n$1 \\leq $ length of $str \\leq 1000$\n\n$1 \\leq q \\leq 100$\n\n$0 \\leq a \\leq b < $ length of $str$\n\nfor replace command, $b - a + 1 = $ length of $p$\n\nSample Input 1\n\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n\nSample Output 1\n\nxaze\n\nSample Input 2\n\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n\nSample Output 2\n\nxyz\nabc", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1178, "cpu_time_ms": 360, "memory_kb": 45676}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s908055163", "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.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": 1545885068, "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/s908055163.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s908055163", "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.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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 220, "memory_kb": 43536}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s569152665", "group_id": "codeNet:p02467", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val n = io.StdIn.readInt()\n println(s\"$n: ${Primes.primeFactorize(n).mkString(\" \")}\")\n }\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 def primeFactorize(n: Int): Seq[Int] = {\n val ab = collection.mutable.ArrayBuffer.empty[Int]\n var x = n\n while (x !=1) {\n if (isPrime(x)) {ab += x; x = 1}\n else {\n val p = rho(x)\n if (isPrime(p))\n while (x % p == 0) {\n x /= p\n ab += p\n }\n else {\n val ps = primeFactorize(p)\n ps foreach (p => while (x % p == 0) {x /= p; ab += p})\n }\n }\n }\n ab\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 }\n}", "language": "Scala", "metadata": {"date": 1512967452, "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/s569152665.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s569152665", "user_id": "u995793569"}, "prompt_components": {"gold_output": "12: 2 2 3\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val n = io.StdIn.readInt()\n println(s\"$n: ${Primes.primeFactorize(n).mkString(\" \")}\")\n }\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 def primeFactorize(n: Int): Seq[Int] = {\n val ab = collection.mutable.ArrayBuffer.empty[Int]\n var x = n\n while (x !=1) {\n if (isPrime(x)) {ab += x; x = 1}\n else {\n val p = rho(x)\n if (isPrime(p))\n while (x % p == 0) {\n x /= p\n ab += p\n }\n else {\n val ps = primeFactorize(p)\n ps foreach (p => while (x % p == 0) {x /= p; ab += p})\n }\n }\n }\n ab\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 }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2465, "cpu_time_ms": 250, "memory_kb": 43908}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s130592341", "group_id": "codeNet:p02469", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val _ = io.StdIn.readInt()\n val an: Seq[Int] = io.StdIn.readLine().split(\" \").map(_.toInt)\n println(an.tail.foldLeft(an.head)((acc, ai) => lcm(acc, ai)))\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": 1513016153, "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/s130592341.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s130592341", "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: Seq[Int] = io.StdIn.readLine().split(\" \").map(_.toInt)\n println(an.tail.foldLeft(an.head)((acc, ai) => lcm(acc, ai)))\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 43900}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s711563653", "group_id": "codeNet:p02534", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n println(\"ACL\" * sc.nextInt())\n}\n", "language": "Scala", "metadata": {"date": 1601247722, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02534.html", "problem_id": "p02534", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02534/input.txt", "sample_output_relpath": "derived/input_output/data/p02534/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02534/Scala/s711563653.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s711563653", "user_id": "u737111725"}, "prompt_components": {"gold_output": "ACLACLACL\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n println(\"ACL\" * sc.nextInt())\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given an integer K.\nPrint the string obtained by repeating the string ACL K times and concatenating them.\n\nFor example, if K = 3, print ACLACLACL.\n\nConstraints\n\n1 \\leq K \\leq 5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the string obtained by repeating the string ACL K times and concatenating them.\n\nSample Input 1\n\n3\n\nSample Output 1\n\nACLACLACL", "sample_input": "3\n"}, "reference_outputs": ["ACLACLACL\n"], "source_document_id": "p02534", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given an integer K.\nPrint the string obtained by repeating the string ACL K times and concatenating them.\n\nFor example, if K = 3, print ACLACLACL.\n\nConstraints\n\n1 \\leq K \\leq 5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the string obtained by repeating the string ACL K times and concatenating them.\n\nSample Input 1\n\n3\n\nSample Output 1\n\nACLACLACL", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 104, "cpu_time_ms": 508, "memory_kb": 55108}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s868431250", "group_id": "codeNet:p02546", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val S = sc.next()\n println(S + (if (S.last == 's') \"es\" else \"s\"))\n}\n", "language": "Scala", "metadata": {"date": 1600607012, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02546.html", "problem_id": "p02546", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02546/input.txt", "sample_output_relpath": "derived/input_output/data/p02546/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02546/Scala/s868431250.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s868431250", "user_id": "u737111725"}, "prompt_components": {"gold_output": "apples\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val S = sc.next()\n println(S + (if (S.last == 's') \"es\" else \"s\"))\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn the Kingdom of AtCoder, people use a language called Taknese, which uses lowercase English letters.\n\nIn Taknese, the plural form of a noun is spelled based on the following rules:\n\nIf a noun's singular form does not end with s, append s to the end of the singular form.\n\nIf a noun's singular form ends with s, append es to the end of the singular form.\n\nYou are given the singular form S of a Taknese noun. Output its plural form.\n\nConstraints\n\nS is a string of length 1 between 1000, inclusive.\n\nS contains only lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the plural form of the given Taknese word.\n\nSample Input 1\n\napple\n\nSample Output 1\n\napples\n\napple ends with e, so its plural form is apples.\n\nSample Input 2\n\nbus\n\nSample Output 2\n\nbuses\n\nbus ends with s, so its plural form is buses.\n\nSample Input 3\n\nbox\n\nSample Output 3\n\nboxs", "sample_input": "apple\n"}, "reference_outputs": ["apples\n"], "source_document_id": "p02546", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn the Kingdom of AtCoder, people use a language called Taknese, which uses lowercase English letters.\n\nIn Taknese, the plural form of a noun is spelled based on the following rules:\n\nIf a noun's singular form does not end with s, append s to the end of the singular form.\n\nIf a noun's singular form ends with s, append es to the end of the singular form.\n\nYou are given the singular form S of a Taknese noun. Output its plural form.\n\nConstraints\n\nS is a string of length 1 between 1000, inclusive.\n\nS contains only lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the plural form of the given Taknese word.\n\nSample Input 1\n\napple\n\nSample Output 1\n\napples\n\napple ends with e, so its plural form is apples.\n\nSample Input 2\n\nbus\n\nSample Output 2\n\nbuses\n\nbus ends with s, so its plural form is buses.\n\nSample Input 3\n\nbox\n\nSample Output 3\n\nboxs", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 484, "memory_kb": 55384}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s369813587", "group_id": "codeNet:p02546", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n import scala.io.StdIn.readLine\n val Array(datS) = readLine.split(\" \")\n\n val ans = datS + (if (datS.last != 's') \"s\" else \"es\")\n\n println(ans)\n }\n}\n", "language": "Scala", "metadata": {"date": 1600542358, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02546.html", "problem_id": "p02546", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02546/input.txt", "sample_output_relpath": "derived/input_output/data/p02546/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02546/Scala/s369813587.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s369813587", "user_id": "u014716041"}, "prompt_components": {"gold_output": "apples\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n import scala.io.StdIn.readLine\n val Array(datS) = readLine.split(\" \")\n\n val ans = datS + (if (datS.last != 's') \"s\" else \"es\")\n\n println(ans)\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn the Kingdom of AtCoder, people use a language called Taknese, which uses lowercase English letters.\n\nIn Taknese, the plural form of a noun is spelled based on the following rules:\n\nIf a noun's singular form does not end with s, append s to the end of the singular form.\n\nIf a noun's singular form ends with s, append es to the end of the singular form.\n\nYou are given the singular form S of a Taknese noun. Output its plural form.\n\nConstraints\n\nS is a string of length 1 between 1000, inclusive.\n\nS contains only lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the plural form of the given Taknese word.\n\nSample Input 1\n\napple\n\nSample Output 1\n\napples\n\napple ends with e, so its plural form is apples.\n\nSample Input 2\n\nbus\n\nSample Output 2\n\nbuses\n\nbus ends with s, so its plural form is buses.\n\nSample Input 3\n\nbox\n\nSample Output 3\n\nboxs", "sample_input": "apple\n"}, "reference_outputs": ["apples\n"], "source_document_id": "p02546", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn the Kingdom of AtCoder, people use a language called Taknese, which uses lowercase English letters.\n\nIn Taknese, the plural form of a noun is spelled based on the following rules:\n\nIf a noun's singular form does not end with s, append s to the end of the singular form.\n\nIf a noun's singular form ends with s, append es to the end of the singular form.\n\nYou are given the singular form S of a Taknese noun. Output its plural form.\n\nConstraints\n\nS is a string of length 1 between 1000, inclusive.\n\nS contains only lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the plural form of the given Taknese word.\n\nSample Input 1\n\napple\n\nSample Output 1\n\napples\n\napple ends with e, so its plural form is apples.\n\nSample Input 2\n\nbus\n\nSample Output 2\n\nbuses\n\nbus ends with s, so its plural form is buses.\n\nSample Input 3\n\nbox\n\nSample Output 3\n\nboxs", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 217, "cpu_time_ms": 529, "memory_kb": 54688}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s530194973", "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 println(1.to(N).foldLeft(0)(_ + (N - 1) / _))\n}\n", "language": "Scala", "metadata": {"date": 1600609425, "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/s530194973.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s530194973", "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 N = sc.nextInt()\n println(1.to(N).foldLeft(0)(_ + (N - 1) / _))\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a positive integer N.\nHow many tuples (A,B,C) of positive integers satisfy A \\times B + C = N?\n\nConstraints\n\n2 \\leq N \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n3\n\nThere are 3 tuples of integers that satisfy A \\times B + C = 3: (A, B, C) = (1, 1, 2), (1, 2, 1), (2, 1, 1).\n\nSample Input 2\n\n100\n\nSample Output 2\n\n473\n\nSample Input 3\n\n1000000\n\nSample Output 3\n\n13969985", "sample_input": "3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02548", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a positive integer N.\nHow many tuples (A,B,C) of positive integers satisfy A \\times B + C = N?\n\nConstraints\n\n2 \\leq N \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n3\n\nThere are 3 tuples of integers that satisfy A \\times B + C = 3: (A, B, C) = (1, 1, 2), (1, 2, 1), (2, 1, 1).\n\nSample Input 2\n\n100\n\nSample Output 2\n\n473\n\nSample Input 3\n\n1000000\n\nSample Output 3\n\n13969985", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 143, "cpu_time_ms": 522, "memory_kb": 56832}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s621439112", "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 val counts = for {\n a <- 1 to N\n b <- 1 to (N / a)\n if a * b < N\n } yield 1\n println(counts.sum)\n}\n", "language": "Scala", "metadata": {"date": 1600608845, "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/s621439112.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s621439112", "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 N = sc.nextInt()\n val counts = for {\n a <- 1 to N\n b <- 1 to (N / a)\n if a * b < N\n } yield 1\n println(counts.sum)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a positive integer N.\nHow many tuples (A,B,C) of positive integers satisfy A \\times B + C = N?\n\nConstraints\n\n2 \\leq N \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n3\n\nThere are 3 tuples of integers that satisfy A \\times B + C = 3: (A, B, C) = (1, 1, 2), (1, 2, 1), (2, 1, 1).\n\nSample Input 2\n\n100\n\nSample Output 2\n\n473\n\nSample Input 3\n\n1000000\n\nSample Output 3\n\n13969985", "sample_input": "3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02548", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a positive integer N.\nHow many tuples (A,B,C) of positive integers satisfy A \\times B + C = N?\n\nConstraints\n\n2 \\leq N \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n3\n\nThere are 3 tuples of integers that satisfy A \\times B + C = 3: (A, B, C) = (1, 1, 2), (1, 2, 1), (2, 1, 1).\n\nSample Input 2\n\n100\n\nSample Output 2\n\n473\n\nSample Input 3\n\n1000000\n\nSample Output 3\n\n13969985", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 205, "cpu_time_ms": 1654, "memory_kb": 154700}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s232169390", "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 var ans = 0\n for (a <- 1 to n) {\n ans += (n-1) / a\n }\n\n println(ans)\n}\n", "language": "Scala", "metadata": {"date": 1600542401, "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/s232169390.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s232169390", "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 var ans = 0\n for (a <- 1 to n) {\n ans += (n-1) / a\n }\n\n println(ans)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a positive integer N.\nHow many tuples (A,B,C) of positive integers satisfy A \\times B + C = N?\n\nConstraints\n\n2 \\leq N \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n3\n\nThere are 3 tuples of integers that satisfy A \\times B + C = 3: (A, B, C) = (1, 1, 2), (1, 2, 1), (2, 1, 1).\n\nSample Input 2\n\n100\n\nSample Output 2\n\n473\n\nSample Input 3\n\n1000000\n\nSample Output 3\n\n13969985", "sample_input": "3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02548", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a positive integer N.\nHow many tuples (A,B,C) of positive integers satisfy A \\times B + C = N?\n\nConstraints\n\n2 \\leq N \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n3\n\nThere are 3 tuples of integers that satisfy A \\times B + C = 3: (A, B, C) = (1, 1, 2), (1, 2, 1), (2, 1, 1).\n\nSample Input 2\n\n100\n\nSample Output 2\n\n473\n\nSample Input 3\n\n1000000\n\nSample Output 3\n\n13969985", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 172, "cpu_time_ms": 564, "memory_kb": 55248}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s684001886", "group_id": "codeNet:p02555", "input_text": "\nimport scala.io.StdIn\n\nobject Main extends App {\n val s = StdIn.readInt()\n def factorial(n: Int):BigInt = List.range(1, n+1).map(BigInt(_)).foldLeft(BigInt(1))(_*_)\n def factorialPart(from:Int,to:Int):BigInt = List.range(from, to+1).map(BigInt(_)).foldLeft(BigInt(1))(_*_)\n var sum = BigInt(0)\n var seqLength = 1\n while(3*seqLength < s){\n val retNum = s - 3*seqLength\n sum += factorialPart(retNum+1,retNum + (seqLength -1))/factorial(seqLength -1)\n seqLength += 1\n }\n\n val mod = BigInt(10).pow(9) + 7\n println(sum % mod)\n}\n\n\n\n\n\n", "language": "Scala", "metadata": {"date": 1600026596, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02555.html", "problem_id": "p02555", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02555/input.txt", "sample_output_relpath": "derived/input_output/data/p02555/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02555/Scala/s684001886.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s684001886", "user_id": "u416662335"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "\nimport scala.io.StdIn\n\nobject Main extends App {\n val s = StdIn.readInt()\n def factorial(n: Int):BigInt = List.range(1, n+1).map(BigInt(_)).foldLeft(BigInt(1))(_*_)\n def factorialPart(from:Int,to:Int):BigInt = List.range(from, to+1).map(BigInt(_)).foldLeft(BigInt(1))(_*_)\n var sum = BigInt(0)\n var seqLength = 1\n while(3*seqLength < s){\n val retNum = s - 3*seqLength\n sum += factorialPart(retNum+1,retNum + (seqLength -1))/factorial(seqLength -1)\n seqLength += 1\n }\n\n val mod = BigInt(10).pow(9) + 7\n println(sum % mod)\n}\n\n\n\n\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is an integer S.\nFind how many sequences there are whose terms are all integers greater than or equal to 3, and whose sum is equal to S.\nThe answer can be very large, so output it modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq S \\leq 2000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n7\n\nSample Output 1\n\n3\n\n3 sequences satisfy the condition: \\{3,4\\}, \\{4,3\\} and \\{7\\}.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n0\n\nThere are no sequences that satisfy the condition.\n\nSample Input 3\n\n1729\n\nSample Output 3\n\n294867501", "sample_input": "7\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02555", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is an integer S.\nFind how many sequences there are whose terms are all integers greater than or equal to 3, and whose sum is equal to S.\nThe answer can be very large, so output it modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq S \\leq 2000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n7\n\nSample Output 1\n\n3\n\n3 sequences satisfy the condition: \\{3,4\\}, \\{4,3\\} and \\{7\\}.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n0\n\nThere are no sequences that satisfy the condition.\n\nSample Input 3\n\n1729\n\nSample Output 3\n\n294867501", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 547, "cpu_time_ms": 748, "memory_kb": 58880}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s935491015", "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\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 idxap = idxa(p)\n val idxbq = idxb(q)\n ans(idxap.head) = q + 1\n\n if (idxap.tail.isEmpty) {\n idxa -= p\n } else {\n idxa(p) = idxap.tail\n }\n\n if (idxbq.tail.isEmpty) {\n idxb -= q\n } else {\n idxb(q) = idxbq.tail\n }\n\n val cp = count(p)\n val cq = count(q)\n count(p) -= 1\n count(q) -= 1\n\n x(cp) -= p\n x(cq) -= q\n x(cp - 1) += p\n x(cq - 1) += 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).toList match {\n case Nil =>\n p = getAny(idxa, -1)\n q = getAny(idxb, p)\n case x1 :: Nil =>\n if (idxa.isDefinedAt(x1)) {\n p = x1\n q = getAny(idxb, p)\n } else {\n q = x1\n p = getAny(idxa, q)\n }\n case x1 :: x2 :: Nil =>\n if (idxa.isDefinedAt(x1)) {\n p = x1\n q = x2\n } else {\n p = x2\n q = x1\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": 1600610728, "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/s935491015.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s935491015", "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\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 idxap = idxa(p)\n val idxbq = idxb(q)\n ans(idxap.head) = q + 1\n\n if (idxap.tail.isEmpty) {\n idxa -= p\n } else {\n idxa(p) = idxap.tail\n }\n\n if (idxbq.tail.isEmpty) {\n idxb -= q\n } else {\n idxb(q) = idxbq.tail\n }\n\n val cp = count(p)\n val cq = count(q)\n count(p) -= 1\n count(q) -= 1\n\n x(cp) -= p\n x(cq) -= q\n x(cp - 1) += p\n x(cq - 1) += 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).toList match {\n case Nil =>\n p = getAny(idxa, -1)\n q = getAny(idxb, p)\n case x1 :: Nil =>\n if (idxa.isDefinedAt(x1)) {\n p = x1\n q = getAny(idxb, p)\n } else {\n q = x1\n p = getAny(idxa, q)\n }\n case x1 :: x2 :: Nil =>\n if (idxa.isDefinedAt(x1)) {\n p = x1\n q = x2\n } else {\n p = x2\n q = x1\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3176, "cpu_time_ms": 2205, "memory_kb": 126020}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s830508369", "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]]()\n val idxb = Map[Int, List[Int]]()\n for (i <- 0 until n) {\n count(a(i)) += 1\n count(b(i)) += 1\n if (idxa.isDefinedAt(a(i))) {\n idxa(a(i)) ::= i\n } else {\n idxa(a(i)) = List(i)\n }\n if (idxb.isDefinedAt(b(i))) {\n idxb(b(i)) ::= i\n } else {\n idxb(b(i)) = List(i)\n }\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 ans(idxa(p).head) = 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.isDefinedAt(x(i).head)) {\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.isDefinedAt(x(i).head)) {\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": 1600539265, "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/s830508369.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s830508369", "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]]()\n val idxb = Map[Int, List[Int]]()\n for (i <- 0 until n) {\n count(a(i)) += 1\n count(b(i)) += 1\n if (idxa.isDefinedAt(a(i))) {\n idxa(a(i)) ::= i\n } else {\n idxa(a(i)) = List(i)\n }\n if (idxb.isDefinedAt(b(i))) {\n idxb(b(i)) ::= i\n } else {\n idxb(b(i)) = List(i)\n }\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 ans(idxa(p).head) = 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.isDefinedAt(x(i).head)) {\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.isDefinedAt(x(i).head)) {\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3206, "cpu_time_ms": 2205, "memory_kb": 124616}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s876716445", "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 = Array.fill(n)(sc.nextInt() - 1)\n val count = Array.fill(n)(0)\n var idxa = Map[Int, List[Int]]().withDefaultValue(Nil)\n var 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 :: idxa(a(i)))\n idxb += b(i) -> (i :: idxb(b(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 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.find{case (k, v) => k != except && v.nonEmpty}.get._1\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", "language": "Scala", "metadata": {"date": 1600529031, "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/s876716445.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s876716445", "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 = Array.fill(n)(sc.nextInt() - 1)\n val count = Array.fill(n)(0)\n var idxa = Map[Int, List[Int]]().withDefaultValue(Nil)\n var 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 :: idxa(a(i)))\n idxb += b(i) -> (i :: idxb(b(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 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.find{case (k, v) => k != except && v.nonEmpty}.get._1\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", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven are two sequences A and B, both of length N.\nA and B are each sorted in the ascending order.\nCheck if it is possible to reorder the terms of B so that for each i (1 \\leq i \\leq N) A_i \\neq B_i holds, and if it is possible, output any of the reorderings that achieve it.\n\nConstraints\n\n1\\leq N \\leq 2 \\times 10^5\n\n1\\leq A_i,B_i \\leq N\n\nA and B are each sorted in the ascending order.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\cdots A_N\nB_1 B_2 \\cdots B_N\n\nOutput\n\nIf there exist no reorderings that satisfy the condition, print No.\n\nIf there exists a reordering that satisfies the condition, print Yes on the first line.\nAfter that, print a reordering of B on the second line, separating terms with a whitespace.\n\nIf there are multiple reorderings that satisfy the condition, you can print any of them.\n\nSample Input 1\n\n6\n1 1 1 2 2 3\n1 1 1 2 2 3\n\nSample Output 1\n\nYes\n2 2 3 1 1 1\n\nSample Input 2\n\n3\n1 1 2\n1 1 3\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n4\n1 1 2 3\n1 2 3 3\n\nSample Output 3\n\nYes\n3 3 1 2", "sample_input": "6\n1 1 1 2 2 3\n1 1 1 2 2 3\n"}, "reference_outputs": ["Yes\n2 2 3 1 1 1\n"], "source_document_id": "p02557", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven are two sequences A and B, both of length N.\nA and B are each sorted in the ascending order.\nCheck if it is possible to reorder the terms of B so that for each i (1 \\leq i \\leq N) A_i \\neq B_i holds, and if it is possible, output any of the reorderings that achieve it.\n\nConstraints\n\n1\\leq N \\leq 2 \\times 10^5\n\n1\\leq A_i,B_i \\leq N\n\nA and B are each sorted in the ascending order.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\cdots A_N\nB_1 B_2 \\cdots B_N\n\nOutput\n\nIf there exist no reorderings that satisfy the condition, print No.\n\nIf there exists a reordering that satisfies the condition, print Yes on the first line.\nAfter that, print a reordering of B on the second line, separating terms with a whitespace.\n\nIf there are multiple reorderings that satisfy the condition, you can print any of them.\n\nSample Input 1\n\n6\n1 1 1 2 2 3\n1 1 1 2 2 3\n\nSample Output 1\n\nYes\n2 2 3 1 1 1\n\nSample Input 2\n\n3\n1 1 2\n1 1 3\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n4\n1 1 2 3\n1 2 3 3\n\nSample Output 3\n\nYes\n3 3 1 2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1701, "cpu_time_ms": 2205, "memory_kb": 120072}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s442124490", "group_id": "codeNet:p02571", "input_text": "import java.io.{BufferedOutputStream, BufferedReader, FileOutputStream, InputStreamReader, PrintWriter}\nimport java.lang\n\nimport scala.annotation.tailrec\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 val s = get[String]\n val t = get[String]\n\n var min = Int.MaxValue\n for(i <- 0 to s.length - t.length) {\n var same = 0\n\n for(j <- 0 until t.length) {\n if (s(i + j) == t(j)) {\n same += 1\n }\n }\n\n min = Math.min(min, t.length - same)\n }\n\n out.println(min)\n\n log(\"=== start\")\n\n out.flush()\n log(\"=== end\")\n debug {\n debugOut.flush()\n }\n }\n}", "language": "Scala", "metadata": {"date": 1598727947, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02571.html", "problem_id": "p02571", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02571/input.txt", "sample_output_relpath": "derived/input_output/data/p02571/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02571/Scala/s442124490.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s442124490", "user_id": "u178269371"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.io.{BufferedOutputStream, BufferedReader, FileOutputStream, InputStreamReader, PrintWriter}\nimport java.lang\n\nimport scala.annotation.tailrec\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 val s = get[String]\n val t = get[String]\n\n var min = Int.MaxValue\n for(i <- 0 to s.length - t.length) {\n var same = 0\n\n for(j <- 0 until t.length) {\n if (s(i + j) == t(j)) {\n same += 1\n }\n }\n\n min = Math.min(min, t.length - same)\n }\n\n out.println(min)\n\n log(\"=== start\")\n\n out.flush()\n log(\"=== end\")\n debug {\n debugOut.flush()\n }\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are two strings S and T.\n\nLet us change some of the characters in S so that T will be a substring of S.\n\nAt least how many characters do we need to change?\n\nHere, a substring is a consecutive subsequence. For example, xxx is a substring of yxxxy, but not a substring of xxyxx.\n\nConstraints\n\nThe lengths of S and T are each at least 1 and at most 1000.\n\nThe length of T is at most that of S.\n\nS and T consist of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the minimum number of characters in S that need to be changed.\n\nSample Input 1\n\ncabacc\nabc\n\nSample Output 1\n\n1\n\nFor example, changing the fourth character a in S to c will match the second through fourth characters in S to T.\n\nSince S itself does not have T as its substring, this number of changes - one - is the minimum needed.\n\nSample Input 2\n\ncodeforces\natcoder\n\nSample Output 2\n\n6", "sample_input": "cabacc\nabc\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02571", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are two strings S and T.\n\nLet us change some of the characters in S so that T will be a substring of S.\n\nAt least how many characters do we need to change?\n\nHere, a substring is a consecutive subsequence. For example, xxx is a substring of yxxxy, but not a substring of xxyxx.\n\nConstraints\n\nThe lengths of S and T are each at least 1 and at most 1000.\n\nThe length of T is at most that of S.\n\nS and T consist of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the minimum number of characters in S that need to be changed.\n\nSample Input 1\n\ncabacc\nabc\n\nSample Output 1\n\n1\n\nFor example, changing the fourth character a in S to c will match the second through fourth characters in S to T.\n\nSince S itself does not have T as its substring, this number of changes - one - is the minimum needed.\n\nSample Input 2\n\ncodeforces\natcoder\n\nSample Output 2\n\n6", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4612, "cpu_time_ms": 551, "memory_kb": 57180}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s745076411", "group_id": "codeNet:p02573", "input_text": "import java.io.{BufferedOutputStream, BufferedReader, FileOutputStream, InputStreamReader, PrintWriter}\nimport java.lang\n\nimport scala.annotation.tailrec\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 val (n, m) = get[Int, Int]\n val friendships = Array.fill(m) {\n get[Int, Int] match {\n case (a, b) => (a - 1, b - 1)\n }\n }\n\n log(\"=== start\")\n\n class UnionFind(n: Int) {\n val roots: Array[Int] = Array.ofDim[Int](n)\n for(i <- 0 until n) {\n roots(i) = i\n }\n\n val sizes: Array[Int] = Array.fill(n)(1)\n\n def root(i: Int): Int = {\n if (roots(i) == i) {\n i\n } else {\n roots(i) = root(roots(i))\n roots(i)\n }\n }\n\n def unite(i: Int, j: Int): Unit = {\n val rootI = root(i)\n val rootJ = root(j)\n if (rootI != rootJ) {\n sizes(rootI) += sizes(rootJ)\n sizes(rootJ) = 0\n roots(rootJ) = rootI\n }\n }\n\n def isSameRoot(i: Int, j: Int): Boolean = {\n root(i) == root(j)\n }\n\n def getSize(i: Int): Int = {\n sizes(root(i))\n }\n }\n\n val unionFind = new UnionFind(n)\n\n for((a,b) <- friendships) {\n unionFind.unite(a,b)\n }\n\n var max = 0\n for(i <- 0 until n) {\n max = Math.max(unionFind.getSize(i), max)\n }\n\n out.println(max)\n\n\n\n\n out.flush()\n log(\"=== end\")\n debug {\n debugOut.flush()\n }\n }\n}", "language": "Scala", "metadata": {"date": 1598728984, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02573.html", "problem_id": "p02573", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02573/input.txt", "sample_output_relpath": "derived/input_output/data/p02573/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02573/Scala/s745076411.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s745076411", "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.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 val (n, m) = get[Int, Int]\n val friendships = Array.fill(m) {\n get[Int, Int] match {\n case (a, b) => (a - 1, b - 1)\n }\n }\n\n log(\"=== start\")\n\n class UnionFind(n: Int) {\n val roots: Array[Int] = Array.ofDim[Int](n)\n for(i <- 0 until n) {\n roots(i) = i\n }\n\n val sizes: Array[Int] = Array.fill(n)(1)\n\n def root(i: Int): Int = {\n if (roots(i) == i) {\n i\n } else {\n roots(i) = root(roots(i))\n roots(i)\n }\n }\n\n def unite(i: Int, j: Int): Unit = {\n val rootI = root(i)\n val rootJ = root(j)\n if (rootI != rootJ) {\n sizes(rootI) += sizes(rootJ)\n sizes(rootJ) = 0\n roots(rootJ) = rootI\n }\n }\n\n def isSameRoot(i: Int, j: Int): Boolean = {\n root(i) == root(j)\n }\n\n def getSize(i: Int): Int = {\n sizes(root(i))\n }\n }\n\n val unionFind = new UnionFind(n)\n\n for((a,b) <- friendships) {\n unionFind.unite(a,b)\n }\n\n var max = 0\n for(i <- 0 until n) {\n max = Math.max(unionFind.getSize(i), max)\n }\n\n out.println(max)\n\n\n\n\n out.flush()\n log(\"=== end\")\n debug {\n debugOut.flush()\n }\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N persons called Person 1 through Person N.\n\nYou are given M facts that \"Person A_i and Person B_i are friends.\" The same fact may be given multiple times.\n\nIf X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts.\n\nTakahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group.\n\nAt least how many groups does he need to make?\n\nConstraints\n\n2 \\leq N \\leq 2\\times 10^5\n\n0 \\leq M \\leq 2\\times 10^5\n\n1\\leq A_i,B_i\\leq N\n\nA_i \\neq B_i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n\\vdots\nA_M B_M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n5 3\n1 2\n3 4\n5 1\n\nSample Output 1\n\n3\n\nDividing them into three groups such as \\{1,3\\}, \\{2,4\\}, and \\{5\\} achieves the goal.\n\nSample Input 2\n\n4 10\n1 2\n2 1\n1 2\n2 1\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n\nSample Output 2\n\n4\n\nSample Input 3\n\n10 4\n3 1\n4 1\n5 9\n2 6\n\nSample Output 3\n\n3", "sample_input": "5 3\n1 2\n3 4\n5 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02573", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N persons called Person 1 through Person N.\n\nYou are given M facts that \"Person A_i and Person B_i are friends.\" The same fact may be given multiple times.\n\nIf X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts.\n\nTakahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group.\n\nAt least how many groups does he need to make?\n\nConstraints\n\n2 \\leq N \\leq 2\\times 10^5\n\n0 \\leq M \\leq 2\\times 10^5\n\n1\\leq A_i,B_i\\leq N\n\nA_i \\neq B_i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n\\vdots\nA_M B_M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n5 3\n1 2\n3 4\n5 1\n\nSample Output 1\n\n3\n\nDividing them into three groups such as \\{1,3\\}, \\{2,4\\}, and \\{5\\} achieves the goal.\n\nSample Input 2\n\n4 10\n1 2\n2 1\n1 2\n2 1\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n\nSample Output 2\n\n4\n\nSample Input 3\n\n10 4\n3 1\n4 1\n5 9\n2 6\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5426, "cpu_time_ms": 1193, "memory_kb": 67920}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s634243232", "group_id": "codeNet:p02576", "input_text": "import scala.io.StdIn._\n\nobject Main extends App {\n\n val Array(n,t,x) = readLine().split(\" \").map(_.toInt)\n\n def solve() = {\n (n.toDouble / t).ceil.toInt * x\n }\n\n println(solve())\n\n}\n\n", "language": "Scala", "metadata": {"date": 1598123078, "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/s634243232.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s634243232", "user_id": "u947008426"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main extends App {\n\n val Array(n,t,x) = readLine().split(\" \").map(_.toInt)\n\n def solve() = {\n (n.toDouble / t).ceil.toInt * x\n }\n\n println(solve())\n\n}\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi loves takoyaki - a ball-shaped snack.\n\nWith a takoyaki machine, he can make at most X pieces of takoyaki at a time, taking T minutes regardless of the number of pieces to make.\n\nHow long does it take to make N takoyaki?\n\nConstraints\n\n1 \\leq N,X,T \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X T\n\nOutput\n\nPrint an integer representing the minimum number of minutes needed to make N pieces of takoyaki.\n\nSample Input 1\n\n20 12 6\n\nSample Output 1\n\n12\n\nHe can make 12 pieces of takoyaki in the first 6 minutes and 8 more in the next 6 minutes, so he can make 20 in a total of 12 minutes.\n\nNote that being able to make 12 in 6 minutes does not mean he can make 2 in 1 minute.\n\nSample Input 2\n\n1000 1 1000\n\nSample Output 2\n\n1000000\n\nIt seems to take a long time to make this kind of takoyaki.", "sample_input": "20 12 6\n"}, "reference_outputs": ["12\n"], "source_document_id": "p02576", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi loves takoyaki - a ball-shaped snack.\n\nWith a takoyaki machine, he can make at most X pieces of takoyaki at a time, taking T minutes regardless of the number of pieces to make.\n\nHow long does it take to make N takoyaki?\n\nConstraints\n\n1 \\leq N,X,T \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X T\n\nOutput\n\nPrint an integer representing the minimum number of minutes needed to make N pieces of takoyaki.\n\nSample Input 1\n\n20 12 6\n\nSample Output 1\n\n12\n\nHe can make 12 pieces of takoyaki in the first 6 minutes and 8 more in the next 6 minutes, so he can make 20 in a total of 12 minutes.\n\nNote that being able to make 12 in 6 minutes does not mean he can make 2 in 1 minute.\n\nSample Input 2\n\n1000 1 1000\n\nSample Output 2\n\n1000000\n\nIt seems to take a long time to make this kind of takoyaki.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 191, "cpu_time_ms": 524, "memory_kb": 54720}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s458069890", "group_id": "codeNet:p02577", "input_text": "\nobject Main extends App {\n \n val sc = new java.util.Scanner(System.in)\n val N: Seq[Char] = sc.next()\n val sum = N.map(_.asDigit).sum\n if (sum % 9 == 0) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1598123615, "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/s458069890.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s458069890", "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 N: Seq[Char] = sc.next()\n val sum = N.map(_.asDigit).sum\n if (sum % 9 == 0) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAn integer N is a multiple of 9 if and only if the sum of the digits in the decimal representation of N is a multiple of 9.\n\nDetermine whether N is a multiple of 9.\n\nConstraints\n\n0 \\leq N < 10^{200000}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N is a multiple of 9, print Yes; otherwise, print No.\n\nSample Input 1\n\n123456789\n\nSample Output 1\n\nYes\n\nThe sum of these digits is 1+2+3+4+5+6+7+8+9=45, which is a multiple of 9, so 123456789 is a multiple of 9.\n\nSample Input 2\n\n0\n\nSample Output 2\n\nYes\n\nSample Input 3\n\n31415926535897932384626433832795028841971693993751058209749445923078164062862089986280\n\nSample Output 3\n\nNo", "sample_input": "123456789\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02577", "source_text": "Score : 200 points\n\nProblem Statement\n\nAn integer N is a multiple of 9 if and only if the sum of the digits in the decimal representation of N is a multiple of 9.\n\nDetermine whether N is a multiple of 9.\n\nConstraints\n\n0 \\leq N < 10^{200000}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N is a multiple of 9, print Yes; otherwise, print No.\n\nSample Input 1\n\n123456789\n\nSample Output 1\n\nYes\n\nThe sum of these digits is 1+2+3+4+5+6+7+8+9=45, which is a multiple of 9, so 123456789 is a multiple of 9.\n\nSample Input 2\n\n0\n\nSample Output 2\n\nYes\n\nSample Input 3\n\n31415926535897932384626433832795028841971693993751058209749445923078164062862089986280\n\nSample Output 3\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 215, "cpu_time_ms": 694, "memory_kb": 59156}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s702530091", "group_id": "codeNet:p02577", "input_text": "\nimport scala.io.StdIn\n\nobject Main extends App {\n val nums=StdIn.readLine().split(\"\").map(_.toInt)\n val sum=nums.sum\n val ans = if(sum % 9 == 0) \"Yes\" else \"No\"\n println(ans)\n\n}\n\n\n\n\n\n\n", "language": "Scala", "metadata": {"date": 1598123370, "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/s702530091.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s702530091", "user_id": "u416662335"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "\nimport scala.io.StdIn\n\nobject Main extends App {\n val nums=StdIn.readLine().split(\"\").map(_.toInt)\n val sum=nums.sum\n val ans = if(sum % 9 == 0) \"Yes\" else \"No\"\n println(ans)\n\n}\n\n\n\n\n\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAn integer N is a multiple of 9 if and only if the sum of the digits in the decimal representation of N is a multiple of 9.\n\nDetermine whether N is a multiple of 9.\n\nConstraints\n\n0 \\leq N < 10^{200000}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N is a multiple of 9, print Yes; otherwise, print No.\n\nSample Input 1\n\n123456789\n\nSample Output 1\n\nYes\n\nThe sum of these digits is 1+2+3+4+5+6+7+8+9=45, which is a multiple of 9, so 123456789 is a multiple of 9.\n\nSample Input 2\n\n0\n\nSample Output 2\n\nYes\n\nSample Input 3\n\n31415926535897932384626433832795028841971693993751058209749445923078164062862089986280\n\nSample Output 3\n\nNo", "sample_input": "123456789\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02577", "source_text": "Score : 200 points\n\nProblem Statement\n\nAn integer N is a multiple of 9 if and only if the sum of the digits in the decimal representation of N is a multiple of 9.\n\nDetermine whether N is a multiple of 9.\n\nConstraints\n\n0 \\leq N < 10^{200000}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N is a multiple of 9, print Yes; otherwise, print No.\n\nSample Input 1\n\n123456789\n\nSample Output 1\n\nYes\n\nThe sum of these digits is 1+2+3+4+5+6+7+8+9=45, which is a multiple of 9, so 123456789 is a multiple of 9.\n\nSample Input 2\n\n0\n\nSample Output 2\n\nYes\n\nSample Input 3\n\n31415926535897932384626433832795028841971693993751058209749445923078164062862089986280\n\nSample Output 3\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 189, "cpu_time_ms": 723, "memory_kb": 65296}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s024569879", "group_id": "codeNet:p02578", "input_text": "import scala.annotation.tailrec\n\nobject Main extends App {\n \n val sc = new java.util.Scanner(System.in)\n sc.useDelimiter(\"\\n\")\n val N = sc.nextInt()\n val A = sc.next().split(\" \").map(_.toLong)\n println(calc(0L, 0, 0L))\n \n @tailrec\n def calc(prev: Long, index: Int, acc: Long): Long = {\n if (index == A.length) {\n acc\n } else if (prev <= A(index)) {\n calc(A(index), index + 1, acc)\n } else {\n calc(prev, index + 1, acc + prev - A(index))\n }\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1598131073, "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/s024569879.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s024569879", "user_id": "u396472025"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import scala.annotation.tailrec\n\nobject Main extends App {\n \n val sc = new java.util.Scanner(System.in)\n sc.useDelimiter(\"\\n\")\n val N = sc.nextInt()\n val A = sc.next().split(\" \").map(_.toLong)\n println(calc(0L, 0, 0L))\n \n @tailrec\n def calc(prev: Long, index: Int, acc: Long): Long = {\n if (index == A.length) {\n acc\n } else if (prev <= A(index)) {\n calc(A(index), index + 1, acc)\n } else {\n calc(prev, index + 1, acc + prev - A(index))\n }\n }\n\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nN persons are standing in a row. The height of the i-th person from the front is A_i.\n\nWe want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:\n\nCondition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.\n\nFind the minimum total height of the stools needed to meet this goal.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 \\ldots A_N\n\nOutput\n\nPrint the minimum total height of the stools needed to meet the goal.\n\nSample Input 1\n\n5\n2 1 5 4 3\n\nSample Output 1\n\n4\n\nIf the persons stand on stools of heights 0, 1, 0, 1, and 2, respectively, their heights will be 2, 2, 5, 5, and 5, satisfying the condition.\n\nWe cannot meet the goal with a smaller total height of the stools.\n\nSample Input 2\n\n5\n3 3 3 3 3\n\nSample Output 2\n\n0\n\nGiving a stool of height 0 to everyone will work.", "sample_input": "5\n2 1 5 4 3\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02578", "source_text": "Score : 300 points\n\nProblem Statement\n\nN persons are standing in a row. The height of the i-th person from the front is A_i.\n\nWe want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:\n\nCondition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.\n\nFind the minimum total height of the stools needed to meet this goal.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 \\ldots A_N\n\nOutput\n\nPrint the minimum total height of the stools needed to meet the goal.\n\nSample Input 1\n\n5\n2 1 5 4 3\n\nSample Output 1\n\n4\n\nIf the persons stand on stools of heights 0, 1, 0, 1, and 2, respectively, their heights will be 2, 2, 5, 5, and 5, satisfying the condition.\n\nWe cannot meet the goal with a smaller total height of the stools.\n\nSample Input 2\n\n5\n3 3 3 3 3\n\nSample Output 2\n\n0\n\nGiving a stool of height 0 to everyone will work.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 483, "cpu_time_ms": 751, "memory_kb": 84612}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s055880790", "group_id": "codeNet:p02578", "input_text": "\nobject Main extends App {\n \n val sc = new java.util.Scanner(System.in)\n val N = sc.nextInt()\n var step: List[Int] = List()\n val A = List.fill(N)(sc.nextInt())\n val ans = for ((a, i) <- A.zipWithIndex) yield {\n if (i == 0 || A(i-1)+step(i-1) <= a) {\n step = step :+ 0\n } else {\n step = step :+ A(i-1)+step(i-1) - a\n }\n }\n println(step.sum)\n\n}\n", "language": "Scala", "metadata": {"date": 1598125997, "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/s055880790.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s055880790", "user_id": "u396472025"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "\nobject Main extends App {\n \n val sc = new java.util.Scanner(System.in)\n val N = sc.nextInt()\n var step: List[Int] = List()\n val A = List.fill(N)(sc.nextInt())\n val ans = for ((a, i) <- A.zipWithIndex) yield {\n if (i == 0 || A(i-1)+step(i-1) <= a) {\n step = step :+ 0\n } else {\n step = step :+ A(i-1)+step(i-1) - a\n }\n }\n println(step.sum)\n\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nN persons are standing in a row. The height of the i-th person from the front is A_i.\n\nWe want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:\n\nCondition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.\n\nFind the minimum total height of the stools needed to meet this goal.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 \\ldots A_N\n\nOutput\n\nPrint the minimum total height of the stools needed to meet the goal.\n\nSample Input 1\n\n5\n2 1 5 4 3\n\nSample Output 1\n\n4\n\nIf the persons stand on stools of heights 0, 1, 0, 1, and 2, respectively, their heights will be 2, 2, 5, 5, and 5, satisfying the condition.\n\nWe cannot meet the goal with a smaller total height of the stools.\n\nSample Input 2\n\n5\n3 3 3 3 3\n\nSample Output 2\n\n0\n\nGiving a stool of height 0 to everyone will work.", "sample_input": "5\n2 1 5 4 3\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02578", "source_text": "Score : 300 points\n\nProblem Statement\n\nN persons are standing in a row. The height of the i-th person from the front is A_i.\n\nWe want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:\n\nCondition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.\n\nFind the minimum total height of the stools needed to meet this goal.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 \\ldots A_N\n\nOutput\n\nPrint the minimum total height of the stools needed to meet the goal.\n\nSample Input 1\n\n5\n2 1 5 4 3\n\nSample Output 1\n\n4\n\nIf the persons stand on stools of heights 0, 1, 0, 1, and 2, respectively, their heights will be 2, 2, 5, 5, and 5, satisfying the condition.\n\nWe cannot meet the goal with a smaller total height of the stools.\n\nSample Input 2\n\n5\n3 3 3 3 3\n\nSample Output 2\n\n0\n\nGiving a stool of height 0 to everyone will work.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 370, "cpu_time_ms": 2206, "memory_kb": 70032}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s386121716", "group_id": "codeNet:p02578", "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\tpw.println(\n\t\tSeq.fill(Scanner.nextInt)(Scanner.nextLong).foldLeft((0L,0L)) { case ((acc, p), ai) =>\n\t\t\tval updated = if (p < ai) ai else p\n\t\t\t(acc + updated - ai, updated)\n\t\t}._1\n\t)\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": 1598124951, "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/s386121716.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s386121716", "user_id": "u822029894"}, "prompt_components": {"gold_output": "4\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\tpw.println(\n\t\tSeq.fill(Scanner.nextInt)(Scanner.nextLong).foldLeft((0L,0L)) { case ((acc, p), ai) =>\n\t\t\tval updated = if (p < ai) ai else p\n\t\t\t(acc + updated - ai, updated)\n\t\t}._1\n\t)\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 : 300 points\n\nProblem Statement\n\nN persons are standing in a row. The height of the i-th person from the front is A_i.\n\nWe want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:\n\nCondition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.\n\nFind the minimum total height of the stools needed to meet this goal.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 \\ldots A_N\n\nOutput\n\nPrint the minimum total height of the stools needed to meet the goal.\n\nSample Input 1\n\n5\n2 1 5 4 3\n\nSample Output 1\n\n4\n\nIf the persons stand on stools of heights 0, 1, 0, 1, and 2, respectively, their heights will be 2, 2, 5, 5, and 5, satisfying the condition.\n\nWe cannot meet the goal with a smaller total height of the stools.\n\nSample Input 2\n\n5\n3 3 3 3 3\n\nSample Output 2\n\n0\n\nGiving a stool of height 0 to everyone will work.", "sample_input": "5\n2 1 5 4 3\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02578", "source_text": "Score : 300 points\n\nProblem Statement\n\nN persons are standing in a row. The height of the i-th person from the front is A_i.\n\nWe want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:\n\nCondition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.\n\nFind the minimum total height of the stools needed to meet this goal.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 \\ldots A_N\n\nOutput\n\nPrint the minimum total height of the stools needed to meet the goal.\n\nSample Input 1\n\n5\n2 1 5 4 3\n\nSample Output 1\n\n4\n\nIf the persons stand on stools of heights 0, 1, 0, 1, and 2, respectively, their heights will be 2, 2, 5, 5, and 5, satisfying the condition.\n\nWe cannot meet the goal with a smaller total height of the stools.\n\nSample Input 2\n\n5\n3 3 3 3 3\n\nSample Output 2\n\n0\n\nGiving a stool of height 0 to everyone will work.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1586, "cpu_time_ms": 630, "memory_kb": 66760}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s996998386", "group_id": "codeNet:p02578", "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 = Array.fill(N)(sc.nextLong)\n\n val z = A.foldLeft((0L, 0L))((z, x) => if (x >= z._2) (z._1, x) else (z._1 + z._2 - x, z._2))._1\n\n println(z)\n}\n", "language": "Scala", "metadata": {"date": 1598123639, "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/s996998386.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s996998386", "user_id": "u786167609"}, "prompt_components": {"gold_output": "4\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 = Array.fill(N)(sc.nextLong)\n\n val z = A.foldLeft((0L, 0L))((z, x) => if (x >= z._2) (z._1, x) else (z._1 + z._2 - x, z._2))._1\n\n println(z)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nN persons are standing in a row. The height of the i-th person from the front is A_i.\n\nWe want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:\n\nCondition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.\n\nFind the minimum total height of the stools needed to meet this goal.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 \\ldots A_N\n\nOutput\n\nPrint the minimum total height of the stools needed to meet the goal.\n\nSample Input 1\n\n5\n2 1 5 4 3\n\nSample Output 1\n\n4\n\nIf the persons stand on stools of heights 0, 1, 0, 1, and 2, respectively, their heights will be 2, 2, 5, 5, and 5, satisfying the condition.\n\nWe cannot meet the goal with a smaller total height of the stools.\n\nSample Input 2\n\n5\n3 3 3 3 3\n\nSample Output 2\n\n0\n\nGiving a stool of height 0 to everyone will work.", "sample_input": "5\n2 1 5 4 3\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02578", "source_text": "Score : 300 points\n\nProblem Statement\n\nN persons are standing in a row. The height of the i-th person from the front is A_i.\n\nWe want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:\n\nCondition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.\n\nFind the minimum total height of the stools needed to meet this goal.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 \\ldots A_N\n\nOutput\n\nPrint the minimum total height of the stools needed to meet the goal.\n\nSample Input 1\n\n5\n2 1 5 4 3\n\nSample Output 1\n\n4\n\nIf the persons stand on stools of heights 0, 1, 0, 1, and 2, respectively, their heights will be 2, 2, 5, 5, and 5, satisfying the condition.\n\nWe cannot meet the goal with a smaller total height of the stools.\n\nSample Input 2\n\n5\n3 3 3 3 3\n\nSample Output 2\n\n0\n\nGiving a stool of height 0 to everyone will work.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 260, "cpu_time_ms": 1038, "memory_kb": 60668}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s722256729", "group_id": "codeNet:p02578", "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())\n var max = as.head\n var ans = 0L\n for (a <- as) {\n if (a < max) {\n ans += max - a\n } else {\n max = a\n }\n }\n\n println(ans)\n}\n", "language": "Scala", "metadata": {"date": 1598123202, "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/s722256729.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s722256729", "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())\n var max = as.head\n var ans = 0L\n for (a <- as) {\n if (a < max) {\n ans += max - a\n } else {\n max = a\n }\n }\n\n println(ans)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nN persons are standing in a row. The height of the i-th person from the front is A_i.\n\nWe want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:\n\nCondition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.\n\nFind the minimum total height of the stools needed to meet this goal.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 \\ldots A_N\n\nOutput\n\nPrint the minimum total height of the stools needed to meet the goal.\n\nSample Input 1\n\n5\n2 1 5 4 3\n\nSample Output 1\n\n4\n\nIf the persons stand on stools of heights 0, 1, 0, 1, and 2, respectively, their heights will be 2, 2, 5, 5, and 5, satisfying the condition.\n\nWe cannot meet the goal with a smaller total height of the stools.\n\nSample Input 2\n\n5\n3 3 3 3 3\n\nSample Output 2\n\n0\n\nGiving a stool of height 0 to everyone will work.", "sample_input": "5\n2 1 5 4 3\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02578", "source_text": "Score : 300 points\n\nProblem Statement\n\nN persons are standing in a row. The height of the i-th person from the front is A_i.\n\nWe want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:\n\nCondition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.\n\nFind the minimum total height of the stools needed to meet this goal.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 \\ldots A_N\n\nOutput\n\nPrint the minimum total height of the stools needed to meet the goal.\n\nSample Input 1\n\n5\n2 1 5 4 3\n\nSample Output 1\n\n4\n\nIf the persons stand on stools of heights 0, 1, 0, 1, and 2, respectively, their heights will be 2, 2, 5, 5, and 5, satisfying the condition.\n\nWe cannot meet the goal with a smaller total height of the stools.\n\nSample Input 2\n\n5\n3 3 3 3 3\n\nSample Output 2\n\n0\n\nGiving a stool of height 0 to everyone will work.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 279, "cpu_time_ms": 1031, "memory_kb": 66176}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s300432387", "group_id": "codeNet:p02579", "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: => Any): Unit = {\n if (DEBUG) {\n debugOut.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 val (h, w) = get[Int, Int]\n val (ch, cw) = get[Int, Int] match {\n case (a, b) => (a - 1, b - 1)\n }\n val (dh, dw) = get[Int, Int] match {\n case (a, b) => (a - 1, b - 1)\n }\n val smap = Array.fill(h) {\n get[String].toCharArray\n }\n\n @inline\n def xy2i(y: Int, x: Int): Int = {\n y * w + x\n }\n\n @inline\n def i2xy(i: Int): (Int, Int) = {\n (i / w, i % w)\n }\n\n log(\"=== start\")\n\n class UnionFind(size: Int) {\n val roots: Array[Int] = Array.ofDim[Int](size)\n for (i <- 0 until size) {\n roots(i) = i\n }\n\n val warpable: Array[mutable.HashSet[Int]] = Array.fill(size)(mutable.HashSet.empty[Int])\n\n def root(a: Int): Int = {\n if (roots(a) == a) {\n a\n } else {\n roots(a) = root(roots(a))\n roots(a)\n }\n }\n\n def isSameRoot(a: Int, b: Int): Boolean = {\n root(a) == root(b)\n }\n\n def walkablize(a: Int, b: Int): Unit = {\n log(s\"walkablize(${i2xy(a)},${i2xy(b)})\")\n if (a != b) {\n val rootA = root(a)\n val rootB = root(b)\n if (rootA != rootB) {\n roots(rootB) = rootA\n warpable(rootA).addAll(warpable(rootB).map(root))\n warpable(rootB).clear()\n }\n }\n }\n\n def warpablize(a: Int, b: Int): Unit = {\n log(s\"warpablize(${i2xy(a)},${i2xy(b)})\")\n val rootA = root(a)\n val rootB = root(b)\n if (rootA != rootB) {\n warpable(rootA).add(rootB)\n warpable(rootB).add(rootA)\n }\n }\n\n def getWarpables(a: Int): mutable.HashSet[Int] = {\n val rootA = root(a)\n warpable(rootA) = warpable(rootA).map(root)\n\n warpable(rootA)\n }\n }\n\n val unionFind = new UnionFind(h * w)\n\n for (y <- 0 until h) {\n for (x <- 0 until w) {\n if (smap(y)(x) == '.') {\n\n for (dy <- -2 to 2) {\n for (dx <- -2 to 2) {\n val tx = x + dx\n val ty = y + dy\n\n if (!(dx == 0 && dy == 0) && tx >= 0 && ty >= 0 && tx < w && ty < h) {\n if (smap(ty)(tx) == '.') {\n if (Math.abs(dx) + Math.abs(dy) == 1) {\n unionFind.walkablize(xy2i(y, x), xy2i(ty, tx))\n } else {\n unionFind.warpablize(xy2i(y, x), xy2i(ty, tx))\n }\n }\n }\n }\n }\n }\n }\n }\n\n debug {\n for (y <- 0 until h) {\n for (x <- 0 until w) {\n if (smap(y)(x) == '.') {\n log(s\"(${y},${x}) = root->${unionFind.root(xy2i(y, x))}, warpables->${unionFind.getWarpables(xy2i(y, x))}\")\n }\n }\n }\n }\n\n val queue = mutable.Queue.empty[Int]\n queue.enqueue(xy2i(ch, cw))\n val warp = Array.fill(h * w)(-1)\n warp(xy2i(ch, cw)) = 0\n\n while (queue.nonEmpty) {\n val current = queue.dequeue()\n val currentWarp = warp(current)\n log(s\"current = ${current}\")\n log(s\"currentWarp = ${currentWarp}\")\n\n if (unionFind.isSameRoot(xy2i(dh, dw), current)) {\n out.println(currentWarp)\n out.flush()\n log(\"=== end\")\n debug {\n debugOut.flush()\n }\n return\n } else {\n val warpables = unionFind.getWarpables(current)\n warpables.foreach { w =>\n log(s\"-> warpables=${w}\")\n\n if (warp(w) == -1) {\n warp(w) = currentWarp + 1\n queue.enqueue(w)\n }\n }\n }\n }\n\n out.println(-1)\n out.flush()\n log(\"=== end\")\n debug {\n debugOut.flush()\n }\n\n }\n}", "language": "Scala", "metadata": {"date": 1598129344, "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/s300432387.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s300432387", "user_id": "u178269371"}, "prompt_components": {"gold_output": "1\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: => Any): Unit = {\n if (DEBUG) {\n debugOut.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 val (h, w) = get[Int, Int]\n val (ch, cw) = get[Int, Int] match {\n case (a, b) => (a - 1, b - 1)\n }\n val (dh, dw) = get[Int, Int] match {\n case (a, b) => (a - 1, b - 1)\n }\n val smap = Array.fill(h) {\n get[String].toCharArray\n }\n\n @inline\n def xy2i(y: Int, x: Int): Int = {\n y * w + x\n }\n\n @inline\n def i2xy(i: Int): (Int, Int) = {\n (i / w, i % w)\n }\n\n log(\"=== start\")\n\n class UnionFind(size: Int) {\n val roots: Array[Int] = Array.ofDim[Int](size)\n for (i <- 0 until size) {\n roots(i) = i\n }\n\n val warpable: Array[mutable.HashSet[Int]] = Array.fill(size)(mutable.HashSet.empty[Int])\n\n def root(a: Int): Int = {\n if (roots(a) == a) {\n a\n } else {\n roots(a) = root(roots(a))\n roots(a)\n }\n }\n\n def isSameRoot(a: Int, b: Int): Boolean = {\n root(a) == root(b)\n }\n\n def walkablize(a: Int, b: Int): Unit = {\n log(s\"walkablize(${i2xy(a)},${i2xy(b)})\")\n if (a != b) {\n val rootA = root(a)\n val rootB = root(b)\n if (rootA != rootB) {\n roots(rootB) = rootA\n warpable(rootA).addAll(warpable(rootB).map(root))\n warpable(rootB).clear()\n }\n }\n }\n\n def warpablize(a: Int, b: Int): Unit = {\n log(s\"warpablize(${i2xy(a)},${i2xy(b)})\")\n val rootA = root(a)\n val rootB = root(b)\n if (rootA != rootB) {\n warpable(rootA).add(rootB)\n warpable(rootB).add(rootA)\n }\n }\n\n def getWarpables(a: Int): mutable.HashSet[Int] = {\n val rootA = root(a)\n warpable(rootA) = warpable(rootA).map(root)\n\n warpable(rootA)\n }\n }\n\n val unionFind = new UnionFind(h * w)\n\n for (y <- 0 until h) {\n for (x <- 0 until w) {\n if (smap(y)(x) == '.') {\n\n for (dy <- -2 to 2) {\n for (dx <- -2 to 2) {\n val tx = x + dx\n val ty = y + dy\n\n if (!(dx == 0 && dy == 0) && tx >= 0 && ty >= 0 && tx < w && ty < h) {\n if (smap(ty)(tx) == '.') {\n if (Math.abs(dx) + Math.abs(dy) == 1) {\n unionFind.walkablize(xy2i(y, x), xy2i(ty, tx))\n } else {\n unionFind.warpablize(xy2i(y, x), xy2i(ty, tx))\n }\n }\n }\n }\n }\n }\n }\n }\n\n debug {\n for (y <- 0 until h) {\n for (x <- 0 until w) {\n if (smap(y)(x) == '.') {\n log(s\"(${y},${x}) = root->${unionFind.root(xy2i(y, x))}, warpables->${unionFind.getWarpables(xy2i(y, x))}\")\n }\n }\n }\n }\n\n val queue = mutable.Queue.empty[Int]\n queue.enqueue(xy2i(ch, cw))\n val warp = Array.fill(h * w)(-1)\n warp(xy2i(ch, cw)) = 0\n\n while (queue.nonEmpty) {\n val current = queue.dequeue()\n val currentWarp = warp(current)\n log(s\"current = ${current}\")\n log(s\"currentWarp = ${currentWarp}\")\n\n if (unionFind.isSameRoot(xy2i(dh, dw), current)) {\n out.println(currentWarp)\n out.flush()\n log(\"=== end\")\n debug {\n debugOut.flush()\n }\n return\n } else {\n val warpables = unionFind.getWarpables(current)\n warpables.foreach { w =>\n log(s\"-> warpables=${w}\")\n\n if (warp(w) == -1) {\n warp(w) = currentWarp + 1\n queue.enqueue(w)\n }\n }\n }\n }\n\n out.println(-1)\n out.flush()\n log(\"=== end\")\n debug {\n debugOut.flush()\n }\n\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "sample_input": "4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02579", "source_text": "Score : 400 points\n\nProblem Statement\n\nA maze is composed of a grid of H \\times W squares - H vertical, W horizontal.\n\nThe square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is # and a road if S_{ij} is ..\n\nThere is a magician in (C_h,C_w). He can do the following two kinds of moves:\n\nMove A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.\n\nMove B: Use magic to warp himself to a road square in the 5\\times 5 area centered at the square he is currently in.\n\nIn either case, he cannot go out of the maze.\n\nAt least how many times does he need to use the magic to reach (D_h, D_w)?\n\nConstraints\n\n1 \\leq H,W \\leq 10^3\n\n1 \\leq C_h,D_h \\leq H\n\n1 \\leq C_w,D_w \\leq W\n\nS_{ij} is # or ..\n\nS_{C_h C_w} and S_{D_h D_w} are ..\n\n(C_h,C_w) \\neq (D_h,D_w)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nC_h C_w\nD_h D_w\nS_{11}\\ldots S_{1W}\n\\vdots\nS_{H1}\\ldots S_{HW}\n\nOutput\n\nPrint the minimum number of times the magician needs to use the magic. If he cannot reach (D_h,D_w), print -1 instead.\n\nSample Input 1\n\n4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n\nSample Output 1\n\n1\n\nFor example, by walking to (2,2) and then using the magic to travel to (4,4), just one use of magic is enough.\n\nNote that he cannot walk diagonally.\n\nSample Input 2\n\n4 4\n1 4\n4 1\n.##.\n####\n####\n.##.\n\nSample Output 2\n\n-1\n\nHe cannot move from there.\n\nSample Input 3\n\n4 4\n2 2\n3 3\n....\n....\n....\n....\n\nSample Output 3\n\n0\n\nNo use of magic is needed.\n\nSample Input 4\n\n4 5\n1 2\n2 5\n#.###\n####.\n#..##\n#..##\n\nSample Output 4\n\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 7851, "cpu_time_ms": 2205, "memory_kb": 301176}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s510182295", "group_id": "codeNet:p02582", "input_text": "object Main extends App {\n val input = io.StdIn.readLine()\n val score = input match {\n case \"RRR\" => 0\n case \"RRS\" => 1\n case \"RSR\" => 1\n case \"RSS\" => 2\n case \"SRR\" => 1\n case \"SRS\" => 1\n case \"SSR\" => 2\n case \"SSS\" => 3\n }\n println(score)\n}", "language": "Scala", "metadata": {"date": 1597896217, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02582.html", "problem_id": "p02582", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02582/input.txt", "sample_output_relpath": "derived/input_output/data/p02582/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02582/Scala/s510182295.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s510182295", "user_id": "u489121515"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n val input = io.StdIn.readLine()\n val score = input match {\n case \"RRR\" => 0\n case \"RRS\" => 1\n case \"RSR\" => 1\n case \"RSS\" => 2\n case \"SRR\" => 1\n case \"SRS\" => 1\n case \"SSR\" => 2\n case \"SSS\" => 3\n }\n println(score)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is S, it means it was sunny on the i-th day; if that character is R, it means it was rainy on that day.\n\nFind the maximum number of consecutive rainy days in this period.\n\nConstraints\n\n|S| = 3\n\nEach character of S is S or R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of consecutive rainy days in the period.\n\nSample Input 1\n\nRRS\n\nSample Output 1\n\n2\n\nWe had rain on the 1-st and 2-nd days in the period. Here, the maximum number of consecutive rainy days is 2, so we should print 2.\n\nSample Input 2\n\nSSS\n\nSample Output 2\n\n0\n\nIt was sunny throughout the period. We had no rainy days, so we should print 0.\n\nSample Input 3\n\nRSR\n\nSample Output 3\n\n1\n\nWe had rain on the 1-st and 3-rd days - two \"streaks\" of one rainy day, so we should print 1.", "sample_input": "RRS\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02582", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is S, it means it was sunny on the i-th day; if that character is R, it means it was rainy on that day.\n\nFind the maximum number of consecutive rainy days in this period.\n\nConstraints\n\n|S| = 3\n\nEach character of S is S or R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of consecutive rainy days in the period.\n\nSample Input 1\n\nRRS\n\nSample Output 1\n\n2\n\nWe had rain on the 1-st and 2-nd days in the period. Here, the maximum number of consecutive rainy days is 2, so we should print 2.\n\nSample Input 2\n\nSSS\n\nSample Output 2\n\n0\n\nIt was sunny throughout the period. We had no rainy days, so we should print 0.\n\nSample Input 3\n\nRSR\n\nSample Output 3\n\n1\n\nWe had rain on the 1-st and 3-rd days - two \"streaks\" of one rainy day, so we should print 1.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 270, "cpu_time_ms": 483, "memory_kb": 54628}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s273631201", "group_id": "codeNet:p02583", "input_text": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val N = in.nextInt\n val Ls = Array.fill(N)(in.nextInt).sorted\n println((for {\n a <- 0 until Ls.size\n b <- a + 1 until Ls.size\n c <- b + 1 until Ls.size\n if (Ls(a) != Ls(b) && Ls(b) != Ls(c) && Ls(a) + Ls(b) > Ls(c))\n } yield 1).size)\n}", "language": "Scala", "metadata": {"date": 1597759970, "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/s273631201.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s273631201", "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 = in.nextInt\n val Ls = Array.fill(N)(in.nextInt).sorted\n println((for {\n a <- 0 until Ls.size\n b <- a + 1 until Ls.size\n c <- b + 1 until Ls.size\n if (Ls(a) != Ls(b) && Ls(b) != Ls(c) && Ls(a) + Ls(b) > Ls(c))\n } yield 1).size)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have sticks numbered 1, \\cdots, N. The length of Stick i (1 \\leq i \\leq N) is L_i.\n\nIn how many ways can we choose three of the sticks with different lengths that can form a triangle?\n\nThat is, find the number of triples of integers (i, j, k) (1 \\leq i < j < k \\leq N) that satisfy both of the following conditions:\n\nL_i, L_j, and L_k are all different.\n\nThere exists a triangle whose sides have lengths L_i, L_j, and L_k.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 \\cdots L_N\n\nOutput\n\nPrint the number of ways to choose three of the sticks with different lengths that can form a triangle.\n\nSample Input 1\n\n5\n4 4 9 7 5\n\nSample Output 1\n\n5\n\nThe following five triples (i, j, k) satisfy the conditions: (1, 3, 4), (1, 4, 5), (2, 3, 4), (2, 4, 5), and (3, 4, 5).\n\nSample Input 2\n\n6\n4 5 4 3 3 5\n\nSample Output 2\n\n8\n\nWe have two sticks for each of the lengths 3, 4, and 5. To satisfy the first condition, we have to choose one from each length.\n\nThere is a triangle whose sides have lengths 3, 4, and 5, so we have 2 ^ 3 = 8 triples (i, j, k) that satisfy the conditions.\n\nSample Input 3\n\n10\n9 4 6 1 9 6 10 6 6 8\n\nSample Output 3\n\n39\n\nSample Input 4\n\n2\n1 1\n\nSample Output 4\n\n0\n\nNo triple (i, j, k) satisfies 1 \\leq i < j < k \\leq N, so we should print 0.", "sample_input": "5\n4 4 9 7 5\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02583", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have sticks numbered 1, \\cdots, N. The length of Stick i (1 \\leq i \\leq N) is L_i.\n\nIn how many ways can we choose three of the sticks with different lengths that can form a triangle?\n\nThat is, find the number of triples of integers (i, j, k) (1 \\leq i < j < k \\leq N) that satisfy both of the following conditions:\n\nL_i, L_j, and L_k are all different.\n\nThere exists a triangle whose sides have lengths L_i, L_j, and L_k.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 \\cdots L_N\n\nOutput\n\nPrint the number of ways to choose three of the sticks with different lengths that can form a triangle.\n\nSample Input 1\n\n5\n4 4 9 7 5\n\nSample Output 1\n\n5\n\nThe following five triples (i, j, k) satisfy the conditions: (1, 3, 4), (1, 4, 5), (2, 3, 4), (2, 4, 5), and (3, 4, 5).\n\nSample Input 2\n\n6\n4 5 4 3 3 5\n\nSample Output 2\n\n8\n\nWe have two sticks for each of the lengths 3, 4, and 5. To satisfy the first condition, we have to choose one from each length.\n\nThere is a triangle whose sides have lengths 3, 4, and 5, so we have 2 ^ 3 = 8 triples (i, j, k) that satisfy the conditions.\n\nSample Input 3\n\n10\n9 4 6 1 9 6 10 6 6 8\n\nSample Output 3\n\n39\n\nSample Input 4\n\n2\n1 1\n\nSample Output 4\n\n0\n\nNo triple (i, j, k) satisfies 1 \\leq i < j < k \\leq N, so we should print 0.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 322, "cpu_time_ms": 609, "memory_kb": 58200}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s104725299", "group_id": "codeNet:p02583", "input_text": "import scala.util.control.Breaks\n\nobject Main extends App {\n val n = scala.io.StdIn.readInt()\n val lInput = scala.io.StdIn.readLine()\n val lArray = lInput.split(\" \").map(_.toLong).toVector\n\n val lArraySorted = lArray.toSet.toVector.sorted\n val sortedLength = lArraySorted.length\n val groupedMap = lArray.groupBy(l => l)\n var result = 0\n\n def setTriangle(head: Long, tail: Vector[Long]): Unit = {\n tail.zipWithIndex.foreach { t =>\n if (head < t._1) {\n val second = (head, t._1)\n setThirdPosition(second, tail.drop(t._2 + 1))\n }\n }\n }\n\n def setThirdPosition(nihen: (Long, Long), tail: Vector[Long]): Unit = {\n val b = new Breaks\n b.breakable {\n tail.foreach { t =>\n if ((nihen._1 + nihen._2) > t && t > Math.abs((nihen._1 - nihen._2))) {\n val firstCount = groupedMap.get(nihen._1).get.size\n val secondCount = groupedMap.get(nihen._2).get.size\n val thirdCount = groupedMap.get(t).get.size\n result = result + (firstCount * secondCount * thirdCount)\n } else {\n b.break()\n }\n }\n }\n }\n\n if (sortedLength > 2) {\n var count = sortedLength\n var tempSortedArray = lArraySorted\n while (count > 2) {\n val head = tempSortedArray.head\n tempSortedArray = tempSortedArray.tail\n setTriangle(head, tempSortedArray)\n count = count - 1\n }\n println(result)\n } else {\n println(0)\n }\n\n}", "language": "Scala", "metadata": {"date": 1597521983, "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/s104725299.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s104725299", "user_id": "u105921924"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import scala.util.control.Breaks\n\nobject Main extends App {\n val n = scala.io.StdIn.readInt()\n val lInput = scala.io.StdIn.readLine()\n val lArray = lInput.split(\" \").map(_.toLong).toVector\n\n val lArraySorted = lArray.toSet.toVector.sorted\n val sortedLength = lArraySorted.length\n val groupedMap = lArray.groupBy(l => l)\n var result = 0\n\n def setTriangle(head: Long, tail: Vector[Long]): Unit = {\n tail.zipWithIndex.foreach { t =>\n if (head < t._1) {\n val second = (head, t._1)\n setThirdPosition(second, tail.drop(t._2 + 1))\n }\n }\n }\n\n def setThirdPosition(nihen: (Long, Long), tail: Vector[Long]): Unit = {\n val b = new Breaks\n b.breakable {\n tail.foreach { t =>\n if ((nihen._1 + nihen._2) > t && t > Math.abs((nihen._1 - nihen._2))) {\n val firstCount = groupedMap.get(nihen._1).get.size\n val secondCount = groupedMap.get(nihen._2).get.size\n val thirdCount = groupedMap.get(t).get.size\n result = result + (firstCount * secondCount * thirdCount)\n } else {\n b.break()\n }\n }\n }\n }\n\n if (sortedLength > 2) {\n var count = sortedLength\n var tempSortedArray = lArraySorted\n while (count > 2) {\n val head = tempSortedArray.head\n tempSortedArray = tempSortedArray.tail\n setTriangle(head, tempSortedArray)\n count = count - 1\n }\n println(result)\n } else {\n println(0)\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 663, "memory_kb": 57208}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s928425918", "group_id": "codeNet:p02583", "input_text": "\nimport scala.io.StdIn\n\nobject Main extends App {\n StdIn.readLine()\n val sticks = StdIn.readLine().split(' ').map(_.toInt)\n\n val stickIdCombinations=scala.collection.mutable.Set.empty[Set[Int]]\n for(s1 <- 0 until sticks.length){\n for(s2 <- 0 until sticks.length){\n for(s3 <- 0 until sticks.length){\n val stickLens = List(s1,s2,s3).map(sticks(_)).toSet\n if(stickLens.size == 3){\n stickIdCombinations += Set(s1,s2,s3)\n }\n }\n }\n }\n\n val ans = (for (stickIds <- stickIdCombinations.toList) yield {\n val List(s1, s2, s3) = stickIds.toList.map(sticks(_))\n if (s1 + s2 > s3 && s2 + s3 > s1 && s3 + s1 > s2)\n 1\n else\n 0\n }).sum\n\n println(ans)\n\n\n\n}\n\n\n\n\n\n\n", "language": "Scala", "metadata": {"date": 1597520274, "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/s928425918.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s928425918", "user_id": "u416662335"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "\nimport scala.io.StdIn\n\nobject Main extends App {\n StdIn.readLine()\n val sticks = StdIn.readLine().split(' ').map(_.toInt)\n\n val stickIdCombinations=scala.collection.mutable.Set.empty[Set[Int]]\n for(s1 <- 0 until sticks.length){\n for(s2 <- 0 until sticks.length){\n for(s3 <- 0 until sticks.length){\n val stickLens = List(s1,s2,s3).map(sticks(_)).toSet\n if(stickLens.size == 3){\n stickIdCombinations += Set(s1,s2,s3)\n }\n }\n }\n }\n\n val ans = (for (stickIds <- stickIdCombinations.toList) yield {\n val List(s1, s2, s3) = stickIds.toList.map(sticks(_))\n if (s1 + s2 > s3 && s2 + s3 > s1 && s3 + s1 > s2)\n 1\n else\n 0\n }).sum\n\n println(ans)\n\n\n\n}\n\n\n\n\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 719, "cpu_time_ms": 1904, "memory_kb": 74728}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s763869147", "group_id": "codeNet:p02584", "input_text": "import scala.math.BigInt.long2bigInt\n\nobject Main extends App {\n val params = io.StdIn.readLine().split(\" \").map(_.toLong)\n var x = params(0)\n var k = params(1)\n var d = params(2)\n var ans: Long = 0\n\n x = Math.abs(x)\n val stright : Long = Math.min(k, x / d)\n k -= stright\n x -= stright * d\n\n if ((k mod 2) == 0)\n ans = x\n else\n ans = Math.abs(x - d)\n\n println(ans)\n}\n", "language": "Scala", "metadata": {"date": 1597900013, "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/s763869147.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s763869147", "user_id": "u489121515"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.math.BigInt.long2bigInt\n\nobject Main extends App {\n val params = io.StdIn.readLine().split(\" \").map(_.toLong)\n var x = params(0)\n var k = params(1)\n var d = params(2)\n var ans: Long = 0\n\n x = Math.abs(x)\n val stright : Long = Math.min(k, x / d)\n k -= stright\n x -= stright * d\n\n if ((k mod 2) == 0)\n ans = x\n else\n ans = Math.abs(x - d)\n\n println(ans)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.\n\nMore specifically, in one move, he can go from coordinate x to x + D or x - D.\n\nHe wants to make K moves so that the absolute value of the coordinate of the destination will be the smallest possible.\n\nFind the minimum possible absolute value of the coordinate of the destination.\n\nConstraints\n\n-10^{15} \\leq X \\leq 10^{15}\n\n1 \\leq K \\leq 10^{15}\n\n1 \\leq D \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX K D\n\nOutput\n\nPrint the minimum possible absolute value of the coordinate of the destination.\n\nSample Input 1\n\n6 2 4\n\nSample Output 1\n\n2\n\nTakahashi is now at coordinate 6. It is optimal to make the following moves:\n\nMove from coordinate 6 to (6 - 4 =) 2.\n\nMove from coordinate 2 to (2 - 4 =) -2.\n\nHere, the absolute value of the coordinate of the destination is 2, and we cannot make it smaller.\n\nSample Input 2\n\n7 4 3\n\nSample Output 2\n\n1\n\nTakahashi is now at coordinate 7. It is optimal to make, for example, the following moves:\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 7.\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 1.\n\nHere, the absolute value of the coordinate of the destination is 1, and we cannot make it smaller.\n\nSample Input 3\n\n10 1 2\n\nSample Output 3\n\n8\n\nSample Input 4\n\n1000000000000000 1000000000000000 1000000000000000\n\nSample Output 4\n\n1000000000000000\n\nThe answer can be enormous.", "sample_input": "6 2 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02584", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.\n\nMore specifically, in one move, he can go from coordinate x to x + D or x - D.\n\nHe wants to make K moves so that the absolute value of the coordinate of the destination will be the smallest possible.\n\nFind the minimum possible absolute value of the coordinate of the destination.\n\nConstraints\n\n-10^{15} \\leq X \\leq 10^{15}\n\n1 \\leq K \\leq 10^{15}\n\n1 \\leq D \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX K D\n\nOutput\n\nPrint the minimum possible absolute value of the coordinate of the destination.\n\nSample Input 1\n\n6 2 4\n\nSample Output 1\n\n2\n\nTakahashi is now at coordinate 6. It is optimal to make the following moves:\n\nMove from coordinate 6 to (6 - 4 =) 2.\n\nMove from coordinate 2 to (2 - 4 =) -2.\n\nHere, the absolute value of the coordinate of the destination is 2, and we cannot make it smaller.\n\nSample Input 2\n\n7 4 3\n\nSample Output 2\n\n1\n\nTakahashi is now at coordinate 7. It is optimal to make, for example, the following moves:\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 7.\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 1.\n\nHere, the absolute value of the coordinate of the destination is 1, and we cannot make it smaller.\n\nSample Input 3\n\n10 1 2\n\nSample Output 3\n\n8\n\nSample Input 4\n\n1000000000000000 1000000000000000 1000000000000000\n\nSample Output 4\n\n1000000000000000\n\nThe answer can be enormous.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 385, "cpu_time_ms": 488, "memory_kb": 54796}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s590381829", "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 val z = if (x == 0) 1 else 0\n for {\n i <- 0 until l\n j <- i+z to i+y\n } {\n ans = ans.max(sum * x + fa(j) - fa(i))\n }\n\n val w = if (x == 1) 1 else 0\n if (x != 0) {\n for {\n i <- 0 until l\n j <- i+w to i+l\n } {\n ans = ans.max(sum * (x-1) + fa(j) - fa(i))\n }\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": 1597544356, "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/s590381829.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s590381829", "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 val z = if (x == 0) 1 else 0\n for {\n i <- 0 until l\n j <- i+z to i+y\n } {\n ans = ans.max(sum * x + fa(j) - fa(i))\n }\n\n val w = if (x == 1) 1 else 0\n if (x != 0) {\n for {\n i <- 0 until l\n j <- i+w to i+l\n } {\n ans = ans.max(sum * (x-1) + fa(j) - fa(i))\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1356, "cpu_time_ms": 958, "memory_kb": 58780}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s375364014", "group_id": "codeNet:p02595", "input_text": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val N, D = in.nextInt\n val Ps = Array.fill(N)((in.nextLong, in.nextLong))\n val sq = D.toLong * D\n\n println(Ps.count{case (x, y) => x * x + y * y <= sq})\n}", "language": "Scala", "metadata": {"date": 1597354393, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02595.html", "problem_id": "p02595", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02595/input.txt", "sample_output_relpath": "derived/input_output/data/p02595/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02595/Scala/s375364014.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s375364014", "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, D = in.nextInt\n val Ps = Array.fill(N)((in.nextLong, in.nextLong))\n val sq = D.toLong * D\n\n println(Ps.count{case (x, y) => x * x + y * y <= sq})\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i).\n\nAmong them, we are looking for the points such that the distance from the origin is at most D. How many such points are there?\n\nWe remind you that the distance between the origin and the point (p, q) can be represented as \\sqrt{p^2+q^2}.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n0 \\leq D \\leq 2\\times 10^5\n\n|X_i|,|Y_i| \\leq 2\\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_1 Y_1\n\\vdots\nX_N Y_N\n\nOutput\n\nPrint an integer representing the number of points such that the distance from the origin is at most D.\n\nSample Input 1\n\n4 5\n0 5\n-2 4\n3 4\n4 -4\n\nSample Output 1\n\n3\n\nThe distance between the origin and each of the given points is as follows:\n\n\\sqrt{0^2+5^2}=5\n\n\\sqrt{(-2)^2+4^2}=4.472\\ldots\n\n\\sqrt{3^2+4^2}=5\n\n\\sqrt{4^2+(-4)^2}=5.656\\ldots\n\nThus, we have three points such that the distance from the origin is at most 5.\n\nSample Input 2\n\n12 3\n1 1\n1 1\n1 1\n1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3\n\nSample Output 2\n\n7\n\nMultiple points may exist at the same coordinates.\n\nSample Input 3\n\n20 100000\n14309 -32939\n-56855 100340\n151364 25430\n103789 -113141\n147404 -136977\n-37006 -30929\n188810 -49557\n13419 70401\n-88280 165170\n-196399 137941\n-176527 -61904\n46659 115261\n-153551 114185\n98784 -6820\n94111 -86268\n-30401 61477\n-55056 7872\n5901 -163796\n138819 -185986\n-69848 -96669\n\nSample Output 3\n\n6", "sample_input": "4 5\n0 5\n-2 4\n3 4\n4 -4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02595", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i).\n\nAmong them, we are looking for the points such that the distance from the origin is at most D. How many such points are there?\n\nWe remind you that the distance between the origin and the point (p, q) can be represented as \\sqrt{p^2+q^2}.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n0 \\leq D \\leq 2\\times 10^5\n\n|X_i|,|Y_i| \\leq 2\\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_1 Y_1\n\\vdots\nX_N Y_N\n\nOutput\n\nPrint an integer representing the number of points such that the distance from the origin is at most D.\n\nSample Input 1\n\n4 5\n0 5\n-2 4\n3 4\n4 -4\n\nSample Output 1\n\n3\n\nThe distance between the origin and each of the given points is as follows:\n\n\\sqrt{0^2+5^2}=5\n\n\\sqrt{(-2)^2+4^2}=4.472\\ldots\n\n\\sqrt{3^2+4^2}=5\n\n\\sqrt{4^2+(-4)^2}=5.656\\ldots\n\nThus, we have three points such that the distance from the origin is at most 5.\n\nSample Input 2\n\n12 3\n1 1\n1 1\n1 1\n1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3\n\nSample Output 2\n\n7\n\nMultiple points may exist at the same coordinates.\n\nSample Input 3\n\n20 100000\n14309 -32939\n-56855 100340\n151364 25430\n103789 -113141\n147404 -136977\n-37006 -30929\n188810 -49557\n13419 70401\n-88280 165170\n-196399 137941\n-176527 -61904\n46659 115261\n-153551 114185\n98784 -6820\n94111 -86268\n-30401 61477\n-55056 7872\n5901 -163796\n138819 -185986\n-69848 -96669\n\nSample Output 3\n\n6", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 229, "cpu_time_ms": 1056, "memory_kb": 68076}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s181479529", "group_id": "codeNet:p02595", "input_text": "import scala.io.StdIn._\n\nobject Main extends App {\n\n val Array(n,d) = readLine().split(\" \").map(_.toInt)\n val xy = Array.fill(n)(readLine().split(\" \").map(_.toLong))\n\n def solve() = {\n xy.map { l =>\n Math.sqrt(l(0) * l(0) + l(1) * l(1))\n }.count(_ <= d)\n }\n\n println(solve())\n\n}\n\n", "language": "Scala", "metadata": {"date": 1596416724, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02595.html", "problem_id": "p02595", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02595/input.txt", "sample_output_relpath": "derived/input_output/data/p02595/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02595/Scala/s181479529.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s181479529", "user_id": "u947008426"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main extends App {\n\n val Array(n,d) = readLine().split(\" \").map(_.toInt)\n val xy = Array.fill(n)(readLine().split(\" \").map(_.toLong))\n\n def solve() = {\n xy.map { l =>\n Math.sqrt(l(0) * l(0) + l(1) * l(1))\n }.count(_ <= d)\n }\n\n println(solve())\n\n}\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i).\n\nAmong them, we are looking for the points such that the distance from the origin is at most D. How many such points are there?\n\nWe remind you that the distance between the origin and the point (p, q) can be represented as \\sqrt{p^2+q^2}.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n0 \\leq D \\leq 2\\times 10^5\n\n|X_i|,|Y_i| \\leq 2\\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_1 Y_1\n\\vdots\nX_N Y_N\n\nOutput\n\nPrint an integer representing the number of points such that the distance from the origin is at most D.\n\nSample Input 1\n\n4 5\n0 5\n-2 4\n3 4\n4 -4\n\nSample Output 1\n\n3\n\nThe distance between the origin and each of the given points is as follows:\n\n\\sqrt{0^2+5^2}=5\n\n\\sqrt{(-2)^2+4^2}=4.472\\ldots\n\n\\sqrt{3^2+4^2}=5\n\n\\sqrt{4^2+(-4)^2}=5.656\\ldots\n\nThus, we have three points such that the distance from the origin is at most 5.\n\nSample Input 2\n\n12 3\n1 1\n1 1\n1 1\n1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3\n\nSample Output 2\n\n7\n\nMultiple points may exist at the same coordinates.\n\nSample Input 3\n\n20 100000\n14309 -32939\n-56855 100340\n151364 25430\n103789 -113141\n147404 -136977\n-37006 -30929\n188810 -49557\n13419 70401\n-88280 165170\n-196399 137941\n-176527 -61904\n46659 115261\n-153551 114185\n98784 -6820\n94111 -86268\n-30401 61477\n-55056 7872\n5901 -163796\n138819 -185986\n-69848 -96669\n\nSample Output 3\n\n6", "sample_input": "4 5\n0 5\n-2 4\n3 4\n4 -4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02595", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i).\n\nAmong them, we are looking for the points such that the distance from the origin is at most D. How many such points are there?\n\nWe remind you that the distance between the origin and the point (p, q) can be represented as \\sqrt{p^2+q^2}.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n0 \\leq D \\leq 2\\times 10^5\n\n|X_i|,|Y_i| \\leq 2\\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_1 Y_1\n\\vdots\nX_N Y_N\n\nOutput\n\nPrint an integer representing the number of points such that the distance from the origin is at most D.\n\nSample Input 1\n\n4 5\n0 5\n-2 4\n3 4\n4 -4\n\nSample Output 1\n\n3\n\nThe distance between the origin and each of the given points is as follows:\n\n\\sqrt{0^2+5^2}=5\n\n\\sqrt{(-2)^2+4^2}=4.472\\ldots\n\n\\sqrt{3^2+4^2}=5\n\n\\sqrt{4^2+(-4)^2}=5.656\\ldots\n\nThus, we have three points such that the distance from the origin is at most 5.\n\nSample Input 2\n\n12 3\n1 1\n1 1\n1 1\n1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3\n\nSample Output 2\n\n7\n\nMultiple points may exist at the same coordinates.\n\nSample Input 3\n\n20 100000\n14309 -32939\n-56855 100340\n151364 25430\n103789 -113141\n147404 -136977\n-37006 -30929\n188810 -49557\n13419 70401\n-88280 165170\n-196399 137941\n-176527 -61904\n46659 115261\n-153551 114185\n98784 -6820\n94111 -86268\n-30401 61477\n-55056 7872\n5901 -163796\n138819 -185986\n-69848 -96669\n\nSample Output 3\n\n6", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 296, "cpu_time_ms": 825, "memory_kb": 66380}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s868517515", "group_id": "codeNet:p02596", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val num = scala.io.StdIn.readInt\n var check_num = Array.fill( num )( false )\n\n if( num%2 == 0 || num%5 == 0 ) println( -1 )\n else {\n var check = 7%num\n var count = 1\n while( check != 0 && !check_num( check ) ) {\n count += 1\n check_num( check ) = true\n check = ( check*10 + 7 )%num \n }\n\n if( check%num != 0 ) println( -1 )\n else println( count )\n }\n }\n}", "language": "Scala", "metadata": {"date": 1596600868, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02596.html", "problem_id": "p02596", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02596/input.txt", "sample_output_relpath": "derived/input_output/data/p02596/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02596/Scala/s868517515.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s868517515", "user_id": "u888177577"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val num = scala.io.StdIn.readInt\n var check_num = Array.fill( num )( false )\n\n if( num%2 == 0 || num%5 == 0 ) println( -1 )\n else {\n var check = 7%num\n var count = 1\n while( check != 0 && !check_num( check ) ) {\n count += 1\n check_num( check ) = true\n check = ( check*10 + 7 )%num \n }\n\n if( check%num != 0 ) println( -1 )\n else println( count )\n }\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi loves the number 7 and multiples of K.\n\nWhere is the first occurrence of a multiple of K in the sequence 7,77,777,\\ldots? (Also see Output and Sample Input/Output below.)\n\nIf the sequence contains no multiples of K, print -1 instead.\n\nConstraints\n\n1 \\leq K \\leq 10^6\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint an integer representing the position of the first occurrence of a multiple of K. (For example, if the first occurrence is the fourth element of the sequence, print 4.)\n\nSample Input 1\n\n101\n\nSample Output 1\n\n4\n\nNone of 7, 77, and 777 is a multiple of 101, but 7777 is.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n-1\n\nAll elements in the sequence are odd numbers; there are no multiples of 2.\n\nSample Input 3\n\n999983\n\nSample Output 3\n\n999982", "sample_input": "101\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02596", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi loves the number 7 and multiples of K.\n\nWhere is the first occurrence of a multiple of K in the sequence 7,77,777,\\ldots? (Also see Output and Sample Input/Output below.)\n\nIf the sequence contains no multiples of K, print -1 instead.\n\nConstraints\n\n1 \\leq K \\leq 10^6\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint an integer representing the position of the first occurrence of a multiple of K. (For example, if the first occurrence is the fourth element of the sequence, print 4.)\n\nSample Input 1\n\n101\n\nSample Output 1\n\n4\n\nNone of 7, 77, and 777 is a multiple of 101, but 7777 is.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n-1\n\nAll elements in the sequence are odd numbers; there are no multiples of 2.\n\nSample Input 3\n\n999983\n\nSample Output 3\n\n999982", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 492, "cpu_time_ms": 497, "memory_kb": 54748}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s473666131", "group_id": "codeNet:p02596", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val k = sc.nextInt()\n val res = Array.fill(k)(false)\n\n var i = 0\n var r = 7 % k\n res(r) = true\n var continue = true\n while (continue) {\n r = (((r * 10) % k) + 7 % k) % k\n if (res(r)) {\n continue = false\n } else {\n res(r) = true\n }\n i += 1\n }\n\n println(if (res(0)) i else -1)\n}\n", "language": "Scala", "metadata": {"date": 1596421579, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02596.html", "problem_id": "p02596", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02596/input.txt", "sample_output_relpath": "derived/input_output/data/p02596/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02596/Scala/s473666131.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s473666131", "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 k = sc.nextInt()\n val res = Array.fill(k)(false)\n\n var i = 0\n var r = 7 % k\n res(r) = true\n var continue = true\n while (continue) {\n r = (((r * 10) % k) + 7 % k) % k\n if (res(r)) {\n continue = false\n } else {\n res(r) = true\n }\n i += 1\n }\n\n println(if (res(0)) i else -1)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi loves the number 7 and multiples of K.\n\nWhere is the first occurrence of a multiple of K in the sequence 7,77,777,\\ldots? (Also see Output and Sample Input/Output below.)\n\nIf the sequence contains no multiples of K, print -1 instead.\n\nConstraints\n\n1 \\leq K \\leq 10^6\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint an integer representing the position of the first occurrence of a multiple of K. (For example, if the first occurrence is the fourth element of the sequence, print 4.)\n\nSample Input 1\n\n101\n\nSample Output 1\n\n4\n\nNone of 7, 77, and 777 is a multiple of 101, but 7777 is.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n-1\n\nAll elements in the sequence are odd numbers; there are no multiples of 2.\n\nSample Input 3\n\n999983\n\nSample Output 3\n\n999982", "sample_input": "101\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02596", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi loves the number 7 and multiples of K.\n\nWhere is the first occurrence of a multiple of K in the sequence 7,77,777,\\ldots? (Also see Output and Sample Input/Output below.)\n\nIf the sequence contains no multiples of K, print -1 instead.\n\nConstraints\n\n1 \\leq K \\leq 10^6\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint an integer representing the position of the first occurrence of a multiple of K. (For example, if the first occurrence is the fourth element of the sequence, print 4.)\n\nSample Input 1\n\n101\n\nSample Output 1\n\n4\n\nNone of 7, 77, and 777 is a multiple of 101, but 7777 is.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n-1\n\nAll elements in the sequence are odd numbers; there are no multiples of 2.\n\nSample Input 3\n\n999983\n\nSample Output 3\n\n999982", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 561, "memory_kb": 55452}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s426137028", "group_id": "codeNet:p02599", "input_text": "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\n val pre = Array.fill(n)(-1)\n val ps = Array.fill(n)(List[Int]())\n for ((r, idx) <- c.zipWithIndex) {\n val l = pre(r)\n if (l != -1) {\n ps(l) ::= r\n }\n pre(r) = idx\n }\n\n val qs = Array.fill(n)(List[(Int, Int)]())\n for (((l, r), idx) <- lr.zipWithIndex) {\n qs(l) ::= (r, idx)\n }\n\n val ans = Array.fill(q)(0)\n val bit = new BinaryIndexedTree(n)\n\n for (((pys, qys), x) <- ps.zip(qs).zipWithIndex.reverse) {\n for (y <- pys) {\n bit.add(y, 1)\n }\n for ((y, idx) <- qys) {\n ans(idx) = y-x+1 - bit.query(y)\n }\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", "language": "Scala", "metadata": {"date": 1596594768, "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/s426137028.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s426137028", "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\n val pre = Array.fill(n)(-1)\n val ps = Array.fill(n)(List[Int]())\n for ((r, idx) <- c.zipWithIndex) {\n val l = pre(r)\n if (l != -1) {\n ps(l) ::= r\n }\n pre(r) = idx\n }\n\n val qs = Array.fill(n)(List[(Int, Int)]())\n for (((l, r), idx) <- lr.zipWithIndex) {\n qs(l) ::= (r, idx)\n }\n\n val ans = Array.fill(q)(0)\n val bit = new BinaryIndexedTree(n)\n\n for (((pys, qys), x) <- ps.zip(qs).zipWithIndex.reverse) {\n for (y <- pys) {\n bit.add(y, 1)\n }\n for ((y, idx) <- qys) {\n ans(idx) = y-x+1 - bit.query(y)\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2496, "cpu_time_ms": 2014, "memory_kb": 271184}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s527646800", "group_id": "codeNet:p02599", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n, q = sc.nextInt()\n val c = Array.fill(n)(sc.nextInt())\n val lr = Array.fill(q)(sc.nextInt, sc.nextInt)\n lr.map(color).foreach(println)\n\n def color(v:(Int, Int)): Int = {\n c.slice(v._1 - 1, v._2).distinct.length\n }\n}", "language": "Scala", "metadata": {"date": 1596420337, "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/s527646800.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s527646800", "user_id": "u511308950"}, "prompt_components": {"gold_output": "2\n3\n1\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n, q = sc.nextInt()\n val c = Array.fill(n)(sc.nextInt())\n val lr = Array.fill(q)(sc.nextInt, sc.nextInt)\n lr.map(color).foreach(println)\n\n def color(v:(Int, Int)): Int = {\n c.slice(v._1 - 1, v._2).distinct.length\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2205, "memory_kb": 103472}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s912926459", "group_id": "codeNet:p02600", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val score = scala.io.StdIn.readInt\n var rate = 0\n if( 400 <= score && score < 600 ) rate = 8\n else if( 600 <= score && score < 800 ) rate = 7\n else if( 800 <= score && score < 1000 ) rate = 6\n else if( 1000 <= score && score < 1200 ) rate = 5\n else if( 1200 <= score && score < 1400 ) rate = 4\n else if( 1400 <= score && score < 1600 ) rate = 3\n else if( 1600 <= score && score < 1800 ) rate = 2\n else if( 1800 <= score && score < 2000 ) rate = 1\n\n println( rate )\n }\n}", "language": "Scala", "metadata": {"date": 1595725479, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02600.html", "problem_id": "p02600", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02600/input.txt", "sample_output_relpath": "derived/input_output/data/p02600/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02600/Scala/s912926459.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s912926459", "user_id": "u888177577"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val score = scala.io.StdIn.readInt\n var rate = 0\n if( 400 <= score && score < 600 ) rate = 8\n else if( 600 <= score && score < 800 ) rate = 7\n else if( 800 <= score && score < 1000 ) rate = 6\n else if( 1000 <= score && score < 1200 ) rate = 5\n else if( 1200 <= score && score < 1400 ) rate = 4\n else if( 1400 <= score && score < 1600 ) rate = 3\n else if( 1600 <= score && score < 1800 ) rate = 2\n else if( 1800 <= score && score < 2000 ) rate = 1\n\n println( rate )\n }\n}", "problem_context": "Score: 100 points\n\nProblem Statement\n\nM-kun is a competitor in AtCoder, whose highest rating is X.\n\nIn this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given:\n\nFrom 400 through 599: 8-kyu\n\nFrom 600 through 799: 7-kyu\n\nFrom 800 through 999: 6-kyu\n\nFrom 1000 through 1199: 5-kyu\n\nFrom 1200 through 1399: 4-kyu\n\nFrom 1400 through 1599: 3-kyu\n\nFrom 1600 through 1799: 2-kyu\n\nFrom 1800 through 1999: 1-kyu\n\nWhat kyu does M-kun have?\n\nConstraints\n\n400 \\leq X \\leq 1999\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the kyu M-kun has, as an integer.\nFor example, if he has 8-kyu, print 8.\n\nSample Input 1\n\n725\n\nSample Output 1\n\n7\n\nM-kun's highest rating is 725, which corresponds to 7-kyu.\n\nThus, 7 is the correct output.\n\nSample Input 2\n\n1600\n\nSample Output 2\n\n2\n\nM-kun's highest rating is 1600, which corresponds to 2-kyu.\n\nThus, 2 is the correct output.", "sample_input": "725\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02600", "source_text": "Score: 100 points\n\nProblem Statement\n\nM-kun is a competitor in AtCoder, whose highest rating is X.\n\nIn this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given:\n\nFrom 400 through 599: 8-kyu\n\nFrom 600 through 799: 7-kyu\n\nFrom 800 through 999: 6-kyu\n\nFrom 1000 through 1199: 5-kyu\n\nFrom 1200 through 1399: 4-kyu\n\nFrom 1400 through 1599: 3-kyu\n\nFrom 1600 through 1799: 2-kyu\n\nFrom 1800 through 1999: 1-kyu\n\nWhat kyu does M-kun have?\n\nConstraints\n\n400 \\leq X \\leq 1999\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the kyu M-kun has, as an integer.\nFor example, if he has 8-kyu, print 8.\n\nSample Input 1\n\n725\n\nSample Output 1\n\n7\n\nM-kun's highest rating is 725, which corresponds to 7-kyu.\n\nThus, 7 is the correct output.\n\nSample Input 2\n\n1600\n\nSample Output 2\n\n2\n\nM-kun's highest rating is 1600, which corresponds to 2-kyu.\n\nThus, 2 is the correct output.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 579, "cpu_time_ms": 546, "memory_kb": 54608}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s505555078", "group_id": "codeNet:p02602", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n\n val n = sc.nextInt\n val k = sc.nextInt\n val a = Array.fill(n)(sc.nextInt)\n for (i <- k until n) {\n println(if (a(i) > a(i-k)) \"Yes\" else \"No\")\n }\n\n}", "language": "Scala", "metadata": {"date": 1595765923, "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/s505555078.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s505555078", "user_id": "u330661451"}, "prompt_components": {"gold_output": "Yes\nNo\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n\n val n = sc.nextInt\n val k = sc.nextInt\n val a = Array.fill(n)(sc.nextInt)\n for (i <- k until n) {\n println(if (a(i) > a(i-k)) \"Yes\" else \"No\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1661, "memory_kb": 60680}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s646782919", "group_id": "codeNet:p02606", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n var l,r,d = sc.nextInt()\n var ans = 0\n for (i <- l to r){\n if (i % d == 0) ans+=1\n }\n println(ans)\n}\n", "language": "Scala", "metadata": {"date": 1594515704, "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/s646782919.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s646782919", "user_id": "u488417454"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n var l,r,d = sc.nextInt()\n var ans = 0\n for (i <- l to r){\n if (i % d == 0) ans+=1\n }\n println(ans)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nHow many multiples of d are there among the integers between L and R (inclusive)?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq L \\leq R \\leq 100\n\n1 \\leq d \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL R d\n\nOutput\n\nPrint the number of multiples of d among the integers between L and R (inclusive).\n\nSample Input 1\n\n5 10 2\n\nSample Output 1\n\n3\n\nAmong the integers between 5 and 10, there are three multiples of 2: 6, 8, and 10.\n\nSample Input 2\n\n6 20 7\n\nSample Output 2\n\n2\n\nAmong the integers between 6 and 20, there are two multiples of 7: 7 and 14.\n\nSample Input 3\n\n1 100 1\n\nSample Output 3\n\n100", "sample_input": "5 10 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02606", "source_text": "Score : 100 points\n\nProblem Statement\n\nHow many multiples of d are there among the integers between L and R (inclusive)?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq L \\leq R \\leq 100\n\n1 \\leq d \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL R d\n\nOutput\n\nPrint the number of multiples of d among the integers between L and R (inclusive).\n\nSample Input 1\n\n5 10 2\n\nSample Output 1\n\n3\n\nAmong the integers between 5 and 10, there are three multiples of 2: 6, 8, and 10.\n\nSample Input 2\n\n6 20 7\n\nSample Output 2\n\n2\n\nAmong the integers between 6 and 20, there are two multiples of 7: 7 and 14.\n\nSample Input 3\n\n1 100 1\n\nSample Output 3\n\n100", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 180, "cpu_time_ms": 561, "memory_kb": 55408}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s363093219", "group_id": "codeNet:p02607", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val count = List.fill(sc.nextInt())(sc.nextInt())\n .zipWithIndex\n .count { case (a, i) => a % 2 == 1 && i % 2 == 0 }\n println(count)\n}\n", "language": "Scala", "metadata": {"date": 1595213254, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02607.html", "problem_id": "p02607", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02607/input.txt", "sample_output_relpath": "derived/input_output/data/p02607/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02607/Scala/s363093219.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s363093219", "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 count = List.fill(sc.nextInt())(sc.nextInt())\n .zipWithIndex\n .count { case (a, i) => a % 2 == 1 && i % 2 == 0 }\n println(count)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have N squares assigned the numbers 1,2,3,\\ldots,N. Each square has an integer written on it, and the integer written on Square i is a_i.\n\nHow many squares i satisfy both of the following conditions?\n\nThe assigned number, i, is odd.\n\nThe written integer is odd.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, a_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\cdots a_N\n\nOutput\n\nPrint the number of squares that satisfy both of the conditions.\n\nSample Input 1\n\n5\n1 3 4 5 7\n\nSample Output 1\n\n2\n\nTwo squares, Square 1 and 5, satisfy both of the conditions.\n\nFor Square 2 and 4, the assigned numbers are not odd.\n\nFor Square 3, the written integer is not odd.\n\nSample Input 2\n\n15\n13 76 46 15 50 98 93 77 31 43 84 90 6 24 14\n\nSample Output 2\n\n3", "sample_input": "5\n1 3 4 5 7\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02607", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have N squares assigned the numbers 1,2,3,\\ldots,N. Each square has an integer written on it, and the integer written on Square i is a_i.\n\nHow many squares i satisfy both of the following conditions?\n\nThe assigned number, i, is odd.\n\nThe written integer is odd.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, a_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\cdots a_N\n\nOutput\n\nPrint the number of squares that satisfy both of the conditions.\n\nSample Input 1\n\n5\n1 3 4 5 7\n\nSample Output 1\n\n2\n\nTwo squares, Square 1 and 5, satisfy both of the conditions.\n\nFor Square 2 and 4, the assigned numbers are not odd.\n\nFor Square 3, the written integer is not odd.\n\nSample Input 2\n\n15\n13 76 46 15 50 98 93 77 31 43 84 90 6 24 14\n\nSample Output 2\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 214, "cpu_time_ms": 503, "memory_kb": 55328}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s255537317", "group_id": "codeNet:p02607", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val numLength = sc.nextInt\n val numSeq = Seq.fill(numLength)(sc.nextInt).zipWithIndex\n val resultSeq = for{\n n <- numSeq\n n1 = if(n._1 % 2 != 0) n._1 else 0\n n2 = if(n._2 % 2 == 0 || n._2 == 0)n._2 else 0\n res = if(n1 > 0 && n2 > 0) 1 else 0\n } yield res\n val result = resultSeq.filter(_ > 0).sum\n println(result)\n}\n", "language": "Scala", "metadata": {"date": 1594577712, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02607.html", "problem_id": "p02607", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02607/input.txt", "sample_output_relpath": "derived/input_output/data/p02607/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02607/Scala/s255537317.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s255537317", "user_id": "u049130451"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val numLength = sc.nextInt\n val numSeq = Seq.fill(numLength)(sc.nextInt).zipWithIndex\n val resultSeq = for{\n n <- numSeq\n n1 = if(n._1 % 2 != 0) n._1 else 0\n n2 = if(n._2 % 2 == 0 || n._2 == 0)n._2 else 0\n res = if(n1 > 0 && n2 > 0) 1 else 0\n } yield res\n val result = resultSeq.filter(_ > 0).sum\n println(result)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have N squares assigned the numbers 1,2,3,\\ldots,N. Each square has an integer written on it, and the integer written on Square i is a_i.\n\nHow many squares i satisfy both of the following conditions?\n\nThe assigned number, i, is odd.\n\nThe written integer is odd.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, a_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\cdots a_N\n\nOutput\n\nPrint the number of squares that satisfy both of the conditions.\n\nSample Input 1\n\n5\n1 3 4 5 7\n\nSample Output 1\n\n2\n\nTwo squares, Square 1 and 5, satisfy both of the conditions.\n\nFor Square 2 and 4, the assigned numbers are not odd.\n\nFor Square 3, the written integer is not odd.\n\nSample Input 2\n\n15\n13 76 46 15 50 98 93 77 31 43 84 90 6 24 14\n\nSample Output 2\n\n3", "sample_input": "5\n1 3 4 5 7\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02607", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have N squares assigned the numbers 1,2,3,\\ldots,N. Each square has an integer written on it, and the integer written on Square i is a_i.\n\nHow many squares i satisfy both of the following conditions?\n\nThe assigned number, i, is odd.\n\nThe written integer is odd.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, a_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\cdots a_N\n\nOutput\n\nPrint the number of squares that satisfy both of the conditions.\n\nSample Input 1\n\n5\n1 3 4 5 7\n\nSample Output 1\n\n2\n\nTwo squares, Square 1 and 5, satisfy both of the conditions.\n\nFor Square 2 and 4, the assigned numbers are not odd.\n\nFor Square 3, the written integer is not odd.\n\nSample Input 2\n\n15\n13 76 46 15 50 98 93 77 31 43 84 90 6 24 14\n\nSample Output 2\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 415, "cpu_time_ms": 520, "memory_kb": 55504}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s827895468", "group_id": "codeNet:p02609", "input_text": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val N = in.nextInt\n val X = BigInt(in.next, 2)\n val Zero = BigInt(0)\n \n def f(n: BigInt, cnt: Int): Int = {\n if (n == Zero) cnt\n else f(n.mod(n.bitCount), cnt + 1)\n }\n\n val bits = X.bitCount\n\n println(((N - 1 to 0 by -1).map {i =>\n (bits + (if (X.testBit(i)) -1 else 1)) match {\n case 0 => 0\n case newBits => f(X.flipBit(i).mod(newBits), 1)\n }\n }).mkString(\"\\n\"))\n}", "language": "Scala", "metadata": {"date": 1595969222, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02609.html", "problem_id": "p02609", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02609/input.txt", "sample_output_relpath": "derived/input_output/data/p02609/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02609/Scala/s827895468.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s827895468", "user_id": "u132324749"}, "prompt_components": {"gold_output": "2\n1\n1\n", "input_to_evaluate": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val N = in.nextInt\n val X = BigInt(in.next, 2)\n val Zero = BigInt(0)\n \n def f(n: BigInt, cnt: Int): Int = {\n if (n == Zero) cnt\n else f(n.mod(n.bitCount), cnt + 1)\n }\n\n val bits = X.bitCount\n\n println(((N - 1 to 0 by -1).map {i =>\n (bits + (if (X.testBit(i)) -1 else 1)) match {\n case 0 => 0\n case newBits => f(X.flipBit(i).mod(newBits), 1)\n }\n }).mkString(\"\\n\"))\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nLet \\mathrm{popcount}(n) be the number of 1s in the binary representation of n.\nFor example, \\mathrm{popcount}(3) = 2, \\mathrm{popcount}(7) = 3, and \\mathrm{popcount}(0) = 0.\n\nLet f(n) be the number of times the following operation will be done when we repeat it until n becomes 0: \"replace n with the remainder when n is divided by \\mathrm{popcount}(n).\" (It can be proved that, under the constraints of this problem, n always becomes 0 after a finite number of operations.)\n\nFor example, when n=7, it becomes 0 after two operations, as follows:\n\n\\mathrm{popcount}(7)=3, so we divide 7 by 3 and replace it with the remainder, 1.\n\n\\mathrm{popcount}(1)=1, so we divide 1 by 1 and replace it with the remainder, 0.\n\nYou are given an integer X with N digits in binary.\nFor each integer i such that 1 \\leq i \\leq N, let X_i be what X becomes when the i-th bit from the top is inverted.\nFind f(X_1), f(X_2), \\ldots, f(X_N).\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nX is an integer with N digits in binary, possibly with leading zeros.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX\n\nOutput\n\nPrint N lines. The i-th line should contain the value f(X_i).\n\nSample Input 1\n\n3\n011\n\nSample Output 1\n\n2\n1\n1\n\nX_1 = 7, which will change as follows: 7 \\rightarrow 1 \\rightarrow 0. Thus, f(7) = 2.\n\nX_2 = 1, which will change as follows: 1 \\rightarrow 0. Thus, f(1) = 1.\n\nX_3 = 2, which will change as follows: 2 \\rightarrow 0. Thus, f(2) = 1.\n\nSample Input 2\n\n23\n00110111001011011001110\n\nSample Output 2\n\n2\n1\n2\n2\n1\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n1\n3", "sample_input": "3\n011\n"}, "reference_outputs": ["2\n1\n1\n"], "source_document_id": "p02609", "source_text": "Score : 400 points\n\nProblem Statement\n\nLet \\mathrm{popcount}(n) be the number of 1s in the binary representation of n.\nFor example, \\mathrm{popcount}(3) = 2, \\mathrm{popcount}(7) = 3, and \\mathrm{popcount}(0) = 0.\n\nLet f(n) be the number of times the following operation will be done when we repeat it until n becomes 0: \"replace n with the remainder when n is divided by \\mathrm{popcount}(n).\" (It can be proved that, under the constraints of this problem, n always becomes 0 after a finite number of operations.)\n\nFor example, when n=7, it becomes 0 after two operations, as follows:\n\n\\mathrm{popcount}(7)=3, so we divide 7 by 3 and replace it with the remainder, 1.\n\n\\mathrm{popcount}(1)=1, so we divide 1 by 1 and replace it with the remainder, 0.\n\nYou are given an integer X with N digits in binary.\nFor each integer i such that 1 \\leq i \\leq N, let X_i be what X becomes when the i-th bit from the top is inverted.\nFind f(X_1), f(X_2), \\ldots, f(X_N).\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nX is an integer with N digits in binary, possibly with leading zeros.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX\n\nOutput\n\nPrint N lines. The i-th line should contain the value f(X_i).\n\nSample Input 1\n\n3\n011\n\nSample Output 1\n\n2\n1\n1\n\nX_1 = 7, which will change as follows: 7 \\rightarrow 1 \\rightarrow 0. Thus, f(7) = 2.\n\nX_2 = 1, which will change as follows: 1 \\rightarrow 0. Thus, f(1) = 1.\n\nX_3 = 2, which will change as follows: 2 \\rightarrow 0. Thus, f(2) = 1.\n\nSample Input 2\n\n23\n00110111001011011001110\n\nSample Output 2\n\n2\n1\n2\n2\n1\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n1\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 467, "cpu_time_ms": 2205, "memory_kb": 57912}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s863373902", "group_id": "codeNet:p02613", "input_text": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val N = in.nextInt\n val Ss = List.fill(N)(in.next)\n def formatCount(judge: String): String = s\"$judge x ${Ss.count(_ == judge)}\"\n println(List(\"AC\", \"WA\", \"TLE\", \"RE\").map(formatCount).mkString(\"\\n\"))\n}", "language": "Scala", "metadata": {"date": 1594136087, "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/s863373902.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s863373902", "user_id": "u132324749"}, "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 in = new java.util.Scanner(System.in)\n val N = in.nextInt\n val Ss = List.fill(N)(in.next)\n def formatCount(judge: String): String = s\"$judge x ${Ss.count(_ == judge)}\"\n println(List(\"AC\", \"WA\", \"TLE\", \"RE\").map(formatCount).mkString(\"\\n\"))\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.\n\nThe problem has N test cases.\n\nFor each test case i (1\\leq i \\leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSee the Output section for the output format.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nS_i is AC, WA, TLE, or RE.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n\\vdots\nS_N\n\nOutput\n\nLet C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively. Print the following:\n\nAC x C_0\nWA x C_1\nTLE x C_2\nRE x C_3\n\nSample Input 1\n\n6\nAC\nTLE\nAC\nAC\nWA\nTLE\n\nSample Output 1\n\nAC x 3\nWA x 1\nTLE x 2\nRE x 0\n\nWe have 3, 1, 2, and 0 test case(s) for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSample Input 2\n\n10\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\n\nSample Output 2\n\nAC x 10\nWA x 0\nTLE x 0\nRE x 0", "sample_input": "6\nAC\nTLE\nAC\nAC\nWA\nTLE\n"}, "reference_outputs": ["AC x 3\nWA x 1\nTLE x 2\nRE x 0\n"], "source_document_id": "p02613", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.\n\nThe problem has N test cases.\n\nFor each test case i (1\\leq i \\leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSee the Output section for the output format.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nS_i is AC, WA, TLE, or RE.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n\\vdots\nS_N\n\nOutput\n\nLet C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively. Print the following:\n\nAC x C_0\nWA x C_1\nTLE x C_2\nRE x C_3\n\nSample Input 1\n\n6\nAC\nTLE\nAC\nAC\nWA\nTLE\n\nSample Output 1\n\nAC x 3\nWA x 1\nTLE x 2\nRE x 0\n\nWe have 3, 1, 2, and 0 test case(s) for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSample Input 2\n\n10\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\n\nSample Output 2\n\nAC x 10\nWA x 0\nTLE x 0\nRE x 0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 277, "cpu_time_ms": 813, "memory_kb": 65056}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s227060999", "group_id": "codeNet:p02614", "input_text": "import java.util.Scanner\n\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val h = sc.nextInt()\n val w = sc.nextInt()\n val k = sc.nextInt()\n\n val sq = Array.fill(h)(sc.next().split(\"\").filter(_ != \"\").map(_ == \"#\")).flatten\n\n val wps = powerSet((0 until w).toList)\n val hps = powerSet((0 until h).toList)\n\n var ans = 0\n\n wps.foreach { wl =>\n val wp = wl.flatMap(wi => (0 until h).map(i => w * i + wi))\n hps.foreach { hl =>\n val hp = hl.flatMap(hi => (0 until w).map(i => i + hi * w))\n val po = (wp ++ hp).toSet\n\n var cnt = 0\n (0 until h * w).foreach(i => if (sq(i) && !po.contains(i)) cnt += 1)\n\n if (cnt == k) ans += 1\n }\n }\n\n println(ans)\n }\n\n\n def powerSet[A](xs: List[A]): List[List[A]] =\n xs.foldLeft(List(Nil: List[A]))((accum, elem) => accum.flatMap(l => Seq(l, elem :: l)))\n\n}\n", "language": "Scala", "metadata": {"date": 1594002779, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02614.html", "problem_id": "p02614", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02614/input.txt", "sample_output_relpath": "derived/input_output/data/p02614/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02614/Scala/s227060999.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s227060999", "user_id": "u197909036"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val h = sc.nextInt()\n val w = sc.nextInt()\n val k = sc.nextInt()\n\n val sq = Array.fill(h)(sc.next().split(\"\").filter(_ != \"\").map(_ == \"#\")).flatten\n\n val wps = powerSet((0 until w).toList)\n val hps = powerSet((0 until h).toList)\n\n var ans = 0\n\n wps.foreach { wl =>\n val wp = wl.flatMap(wi => (0 until h).map(i => w * i + wi))\n hps.foreach { hl =>\n val hp = hl.flatMap(hi => (0 until w).map(i => i + hi * w))\n val po = (wp ++ hp).toSet\n\n var cnt = 0\n (0 until h * w).foreach(i => if (sq(i) && !po.contains(i)) cnt += 1)\n\n if (cnt == k) ans += 1\n }\n }\n\n println(ans)\n }\n\n\n def powerSet[A](xs: List[A]): List[List[A]] =\n xs.foldLeft(List(Nil: List[A]))((accum, elem) => accum.flatMap(l => Seq(l, elem :: l)))\n\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \\leq i \\leq H, 1 \\leq j \\leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is ., and black if c_{i,j} is #.\n\nConsider doing the following operation:\n\nChoose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns.\n\nYou are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.\n\nConstraints\n\n1 \\leq H, W \\leq 6\n\n1 \\leq K \\leq HW\n\nc_{i,j} is . or #.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\nc_{1,1}c_{1,2}...c_{1,W}\nc_{2,1}c_{2,2}...c_{2,W}\n:\nc_{H,1}c_{H,2}...c_{H,W}\n\nOutput\n\nPrint an integer representing the number of choices of rows and columns satisfying the condition.\n\nSample Input 1\n\n2 3 2\n..#\n###\n\nSample Output 1\n\n5\n\nFive choices below satisfy the condition.\n\nThe 1-st row and 1-st column\n\nThe 1-st row and 2-nd column\n\nThe 1-st row and 3-rd column\n\nThe 1-st and 2-nd column\n\nThe 3-rd column\n\nSample Input 2\n\n2 3 4\n..#\n###\n\nSample Output 2\n\n1\n\nOne choice, which is choosing nothing, satisfies the condition.\n\nSample Input 3\n\n2 2 3\n##\n##\n\nSample Output 3\n\n0\n\nSample Input 4\n\n6 6 8\n..##..\n.#..#.\n#....#\n######\n#....#\n#....#\n\nSample Output 4\n\n208", "sample_input": "2 3 2\n..#\n###\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02614", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \\leq i \\leq H, 1 \\leq j \\leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is ., and black if c_{i,j} is #.\n\nConsider doing the following operation:\n\nChoose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns.\n\nYou are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.\n\nConstraints\n\n1 \\leq H, W \\leq 6\n\n1 \\leq K \\leq HW\n\nc_{i,j} is . or #.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\nc_{1,1}c_{1,2}...c_{1,W}\nc_{2,1}c_{2,2}...c_{2,W}\n:\nc_{H,1}c_{H,2}...c_{H,W}\n\nOutput\n\nPrint an integer representing the number of choices of rows and columns satisfying the condition.\n\nSample Input 1\n\n2 3 2\n..#\n###\n\nSample Output 1\n\n5\n\nFive choices below satisfy the condition.\n\nThe 1-st row and 1-st column\n\nThe 1-st row and 2-nd column\n\nThe 1-st row and 3-rd column\n\nThe 1-st and 2-nd column\n\nThe 3-rd column\n\nSample Input 2\n\n2 3 4\n..#\n###\n\nSample Output 2\n\n1\n\nOne choice, which is choosing nothing, satisfies the condition.\n\nSample Input 3\n\n2 2 3\n##\n##\n\nSample Output 3\n\n0\n\nSample Input 4\n\n6 6 8\n..##..\n.#..#.\n#....#\n######\n#....#\n#....#\n\nSample Output 4\n\n208", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 714, "memory_kb": 60928}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s746245802", "group_id": "codeNet:p02615", "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).sorted.reverse\n\n println(As.head + {\n val l = As.tail.take((N - 1) / 2)\n if (N % 2 == 0) l.sum * 2\n else l.sum * 2 - l.last\n })\n}", "language": "Scala", "metadata": {"date": 1594134121, "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/s746245802.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s746245802", "user_id": "u132324749"}, "prompt_components": {"gold_output": "7\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).sorted.reverse\n\n println(As.head + {\n val l = As.tail.take((N - 1) / 2)\n if (N % 2 == 0) l.sum * 2\n else l.sum * 2 - l.last\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1232, "memory_kb": 79640}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s764170953", "group_id": "codeNet:p02621", "input_text": "import scala.math.pow\n\nobject Main extends App {\n val sc = new java.util.Scanner(System.in)\n var n = sc.nextInt()\n println(n+pow(n,2).toInt+pow(n,3).toInt)\n}\n", "language": "Scala", "metadata": {"date": 1593306146, "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/s764170953.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s764170953", "user_id": "u488417454"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "import scala.math.pow\n\nobject Main extends App {\n val sc = new java.util.Scanner(System.in)\n var n = sc.nextInt()\n println(n+pow(n,2).toInt+pow(n,3).toInt)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 512, "memory_kb": 55304}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s846561793", "group_id": "codeNet:p02627", "input_text": "object Main extends App {\n\tval pw = new java.io.PrintWriter(System.out)\n\n\tpw.println(if ((Scanner.next())(0).isUpper) \"A\" else \"a\")\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": 1592787821, "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/s846561793.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s846561793", "user_id": "u822029894"}, "prompt_components": {"gold_output": "A\n", "input_to_evaluate": "object Main extends App {\n\tval pw = new java.io.PrintWriter(System.out)\n\n\tpw.println(if ((Scanner.next())(0).isUpper) \"A\" else \"a\")\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 : 100 points\n\nProblem Statement\n\nAn uppercase or lowercase English letter \\alpha will be given as input.\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nConstraints\n\n\\alpha is an uppercase (A - Z) or lowercase (a - z) English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nα\n\nOutput\n\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nSample Input 1\n\nB\n\nSample Output 1\n\nA\n\nB is uppercase, so we should print A.\n\nSample Input 2\n\na\n\nSample Output 2\n\na\n\na is lowercase, so we should print a.", "sample_input": "B\n"}, "reference_outputs": ["A\n"], "source_document_id": "p02627", "source_text": "Score : 100 points\n\nProblem Statement\n\nAn uppercase or lowercase English letter \\alpha will be given as input.\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nConstraints\n\n\\alpha is an uppercase (A - Z) or lowercase (a - z) English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nα\n\nOutput\n\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nSample Input 1\n\nB\n\nSample Output 1\n\nA\n\nB is uppercase, so we should print A.\n\nSample Input 2\n\na\n\nSample Output 2\n\na\n\na is lowercase, so we should print a.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1313, "cpu_time_ms": 516, "memory_kb": 54660}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s407389846", "group_id": "codeNet:p02628", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val N, K = sc.nextInt\n val p = Array.fill(N)(sc.nextInt)\n\n val z = p.combinations(K).map(_.sum).min\n println(z)\n}\n", "language": "Scala", "metadata": {"date": 1592787783, "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/s407389846.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s407389846", "user_id": "u786167609"}, "prompt_components": {"gold_output": "210\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val N, K = sc.nextInt\n val p = Array.fill(N)(sc.nextInt)\n\n val z = p.combinations(K).map(_.sum).min\n println(z)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA shop sells N kinds of fruits, Fruit 1, \\ldots, N, at prices of p_1, \\ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)\n\nHere, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 1000\n\n1 \\leq p_i \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\np_1 p_2 \\ldots p_N\n\nOutput\n\nPrint an integer representing the minimum possible total price of fruits.\n\nSample Input 1\n\n5 3\n50 100 80 120 80\n\nSample Output 1\n\n210\n\nThis shop sells Fruit 1, 2, 3, 4, and 5 for 50 yen, 100 yen, 80 yen, 120 yen, and 80 yen, respectively.\n\nThe minimum total price for three kinds of fruits is 50 + 80 + 80 = 210 yen when choosing Fruit 1, 3, and 5.\n\nSample Input 2\n\n1 1\n1000\n\nSample Output 2\n\n1000", "sample_input": "5 3\n50 100 80 120 80\n"}, "reference_outputs": ["210\n"], "source_document_id": "p02628", "source_text": "Score : 200 points\n\nProblem Statement\n\nA shop sells N kinds of fruits, Fruit 1, \\ldots, N, at prices of p_1, \\ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)\n\nHere, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 1000\n\n1 \\leq p_i \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\np_1 p_2 \\ldots p_N\n\nOutput\n\nPrint an integer representing the minimum possible total price of fruits.\n\nSample Input 1\n\n5 3\n50 100 80 120 80\n\nSample Output 1\n\n210\n\nThis shop sells Fruit 1, 2, 3, 4, and 5 for 50 yen, 100 yen, 80 yen, 120 yen, and 80 yen, respectively.\n\nThe minimum total price for three kinds of fruits is 50 + 80 + 80 = 210 yen when choosing Fruit 1, 3, and 5.\n\nSample Input 2\n\n1 1\n1000\n\nSample Output 2\n\n1000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 205, "cpu_time_ms": 2205, "memory_kb": 57764}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s736562064", "group_id": "codeNet:p02629", "input_text": "import java.security.KeyStore.TrustedCertificateEntry\nimport java.util\nimport java.util.regex.Pattern\nimport java.util.{ArrayList, Collections, Comparator, List => JList}\n\nimport scala.collection.immutable.TreeMap\nimport scala.math._\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 Array(n, q) = input.split(LINE_SEPARATOR).head.split(\" \").map(_.toInt)\n// val a = input.split(LINE_SEPARATOR).tail.take(n).map(_.split(\" \").head.toInt)\n// val b = input.split(LINE_SEPARATOR).tail.take(n).map(_.split(\" \").tail.head.toInt)\n// val c = input.split(LINE_SEPARATOR).drop(n + 1).map(_.split(\" \").head.toInt)\n// val d = input.split(LINE_SEPARATOR).drop(n + 1).map(_.split(\" \").tail.head.toInt)\n// val k = 2 * pow(10, 5).toInt\n// val INF = pow(10, 9).toInt + 1\n// val pqMap = (0 until k).map(_ => new mutable.TreeMap[Int, Int]).toArray\n// def add(k: Int, ai: Int): Unit = {\n// val count = pqMap(k).getOrElse(ai, 0)\n// pqMap(k) += ai -> (count + 1)\n// }\n// def delete(k: Int, ai: Int): Unit = {\n// val count = pqMap(k).getOrElse(ai, 0)\n// if (count == 1) pqMap(k) -= ai else pqMap(k) += ai -> (count - 1)\n// }\n// val i2k = (0 until n).map{i =>\n// b(i)\n// }.toArray\n// (0 until n).foreach{i =>\n// add(b(i) - 1, a(i))\n// }\n// val maxList = pqMap.map(pq => if (pq.nonEmpty) pq.last._1 else INF)\n//\n// (0 until q).map{j =>\n// add(d(j) - 1, a(c(j) - 1))\n// delete(i2k(c(j) - 1) - 1, a(c(j) - 1))\n// maxList(i2k(c(j) - 1) - 1) =\n// if (pqMap(i2k(c(j) - 1) - 1).nonEmpty) pqMap(i2k(c(j) - 1) - 1).last._1 else INF\n// i2k(c(j) - 1) = d(j)\n// maxList(d(j) - 1) = if (pqMap(d(j) - 1).nonEmpty) pqMap(d(j) - 1).last._1 else INF\n// maxList.min\n// }.mkString(LINE_SEPARATOR)\n// }\n\n def solve(input: String): String = {\n val n = input.toLong\n divideDigits(n, 26L).map(_.toInt).map(i => (i + 96).toChar).mkString\n }\n\n def divideDigits(num: Long, base: Long = 10L): List[Long] = {\n def proc(num: Long, base: Long, flg: Boolean): List[Long] = {\n var flag = flg\n val quotient = num / base\n val remainder = if (num % base == 0) {\n flag = true\n base\n } else if (flag) {\n flag = false\n val temp = num % base - 1\n if (temp == 0) {\n flag = true\n base\n } else temp\n } else {\n flag = flg\n num % base\n }\n quotient match {\n case 0 =>\n if (flag) {\n List.empty\n } else List(remainder)\n case _ => remainder :: proc(quotient, base, flag)\n }\n }\n\n proc(num, base, false).reverse//.filterNot(_ == 0)\n }\n\n\n def medianCalculator(seq: Seq[Long]): Long = {\n //In order if you are not sure that 'seq' is sorted\n val sortedSeq = seq.sortWith(_ < _)\n\n if (seq.size % 2 == 1) sortedSeq(sortedSeq.size / 2)\n else {\n val (up, down) = sortedSeq.splitAt(seq.size / 2)\n (up.last + down.head) / 2\n }\n }\n\n def factorize(x: Long): List[Long] = {\n def foo(x: Long, a: Long = 2, list: List[Long] = Nil): List[Long] = a*a > x match {\n case false if x % a == 0 => foo(x / a, a , a :: list)\n case false => foo(x , a + 1, list)\n case true => x :: list\n }\n foo(x)\n }\n\n def divisors(n: Int): Vector[Int] = {\n val halfList = (1 to sqrt(n).toInt).toVector.filter(n % _ == 0).map(_.toInt)\n val reversedList = if (sqrt(n).floor == sqrt(n)) halfList.reverse.tail.map(n/_) else halfList.reverse.map(n/_)\n halfList ++ reversedList\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 \"\"\"2\"\"\".stripMargin -> \"\"\"b\n |\n |\n |\n |\"\"\".stripMargin\n ,\n \"\"\"27\"\"\".stripMargin -> \"\"\"aa\n |\"\"\".stripMargin,\n \"\"\"123456789\"\"\" -> \"\"\"jjddja\"\"\",\n \"\"\"1000000000000001\"\"\" -> \"test\",\n \"\"\"702\"\"\" -> \"\"\"zz\"\"\",\n \"\"\"26\"\"\" -> \"z\",\n \"\"\"677\"\"\" -> \"\"\"za\"\"\",\n \"\"\"1353\"\"\" -> \"\"\"aza\"\"\"\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\n\n\n}\n", "language": "Scala", "metadata": {"date": 1592793249, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02629.html", "problem_id": "p02629", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02629/input.txt", "sample_output_relpath": "derived/input_output/data/p02629/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02629/Scala/s736562064.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s736562064", "user_id": "u114537090"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "import java.security.KeyStore.TrustedCertificateEntry\nimport java.util\nimport java.util.regex.Pattern\nimport java.util.{ArrayList, Collections, Comparator, List => JList}\n\nimport scala.collection.immutable.TreeMap\nimport scala.math._\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 Array(n, q) = input.split(LINE_SEPARATOR).head.split(\" \").map(_.toInt)\n// val a = input.split(LINE_SEPARATOR).tail.take(n).map(_.split(\" \").head.toInt)\n// val b = input.split(LINE_SEPARATOR).tail.take(n).map(_.split(\" \").tail.head.toInt)\n// val c = input.split(LINE_SEPARATOR).drop(n + 1).map(_.split(\" \").head.toInt)\n// val d = input.split(LINE_SEPARATOR).drop(n + 1).map(_.split(\" \").tail.head.toInt)\n// val k = 2 * pow(10, 5).toInt\n// val INF = pow(10, 9).toInt + 1\n// val pqMap = (0 until k).map(_ => new mutable.TreeMap[Int, Int]).toArray\n// def add(k: Int, ai: Int): Unit = {\n// val count = pqMap(k).getOrElse(ai, 0)\n// pqMap(k) += ai -> (count + 1)\n// }\n// def delete(k: Int, ai: Int): Unit = {\n// val count = pqMap(k).getOrElse(ai, 0)\n// if (count == 1) pqMap(k) -= ai else pqMap(k) += ai -> (count - 1)\n// }\n// val i2k = (0 until n).map{i =>\n// b(i)\n// }.toArray\n// (0 until n).foreach{i =>\n// add(b(i) - 1, a(i))\n// }\n// val maxList = pqMap.map(pq => if (pq.nonEmpty) pq.last._1 else INF)\n//\n// (0 until q).map{j =>\n// add(d(j) - 1, a(c(j) - 1))\n// delete(i2k(c(j) - 1) - 1, a(c(j) - 1))\n// maxList(i2k(c(j) - 1) - 1) =\n// if (pqMap(i2k(c(j) - 1) - 1).nonEmpty) pqMap(i2k(c(j) - 1) - 1).last._1 else INF\n// i2k(c(j) - 1) = d(j)\n// maxList(d(j) - 1) = if (pqMap(d(j) - 1).nonEmpty) pqMap(d(j) - 1).last._1 else INF\n// maxList.min\n// }.mkString(LINE_SEPARATOR)\n// }\n\n def solve(input: String): String = {\n val n = input.toLong\n divideDigits(n, 26L).map(_.toInt).map(i => (i + 96).toChar).mkString\n }\n\n def divideDigits(num: Long, base: Long = 10L): List[Long] = {\n def proc(num: Long, base: Long, flg: Boolean): List[Long] = {\n var flag = flg\n val quotient = num / base\n val remainder = if (num % base == 0) {\n flag = true\n base\n } else if (flag) {\n flag = false\n val temp = num % base - 1\n if (temp == 0) {\n flag = true\n base\n } else temp\n } else {\n flag = flg\n num % base\n }\n quotient match {\n case 0 =>\n if (flag) {\n List.empty\n } else List(remainder)\n case _ => remainder :: proc(quotient, base, flag)\n }\n }\n\n proc(num, base, false).reverse//.filterNot(_ == 0)\n }\n\n\n def medianCalculator(seq: Seq[Long]): Long = {\n //In order if you are not sure that 'seq' is sorted\n val sortedSeq = seq.sortWith(_ < _)\n\n if (seq.size % 2 == 1) sortedSeq(sortedSeq.size / 2)\n else {\n val (up, down) = sortedSeq.splitAt(seq.size / 2)\n (up.last + down.head) / 2\n }\n }\n\n def factorize(x: Long): List[Long] = {\n def foo(x: Long, a: Long = 2, list: List[Long] = Nil): List[Long] = a*a > x match {\n case false if x % a == 0 => foo(x / a, a , a :: list)\n case false => foo(x , a + 1, list)\n case true => x :: list\n }\n foo(x)\n }\n\n def divisors(n: Int): Vector[Int] = {\n val halfList = (1 to sqrt(n).toInt).toVector.filter(n % _ == 0).map(_.toInt)\n val reversedList = if (sqrt(n).floor == sqrt(n)) halfList.reverse.tail.map(n/_) else halfList.reverse.map(n/_)\n halfList ++ reversedList\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 \"\"\"2\"\"\".stripMargin -> \"\"\"b\n |\n |\n |\n |\"\"\".stripMargin\n ,\n \"\"\"27\"\"\".stripMargin -> \"\"\"aa\n |\"\"\".stripMargin,\n \"\"\"123456789\"\"\" -> \"\"\"jjddja\"\"\",\n \"\"\"1000000000000001\"\"\" -> \"test\",\n \"\"\"702\"\"\" -> \"\"\"zz\"\"\",\n \"\"\"26\"\"\" -> \"z\",\n \"\"\"677\"\"\" -> \"\"\"za\"\"\",\n \"\"\"1353\"\"\" -> \"\"\"aza\"\"\"\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\n\n\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\n1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001, but he gave them new names, as follows:\n\nthe dogs numbered 1,2,\\cdots,26 were respectively given the names a, b, ..., z;\n\nthe dogs numbered 27,28,29,\\cdots,701,702 were respectively given the names aa, ab, ac, ..., zy, zz;\n\nthe dogs numbered 703,704,705,\\cdots,18277,18278 were respectively given the names aaa, aab, aac, ..., zzy, zzz;\n\nthe dogs numbered 18279,18280,18281,\\cdots,475253,475254 were respectively given the names aaaa, aaab, aaac, ..., zzzy, zzzz;\n\nthe dogs numbered 475255,475256,\\cdots were respectively given the names aaaaa, aaaab, ...;\n\nand so on.\n\nTo sum it up, the dogs numbered 1, 2, \\cdots were respectively given the following names:\n\na, b, ..., z, aa, ab, ..., az, ba, bb, ..., bz, ..., za, zb, ..., zz, aaa, aab, ..., aaz, aba, abb, ..., abz, ..., zzz, aaaa, ...\n\nNow, Roger asks you:\n\n\"What is the name for the dog numbered N?\"\n\nConstraints\n\nN is an integer.\n\n1 \\leq N \\leq 1000000000000001\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer to Roger's question as a string consisting of lowercase English letters.\n\nSample Input 1\n\n2\n\nSample Output 1\n\nb\n\nSample Input 2\n\n27\n\nSample Output 2\n\naa\n\nSample Input 3\n\n123456789\n\nSample Output 3\n\njjddja", "sample_input": "2\n"}, "reference_outputs": ["b\n"], "source_document_id": "p02629", "source_text": "Score : 300 points\n\nProblem Statement\n\n1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001, but he gave them new names, as follows:\n\nthe dogs numbered 1,2,\\cdots,26 were respectively given the names a, b, ..., z;\n\nthe dogs numbered 27,28,29,\\cdots,701,702 were respectively given the names aa, ab, ac, ..., zy, zz;\n\nthe dogs numbered 703,704,705,\\cdots,18277,18278 were respectively given the names aaa, aab, aac, ..., zzy, zzz;\n\nthe dogs numbered 18279,18280,18281,\\cdots,475253,475254 were respectively given the names aaaa, aaab, aaac, ..., zzzy, zzzz;\n\nthe dogs numbered 475255,475256,\\cdots were respectively given the names aaaaa, aaaab, ...;\n\nand so on.\n\nTo sum it up, the dogs numbered 1, 2, \\cdots were respectively given the following names:\n\na, b, ..., z, aa, ab, ..., az, ba, bb, ..., bz, ..., za, zb, ..., zz, aaa, aab, ..., aaz, aba, abb, ..., abz, ..., zzz, aaaa, ...\n\nNow, Roger asks you:\n\n\"What is the name for the dog numbered N?\"\n\nConstraints\n\nN is an integer.\n\n1 \\leq N \\leq 1000000000000001\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer to Roger's question as a string consisting of lowercase English letters.\n\nSample Input 1\n\n2\n\nSample Output 1\n\nb\n\nSample Input 2\n\n27\n\nSample Output 2\n\naa\n\nSample Input 3\n\n123456789\n\nSample Output 3\n\njjddja", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5350, "cpu_time_ms": 534, "memory_kb": 55376}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s025807778", "group_id": "codeNet:p02629", "input_text": "object Main extends App {\n val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList\n val n = inputs.head.toInt\n\n println(solve(n))\n\n def solve(n: Int): String = {\n var dog = n\n val str = \"-abcdefghijklmnopqrstuvwxyz\"\n val base = 26\n var name = \"\"\n\n while(dog != 0) {\n val p = dog % base\n dog = dog / base\n name = name + str(p.toInt)\n }\n name.reverse\n }\n}", "language": "Scala", "metadata": {"date": 1592788949, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02629.html", "problem_id": "p02629", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02629/input.txt", "sample_output_relpath": "derived/input_output/data/p02629/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02629/Scala/s025807778.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s025807778", "user_id": "u631102131"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "object Main extends App {\n val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList\n val n = inputs.head.toInt\n\n println(solve(n))\n\n def solve(n: Int): String = {\n var dog = n\n val str = \"-abcdefghijklmnopqrstuvwxyz\"\n val base = 26\n var name = \"\"\n\n while(dog != 0) {\n val p = dog % base\n dog = dog / base\n name = name + str(p.toInt)\n }\n name.reverse\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\n1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001, but he gave them new names, as follows:\n\nthe dogs numbered 1,2,\\cdots,26 were respectively given the names a, b, ..., z;\n\nthe dogs numbered 27,28,29,\\cdots,701,702 were respectively given the names aa, ab, ac, ..., zy, zz;\n\nthe dogs numbered 703,704,705,\\cdots,18277,18278 were respectively given the names aaa, aab, aac, ..., zzy, zzz;\n\nthe dogs numbered 18279,18280,18281,\\cdots,475253,475254 were respectively given the names aaaa, aaab, aaac, ..., zzzy, zzzz;\n\nthe dogs numbered 475255,475256,\\cdots were respectively given the names aaaaa, aaaab, ...;\n\nand so on.\n\nTo sum it up, the dogs numbered 1, 2, \\cdots were respectively given the following names:\n\na, b, ..., z, aa, ab, ..., az, ba, bb, ..., bz, ..., za, zb, ..., zz, aaa, aab, ..., aaz, aba, abb, ..., abz, ..., zzz, aaaa, ...\n\nNow, Roger asks you:\n\n\"What is the name for the dog numbered N?\"\n\nConstraints\n\nN is an integer.\n\n1 \\leq N \\leq 1000000000000001\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer to Roger's question as a string consisting of lowercase English letters.\n\nSample Input 1\n\n2\n\nSample Output 1\n\nb\n\nSample Input 2\n\n27\n\nSample Output 2\n\naa\n\nSample Input 3\n\n123456789\n\nSample Output 3\n\njjddja", "sample_input": "2\n"}, "reference_outputs": ["b\n"], "source_document_id": "p02629", "source_text": "Score : 300 points\n\nProblem Statement\n\n1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001, but he gave them new names, as follows:\n\nthe dogs numbered 1,2,\\cdots,26 were respectively given the names a, b, ..., z;\n\nthe dogs numbered 27,28,29,\\cdots,701,702 were respectively given the names aa, ab, ac, ..., zy, zz;\n\nthe dogs numbered 703,704,705,\\cdots,18277,18278 were respectively given the names aaa, aab, aac, ..., zzy, zzz;\n\nthe dogs numbered 18279,18280,18281,\\cdots,475253,475254 were respectively given the names aaaa, aaab, aaac, ..., zzzy, zzzz;\n\nthe dogs numbered 475255,475256,\\cdots were respectively given the names aaaaa, aaaab, ...;\n\nand so on.\n\nTo sum it up, the dogs numbered 1, 2, \\cdots were respectively given the following names:\n\na, b, ..., z, aa, ab, ..., az, ba, bb, ..., bz, ..., za, zb, ..., zz, aaa, aab, ..., aaz, aba, abb, ..., abz, ..., zzz, aaaa, ...\n\nNow, Roger asks you:\n\n\"What is the name for the dog numbered N?\"\n\nConstraints\n\nN is an integer.\n\n1 \\leq N \\leq 1000000000000001\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer to Roger's question as a string consisting of lowercase English letters.\n\nSample Input 1\n\n2\n\nSample Output 1\n\nb\n\nSample Input 2\n\n27\n\nSample Output 2\n\naa\n\nSample Input 3\n\n123456789\n\nSample Output 3\n\njjddja", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 405, "cpu_time_ms": 524, "memory_kb": 54924}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s790934119", "group_id": "codeNet:p02629", "input_text": "import java.security.KeyStore.TrustedCertificateEntry\nimport java.util\nimport java.util.regex.Pattern\nimport java.util.{ArrayList, Collections, Comparator, List => JList}\n\nimport scala.collection.immutable.TreeMap\nimport scala.math._\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 Array(n, q) = input.split(LINE_SEPARATOR).head.split(\" \").map(_.toInt)\n// val a = input.split(LINE_SEPARATOR).tail.take(n).map(_.split(\" \").head.toInt)\n// val b = input.split(LINE_SEPARATOR).tail.take(n).map(_.split(\" \").tail.head.toInt)\n// val c = input.split(LINE_SEPARATOR).drop(n + 1).map(_.split(\" \").head.toInt)\n// val d = input.split(LINE_SEPARATOR).drop(n + 1).map(_.split(\" \").tail.head.toInt)\n// val k = 2 * pow(10, 5).toInt\n// val INF = pow(10, 9).toInt + 1\n// val pqMap = (0 until k).map(_ => new mutable.TreeMap[Int, Int]).toArray\n// def add(k: Int, ai: Int): Unit = {\n// val count = pqMap(k).getOrElse(ai, 0)\n// pqMap(k) += ai -> (count + 1)\n// }\n// def delete(k: Int, ai: Int): Unit = {\n// val count = pqMap(k).getOrElse(ai, 0)\n// if (count == 1) pqMap(k) -= ai else pqMap(k) += ai -> (count - 1)\n// }\n// val i2k = (0 until n).map{i =>\n// b(i)\n// }.toArray\n// (0 until n).foreach{i =>\n// add(b(i) - 1, a(i))\n// }\n// val maxList = pqMap.map(pq => if (pq.nonEmpty) pq.last._1 else INF)\n//\n// (0 until q).map{j =>\n// add(d(j) - 1, a(c(j) - 1))\n// delete(i2k(c(j) - 1) - 1, a(c(j) - 1))\n// maxList(i2k(c(j) - 1) - 1) =\n// if (pqMap(i2k(c(j) - 1) - 1).nonEmpty) pqMap(i2k(c(j) - 1) - 1).last._1 else INF\n// i2k(c(j) - 1) = d(j)\n// maxList(d(j) - 1) = if (pqMap(d(j) - 1).nonEmpty) pqMap(d(j) - 1).last._1 else INF\n// maxList.min\n// }.mkString(LINE_SEPARATOR)\n// }\n\n def solve(input: String): String = {\n val n = input.toLong\n divideDigits(n, 26).map(i => (i.toInt + 96).toChar).mkString\n }\n\n def divideDigits(num: Long, base: Long = 10): List[Long] = {\n def proc(num: Long, base: Long): List[Long] = {\n val quotient = num / base\n val remainder = num % base\n quotient match {\n case 0 => return List(remainder)\n case _ => remainder :: proc(quotient, base)\n }\n }\n\n proc(num, base).reverse\n }\n\n\n def medianCalculator(seq: Seq[Long]): Long = {\n //In order if you are not sure that 'seq' is sorted\n val sortedSeq = seq.sortWith(_ < _)\n\n if (seq.size % 2 == 1) sortedSeq(sortedSeq.size / 2)\n else {\n val (up, down) = sortedSeq.splitAt(seq.size / 2)\n (up.last + down.head) / 2\n }\n }\n\n def factorize(x: Long): List[Long] = {\n def foo(x: Long, a: Long = 2, list: List[Long] = Nil): List[Long] = a*a > x match {\n case false if x % a == 0 => foo(x / a, a , a :: list)\n case false => foo(x , a + 1, list)\n case true => x :: list\n }\n foo(x)\n }\n\n def divisors(n: Int): Vector[Int] = {\n val halfList = (1 to sqrt(n).toInt).toVector.filter(n % _ == 0).map(_.toInt)\n val reversedList = if (sqrt(n).floor == sqrt(n)) halfList.reverse.tail.map(n/_) else halfList.reverse.map(n/_)\n halfList ++ reversedList\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 \"\"\"2\"\"\".stripMargin -> \"\"\"b\n |\n |\n |\n |\"\"\".stripMargin\n ,\n \"\"\"27\"\"\".stripMargin -> \"\"\"aa\n |\"\"\".stripMargin,\n \"\"\"123456789\"\"\" -> \"\"\"jjddja\"\"\"\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\n\n\n}\n", "language": "Scala", "metadata": {"date": 1592788926, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02629.html", "problem_id": "p02629", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02629/input.txt", "sample_output_relpath": "derived/input_output/data/p02629/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02629/Scala/s790934119.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s790934119", "user_id": "u114537090"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "import java.security.KeyStore.TrustedCertificateEntry\nimport java.util\nimport java.util.regex.Pattern\nimport java.util.{ArrayList, Collections, Comparator, List => JList}\n\nimport scala.collection.immutable.TreeMap\nimport scala.math._\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 Array(n, q) = input.split(LINE_SEPARATOR).head.split(\" \").map(_.toInt)\n// val a = input.split(LINE_SEPARATOR).tail.take(n).map(_.split(\" \").head.toInt)\n// val b = input.split(LINE_SEPARATOR).tail.take(n).map(_.split(\" \").tail.head.toInt)\n// val c = input.split(LINE_SEPARATOR).drop(n + 1).map(_.split(\" \").head.toInt)\n// val d = input.split(LINE_SEPARATOR).drop(n + 1).map(_.split(\" \").tail.head.toInt)\n// val k = 2 * pow(10, 5).toInt\n// val INF = pow(10, 9).toInt + 1\n// val pqMap = (0 until k).map(_ => new mutable.TreeMap[Int, Int]).toArray\n// def add(k: Int, ai: Int): Unit = {\n// val count = pqMap(k).getOrElse(ai, 0)\n// pqMap(k) += ai -> (count + 1)\n// }\n// def delete(k: Int, ai: Int): Unit = {\n// val count = pqMap(k).getOrElse(ai, 0)\n// if (count == 1) pqMap(k) -= ai else pqMap(k) += ai -> (count - 1)\n// }\n// val i2k = (0 until n).map{i =>\n// b(i)\n// }.toArray\n// (0 until n).foreach{i =>\n// add(b(i) - 1, a(i))\n// }\n// val maxList = pqMap.map(pq => if (pq.nonEmpty) pq.last._1 else INF)\n//\n// (0 until q).map{j =>\n// add(d(j) - 1, a(c(j) - 1))\n// delete(i2k(c(j) - 1) - 1, a(c(j) - 1))\n// maxList(i2k(c(j) - 1) - 1) =\n// if (pqMap(i2k(c(j) - 1) - 1).nonEmpty) pqMap(i2k(c(j) - 1) - 1).last._1 else INF\n// i2k(c(j) - 1) = d(j)\n// maxList(d(j) - 1) = if (pqMap(d(j) - 1).nonEmpty) pqMap(d(j) - 1).last._1 else INF\n// maxList.min\n// }.mkString(LINE_SEPARATOR)\n// }\n\n def solve(input: String): String = {\n val n = input.toLong\n divideDigits(n, 26).map(i => (i.toInt + 96).toChar).mkString\n }\n\n def divideDigits(num: Long, base: Long = 10): List[Long] = {\n def proc(num: Long, base: Long): List[Long] = {\n val quotient = num / base\n val remainder = num % base\n quotient match {\n case 0 => return List(remainder)\n case _ => remainder :: proc(quotient, base)\n }\n }\n\n proc(num, base).reverse\n }\n\n\n def medianCalculator(seq: Seq[Long]): Long = {\n //In order if you are not sure that 'seq' is sorted\n val sortedSeq = seq.sortWith(_ < _)\n\n if (seq.size % 2 == 1) sortedSeq(sortedSeq.size / 2)\n else {\n val (up, down) = sortedSeq.splitAt(seq.size / 2)\n (up.last + down.head) / 2\n }\n }\n\n def factorize(x: Long): List[Long] = {\n def foo(x: Long, a: Long = 2, list: List[Long] = Nil): List[Long] = a*a > x match {\n case false if x % a == 0 => foo(x / a, a , a :: list)\n case false => foo(x , a + 1, list)\n case true => x :: list\n }\n foo(x)\n }\n\n def divisors(n: Int): Vector[Int] = {\n val halfList = (1 to sqrt(n).toInt).toVector.filter(n % _ == 0).map(_.toInt)\n val reversedList = if (sqrt(n).floor == sqrt(n)) halfList.reverse.tail.map(n/_) else halfList.reverse.map(n/_)\n halfList ++ reversedList\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 \"\"\"2\"\"\".stripMargin -> \"\"\"b\n |\n |\n |\n |\"\"\".stripMargin\n ,\n \"\"\"27\"\"\".stripMargin -> \"\"\"aa\n |\"\"\".stripMargin,\n \"\"\"123456789\"\"\" -> \"\"\"jjddja\"\"\"\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\n\n\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\n1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001, but he gave them new names, as follows:\n\nthe dogs numbered 1,2,\\cdots,26 were respectively given the names a, b, ..., z;\n\nthe dogs numbered 27,28,29,\\cdots,701,702 were respectively given the names aa, ab, ac, ..., zy, zz;\n\nthe dogs numbered 703,704,705,\\cdots,18277,18278 were respectively given the names aaa, aab, aac, ..., zzy, zzz;\n\nthe dogs numbered 18279,18280,18281,\\cdots,475253,475254 were respectively given the names aaaa, aaab, aaac, ..., zzzy, zzzz;\n\nthe dogs numbered 475255,475256,\\cdots were respectively given the names aaaaa, aaaab, ...;\n\nand so on.\n\nTo sum it up, the dogs numbered 1, 2, \\cdots were respectively given the following names:\n\na, b, ..., z, aa, ab, ..., az, ba, bb, ..., bz, ..., za, zb, ..., zz, aaa, aab, ..., aaz, aba, abb, ..., abz, ..., zzz, aaaa, ...\n\nNow, Roger asks you:\n\n\"What is the name for the dog numbered N?\"\n\nConstraints\n\nN is an integer.\n\n1 \\leq N \\leq 1000000000000001\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer to Roger's question as a string consisting of lowercase English letters.\n\nSample Input 1\n\n2\n\nSample Output 1\n\nb\n\nSample Input 2\n\n27\n\nSample Output 2\n\naa\n\nSample Input 3\n\n123456789\n\nSample Output 3\n\njjddja", "sample_input": "2\n"}, "reference_outputs": ["b\n"], "source_document_id": "p02629", "source_text": "Score : 300 points\n\nProblem Statement\n\n1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001, but he gave them new names, as follows:\n\nthe dogs numbered 1,2,\\cdots,26 were respectively given the names a, b, ..., z;\n\nthe dogs numbered 27,28,29,\\cdots,701,702 were respectively given the names aa, ab, ac, ..., zy, zz;\n\nthe dogs numbered 703,704,705,\\cdots,18277,18278 were respectively given the names aaa, aab, aac, ..., zzy, zzz;\n\nthe dogs numbered 18279,18280,18281,\\cdots,475253,475254 were respectively given the names aaaa, aaab, aaac, ..., zzzy, zzzz;\n\nthe dogs numbered 475255,475256,\\cdots were respectively given the names aaaaa, aaaab, ...;\n\nand so on.\n\nTo sum it up, the dogs numbered 1, 2, \\cdots were respectively given the following names:\n\na, b, ..., z, aa, ab, ..., az, ba, bb, ..., bz, ..., za, zb, ..., zz, aaa, aab, ..., aaz, aba, abb, ..., abz, ..., zzz, aaaa, ...\n\nNow, Roger asks you:\n\n\"What is the name for the dog numbered N?\"\n\nConstraints\n\nN is an integer.\n\n1 \\leq N \\leq 1000000000000001\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer to Roger's question as a string consisting of lowercase English letters.\n\nSample Input 1\n\n2\n\nSample Output 1\n\nb\n\nSample Input 2\n\n27\n\nSample Output 2\n\naa\n\nSample Input 3\n\n123456789\n\nSample Output 3\n\njjddja", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4808, "cpu_time_ms": 539, "memory_kb": 55356}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s811188500", "group_id": "codeNet:p02630", "input_text": "// TLE\nobject Main extends App {\n val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList\n val size = inputs(0).toInt\n val startNums = inputs(1).split(\" \").map(_.toInt)\n val q = inputs(2).toInt\n val bi = inputs.splitAt(3)._2\n\n solve(size, startNums, q, bi)\n\n def solve(size: Int, startNums: Seq[Int], q: Int, bi: Seq[String]): Unit = {\n val array = scala.collection.mutable.HashMap.empty[Int, Int]\n var sum = 0\n startNums.foreach { v =>\n sum = sum + v\n array.update(v, array.applyOrElse(v, (n: Int) => 0) + 1)\n }\n\n // 最終的に数字が何になるのかだけ処理する\n bi.foreach { str =>\n val set = str.split(\" \").map(_.toInt)\n val from = set(0)\n val to = set(1)\n var diff = 0\n\n if(array.isDefinedAt(from)) {\n diff = (to - from) * array(from)\n array.update(to, array.applyOrElse(to, (n: Int) => 0) + array(from))\n array.remove(from)\n }\n sum = sum + diff\n\n println(sum)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1592796467, "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/s811188500.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s811188500", "user_id": "u631102131"}, "prompt_components": {"gold_output": "11\n12\n16\n", "input_to_evaluate": "// TLE\nobject Main extends App {\n val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList\n val size = inputs(0).toInt\n val startNums = inputs(1).split(\" \").map(_.toInt)\n val q = inputs(2).toInt\n val bi = inputs.splitAt(3)._2\n\n solve(size, startNums, q, bi)\n\n def solve(size: Int, startNums: Seq[Int], q: Int, bi: Seq[String]): Unit = {\n val array = scala.collection.mutable.HashMap.empty[Int, Int]\n var sum = 0\n startNums.foreach { v =>\n sum = sum + v\n array.update(v, array.applyOrElse(v, (n: Int) => 0) + 1)\n }\n\n // 最終的に数字が何になるのかだけ処理する\n bi.foreach { str =>\n val set = str.split(\" \").map(_.toInt)\n val from = set(0)\n val to = set(1)\n var diff = 0\n\n if(array.isDefinedAt(from)) {\n diff = (to - from) * array(from)\n array.update(to, array.applyOrElse(to, (n: Int) => 0) + array(from))\n array.remove(from)\n }\n sum = sum + diff\n\n println(sum)\n }\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou have a sequence A composed of N positive integers: A_{1}, A_{2}, \\cdots, A_{N}.\n\nYou will now successively do the following Q operations:\n\nIn the i-th operation, you replace every element whose value is B_{i} with C_{i}.\n\nFor each i (1 \\leq i \\leq Q), find S_{i}: the sum of all elements in A just after the i-th operation.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, Q, A_{i}, B_{i}, C_{i} \\leq 10^{5}\n\nB_{i} \\neq C_{i}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1} A_{2} \\cdots A_{N}\nQ\nB_{1} C_{1}\nB_{2} C_{2}\n\\vdots\nB_{Q} C_{Q}\n\nOutput\n\nPrint Q integers S_{i} to Standard Output in the following format:\n\nS_{1}\nS_{2}\n\\vdots\nS_{Q}\n\nNote that S_{i} may not fit into a 32-bit integer.\n\nSample Input 1\n\n4\n1 2 3 4\n3\n1 2\n3 4\n2 4\n\nSample Output 1\n\n11\n12\n16\n\nInitially, the sequence A is 1,2,3,4.\n\nAfter each operation, it becomes the following:\n\n2, 2, 3, 4\n\n2, 2, 4, 4\n\n4, 4, 4, 4\n\nSample Input 2\n\n4\n1 1 1 1\n3\n1 2\n2 1\n3 5\n\nSample Output 2\n\n8\n4\n4\n\nNote that the sequence A may not contain an element whose value is B_{i}.\n\nSample Input 3\n\n2\n1 2\n3\n1 100\n2 100\n100 1000\n\nSample Output 3\n\n102\n200\n2000", "sample_input": "4\n1 2 3 4\n3\n1 2\n3 4\n2 4\n"}, "reference_outputs": ["11\n12\n16\n"], "source_document_id": "p02630", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou have a sequence A composed of N positive integers: A_{1}, A_{2}, \\cdots, A_{N}.\n\nYou will now successively do the following Q operations:\n\nIn the i-th operation, you replace every element whose value is B_{i} with C_{i}.\n\nFor each i (1 \\leq i \\leq Q), find S_{i}: the sum of all elements in A just after the i-th operation.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, Q, A_{i}, B_{i}, C_{i} \\leq 10^{5}\n\nB_{i} \\neq C_{i}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1} A_{2} \\cdots A_{N}\nQ\nB_{1} C_{1}\nB_{2} C_{2}\n\\vdots\nB_{Q} C_{Q}\n\nOutput\n\nPrint Q integers S_{i} to Standard Output in the following format:\n\nS_{1}\nS_{2}\n\\vdots\nS_{Q}\n\nNote that S_{i} may not fit into a 32-bit integer.\n\nSample Input 1\n\n4\n1 2 3 4\n3\n1 2\n3 4\n2 4\n\nSample Output 1\n\n11\n12\n16\n\nInitially, the sequence A is 1,2,3,4.\n\nAfter each operation, it becomes the following:\n\n2, 2, 3, 4\n\n2, 2, 4, 4\n\n4, 4, 4, 4\n\nSample Input 2\n\n4\n1 1 1 1\n3\n1 2\n2 1\n3 5\n\nSample Output 2\n\n8\n4\n4\n\nNote that the sequence A may not contain an element whose value is B_{i}.\n\nSample Input 3\n\n2\n1 2\n3\n1 100\n2 100\n100 1000\n\nSample Output 3\n\n102\n200\n2000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 997, "cpu_time_ms": 1510, "memory_kb": 79648}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s955423143", "group_id": "codeNet:p02631", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n\n def readALine(c:Int, ac:List[Int]=Nil):List[Int] =\n if (c > 0) readALine(c-1, sc.nextInt::ac) else ac.reverse\n // def readLines(r:Int, c:Int, ac:List[List[Int]]):List[List[Int]] =\n // if (r > 0) readLines(r-1, c, readALine(c, Nil)::ac) else ac.reverse\n val sc = new Scanner(System.in)\n val N = sc.nextInt\n val Ai = readALine(N)\n\n def solver():List[Int] = {\n def prod(l:List[Int], ac:Int = 0):Int = {\n if (l.isEmpty) ac else prod(l.tail, l.head ^ ac)\n } \n def iter(al:List[Int], bl:List[Int], ac:List[Int]):List[Int] = {\n if (al.isEmpty) ac.reverse else {\n val a0 = al.head\n val a1 = al.tail.head\n val al_ = al.tail.tail\n val others = prod(al_) ^ prod(bl)\n iter(al_,a1::a0::bl, (a0^others)::(a1^others)::ac)\n }\n }\n iter(Ai, Nil, Nil)\n }\n\n println(solver().mkString(\" \"))\n\n}", "language": "Scala", "metadata": {"date": 1593862289, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02631.html", "problem_id": "p02631", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02631/input.txt", "sample_output_relpath": "derived/input_output/data/p02631/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02631/Scala/s955423143.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s955423143", "user_id": "u909235613"}, "prompt_components": {"gold_output": "26 5 7 22\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n\n def readALine(c:Int, ac:List[Int]=Nil):List[Int] =\n if (c > 0) readALine(c-1, sc.nextInt::ac) else ac.reverse\n // def readLines(r:Int, c:Int, ac:List[List[Int]]):List[List[Int]] =\n // if (r > 0) readLines(r-1, c, readALine(c, Nil)::ac) else ac.reverse\n val sc = new Scanner(System.in)\n val N = sc.nextInt\n val Ai = readALine(N)\n\n def solver():List[Int] = {\n def prod(l:List[Int], ac:Int = 0):Int = {\n if (l.isEmpty) ac else prod(l.tail, l.head ^ ac)\n } \n def iter(al:List[Int], bl:List[Int], ac:List[Int]):List[Int] = {\n if (al.isEmpty) ac.reverse else {\n val a0 = al.head\n val a1 = al.tail.head\n val al_ = al.tail.tail\n val others = prod(al_) ^ prod(bl)\n iter(al_,a1::a0::bl, (a0^others)::(a1^others)::ac)\n }\n }\n iter(Ai, Nil, Nil)\n }\n\n println(solver().mkString(\" \"))\n\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N Snuke Cats numbered 1, 2, \\ldots, N, where N is even.\n\nEach Snuke Cat wears a red scarf, on which his favorite non-negative integer is written.\n\nRecently, they learned the operation called xor (exclusive OR).\n\nWhat is xor?\n\nFor n non-negative integers x_1, x_2, \\ldots, x_n, their xor, x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is defined as follows:\n\nWhen x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if the number of integers among x_1, x_2, \\ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.\n\nFor example, 3~\\textrm{xor}~5 = 6.\n\nThey wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf.\n\nWe know that the xor calculated by Snuke Cat i, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i.\nUsing this information, restore the integer written on the scarf of each Snuke Cat.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n0 \\leq a_i \\leq 10^9\n\nThere exists a combination of integers on the scarfs that is consistent with the given information.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint a line containing N integers separated with space.\n\nThe i-th of the integers from the left should represent the integer written on the scarf of Snuke Cat i.\n\nIf there are multiple possible solutions, you may print any of them.\n\nSample Input 1\n\n4\n20 11 9 24\n\nSample Output 1\n\n26 5 7 22\n\n5~\\textrm{xor}~7~\\textrm{xor}~22 = 20\n\n26~\\textrm{xor}~7~\\textrm{xor}~22 = 11\n\n26~\\textrm{xor}~5~\\textrm{xor}~22 = 9\n\n26~\\textrm{xor}~5~\\textrm{xor}~7 = 24\n\nThus, this output is consistent with the given information.", "sample_input": "4\n20 11 9 24\n"}, "reference_outputs": ["26 5 7 22\n"], "source_document_id": "p02631", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N Snuke Cats numbered 1, 2, \\ldots, N, where N is even.\n\nEach Snuke Cat wears a red scarf, on which his favorite non-negative integer is written.\n\nRecently, they learned the operation called xor (exclusive OR).\n\nWhat is xor?\n\nFor n non-negative integers x_1, x_2, \\ldots, x_n, their xor, x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is defined as follows:\n\nWhen x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if the number of integers among x_1, x_2, \\ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.\n\nFor example, 3~\\textrm{xor}~5 = 6.\n\nThey wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf.\n\nWe know that the xor calculated by Snuke Cat i, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i.\nUsing this information, restore the integer written on the scarf of each Snuke Cat.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n0 \\leq a_i \\leq 10^9\n\nThere exists a combination of integers on the scarfs that is consistent with the given information.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint a line containing N integers separated with space.\n\nThe i-th of the integers from the left should represent the integer written on the scarf of Snuke Cat i.\n\nIf there are multiple possible solutions, you may print any of them.\n\nSample Input 1\n\n4\n20 11 9 24\n\nSample Output 1\n\n26 5 7 22\n\n5~\\textrm{xor}~7~\\textrm{xor}~22 = 20\n\n26~\\textrm{xor}~7~\\textrm{xor}~22 = 11\n\n26~\\textrm{xor}~5~\\textrm{xor}~22 = 9\n\n26~\\textrm{xor}~5~\\textrm{xor}~7 = 24\n\nThus, this output is consistent with the given information.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 905, "cpu_time_ms": 2205, "memory_kb": 55656}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s485183558", "group_id": "codeNet:p02639", "input_text": "import java.security.KeyStore.TrustedCertificateEntry\nimport java.util\nimport java.util.regex.Pattern\nimport java.util.{ArrayList, Collections, Comparator, List => JList}\n\nimport scala.collection.immutable.TreeMap\nimport scala.math._\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 x = input.split(\" \").map(_.toInt)\n var res = 0\n (1 to 5).foreach{i =>\n if (x(i - 1) != i) res = i\n }\n res.toString\n }\n\n def medianCalculator(seq: Seq[Long]): Long = {\n //In order if you are not sure that 'seq' is sorted\n val sortedSeq = seq.sortWith(_ < _)\n\n if (seq.size % 2 == 1) sortedSeq(sortedSeq.size / 2)\n else {\n val (up, down) = sortedSeq.splitAt(seq.size / 2)\n (up.last + down.head) / 2\n }\n }\n\n def factorize(x: Long): List[Long] = {\n def foo(x: Long, a: Long = 2, list: List[Long] = Nil): List[Long] = a*a > x match {\n case false if x % a == 0 => foo(x / a, a , a :: list)\n case false => foo(x , a + 1, list)\n case true => x :: list\n }\n foo(x)\n }\n\n def divisors(n: Long): Vector[Long] = {\n val halfList = (1 to sqrt(n).toInt).toVector.filter(_ % n == 0).map(_.toLong)\n val reversedList = if (sqrt(n).floor == sqrt(n)) halfList.reverse.tail.map(n/_) else halfList.reverse.map(n/_)\n halfList ++ reversedList\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 \"\"\"0 2 3 4 5\"\"\".stripMargin -> \"\"\"1\n |\n |\n |\"\"\".stripMargin,\n \"\"\"1 2 0 4 5\"\"\".stripMargin -> \"\"\"3\"\"\".stripMargin\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}\n", "language": "Scala", "metadata": {"date": 1592189963, "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/s485183558.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s485183558", "user_id": "u114537090"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.security.KeyStore.TrustedCertificateEntry\nimport java.util\nimport java.util.regex.Pattern\nimport java.util.{ArrayList, Collections, Comparator, List => JList}\n\nimport scala.collection.immutable.TreeMap\nimport scala.math._\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 x = input.split(\" \").map(_.toInt)\n var res = 0\n (1 to 5).foreach{i =>\n if (x(i - 1) != i) res = i\n }\n res.toString\n }\n\n def medianCalculator(seq: Seq[Long]): Long = {\n //In order if you are not sure that 'seq' is sorted\n val sortedSeq = seq.sortWith(_ < _)\n\n if (seq.size % 2 == 1) sortedSeq(sortedSeq.size / 2)\n else {\n val (up, down) = sortedSeq.splitAt(seq.size / 2)\n (up.last + down.head) / 2\n }\n }\n\n def factorize(x: Long): List[Long] = {\n def foo(x: Long, a: Long = 2, list: List[Long] = Nil): List[Long] = a*a > x match {\n case false if x % a == 0 => foo(x / a, a , a :: list)\n case false => foo(x , a + 1, list)\n case true => x :: list\n }\n foo(x)\n }\n\n def divisors(n: Long): Vector[Long] = {\n val halfList = (1 to sqrt(n).toInt).toVector.filter(_ % n == 0).map(_.toLong)\n val reversedList = if (sqrt(n).floor == sqrt(n)) halfList.reverse.tail.map(n/_) else halfList.reverse.map(n/_)\n halfList ++ reversedList\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 \"\"\"0 2 3 4 5\"\"\".stripMargin -> \"\"\"1\n |\n |\n |\"\"\".stripMargin,\n \"\"\"1 2 0 4 5\"\"\".stripMargin -> \"\"\"3\"\"\".stripMargin\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}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have five variables x_1, x_2, x_3, x_4, and x_5.\n\nThe variable x_i was initially assigned a value of i.\n\nSnuke chose one of these variables and assigned it 0.\n\nYou are given the values of the five variables after this assignment.\n\nFind out which variable Snuke assigned 0.\n\nConstraints\n\nThe values of x_1, x_2, x_3, x_4, and x_5 given as input are a possible outcome of the assignment by Snuke.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx_1 x_2 x_3 x_4 x_5\n\nOutput\n\nIf the variable Snuke assigned 0 was x_i, print the integer i.\n\nSample Input 1\n\n0 2 3 4 5\n\nSample Output 1\n\n1\n\nIn this case, Snuke assigned 0 to x_1, so we should print 1.\n\nSample Input 2\n\n1 2 0 4 5\n\nSample Output 2\n\n3", "sample_input": "0 2 3 4 5\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02639", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have five variables x_1, x_2, x_3, x_4, and x_5.\n\nThe variable x_i was initially assigned a value of i.\n\nSnuke chose one of these variables and assigned it 0.\n\nYou are given the values of the five variables after this assignment.\n\nFind out which variable Snuke assigned 0.\n\nConstraints\n\nThe values of x_1, x_2, x_3, x_4, and x_5 given as input are a possible outcome of the assignment by Snuke.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx_1 x_2 x_3 x_4 x_5\n\nOutput\n\nIf the variable Snuke assigned 0 was x_i, print the integer i.\n\nSample Input 1\n\n0 2 3 4 5\n\nSample Output 1\n\n1\n\nIn this case, Snuke assigned 0 to x_1, so we should print 1.\n\nSample Input 2\n\n1 2 0 4 5\n\nSample Output 2\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2861, "cpu_time_ms": 509, "memory_kb": 55000}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s004127375", "group_id": "codeNet:p02639", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val xs = Seq.fill(5)(sc.nextInt)\n println(xs.indexOf(0) + 1)\n}\n", "language": "Scala", "metadata": {"date": 1592182998, "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/s004127375.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s004127375", "user_id": "u220774651"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val xs = Seq.fill(5)(sc.nextInt)\n println(xs.indexOf(0) + 1)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have five variables x_1, x_2, x_3, x_4, and x_5.\n\nThe variable x_i was initially assigned a value of i.\n\nSnuke chose one of these variables and assigned it 0.\n\nYou are given the values of the five variables after this assignment.\n\nFind out which variable Snuke assigned 0.\n\nConstraints\n\nThe values of x_1, x_2, x_3, x_4, and x_5 given as input are a possible outcome of the assignment by Snuke.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx_1 x_2 x_3 x_4 x_5\n\nOutput\n\nIf the variable Snuke assigned 0 was x_i, print the integer i.\n\nSample Input 1\n\n0 2 3 4 5\n\nSample Output 1\n\n1\n\nIn this case, Snuke assigned 0 to x_1, so we should print 1.\n\nSample Input 2\n\n1 2 0 4 5\n\nSample Output 2\n\n3", "sample_input": "0 2 3 4 5\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02639", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have five variables x_1, x_2, x_3, x_4, and x_5.\n\nThe variable x_i was initially assigned a value of i.\n\nSnuke chose one of these variables and assigned it 0.\n\nYou are given the values of the five variables after this assignment.\n\nFind out which variable Snuke assigned 0.\n\nConstraints\n\nThe values of x_1, x_2, x_3, x_4, and x_5 given as input are a possible outcome of the assignment by Snuke.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx_1 x_2 x_3 x_4 x_5\n\nOutput\n\nIf the variable Snuke assigned 0 was x_i, print the integer i.\n\nSample Input 1\n\n0 2 3 4 5\n\nSample Output 1\n\n1\n\nIn this case, Snuke assigned 0 to x_1, so we should print 1.\n\nSample Input 2\n\n1 2 0 4 5\n\nSample Output 2\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 152, "cpu_time_ms": 511, "memory_kb": 55412}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s602093653", "group_id": "codeNet:p02641", "input_text": "object Main extends App{\n val sc = new java.util.Scanner(System.in)\n var a , b =sc.nextInt()\n if(b == 0) {print(a);sys.exit()}\n var c = List.fill(b)(sc.nextInt())\n if(c.indexOf(a) == -1){print(a);sys.exit()}\n c :+ a\n c = c.sorted\n var min = 0\n var max = 0\n if (c.indexOf(a) == 0){print(a-1);sys.exit()}\n min = c(c.indexOf(a) - 1)\n if(c.indexOf(a) != b-1) {\n max = c(c.indexOf(a)+1)\n }else{\n max = 105\n }\n var i = a-1\n var j = a+1\n var ans = 0\n while (i == min){\n i-=1\n if(!(c.indexOf(min)-1 == -1)) {\n min = c(c.indexOf(min) - 1)\n }else{\n min = i+1\n }\n }\n while (j == max){\n j+=1\n if(!(c.indexOf(max)+1 > b-1)) {\n max = c(c.indexOf(max) + 1)\n }else{\n max = j+1\n }\n }\n var ia = a-i\n var ja = a-j\n if(ia >= a){print(0);sys.exit()}\n if(math.abs(ia)>math.abs(ja)){\n print(j)\n }else{\n print(i)\n }\n}\n", "language": "Scala", "metadata": {"date": 1592191532, "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/s602093653.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s602093653", "user_id": "u488417454"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "object Main extends App{\n val sc = new java.util.Scanner(System.in)\n var a , b =sc.nextInt()\n if(b == 0) {print(a);sys.exit()}\n var c = List.fill(b)(sc.nextInt())\n if(c.indexOf(a) == -1){print(a);sys.exit()}\n c :+ a\n c = c.sorted\n var min = 0\n var max = 0\n if (c.indexOf(a) == 0){print(a-1);sys.exit()}\n min = c(c.indexOf(a) - 1)\n if(c.indexOf(a) != b-1) {\n max = c(c.indexOf(a)+1)\n }else{\n max = 105\n }\n var i = a-1\n var j = a+1\n var ans = 0\n while (i == min){\n i-=1\n if(!(c.indexOf(min)-1 == -1)) {\n min = c(c.indexOf(min) - 1)\n }else{\n min = i+1\n }\n }\n while (j == max){\n j+=1\n if(!(c.indexOf(max)+1 > b-1)) {\n max = c(c.indexOf(max) + 1)\n }else{\n max = j+1\n }\n }\n var ia = a-i\n var ja = a-j\n if(ia >= a){print(0);sys.exit()}\n if(math.abs(ia)>math.abs(ja)){\n print(j)\n }else{\n print(i)\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven are an integer X and an integer sequence of length N: p_1, \\ldots, p_N.\n\nAmong the integers not contained in the sequence p_1, \\ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n0 \\leq N \\leq 100\n\n1 \\leq p_i \\leq 100\n\np_1, \\ldots, p_N are all distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX N\np_1 ... p_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6 5\n4 7 10 6 5\n\nSample Output 1\n\n8\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the one nearest to 6 is 8.\n\nSample Input 2\n\n10 5\n4 7 10 6 5\n\nSample Output 2\n\n9\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the ones nearest to 10 are 9 and 11. We should print the smaller one, 9.\n\nSample Input 3\n\n100 0\n\nSample Output 3\n\n100\n\nWhen N = 0, the second line in the input will be empty. Also, as seen here, X itself can be the answer.", "sample_input": "6 5\n4 7 10 6 5\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02641", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven are an integer X and an integer sequence of length N: p_1, \\ldots, p_N.\n\nAmong the integers not contained in the sequence p_1, \\ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n0 \\leq N \\leq 100\n\n1 \\leq p_i \\leq 100\n\np_1, \\ldots, p_N are all distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX N\np_1 ... p_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6 5\n4 7 10 6 5\n\nSample Output 1\n\n8\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the one nearest to 6 is 8.\n\nSample Input 2\n\n10 5\n4 7 10 6 5\n\nSample Output 2\n\n9\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the ones nearest to 10 are 9 and 11. We should print the smaller one, 9.\n\nSample Input 3\n\n100 0\n\nSample Output 3\n\n100\n\nWhen N = 0, the second line in the input will be empty. Also, as seen here, X itself can be the answer.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 877, "cpu_time_ms": 540, "memory_kb": 55644}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s765938574", "group_id": "codeNet:p02641", "input_text": "object Main extends App {\n val xn = scala.io.StdIn.readLine()\n val xnArray = xn.split(\" \").map(_.toInt).toSeq\n val x = xnArray(0)\n val n = xnArray(1)\n\n val pInput = scala.io.StdIn.readLine()\n\n if (n == 0) {\n println(x)\n } else {\n val pArray = pInput.split(\" \").map(_.toInt).toVector.sorted\n if (pArray.find(_ == x).isEmpty) {\n println(x)\n } else {\n val min = pArray.head - 1\n val minSabun = Math.abs(x - min)\n val max = pArray.last + 1\n val maxSabun = Math.abs(x - max)\n\n var temp = -999\n var sabun = -999\n var result = -999\n if (minSabun > maxSabun) {\n sabun = maxSabun\n result = max\n } else {\n sabun = minSabun\n result = min\n }\n pArray.zipWithIndex.foreach { p =>\n if (temp == -999) {\n temp = p._1\n } else if (temp + 1 == p._1) {\n temp = p._1\n } else {\n // 現状より一つ前の値\n (temp + 1 to p._1 - 1).foreach { i =>\n val tempSabun = Math.abs(x - i)\n if (tempSabun < sabun) {\n sabun = tempSabun\n result = i\n } else if (tempSabun == sabun && i < result) {\n sabun = tempSabun\n result = i\n }\n }\n temp = p._1\n }\n }\n println(result)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1592187273, "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/s765938574.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s765938574", "user_id": "u105921924"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "object Main extends App {\n val xn = scala.io.StdIn.readLine()\n val xnArray = xn.split(\" \").map(_.toInt).toSeq\n val x = xnArray(0)\n val n = xnArray(1)\n\n val pInput = scala.io.StdIn.readLine()\n\n if (n == 0) {\n println(x)\n } else {\n val pArray = pInput.split(\" \").map(_.toInt).toVector.sorted\n if (pArray.find(_ == x).isEmpty) {\n println(x)\n } else {\n val min = pArray.head - 1\n val minSabun = Math.abs(x - min)\n val max = pArray.last + 1\n val maxSabun = Math.abs(x - max)\n\n var temp = -999\n var sabun = -999\n var result = -999\n if (minSabun > maxSabun) {\n sabun = maxSabun\n result = max\n } else {\n sabun = minSabun\n result = min\n }\n pArray.zipWithIndex.foreach { p =>\n if (temp == -999) {\n temp = p._1\n } else if (temp + 1 == p._1) {\n temp = p._1\n } else {\n // 現状より一つ前の値\n (temp + 1 to p._1 - 1).foreach { i =>\n val tempSabun = Math.abs(x - i)\n if (tempSabun < sabun) {\n sabun = tempSabun\n result = i\n } else if (tempSabun == sabun && i < result) {\n sabun = tempSabun\n result = i\n }\n }\n temp = p._1\n }\n }\n println(result)\n }\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven are an integer X and an integer sequence of length N: p_1, \\ldots, p_N.\n\nAmong the integers not contained in the sequence p_1, \\ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n0 \\leq N \\leq 100\n\n1 \\leq p_i \\leq 100\n\np_1, \\ldots, p_N are all distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX N\np_1 ... p_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6 5\n4 7 10 6 5\n\nSample Output 1\n\n8\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the one nearest to 6 is 8.\n\nSample Input 2\n\n10 5\n4 7 10 6 5\n\nSample Output 2\n\n9\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the ones nearest to 10 are 9 and 11. We should print the smaller one, 9.\n\nSample Input 3\n\n100 0\n\nSample Output 3\n\n100\n\nWhen N = 0, the second line in the input will be empty. Also, as seen here, X itself can be the answer.", "sample_input": "6 5\n4 7 10 6 5\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02641", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven are an integer X and an integer sequence of length N: p_1, \\ldots, p_N.\n\nAmong the integers not contained in the sequence p_1, \\ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n0 \\leq N \\leq 100\n\n1 \\leq p_i \\leq 100\n\np_1, \\ldots, p_N are all distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX N\np_1 ... p_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6 5\n4 7 10 6 5\n\nSample Output 1\n\n8\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the one nearest to 6 is 8.\n\nSample Input 2\n\n10 5\n4 7 10 6 5\n\nSample Output 2\n\n9\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the ones nearest to 10 are 9 and 11. We should print the smaller one, 9.\n\nSample Input 3\n\n100 0\n\nSample Output 3\n\n100\n\nWhen N = 0, the second line in the input will be empty. Also, as seen here, X itself can be the answer.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1345, "cpu_time_ms": 518, "memory_kb": 54888}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s992163749", "group_id": "codeNet:p02641", "input_text": "import java.util.Scanner\n\nimport scala.util.control.Breaks\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val x = sc.nextInt()\n val n = sc.nextInt()\n\n val p = Set.fill(n)(sc.nextInt())\n\n var ans = x\n var dis = 0\n val b = new Breaks\n b.breakable {\n while (true) {\n if (!p.contains(ans - dis)) {\n ans = ans - dis\n b.break()\n } else if (!p.contains(ans + dis)) {\n ans = ans + dis\n b.break()\n } else {\n dis += 1\n }\n }\n }\n\n println(ans)\n\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1592183972, "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/s992163749.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s992163749", "user_id": "u197909036"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.util.control.Breaks\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val x = sc.nextInt()\n val n = sc.nextInt()\n\n val p = Set.fill(n)(sc.nextInt())\n\n var ans = x\n var dis = 0\n val b = new Breaks\n b.breakable {\n while (true) {\n if (!p.contains(ans - dis)) {\n ans = ans - dis\n b.break()\n } else if (!p.contains(ans + dis)) {\n ans = ans + dis\n b.break()\n } else {\n dis += 1\n }\n }\n }\n\n println(ans)\n\n }\n\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven are an integer X and an integer sequence of length N: p_1, \\ldots, p_N.\n\nAmong the integers not contained in the sequence p_1, \\ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n0 \\leq N \\leq 100\n\n1 \\leq p_i \\leq 100\n\np_1, \\ldots, p_N are all distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX N\np_1 ... p_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6 5\n4 7 10 6 5\n\nSample Output 1\n\n8\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the one nearest to 6 is 8.\n\nSample Input 2\n\n10 5\n4 7 10 6 5\n\nSample Output 2\n\n9\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the ones nearest to 10 are 9 and 11. We should print the smaller one, 9.\n\nSample Input 3\n\n100 0\n\nSample Output 3\n\n100\n\nWhen N = 0, the second line in the input will be empty. Also, as seen here, X itself can be the answer.", "sample_input": "6 5\n4 7 10 6 5\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02641", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven are an integer X and an integer sequence of length N: p_1, \\ldots, p_N.\n\nAmong the integers not contained in the sequence p_1, \\ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n0 \\leq N \\leq 100\n\n1 \\leq p_i \\leq 100\n\np_1, \\ldots, p_N are all distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX N\np_1 ... p_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6 5\n4 7 10 6 5\n\nSample Output 1\n\n8\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the one nearest to 6 is 8.\n\nSample Input 2\n\n10 5\n4 7 10 6 5\n\nSample Output 2\n\n9\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the ones nearest to 10 are 9 and 11. We should print the smaller one, 9.\n\nSample Input 3\n\n100 0\n\nSample Output 3\n\n100\n\nWhen N = 0, the second line in the input will be empty. Also, as seen here, X itself can be the answer.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 598, "cpu_time_ms": 515, "memory_kb": 55780}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s028909068", "group_id": "codeNet:p02641", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val X, N = sc.nextInt\n val p = Set.fill(N)(sc.nextInt)\n\n var i = 0\n var x = Int.MaxValue\n var z = 0\n do {\n if (!p.contains(X - i) && i < x) {\n x = i\n z = X - i\n } else if (!p.contains(X + i) && i < x) {\n x = i\n z = X + i\n }\n i += 1\n } while (x == Int.MaxValue)\n println(z)\n}\n", "language": "Scala", "metadata": {"date": 1592183843, "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/s028909068.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s028909068", "user_id": "u786167609"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val X, N = sc.nextInt\n val p = Set.fill(N)(sc.nextInt)\n\n var i = 0\n var x = Int.MaxValue\n var z = 0\n do {\n if (!p.contains(X - i) && i < x) {\n x = i\n z = X - i\n } else if (!p.contains(X + i) && i < x) {\n x = i\n z = X + i\n }\n i += 1\n } while (x == Int.MaxValue)\n println(z)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven are an integer X and an integer sequence of length N: p_1, \\ldots, p_N.\n\nAmong the integers not contained in the sequence p_1, \\ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n0 \\leq N \\leq 100\n\n1 \\leq p_i \\leq 100\n\np_1, \\ldots, p_N are all distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX N\np_1 ... p_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6 5\n4 7 10 6 5\n\nSample Output 1\n\n8\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the one nearest to 6 is 8.\n\nSample Input 2\n\n10 5\n4 7 10 6 5\n\nSample Output 2\n\n9\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the ones nearest to 10 are 9 and 11. We should print the smaller one, 9.\n\nSample Input 3\n\n100 0\n\nSample Output 3\n\n100\n\nWhen N = 0, the second line in the input will be empty. Also, as seen here, X itself can be the answer.", "sample_input": "6 5\n4 7 10 6 5\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02641", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven are an integer X and an integer sequence of length N: p_1, \\ldots, p_N.\n\nAmong the integers not contained in the sequence p_1, \\ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n0 \\leq N \\leq 100\n\n1 \\leq p_i \\leq 100\n\np_1, \\ldots, p_N are all distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX N\np_1 ... p_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6 5\n4 7 10 6 5\n\nSample Output 1\n\n8\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the one nearest to 6 is 8.\n\nSample Input 2\n\n10 5\n4 7 10 6 5\n\nSample Output 2\n\n9\n\nAmong the integers not contained in the sequence 4, 7, 10, 6, 5, the ones nearest to 10 are 9 and 11. We should print the smaller one, 9.\n\nSample Input 3\n\n100 0\n\nSample Output 3\n\n100\n\nWhen N = 0, the second line in the input will be empty. Also, as seen here, X itself can be the answer.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 402, "cpu_time_ms": 482, "memory_kb": 55728}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s333306352", "group_id": "codeNet:p02644", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val h, w, k = sc.nextInt()\n val x1, y1, x2, y2 = sc.nextInt()-1\n val c = Array.fill(h)(sc.next()).map(_.map(_ == '@').toArray)\n\n def compare(a: (Int, Int), b: (Int, Int)): Boolean = {\n if (a._1 == b._1) {\n a._2 < b._2\n } else {\n a._1 < b._1\n }\n }\n\n def shortestPath(sx: Int, sy: Int): Array[Array[Array[(Int, Int)]]] = {\n val sp = Array.fill(h, w, 4)((-1, 0))\n val dir = Array((1,0), (0,1), (-1,0), (0,-1))\n val heap = new BinaryHeap[(Int,Int,Int), (Int,Int)](4000000, compare)\n sp(sx)(sy)(0) = (0, 0)\n heap.add((sx, sy, 0), (0, 0))\n\n while (heap.nonEmpty) {\n val ((x1, y1, d1), (a, b)) = heap.pop()\n\n for (i <- -1 to 1) {\n val d2 = (d1+i+4) % 4\n val (x2, y2) = if (i == 0) {\n (x1 + dir(d2)._1, y1 + dir(d2)._2)\n } else {\n (x1, y1)\n }\n\n if (i != 0 || (0 <= x2 && x2 < h && 0 <= y2 && y2 < w && !c(x2)(y2))) {\n val costOld = sp(x2)(y2)(d2)\n val costNew = if (i == 0) {\n if (b == k-1) (a+1, 0) else (a, b+1)\n } else {\n if (b == 0) (a, 0) else (a+1, 0)\n }\n\n if (costOld._1 == -1) {\n sp(x2)(y2)(d2) = costNew\n heap.add((x2, y2, d2), costNew)\n } else if (compare(costNew, costOld)) {\n sp(x2)(y2)(d2) = costNew\n heap.upPriority((x2, y2, d2), costNew)\n }\n }\n }\n }\n sp\n }\n\n class BinaryHeap[A, P](maxSize: Int, comparator: (P, P) => Boolean) {\n private val heap = Array.ofDim[(A, P)](maxSize)\n private var indexMap = Map[A, Int]()\n\n var size = 0\n def isEmpty: Boolean = size == 0\n def nonEmpty: Boolean = !isEmpty\n\n private def par(idx: Int): Int = (idx - 1) / 2\n private def left(idx: Int): Int = 2 * idx + 1\n private def right(idx: Int): Int = 2 * idx + 2\n\n private def isRoot(idx: Int): Boolean = idx == 0\n private def hasLeft(idx: Int): Boolean = left(idx) < size\n private def hasRight(idx: Int): Boolean = right(idx) < size\n\n private def swap(i: Int, j: Int): Unit = {\n indexMap += heap(i)._1 -> j\n indexMap += heap(j)._1 -> i\n\n val t = heap(i)\n heap(i) = heap(j)\n heap(j) = t\n }\n\n private def upHeap(idx: Int): Unit = {\n if (!isRoot(idx) && comparator(heap(idx)._2, heap(par(idx))._2)) {\n swap(idx, par(idx))\n upHeap(par(idx))\n }\n }\n\n private def downHeap(idx: Int): Unit = {\n if (hasLeft(idx)) {\n val t = if (hasRight(idx) && comparator(heap(right(idx))._2, heap(left(idx))._2)) {\n right(idx)\n } else {\n left(idx)\n }\n if (comparator(heap(t)._2, heap(idx)._2)) {\n swap(idx, t)\n downHeap(t)\n }\n }\n }\n\n def add(a: A, p: P): Unit = {\n if (size >= maxSize) {\n throw new UnsupportedOperationException()\n } else {\n size += 1\n heap(size - 1) = (a, p)\n indexMap += a -> (size - 1)\n upHeap(size - 1)\n }\n }\n\n def pop(): (A, P) = {\n if (isEmpty) {\n throw new UnsupportedOperationException()\n } else {\n val head = heap(0)\n indexMap -= head._1\n heap(0) = heap(size - 1)\n size -= 1\n downHeap(0)\n head\n }\n }\n\n def upPriority(a: A, p: P): Unit = {\n val idx = indexMap(a)\n heap(idx) = (a, p)\n upHeap(idx)\n }\n }\n\n val sp = shortestPath(x1, y1)\n println(sp(x2)(y2).map{case (a, b) => a + (if (b == 0) 0 else 1)}.min)\n}\n", "language": "Scala", "metadata": {"date": 1592675141, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02644.html", "problem_id": "p02644", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02644/input.txt", "sample_output_relpath": "derived/input_output/data/p02644/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02644/Scala/s333306352.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s333306352", "user_id": "u191819389"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val h, w, k = sc.nextInt()\n val x1, y1, x2, y2 = sc.nextInt()-1\n val c = Array.fill(h)(sc.next()).map(_.map(_ == '@').toArray)\n\n def compare(a: (Int, Int), b: (Int, Int)): Boolean = {\n if (a._1 == b._1) {\n a._2 < b._2\n } else {\n a._1 < b._1\n }\n }\n\n def shortestPath(sx: Int, sy: Int): Array[Array[Array[(Int, Int)]]] = {\n val sp = Array.fill(h, w, 4)((-1, 0))\n val dir = Array((1,0), (0,1), (-1,0), (0,-1))\n val heap = new BinaryHeap[(Int,Int,Int), (Int,Int)](4000000, compare)\n sp(sx)(sy)(0) = (0, 0)\n heap.add((sx, sy, 0), (0, 0))\n\n while (heap.nonEmpty) {\n val ((x1, y1, d1), (a, b)) = heap.pop()\n\n for (i <- -1 to 1) {\n val d2 = (d1+i+4) % 4\n val (x2, y2) = if (i == 0) {\n (x1 + dir(d2)._1, y1 + dir(d2)._2)\n } else {\n (x1, y1)\n }\n\n if (i != 0 || (0 <= x2 && x2 < h && 0 <= y2 && y2 < w && !c(x2)(y2))) {\n val costOld = sp(x2)(y2)(d2)\n val costNew = if (i == 0) {\n if (b == k-1) (a+1, 0) else (a, b+1)\n } else {\n if (b == 0) (a, 0) else (a+1, 0)\n }\n\n if (costOld._1 == -1) {\n sp(x2)(y2)(d2) = costNew\n heap.add((x2, y2, d2), costNew)\n } else if (compare(costNew, costOld)) {\n sp(x2)(y2)(d2) = costNew\n heap.upPriority((x2, y2, d2), costNew)\n }\n }\n }\n }\n sp\n }\n\n class BinaryHeap[A, P](maxSize: Int, comparator: (P, P) => Boolean) {\n private val heap = Array.ofDim[(A, P)](maxSize)\n private var indexMap = Map[A, Int]()\n\n var size = 0\n def isEmpty: Boolean = size == 0\n def nonEmpty: Boolean = !isEmpty\n\n private def par(idx: Int): Int = (idx - 1) / 2\n private def left(idx: Int): Int = 2 * idx + 1\n private def right(idx: Int): Int = 2 * idx + 2\n\n private def isRoot(idx: Int): Boolean = idx == 0\n private def hasLeft(idx: Int): Boolean = left(idx) < size\n private def hasRight(idx: Int): Boolean = right(idx) < size\n\n private def swap(i: Int, j: Int): Unit = {\n indexMap += heap(i)._1 -> j\n indexMap += heap(j)._1 -> i\n\n val t = heap(i)\n heap(i) = heap(j)\n heap(j) = t\n }\n\n private def upHeap(idx: Int): Unit = {\n if (!isRoot(idx) && comparator(heap(idx)._2, heap(par(idx))._2)) {\n swap(idx, par(idx))\n upHeap(par(idx))\n }\n }\n\n private def downHeap(idx: Int): Unit = {\n if (hasLeft(idx)) {\n val t = if (hasRight(idx) && comparator(heap(right(idx))._2, heap(left(idx))._2)) {\n right(idx)\n } else {\n left(idx)\n }\n if (comparator(heap(t)._2, heap(idx)._2)) {\n swap(idx, t)\n downHeap(t)\n }\n }\n }\n\n def add(a: A, p: P): Unit = {\n if (size >= maxSize) {\n throw new UnsupportedOperationException()\n } else {\n size += 1\n heap(size - 1) = (a, p)\n indexMap += a -> (size - 1)\n upHeap(size - 1)\n }\n }\n\n def pop(): (A, P) = {\n if (isEmpty) {\n throw new UnsupportedOperationException()\n } else {\n val head = heap(0)\n indexMap -= head._1\n heap(0) = heap(size - 1)\n size -= 1\n downHeap(0)\n head\n }\n }\n\n def upPriority(a: A, p: P): Unit = {\n val idx = indexMap(a)\n heap(idx) = (a, p)\n upHeap(idx)\n }\n }\n\n val sp = shortestPath(x1, y1)\n println(sp(x2)(y2).map{case (a, b) => a + (if (b == 0) 0 else 1)}.min)\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nSnuke, a water strider, lives in a rectangular pond that can be seen as a grid with H east-west rows and W north-south columns. Let (i,j) be the square at the i-th row from the north and j-th column from the west.\n\nSome of the squares have a lotus leaf on it and cannot be entered.\nThe square (i,j) has a lotus leaf on it if c_{ij} is @, and it does not if c_{ij} is ..\n\nIn one stroke, Snuke can move between 1 and K squares (inclusive) toward one of the four directions: north, east, south, and west.\nThe move may not pass through a square with a lotus leaf. Moving to such a square or out of the pond is also forbidden.\n\nFind the minimum number of strokes Snuke takes to travel from the square (x_1,y_1) to (x_2,y_2).\nIf the travel from (x_1,y_1) to (x_2,y_2) is impossible, point out that fact.\n\nConstraints\n\n1 \\leq H,W,K \\leq 10^6\n\nH \\times W \\leq 10^6\n\n1 \\leq x_1,x_2 \\leq H\n\n1 \\leq y_1,y_2 \\leq W\n\nx_1 \\neq x_2 or y_1 \\neq y_2.\n\nc_{i,j} is . or @.\n\nc_{x_1,y_1} = .\n\nc_{x_2,y_2} = .\n\nAll numbers in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\nx_1 y_1 x_2 y_2\nc_{1,1}c_{1,2} .. c_{1,W}\nc_{2,1}c_{2,2} .. c_{2,W}\n:\nc_{H,1}c_{H,2} .. c_{H,W}\n\nOutput\n\nPrint the minimum number of strokes Snuke takes to travel from the square (x_1,y_1) to (x_2,y_2), or print -1 if the travel is impossible.\n\nSample Input 1\n\n3 5 2\n3 2 3 4\n.....\n.@..@\n..@..\n\nSample Output 1\n\n5\n\nInitially, Snuke is at the square (3,2).\nHe can reach the square (3, 4) by making five strokes as follows:\n\nFrom (3, 2), go west one square to (3, 1).\n\nFrom (3, 1), go north two squares to (1, 1).\n\nFrom (1, 1), go east two squares to (1, 3).\n\nFrom (1, 3), go east one square to (1, 4).\n\nFrom (1, 4), go south two squares to (3, 4).\n\nSample Input 2\n\n1 6 4\n1 1 1 6\n......\n\nSample Output 2\n\n2\n\nSample Input 3\n\n3 3 1\n2 1 2 3\n.@.\n.@.\n.@.\n\nSample Output 3\n\n-1", "sample_input": "3 5 2\n3 2 3 4\n.....\n.@..@\n..@..\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02644", "source_text": "Score : 600 points\n\nProblem Statement\n\nSnuke, a water strider, lives in a rectangular pond that can be seen as a grid with H east-west rows and W north-south columns. Let (i,j) be the square at the i-th row from the north and j-th column from the west.\n\nSome of the squares have a lotus leaf on it and cannot be entered.\nThe square (i,j) has a lotus leaf on it if c_{ij} is @, and it does not if c_{ij} is ..\n\nIn one stroke, Snuke can move between 1 and K squares (inclusive) toward one of the four directions: north, east, south, and west.\nThe move may not pass through a square with a lotus leaf. Moving to such a square or out of the pond is also forbidden.\n\nFind the minimum number of strokes Snuke takes to travel from the square (x_1,y_1) to (x_2,y_2).\nIf the travel from (x_1,y_1) to (x_2,y_2) is impossible, point out that fact.\n\nConstraints\n\n1 \\leq H,W,K \\leq 10^6\n\nH \\times W \\leq 10^6\n\n1 \\leq x_1,x_2 \\leq H\n\n1 \\leq y_1,y_2 \\leq W\n\nx_1 \\neq x_2 or y_1 \\neq y_2.\n\nc_{i,j} is . or @.\n\nc_{x_1,y_1} = .\n\nc_{x_2,y_2} = .\n\nAll numbers in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\nx_1 y_1 x_2 y_2\nc_{1,1}c_{1,2} .. c_{1,W}\nc_{2,1}c_{2,2} .. c_{2,W}\n:\nc_{H,1}c_{H,2} .. c_{H,W}\n\nOutput\n\nPrint the minimum number of strokes Snuke takes to travel from the square (x_1,y_1) to (x_2,y_2), or print -1 if the travel is impossible.\n\nSample Input 1\n\n3 5 2\n3 2 3 4\n.....\n.@..@\n..@..\n\nSample Output 1\n\n5\n\nInitially, Snuke is at the square (3,2).\nHe can reach the square (3, 4) by making five strokes as follows:\n\nFrom (3, 2), go west one square to (3, 1).\n\nFrom (3, 1), go north two squares to (1, 1).\n\nFrom (1, 1), go east two squares to (1, 3).\n\nFrom (1, 3), go east one square to (1, 4).\n\nFrom (1, 4), go south two squares to (3, 4).\n\nSample Input 2\n\n1 6 4\n1 1 1 6\n......\n\nSample Output 2\n\n2\n\nSample Input 3\n\n3 3 1\n2 1 2 3\n.@.\n.@.\n.@.\n\nSample Output 3\n\n-1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3555, "cpu_time_ms": 3311, "memory_kb": 301368}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s574889946", "group_id": "codeNet:p02657", "input_text": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val A, B = in.nextInt\n println(A * B)\n}", "language": "Scala", "metadata": {"date": 1591285097, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02657.html", "problem_id": "p02657", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02657/input.txt", "sample_output_relpath": "derived/input_output/data/p02657/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02657/Scala/s574889946.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s574889946", "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 A, B = in.nextInt\n println(A * B)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nCompute A \\times B.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\leq B \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the value A \\times B as an integer.\n\nSample Input 1\n\n2 5\n\nSample Output 1\n\n10\n\nWe have 2 \\times 5 = 10.\n\nSample Input 2\n\n100 100\n\nSample Output 2\n\n10000", "sample_input": "2 5\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02657", "source_text": "Score : 100 points\n\nProblem Statement\n\nCompute A \\times B.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\leq B \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the value A \\times B as an integer.\n\nSample Input 1\n\n2 5\n\nSample Output 1\n\n10\n\nWe have 2 \\times 5 = 10.\n\nSample Input 2\n\n100 100\n\nSample Output 2\n\n10000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 112, "cpu_time_ms": 516, "memory_kb": 55272}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s417826861", "group_id": "codeNet:p02660", "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\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n println(\n recursive(sc.nextLong())\n .filter(_ >= 2)\n .groupBy(identity)\n .map(_._2.length)\n .map(recursive2(_))\n .sum\n )\n }\n\n @scala.annotation.tailrec\n def recursive(N: Long, ret: List[Long] = List(), now: Long = 2): List[Long] = {\n if (N < now * now) ret :+ N\n else if (N % now == 0) recursive(N / now, ret :+ now, now)\n else recursive(N, ret, now + 1)\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}", "language": "Scala", "metadata": {"date": 1591672768, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02660.html", "problem_id": "p02660", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02660/input.txt", "sample_output_relpath": "derived/input_output/data/p02660/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02660/Scala/s417826861.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s417826861", "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\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\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n println(\n recursive(sc.nextLong())\n .filter(_ >= 2)\n .groupBy(identity)\n .map(_._2.length)\n .map(recursive2(_))\n .sum\n )\n }\n\n @scala.annotation.tailrec\n def recursive(N: Long, ret: List[Long] = List(), now: Long = 2): List[Long] = {\n if (N < now * now) ret :+ N\n else if (N % now == 0) recursive(N / now, ret :+ now, now)\n else recursive(N, ret, now + 1)\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}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is a positive integer N. Consider repeatedly applying the operation below on N:\n\nFirst, choose a positive integer z satisfying all of the conditions below:\n\nz can be represented as z=p^e, where p is a prime number and e is a positive integer;\n\nz divides N;\n\nz is different from all integers chosen in previous operations.\n\nThen, replace N with N/z.\n\nFind the maximum number of times the operation can be applied.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum number of times the operation can be applied.\n\nSample Input 1\n\n24\n\nSample Output 1\n\n3\n\nWe can apply the operation three times by, for example, making the following choices:\n\nChoose z=2 (=2^1). (Now we have N=12.)\n\nChoose z=3 (=3^1). (Now we have N=4.)\n\nChoose z=4 (=2^2). (Now we have N=1.)\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0\n\nWe cannot apply the operation at all.\n\nSample Input 3\n\n64\n\nSample Output 3\n\n3\n\nWe can apply the operation three times by, for example, making the following choices:\n\nChoose z=2 (=2^1). (Now we have N=32.)\n\nChoose z=4 (=2^2). (Now we have N=8.)\n\nChoose z=8 (=2^3). (Now we have N=1.)\n\nSample Input 4\n\n1000000007\n\nSample Output 4\n\n1\n\nWe can apply the operation once by, for example, making the following choice:\n\nz=1000000007 (=1000000007^1). (Now we have N=1.)\n\nSample Input 5\n\n997764507000\n\nSample Output 5\n\n7", "sample_input": "24\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02660", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is a positive integer N. Consider repeatedly applying the operation below on N:\n\nFirst, choose a positive integer z satisfying all of the conditions below:\n\nz can be represented as z=p^e, where p is a prime number and e is a positive integer;\n\nz divides N;\n\nz is different from all integers chosen in previous operations.\n\nThen, replace N with N/z.\n\nFind the maximum number of times the operation can be applied.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum number of times the operation can be applied.\n\nSample Input 1\n\n24\n\nSample Output 1\n\n3\n\nWe can apply the operation three times by, for example, making the following choices:\n\nChoose z=2 (=2^1). (Now we have N=12.)\n\nChoose z=3 (=3^1). (Now we have N=4.)\n\nChoose z=4 (=2^2). (Now we have N=1.)\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0\n\nWe cannot apply the operation at all.\n\nSample Input 3\n\n64\n\nSample Output 3\n\n3\n\nWe can apply the operation three times by, for example, making the following choices:\n\nChoose z=2 (=2^1). (Now we have N=32.)\n\nChoose z=4 (=2^2). (Now we have N=8.)\n\nChoose z=8 (=2^3). (Now we have N=1.)\n\nSample Input 4\n\n1000000007\n\nSample Output 4\n\n1\n\nWe can apply the operation once by, for example, making the following choice:\n\nz=1000000007 (=1000000007^1). (Now we have N=1.)\n\nSample Input 5\n\n997764507000\n\nSample Output 5\n\n7", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 9070, "cpu_time_ms": 518, "memory_kb": 55292}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s144695165", "group_id": "codeNet:p02660", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextLong()\n\n def factorize(n: Long): List[Long] = {\n if (n == 1) {\n 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 val factorMap = factorize(n).groupBy(identity).view.mapValues(_.length).toMap\n val counts = factorMap.map{ case (p, k) =>\n var rest = k\n var e = 1\n var ans = 0\n while (e <= rest) {\n ans += 1\n rest -= e\n e += 1\n }\n ans\n }\n\n println(counts.sum)\n}", "language": "Scala", "metadata": {"date": 1590974664, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02660.html", "problem_id": "p02660", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02660/input.txt", "sample_output_relpath": "derived/input_output/data/p02660/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02660/Scala/s144695165.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s144695165", "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.nextLong()\n\n def factorize(n: Long): List[Long] = {\n if (n == 1) {\n 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 val factorMap = factorize(n).groupBy(identity).view.mapValues(_.length).toMap\n val counts = factorMap.map{ case (p, k) =>\n var rest = k\n var e = 1\n var ans = 0\n while (e <= rest) {\n ans += 1\n rest -= e\n e += 1\n }\n ans\n }\n\n println(counts.sum)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is a positive integer N. Consider repeatedly applying the operation below on N:\n\nFirst, choose a positive integer z satisfying all of the conditions below:\n\nz can be represented as z=p^e, where p is a prime number and e is a positive integer;\n\nz divides N;\n\nz is different from all integers chosen in previous operations.\n\nThen, replace N with N/z.\n\nFind the maximum number of times the operation can be applied.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum number of times the operation can be applied.\n\nSample Input 1\n\n24\n\nSample Output 1\n\n3\n\nWe can apply the operation three times by, for example, making the following choices:\n\nChoose z=2 (=2^1). (Now we have N=12.)\n\nChoose z=3 (=3^1). (Now we have N=4.)\n\nChoose z=4 (=2^2). (Now we have N=1.)\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0\n\nWe cannot apply the operation at all.\n\nSample Input 3\n\n64\n\nSample Output 3\n\n3\n\nWe can apply the operation three times by, for example, making the following choices:\n\nChoose z=2 (=2^1). (Now we have N=32.)\n\nChoose z=4 (=2^2). (Now we have N=8.)\n\nChoose z=8 (=2^3). (Now we have N=1.)\n\nSample Input 4\n\n1000000007\n\nSample Output 4\n\n1\n\nWe can apply the operation once by, for example, making the following choice:\n\nz=1000000007 (=1000000007^1). (Now we have N=1.)\n\nSample Input 5\n\n997764507000\n\nSample Output 5\n\n7", "sample_input": "24\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02660", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is a positive integer N. Consider repeatedly applying the operation below on N:\n\nFirst, choose a positive integer z satisfying all of the conditions below:\n\nz can be represented as z=p^e, where p is a prime number and e is a positive integer;\n\nz divides N;\n\nz is different from all integers chosen in previous operations.\n\nThen, replace N with N/z.\n\nFind the maximum number of times the operation can be applied.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum number of times the operation can be applied.\n\nSample Input 1\n\n24\n\nSample Output 1\n\n3\n\nWe can apply the operation three times by, for example, making the following choices:\n\nChoose z=2 (=2^1). (Now we have N=12.)\n\nChoose z=3 (=3^1). (Now we have N=4.)\n\nChoose z=4 (=2^2). (Now we have N=1.)\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0\n\nWe cannot apply the operation at all.\n\nSample Input 3\n\n64\n\nSample Output 3\n\n3\n\nWe can apply the operation three times by, for example, making the following choices:\n\nChoose z=2 (=2^1). (Now we have N=32.)\n\nChoose z=4 (=2^2). (Now we have N=8.)\n\nChoose z=8 (=2^3). (Now we have N=1.)\n\nSample Input 4\n\n1000000007\n\nSample Output 4\n\n1\n\nWe can apply the operation once by, for example, making the following choice:\n\nz=1000000007 (=1000000007^1). (Now we have N=1.)\n\nSample Input 5\n\n997764507000\n\nSample Output 5\n\n7", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 639, "cpu_time_ms": 2205, "memory_kb": 56040}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s736178027", "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\n val amed = if (n % 2 == 1) a((n-1)/2) else a(n/2 - 1) + a(n/2)\n val bmed = if (n % 2 == 1) b((n-1)/2) else b(n/2 - 1) + b(n/2)\n println(bmed - amed + 1)\n}", "language": "Scala", "metadata": {"date": 1590987649, "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/s736178027.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s736178027", "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\n val amed = if (n % 2 == 1) a((n-1)/2) else a(n/2 - 1) + a(n/2)\n val bmed = if (n % 2 == 1) b((n-1)/2) else b(n/2 - 1) + b(n/2)\n println(bmed - amed + 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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 369, "cpu_time_ms": 1567, "memory_kb": 76648}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s513995400", "group_id": "codeNet:p02665", "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 A = new Array[Long](N+1)\n for (i <- 0 to N) {\n A(i) = in.next().toLong\n }\n\n //\n var flag = true\n val dpMax = new Array[Long](N+1)\n var cnt = 1L\n breakable {\n for (i <- 0 to N) {\n cnt -= A(i)\n if (cnt < 0) {\n flag = false\n break\n }\n\n dpMax(i) = cnt min (Long.MaxValue / 100)\n cnt *= 2\n }\n }\n\n\n if (!flag)\n println(-1)\n else if (N == 0) {\n if (A(0) == 1)\n println(1)\n else\n println(-1)\n }\n else {\n var ans = 0L\n var nodes = 0L\n\n breakable {\n for (i <- (0 to N).reverse) {\n val now = A(i)\n\n if ((nodes+1) / 2 > dpMax(i)) {\n flag = false\n break\n }\n else {\n nodes = (nodes min dpMax(i)) + now\n ans += nodes\n }\n }\n }\n\n if (!flag)\n println(-1)\n else\n println(ans)\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": 1590891205, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02665.html", "problem_id": "p02665", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02665/input.txt", "sample_output_relpath": "derived/input_output/data/p02665/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02665/Scala/s513995400.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s513995400", "user_id": "u098968285"}, "prompt_components": {"gold_output": "7\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 A = new Array[Long](N+1)\n for (i <- 0 to N) {\n A(i) = in.next().toLong\n }\n\n //\n var flag = true\n val dpMax = new Array[Long](N+1)\n var cnt = 1L\n breakable {\n for (i <- 0 to N) {\n cnt -= A(i)\n if (cnt < 0) {\n flag = false\n break\n }\n\n dpMax(i) = cnt min (Long.MaxValue / 100)\n cnt *= 2\n }\n }\n\n\n if (!flag)\n println(-1)\n else if (N == 0) {\n if (A(0) == 1)\n println(1)\n else\n println(-1)\n }\n else {\n var ans = 0L\n var nodes = 0L\n\n breakable {\n for (i <- (0 to N).reverse) {\n val now = A(i)\n\n if ((nodes+1) / 2 > dpMax(i)) {\n flag = false\n break\n }\n else {\n nodes = (nodes min dpMax(i)) + now\n ans += nodes\n }\n }\n }\n\n if (!flag)\n println(-1)\n else\n println(ans)\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 : 600 points\n\nProblem Statement\n\nGiven is an integer sequence of length N+1: A_0, A_1, A_2, \\ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \\ldots, N, there are exactly A_d leaves at depth d? If such a tree exists, print the maximum possible number of vertices in such a tree; otherwise, print -1.\n\nNotes\n\nA binary tree is a rooted tree such that each vertex has at most two direct children.\n\nA leaf in a binary tree is a vertex with zero children.\n\nThe depth of a vertex v in a binary tree is the distance from the tree's root to v. (The root has the depth of 0.)\n\nThe depth of a binary tree is the maximum depth of a vertex in the tree.\n\nConstraints\n\n0 \\leq N \\leq 10^5\n\n0 \\leq A_i \\leq 10^{8} (0 \\leq i \\leq N)\n\nA_N \\geq 1\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_0 A_1 A_2 \\cdots A_N\n\nOutput\n\nPrint the answer as an integer.\n\nSample Input 1\n\n3\n0 1 1 2\n\nSample Output 1\n\n7\n\nBelow is the tree with the maximum possible number of vertices. It has seven vertices, so we should print 7.\n\nSample Input 2\n\n4\n0 0 1 0 2\n\nSample Output 2\n\n10\n\nSample Input 3\n\n2\n0 3 1\n\nSample Output 3\n\n-1\n\nSample Input 4\n\n1\n1 1\n\nSample Output 4\n\n-1\n\nSample Input 5\n\n10\n0 0 1 1 2 3 5 8 13 21 34\n\nSample Output 5\n\n264", "sample_input": "3\n0 1 1 2\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02665", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven is an integer sequence of length N+1: A_0, A_1, A_2, \\ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \\ldots, N, there are exactly A_d leaves at depth d? If such a tree exists, print the maximum possible number of vertices in such a tree; otherwise, print -1.\n\nNotes\n\nA binary tree is a rooted tree such that each vertex has at most two direct children.\n\nA leaf in a binary tree is a vertex with zero children.\n\nThe depth of a vertex v in a binary tree is the distance from the tree's root to v. (The root has the depth of 0.)\n\nThe depth of a binary tree is the maximum depth of a vertex in the tree.\n\nConstraints\n\n0 \\leq N \\leq 10^5\n\n0 \\leq A_i \\leq 10^{8} (0 \\leq i \\leq N)\n\nA_N \\geq 1\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_0 A_1 A_2 \\cdots A_N\n\nOutput\n\nPrint the answer as an integer.\n\nSample Input 1\n\n3\n0 1 1 2\n\nSample Output 1\n\n7\n\nBelow is the tree with the maximum possible number of vertices. It has seven vertices, so we should print 7.\n\nSample Input 2\n\n4\n0 0 1 0 2\n\nSample Output 2\n\n10\n\nSample Input 3\n\n2\n0 3 1\n\nSample Output 3\n\n-1\n\nSample Input 4\n\n1\n1 1\n\nSample Output 4\n\n-1\n\nSample Input 5\n\n10\n0 0 1 1 2 3 5 8 13 21 34\n\nSample Output 5\n\n264", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1652, "cpu_time_ms": 610, "memory_kb": 59476}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s424311478", "group_id": "codeNet:p02675", "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, M = sc.nextInt\n val graph = (0 until M).foldLeft(Vector.fill(N)(Vector.empty[Int])) { (acc, _) =>\n val A, B = sc.nextInt - 1\n acc.updated(A, acc(A) :+ B).updated(B, acc(B) :+ A)\n }\n\n val ps = loop(Vector.fill(N)(-1).updated(0, 0), graph(0).map(_ -> 0)).tail\n println(\"Yes\")\n ps.foreach(p => println(p + 1))\n\n @tailrec def loop(acc: Vector[Int], nexts: Vector[(Int, Int)]): Vector[Int] = nexts match {\n case (room, prev) +: rest if acc(room) == -1 =>\n loop(acc.updated(room, prev), rest ++ graph(room).withFilter(r => acc(r) == -1).map(_ -> room))\n case _ +: rest =>\n loop(acc, rest)\n case _ => acc\n }\n\n}\n\n", "language": "Scala", "metadata": {"date": 1591670470, "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/s424311478.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s424311478", "user_id": "u220774651"}, "prompt_components": {"gold_output": "pon\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, M = sc.nextInt\n val graph = (0 until M).foldLeft(Vector.fill(N)(Vector.empty[Int])) { (acc, _) =>\n val A, B = sc.nextInt - 1\n acc.updated(A, acc(A) :+ B).updated(B, acc(B) :+ A)\n }\n\n val ps = loop(Vector.fill(N)(-1).updated(0, 0), graph(0).map(_ -> 0)).tail\n println(\"Yes\")\n ps.foreach(p => println(p + 1))\n\n @tailrec def loop(acc: Vector[Int], nexts: Vector[(Int, Int)]): Vector[Int] = nexts match {\n case (room, prev) +: rest if acc(room) == -1 =>\n loop(acc.updated(room, prev), rest ++ graph(room).withFilter(r => acc(r) == -1).map(_ -> room))\n case _ +: rest =>\n loop(acc, rest)\n case _ => acc\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 512, "memory_kb": 55556}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s475772907", "group_id": "codeNet:p02677", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val A, B, H, M = sc.nextDouble()\n val sideLength = (angle: Double) =>\n math.sqrt(A * A + B * B - 2 * A * B * math.cos(math.toRadians(angle)))\n val hourHandAngle = ((360.0 / (12 * 60.0)) * (H * 60 + M)) % 360.0\n val minuteHandAngle = ((360.0 / 60.0) * M) % 360.0\n println {\n math.abs(hourHandAngle - minuteHandAngle) match {\n case 0.0 => math.abs(A - B)\n case 180.0 => A + B\n case angle if 180.0 < angle => sideLength(360.0 - angle)\n case angle => sideLength(angle)\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1595615019, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02677.html", "problem_id": "p02677", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02677/input.txt", "sample_output_relpath": "derived/input_output/data/p02677/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02677/Scala/s475772907.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s475772907", "user_id": "u737111725"}, "prompt_components": {"gold_output": "5.00000000000000000000\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val A, B, H, M = sc.nextDouble()\n val sideLength = (angle: Double) =>\n math.sqrt(A * A + B * B - 2 * A * B * math.cos(math.toRadians(angle)))\n val hourHandAngle = ((360.0 / (12 * 60.0)) * (H * 60 + M)) % 360.0\n val minuteHandAngle = ((360.0 / 60.0) * M) % 360.0\n println {\n math.abs(hourHandAngle - minuteHandAngle) match {\n case 0.0 => math.abs(A - B)\n case 180.0 => A + B\n case angle if 180.0 < angle => sideLength(360.0 - angle)\n case angle => sideLength(angle)\n }\n }\n}\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nConsider an analog clock whose hour and minute hands are A and B centimeters long, respectively.\n\nAn endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.\n\nAt 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 1000\n\n0 \\leq H \\leq 11\n\n0 \\leq M \\leq 59\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B H M\n\nOutput\n\nPrint the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}.\n\nSample Input 1\n\n3 4 9 0\n\nSample Output 1\n\n5.00000000000000000000\n\nThe two hands will be in the positions shown in the figure below, so the answer is 5 centimeters.\n\nSample Input 2\n\n3 4 10 40\n\nSample Output 2\n\n4.56425719433005567605\n\nThe two hands will be in the positions shown in the figure below. Note that each hand always rotates at constant angular velocity.", "sample_input": "3 4 9 0\n"}, "reference_outputs": ["5.00000000000000000000\n"], "source_document_id": "p02677", "source_text": "Score: 300 points\n\nProblem Statement\n\nConsider an analog clock whose hour and minute hands are A and B centimeters long, respectively.\n\nAn endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.\n\nAt 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 1000\n\n0 \\leq H \\leq 11\n\n0 \\leq M \\leq 59\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B H M\n\nOutput\n\nPrint the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}.\n\nSample Input 1\n\n3 4 9 0\n\nSample Output 1\n\n5.00000000000000000000\n\nThe two hands will be in the positions shown in the figure below, so the answer is 5 centimeters.\n\nSample Input 2\n\n3 4 10 40\n\nSample Output 2\n\n4.56425719433005567605\n\nThe two hands will be in the positions shown in the figure below. Note that each hand always rotates at constant angular velocity.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 579, "cpu_time_ms": 512, "memory_kb": 55448}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s331194081", "group_id": "codeNet:p02677", "input_text": "object Main extends App{\n val input = io.StdIn.readLine.split(' ').map(_.toDouble)\n val A = input(0)\n val B = input(1)\n val H = input(2)\n val M = input(3)\n\n val radH = (H + M / 60d) / 6.0d\n val radM = M / 30.0d\n\n val radD = radH - radM\n\n val posH = (0d, A)\n val posM = (- B*Math.sin(radD * Math.PI), B*Math.cos(radD * Math.PI))\n\n val distance = Math.sqrt( Math.pow(posH._1 - posM._1 , 2) + Math.pow(posH._2 - posM._2, 2) )\n\n printf(\"%.10f\",distance)\n}", "language": "Scala", "metadata": {"date": 1589776961, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02677.html", "problem_id": "p02677", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02677/input.txt", "sample_output_relpath": "derived/input_output/data/p02677/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02677/Scala/s331194081.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s331194081", "user_id": "u473298014"}, "prompt_components": {"gold_output": "5.00000000000000000000\n", "input_to_evaluate": "object Main extends App{\n val input = io.StdIn.readLine.split(' ').map(_.toDouble)\n val A = input(0)\n val B = input(1)\n val H = input(2)\n val M = input(3)\n\n val radH = (H + M / 60d) / 6.0d\n val radM = M / 30.0d\n\n val radD = radH - radM\n\n val posH = (0d, A)\n val posM = (- B*Math.sin(radD * Math.PI), B*Math.cos(radD * Math.PI))\n\n val distance = Math.sqrt( Math.pow(posH._1 - posM._1 , 2) + Math.pow(posH._2 - posM._2, 2) )\n\n printf(\"%.10f\",distance)\n}", "problem_context": "Score: 300 points\n\nProblem Statement\n\nConsider an analog clock whose hour and minute hands are A and B centimeters long, respectively.\n\nAn endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.\n\nAt 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 1000\n\n0 \\leq H \\leq 11\n\n0 \\leq M \\leq 59\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B H M\n\nOutput\n\nPrint the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}.\n\nSample Input 1\n\n3 4 9 0\n\nSample Output 1\n\n5.00000000000000000000\n\nThe two hands will be in the positions shown in the figure below, so the answer is 5 centimeters.\n\nSample Input 2\n\n3 4 10 40\n\nSample Output 2\n\n4.56425719433005567605\n\nThe two hands will be in the positions shown in the figure below. Note that each hand always rotates at constant angular velocity.", "sample_input": "3 4 9 0\n"}, "reference_outputs": ["5.00000000000000000000\n"], "source_document_id": "p02677", "source_text": "Score: 300 points\n\nProblem Statement\n\nConsider an analog clock whose hour and minute hands are A and B centimeters long, respectively.\n\nAn endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.\n\nAt 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 1000\n\n0 \\leq H \\leq 11\n\n0 \\leq M \\leq 59\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B H M\n\nOutput\n\nPrint the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}.\n\nSample Input 1\n\n3 4 9 0\n\nSample Output 1\n\n5.00000000000000000000\n\nThe two hands will be in the positions shown in the figure below, so the answer is 5 centimeters.\n\nSample Input 2\n\n3 4 10 40\n\nSample Output 2\n\n4.56425719433005567605\n\nThe two hands will be in the positions shown in the figure below. Note that each hand always rotates at constant angular velocity.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 464, "cpu_time_ms": 482, "memory_kb": 54832}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s939143958", "group_id": "codeNet:p02677", "input_text": "import java.util.Scanner\n\nimport scala.annotation.tailrec\n\nobject Main {\n def main(args: Array[String]): Unit = {\n //nextLineとnextを同時に使ったら死ぬ\n val sc = new Scanner(System.in)\n\n val a, b, h, m = sc.nextDouble()\n val hh = (h % 12) * 30 + m / 2\n debug(hh)\n val mm = m * 6\n debug(mm)\n val diff = {\n val ss = math.abs(mm - hh)\n math.min(ss, 360 - ss)\n }\n debug(diff)\n val ans = math.sqrt(\n a * a + b * b - 2 * a * b * math\n .cos(math.toRadians(math.round(diff * 1000) / 1000))\n )\n debug(a * a, b * b, -2 * a * b, math.cos(diff))\n println(ans)\n }\n\n //region\n\n def debug(args: Any*): Unit = {\n Console.err.println(args.mkString(\" \"))\n Console.err.flush()\n }\n\n def printExecTime(process: => Unit): Unit = {\n val start = System.currentTimeMillis\n process\n debug(\"処理時間: \" + (System.currentTimeMillis - start) + \" ミリ秒\")\n }\n\n def bitSearch[T](n: Int, choice: Vector[T]): Vector[Vector[T]] = {\n @tailrec\n def bitSearchLogic(n: Int,\n choice: Vector[T],\n acc: Vector[Vector[T]]): Vector[Vector[T]] = {\n if (n == 0) acc\n else {\n val newAcc =\n acc.flatMap(vec => {\n choice.map(c => vec :+ c)\n })\n bitSearchLogic(n - 1, choice, newAcc)\n }\n }\n\n val firstAcc = choice.map(i => Vector(i))\n bitSearchLogic(n - 1, choice, firstAcc)\n }\n //endregion\n}\n", "language": "Scala", "metadata": {"date": 1589764824, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02677.html", "problem_id": "p02677", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02677/input.txt", "sample_output_relpath": "derived/input_output/data/p02677/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02677/Scala/s939143958.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s939143958", "user_id": "u336949031"}, "prompt_components": {"gold_output": "5.00000000000000000000\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.annotation.tailrec\n\nobject Main {\n def main(args: Array[String]): Unit = {\n //nextLineとnextを同時に使ったら死ぬ\n val sc = new Scanner(System.in)\n\n val a, b, h, m = sc.nextDouble()\n val hh = (h % 12) * 30 + m / 2\n debug(hh)\n val mm = m * 6\n debug(mm)\n val diff = {\n val ss = math.abs(mm - hh)\n math.min(ss, 360 - ss)\n }\n debug(diff)\n val ans = math.sqrt(\n a * a + b * b - 2 * a * b * math\n .cos(math.toRadians(math.round(diff * 1000) / 1000))\n )\n debug(a * a, b * b, -2 * a * b, math.cos(diff))\n println(ans)\n }\n\n //region\n\n def debug(args: Any*): Unit = {\n Console.err.println(args.mkString(\" \"))\n Console.err.flush()\n }\n\n def printExecTime(process: => Unit): Unit = {\n val start = System.currentTimeMillis\n process\n debug(\"処理時間: \" + (System.currentTimeMillis - start) + \" ミリ秒\")\n }\n\n def bitSearch[T](n: Int, choice: Vector[T]): Vector[Vector[T]] = {\n @tailrec\n def bitSearchLogic(n: Int,\n choice: Vector[T],\n acc: Vector[Vector[T]]): Vector[Vector[T]] = {\n if (n == 0) acc\n else {\n val newAcc =\n acc.flatMap(vec => {\n choice.map(c => vec :+ c)\n })\n bitSearchLogic(n - 1, choice, newAcc)\n }\n }\n\n val firstAcc = choice.map(i => Vector(i))\n bitSearchLogic(n - 1, choice, firstAcc)\n }\n //endregion\n}\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nConsider an analog clock whose hour and minute hands are A and B centimeters long, respectively.\n\nAn endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.\n\nAt 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 1000\n\n0 \\leq H \\leq 11\n\n0 \\leq M \\leq 59\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B H M\n\nOutput\n\nPrint the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}.\n\nSample Input 1\n\n3 4 9 0\n\nSample Output 1\n\n5.00000000000000000000\n\nThe two hands will be in the positions shown in the figure below, so the answer is 5 centimeters.\n\nSample Input 2\n\n3 4 10 40\n\nSample Output 2\n\n4.56425719433005567605\n\nThe two hands will be in the positions shown in the figure below. Note that each hand always rotates at constant angular velocity.", "sample_input": "3 4 9 0\n"}, "reference_outputs": ["5.00000000000000000000\n"], "source_document_id": "p02677", "source_text": "Score: 300 points\n\nProblem Statement\n\nConsider an analog clock whose hour and minute hands are A and B centimeters long, respectively.\n\nAn endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.\n\nAt 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 1000\n\n0 \\leq H \\leq 11\n\n0 \\leq M \\leq 59\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B H M\n\nOutput\n\nPrint the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}.\n\nSample Input 1\n\n3 4 9 0\n\nSample Output 1\n\n5.00000000000000000000\n\nThe two hands will be in the positions shown in the figure below, so the answer is 5 centimeters.\n\nSample Input 2\n\n3 4 10 40\n\nSample Output 2\n\n4.56425719433005567605\n\nThe two hands will be in the positions shown in the figure below. Note that each hand always rotates at constant angular velocity.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1470, "cpu_time_ms": 511, "memory_kb": 55480}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s788384850", "group_id": "codeNet:p02678", "input_text": "import scala.collection.mutable.{Map => MMap, Queue => MQueue}\nimport scala.io.StdIn.readLine\n\nobject Main extends App\n{\n\ttype PathMap = Map[Int, List[Int]]\n\tval (n, m) = readInts()\n\t\n\tval pathMap: PathMap = (1 to m).foldLeft[PathMap](Map.empty.withDefaultValue(List.empty)) { case (map: PathMap, _) =>\n\t\tval (from, to) = readInts()\n\t\tval fromList = map(from)\n\t\tval toList = map(to)\n\t\tmap.updated(from, to :: fromList).updated(to, from :: toList)\n\t}\n\t\n\tval resultPreMap = calc()\n\tprintln(\"Yes\")\n\t(2 to n).foreach(node => println(resultPreMap(node)))\n\t\n\tprivate def calc(queue: MQueue[Int] = MQueue(1), preMap: MMap[Int, Int] = MMap(1 -> 0)): MMap[Int, Int] =\n\t{\n\t\twhile (queue.nonEmpty) {\n\t\t\tval node = queue.dequeue()\n\t\t\tpathMap(node).foreach { nextNode =>\n\t\t\t\tval pre = preMap.get(nextNode)\n\t\t\t\tif (pre.isEmpty) {\n\t\t\t\t\tqueue += nextNode\n\t\t\t\t\tpreMap += Tuple2(nextNode, node)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tpreMap\n\t}\n\t\n\tprivate def readInts(): (Int, Int) =\n\t{\n\t\tval line = readLine().split(\" \",2).map(_.toInt)\n\t\t(line(0), line(1))\n\t}\n}", "language": "Scala", "metadata": {"date": 1589859920, "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/s788384850.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s788384850", "user_id": "u340881840"}, "prompt_components": {"gold_output": "Yes\n1\n2\n2\n", "input_to_evaluate": "import scala.collection.mutable.{Map => MMap, Queue => MQueue}\nimport scala.io.StdIn.readLine\n\nobject Main extends App\n{\n\ttype PathMap = Map[Int, List[Int]]\n\tval (n, m) = readInts()\n\t\n\tval pathMap: PathMap = (1 to m).foldLeft[PathMap](Map.empty.withDefaultValue(List.empty)) { case (map: PathMap, _) =>\n\t\tval (from, to) = readInts()\n\t\tval fromList = map(from)\n\t\tval toList = map(to)\n\t\tmap.updated(from, to :: fromList).updated(to, from :: toList)\n\t}\n\t\n\tval resultPreMap = calc()\n\tprintln(\"Yes\")\n\t(2 to n).foreach(node => println(resultPreMap(node)))\n\t\n\tprivate def calc(queue: MQueue[Int] = MQueue(1), preMap: MMap[Int, Int] = MMap(1 -> 0)): MMap[Int, Int] =\n\t{\n\t\twhile (queue.nonEmpty) {\n\t\t\tval node = queue.dequeue()\n\t\t\tpathMap(node).foreach { nextNode =>\n\t\t\t\tval pre = preMap.get(nextNode)\n\t\t\t\tif (pre.isEmpty) {\n\t\t\t\t\tqueue += nextNode\n\t\t\t\t\tpreMap += Tuple2(nextNode, node)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tpreMap\n\t}\n\t\n\tprivate def readInts(): (Int, Int) =\n\t{\n\t\tval line = readLine().split(\" \",2).map(_.toInt)\n\t\t(line(0), line(1))\n\t}\n}", "problem_context": "Score: 400 points\n\nProblem Statement\n\nThere is a cave.\n\nThe cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.\n\nIt is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.\n\nSince it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.\n\nIf you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.\n\nDetermine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 2 \\times 10^5\n\n1 \\leq A_i, B_i \\leq N\\ (1 \\leq i \\leq M)\n\nA_i \\neq B_i\\ (1 \\leq i \\leq M)\n\nOne can travel between any two rooms by traversing passages.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput\n\nIf there is no way to place signposts satisfying the objective, print No.\n\nOtherwise, print N lines. The first line should contain Yes, and the i-th line (2 \\leq i \\leq N) should contain the integer representing the room indicated by the signpost in Room i.\n\nSample Input 1\n\n4 4\n1 2\n2 3\n3 4\n4 2\n\nSample Output 1\n\nYes\n1\n2\n2\n\nIf we place the signposts as described in the sample output, the following happens:\n\nStarting in Room 2, you will reach Room 1 after traversing one passage: (2) \\to 1. This is the minimum number of passages possible.\n\nStarting in Room 3, you will reach Room 1 after traversing two passages: (3) \\to 2 \\to 1. This is the minimum number of passages possible.\n\nStarting in Room 4, you will reach Room 1 after traversing two passages: (4) \\to 2 \\to 1. This is the minimum number of passages possible.\n\nThus, the objective is satisfied.\n\nSample Input 2\n\n6 9\n3 4\n6 1\n2 4\n5 3\n4 6\n1 5\n6 2\n4 5\n5 6\n\nSample Output 2\n\nYes\n6\n5\n5\n1\n1\n\nIf there are multiple solutions, any of them will be accepted.", "sample_input": "4 4\n1 2\n2 3\n3 4\n4 2\n"}, "reference_outputs": ["Yes\n1\n2\n2\n"], "source_document_id": "p02678", "source_text": "Score: 400 points\n\nProblem Statement\n\nThere is a cave.\n\nThe cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.\n\nIt is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.\n\nSince it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.\n\nIf you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.\n\nDetermine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 2 \\times 10^5\n\n1 \\leq A_i, B_i \\leq N\\ (1 \\leq i \\leq M)\n\nA_i \\neq B_i\\ (1 \\leq i \\leq M)\n\nOne can travel between any two rooms by traversing passages.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput\n\nIf there is no way to place signposts satisfying the objective, print No.\n\nOtherwise, print N lines. The first line should contain Yes, and the i-th line (2 \\leq i \\leq N) should contain the integer representing the room indicated by the signpost in Room i.\n\nSample Input 1\n\n4 4\n1 2\n2 3\n3 4\n4 2\n\nSample Output 1\n\nYes\n1\n2\n2\n\nIf we place the signposts as described in the sample output, the following happens:\n\nStarting in Room 2, you will reach Room 1 after traversing one passage: (2) \\to 1. This is the minimum number of passages possible.\n\nStarting in Room 3, you will reach Room 1 after traversing two passages: (3) \\to 2 \\to 1. This is the minimum number of passages possible.\n\nStarting in Room 4, you will reach Room 1 after traversing two passages: (4) \\to 2 \\to 1. This is the minimum number of passages possible.\n\nThus, the objective is satisfied.\n\nSample Input 2\n\n6 9\n3 4\n6 1\n2 4\n5 3\n4 6\n1 5\n6 2\n4 5\n5 6\n\nSample Output 2\n\nYes\n6\n5\n5\n1\n1\n\nIf there are multiple solutions, any of them will be accepted.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1022, "cpu_time_ms": 2205, "memory_kb": 102236}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s306940219", "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).map(x => { x._1 -> x._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).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": 1589770234, "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/s306940219.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s306940219", "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).map(x => { x._1 -> x._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).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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2204, "memory_kb": 123832}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s070054113", "group_id": "codeNet:p02678", "input_text": "import java.util.Scanner\n\nimport scala.collection.mutable\n\nobject Main {\n def main(args: Array[String]): Unit = {\n\n val sc = new Scanner(System.in)\n val n = sc.nextInt()\n val m = sc.nextInt()\n\n val ab = Set.fill(m)(Set(sc.nextInt(), sc.nextInt()))\n\n val history = mutable.Set.empty[Int]\n val store = mutable.ArrayBuffer.fill(n)(0)\n val stack = mutable.Stack(1)\n\n def l(p: Int): Unit = {\n history += p\n ab.filter(_.contains(p)).flatten.filter(_ != p).filter(!history.contains(_)).foreach { i =>\n stack.push(i)\n if (store(i - 1) == 0) store(i - 1) = p\n }\n if (stack.nonEmpty) l(stack.pop())\n }\n\n l(stack.pop())\n\n println(\"Yes\")\n store.tail.foreach(println)\n\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1589769529, "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/s070054113.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s070054113", "user_id": "u197909036"}, "prompt_components": {"gold_output": "Yes\n1\n2\n2\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.collection.mutable\n\nobject Main {\n def main(args: Array[String]): Unit = {\n\n val sc = new Scanner(System.in)\n val n = sc.nextInt()\n val m = sc.nextInt()\n\n val ab = Set.fill(m)(Set(sc.nextInt(), sc.nextInt()))\n\n val history = mutable.Set.empty[Int]\n val store = mutable.ArrayBuffer.fill(n)(0)\n val stack = mutable.Stack(1)\n\n def l(p: Int): Unit = {\n history += p\n ab.filter(_.contains(p)).flatten.filter(_ != p).filter(!history.contains(_)).foreach { i =>\n stack.push(i)\n if (store(i - 1) == 0) store(i - 1) = p\n }\n if (stack.nonEmpty) l(stack.pop())\n }\n\n l(stack.pop())\n\n println(\"Yes\")\n store.tail.foreach(println)\n\n }\n\n}\n", "problem_context": "Score: 400 points\n\nProblem Statement\n\nThere is a cave.\n\nThe cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.\n\nIt is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.\n\nSince it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.\n\nIf you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.\n\nDetermine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 2 \\times 10^5\n\n1 \\leq A_i, B_i \\leq N\\ (1 \\leq i \\leq M)\n\nA_i \\neq B_i\\ (1 \\leq i \\leq M)\n\nOne can travel between any two rooms by traversing passages.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput\n\nIf there is no way to place signposts satisfying the objective, print No.\n\nOtherwise, print N lines. The first line should contain Yes, and the i-th line (2 \\leq i \\leq N) should contain the integer representing the room indicated by the signpost in Room i.\n\nSample Input 1\n\n4 4\n1 2\n2 3\n3 4\n4 2\n\nSample Output 1\n\nYes\n1\n2\n2\n\nIf we place the signposts as described in the sample output, the following happens:\n\nStarting in Room 2, you will reach Room 1 after traversing one passage: (2) \\to 1. This is the minimum number of passages possible.\n\nStarting in Room 3, you will reach Room 1 after traversing two passages: (3) \\to 2 \\to 1. This is the minimum number of passages possible.\n\nStarting in Room 4, you will reach Room 1 after traversing two passages: (4) \\to 2 \\to 1. This is the minimum number of passages possible.\n\nThus, the objective is satisfied.\n\nSample Input 2\n\n6 9\n3 4\n6 1\n2 4\n5 3\n4 6\n1 5\n6 2\n4 5\n5 6\n\nSample Output 2\n\nYes\n6\n5\n5\n1\n1\n\nIf there are multiple solutions, any of them will be accepted.", "sample_input": "4 4\n1 2\n2 3\n3 4\n4 2\n"}, "reference_outputs": ["Yes\n1\n2\n2\n"], "source_document_id": "p02678", "source_text": "Score: 400 points\n\nProblem Statement\n\nThere is a cave.\n\nThe cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.\n\nIt is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.\n\nSince it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.\n\nIf you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.\n\nDetermine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 2 \\times 10^5\n\n1 \\leq A_i, B_i \\leq N\\ (1 \\leq i \\leq M)\n\nA_i \\neq B_i\\ (1 \\leq i \\leq M)\n\nOne can travel between any two rooms by traversing passages.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput\n\nIf there is no way to place signposts satisfying the objective, print No.\n\nOtherwise, print N lines. The first line should contain Yes, and the i-th line (2 \\leq i \\leq N) should contain the integer representing the room indicated by the signpost in Room i.\n\nSample Input 1\n\n4 4\n1 2\n2 3\n3 4\n4 2\n\nSample Output 1\n\nYes\n1\n2\n2\n\nIf we place the signposts as described in the sample output, the following happens:\n\nStarting in Room 2, you will reach Room 1 after traversing one passage: (2) \\to 1. This is the minimum number of passages possible.\n\nStarting in Room 3, you will reach Room 1 after traversing two passages: (3) \\to 2 \\to 1. This is the minimum number of passages possible.\n\nStarting in Room 4, you will reach Room 1 after traversing two passages: (4) \\to 2 \\to 1. This is the minimum number of passages possible.\n\nThus, the objective is satisfied.\n\nSample Input 2\n\n6 9\n3 4\n6 1\n2 4\n5 3\n4 6\n1 5\n6 2\n4 5\n5 6\n\nSample Output 2\n\nYes\n6\n5\n5\n1\n1\n\nIf there are multiple solutions, any of them will be accepted.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 734, "cpu_time_ms": 2206, "memory_kb": 86024}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s136662483", "group_id": "codeNet:p02681", "input_text": "import java.util.Scanner\n\nimport scala.io.StdIn._\nobject Main extends App {\n\n val s = scala.io.StdIn.readLine()\n val t = scala.io.StdIn.readLine()\n\n def solve() = {\n if(s + t.last == t) \"Yes\" else \"No\"\n }\n\n println(solve())\n\n}\n\n", "language": "Scala", "metadata": {"date": 1593660789, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02681.html", "problem_id": "p02681", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02681/input.txt", "sample_output_relpath": "derived/input_output/data/p02681/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02681/Scala/s136662483.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s136662483", "user_id": "u947008426"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.io.StdIn._\nobject Main extends App {\n\n val s = scala.io.StdIn.readLine()\n val t = scala.io.StdIn.readLine()\n\n def solve() = {\n if(s + t.last == t) \"Yes\" else \"No\"\n }\n\n println(solve())\n\n}\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi wants to be a member of some web service.\n\nHe tried to register himself with the ID S, which turned out to be already used by another user.\n\nThus, he decides to register using a string obtained by appending one character at the end of S as his ID.\n\nHe is now trying to register with the ID T. Determine whether this string satisfies the property above.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\n1 \\leq |S| \\leq 10\n\n|T| = |S| + 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf T satisfies the property in Problem Statement, print Yes; otherwise, print No.\n\nSample Input 1\n\nchokudai\nchokudaiz\n\nSample Output 1\n\nYes\n\nchokudaiz can be obtained by appending z at the end of chokudai.\n\nSample Input 2\n\nsnuke\nsnekee\n\nSample Output 2\n\nNo\n\nsnekee cannot be obtained by appending one character at the end of snuke.\n\nSample Input 3\n\na\naa\n\nSample Output 3\n\nYes", "sample_input": "chokudai\nchokudaiz\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02681", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi wants to be a member of some web service.\n\nHe tried to register himself with the ID S, which turned out to be already used by another user.\n\nThus, he decides to register using a string obtained by appending one character at the end of S as his ID.\n\nHe is now trying to register with the ID T. Determine whether this string satisfies the property above.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\n1 \\leq |S| \\leq 10\n\n|T| = |S| + 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf T satisfies the property in Problem Statement, print Yes; otherwise, print No.\n\nSample Input 1\n\nchokudai\nchokudaiz\n\nSample Output 1\n\nYes\n\nchokudaiz can be obtained by appending z at the end of chokudai.\n\nSample Input 2\n\nsnuke\nsnekee\n\nSample Output 2\n\nNo\n\nsnekee cannot be obtained by appending one character at the end of snuke.\n\nSample Input 3\n\na\naa\n\nSample Output 3\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 236, "cpu_time_ms": 489, "memory_kb": 54724}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s319199737", "group_id": "codeNet:p02681", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val S, T = sc.nextLine\n\n val x = if (T.take(S.length) == S) \"Yes\" else \"No\"\n println(x)\n}", "language": "Scala", "metadata": {"date": 1589158884, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02681.html", "problem_id": "p02681", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02681/input.txt", "sample_output_relpath": "derived/input_output/data/p02681/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02681/Scala/s319199737.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s319199737", "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 S, T = sc.nextLine\n\n val x = if (T.take(S.length) == S) \"Yes\" else \"No\"\n println(x)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi wants to be a member of some web service.\n\nHe tried to register himself with the ID S, which turned out to be already used by another user.\n\nThus, he decides to register using a string obtained by appending one character at the end of S as his ID.\n\nHe is now trying to register with the ID T. Determine whether this string satisfies the property above.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\n1 \\leq |S| \\leq 10\n\n|T| = |S| + 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf T satisfies the property in Problem Statement, print Yes; otherwise, print No.\n\nSample Input 1\n\nchokudai\nchokudaiz\n\nSample Output 1\n\nYes\n\nchokudaiz can be obtained by appending z at the end of chokudai.\n\nSample Input 2\n\nsnuke\nsnekee\n\nSample Output 2\n\nNo\n\nsnekee cannot be obtained by appending one character at the end of snuke.\n\nSample Input 3\n\na\naa\n\nSample Output 3\n\nYes", "sample_input": "chokudai\nchokudaiz\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02681", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi wants to be a member of some web service.\n\nHe tried to register himself with the ID S, which turned out to be already used by another user.\n\nThus, he decides to register using a string obtained by appending one character at the end of S as his ID.\n\nHe is now trying to register with the ID T. Determine whether this string satisfies the property above.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\n1 \\leq |S| \\leq 10\n\n|T| = |S| + 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf T satisfies the property in Problem Statement, print Yes; otherwise, print No.\n\nSample Input 1\n\nchokudai\nchokudaiz\n\nSample Output 1\n\nYes\n\nchokudaiz can be obtained by appending z at the end of chokudai.\n\nSample Input 2\n\nsnuke\nsnekee\n\nSample Output 2\n\nNo\n\nsnekee cannot be obtained by appending one character at the end of snuke.\n\nSample Input 3\n\na\naa\n\nSample Output 3\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 179, "cpu_time_ms": 503, "memory_kb": 55232}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s831459760", "group_id": "codeNet:p02682", "input_text": "import java.util.Scanner\n\nimport scala.io.StdIn._\nobject Main extends App {\n\n val Array(a,b,c,k) = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n\n def solve() = {\n k match {\n case x if x <= a => 1 * x\n case x if x >= a && x <= a+b => a\n case x if x >= a+b && x <= a+b+c => a - (x - a - b)\n case _ => a - c\n }\n }\n\n println(solve())\n\n}\n\n", "language": "Scala", "metadata": {"date": 1593662001, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02682.html", "problem_id": "p02682", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02682/input.txt", "sample_output_relpath": "derived/input_output/data/p02682/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02682/Scala/s831459760.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s831459760", "user_id": "u947008426"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.io.StdIn._\nobject Main extends App {\n\n val Array(a,b,c,k) = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n\n def solve() = {\n k match {\n case x if x <= a => 1 * x\n case x if x >= a && x <= a+b => a\n case x if x >= a+b && x <= a+b+c => a - (x - a - b)\n case _ => a - c\n }\n }\n\n println(solve())\n\n}\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.\n\nWe will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A, B, C\n\n1 \\leq K \\leq A + B + C \\leq 2 \\times 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the maximum possible sum of the numbers written on the cards chosen.\n\nSample Input 1\n\n2 1 1 3\n\nSample Output 1\n\n2\n\nConsider picking up two cards with 1s and one card with a 0.\nIn this case, the sum of the numbers written on the cards is 2, which is the maximum possible value.\n\nSample Input 2\n\n1 2 3 4\n\nSample Output 2\n\n0\n\nSample Input 3\n\n2000000000 0 0 2000000000\n\nSample Output 3\n\n2000000000", "sample_input": "2 1 1 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02682", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.\n\nWe will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A, B, C\n\n1 \\leq K \\leq A + B + C \\leq 2 \\times 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the maximum possible sum of the numbers written on the cards chosen.\n\nSample Input 1\n\n2 1 1 3\n\nSample Output 1\n\n2\n\nConsider picking up two cards with 1s and one card with a 0.\nIn this case, the sum of the numbers written on the cards is 2, which is the maximum possible value.\n\nSample Input 2\n\n1 2 3 4\n\nSample Output 2\n\n0\n\nSample Input 3\n\n2000000000 0 0 2000000000\n\nSample Output 3\n\n2000000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 369, "cpu_time_ms": 491, "memory_kb": 54816}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s915068192", "group_id": "codeNet:p02682", "input_text": "import java.util.Scanner\n\nimport scala.collection.mutable.ArrayBuffer\nimport scala.util.control.Breaks\nimport scala.math.abs\n\nobject Main extends App {\n\n val sc = new Scanner(System.in)\n val a, b, c, k = sc.nextLong()\n\n val res = (if (a >= k) {\n a\n } else if (a + b >= k) {\n a\n } else {\n a * 1 + ((k - a - b) * -1)\n })\n\n println(res)\n}\n", "language": "Scala", "metadata": {"date": 1589160910, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02682.html", "problem_id": "p02682", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02682/input.txt", "sample_output_relpath": "derived/input_output/data/p02682/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02682/Scala/s915068192.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s915068192", "user_id": "u197909036"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.collection.mutable.ArrayBuffer\nimport scala.util.control.Breaks\nimport scala.math.abs\n\nobject Main extends App {\n\n val sc = new Scanner(System.in)\n val a, b, c, k = sc.nextLong()\n\n val res = (if (a >= k) {\n a\n } else if (a + b >= k) {\n a\n } else {\n a * 1 + ((k - a - b) * -1)\n })\n\n println(res)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.\n\nWe will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A, B, C\n\n1 \\leq K \\leq A + B + C \\leq 2 \\times 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the maximum possible sum of the numbers written on the cards chosen.\n\nSample Input 1\n\n2 1 1 3\n\nSample Output 1\n\n2\n\nConsider picking up two cards with 1s and one card with a 0.\nIn this case, the sum of the numbers written on the cards is 2, which is the maximum possible value.\n\nSample Input 2\n\n1 2 3 4\n\nSample Output 2\n\n0\n\nSample Input 3\n\n2000000000 0 0 2000000000\n\nSample Output 3\n\n2000000000", "sample_input": "2 1 1 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02682", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.\n\nWe will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A, B, C\n\n1 \\leq K \\leq A + B + C \\leq 2 \\times 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the maximum possible sum of the numbers written on the cards chosen.\n\nSample Input 1\n\n2 1 1 3\n\nSample Output 1\n\n2\n\nConsider picking up two cards with 1s and one card with a 0.\nIn this case, the sum of the numbers written on the cards is 2, which is the maximum possible value.\n\nSample Input 2\n\n1 2 3 4\n\nSample Output 2\n\n0\n\nSample Input 3\n\n2000000000 0 0 2000000000\n\nSample Output 3\n\n2000000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 352, "cpu_time_ms": 476, "memory_kb": 55408}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s015713539", "group_id": "codeNet:p02683", "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\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val N, M = sc.nextInt()\n val X = sc.nextLong()\n val A = Array.fill(N)((sc.nextLong(), Array.fill(M)(sc.nextLong())))\n println(\n (0 until 1 << N).map(now =>\n A.zipWithIndex.filter { case (_, idx) => (now & 1 << idx) != 0 }\n .map(now => (now._1._1, now._1._2))\n .foldLeft((0L, Array.fill(M)(0L)))((a, b) =>\n (a._1 + b._1, a._2.zip(b._2).map { case (x, y) => x + y })\n )\n ).filter { case (_, b) => b.forall(_ >= X) }\n .map(_._1)\n .minOption\n .getOrElse(-1)\n )\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": 1589845965, "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/s015713539.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s015713539", "user_id": "u779353743"}, "prompt_components": {"gold_output": "120\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\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val N, M = sc.nextInt()\n val X = sc.nextLong()\n val A = Array.fill(N)((sc.nextLong(), Array.fill(M)(sc.nextLong())))\n println(\n (0 until 1 << N).map(now =>\n A.zipWithIndex.filter { case (_, idx) => (now & 1 << idx) != 0 }\n .map(now => (now._1._1, now._1._2))\n .foldLeft((0L, Array.fill(M)(0L)))((a, b) =>\n (a._1 + b._1, a._2.zip(b._2).map { case (x, y) => x + y })\n )\n ).filter { case (_, b) => b.forall(_ >= X) }\n .map(_._1)\n .minOption\n .getOrElse(-1)\n )\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 : 300 points\n\nProblem\n\nTakahashi, who is a novice in competitive programming, wants to learn M algorithms.\nInitially, his understanding level of each of the M algorithms is 0.\n\nTakahashi is visiting a bookstore, where he finds N books on algorithms.\nThe i-th book (1\\leq i\\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\\leq j\\leq M).\nThere is no other way to increase the understanding levels of the algorithms.\n\nTakahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.\n\nConstraints\n\nAll values in input are integers.\n\n1\\leq N, M\\leq 12\n\n1\\leq X\\leq 10^5\n\n1\\leq C_i \\leq 10^5\n\n0\\leq A_{i, j} \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M X\nC_1 A_{1,1} A_{1,2} \\cdots A_{1,M}\nC_2 A_{2,1} A_{2,2} \\cdots A_{2,M}\n\\vdots\nC_N A_{N,1} A_{N,2} \\cdots A_{N,M}\n\nOutput\n\nIf the objective is not achievable, print -1; otherwise, print the minimum amount of money needed to achieve it.\n\nSample Input 1\n\n3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9\n\nSample Output 1\n\n120\n\nBuying the second and third books makes his understanding levels of all the algorithms 10 or higher, at the minimum cost possible.\n\nSample Input 2\n\n3 3 10\n100 3 1 4\n100 1 5 9\n100 2 6 5\n\nSample Output 2\n\n-1\n\nBuying all the books is still not enough to make his understanding levels of all the algorithms 10 or higher.\n\nSample Input 3\n\n8 5 22\n100 3 7 5 3 1\n164 4 5 2 7 8\n334 7 2 7 2 9\n234 4 7 2 8 2\n541 5 4 3 3 6\n235 4 8 6 9 7\n394 3 6 1 6 2\n872 8 4 3 7 2\n\nSample Output 3\n\n1067", "sample_input": "3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9\n"}, "reference_outputs": ["120\n"], "source_document_id": "p02683", "source_text": "Score : 300 points\n\nProblem\n\nTakahashi, who is a novice in competitive programming, wants to learn M algorithms.\nInitially, his understanding level of each of the M algorithms is 0.\n\nTakahashi is visiting a bookstore, where he finds N books on algorithms.\nThe i-th book (1\\leq i\\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\\leq j\\leq M).\nThere is no other way to increase the understanding levels of the algorithms.\n\nTakahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.\n\nConstraints\n\nAll values in input are integers.\n\n1\\leq N, M\\leq 12\n\n1\\leq X\\leq 10^5\n\n1\\leq C_i \\leq 10^5\n\n0\\leq A_{i, j} \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M X\nC_1 A_{1,1} A_{1,2} \\cdots A_{1,M}\nC_2 A_{2,1} A_{2,2} \\cdots A_{2,M}\n\\vdots\nC_N A_{N,1} A_{N,2} \\cdots A_{N,M}\n\nOutput\n\nIf the objective is not achievable, print -1; otherwise, print the minimum amount of money needed to achieve it.\n\nSample Input 1\n\n3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9\n\nSample Output 1\n\n120\n\nBuying the second and third books makes his understanding levels of all the algorithms 10 or higher, at the minimum cost possible.\n\nSample Input 2\n\n3 3 10\n100 3 1 4\n100 1 5 9\n100 2 6 5\n\nSample Output 2\n\n-1\n\nBuying all the books is still not enough to make his understanding levels of all the algorithms 10 or higher.\n\nSample Input 3\n\n8 5 22\n100 3 7 5 3 1\n164 4 5 2 7 8\n334 7 2 7 2 9\n234 4 7 2 8 2\n541 5 4 3 3 6\n235 4 8 6 9 7\n394 3 6 1 6 2\n872 8 4 3 7 2\n\nSample Output 3\n\n1067", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 9231, "cpu_time_ms": 676, "memory_kb": 59116}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s738351121", "group_id": "codeNet:p02683", "input_text": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\n\ncase class Book(cost: Int, skills: Array[Int])\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, x) = in.readLine().split(\"\\\\s+\").map(_.toInt)\n val books = Array.fill(n) {\n val line = in.readLine().split(\"\\\\s+\").map(_.toInt)\n Book(line(0), line.slice(1, line.length))\n }\n\n var minCost = Int.MaxValue\n\n for (i <- 0 until Math.pow(2, n).toInt) {\n val readBooks = books.foldLeft[(List[Book], Int)]((Nil, i)) {\n case ((acc, q), book) =>\n if ((q & 1) == 1) {\n (book :: acc, q >> 1)\n } else {\n (acc, q >> 1)\n }\n }._1\n var cost = 0\n val skill = Array.ofDim[Int](m)\n for (book <- readBooks) {\n cost += book.cost\n for (i <- skill.indices) {\n skill(i) += book.skills(i)\n }\n }\n if (skill.forall(_ >= x)) {\n minCost = Math.min(minCost, cost)\n }\n }\n\n out.println(\n if (minCost == Int.MaxValue) {\n -1\n } else {\n minCost\n }\n )\n\n out.flush()\n }\n}\n", "language": "Scala", "metadata": {"date": 1589163441, "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/s738351121.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s738351121", "user_id": "u178269371"}, "prompt_components": {"gold_output": "120\n", "input_to_evaluate": "import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}\n\ncase class Book(cost: Int, skills: Array[Int])\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, x) = in.readLine().split(\"\\\\s+\").map(_.toInt)\n val books = Array.fill(n) {\n val line = in.readLine().split(\"\\\\s+\").map(_.toInt)\n Book(line(0), line.slice(1, line.length))\n }\n\n var minCost = Int.MaxValue\n\n for (i <- 0 until Math.pow(2, n).toInt) {\n val readBooks = books.foldLeft[(List[Book], Int)]((Nil, i)) {\n case ((acc, q), book) =>\n if ((q & 1) == 1) {\n (book :: acc, q >> 1)\n } else {\n (acc, q >> 1)\n }\n }._1\n var cost = 0\n val skill = Array.ofDim[Int](m)\n for (book <- readBooks) {\n cost += book.cost\n for (i <- skill.indices) {\n skill(i) += book.skills(i)\n }\n }\n if (skill.forall(_ >= x)) {\n minCost = Math.min(minCost, cost)\n }\n }\n\n out.println(\n if (minCost == Int.MaxValue) {\n -1\n } else {\n minCost\n }\n )\n\n out.flush()\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem\n\nTakahashi, who is a novice in competitive programming, wants to learn M algorithms.\nInitially, his understanding level of each of the M algorithms is 0.\n\nTakahashi is visiting a bookstore, where he finds N books on algorithms.\nThe i-th book (1\\leq i\\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\\leq j\\leq M).\nThere is no other way to increase the understanding levels of the algorithms.\n\nTakahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.\n\nConstraints\n\nAll values in input are integers.\n\n1\\leq N, M\\leq 12\n\n1\\leq X\\leq 10^5\n\n1\\leq C_i \\leq 10^5\n\n0\\leq A_{i, j} \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M X\nC_1 A_{1,1} A_{1,2} \\cdots A_{1,M}\nC_2 A_{2,1} A_{2,2} \\cdots A_{2,M}\n\\vdots\nC_N A_{N,1} A_{N,2} \\cdots A_{N,M}\n\nOutput\n\nIf the objective is not achievable, print -1; otherwise, print the minimum amount of money needed to achieve it.\n\nSample Input 1\n\n3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9\n\nSample Output 1\n\n120\n\nBuying the second and third books makes his understanding levels of all the algorithms 10 or higher, at the minimum cost possible.\n\nSample Input 2\n\n3 3 10\n100 3 1 4\n100 1 5 9\n100 2 6 5\n\nSample Output 2\n\n-1\n\nBuying all the books is still not enough to make his understanding levels of all the algorithms 10 or higher.\n\nSample Input 3\n\n8 5 22\n100 3 7 5 3 1\n164 4 5 2 7 8\n334 7 2 7 2 9\n234 4 7 2 8 2\n541 5 4 3 3 6\n235 4 8 6 9 7\n394 3 6 1 6 2\n872 8 4 3 7 2\n\nSample Output 3\n\n1067", "sample_input": "3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9\n"}, "reference_outputs": ["120\n"], "source_document_id": "p02683", "source_text": "Score : 300 points\n\nProblem\n\nTakahashi, who is a novice in competitive programming, wants to learn M algorithms.\nInitially, his understanding level of each of the M algorithms is 0.\n\nTakahashi is visiting a bookstore, where he finds N books on algorithms.\nThe i-th book (1\\leq i\\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\\leq j\\leq M).\nThere is no other way to increase the understanding levels of the algorithms.\n\nTakahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.\n\nConstraints\n\nAll values in input are integers.\n\n1\\leq N, M\\leq 12\n\n1\\leq X\\leq 10^5\n\n1\\leq C_i \\leq 10^5\n\n0\\leq A_{i, j} \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M X\nC_1 A_{1,1} A_{1,2} \\cdots A_{1,M}\nC_2 A_{2,1} A_{2,2} \\cdots A_{2,M}\n\\vdots\nC_N A_{N,1} A_{N,2} \\cdots A_{N,M}\n\nOutput\n\nIf the objective is not achievable, print -1; otherwise, print the minimum amount of money needed to achieve it.\n\nSample Input 1\n\n3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9\n\nSample Output 1\n\n120\n\nBuying the second and third books makes his understanding levels of all the algorithms 10 or higher, at the minimum cost possible.\n\nSample Input 2\n\n3 3 10\n100 3 1 4\n100 1 5 9\n100 2 6 5\n\nSample Output 2\n\n-1\n\nBuying all the books is still not enough to make his understanding levels of all the algorithms 10 or higher.\n\nSample Input 3\n\n8 5 22\n100 3 7 5 3 1\n164 4 5 2 7 8\n334 7 2 7 2 9\n234 4 7 2 8 2\n541 5 4 3 3 6\n235 4 8 6 9 7\n394 3 6 1 6 2\n872 8 4 3 7 2\n\nSample Output 3\n\n1067", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1276, "cpu_time_ms": 553, "memory_kb": 56340}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s137398885", "group_id": "codeNet:p02683", "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, m, x = Scanner.nextInt\n\n\tcase class Book(c: Int, a: Array[Int])\n\tval bs = Seq.fill(n)(Book(Scanner.nextInt, Array.fill(m)(Scanner.nextInt)))\n\n\tval ans = (1 to n).flatMap(bs combinations _).collect{case b if (b.map(_.a).transpose.map(_.sum).forall(_ >= x)) => b.map(_.c).sum}\n\n\tpw.println(if (ans.isEmpty) -1 else ans.min)\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": 1589160377, "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/s137398885.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s137398885", "user_id": "u822029894"}, "prompt_components": {"gold_output": "120\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, m, x = Scanner.nextInt\n\n\tcase class Book(c: Int, a: Array[Int])\n\tval bs = Seq.fill(n)(Book(Scanner.nextInt, Array.fill(m)(Scanner.nextInt)))\n\n\tval ans = (1 to n).flatMap(bs combinations _).collect{case b if (b.map(_.a).transpose.map(_.sum).forall(_ >= x)) => b.map(_.c).sum}\n\n\tpw.println(if (ans.isEmpty) -1 else ans.min)\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 : 300 points\n\nProblem\n\nTakahashi, who is a novice in competitive programming, wants to learn M algorithms.\nInitially, his understanding level of each of the M algorithms is 0.\n\nTakahashi is visiting a bookstore, where he finds N books on algorithms.\nThe i-th book (1\\leq i\\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\\leq j\\leq M).\nThere is no other way to increase the understanding levels of the algorithms.\n\nTakahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.\n\nConstraints\n\nAll values in input are integers.\n\n1\\leq N, M\\leq 12\n\n1\\leq X\\leq 10^5\n\n1\\leq C_i \\leq 10^5\n\n0\\leq A_{i, j} \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M X\nC_1 A_{1,1} A_{1,2} \\cdots A_{1,M}\nC_2 A_{2,1} A_{2,2} \\cdots A_{2,M}\n\\vdots\nC_N A_{N,1} A_{N,2} \\cdots A_{N,M}\n\nOutput\n\nIf the objective is not achievable, print -1; otherwise, print the minimum amount of money needed to achieve it.\n\nSample Input 1\n\n3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9\n\nSample Output 1\n\n120\n\nBuying the second and third books makes his understanding levels of all the algorithms 10 or higher, at the minimum cost possible.\n\nSample Input 2\n\n3 3 10\n100 3 1 4\n100 1 5 9\n100 2 6 5\n\nSample Output 2\n\n-1\n\nBuying all the books is still not enough to make his understanding levels of all the algorithms 10 or higher.\n\nSample Input 3\n\n8 5 22\n100 3 7 5 3 1\n164 4 5 2 7 8\n334 7 2 7 2 9\n234 4 7 2 8 2\n541 5 4 3 3 6\n235 4 8 6 9 7\n394 3 6 1 6 2\n872 8 4 3 7 2\n\nSample Output 3\n\n1067", "sample_input": "3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9\n"}, "reference_outputs": ["120\n"], "source_document_id": "p02683", "source_text": "Score : 300 points\n\nProblem\n\nTakahashi, who is a novice in competitive programming, wants to learn M algorithms.\nInitially, his understanding level of each of the M algorithms is 0.\n\nTakahashi is visiting a bookstore, where he finds N books on algorithms.\nThe i-th book (1\\leq i\\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\\leq j\\leq M).\nThere is no other way to increase the understanding levels of the algorithms.\n\nTakahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.\n\nConstraints\n\nAll values in input are integers.\n\n1\\leq N, M\\leq 12\n\n1\\leq X\\leq 10^5\n\n1\\leq C_i \\leq 10^5\n\n0\\leq A_{i, j} \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M X\nC_1 A_{1,1} A_{1,2} \\cdots A_{1,M}\nC_2 A_{2,1} A_{2,2} \\cdots A_{2,M}\n\\vdots\nC_N A_{N,1} A_{N,2} \\cdots A_{N,M}\n\nOutput\n\nIf the objective is not achievable, print -1; otherwise, print the minimum amount of money needed to achieve it.\n\nSample Input 1\n\n3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9\n\nSample Output 1\n\n120\n\nBuying the second and third books makes his understanding levels of all the algorithms 10 or higher, at the minimum cost possible.\n\nSample Input 2\n\n3 3 10\n100 3 1 4\n100 1 5 9\n100 2 6 5\n\nSample Output 2\n\n-1\n\nBuying all the books is still not enough to make his understanding levels of all the algorithms 10 or higher.\n\nSample Input 3\n\n8 5 22\n100 3 7 5 3 1\n164 4 5 2 7 8\n334 7 2 7 2 9\n234 4 7 2 8 2\n541 5 4 3 3 6\n235 4 8 6 9 7\n394 3 6 1 6 2\n872 8 4 3 7 2\n\nSample Output 3\n\n1067", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1732, "cpu_time_ms": 722, "memory_kb": 59332}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s295366730", "group_id": "codeNet:p02687", "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 out.println(\n if (s == \"ABC\") {\n \"ARC\"\n } else {\n \"ABC\"\n }\n )\n\n out.flush()\n }\n}\n", "language": "Scala", "metadata": {"date": 1588554070, "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/s295366730.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s295366730", "user_id": "u178269371"}, "prompt_components": {"gold_output": "ARC\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 out.println(\n if (s == \"ABC\") {\n \"ARC\"\n } else {\n \"ABC\"\n }\n )\n\n out.flush()\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 425, "cpu_time_ms": 489, "memory_kb": 54580}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s144495322", "group_id": "codeNet:p02689", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n, m = sc.nextInt\n val h = Seq.fill(n)(sc.nextInt)\n\n var good_t = (1 to n).toSet\n\n for (_ <- 1 to m) {\n val a, b = sc.nextInt\n\n if (h(a - 1) >= h(b - 1)) {\n good_t = good_t - b\n } else {\n good_t = good_t - a\n }\n }\n\n print(good_t.size)\n}\n", "language": "Scala", "metadata": {"date": 1588559735, "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/s144495322.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s144495322", "user_id": "u015315385"}, "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, m = sc.nextInt\n val h = Seq.fill(n)(sc.nextInt)\n\n var good_t = (1 to n).toSet\n\n for (_ <- 1 to m) {\n val a, b = sc.nextInt\n\n if (h(a - 1) >= h(b - 1)) {\n good_t = good_t - b\n } else {\n good_t = good_t - a\n }\n }\n\n print(good_t.size)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2205, "memory_kb": 55628}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s142216178", "group_id": "codeNet:p02690", "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 X = sc.nextLong()\n val A = (0L to 1100L).map(x => (recursive(x), x)).toMap\n val ans =\n A.keys.toList.combinations(2)\n .filter(x => Math.abs(x(0) - x(1)) == X || Math.abs(x(0) + x(1)) == X)\n .toList.head\n val ans1 = A(ans(0))\n val ans2 = A(ans(1))\n if (recursive(ans1) - recursive(ans2) == X) println(ans1 + \" \" + ans2)\n else if (recursive(ans1) + recursive(ans2) == X) println(ans1 + \" \" + -ans2)\n else if (-recursive(ans1) + recursive(ans2) == X) println(-ans1 + \" \" + ans2)\n else if (-recursive(ans1) - recursive(ans2) == X) println(-ans1 + \" \" + -ans2)\n }\n\n @scala.annotation.tailrec\n def recursive(input: Long, ret: Long = 1, num: Long = 5): Long = {\n if (num == 0) ret\n else recursive(input, ret * input, num - 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": 1588991150, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02690.html", "problem_id": "p02690", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02690/input.txt", "sample_output_relpath": "derived/input_output/data/p02690/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02690/Scala/s142216178.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s142216178", "user_id": "u779353743"}, "prompt_components": {"gold_output": "2 -1\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 X = sc.nextLong()\n val A = (0L to 1100L).map(x => (recursive(x), x)).toMap\n val ans =\n A.keys.toList.combinations(2)\n .filter(x => Math.abs(x(0) - x(1)) == X || Math.abs(x(0) + x(1)) == X)\n .toList.head\n val ans1 = A(ans(0))\n val ans2 = A(ans(1))\n if (recursive(ans1) - recursive(ans2) == X) println(ans1 + \" \" + ans2)\n else if (recursive(ans1) + recursive(ans2) == X) println(ans1 + \" \" + -ans2)\n else if (-recursive(ans1) + recursive(ans2) == X) println(-ans1 + \" \" + ans2)\n else if (-recursive(ans1) - recursive(ans2) == X) println(-ans1 + \" \" + -ans2)\n }\n\n @scala.annotation.tailrec\n def recursive(input: Long, ret: Long = 1, num: Long = 5): Long = {\n if (num == 0) ret\n else recursive(input, ret * input, num - 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 : 400 points\n\nProblem Statement\n\nGive a pair of integers (A, B) such that A^5-B^5 = X.\nIt is guaranteed that there exists such a pair for the given integer X.\n\nConstraints\n\n1 \\leq X \\leq 10^9\n\nX is an integer.\n\nThere exists a pair of integers (A, B) satisfying the condition in Problem Statement.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint A and B, with space in between.\nIf there are multiple pairs of integers (A, B) satisfying the condition, you may print any of them.\n\nA B\n\nSample Input 1\n\n33\n\nSample Output 1\n\n2 -1\n\nFor A=2 and B=-1, A^5-B^5 = 33.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0 -1", "sample_input": "33\n"}, "reference_outputs": ["2 -1\n"], "source_document_id": "p02690", "source_text": "Score : 400 points\n\nProblem Statement\n\nGive a pair of integers (A, B) such that A^5-B^5 = X.\nIt is guaranteed that there exists such a pair for the given integer X.\n\nConstraints\n\n1 \\leq X \\leq 10^9\n\nX is an integer.\n\nThere exists a pair of integers (A, B) satisfying the condition in Problem Statement.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint A and B, with space in between.\nIf there are multiple pairs of integers (A, B) satisfying the condition, you may print any of them.\n\nA B\n\nSample Input 1\n\n33\n\nSample Output 1\n\n2 -1\n\nFor A=2 and B=-1, A^5-B^5 = 33.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0 -1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 9254, "cpu_time_ms": 1686, "memory_kb": 58444}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s801202392", "group_id": "codeNet:p02690", "input_text": "import java.util\n\nimport scala.io.StdIn.readLine\nimport scala.io.StdIn.readInt\nimport java.util.Scanner\nimport java.util.ArrayList\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val x = sc.nextLong()\n val f = (x:Long)=>x*x*x*x*x\n for(i <- -1000 to 1000 ;j<- -1000 to 1000){\n if(f(i) - f(j) == x){\n println(f\"$i $j\")\n System.exit(0)\n }\n }\n\n\n\n\n\n}", "language": "Scala", "metadata": {"date": 1588630219, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02690.html", "problem_id": "p02690", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02690/input.txt", "sample_output_relpath": "derived/input_output/data/p02690/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02690/Scala/s801202392.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s801202392", "user_id": "u093219895"}, "prompt_components": {"gold_output": "2 -1\n", "input_to_evaluate": "import java.util\n\nimport scala.io.StdIn.readLine\nimport scala.io.StdIn.readInt\nimport java.util.Scanner\nimport java.util.ArrayList\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val x = sc.nextLong()\n val f = (x:Long)=>x*x*x*x*x\n for(i <- -1000 to 1000 ;j<- -1000 to 1000){\n if(f(i) - f(j) == x){\n println(f\"$i $j\")\n System.exit(0)\n }\n }\n\n\n\n\n\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGive a pair of integers (A, B) such that A^5-B^5 = X.\nIt is guaranteed that there exists such a pair for the given integer X.\n\nConstraints\n\n1 \\leq X \\leq 10^9\n\nX is an integer.\n\nThere exists a pair of integers (A, B) satisfying the condition in Problem Statement.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint A and B, with space in between.\nIf there are multiple pairs of integers (A, B) satisfying the condition, you may print any of them.\n\nA B\n\nSample Input 1\n\n33\n\nSample Output 1\n\n2 -1\n\nFor A=2 and B=-1, A^5-B^5 = 33.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0 -1", "sample_input": "33\n"}, "reference_outputs": ["2 -1\n"], "source_document_id": "p02690", "source_text": "Score : 400 points\n\nProblem Statement\n\nGive a pair of integers (A, B) such that A^5-B^5 = X.\nIt is guaranteed that there exists such a pair for the given integer X.\n\nConstraints\n\n1 \\leq X \\leq 10^9\n\nX is an integer.\n\nThere exists a pair of integers (A, B) satisfying the condition in Problem Statement.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint A and B, with space in between.\nIf there are multiple pairs of integers (A, B) satisfying the condition, you may print any of them.\n\nA B\n\nSample Input 1\n\n33\n\nSample Output 1\n\n2 -1\n\nFor A=2 and B=-1, A^5-B^5 = 33.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0 -1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 379, "cpu_time_ms": 529, "memory_kb": 55676}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s769237637", "group_id": "codeNet:p02690", "input_text": "import scala.io.StdIn._\nobject Main {\n def main(args:Array[String]) {\n val X = readLine().toLong\n\n var A = 0d\n var B = 0\n var flag = true\n var i = 1\n while(flag) {\n if(i % 2 == 0) B += 1\n else B *= -1\n A = Math.pow(X + Math.pow(B, 5), 1d / 5)\n if(A - A.toInt == 0) flag = false\n i += 1\n }\n println(A.toInt + \" \" + B)\n }\n}\n\n\n", "language": "Scala", "metadata": {"date": 1588559671, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02690.html", "problem_id": "p02690", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02690/input.txt", "sample_output_relpath": "derived/input_output/data/p02690/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02690/Scala/s769237637.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s769237637", "user_id": "u240766189"}, "prompt_components": {"gold_output": "2 -1\n", "input_to_evaluate": "import scala.io.StdIn._\nobject Main {\n def main(args:Array[String]) {\n val X = readLine().toLong\n\n var A = 0d\n var B = 0\n var flag = true\n var i = 1\n while(flag) {\n if(i % 2 == 0) B += 1\n else B *= -1\n A = Math.pow(X + Math.pow(B, 5), 1d / 5)\n if(A - A.toInt == 0) flag = false\n i += 1\n }\n println(A.toInt + \" \" + B)\n }\n}\n\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGive a pair of integers (A, B) such that A^5-B^5 = X.\nIt is guaranteed that there exists such a pair for the given integer X.\n\nConstraints\n\n1 \\leq X \\leq 10^9\n\nX is an integer.\n\nThere exists a pair of integers (A, B) satisfying the condition in Problem Statement.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint A and B, with space in between.\nIf there are multiple pairs of integers (A, B) satisfying the condition, you may print any of them.\n\nA B\n\nSample Input 1\n\n33\n\nSample Output 1\n\n2 -1\n\nFor A=2 and B=-1, A^5-B^5 = 33.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0 -1", "sample_input": "33\n"}, "reference_outputs": ["2 -1\n"], "source_document_id": "p02690", "source_text": "Score : 400 points\n\nProblem Statement\n\nGive a pair of integers (A, B) such that A^5-B^5 = X.\nIt is guaranteed that there exists such a pair for the given integer X.\n\nConstraints\n\n1 \\leq X \\leq 10^9\n\nX is an integer.\n\nThere exists a pair of integers (A, B) satisfying the condition in Problem Statement.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint A and B, with space in between.\nIf there are multiple pairs of integers (A, B) satisfying the condition, you may print any of them.\n\nA B\n\nSample Input 1\n\n33\n\nSample Output 1\n\n2 -1\n\nFor A=2 and B=-1, A^5-B^5 = 33.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0 -1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 375, "cpu_time_ms": 2205, "memory_kb": 54244}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s227712224", "group_id": "codeNet:p02693", "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\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val K, A, B = sc.nextLong()\n println(if (B / K - A / K != 0 || B % K == 0) \"OK\" else \"NG\")\n }\n\n @scala.annotation.tailrec\n def recursive(N: Long, ret: List[Long] = List(), now: Long = 2): List[Long] = {\n if (N < now * now) ret :+ N\n else if (N % now == 0) recursive(N / now, ret :+ now, now)\n else recursive(N, ret, now + 1)\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}", "language": "Scala", "metadata": {"date": 1591837339, "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/s227712224.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s227712224", "user_id": "u779353743"}, "prompt_components": {"gold_output": "OK\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\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val K, A, B = sc.nextLong()\n println(if (B / K - A / K != 0 || B % K == 0) \"OK\" else \"NG\")\n }\n\n @scala.annotation.tailrec\n def recursive(N: Long, ret: List[Long] = List(), now: Long = 2): List[Long] = {\n if (N < now * now) ret :+ N\n else if (N % now == 0) recursive(N / now, ret :+ now, now)\n else recursive(N, ret, now + 1)\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}", "problem_context": "Score: 100 points\n\nProblem Statement\n\nTakahashi the Jumbo will practice golf.\n\nHis objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 1000\n\n1 \\leq K \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nA B\n\nOutput\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nSample Input 1\n\n7\n500 600\n\nSample Output 1\n\nOK\n\nAmong the multiples of 7, for example, 567 lies between 500 and 600.\n\nSample Input 2\n\n4\n5 7\n\nSample Output 2\n\nNG\n\nNo multiple of 4 lies between 5 and 7.\n\nSample Input 3\n\n1\n11 11\n\nSample Output 3\n\nOK", "sample_input": "7\n500 600\n"}, "reference_outputs": ["OK\n"], "source_document_id": "p02693", "source_text": "Score: 100 points\n\nProblem Statement\n\nTakahashi the Jumbo will practice golf.\n\nHis objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 1000\n\n1 \\leq K \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nA B\n\nOutput\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nSample Input 1\n\n7\n500 600\n\nSample Output 1\n\nOK\n\nAmong the multiples of 7, for example, 567 lies between 500 and 600.\n\nSample Input 2\n\n4\n5 7\n\nSample Output 2\n\nNG\n\nNo multiple of 4 lies between 5 and 7.\n\nSample Input 3\n\n1\n11 11\n\nSample Output 3\n\nOK", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 9000, "cpu_time_ms": 526, "memory_kb": 54864}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s316195260", "group_id": "codeNet:p02693", "input_text": "object Main extends App {\n import io.StdIn._\n \n val k = readInt()\n val Array(a, b) =\n readLine()\n .split(\" \")\n .map(_.toInt)\n \n var m = a\n var pass = false\n while (m < b && !pass) {\n if (m % k == 0)\n pass = true\n\n m += 1\n }\n\n println {\n if (pass) \"OK\"\n else \"NO\"\n }\n}", "language": "Scala", "metadata": {"date": 1591831523, "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/s316195260.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s316195260", "user_id": "u426724213"}, "prompt_components": {"gold_output": "OK\n", "input_to_evaluate": "object Main extends App {\n import io.StdIn._\n \n val k = readInt()\n val Array(a, b) =\n readLine()\n .split(\" \")\n .map(_.toInt)\n \n var m = a\n var pass = false\n while (m < b && !pass) {\n if (m % k == 0)\n pass = true\n\n m += 1\n }\n\n println {\n if (pass) \"OK\"\n else \"NO\"\n }\n}", "problem_context": "Score: 100 points\n\nProblem Statement\n\nTakahashi the Jumbo will practice golf.\n\nHis objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 1000\n\n1 \\leq K \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nA B\n\nOutput\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nSample Input 1\n\n7\n500 600\n\nSample Output 1\n\nOK\n\nAmong the multiples of 7, for example, 567 lies between 500 and 600.\n\nSample Input 2\n\n4\n5 7\n\nSample Output 2\n\nNG\n\nNo multiple of 4 lies between 5 and 7.\n\nSample Input 3\n\n1\n11 11\n\nSample Output 3\n\nOK", "sample_input": "7\n500 600\n"}, "reference_outputs": ["OK\n"], "source_document_id": "p02693", "source_text": "Score: 100 points\n\nProblem Statement\n\nTakahashi the Jumbo will practice golf.\n\nHis objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 1000\n\n1 \\leq K \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nA B\n\nOutput\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nSample Input 1\n\n7\n500 600\n\nSample Output 1\n\nOK\n\nAmong the multiples of 7, for example, 567 lies between 500 and 600.\n\nSample Input 2\n\n4\n5 7\n\nSample Output 2\n\nNG\n\nNo multiple of 4 lies between 5 and 7.\n\nSample Input 3\n\n1\n11 11\n\nSample Output 3\n\nOK", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 310, "cpu_time_ms": 520, "memory_kb": 54788}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s861985537", "group_id": "codeNet:p02693", "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 k, a, b = Scanner.nextInt\n\n\tpw.println( if (a == b || (1 to (b-a) filter (_ % k == 0)).nonEmpty) \"OK\" else \"NG\" )\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": 1588468852, "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/s861985537.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s861985537", "user_id": "u822029894"}, "prompt_components": {"gold_output": "OK\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 k, a, b = Scanner.nextInt\n\n\tpw.println( if (a == b || (1 to (b-a) filter (_ % k == 0)).nonEmpty) \"OK\" else \"NG\" )\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: 100 points\n\nProblem Statement\n\nTakahashi the Jumbo will practice golf.\n\nHis objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 1000\n\n1 \\leq K \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nA B\n\nOutput\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nSample Input 1\n\n7\n500 600\n\nSample Output 1\n\nOK\n\nAmong the multiples of 7, for example, 567 lies between 500 and 600.\n\nSample Input 2\n\n4\n5 7\n\nSample Output 2\n\nNG\n\nNo multiple of 4 lies between 5 and 7.\n\nSample Input 3\n\n1\n11 11\n\nSample Output 3\n\nOK", "sample_input": "7\n500 600\n"}, "reference_outputs": ["OK\n"], "source_document_id": "p02693", "source_text": "Score: 100 points\n\nProblem Statement\n\nTakahashi the Jumbo will practice golf.\n\nHis objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 1000\n\n1 \\leq K \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nA B\n\nOutput\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nSample Input 1\n\n7\n500 600\n\nSample Output 1\n\nOK\n\nAmong the multiples of 7, for example, 567 lies between 500 and 600.\n\nSample Input 2\n\n4\n5 7\n\nSample Output 2\n\nNG\n\nNo multiple of 4 lies between 5 and 7.\n\nSample Input 3\n\n1\n11 11\n\nSample Output 3\n\nOK", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1521, "cpu_time_ms": 477, "memory_kb": 54716}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s060683321", "group_id": "codeNet:p02693", "input_text": "object Main extends App{\n val k = scala.io.StdIn.readInt\n val Array(a,b) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n if((a to b).map(_%k).contains(0)) println (\"OK\")\n else println(\"NG\")\n}\n", "language": "Scala", "metadata": {"date": 1588468803, "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/s060683321.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s060683321", "user_id": "u104354966"}, "prompt_components": {"gold_output": "OK\n", "input_to_evaluate": "object Main extends App{\n val k = scala.io.StdIn.readInt\n val Array(a,b) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n if((a to b).map(_%k).contains(0)) println (\"OK\")\n else println(\"NG\")\n}\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nTakahashi the Jumbo will practice golf.\n\nHis objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 1000\n\n1 \\leq K \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nA B\n\nOutput\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nSample Input 1\n\n7\n500 600\n\nSample Output 1\n\nOK\n\nAmong the multiples of 7, for example, 567 lies between 500 and 600.\n\nSample Input 2\n\n4\n5 7\n\nSample Output 2\n\nNG\n\nNo multiple of 4 lies between 5 and 7.\n\nSample Input 3\n\n1\n11 11\n\nSample Output 3\n\nOK", "sample_input": "7\n500 600\n"}, "reference_outputs": ["OK\n"], "source_document_id": "p02693", "source_text": "Score: 100 points\n\nProblem Statement\n\nTakahashi the Jumbo will practice golf.\n\nHis objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 1000\n\n1 \\leq K \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nA B\n\nOutput\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nSample Input 1\n\n7\n500 600\n\nSample Output 1\n\nOK\n\nAmong the multiples of 7, for example, 567 lies between 500 and 600.\n\nSample Input 2\n\n4\n5 7\n\nSample Output 2\n\nNG\n\nNo multiple of 4 lies between 5 and 7.\n\nSample Input 3\n\n1\n11 11\n\nSample Output 3\n\nOK", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 199, "cpu_time_ms": 502, "memory_kb": 54848}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s901405817", "group_id": "codeNet:p02693", "input_text": "import scala.util.control.Breaks\n\nobject Main extends App {\n val k = scala.io.StdIn.readInt()\n val ab = scala.io.StdIn.readLine()\n val abArray = ab.split(\" \").map(_.toInt).toSeq\n val a = abArray(0)\n val b = abArray(1)\n var okFlg = false\n\n val break = new Breaks\n break.breakable {\n (a to b).foreach { i =>\n if (i % k == 0) {\n okFlg = true\n break.break()\n }\n }\n }\n if (okFlg) println(\"OK\") else println(\"NG\")\n}", "language": "Scala", "metadata": {"date": 1588468556, "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/s901405817.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s901405817", "user_id": "u105921924"}, "prompt_components": {"gold_output": "OK\n", "input_to_evaluate": "import scala.util.control.Breaks\n\nobject Main extends App {\n val k = scala.io.StdIn.readInt()\n val ab = scala.io.StdIn.readLine()\n val abArray = ab.split(\" \").map(_.toInt).toSeq\n val a = abArray(0)\n val b = abArray(1)\n var okFlg = false\n\n val break = new Breaks\n break.breakable {\n (a to b).foreach { i =>\n if (i % k == 0) {\n okFlg = true\n break.break()\n }\n }\n }\n if (okFlg) println(\"OK\") else println(\"NG\")\n}", "problem_context": "Score: 100 points\n\nProblem Statement\n\nTakahashi the Jumbo will practice golf.\n\nHis objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 1000\n\n1 \\leq K \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nA B\n\nOutput\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nSample Input 1\n\n7\n500 600\n\nSample Output 1\n\nOK\n\nAmong the multiples of 7, for example, 567 lies between 500 and 600.\n\nSample Input 2\n\n4\n5 7\n\nSample Output 2\n\nNG\n\nNo multiple of 4 lies between 5 and 7.\n\nSample Input 3\n\n1\n11 11\n\nSample Output 3\n\nOK", "sample_input": "7\n500 600\n"}, "reference_outputs": ["OK\n"], "source_document_id": "p02693", "source_text": "Score: 100 points\n\nProblem Statement\n\nTakahashi the Jumbo will practice golf.\n\nHis objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 1000\n\n1 \\leq K \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nA B\n\nOutput\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nSample Input 1\n\n7\n500 600\n\nSample Output 1\n\nOK\n\nAmong the multiples of 7, for example, 567 lies between 500 and 600.\n\nSample Input 2\n\n4\n5 7\n\nSample Output 2\n\nNG\n\nNo multiple of 4 lies between 5 and 7.\n\nSample Input 3\n\n1\n11 11\n\nSample Output 3\n\nOK", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 451, "cpu_time_ms": 521, "memory_kb": 54736}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s447206427", "group_id": "codeNet:p02694", "input_text": "object Main {\n import scala.io.StdIn.readLine\n def main(args: Array[String]): Unit = {\n val x = readLine.trim().toLong\n var current = 100L\n\n var i = 0\n while(current < x) {\n current += (current * 0.01).toLong\n i += 1\n }\n println(i)\n }\n}\n", "language": "Scala", "metadata": {"date": 1588681723, "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/s447206427.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s447206427", "user_id": "u291133005"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main {\n import scala.io.StdIn.readLine\n def main(args: Array[String]): Unit = {\n val x = readLine.trim().toLong\n var current = 100L\n\n var i = 0\n while(current < x) {\n current += (current * 0.01).toLong\n i += 1\n }\n println(i)\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.\n\nThe bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)\n\nAssuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?\n\nConstraints\n\n101 \\le X \\le 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the number of years it takes for Takahashi's balance to reach X yen or above for the first time.\n\nSample Input 1\n\n103\n\nSample Output 1\n\n3\n\nThe balance after one year is 101 yen.\n\nThe balance after two years is 102 yen.\n\nThe balance after three years is 103 yen.\n\nThus, it takes three years for the balance to reach 103 yen or above.\n\nSample Input 2\n\n1000000000000000000\n\nSample Output 2\n\n3760\n\nSample Input 3\n\n1333333333\n\nSample Output 3\n\n1706", "sample_input": "103\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02694", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.\n\nThe bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)\n\nAssuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?\n\nConstraints\n\n101 \\le X \\le 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the number of years it takes for Takahashi's balance to reach X yen or above for the first time.\n\nSample Input 1\n\n103\n\nSample Output 1\n\n3\n\nThe balance after one year is 101 yen.\n\nThe balance after two years is 102 yen.\n\nThe balance after three years is 103 yen.\n\nThus, it takes three years for the balance to reach 103 yen or above.\n\nSample Input 2\n\n1000000000000000000\n\nSample Output 2\n\n3760\n\nSample Input 3\n\n1333333333\n\nSample Output 3\n\n1706", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 268, "cpu_time_ms": 501, "memory_kb": 54536}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s252205552", "group_id": "codeNet:p02695", "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 def ** (exp: Int): Int = scala.math.pow(i, exp).intValue\n }\n\n implicit class LongImplicits(val i: Long) {\n def isEven = i % 2 == 0\n def isOdd = !isEven\n\n def ** (exp: Long): Long = scala.math.pow(i, exp).longValue\n }\n}\n\nobject Main extends App {\n import Helpers._\n\n val Array(n, m, q) = readIntLine\n val as = for (_ <- 0 until q) yield readIntLine\n\n def mycomb[T](n: Int, l: List[T]): List[List[T]] =\n n match {\n case 0 => List(List())\n case _ => for(el <- l;\n sl <- mycomb(n-1, l dropWhile { _ != el } ))\n yield el :: sl\n }\n \n def comb[T](n: Int, l: List[T]): List[List[T]] = mycomb(n, l.distinct)\n\n val candidate = comb(n, (1 to m).toList)\n\n println((for {\n x <- candidate\n } yield (for {\n a <- as\n if x(a(1) - 1) - x(a(0) - 1) == a(2)\n } yield a(3)).sum).max)\n}\n\n", "language": "Scala", "metadata": {"date": 1589083123, "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/s252205552.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s252205552", "user_id": "u174523836"}, "prompt_components": {"gold_output": "110\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 def ** (exp: Int): Int = scala.math.pow(i, exp).intValue\n }\n\n implicit class LongImplicits(val i: Long) {\n def isEven = i % 2 == 0\n def isOdd = !isEven\n\n def ** (exp: Long): Long = scala.math.pow(i, exp).longValue\n }\n}\n\nobject Main extends App {\n import Helpers._\n\n val Array(n, m, q) = readIntLine\n val as = for (_ <- 0 until q) yield readIntLine\n\n def mycomb[T](n: Int, l: List[T]): List[List[T]] =\n n match {\n case 0 => List(List())\n case _ => for(el <- l;\n sl <- mycomb(n-1, l dropWhile { _ != el } ))\n yield el :: sl\n }\n \n def comb[T](n: Int, l: List[T]): List[List[T]] = mycomb(n, l.distinct)\n\n val candidate = comb(n, (1 to m).toList)\n\n println((for {\n x <- candidate\n } yield (for {\n a <- as\n if x(a(1) - 1) - x(a(0) - 1) == a(2)\n } yield a(3)).sum).max)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1192, "cpu_time_ms": 1294, "memory_kb": 94656}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s020739232", "group_id": "codeNet:p02696", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n\n val Array(a, b, n) = StdIn.readLine().split(\" \").map(_.toLong)\n val x = n / (b - 1) * (b - 1)\n println(f(x))\n\n def f(x: Long) = (a * x) / b - a * (x / b)\n\n def readIntPair: (Int, Int) = {\n val Array(x, y) = StdIn.readLine().split(\" \").map(_.toInt)\n (x, y)\n }\n\n def readIntArr = StdIn.readLine().split(\" \").map(_.toInt)\n}", "language": "Scala", "metadata": {"date": 1589702226, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02696.html", "problem_id": "p02696", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02696/input.txt", "sample_output_relpath": "derived/input_output/data/p02696/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02696/Scala/s020739232.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s020739232", "user_id": "u208733542"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n\n val Array(a, b, n) = StdIn.readLine().split(\" \").map(_.toLong)\n val x = n / (b - 1) * (b - 1)\n println(f(x))\n\n def f(x: Long) = (a * x) / b - a * (x / b)\n\n def readIntPair: (Int, Int) = {\n val Array(x, y) = StdIn.readLine().split(\" \").map(_.toInt)\n (x, y)\n }\n\n def readIntArr = StdIn.readLine().split(\" \").map(_.toInt)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are integers A, B, and N.\n\nFind the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.\n\nHere floor(t) denotes the greatest integer not greater than the real number t.\n\nConstraints\n\n1 ≤ A ≤ 10^{6}\n\n1 ≤ B ≤ 10^{12}\n\n1 ≤ N ≤ 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B N\n\nOutput\n\nPrint the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.\n\nSample Input 1\n\n5 7 4\n\nSample Output 1\n\n2\n\nWhen x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.\n\nSample Input 2\n\n11 10 9\n\nSample Output 2\n\n9", "sample_input": "5 7 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02696", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are integers A, B, and N.\n\nFind the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.\n\nHere floor(t) denotes the greatest integer not greater than the real number t.\n\nConstraints\n\n1 ≤ A ≤ 10^{6}\n\n1 ≤ B ≤ 10^{12}\n\n1 ≤ N ≤ 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B N\n\nOutput\n\nPrint the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.\n\nSample Input 1\n\n5 7 4\n\nSample Output 1\n\n2\n\nWhen x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.\n\nSample Input 2\n\n11 10 9\n\nSample Output 2\n\n9", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 384, "cpu_time_ms": 488, "memory_kb": 54836}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s901741269", "group_id": "codeNet:p02701", "input_text": "import java.security.KeyStore.TrustedCertificateEntry\nimport java.util\nimport java.util.regex.Pattern\nimport java.util.{ArrayList, Collections, Comparator, List => JList}\n\nimport scala.collection.immutable.TreeMap\nimport scala.math._\nimport scala.collection.mutable\nimport scala.collection.mutable.{ArrayBuffer, ListBuffer}\nimport scala.util.{Failure, Success, Try}\n\nobject Main{\n val LS = \"\\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(LS);\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 Array(n, q) = input.split(LINE_SEPARATOR).head.split(\" \").map(_.toInt)\n// val a = input.split(LINE_SEPARATOR).tail.take(n).map(_.split(\" \").head.toInt)\n// val b = input.split(LINE_SEPARATOR).tail.take(n).map(_.split(\" \").tail.head.toInt)\n// val c = input.split(LINE_SEPARATOR).drop(n + 1).map(_.split(\" \").head.toInt)\n// val d = input.split(LINE_SEPARATOR).drop(n + 1).map(_.split(\" \").tail.head.toInt)\n// val k = 2 * pow(10, 5).toInt\n// val INF = pow(10, 9).toInt + 1\n// val pqMap = (0 until k).map(_ => new mutable.TreeMap[Int, Int]).toArray\n// def add(k: Int, ai: Int): Unit = {\n// val count = pqMap(k).getOrElse(ai, 0)\n// pqMap(k) += ai -> (count + 1)\n// }\n// def delete(k: Int, ai: Int): Unit = {\n// val count = pqMap(k).getOrElse(ai, 0)\n// if (count == 1) pqMap(k) -= ai else pqMap(k) += ai -> (count - 1)\n// }\n// val i2k = (0 until n).map{i =>\n// b(i)\n// }.toArray\n// (0 until n).foreach{i =>\n// add(b(i) - 1, a(i))\n// }\n// val maxList = pqMap.map(pq => if (pq.nonEmpty) pq.last._1 else INF)\n//\n// (0 until q).map{j =>\n// add(d(j) - 1, a(c(j) - 1))\n// delete(i2k(c(j) - 1) - 1, a(c(j) - 1))\n// maxList(i2k(c(j) - 1) - 1) =\n// if (pqMap(i2k(c(j) - 1) - 1).nonEmpty) pqMap(i2k(c(j) - 1) - 1).last._1 else INF\n// i2k(c(j) - 1) = d(j)\n// maxList(d(j) - 1) = if (pqMap(d(j) - 1).nonEmpty) pqMap(d(j) - 1).last._1 else INF\n// maxList.min\n// }.mkString(LINE_SEPARATOR)\n// }\n\n def solve(input: String): String = {\n val n = input.split(LS).head.toInt\n input.split(LS).tail.distinct.size.toString\n }\n\n def divideDigits(num: Long, base: Long = 10L): List[Long] = {\n def proc(num: Long, base: Long, flg: Boolean): List[Long] = {\n var flag = flg\n val quotient = num / base\n val remainder = if (num % base == 0) {\n flag = true\n base\n } else if (flag) {\n flag = false\n val temp = num % base - 1\n if (temp == 0) {\n flag = true\n base - 1\n } else temp\n } else {\n flag = flg\n num % base\n }\n quotient match {\n case 0 =>\n if (flag) {\n List.empty\n } else List(remainder)\n case _ => remainder :: proc(quotient, base, flag)\n }\n }\n\n proc(num, base, false).reverse//.filterNot(_ == 0)\n }\n\n\n def medianCalculator(seq: Seq[Long]): Long = {\n //In order if you are not sure that 'seq' is sorted\n val sortedSeq = seq.sortWith(_ < _)\n\n if (seq.size % 2 == 1) sortedSeq(sortedSeq.size / 2)\n else {\n val (up, down) = sortedSeq.splitAt(seq.size / 2)\n (up.last + down.head) / 2\n }\n }\n\n def factorize(x: Long): List[Long] = {\n def foo(x: Long, a: Long = 2, list: List[Long] = Nil): List[Long] = a*a > x match {\n case false if x % a == 0 => foo(x / a, a , a :: list)\n case false => foo(x , a + 1, list)\n case true => x :: list\n }\n foo(x)\n }\n\n def divisors(n: Int): Vector[Int] = {\n val halfList = (1 to sqrt(n).toInt).toVector.filter(n % _ == 0).map(_.toInt)\n val reversedList = if (sqrt(n).floor == sqrt(n)) halfList.reverse.tail.map(n/_) else halfList.reverse.map(n/_)\n halfList ++ reversedList\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 \"\"\"3\n |apple\n |orange\n |apple\"\"\".stripMargin -> \"\"\"2\n |\n |\n |\n |\n |\"\"\".stripMargin\n ,\n \"\"\"5\n |grape\n |grape\n |grape\n |grape\n |grape\"\"\".stripMargin -> \"\"\"1\n |\"\"\".stripMargin\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\n\n\n}\n", "language": "Scala", "metadata": {"date": 1592880342, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02701.html", "problem_id": "p02701", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02701/input.txt", "sample_output_relpath": "derived/input_output/data/p02701/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02701/Scala/s901741269.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s901741269", "user_id": "u114537090"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.security.KeyStore.TrustedCertificateEntry\nimport java.util\nimport java.util.regex.Pattern\nimport java.util.{ArrayList, Collections, Comparator, List => JList}\n\nimport scala.collection.immutable.TreeMap\nimport scala.math._\nimport scala.collection.mutable\nimport scala.collection.mutable.{ArrayBuffer, ListBuffer}\nimport scala.util.{Failure, Success, Try}\n\nobject Main{\n val LS = \"\\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(LS);\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 Array(n, q) = input.split(LINE_SEPARATOR).head.split(\" \").map(_.toInt)\n// val a = input.split(LINE_SEPARATOR).tail.take(n).map(_.split(\" \").head.toInt)\n// val b = input.split(LINE_SEPARATOR).tail.take(n).map(_.split(\" \").tail.head.toInt)\n// val c = input.split(LINE_SEPARATOR).drop(n + 1).map(_.split(\" \").head.toInt)\n// val d = input.split(LINE_SEPARATOR).drop(n + 1).map(_.split(\" \").tail.head.toInt)\n// val k = 2 * pow(10, 5).toInt\n// val INF = pow(10, 9).toInt + 1\n// val pqMap = (0 until k).map(_ => new mutable.TreeMap[Int, Int]).toArray\n// def add(k: Int, ai: Int): Unit = {\n// val count = pqMap(k).getOrElse(ai, 0)\n// pqMap(k) += ai -> (count + 1)\n// }\n// def delete(k: Int, ai: Int): Unit = {\n// val count = pqMap(k).getOrElse(ai, 0)\n// if (count == 1) pqMap(k) -= ai else pqMap(k) += ai -> (count - 1)\n// }\n// val i2k = (0 until n).map{i =>\n// b(i)\n// }.toArray\n// (0 until n).foreach{i =>\n// add(b(i) - 1, a(i))\n// }\n// val maxList = pqMap.map(pq => if (pq.nonEmpty) pq.last._1 else INF)\n//\n// (0 until q).map{j =>\n// add(d(j) - 1, a(c(j) - 1))\n// delete(i2k(c(j) - 1) - 1, a(c(j) - 1))\n// maxList(i2k(c(j) - 1) - 1) =\n// if (pqMap(i2k(c(j) - 1) - 1).nonEmpty) pqMap(i2k(c(j) - 1) - 1).last._1 else INF\n// i2k(c(j) - 1) = d(j)\n// maxList(d(j) - 1) = if (pqMap(d(j) - 1).nonEmpty) pqMap(d(j) - 1).last._1 else INF\n// maxList.min\n// }.mkString(LINE_SEPARATOR)\n// }\n\n def solve(input: String): String = {\n val n = input.split(LS).head.toInt\n input.split(LS).tail.distinct.size.toString\n }\n\n def divideDigits(num: Long, base: Long = 10L): List[Long] = {\n def proc(num: Long, base: Long, flg: Boolean): List[Long] = {\n var flag = flg\n val quotient = num / base\n val remainder = if (num % base == 0) {\n flag = true\n base\n } else if (flag) {\n flag = false\n val temp = num % base - 1\n if (temp == 0) {\n flag = true\n base - 1\n } else temp\n } else {\n flag = flg\n num % base\n }\n quotient match {\n case 0 =>\n if (flag) {\n List.empty\n } else List(remainder)\n case _ => remainder :: proc(quotient, base, flag)\n }\n }\n\n proc(num, base, false).reverse//.filterNot(_ == 0)\n }\n\n\n def medianCalculator(seq: Seq[Long]): Long = {\n //In order if you are not sure that 'seq' is sorted\n val sortedSeq = seq.sortWith(_ < _)\n\n if (seq.size % 2 == 1) sortedSeq(sortedSeq.size / 2)\n else {\n val (up, down) = sortedSeq.splitAt(seq.size / 2)\n (up.last + down.head) / 2\n }\n }\n\n def factorize(x: Long): List[Long] = {\n def foo(x: Long, a: Long = 2, list: List[Long] = Nil): List[Long] = a*a > x match {\n case false if x % a == 0 => foo(x / a, a , a :: list)\n case false => foo(x , a + 1, list)\n case true => x :: list\n }\n foo(x)\n }\n\n def divisors(n: Int): Vector[Int] = {\n val halfList = (1 to sqrt(n).toInt).toVector.filter(n % _ == 0).map(_.toInt)\n val reversedList = if (sqrt(n).floor == sqrt(n)) halfList.reverse.tail.map(n/_) else halfList.reverse.map(n/_)\n halfList ++ reversedList\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 \"\"\"3\n |apple\n |orange\n |apple\"\"\".stripMargin -> \"\"\"2\n |\n |\n |\n |\n |\"\"\".stripMargin\n ,\n \"\"\"5\n |grape\n |grape\n |grape\n |grape\n |grape\"\"\".stripMargin -> \"\"\"1\n |\"\"\".stripMargin\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\n\n\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.\n\nHow many kinds of items did you get?\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS_i consists of lowercase English letters and has a length between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint the number of kinds of items you got.\n\nSample Input 1\n\n3\napple\norange\napple\n\nSample Output 1\n\n2\n\nYou got two kinds of items: apple and orange.\n\nSample Input 2\n\n5\ngrape\ngrape\ngrape\ngrape\ngrape\n\nSample Output 2\n\n1\n\nSample Input 3\n\n4\naaaa\na\naaa\naa\n\nSample Output 3\n\n4", "sample_input": "3\napple\norange\napple\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02701", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.\n\nHow many kinds of items did you get?\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS_i consists of lowercase English letters and has a length between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint the number of kinds of items you got.\n\nSample Input 1\n\n3\napple\norange\napple\n\nSample Output 1\n\n2\n\nYou got two kinds of items: apple and orange.\n\nSample Input 2\n\n5\ngrape\ngrape\ngrape\ngrape\ngrape\n\nSample Output 2\n\n1\n\nSample Input 3\n\n4\naaaa\na\naaa\naa\n\nSample Output 3\n\n4", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5282, "cpu_time_ms": 842, "memory_kb": 84368}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s574849011", "group_id": "codeNet:p02701", "input_text": "object Main extends App {\n\tval N = scala.io.StdIn.readInt\n\tval set = scala.collection.mutable.Set[String]()\n\n\tfor(i<-0 until N){\n\t\tval s = scala.io.StdIn.readLine\n\t\tset += s\n\t}\n\n\tprintln(set.size)\n}", "language": "Scala", "metadata": {"date": 1588625541, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02701.html", "problem_id": "p02701", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02701/input.txt", "sample_output_relpath": "derived/input_output/data/p02701/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02701/Scala/s574849011.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s574849011", "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 set = scala.collection.mutable.Set[String]()\n\n\tfor(i<-0 until N){\n\t\tval s = scala.io.StdIn.readLine\n\t\tset += s\n\t}\n\n\tprintln(set.size)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.\n\nHow many kinds of items did you get?\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS_i consists of lowercase English letters and has a length between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint the number of kinds of items you got.\n\nSample Input 1\n\n3\napple\norange\napple\n\nSample Output 1\n\n2\n\nYou got two kinds of items: apple and orange.\n\nSample Input 2\n\n5\ngrape\ngrape\ngrape\ngrape\ngrape\n\nSample Output 2\n\n1\n\nSample Input 3\n\n4\naaaa\na\naaa\naa\n\nSample Output 3\n\n4", "sample_input": "3\napple\norange\napple\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02701", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.\n\nHow many kinds of items did you get?\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS_i consists of lowercase English letters and has a length between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint the number of kinds of items you got.\n\nSample Input 1\n\n3\napple\norange\napple\n\nSample Output 1\n\n2\n\nYou got two kinds of items: apple and orange.\n\nSample Input 2\n\n5\ngrape\ngrape\ngrape\ngrape\ngrape\n\nSample Output 2\n\n1\n\nSample Input 3\n\n4\naaaa\na\naaa\naa\n\nSample Output 3\n\n4", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 198, "cpu_time_ms": 718, "memory_kb": 72204}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s119079629", "group_id": "codeNet:p02701", "input_text": "import scala.io.StdIn._\nobject Main {\n def main(args:Array[String]) {\n val N = readLine().toInt\n\n var list = for(i <- 0 until N) yield readLine()\n println(list.distinct.size)\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1588049856, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02701.html", "problem_id": "p02701", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02701/input.txt", "sample_output_relpath": "derived/input_output/data/p02701/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02701/Scala/s119079629.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s119079629", "user_id": "u240766189"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.io.StdIn._\nobject Main {\n def main(args:Array[String]) {\n val N = readLine().toInt\n\n var list = for(i <- 0 until N) yield readLine()\n println(list.distinct.size)\n }\n}\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.\n\nHow many kinds of items did you get?\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS_i consists of lowercase English letters and has a length between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint the number of kinds of items you got.\n\nSample Input 1\n\n3\napple\norange\napple\n\nSample Output 1\n\n2\n\nYou got two kinds of items: apple and orange.\n\nSample Input 2\n\n5\ngrape\ngrape\ngrape\ngrape\ngrape\n\nSample Output 2\n\n1\n\nSample Input 3\n\n4\naaaa\na\naaa\naa\n\nSample Output 3\n\n4", "sample_input": "3\napple\norange\napple\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02701", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.\n\nHow many kinds of items did you get?\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS_i consists of lowercase English letters and has a length between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint the number of kinds of items you got.\n\nSample Input 1\n\n3\napple\norange\napple\n\nSample Output 1\n\n2\n\nYou got two kinds of items: apple and orange.\n\nSample Input 2\n\n5\ngrape\ngrape\ngrape\ngrape\ngrape\n\nSample Output 2\n\n1\n\nSample Input 3\n\n4\naaaa\na\naaa\naa\n\nSample Output 3\n\n4", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 192, "cpu_time_ms": 714, "memory_kb": 73564}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s495680116", "group_id": "codeNet:p02712", "input_text": "object Main extends App {\n\tval N = scala.io.StdIn.readLong\n\n\tval a = N / 3L\n\tval b = N / 5L\n\tval c = N / 15L\n\n\tprintln(N*(N+1L)/2L - 3L*a*(a+1L)/2L - 5L*b*(b+1L)/2L + 15L*c*(c+1L)/2L )\n}", "language": "Scala", "metadata": {"date": 1586751622, "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/s495680116.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s495680116", "user_id": "u675876401"}, "prompt_components": {"gold_output": "60\n", "input_to_evaluate": "object Main extends App {\n\tval N = scala.io.StdIn.readLong\n\n\tval a = N / 3L\n\tval b = N / 5L\n\tval c = N / 15L\n\n\tprintln(N*(N+1L)/2L - 3L*a*(a+1L)/2L - 5L*b*(b+1L)/2L + 15L*c*(c+1L)/2L )\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nLet us define the FizzBuzz sequence a_1,a_2,... as follows:\n\nIf both 3 and 5 divides i, a_i=\\mbox{FizzBuzz}.\n\nIf the above does not hold but 3 divides i, a_i=\\mbox{Fizz}.\n\nIf none of the above holds but 5 divides i, a_i=\\mbox{Buzz}.\n\nIf none of the above holds, a_i=i.\n\nFind the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nSample Input 1\n\n15\n\nSample Output 1\n\n60\n\nThe first 15 terms of the FizzBuzz sequence are:\n\n1,2,\\mbox{Fizz},4,\\mbox{Buzz},\\mbox{Fizz},7,8,\\mbox{Fizz},\\mbox{Buzz},11,\\mbox{Fizz},13,14,\\mbox{FizzBuzz}\n\nAmong them, numbers are 1,2,4,7,8,11,13,14, and the sum of them is 60.\n\nSample Input 2\n\n1000000\n\nSample Output 2\n\n266666333332\n\nWatch out for overflow.", "sample_input": "15\n"}, "reference_outputs": ["60\n"], "source_document_id": "p02712", "source_text": "Score : 200 points\n\nProblem Statement\n\nLet us define the FizzBuzz sequence a_1,a_2,... as follows:\n\nIf both 3 and 5 divides i, a_i=\\mbox{FizzBuzz}.\n\nIf the above does not hold but 3 divides i, a_i=\\mbox{Fizz}.\n\nIf none of the above holds but 5 divides i, a_i=\\mbox{Buzz}.\n\nIf none of the above holds, a_i=i.\n\nFind the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the sum of all numbers among the first N terms of the FizzBuzz sequence.\n\nSample Input 1\n\n15\n\nSample Output 1\n\n60\n\nThe first 15 terms of the FizzBuzz sequence are:\n\n1,2,\\mbox{Fizz},4,\\mbox{Buzz},\\mbox{Fizz},7,8,\\mbox{Fizz},\\mbox{Buzz},11,\\mbox{Fizz},13,14,\\mbox{FizzBuzz}\n\nAmong them, numbers are 1,2,4,7,8,11,13,14, and the sum of them is 60.\n\nSample Input 2\n\n1000000\n\nSample Output 2\n\n266666333332\n\nWatch out for overflow.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 186, "cpu_time_ms": 461, "memory_kb": 54644}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s943340658", "group_id": "codeNet:p02719", "input_text": "import scala.math.abs\n\nobject Main extends App {\n val sc = new java.util.Scanner(System.in) \n var n = sc.nextLong()\n var k = sc.nextLong()\n val ans = (n % k).min(abs(n % k - k))\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1598225824, "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/s943340658.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s943340658", "user_id": "u396472025"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import scala.math.abs\n\nobject Main extends App {\n val sc = new java.util.Scanner(System.in) \n var n = sc.nextLong()\n var k = sc.nextLong()\n val ans = (n % k).min(abs(n % k - k))\n println(ans)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven any integer x, Aoki can do the operation below.\n\nOperation: Replace x with the absolute difference of x and K.\n\nYou are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nConstraints\n\n0 ≤ N ≤ 10^{18}\n\n1 ≤ K ≤ 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nSample Input 1\n\n7 4\n\nSample Output 1\n\n1\n\nInitially, N=7.\n\nAfter one operation, N becomes |7-4| = 3.\n\nAfter two operations, N becomes |3-4| = 1, which is the minimum value taken by N.\n\nSample Input 2\n\n2 6\n\nSample Output 2\n\n2\n\nN=2 after zero operations is the minimum.\n\nSample Input 3\n\n1000000000000000000 1\n\nSample Output 3\n\n0", "sample_input": "7 4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02719", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven any integer x, Aoki can do the operation below.\n\nOperation: Replace x with the absolute difference of x and K.\n\nYou are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nConstraints\n\n0 ≤ N ≤ 10^{18}\n\n1 ≤ K ≤ 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nSample Input 1\n\n7 4\n\nSample Output 1\n\n1\n\nInitially, N=7.\n\nAfter one operation, N becomes |7-4| = 3.\n\nAfter two operations, N becomes |3-4| = 1, which is the minimum value taken by N.\n\nSample Input 2\n\n2 6\n\nSample Output 2\n\n2\n\nN=2 after zero operations is the minimum.\n\nSample Input 3\n\n1000000000000000000 1\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 198, "cpu_time_ms": 495, "memory_kb": 55444}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s039616931", "group_id": "codeNet:p02719", "input_text": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val N, K = in.nextLong\n val mod = N % K\n println(mod min K - mod)\n}", "language": "Scala", "metadata": {"date": 1586196612, "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/s039616931.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s039616931", "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, K = in.nextLong\n val mod = N % K\n println(mod min K - mod)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven any integer x, Aoki can do the operation below.\n\nOperation: Replace x with the absolute difference of x and K.\n\nYou are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nConstraints\n\n0 ≤ N ≤ 10^{18}\n\n1 ≤ K ≤ 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nSample Input 1\n\n7 4\n\nSample Output 1\n\n1\n\nInitially, N=7.\n\nAfter one operation, N becomes |7-4| = 3.\n\nAfter two operations, N becomes |3-4| = 1, which is the minimum value taken by N.\n\nSample Input 2\n\n2 6\n\nSample Output 2\n\n2\n\nN=2 after zero operations is the minimum.\n\nSample Input 3\n\n1000000000000000000 1\n\nSample Output 3\n\n0", "sample_input": "7 4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02719", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven any integer x, Aoki can do the operation below.\n\nOperation: Replace x with the absolute difference of x and K.\n\nYou are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nConstraints\n\n0 ≤ N ≤ 10^{18}\n\n1 ≤ K ≤ 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nSample Input 1\n\n7 4\n\nSample Output 1\n\n1\n\nInitially, N=7.\n\nAfter one operation, N becomes |7-4| = 3.\n\nAfter two operations, N becomes |3-4| = 1, which is the minimum value taken by N.\n\nSample Input 2\n\n2 6\n\nSample Output 2\n\n2\n\nN=2 after zero operations is the minimum.\n\nSample Input 3\n\n1000000000000000000 1\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 141, "cpu_time_ms": 340, "memory_kb": 25664}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s149267908", "group_id": "codeNet:p02722", "input_text": "\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(\"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 def divisors(x: Long): Array[Long] = {\n val pre = ArrayBuffer[Long]()\n val post = ArrayBuffer[Long]()\n REP(math.sqrt(x).toInt, 1) { d =>\n if (x % d == 0) {\n pre += d\n if (d * d != x) post += x / d\n }\n }\n\n val res = Array.ofDim[Long](pre.length + post.length)\n REP(pre.length)(i => res(i) = pre(i))\n val preLen = pre.length\n val postLen = post.length\n REP(postLen)(i => res(i + preLen) = post(postLen - 1 - i))\n res\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 import Workspace._\n\n // toIntとか+7とかするならvalにしろ\n final private[this] val MOD = 1000000007\n\n def solve(): Unit = {\n val N = nl()\n val D = divisors(N)\n var ans = mutable.Set[Long]()\n\n // 約数から探す\n REP(D.length - 1, 1) { i =>\n val d = D(i)\n var x = N\n while(x % d == 0) {\n x /= d\n }\n if (x == 1 || x % d == 1) {\n debug(s\"d:$d\")\n ans += d\n }\n }\n\n // 約数以外から探す\n REP(math.sqrt(N).toInt, 1) { a =>\n if ((N - 1) % a == 0) {\n val x = (N - 1) / a\n ans += a\n ans += x\n }\n }\n\n out.println(ans.size - 1) // 1を除く\n }\n}", "language": "Scala", "metadata": {"date": 1586383122, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02722.html", "problem_id": "p02722", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02722/input.txt", "sample_output_relpath": "derived/input_output/data/p02722/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02722/Scala/s149267908.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s149267908", "user_id": "u460609472"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "\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(\"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 def divisors(x: Long): Array[Long] = {\n val pre = ArrayBuffer[Long]()\n val post = ArrayBuffer[Long]()\n REP(math.sqrt(x).toInt, 1) { d =>\n if (x % d == 0) {\n pre += d\n if (d * d != x) post += x / d\n }\n }\n\n val res = Array.ofDim[Long](pre.length + post.length)\n REP(pre.length)(i => res(i) = pre(i))\n val preLen = pre.length\n val postLen = post.length\n REP(postLen)(i => res(i + preLen) = post(postLen - 1 - i))\n res\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 import Workspace._\n\n // toIntとか+7とかするならvalにしろ\n final private[this] val MOD = 1000000007\n\n def solve(): Unit = {\n val N = nl()\n val D = divisors(N)\n var ans = mutable.Set[Long]()\n\n // 約数から探す\n REP(D.length - 1, 1) { i =>\n val d = D(i)\n var x = N\n while(x % d == 0) {\n x /= d\n }\n if (x == 1 || x % d == 1) {\n debug(s\"d:$d\")\n ans += d\n }\n }\n\n // 約数以外から探す\n REP(math.sqrt(N).toInt, 1) { a =>\n if ((N - 1) % a == 0) {\n val x = (N - 1) / a\n ans += a\n ans += x\n }\n }\n\n out.println(ans.size - 1) // 1を除く\n }\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven is a positive integer N.\n\nWe will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K.\n\nOperation: if K divides N, replace N with N/K; otherwise, replace N with N-K.\n\nIn how many choices of K will N become 1 in the end?\n\nConstraints\n\n2 \\leq N \\leq 10^{12}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of choices of K in which N becomes 1 in the end.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n3\n\nThere are three choices of K in which N becomes 1 in the end: 2, 5, and 6.\n\nIn each of these choices, N will change as follows:\n\nWhen K=2: 6 \\to 3 \\to 1\n\nWhen K=5: 6 \\to 1\n\nWhen K=6: 6 \\to 1\n\nSample Input 2\n\n3141\n\nSample Output 2\n\n13\n\nSample Input 3\n\n314159265358\n\nSample Output 3\n\n9", "sample_input": "6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02722", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven is a positive integer N.\n\nWe will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K.\n\nOperation: if K divides N, replace N with N/K; otherwise, replace N with N-K.\n\nIn how many choices of K will N become 1 in the end?\n\nConstraints\n\n2 \\leq N \\leq 10^{12}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of choices of K in which N becomes 1 in the end.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n3\n\nThere are three choices of K in which N becomes 1 in the end: 2, 5, and 6.\n\nIn each of these choices, N will change as follows:\n\nWhen K=2: 6 \\to 3 \\to 1\n\nWhen K=5: 6 \\to 1\n\nWhen K=6: 6 \\to 1\n\nSample Input 2\n\n3141\n\nSample Output 2\n\n13\n\nSample Input 3\n\n314159265358\n\nSample Output 3\n\n9", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4825, "cpu_time_ms": 380, "memory_kb": 27676}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s035078787", "group_id": "codeNet:p02723", "input_text": "object Main extends App {\n val S = io.StdIn.readLine()\n if (S(2) == S(3) && S(4) == S(5)){\n println(\"Yes\")\n }else{\n println(\"No\")\n }\n}", "language": "Scala", "metadata": {"date": 1586667963, "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/s035078787.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s035078787", "user_id": "u646130340"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n val S = io.StdIn.readLine()\n if (S(2) == S(3) && S(4) == S(5)){\n println(\"Yes\")\n }else{\n println(\"No\")\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 333, "memory_kb": 27184}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s026738970", "group_id": "codeNet:p02723", "input_text": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val S = in.next\n val coffee = S.charAt(2) == S.charAt(3) && S.charAt(4) == S.charAt(5)\n println(if (coffee) \"Yes\" else \"No\")\n}", "language": "Scala", "metadata": {"date": 1585600026, "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/s026738970.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s026738970", "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 S = in.next\n val coffee = S.charAt(2) == S.charAt(3) && S.charAt(4) == S.charAt(5)\n println(if (coffee) \"Yes\" else \"No\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 349, "memory_kb": 27208}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s548529423", "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 :+ (k+homes.head))).map{case (x, y) => scala.math.abs(y - x)}.max).toString)\n}", "language": "Scala", "metadata": {"date": 1595130038, "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/s548529423.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s548529423", "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 :+ (k+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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 846, "memory_kb": 81160}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s891533762", "group_id": "codeNet:p02725", "input_text": "object Main extends App {\n\tval Array(k, n) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\tval a = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\tval b = new Array[Int](n)\n\n\tfor(i<-0 until n-1){\n\t\tb(i) = k - (a(i+1) - a(i))\n\t}\n\n\tb(n-1) = a(n-1) - a(0)\n\n\tprintln(b.min)\n}", "language": "Scala", "metadata": {"date": 1585504830, "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/s891533762.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s891533762", "user_id": "u675876401"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "object Main extends App {\n\tval Array(k, n) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\tval a = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\tval b = new Array[Int](n)\n\n\tfor(i<-0 until n-1){\n\t\tb(i) = k - (a(i+1) - a(i))\n\t}\n\n\tb(n-1) = a(n-1) - a(0)\n\n\tprintln(b.min)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a circular pond with a perimeter of K meters, and N houses around them.\n\nThe i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.\n\nWhen traveling between these houses, you can only go around the pond.\n\nFind the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.\n\nConstraints\n\n2 \\leq K \\leq 10^6\n\n2 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq A_1 < ... < A_N < K\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK N\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.\n\nSample Input 1\n\n20 3\n5 10 15\n\nSample Output 1\n\n10\n\nIf you start at the 1-st house and go to the 2-nd and 3-rd houses in this order, the total distance traveled will be 10.\n\nSample Input 2\n\n20 3\n0 5 15\n\nSample Output 2\n\n10\n\nIf you start at the 2-nd house and go to the 1-st and 3-rd houses in this order, the total distance traveled will be 10.", "sample_input": "20 3\n5 10 15\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02725", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a circular pond with a perimeter of K meters, and N houses around them.\n\nThe i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.\n\nWhen traveling between these houses, you can only go around the pond.\n\nFind the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.\n\nConstraints\n\n2 \\leq K \\leq 10^6\n\n2 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq A_1 < ... < A_N < K\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK N\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.\n\nSample Input 1\n\n20 3\n5 10 15\n\nSample Output 1\n\n10\n\nIf you start at the 1-st house and go to the 2-nd and 3-rd houses in this order, the total distance traveled will be 10.\n\nSample Input 2\n\n20 3\n0 5 15\n\nSample Output 2\n\n10\n\nIf you start at the 2-nd house and go to the 1-st and 3-rd houses in this order, the total distance traveled will be 10.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 275, "cpu_time_ms": 544, "memory_kb": 54544}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s842839664", "group_id": "codeNet:p02726", "input_text": "import scala.math.abs\n\nobject Main extends App {\n val Array(n, x, y) = io.StdIn.readLine().split(' ').map(_.toInt)\n\n val count = Array.fill(n)(0)\n for (k <- 1 until n) {\n for (i <- 1 to n; j = i+k; if j <= n) {\n val len = Seq(abs(i-j), abs(x-i)+1+abs(y-j), abs(y-i)+1+abs(x-j)).min\n count(len) += 1\n }\n }\n for (a <- count.drop(1)) println(a)\n}", "language": "Scala", "metadata": {"date": 1586405179, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02726.html", "problem_id": "p02726", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02726/input.txt", "sample_output_relpath": "derived/input_output/data/p02726/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02726/Scala/s842839664.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s842839664", "user_id": "u269739894"}, "prompt_components": {"gold_output": "5\n4\n1\n0\n", "input_to_evaluate": "import scala.math.abs\n\nobject Main extends App {\n val Array(n, x, y) = io.StdIn.readLine().split(' ').map(_.toInt)\n\n val count = Array.fill(n)(0)\n for (k <- 1 until n) {\n for (i <- 1 to n; j = i+k; if j <= n) {\n val len = Seq(abs(i-j), abs(x-i)+1+abs(y-j), abs(y-i)+1+abs(x-j)).min\n count(len) += 1\n }\n }\n for (a <- count.drop(1)) println(a)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have an undirected graph G with N vertices numbered 1 to N and N edges as follows:\n\nFor each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.\n\nThere is an edge between Vertex X and Vertex Y.\n\nFor each k=1,2,...,N-1, solve the problem below:\n\nFind the number of pairs of integers (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j in G is k.\n\nConstraints\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq X,Y \\leq N\n\nX+1 < Y\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X Y\n\nOutput\n\nFor each k=1, 2, ..., N-1 in this order, print a line containing the answer to the problem.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\n5\n4\n1\n0\n\nThe graph in this input is as follows:\n\nThere are five pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 1: (1,2)\\,,(2,3)\\,,(2,4)\\,,(3,4)\\,,(4,5).\n\nThere are four pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 2: (1,3)\\,,(1,4)\\,,(2,5)\\,,(3,5).\n\nThere is one pair (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 3: (1,5).\n\nThere are no pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 4.\n\nSample Input 2\n\n3 1 3\n\nSample Output 2\n\n3\n0\n\nThe graph in this input is as follows:\n\nSample Input 3\n\n7 3 7\n\nSample Output 3\n\n7\n8\n4\n2\n0\n0\n\nSample Input 4\n\n10 4 8\n\nSample Output 4\n\n10\n12\n10\n8\n4\n1\n0\n0\n0", "sample_input": "5 2 4\n"}, "reference_outputs": ["5\n4\n1\n0\n"], "source_document_id": "p02726", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have an undirected graph G with N vertices numbered 1 to N and N edges as follows:\n\nFor each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.\n\nThere is an edge between Vertex X and Vertex Y.\n\nFor each k=1,2,...,N-1, solve the problem below:\n\nFind the number of pairs of integers (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j in G is k.\n\nConstraints\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq X,Y \\leq N\n\nX+1 < Y\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X Y\n\nOutput\n\nFor each k=1, 2, ..., N-1 in this order, print a line containing the answer to the problem.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\n5\n4\n1\n0\n\nThe graph in this input is as follows:\n\nThere are five pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 1: (1,2)\\,,(2,3)\\,,(2,4)\\,,(3,4)\\,,(4,5).\n\nThere are four pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 2: (1,3)\\,,(1,4)\\,,(2,5)\\,,(3,5).\n\nThere is one pair (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 3: (1,5).\n\nThere are no pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 4.\n\nSample Input 2\n\n3 1 3\n\nSample Output 2\n\n3\n0\n\nThe graph in this input is as follows:\n\nSample Input 3\n\n7 3 7\n\nSample Output 3\n\n7\n8\n4\n2\n0\n0\n\nSample Input 4\n\n10 4 8\n\nSample Output 4\n\n10\n12\n10\n8\n4\n1\n0\n0\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 364, "cpu_time_ms": 1174, "memory_kb": 116464}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s336406757", "group_id": "codeNet:p02729", "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 Array(n, m) = in.readLine().split(\"\\\\s+\").map(_.toInt)\n\n out.println(n * (n - 1) / 2 + m * (m - 1) / 2)\n out.flush()\n }\n}\n", "language": "Scala", "metadata": {"date": 1584925428, "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/s336406757.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s336406757", "user_id": "u178269371"}, "prompt_components": {"gold_output": "1\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 Array(n, m) = in.readLine().split(\"\\\\s+\").map(_.toInt)\n\n out.println(n * (n - 1) / 2 + m * (m - 1) / 2)\n out.flush()\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 325, "memory_kb": 27328}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s829424244", "group_id": "codeNet:p02730", "input_text": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val S = in.next\n def isPalindrome(s: String) = s.reverse.zip(s).forall{case (l, r) => l == r}\n val result = isPalindrome(S) && isPalindrome(S.substring(0, (S.size - 1) / 2))\n println(if (result) \"Yes\" else \"No\")\n}", "language": "Scala", "metadata": {"date": 1585346065, "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/s829424244.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s829424244", "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 S = in.next\n def isPalindrome(s: String) = s.reverse.zip(s).forall{case (l, r) => l == r}\n val result = isPalindrome(S) && isPalindrome(S.substring(0, (S.size - 1) / 2))\n println(if (result) \"Yes\" else \"No\")\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:\n\nS is a palindrome.\n\nLet N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome.\n\nThe string consisting of the (N+3)/2-st through N-th characters of S is a palindrome.\n\nDetermine whether S is a strong palindrome.\n\nConstraints\n\nS consists of lowercase English letters.\n\nThe length of S is an odd number between 3 and 99 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a strong palindrome, print Yes;\notherwise, print No.\n\nSample Input 1\n\nakasaka\n\nSample Output 1\n\nYes\n\nS is akasaka.\n\nThe string formed by the 1-st through the 3-rd characters is aka.\n\nThe string formed by the 5-th through the 7-th characters is aka.\nAll of these are palindromes, so S is a strong palindrome.\n\nSample Input 2\n\nlevel\n\nSample Output 2\n\nNo\n\nSample Input 3\n\natcoder\n\nSample Output 3\n\nNo", "sample_input": "akasaka\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02730", "source_text": "Score : 200 points\n\nProblem Statement\n\nA string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:\n\nS is a palindrome.\n\nLet N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome.\n\nThe string consisting of the (N+3)/2-st through N-th characters of S is a palindrome.\n\nDetermine whether S is a strong palindrome.\n\nConstraints\n\nS consists of lowercase English letters.\n\nThe length of S is an odd number between 3 and 99 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a strong palindrome, print Yes;\notherwise, print No.\n\nSample Input 1\n\nakasaka\n\nSample Output 1\n\nYes\n\nS is akasaka.\n\nThe string formed by the 1-st through the 3-rd characters is aka.\n\nThe string formed by the 5-th through the 7-th characters is aka.\nAll of these are palindromes, so S is a strong palindrome.\n\nSample Input 2\n\nlevel\n\nSample Output 2\n\nNo\n\nSample Input 3\n\natcoder\n\nSample Output 3\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 288, "cpu_time_ms": 337, "memory_kb": 27436}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s487301783", "group_id": "codeNet:p02730", "input_text": "import java.util._\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val scanner = new Scanner(System.in)\n val string = scanner.nextLine\n val revString = string.reverse\n if (string != revString) {\n println(\"No\")\n return\n }\n\n val firstHalf = string.substring((string.length - 1) / 2 + 1)\n if (firstHalf != firstHalf.reverse) {\n println(\"No\")\n return\n }\n\n val secondHalf = string.substring((string.length - 1) / 2 + 1, string.length)\n if (secondHalf != secondHalf.reverse) {\n println(\"No\")\n return\n }\n\n println(\"Yes\")\n }\n}\n", "language": "Scala", "metadata": {"date": 1585085957, "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/s487301783.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s487301783", "user_id": "u581142892"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util._\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val scanner = new Scanner(System.in)\n val string = scanner.nextLine\n val revString = string.reverse\n if (string != revString) {\n println(\"No\")\n return\n }\n\n val firstHalf = string.substring((string.length - 1) / 2 + 1)\n if (firstHalf != firstHalf.reverse) {\n println(\"No\")\n return\n }\n\n val secondHalf = string.substring((string.length - 1) / 2 + 1, string.length)\n if (secondHalf != secondHalf.reverse) {\n println(\"No\")\n return\n }\n\n println(\"Yes\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 596, "cpu_time_ms": 338, "memory_kb": 27216}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s282066916", "group_id": "codeNet:p02732", "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 as = in.readLine().split(\"\\\\s+\").map(_.toInt)\n\n val map = Array.ofDim[Int](n + 1)\n for (a <- as) {\n map(a) += 1\n }\n\n val cns = Array.ofDim[Int](n + 1)\n val dcns = Array.ofDim[Int](n + 1)\n for (i <- as.indices) {\n val c = map(i)\n cns(i) = if (c > 1) {\n map(i) * (map(i) - 1) / 2\n } else {\n 0\n }\n dcns(i) = if (c > 2) {\n (map(i) - 1) * (map(i) - 2) / 2\n } else {\n 0\n }\n }\n\n val sumOfCns = cns.sum\n\n for (a <- as) {\n out.println(sumOfCns - cns(a) + dcns(a))\n }\n\n out.flush()\n }\n}\n", "language": "Scala", "metadata": {"date": 1584927031, "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/s282066916.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s282066916", "user_id": "u178269371"}, "prompt_components": {"gold_output": "2\n2\n3\n2\n3\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 as = in.readLine().split(\"\\\\s+\").map(_.toInt)\n\n val map = Array.ofDim[Int](n + 1)\n for (a <- as) {\n map(a) += 1\n }\n\n val cns = Array.ofDim[Int](n + 1)\n val dcns = Array.ofDim[Int](n + 1)\n for (i <- as.indices) {\n val c = map(i)\n cns(i) = if (c > 1) {\n map(i) * (map(i) - 1) / 2\n } else {\n 0\n }\n dcns(i) = if (c > 2) {\n (map(i) - 1) * (map(i) - 2) / 2\n } else {\n 0\n }\n }\n\n val sumOfCns = cns.sum\n\n for (a <- as) {\n out.println(sumOfCns - cns(a) + dcns(a))\n }\n\n out.flush()\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N balls. The i-th ball has an integer A_i written on it.\n\nFor each k=1, 2, ..., N, solve the following problem and print the answer.\n\nFind the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.\n\nConstraints\n\n3 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq N\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFor each k=1,2,...,N, print a line containing the answer.\n\nSample Input 1\n\n5\n1 1 2 1 2\n\nSample Output 1\n\n2\n2\n3\n2\n3\n\nConsider the case k=1 for example. The numbers written on the remaining balls are 1,2,1,2.\n\nFrom these balls, there are two ways to choose two distinct balls so that the integers written on them are equal.\n\nThus, the answer for k=1 is 2.\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\n0\n0\n0\n0\n\nNo two balls have equal numbers written on them.\n\nSample Input 3\n\n5\n3 3 3 3 3\n\nSample Output 3\n\n6\n6\n6\n6\n6\n\nAny two balls have equal numbers written on them.\n\nSample Input 4\n\n8\n1 2 1 4 2 1 4 1\n\nSample Output 4\n\n5\n7\n5\n7\n7\n5\n7\n5", "sample_input": "5\n1 1 2 1 2\n"}, "reference_outputs": ["2\n2\n3\n2\n3\n"], "source_document_id": "p02732", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have N balls. The i-th ball has an integer A_i written on it.\n\nFor each k=1, 2, ..., N, solve the following problem and print the answer.\n\nFind the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.\n\nConstraints\n\n3 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq N\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFor each k=1,2,...,N, print a line containing the answer.\n\nSample Input 1\n\n5\n1 1 2 1 2\n\nSample Output 1\n\n2\n2\n3\n2\n3\n\nConsider the case k=1 for example. The numbers written on the remaining balls are 1,2,1,2.\n\nFrom these balls, there are two ways to choose two distinct balls so that the integers written on them are equal.\n\nThus, the answer for k=1 is 2.\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\n0\n0\n0\n0\n\nNo two balls have equal numbers written on them.\n\nSample Input 3\n\n5\n3 3 3 3 3\n\nSample Output 3\n\n6\n6\n6\n6\n6\n\nAny two balls have equal numbers written on them.\n\nSample Input 4\n\n8\n1 2 1 4 2 1 4 1\n\nSample Output 4\n\n5\n7\n5\n7\n7\n5\n7\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 901, "cpu_time_ms": 893, "memory_kb": 82908}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s382363316", "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.nextInt()\n val W = sc.nextInt()\n\n println(round(H * W / 2))\n \n}", "language": "Scala", "metadata": {"date": 1597801134, "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/s382363316.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s382363316", "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.nextInt()\n val W = sc.nextInt()\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 504, "memory_kb": 55344}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s427203868", "group_id": "codeNet:p02742", "input_text": "\nobject Main extends App {\n val Array(h, w) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\n val ans = {\n val min = List(h, w).min\n val max = List(h, w).max\n if (min == 1) {\n 1\n } else {\n // 偶数, 偶数\n if (min % 2 == 0 && max % 2 == 0) {\n (BigInt(h) * w) / 2\n } else if (min % 2 != 0 && max % 2 != 0) {\n // 奇数, 奇数\n (((BigInt(h) - 1) * w) / 2) + (BigInt(h) / 2) + 1\n } else {\n // 奇数, 偶数\n (BigInt(h) * w) / 2\n }\n }\n }\n\n\n println(ans)\n}\n", "language": "Scala", "metadata": {"date": 1593493538, "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/s427203868.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s427203868", "user_id": "u654455149"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "\nobject Main extends App {\n val Array(h, w) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\n val ans = {\n val min = List(h, w).min\n val max = List(h, w).max\n if (min == 1) {\n 1\n } else {\n // 偶数, 偶数\n if (min % 2 == 0 && max % 2 == 0) {\n (BigInt(h) * w) / 2\n } else if (min % 2 != 0 && max % 2 != 0) {\n // 奇数, 奇数\n (((BigInt(h) - 1) * w) / 2) + (BigInt(h) / 2) + 1\n } else {\n // 奇数, 偶数\n (BigInt(h) * w) / 2\n }\n }\n }\n\n\n println(ans)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a board with H horizontal rows and W vertical columns of squares.\nThere is a bishop at the top-left square on this board.\nHow many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally.\nMore formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:\n\nr_1 + c_1 = r_2 + c_2\n\nr_1 - c_1 = r_2 - c_2\n\nFor example, in the following figure, the bishop can move to any of the red squares in one move:\n\nConstraints\n\n1 \\leq H, W \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH \\ W\n\nOutput\n\nPrint the number of squares the bishop can reach.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\n10\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n11\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n500000000000000000", "sample_input": "4 5\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02742", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a board with H horizontal rows and W vertical columns of squares.\nThere is a bishop at the top-left square on this board.\nHow many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally.\nMore formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:\n\nr_1 + c_1 = r_2 + c_2\n\nr_1 - c_1 = r_2 - c_2\n\nFor example, in the following figure, the bishop can move to any of the red squares in one move:\n\nConstraints\n\n1 \\leq H, W \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH \\ W\n\nOutput\n\nPrint the number of squares the bishop can reach.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\n10\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n11\n\nThe bishop can reach the cyan squares in the following figure:\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n500000000000000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 542, "cpu_time_ms": 507, "memory_kb": 54852}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s366624843", "group_id": "codeNet:p02744", "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 = ni()\n val chars = Array.ofDim[Char](N)\n chars(0) = 'a'\n def dfs(i: Int, d: Int): Unit = {\n if (i == N) {\n out.println(chars.mkString)\n } else {\n chars(i) = (d+'a').toChar\n dfs(i + 1, d)\n chars(i) = (d + 1+'a').toChar\n dfs(i + 1, d + 1)\n }\n }\n\n dfs(1, 0)\n }\n}", "language": "Scala", "metadata": {"date": 1584235004, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02744.html", "problem_id": "p02744", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02744/input.txt", "sample_output_relpath": "derived/input_output/data/p02744/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02744/Scala/s366624843.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s366624843", "user_id": "u460609472"}, "prompt_components": {"gold_output": "a\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 = ni()\n val chars = Array.ofDim[Char](N)\n chars(0) = 'a'\n def dfs(i: Int, d: Int): Unit = {\n if (i == N) {\n out.println(chars.mkString)\n } else {\n chars(i) = (d+'a').toChar\n dfs(i + 1, d)\n chars(i) = (d + 1+'a').toChar\n dfs(i + 1, d + 1)\n }\n }\n\n dfs(1, 0)\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nIn this problem, we only consider strings consisting of lowercase English letters.\n\nStrings s and t are said to be isomorphic when the following conditions are satisfied:\n\n|s| = |t| holds.\n\nFor every pair i, j, one of the following holds:\n\ns_i = s_j and t_i = t_j.\n\ns_i \\neq s_j and t_i \\neq t_j.\n\nFor example, abcac and zyxzx are isomorphic, while abcac and ppppp are not.\n\nA string s is said to be in normal form when the following condition is satisfied:\n\nFor every string t that is isomorphic to s, s \\leq t holds. Here \\leq denotes lexicographic comparison.\n\nFor example, abcac is in normal form, but zyxzx is not since it is isomorphic to abcac, which is lexicographically smaller than zyxzx.\n\nYou are given an integer N.\nPrint all strings of length N that are in normal form, in lexicographically ascending order.\n\nConstraints\n\n1 \\leq N \\leq 10\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nAssume that there are K strings of length N that are in normal form: w_1, \\ldots, w_K in lexicographical order.\nOutput should be in the following format:\n\nw_1\n:\nw_K\n\nSample Input 1\n\n1\n\nSample Output 1\n\na\n\nSample Input 2\n\n2\n\nSample Output 2\n\naa\nab", "sample_input": "1\n"}, "reference_outputs": ["a\n"], "source_document_id": "p02744", "source_text": "Score : 400 points\n\nProblem Statement\n\nIn this problem, we only consider strings consisting of lowercase English letters.\n\nStrings s and t are said to be isomorphic when the following conditions are satisfied:\n\n|s| = |t| holds.\n\nFor every pair i, j, one of the following holds:\n\ns_i = s_j and t_i = t_j.\n\ns_i \\neq s_j and t_i \\neq t_j.\n\nFor example, abcac and zyxzx are isomorphic, while abcac and ppppp are not.\n\nA string s is said to be in normal form when the following condition is satisfied:\n\nFor every string t that is isomorphic to s, s \\leq t holds. Here \\leq denotes lexicographic comparison.\n\nFor example, abcac is in normal form, but zyxzx is not since it is isomorphic to abcac, which is lexicographically smaller than zyxzx.\n\nYou are given an integer N.\nPrint all strings of length N that are in normal form, in lexicographically ascending order.\n\nConstraints\n\n1 \\leq N \\leq 10\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nAssume that there are K strings of length N that are in normal form: w_1, \\ldots, w_K in lexicographical order.\nOutput should be in the following format:\n\nw_1\n:\nw_K\n\nSample Input 1\n\n1\n\nSample Output 1\n\na\n\nSample Input 2\n\n2\n\nSample Output 2\n\naa\nab", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4152, "cpu_time_ms": 337, "memory_kb": 25544}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s952957793", "group_id": "codeNet:p02745", "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": 1584240127, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02745.html", "problem_id": "p02745", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02745/input.txt", "sample_output_relpath": "derived/input_output/data/p02745/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02745/Scala/s952957793.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s952957793", "user_id": "u460609472"}, "prompt_components": {"gold_output": "7\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 : 500 points\n\nProblem Statement\n\nSnuke has a string s.\nFrom this string, Anuke, Bnuke, and Cnuke obtained strings a, b, and c, respectively, as follows:\n\nChoose a non-empty (contiguous) substring of s (possibly s itself). Then, replace some characters (possibly all or none) in it with ?s.\n\nFor example, if s is mississippi, we can choose the substring ssissip and replace its 1-st and 3-rd characters with ? to obtain ?s?ssip.\n\nYou are given the strings a, b, and c.\nFind the minimum possible length of s.\n\nConstraints\n\n1 \\leq |a|, |b|, |c| \\leq 2000\n\na, b, and c consists of lowercase English letters and ?s.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\nb\nc\n\nOutput\n\nPrint the minimum possible length of s.\n\nSample Input 1\n\na?c\nder\ncod\n\nSample Output 1\n\n7\n\nFor example, s could be atcoder.\n\nSample Input 2\n\natcoder\natcoder\n???????\n\nSample Output 2\n\n7\n\na, b, and c may not be distinct.", "sample_input": "a?c\nder\ncod\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02745", "source_text": "Score : 500 points\n\nProblem Statement\n\nSnuke has a string s.\nFrom this string, Anuke, Bnuke, and Cnuke obtained strings a, b, and c, respectively, as follows:\n\nChoose a non-empty (contiguous) substring of s (possibly s itself). Then, replace some characters (possibly all or none) in it with ?s.\n\nFor example, if s is mississippi, we can choose the substring ssissip and replace its 1-st and 3-rd characters with ? to obtain ?s?ssip.\n\nYou are given the strings a, b, and c.\nFind the minimum possible length of s.\n\nConstraints\n\n1 \\leq |a|, |b|, |c| \\leq 2000\n\na, b, and c consists of lowercase English letters and ?s.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\nb\nc\n\nOutput\n\nPrint the minimum possible length of s.\n\nSample Input 1\n\na?c\nder\ncod\n\nSample Output 1\n\n7\n\nFor example, s could be atcoder.\n\nSample Input 2\n\natcoder\natcoder\n???????\n\nSample Output 2\n\n7\n\na, b, and c may not be distinct.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3988, "cpu_time_ms": 330, "memory_kb": 27328}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s347612796", "group_id": "codeNet:p02748", "input_text": "object Main extends App {\n val abmInput = scala.io.StdIn.readLine()\n val abmArray = abmInput.split(\" \").map(_.toInt).toSeq\n val aLength = abmArray(0)\n val bLength = abmArray(1)\n val mLength = abmArray(2)\n\n val aInput = scala.io.StdIn.readLine()\n val aArray = aInput.split(\" \").map(_.toInt).toVector\n val bInput = scala.io.StdIn.readLine()\n val bArray = bInput.split(\" \").map(_.toInt).toVector\n\n var mMap = scala.collection.mutable.Map.empty[(Int, Int), Int]\n (1 to mLength).foreach { _ =>\n val mInput = scala.io.StdIn.readLine()\n val mInputArray = mInput.split(\" \").map(_.toInt).toSeq\n val key = (mInputArray(0), mInputArray(1))\n if (mMap.contains(key)) {\n val existingValue = mMap.get(key).get\n if(existingValue < mInputArray(2)) {\n mMap.put(key, mInputArray(2))\n }\n } else {\n mMap.put(key, mInputArray(2))\n }\n }\n\n var min = aArray.min + bArray.min\n mMap.keys.foreach { key =>\n val mCalculate = aArray(key._1 - 1) + bArray(key._2 - 1) - mMap.get(key).get\n if(mCalculate < min) {\n min = mCalculate\n }\n }\n println(min)\n}", "language": "Scala", "metadata": {"date": 1583717623, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/s347612796.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s347612796", "user_id": "u105921924"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "object Main extends App {\n val abmInput = scala.io.StdIn.readLine()\n val abmArray = abmInput.split(\" \").map(_.toInt).toSeq\n val aLength = abmArray(0)\n val bLength = abmArray(1)\n val mLength = abmArray(2)\n\n val aInput = scala.io.StdIn.readLine()\n val aArray = aInput.split(\" \").map(_.toInt).toVector\n val bInput = scala.io.StdIn.readLine()\n val bArray = bInput.split(\" \").map(_.toInt).toVector\n\n var mMap = scala.collection.mutable.Map.empty[(Int, Int), Int]\n (1 to mLength).foreach { _ =>\n val mInput = scala.io.StdIn.readLine()\n val mInputArray = mInput.split(\" \").map(_.toInt).toSeq\n val key = (mInputArray(0), mInputArray(1))\n if (mMap.contains(key)) {\n val existingValue = mMap.get(key).get\n if(existingValue < mInputArray(2)) {\n mMap.put(key, mInputArray(2))\n }\n } else {\n mMap.put(key, mInputArray(2))\n }\n }\n\n var min = aArray.min + bArray.min\n mMap.keys.foreach { key =>\n val mCalculate = aArray(key._1 - 1) + bArray(key._2 - 1) - mMap.get(key).get\n if(mCalculate < min) {\n min = mCalculate\n }\n }\n println(min)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1422, "memory_kb": 95780}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s110062911", "group_id": "codeNet:p02753", "input_text": "object Main extends App {\n\n val s = scala.io.StdIn.readLine().split(\"\").toList\n s match {\n case List(a, b, c) if a == b && b == c =>\n println(\"No\")\n case _ =>\n println(\"Yes\")\n }\n}", "language": "Scala", "metadata": {"date": 1586442259, "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/s110062911.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s110062911", "user_id": "u647522078"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n\n val s = scala.io.StdIn.readLine().split(\"\").toList\n s match {\n case List(a, b, c) if a == b && b == c =>\n println(\"No\")\n case _ =>\n println(\"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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 331, "memory_kb": 25424}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s939930101", "group_id": "codeNet:p02754", "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 a = sc.nextLong()\n val b = sc.nextLong()\n\n val x = n / (a + b) * a\n val y = n % (a + b)\n val z = List(y, a).min\n\n println(x + z)\n}\n", "language": "Scala", "metadata": {"date": 1583636643, "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/s939930101.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s939930101", "user_id": "u786167609"}, "prompt_components": {"gold_output": "4\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 a = sc.nextLong()\n val b = sc.nextLong()\n\n val x = n / (a + b) * a\n val y = n % (a + b)\n val z = List(y, a).min\n\n println(x + z)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has many red balls and blue balls. Now, he will place them in a row.\n\nInitially, there is no ball placed.\n\nTakahashi, who is very patient, will do the following operation 10^{100} times:\n\nPlace A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.\n\nHow many blue balls will be there among the first N balls in the row of balls made this way?\n\nConstraints\n\n1 \\leq N \\leq 10^{18}\n\nA, B \\geq 0\n\n0 < A + B \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the number of blue balls that will be there among the first N balls in the row of balls.\n\nSample Input 1\n\n8 3 4\n\nSample Output 1\n\n4\n\nLet b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb, among which there are four blue balls.\n\nSample Input 2\n\n8 0 4\n\nSample Output 2\n\n0\n\nHe placed only red balls from the beginning.\n\nSample Input 3\n\n6 2 4\n\nSample Output 3\n\n2\n\nAmong bbrrrr, there are two blue balls.", "sample_input": "8 3 4\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02754", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has many red balls and blue balls. Now, he will place them in a row.\n\nInitially, there is no ball placed.\n\nTakahashi, who is very patient, will do the following operation 10^{100} times:\n\nPlace A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.\n\nHow many blue balls will be there among the first N balls in the row of balls made this way?\n\nConstraints\n\n1 \\leq N \\leq 10^{18}\n\nA, B \\geq 0\n\n0 < A + B \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the number of blue balls that will be there among the first N balls in the row of balls.\n\nSample Input 1\n\n8 3 4\n\nSample Output 1\n\n4\n\nLet b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb, among which there are four blue balls.\n\nSample Input 2\n\n8 0 4\n\nSample Output 2\n\n0\n\nHe placed only red balls from the beginning.\n\nSample Input 3\n\n6 2 4\n\nSample Output 3\n\n2\n\nAmong bbrrrr, there are two blue balls.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 252, "cpu_time_ms": 349, "memory_kb": 25536}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s445900457", "group_id": "codeNet:p02755", "input_text": "object Main {\n // 標準入力\n import scala.io.StdIn._\n def readints: Array[Long] = readLine split \" \" map (_.toLong)\n //\n def main(args: Array[String]) = {\n val Array(a, b) = readints\n val la = (a * 12.5).ceil.toLong\n val ua = ((a + 1) * 12.5).ceil.toLong\n val lb = (b * 10).ceil.toLong\n val ub = ((b + 1) * 10).ceil.toLong\n val lc = Math.max(la, lb)\n val uc = Math.min(ua, ub)\n if (lc < uc) {\n println(s\"$lc\")\n } else {\n println(s\"-1\")\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1591751915, "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/s445900457.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s445900457", "user_id": "u872959410"}, "prompt_components": {"gold_output": "25\n", "input_to_evaluate": "object Main {\n // 標準入力\n import scala.io.StdIn._\n def readints: Array[Long] = readLine split \" \" map (_.toLong)\n //\n def main(args: Array[String]) = {\n val Array(a, b) = readints\n val la = (a * 12.5).ceil.toLong\n val ua = ((a + 1) * 12.5).ceil.toLong\n val lb = (b * 10).ceil.toLong\n val ub = ((b + 1) * 10).ceil.toLong\n val lc = Math.max(la, lb)\n val uc = Math.min(ua, ub)\n if (lc < uc) {\n println(s\"$lc\")\n } else {\n println(s\"-1\")\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 333, "memory_kb": 27320}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s772464408", "group_id": "codeNet:p02755", "input_text": "import scala.util.control.Breaks\n\nobject Main extends App {\n val abInput = scala.io.StdIn.readLine()\n val abArray = abInput.split(\" \").map(_.toInt).toSeq\n val a = abArray(0)\n val b = abArray(1)\n val break = new Breaks\n\n var result = -1\n break.breakable {\n (10 to 10000).foreach { i =>\n val aResult = (i * 0.08).toInt\n val bResult = (i * 0.1).toInt\n\n if(a == aResult && b == bResult) {\n result = i\n break.break()\n }\n }\n }\n println(result)\n}", "language": "Scala", "metadata": {"date": 1583634505, "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/s772464408.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s772464408", "user_id": "u105921924"}, "prompt_components": {"gold_output": "25\n", "input_to_evaluate": "import scala.util.control.Breaks\n\nobject Main extends App {\n val abInput = scala.io.StdIn.readLine()\n val abArray = abInput.split(\" \").map(_.toInt).toSeq\n val a = abArray(0)\n val b = abArray(1)\n val break = new Breaks\n\n var result = -1\n break.breakable {\n (10 to 10000).foreach { i =>\n val aResult = (i * 0.08).toInt\n val bResult = (i * 0.1).toInt\n\n if(a == aResult && b == bResult) {\n result = i\n break.break()\n }\n }\n }\n println(result)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nFind the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.)\n\nHere, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer.\n\nIf multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print -1.\n\nConstraints\n\n1 \\leq A \\leq B \\leq 100\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf there is a price that satisfies the condition, print an integer representing the lowest such price; otherwise, print -1.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n25\n\nIf the price of a product before tax is 25 yen, the amount of consumption tax levied on it is:\n\nWhen the consumption tax rate is 8 percent: \\lfloor 25 \\times 0.08 \\rfloor = \\lfloor 2 \\rfloor = 2 yen.\n\nWhen the consumption tax rate is 10 percent: \\lfloor 25 \\times 0.1 \\rfloor = \\lfloor 2.5 \\rfloor = 2 yen.\n\nThus, the price of 25 yen satisfies the condition. There are other possible prices, such as 26 yen, but print the minimum such price, 25.\n\nSample Input 2\n\n8 10\n\nSample Output 2\n\n100\n\nIf the price of a product before tax is 100 yen, the amount of consumption tax levied on it is:\n\nWhen the consumption tax rate is 8 percent: \\lfloor 100 \\times 0.08 \\rfloor = 8 yen.\n\nWhen the consumption tax rate is 10 percent: \\lfloor 100 \\times 0.1 \\rfloor = 10 yen.\n\nSample Input 3\n\n19 99\n\nSample Output 3\n\n-1\n\nThere is no price before tax satisfying this condition, so print -1.", "sample_input": "2 2\n"}, "reference_outputs": ["25\n"], "source_document_id": "p02755", "source_text": "Score : 300 points\n\nProblem Statement\n\nFind the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.)\n\nHere, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer.\n\nIf multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print -1.\n\nConstraints\n\n1 \\leq A \\leq B \\leq 100\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf there is a price that satisfies the condition, print an integer representing the lowest such price; otherwise, print -1.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n25\n\nIf the price of a product before tax is 25 yen, the amount of consumption tax levied on it is:\n\nWhen the consumption tax rate is 8 percent: \\lfloor 25 \\times 0.08 \\rfloor = \\lfloor 2 \\rfloor = 2 yen.\n\nWhen the consumption tax rate is 10 percent: \\lfloor 25 \\times 0.1 \\rfloor = \\lfloor 2.5 \\rfloor = 2 yen.\n\nThus, the price of 25 yen satisfies the condition. There are other possible prices, such as 26 yen, but print the minimum such price, 25.\n\nSample Input 2\n\n8 10\n\nSample Output 2\n\n100\n\nIf the price of a product before tax is 100 yen, the amount of consumption tax levied on it is:\n\nWhen the consumption tax rate is 8 percent: \\lfloor 100 \\times 0.08 \\rfloor = 8 yen.\n\nWhen the consumption tax rate is 10 percent: \\lfloor 100 \\times 0.1 \\rfloor = 10 yen.\n\nSample Input 3\n\n19 99\n\nSample Output 3\n\n-1\n\nThere is no price before tax satisfying this condition, so print -1.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 488, "cpu_time_ms": 361, "memory_kb": 27196}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s484579041", "group_id": "codeNet:p02756", "input_text": "object Main extends App {\n val buf = new StringBuilder\n val tmp = new StringBuilder\n val s = io.StdIn.readLine()\n val q = io.StdIn.readLine().toInt\n var reverse = false\n buf.append(s)\n for (_ <- 0 until q) {\n val query = io.StdIn.readLine().split(' ')\n val t = query(0).toInt\n if (t == 1) {\n if (tmp.nonEmpty) {buf.append(tmp.reverse); tmp.clear()}\n reverse = !reverse\n }\n else if (t == 2) {\n val f = query(1).toInt\n val c = query(2)\n if (f == 1) {\n if (reverse) {\n buf.append(c)\n } else {\n tmp.append(c)\n }\n } else {\n if (reverse) {\n tmp.append(c)\n } else {\n buf.append(c)\n }\n }\n }\n }\n\n println(if (reverse) tmp.append(buf).toString() else tmp.append(buf.reverse).toString())\n}", "language": "Scala", "metadata": {"date": 1583638047, "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/s484579041.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s484579041", "user_id": "u269739894"}, "prompt_components": {"gold_output": "cpa\n", "input_to_evaluate": "object Main extends App {\n val buf = new StringBuilder\n val tmp = new StringBuilder\n val s = io.StdIn.readLine()\n val q = io.StdIn.readLine().toInt\n var reverse = false\n buf.append(s)\n for (_ <- 0 until q) {\n val query = io.StdIn.readLine().split(' ')\n val t = query(0).toInt\n if (t == 1) {\n if (tmp.nonEmpty) {buf.append(tmp.reverse); tmp.clear()}\n reverse = !reverse\n }\n else if (t == 2) {\n val f = query(1).toInt\n val c = query(2)\n if (f == 1) {\n if (reverse) {\n buf.append(c)\n } else {\n tmp.append(c)\n }\n } else {\n if (reverse) {\n tmp.append(c)\n } else {\n buf.append(c)\n }\n }\n }\n }\n\n println(if (reverse) tmp.append(buf).toString() else tmp.append(buf.reverse).toString())\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a string S consisting of lowercase English letters.\n\nStarting with this string, he will produce a new one in the procedure given as follows.\n\nThe procedure consists of Q operations. In Operation i (1 \\leq i \\leq Q), an integer T_i is provided, which means the following:\n\nIf T_i = 1: reverse the string S.\n\nIf T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided.\n\nIf F_i = 1 : Add C_i to the beginning of the string S.\n\nIf F_i = 2 : Add C_i to the end of the string S.\n\nHelp Takahashi by finding the final string that results from the procedure.\n\nConstraints\n\n1 \\leq |S| \\leq 10^5\n\nS consists of lowercase English letters.\n\n1 \\leq Q \\leq 2 \\times 10^5\n\nT_i = 1 or 2.\n\nF_i = 1 or 2, if provided.\n\nC_i is a lowercase English letter, if provided.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nQ\nQuery_1\n:\nQuery_Q\n\nIn the 3-rd through the (Q+2)-th lines, Query_i is one of the following:\n\n1\n\nwhich means T_i = 1, and:\n\n2 F_i C_i\n\nwhich means T_i = 2.\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\na\n4\n2 1 p\n1\n2 2 c\n1\n\nSample Output 1\n\ncpa\n\nThere will be Q = 4 operations. Initially, S is a.\n\nOperation 1: Add p at the beginning of S. S becomes pa.\n\nOperation 2: Reverse S. S becomes ap.\n\nOperation 3: Add c at the end of S. S becomes apc.\n\nOperation 4: Reverse S. S becomes cpa.\n\nThus, the resulting string is cpa.\n\nSample Input 2\n\na\n6\n2 2 a\n2 1 b\n1\n2 2 c\n1\n1\n\nSample Output 2\n\naabc\n\nThere will be Q = 6 operations. Initially, S is a.\n\nOperation 1: S becomes aa.\n\nOperation 2: S becomes baa.\n\nOperation 3: S becomes aab.\n\nOperation 4: S becomes aabc.\n\nOperation 5: S becomes cbaa.\n\nOperation 6: S becomes aabc.\n\nThus, the resulting string is aabc.\n\nSample Input 3\n\ny\n1\n2 1 x\n\nSample Output 3\n\nxy", "sample_input": "a\n4\n2 1 p\n1\n2 2 c\n1\n"}, "reference_outputs": ["cpa\n"], "source_document_id": "p02756", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a string S consisting of lowercase English letters.\n\nStarting with this string, he will produce a new one in the procedure given as follows.\n\nThe procedure consists of Q operations. In Operation i (1 \\leq i \\leq Q), an integer T_i is provided, which means the following:\n\nIf T_i = 1: reverse the string S.\n\nIf T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided.\n\nIf F_i = 1 : Add C_i to the beginning of the string S.\n\nIf F_i = 2 : Add C_i to the end of the string S.\n\nHelp Takahashi by finding the final string that results from the procedure.\n\nConstraints\n\n1 \\leq |S| \\leq 10^5\n\nS consists of lowercase English letters.\n\n1 \\leq Q \\leq 2 \\times 10^5\n\nT_i = 1 or 2.\n\nF_i = 1 or 2, if provided.\n\nC_i is a lowercase English letter, if provided.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nQ\nQuery_1\n:\nQuery_Q\n\nIn the 3-rd through the (Q+2)-th lines, Query_i is one of the following:\n\n1\n\nwhich means T_i = 1, and:\n\n2 F_i C_i\n\nwhich means T_i = 2.\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\na\n4\n2 1 p\n1\n2 2 c\n1\n\nSample Output 1\n\ncpa\n\nThere will be Q = 4 operations. Initially, S is a.\n\nOperation 1: Add p at the beginning of S. S becomes pa.\n\nOperation 2: Reverse S. S becomes ap.\n\nOperation 3: Add c at the end of S. S becomes apc.\n\nOperation 4: Reverse S. S becomes cpa.\n\nThus, the resulting string is cpa.\n\nSample Input 2\n\na\n6\n2 2 a\n2 1 b\n1\n2 2 c\n1\n1\n\nSample Output 2\n\naabc\n\nThere will be Q = 6 operations. Initially, S is a.\n\nOperation 1: S becomes aa.\n\nOperation 2: S becomes baa.\n\nOperation 3: S becomes aab.\n\nOperation 4: S becomes aabc.\n\nOperation 5: S becomes cbaa.\n\nOperation 6: S becomes aabc.\n\nThus, the resulting string is aabc.\n\nSample Input 3\n\ny\n1\n2 1 x\n\nSample Output 3\n\nxy", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 812, "cpu_time_ms": 921, "memory_kb": 62420}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s799536915", "group_id": "codeNet:p02759", "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 ans =\n if (N % 2 == 0) N / 2\n else (N / 2) + 1\n println(ans)\n }\n}\n", "language": "Scala", "metadata": {"date": 1583255443, "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/s799536915.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s799536915", "user_id": "u307860479"}, "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 ans =\n if (N % 2 == 0) N / 2\n else (N / 2) + 1\n println(ans)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 229, "cpu_time_ms": 338, "memory_kb": 27048}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s085979095", "group_id": "codeNet:p02759", "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\n println((n + 1) / 2)\n }\n}\n", "language": "Scala", "metadata": {"date": 1583114497, "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/s085979095.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s085979095", "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\n println((n + 1) / 2)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 362, "memory_kb": 26072}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s358733178", "group_id": "codeNet:p02760", "input_text": "object Main extends App {\n val in = new java.util.Scanner(System.in)\n val A = Array.fill(9)(in.nextInt)\n val N = in.nextInt\n\n (1 to N).foreach {i =>\n val b = in.nextInt\n A.indexWhere(_ == b) match {\n case -1 =>\n case n => A(n) = 0\n }\n }\n\n val bingos: Seq[Seq[Int]] =\n Seq(0, 4, 8) :: Seq(2, 4, 6) :: (0 to 2).flatMap { i =>\n Seq((0 to 2).map(j => j + i * 3), (0 to 2).map(j => j * 3 + i))\n }.toList\n\n println(if (bingos.exists(_.forall(A(_) == 0))) \"Yes\" else \"No\")\n}", "language": "Scala", "metadata": {"date": 1585340776, "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/s358733178.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s358733178", "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 A = Array.fill(9)(in.nextInt)\n val N = in.nextInt\n\n (1 to N).foreach {i =>\n val b = in.nextInt\n A.indexWhere(_ == b) match {\n case -1 =>\n case n => A(n) = 0\n }\n }\n\n val bingos: Seq[Seq[Int]] =\n Seq(0, 4, 8) :: Seq(2, 4, 6) :: (0 to 2).flatMap { i =>\n Seq((0 to 2).map(j => j + i * 3), (0 to 2).map(j => j * 3 + i))\n }.toList\n\n println(if (bingos.exists(_.forall(A(_) == 0))) \"Yes\" else \"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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 379, "memory_kb": 25760}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s427731502", "group_id": "codeNet:p02760", "input_text": "object Main extends App {\n\tval a = Array.ofDim[Int](3, 3)\n\tfor(i<-0 until 3){\n\t\ta(i) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\t}\n\tval N = scala.io.StdIn.readInt\n\tfor(i<-0 until N){\n\t\tval b = scala.io.StdIn.readInt\n\n\t\tif(a(0).contains(b)){\n\t\t\ta(0)(a(0).indexOf(b)) = 0\n\t\t}\n\n\t\tif(a(1).contains(b)){\n\t\t\ta(1)(a(1).indexOf(b)) = 0\n\t\t}\n\n\t\tif(a(2).contains(b)){\n\t\t\ta(2)(a(2).indexOf(b)) = 0\n\t\t}\n\t}\n\n\tvar flag = false\n\n\tif(a(0).sum == 0 || a(1).sum == 0 || a(2).sum == 0) flag = true\n\n\tfor(i<-0 until 3){\n\t\tif(a(0)(i) + a(1)(i) + a(2)(i) == 0) flag = true\n\t}\n\n\tif(a(0)(0) + a(1)(1) + a(2)(2) == 0) flag = true\n\tif(a(0)(2) + a(1)(1) + a(2)(0) == 0) flag = true\n\n\tif(flag) println(\"Yes\")\n\telse println(\"No\")\n\n}\n", "language": "Scala", "metadata": {"date": 1584890826, "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/s427731502.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s427731502", "user_id": "u675876401"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n\tval a = Array.ofDim[Int](3, 3)\n\tfor(i<-0 until 3){\n\t\ta(i) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\t}\n\tval N = scala.io.StdIn.readInt\n\tfor(i<-0 until N){\n\t\tval b = scala.io.StdIn.readInt\n\n\t\tif(a(0).contains(b)){\n\t\t\ta(0)(a(0).indexOf(b)) = 0\n\t\t}\n\n\t\tif(a(1).contains(b)){\n\t\t\ta(1)(a(1).indexOf(b)) = 0\n\t\t}\n\n\t\tif(a(2).contains(b)){\n\t\t\ta(2)(a(2).indexOf(b)) = 0\n\t\t}\n\t}\n\n\tvar flag = false\n\n\tif(a(0).sum == 0 || a(1).sum == 0 || a(2).sum == 0) flag = true\n\n\tfor(i<-0 until 3){\n\t\tif(a(0)(i) + a(1)(i) + a(2)(i) == 0) flag = true\n\t}\n\n\tif(a(0)(0) + a(1)(1) + a(2)(2) == 0) flag = true\n\tif(a(0)(2) + a(1)(1) + a(2)(0) == 0) flag = true\n\n\tif(flag) println(\"Yes\")\n\telse println(\"No\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 710, "cpu_time_ms": 323, "memory_kb": 25412}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s788120619", "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 val ans = Range(0, n).map { i =>\n val gid = memberToGroup(i)\n val blocked = blocks(i).count(b => memberToGroup(b) == gid)\n groupToMember(gid).size - (1 + friends(i).size + blocked)\n }\n\n println(ans.mkString(\" \"))\n}", "language": "Scala", "metadata": {"date": 1584678561, "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/s788120619.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s788120619", "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 val ans = Range(0, n).map { i =>\n val gid = memberToGroup(i)\n val blocked = blocks(i).count(b => memberToGroup(b) == gid)\n groupToMember(gid).size - (1 + friends(i).size + blocked)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1282, "cpu_time_ms": 2111, "memory_kb": 157004}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s197405567", "group_id": "codeNet:p02762", "input_text": "import io.StdIn._\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 uf = UnionFind.of(N)\n val friendCount = Array.fill(N)(0)\n val blocks = Array.fill(N)(Array.empty[Int])\n\n for (_ <- 0 until M) {\n val friendship = readLine.split(\" \").map(_.toInt - 1) // 入力は 1始まり、プログラム上は0始まり\n val a = friendship(0);\n val b = friendship(1);\n uf.unite(a, b)\n friendCount(a) = friendCount(a) + 1\n friendCount(b) = friendCount(b) + 1\n }\n for (_ <- 0 until K) {\n val blockship = readLine.split(\" \").map(_.toInt - 1)\n val a = blockship(0)\n val b = blockship(1)\n blocks(a) = blocks(a) :+ b\n blocks(b) = blocks(b) :+ a\n }\n\n for (i <- 0 until N) {\n val blockCount = blocks(i).count(block => uf.same(i, block))\n val ans = uf.size(i) - 1 - friendCount(i) - blockCount\n print(s\"${ans} \")\n }\n print(\"\\n\")\n}\n\n/**\n * d(x) == a として\n * x がツリーの根であれば: a はツリーのサイズ(ノード数) に -1 をかけた数\n * x がツリーの根でなければ: a は関連ノードのインデックス番号\n *\n * @param d\n */\ncase class UnionFind(d: Array[Int]) {\n def root(x: Int): Int = if (d(x) < 0) x else {\n val rt = root(d(x))\n d(x) = rt // memoization\n rt\n }\n\n def unite(x: Int, y: Int): Boolean = {\n val xRoot = root(x)\n val yRoot = root(y)\n\n if (xRoot == yRoot) false\n else {\n if (xRoot < yRoot) {\n d(xRoot) = d(xRoot) + d(yRoot)\n d(yRoot) = xRoot\n } else {\n d(yRoot) = d(yRoot) + d(xRoot)\n d(xRoot) = yRoot\n }\n true\n }\n }\n\n def same(x: Int, y: Int): Boolean = root(x) == root(y)\n\n def size(x: Int): Int = -1 * d(root(x))\n}\n\nobject UnionFind {\n def of(n: Int) = UnionFind(Array.fill[Int](n)(-1))\n}\n", "language": "Scala", "metadata": {"date": 1583211046, "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/s197405567.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s197405567", "user_id": "u611263604"}, "prompt_components": {"gold_output": "0 1 0 1\n", "input_to_evaluate": "import io.StdIn._\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 uf = UnionFind.of(N)\n val friendCount = Array.fill(N)(0)\n val blocks = Array.fill(N)(Array.empty[Int])\n\n for (_ <- 0 until M) {\n val friendship = readLine.split(\" \").map(_.toInt - 1) // 入力は 1始まり、プログラム上は0始まり\n val a = friendship(0);\n val b = friendship(1);\n uf.unite(a, b)\n friendCount(a) = friendCount(a) + 1\n friendCount(b) = friendCount(b) + 1\n }\n for (_ <- 0 until K) {\n val blockship = readLine.split(\" \").map(_.toInt - 1)\n val a = blockship(0)\n val b = blockship(1)\n blocks(a) = blocks(a) :+ b\n blocks(b) = blocks(b) :+ a\n }\n\n for (i <- 0 until N) {\n val blockCount = blocks(i).count(block => uf.same(i, block))\n val ans = uf.size(i) - 1 - friendCount(i) - blockCount\n print(s\"${ans} \")\n }\n print(\"\\n\")\n}\n\n/**\n * d(x) == a として\n * x がツリーの根であれば: a はツリーのサイズ(ノード数) に -1 をかけた数\n * x がツリーの根でなければ: a は関連ノードのインデックス番号\n *\n * @param d\n */\ncase class UnionFind(d: Array[Int]) {\n def root(x: Int): Int = if (d(x) < 0) x else {\n val rt = root(d(x))\n d(x) = rt // memoization\n rt\n }\n\n def unite(x: Int, y: Int): Boolean = {\n val xRoot = root(x)\n val yRoot = root(y)\n\n if (xRoot == yRoot) false\n else {\n if (xRoot < yRoot) {\n d(xRoot) = d(xRoot) + d(yRoot)\n d(yRoot) = xRoot\n } else {\n d(yRoot) = d(yRoot) + d(xRoot)\n d(xRoot) = yRoot\n }\n true\n }\n }\n\n def same(x: Int, y: Int): Boolean = root(x) == root(y)\n\n def size(x: Int): Int = -1 * d(root(x))\n}\n\nobject UnionFind {\n def of(n: Int) = UnionFind(Array.fill[Int](n)(-1))\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nAn SNS has N users - User 1, User 2, \\cdots, User N.\n\nBetween these N users, there are some relationships - M friendships and K blockships.\n\nFor each i = 1, 2, \\cdots, M, there is a bidirectional friendship between User A_i and User B_i.\n\nFor each i = 1, 2, \\cdots, K, there is a bidirectional blockship between User C_i and User D_i.\n\nWe define User a to be a friend candidate for User b when all of the following four conditions are satisfied:\n\na \\neq b.\n\nThere is not a friendship between User a and User b.\n\nThere is not a blockship between User a and User b.\n\nThere exists a sequence c_0, c_1, c_2, \\cdots, c_L consisting of integers between 1 and N (inclusive) such that c_0 = a, c_L = b, and there is a friendship between User c_i and c_{i+1} for each i = 0, 1, \\cdots, L - 1.\n\nFor each user i = 1, 2, ... N, how many friend candidates does it have?\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10^5\n\n0 \\leq M \\leq 10^5\n\n0 \\leq K \\leq 10^5\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\n1 \\leq C_i, D_i \\leq N\n\nC_i \\neq D_i\n\n(A_i, B_i) \\neq (A_j, B_j) (i \\neq j)\n\n(A_i, B_i) \\neq (B_j, A_j)\n\n(C_i, D_i) \\neq (C_j, D_j) (i \\neq j)\n\n(C_i, D_i) \\neq (D_j, C_j)\n\n(A_i, B_i) \\neq (C_j, D_j)\n\n(A_i, B_i) \\neq (D_j, C_j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\nA_1 B_1\n\\vdots\nA_M B_M\nC_1 D_1\n\\vdots\nC_K D_K\n\nOutput\n\nPrint the answers in order, with space in between.\n\nSample Input 1\n\n4 4 1\n2 1\n1 3\n3 2\n3 4\n4 1\n\nSample Output 1\n\n0 1 0 1\n\nThere is a friendship between User 2 and 3, and between 3 and 4. Also, there is no friendship or blockship between User 2 and 4. Thus, User 4 is a friend candidate for User 2.\n\nHowever, neither User 1 or 3 is a friend candidate for User 2, so User 2 has one friend candidate.\n\nSample Input 2\n\n5 10 0\n1 2\n1 3\n1 4\n1 5\n3 2\n2 4\n2 5\n4 3\n5 3\n4 5\n\nSample Output 2\n\n0 0 0 0 0\n\nEveryone is a friend of everyone else and has no friend candidate.\n\nSample Input 3\n\n10 9 3\n10 1\n6 7\n8 2\n2 5\n8 4\n7 3\n10 9\n6 4\n5 8\n2 6\n7 5\n3 1\n\nSample Output 3\n\n1 3 5 4 3 3 3 3 1 0", "sample_input": "4 4 1\n2 1\n1 3\n3 2\n3 4\n4 1\n"}, "reference_outputs": ["0 1 0 1\n"], "source_document_id": "p02762", "source_text": "Score : 400 points\n\nProblem Statement\n\nAn SNS has N users - User 1, User 2, \\cdots, User N.\n\nBetween these N users, there are some relationships - M friendships and K blockships.\n\nFor each i = 1, 2, \\cdots, M, there is a bidirectional friendship between User A_i and User B_i.\n\nFor each i = 1, 2, \\cdots, K, there is a bidirectional blockship between User C_i and User D_i.\n\nWe define User a to be a friend candidate for User b when all of the following four conditions are satisfied:\n\na \\neq b.\n\nThere is not a friendship between User a and User b.\n\nThere is not a blockship between User a and User b.\n\nThere exists a sequence c_0, c_1, c_2, \\cdots, c_L consisting of integers between 1 and N (inclusive) such that c_0 = a, c_L = b, and there is a friendship between User c_i and c_{i+1} for each i = 0, 1, \\cdots, L - 1.\n\nFor each user i = 1, 2, ... N, how many friend candidates does it have?\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10^5\n\n0 \\leq M \\leq 10^5\n\n0 \\leq K \\leq 10^5\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\n1 \\leq C_i, D_i \\leq N\n\nC_i \\neq D_i\n\n(A_i, B_i) \\neq (A_j, B_j) (i \\neq j)\n\n(A_i, B_i) \\neq (B_j, A_j)\n\n(C_i, D_i) \\neq (C_j, D_j) (i \\neq j)\n\n(C_i, D_i) \\neq (D_j, C_j)\n\n(A_i, B_i) \\neq (C_j, D_j)\n\n(A_i, B_i) \\neq (D_j, C_j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\nA_1 B_1\n\\vdots\nA_M B_M\nC_1 D_1\n\\vdots\nC_K D_K\n\nOutput\n\nPrint the answers in order, with space in between.\n\nSample Input 1\n\n4 4 1\n2 1\n1 3\n3 2\n3 4\n4 1\n\nSample Output 1\n\n0 1 0 1\n\nThere is a friendship between User 2 and 3, and between 3 and 4. Also, there is no friendship or blockship between User 2 and 4. Thus, User 4 is a friend candidate for User 2.\n\nHowever, neither User 1 or 3 is a friend candidate for User 2, so User 2 has one friend candidate.\n\nSample Input 2\n\n5 10 0\n1 2\n1 3\n1 4\n1 5\n3 2\n2 4\n2 5\n4 3\n5 3\n4 5\n\nSample Output 2\n\n0 0 0 0 0\n\nEveryone is a friend of everyone else and has no friend candidate.\n\nSample Input 3\n\n10 9 3\n10 1\n6 7\n8 2\n2 5\n8 4\n7 3\n10 9\n6 4\n5 8\n2 6\n7 5\n3 1\n\nSample Output 3\n\n1 3 5 4 3 3 3 3 1 0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1864, "cpu_time_ms": 1705, "memory_kb": 110452}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s310950494", "group_id": "codeNet:p02762", "input_text": "import scala.collection.mutable.ArrayBuffer\n\nobject Main {\n def main(args: Array[String]): Unit = {\n solve2\n }\n\n\n def solve2(): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n, m, k = sc.nextInt()\n val users = Array.fill[User](n)(User(new ArrayBuffer[Int](), new ArrayBuffer[Int]()))\n val uf = new UnionFind(n)\n\n for (i <- 0 until m) {\n val a = sc.nextInt() - 1\n val b = sc.nextInt() - 1\n users(a).friends.append(b)\n users(b).friends.append(a)\n\n uf.unite(a, b)\n }\n for (i <- 0 until k) {\n val c = sc.nextInt() - 1\n val d = sc.nextInt() - 1\n users(c).blocks.append(d)\n users(d).blocks.append(c)\n }\n\n val pw = new java.io.PrintWriter(System.out)\n for (i <- 0 until n) {\n\n // 連結成分の数 - 自分自身 - 友達の数\n var ans = uf.size(i) - 1 - users(i).friends.size\n for (block <- users(i).blocks) {\n if (uf.same(i, block)) {\n // ブロック対象が同じ連結成分に存在したら、友達候補から減算する\n ans -= 1\n }\n }\n pw.println(ans)\n }\n pw.flush()\n }\n\n\n def solve(): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n, m, k = sc.nextInt()\n val users = Array.fill[User](n)(User(new ArrayBuffer[Int](), new ArrayBuffer[Int]()))\n\n for (i <- 0 until m) {\n val a = sc.nextInt() - 1\n val b = sc.nextInt() - 1\n users(a).friends.append(b)\n users(b).friends.append(a)\n }\n for (i <- 0 until k) {\n val c = sc.nextInt() - 1\n val d = sc.nextInt() - 1\n users(c).blocks.append(d)\n users(d).blocks.append(c)\n }\n\n val pw = new java.io.PrintWriter(System.out)\n for (i <- 0 until n) {\n val ans = search(i, users)\n pw.println(ans)\n }\n pw.flush()\n }\n\n def search(target: Int, users: Array[User]): Int = {\n val queue = scala.collection.mutable.Queue[Int]()\n val checked = new ArrayBuffer[Int]()\n val friends = users(target).friends\n val blocks = users(target).blocks\n var ans = 0\n\n users(target).friends.foreach(queue.enqueue(_))\n\n while (!queue.isEmpty) {\n val num = queue.dequeue()\n if (target != num && !checked.contains(num)) {\n if (!friends.contains(num) && !blocks.contains(num)) {\n ans += 1\n }\n\n checked.append(num)\n users(num).friends.foreach { f =>\n if (f != target && !checked.contains(f)) {\n queue.enqueue(f)\n }\n }\n }\n }\n\n return ans\n }\n\n case class User(friends: ArrayBuffer[Int], blocks: ArrayBuffer[Int])\n\n}\n\nclass UnionFind(n: Int) {\n private val d: ArrayBuffer[Int] = ArrayBuffer.fill[Int](n)(-1)\n\n def find(x: Int): Int = {\n if (d(x) < 0) {\n return x\n }\n else {\n d(x) = find(d(x))\n return d(x)\n }\n }\n\n def unite(x: Int, y: Int): Boolean = {\n // 根同士をくっつけるため根を取得\n val tmpX = find(x)\n val tmpY = find(y)\n if (tmpX == tmpY) {\n // 同じ連結成分内にどちらも存在するため、連結不要!\n return false\n }\n\n if (d(tmpX) < d(tmpY)) {\n // x方が集合が大きい場合、y->xの向きにくっつける\n d(tmpX) += d(tmpY)\n d(tmpY) = tmpX\n } else {\n // その逆\n d(tmpY) += d(tmpX)\n d(tmpX) = tmpY\n }\n\n return true\n }\n\n def same(x: Int, y: Int): Boolean = {\n find(x) == find(y)\n }\n\n def size(x: Int): Int = {\n -d(find(x))\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1583200876, "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/s310950494.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s310950494", "user_id": "u433254839"}, "prompt_components": {"gold_output": "0 1 0 1\n", "input_to_evaluate": "import scala.collection.mutable.ArrayBuffer\n\nobject Main {\n def main(args: Array[String]): Unit = {\n solve2\n }\n\n\n def solve2(): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n, m, k = sc.nextInt()\n val users = Array.fill[User](n)(User(new ArrayBuffer[Int](), new ArrayBuffer[Int]()))\n val uf = new UnionFind(n)\n\n for (i <- 0 until m) {\n val a = sc.nextInt() - 1\n val b = sc.nextInt() - 1\n users(a).friends.append(b)\n users(b).friends.append(a)\n\n uf.unite(a, b)\n }\n for (i <- 0 until k) {\n val c = sc.nextInt() - 1\n val d = sc.nextInt() - 1\n users(c).blocks.append(d)\n users(d).blocks.append(c)\n }\n\n val pw = new java.io.PrintWriter(System.out)\n for (i <- 0 until n) {\n\n // 連結成分の数 - 自分自身 - 友達の数\n var ans = uf.size(i) - 1 - users(i).friends.size\n for (block <- users(i).blocks) {\n if (uf.same(i, block)) {\n // ブロック対象が同じ連結成分に存在したら、友達候補から減算する\n ans -= 1\n }\n }\n pw.println(ans)\n }\n pw.flush()\n }\n\n\n def solve(): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n, m, k = sc.nextInt()\n val users = Array.fill[User](n)(User(new ArrayBuffer[Int](), new ArrayBuffer[Int]()))\n\n for (i <- 0 until m) {\n val a = sc.nextInt() - 1\n val b = sc.nextInt() - 1\n users(a).friends.append(b)\n users(b).friends.append(a)\n }\n for (i <- 0 until k) {\n val c = sc.nextInt() - 1\n val d = sc.nextInt() - 1\n users(c).blocks.append(d)\n users(d).blocks.append(c)\n }\n\n val pw = new java.io.PrintWriter(System.out)\n for (i <- 0 until n) {\n val ans = search(i, users)\n pw.println(ans)\n }\n pw.flush()\n }\n\n def search(target: Int, users: Array[User]): Int = {\n val queue = scala.collection.mutable.Queue[Int]()\n val checked = new ArrayBuffer[Int]()\n val friends = users(target).friends\n val blocks = users(target).blocks\n var ans = 0\n\n users(target).friends.foreach(queue.enqueue(_))\n\n while (!queue.isEmpty) {\n val num = queue.dequeue()\n if (target != num && !checked.contains(num)) {\n if (!friends.contains(num) && !blocks.contains(num)) {\n ans += 1\n }\n\n checked.append(num)\n users(num).friends.foreach { f =>\n if (f != target && !checked.contains(f)) {\n queue.enqueue(f)\n }\n }\n }\n }\n\n return ans\n }\n\n case class User(friends: ArrayBuffer[Int], blocks: ArrayBuffer[Int])\n\n}\n\nclass UnionFind(n: Int) {\n private val d: ArrayBuffer[Int] = ArrayBuffer.fill[Int](n)(-1)\n\n def find(x: Int): Int = {\n if (d(x) < 0) {\n return x\n }\n else {\n d(x) = find(d(x))\n return d(x)\n }\n }\n\n def unite(x: Int, y: Int): Boolean = {\n // 根同士をくっつけるため根を取得\n val tmpX = find(x)\n val tmpY = find(y)\n if (tmpX == tmpY) {\n // 同じ連結成分内にどちらも存在するため、連結不要!\n return false\n }\n\n if (d(tmpX) < d(tmpY)) {\n // x方が集合が大きい場合、y->xの向きにくっつける\n d(tmpX) += d(tmpY)\n d(tmpY) = tmpX\n } else {\n // その逆\n d(tmpY) += d(tmpX)\n d(tmpX) = tmpY\n }\n\n return true\n }\n\n def same(x: Int, y: Int): Boolean = {\n find(x) == find(y)\n }\n\n def size(x: Int): Int = {\n -d(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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3467, "cpu_time_ms": 1661, "memory_kb": 151424}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s013973484", "group_id": "codeNet:p02762", "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, m, k = sc.nextInt()\n val users = Array.fill[User](n)(User(new ArrayBuffer[Int](), new ArrayBuffer[Int]()))\n\n for (i <- 0 until m) {\n val a = sc.nextInt() - 1\n val b = sc.nextInt() - 1\n users(a).friends.append(b)\n users(b).friends.append(a)\n }\n for (i <- 0 until k) {\n val c = sc.nextInt() - 1\n val d = sc.nextInt() - 1\n users(c).blocks.append(d)\n users(d).blocks.append(c)\n }\n\n val pw = new java.io.PrintWriter(System.out)\n for (i <- 0 until n) {\n val ans = dfs(i, users)\n pw.println(ans)\n }\n pw.flush()\n }\n\n def dfs(target: Int, users: Array[User]): Int = {\n val queue = scala.collection.mutable.Queue[Int]()\n val checked = new ArrayBuffer[Int]()\n val friends = users(target).friends\n val blocks = users(target).blocks\n var ans = 0\n\n users(target).friends.foreach(queue.enqueue(_))\n\n while (!queue.isEmpty) {\n val num = queue.dequeue()\n if (target != num && !checked.contains(num)) {\n if (!friends.contains(num) && !blocks.contains(num)) {\n ans += 1\n }\n\n checked.append(num)\n users(num).friends.foreach(queue.enqueue(_))\n }\n }\n\n return ans\n }\n\n case class User(friends: ArrayBuffer[Int], blocks: ArrayBuffer[Int])\n\n}\n\n", "language": "Scala", "metadata": {"date": 1583119005, "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/s013973484.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s013973484", "user_id": "u433254839"}, "prompt_components": {"gold_output": "0 1 0 1\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, m, k = sc.nextInt()\n val users = Array.fill[User](n)(User(new ArrayBuffer[Int](), new ArrayBuffer[Int]()))\n\n for (i <- 0 until m) {\n val a = sc.nextInt() - 1\n val b = sc.nextInt() - 1\n users(a).friends.append(b)\n users(b).friends.append(a)\n }\n for (i <- 0 until k) {\n val c = sc.nextInt() - 1\n val d = sc.nextInt() - 1\n users(c).blocks.append(d)\n users(d).blocks.append(c)\n }\n\n val pw = new java.io.PrintWriter(System.out)\n for (i <- 0 until n) {\n val ans = dfs(i, users)\n pw.println(ans)\n }\n pw.flush()\n }\n\n def dfs(target: Int, users: Array[User]): Int = {\n val queue = scala.collection.mutable.Queue[Int]()\n val checked = new ArrayBuffer[Int]()\n val friends = users(target).friends\n val blocks = users(target).blocks\n var ans = 0\n\n users(target).friends.foreach(queue.enqueue(_))\n\n while (!queue.isEmpty) {\n val num = queue.dequeue()\n if (target != num && !checked.contains(num)) {\n if (!friends.contains(num) && !blocks.contains(num)) {\n ans += 1\n }\n\n checked.append(num)\n users(num).friends.foreach(queue.enqueue(_))\n }\n }\n\n return ans\n }\n\n case class User(friends: ArrayBuffer[Int], blocks: ArrayBuffer[Int])\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1476, "cpu_time_ms": 2111, "memory_kb": 155424}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s478595579", "group_id": "codeNet:p02765", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val N, R = sc.nextInt()\n println(R + (10 - N).max(0) * 100)\n}\n", "language": "Scala", "metadata": {"date": 1596110929, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/s478595579.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s478595579", "user_id": "u737111725"}, "prompt_components": {"gold_output": "3719\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val N, R = sc.nextInt()\n println(R + (10 - N).max(0) * 100)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 493, "memory_kb": 55360}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s442178703", "group_id": "codeNet:p02767", "input_text": "object Main extends App {\n\tval N = scala.io.StdIn.readInt\n\tval X = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\n\tprintln(X.map(z => z*z).sum - (X.sum)*(X.sum)/N)\n}", "language": "Scala", "metadata": {"date": 1585099057, "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/s442178703.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s442178703", "user_id": "u675876401"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "object Main extends App {\n\tval N = scala.io.StdIn.readInt\n\tval X = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\n\tprintln(X.map(z => z*z).sum - (X.sum)*(X.sum)/N)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N people living on a number line.\n\nThe i-th person lives at coordinate X_i.\n\nYou are going to hold a meeting that all N people have to attend.\n\nThe meeting can be held at any integer coordinate. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.\n\nFind the minimum total points of stamina the N people have to spend.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq X_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint the minimum total stamina the N people have to spend.\n\nSample Input 1\n\n2\n1 4\n\nSample Output 1\n\n5\n\nAssume the meeting is held at coordinate 2. In this case, the first person will spend (1 - 2)^2 points of stamina, and the second person will spend (4 - 2)^2 = 4 points of stamina, for a total of 5 points of stamina. This is the minimum total stamina that the 2 people have to spend.\n\nNote that you can hold the meeting only at an integer coordinate.\n\nSample Input 2\n\n7\n14 14 2 13 56 2 37\n\nSample Output 2\n\n2354", "sample_input": "2\n1 4\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02767", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N people living on a number line.\n\nThe i-th person lives at coordinate X_i.\n\nYou are going to hold a meeting that all N people have to attend.\n\nThe meeting can be held at any integer coordinate. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.\n\nFind the minimum total points of stamina the N people have to spend.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq X_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint the minimum total stamina the N people have to spend.\n\nSample Input 1\n\n2\n1 4\n\nSample Output 1\n\n5\n\nAssume the meeting is held at coordinate 2. In this case, the first person will spend (1 - 2)^2 points of stamina, and the second person will spend (4 - 2)^2 = 4 points of stamina, for a total of 5 points of stamina. This is the minimum total stamina that the 2 people have to spend.\n\nNote that you can hold the meeting only at an integer coordinate.\n\nSample Input 2\n\n7\n14 14 2 13 56 2 37\n\nSample Output 2\n\n2354", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 167, "cpu_time_ms": 330, "memory_kb": 27460}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s258209757", "group_id": "codeNet:p02771", "input_text": "object Main{\n import scala.io.StdIn._\n def main(args: Array[String]): Unit = {\n val a = readLine().split(\" \").distinct.length\n println(if(a == 2) \"Yes\" else \"No\")\n }\n}\n", "language": "Scala", "metadata": {"date": 1587657431, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02771.html", "problem_id": "p02771", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02771/input.txt", "sample_output_relpath": "derived/input_output/data/p02771/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02771/Scala/s258209757.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s258209757", "user_id": "u759091915"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main{\n import scala.io.StdIn._\n def main(args: Array[String]): Unit = {\n val a = readLine().split(\" \").distinct.length\n println(if(a == 2) \"Yes\" else \"No\")\n }\n}\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nA triple of numbers is said to be poor when two of those numbers are equal but the other number is different from those two numbers.\n\nYou will be given three integers A, B, and C. If this triple is poor, print Yes; otherwise, print No.\n\nConstraints\n\nA, B, and C are all integers between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf the given triple is poor, print Yes; otherwise, print No.\n\nSample Input 1\n\n5 7 5\n\nSample Output 1\n\nYes\n\nA and C are equal, but B is different from those two numbers, so this triple is poor.\n\nSample Input 2\n\n4 4 4\n\nSample Output 2\n\nNo\n\nA, B, and C are all equal, so this triple is not poor.\n\nSample Input 3\n\n4 9 6\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n3 3 4\n\nSample Output 4\n\nYes", "sample_input": "5 7 5\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02771", "source_text": "Score: 100 points\n\nProblem Statement\n\nA triple of numbers is said to be poor when two of those numbers are equal but the other number is different from those two numbers.\n\nYou will be given three integers A, B, and C. If this triple is poor, print Yes; otherwise, print No.\n\nConstraints\n\nA, B, and C are all integers between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf the given triple is poor, print Yes; otherwise, print No.\n\nSample Input 1\n\n5 7 5\n\nSample Output 1\n\nYes\n\nA and C are equal, but B is different from those two numbers, so this triple is poor.\n\nSample Input 2\n\n4 4 4\n\nSample Output 2\n\nNo\n\nA, B, and C are all equal, so this triple is not poor.\n\nSample Input 3\n\n4 9 6\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n3 3 4\n\nSample Output 4\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 330, "memory_kb": 25528}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s174118566", "group_id": "codeNet:p02772", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val isApprovable = List.fill(sc.nextInt())(sc.nextInt())\n .forall(i => i % 2 == 1 || i % 3 == 0 || i % 5 == 0)\n println(if (isApprovable) \"APPROVED\" else \"DENIED\")\n}\n", "language": "Scala", "metadata": {"date": 1596355154, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02772.html", "problem_id": "p02772", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02772/input.txt", "sample_output_relpath": "derived/input_output/data/p02772/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02772/Scala/s174118566.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s174118566", "user_id": "u737111725"}, "prompt_components": {"gold_output": "APPROVED\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val isApprovable = List.fill(sc.nextInt())(sc.nextInt())\n .forall(i => i % 2 == 1 || i % 3 == 0 || i % 5 == 0)\n println(if (isApprovable) \"APPROVED\" else \"DENIED\")\n}\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nYou are an immigration officer in the Kingdom of AtCoder. The document carried by an immigrant has some number of integers written on it, and you need to check whether they meet certain criteria.\n\nAccording to the regulation, the immigrant should be allowed entry to the kingdom if and only if the following condition is satisfied:\n\nAll even numbers written on the document are divisible by 3 or 5.\n\nIf the immigrant should be allowed entry according to the regulation, output APPROVED; otherwise, print DENIED.\n\nNotes\n\nThe condition in the statement can be rephrased as \"If x is an even number written on the document, x is divisible by 3 or 5\".\nHere \"if\" and \"or\" are logical terms.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nIf the immigrant should be allowed entry according to the regulation, print APPROVED; otherwise, print DENIED.\n\nSample Input 1\n\n5\n6 7 9 10 31\n\nSample Output 1\n\nAPPROVED\n\nThe even numbers written on the document are 6 and 10.\n\nAll of them are divisible by 3 or 5, so the immigrant should be allowed entry.\n\nSample Input 2\n\n3\n28 27 24\n\nSample Output 2\n\nDENIED\n\n28 violates the condition, so the immigrant should not be allowed entry.", "sample_input": "5\n6 7 9 10 31\n"}, "reference_outputs": ["APPROVED\n"], "source_document_id": "p02772", "source_text": "Score: 200 points\n\nProblem Statement\n\nYou are an immigration officer in the Kingdom of AtCoder. The document carried by an immigrant has some number of integers written on it, and you need to check whether they meet certain criteria.\n\nAccording to the regulation, the immigrant should be allowed entry to the kingdom if and only if the following condition is satisfied:\n\nAll even numbers written on the document are divisible by 3 or 5.\n\nIf the immigrant should be allowed entry according to the regulation, output APPROVED; otherwise, print DENIED.\n\nNotes\n\nThe condition in the statement can be rephrased as \"If x is an even number written on the document, x is divisible by 3 or 5\".\nHere \"if\" and \"or\" are logical terms.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nIf the immigrant should be allowed entry according to the regulation, print APPROVED; otherwise, print DENIED.\n\nSample Input 1\n\n5\n6 7 9 10 31\n\nSample Output 1\n\nAPPROVED\n\nThe even numbers written on the document are 6 and 10.\n\nAll of them are divisible by 3 or 5, so the immigrant should be allowed entry.\n\nSample Input 2\n\n3\n28 27 24\n\nSample Output 2\n\nDENIED\n\n28 violates the condition, so the immigrant should not be allowed entry.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 242, "cpu_time_ms": 491, "memory_kb": 55376}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s987014793", "group_id": "codeNet:p02772", "input_text": "import scala.io.StdIn._\n\nobject Main extends App {\n\n\n val n = readInt()\n val A = readLine().split(\" \").map(_.toInt)\n\n def solve() = {\n val isValid = A.map { num =>\n if(num % 2 == 0 && num % 5 == 0 || num % 3 == 0) true else true\n }.forall(identity)\n if(isValid) \"APPROVED\" else \"DENIED\"\n }\n\n println(solve())\n\n}\n\n", "language": "Scala", "metadata": {"date": 1594759311, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02772.html", "problem_id": "p02772", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02772/input.txt", "sample_output_relpath": "derived/input_output/data/p02772/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02772/Scala/s987014793.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s987014793", "user_id": "u947008426"}, "prompt_components": {"gold_output": "APPROVED\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main extends App {\n\n\n val n = readInt()\n val A = readLine().split(\" \").map(_.toInt)\n\n def solve() = {\n val isValid = A.map { num =>\n if(num % 2 == 0 && num % 5 == 0 || num % 3 == 0) true else true\n }.forall(identity)\n if(isValid) \"APPROVED\" else \"DENIED\"\n }\n\n println(solve())\n\n}\n\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nYou are an immigration officer in the Kingdom of AtCoder. The document carried by an immigrant has some number of integers written on it, and you need to check whether they meet certain criteria.\n\nAccording to the regulation, the immigrant should be allowed entry to the kingdom if and only if the following condition is satisfied:\n\nAll even numbers written on the document are divisible by 3 or 5.\n\nIf the immigrant should be allowed entry according to the regulation, output APPROVED; otherwise, print DENIED.\n\nNotes\n\nThe condition in the statement can be rephrased as \"If x is an even number written on the document, x is divisible by 3 or 5\".\nHere \"if\" and \"or\" are logical terms.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nIf the immigrant should be allowed entry according to the regulation, print APPROVED; otherwise, print DENIED.\n\nSample Input 1\n\n5\n6 7 9 10 31\n\nSample Output 1\n\nAPPROVED\n\nThe even numbers written on the document are 6 and 10.\n\nAll of them are divisible by 3 or 5, so the immigrant should be allowed entry.\n\nSample Input 2\n\n3\n28 27 24\n\nSample Output 2\n\nDENIED\n\n28 violates the condition, so the immigrant should not be allowed entry.", "sample_input": "5\n6 7 9 10 31\n"}, "reference_outputs": ["APPROVED\n"], "source_document_id": "p02772", "source_text": "Score: 200 points\n\nProblem Statement\n\nYou are an immigration officer in the Kingdom of AtCoder. The document carried by an immigrant has some number of integers written on it, and you need to check whether they meet certain criteria.\n\nAccording to the regulation, the immigrant should be allowed entry to the kingdom if and only if the following condition is satisfied:\n\nAll even numbers written on the document are divisible by 3 or 5.\n\nIf the immigrant should be allowed entry according to the regulation, output APPROVED; otherwise, print DENIED.\n\nNotes\n\nThe condition in the statement can be rephrased as \"If x is an even number written on the document, x is divisible by 3 or 5\".\nHere \"if\" and \"or\" are logical terms.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nIf the immigrant should be allowed entry according to the regulation, print APPROVED; otherwise, print DENIED.\n\nSample Input 1\n\n5\n6 7 9 10 31\n\nSample Output 1\n\nAPPROVED\n\nThe even numbers written on the document are 6 and 10.\n\nAll of them are divisible by 3 or 5, so the immigrant should be allowed entry.\n\nSample Input 2\n\n3\n28 27 24\n\nSample Output 2\n\nDENIED\n\n28 violates the condition, so the immigrant should not be allowed entry.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 332, "cpu_time_ms": 502, "memory_kb": 54732}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s267139681", "group_id": "codeNet:p02772", "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 var approved = true\n for (num <- a.filter(_ % 2 == 0)) {\n if (num % 3 != 0 && num % 5 != 0) {\n approved = false\n }\n }\n\n if (approved) println(\"APPROVED \")\n else println(\"DENIED \")\n }\n}\n", "language": "Scala", "metadata": {"date": 1581970005, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02772.html", "problem_id": "p02772", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02772/input.txt", "sample_output_relpath": "derived/input_output/data/p02772/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02772/Scala/s267139681.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s267139681", "user_id": "u433254839"}, "prompt_components": {"gold_output": "APPROVED\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 var approved = true\n for (num <- a.filter(_ % 2 == 0)) {\n if (num % 3 != 0 && num % 5 != 0) {\n approved = false\n }\n }\n\n if (approved) println(\"APPROVED \")\n else println(\"DENIED \")\n }\n}\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nYou are an immigration officer in the Kingdom of AtCoder. The document carried by an immigrant has some number of integers written on it, and you need to check whether they meet certain criteria.\n\nAccording to the regulation, the immigrant should be allowed entry to the kingdom if and only if the following condition is satisfied:\n\nAll even numbers written on the document are divisible by 3 or 5.\n\nIf the immigrant should be allowed entry according to the regulation, output APPROVED; otherwise, print DENIED.\n\nNotes\n\nThe condition in the statement can be rephrased as \"If x is an even number written on the document, x is divisible by 3 or 5\".\nHere \"if\" and \"or\" are logical terms.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nIf the immigrant should be allowed entry according to the regulation, print APPROVED; otherwise, print DENIED.\n\nSample Input 1\n\n5\n6 7 9 10 31\n\nSample Output 1\n\nAPPROVED\n\nThe even numbers written on the document are 6 and 10.\n\nAll of them are divisible by 3 or 5, so the immigrant should be allowed entry.\n\nSample Input 2\n\n3\n28 27 24\n\nSample Output 2\n\nDENIED\n\n28 violates the condition, so the immigrant should not be allowed entry.", "sample_input": "5\n6 7 9 10 31\n"}, "reference_outputs": ["APPROVED\n"], "source_document_id": "p02772", "source_text": "Score: 200 points\n\nProblem Statement\n\nYou are an immigration officer in the Kingdom of AtCoder. The document carried by an immigrant has some number of integers written on it, and you need to check whether they meet certain criteria.\n\nAccording to the regulation, the immigrant should be allowed entry to the kingdom if and only if the following condition is satisfied:\n\nAll even numbers written on the document are divisible by 3 or 5.\n\nIf the immigrant should be allowed entry according to the regulation, output APPROVED; otherwise, print DENIED.\n\nNotes\n\nThe condition in the statement can be rephrased as \"If x is an even number written on the document, x is divisible by 3 or 5\".\nHere \"if\" and \"or\" are logical terms.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nIf the immigrant should be allowed entry according to the regulation, print APPROVED; otherwise, print DENIED.\n\nSample Input 1\n\n5\n6 7 9 10 31\n\nSample Output 1\n\nAPPROVED\n\nThe even numbers written on the document are 6 and 10.\n\nAll of them are divisible by 3 or 5, so the immigrant should be allowed entry.\n\nSample Input 2\n\n3\n28 27 24\n\nSample Output 2\n\nDENIED\n\n28 violates the condition, so the immigrant should not be allowed entry.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 475, "cpu_time_ms": 351, "memory_kb": 27320}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s590344335", "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.HashMap[String,Int]()\n var max=0\n for {i <- (0 until(n))}{\n val s=readLine()\n map(s) = if(map.contains(s)) map(s) + 1 else 1\n max=Math.max(map(s),max)\n }\n map.toSeq.collect{case r if r._2 == max => r._1}.sorted.foreach(println(_))\n}", "language": "Scala", "metadata": {"date": 1588008209, "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/s590344335.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s590344335", "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.HashMap[String,Int]()\n var max=0\n for {i <- (0 until(n))}{\n val s=readLine()\n map(s) = if(map.contains(s)) map(s) + 1 else 1\n max=Math.max(map(s),max)\n }\n map.toSeq.collect{case r if r._2 == max => 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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 349, "cpu_time_ms": 2111, "memory_kb": 80356}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s062509808", "group_id": "codeNet:p02777", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val s, t = sc.next()\n val a, b = sc.nextInt()\n val u = sc.next()\n var num_s = -1\n var num_t = -1\n if (s==u) {\n println(\"red\")\n num_s = a - 1\n num_t = b\n } else {\n println(\"blue\")\n num_s = a\n num_t = b - 1\n }\n println(s\"$num_s $num_t\") \n}", "language": "Scala", "metadata": {"date": 1582242531, "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/s062509808.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s062509808", "user_id": "u842388336"}, "prompt_components": {"gold_output": "2 4\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val s, t = sc.next()\n val a, b = sc.nextInt()\n val u = sc.next()\n var num_s = -1\n var num_t = -1\n if (s==u) {\n println(\"red\")\n num_s = a - 1\n num_t = b\n } else {\n println(\"blue\")\n num_s = a\n num_t = b - 1\n }\n println(s\"$num_s $num_t\") \n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have A balls with the string S written on each of them and B balls with the string T written on each of them.\n\nFrom these balls, Takahashi chooses one with the string U written on it and throws it away.\n\nFind the number of balls with the string S and balls with the string T that we have now.\n\nConstraints\n\nS, T, and U are strings consisting of lowercase English letters.\n\nThe lengths of S and T are each between 1 and 10 (inclusive).\n\nS \\not= T\n\nS=U or T=U.\n\n1 \\leq A,B \\leq 10\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\nA B\nU\n\nOutput\n\nPrint the answer, with space in between.\n\nSample Input 1\n\nred blue\n3 4\nred\n\nSample Output 1\n\n2 4\n\nTakahashi chose a ball with red written on it and threw it away.\nNow we have two balls with the string S and four balls with the string T.\n\nSample Input 2\n\nred blue\n5 5\nblue\n\nSample Output 2\n\n5 4\n\nTakahashi chose a ball with blue written on it and threw it away.\nNow we have five balls with the string S and four balls with the string T.", "sample_input": "red blue\n3 4\nred\n"}, "reference_outputs": ["2 4\n"], "source_document_id": "p02777", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have A balls with the string S written on each of them and B balls with the string T written on each of them.\n\nFrom these balls, Takahashi chooses one with the string U written on it and throws it away.\n\nFind the number of balls with the string S and balls with the string T that we have now.\n\nConstraints\n\nS, T, and U are strings consisting of lowercase English letters.\n\nThe lengths of S and T are each between 1 and 10 (inclusive).\n\nS \\not= T\n\nS=U or T=U.\n\n1 \\leq A,B \\leq 10\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\nA B\nU\n\nOutput\n\nPrint the answer, with space in between.\n\nSample Input 1\n\nred blue\n3 4\nred\n\nSample Output 1\n\n2 4\n\nTakahashi chose a ball with red written on it and threw it away.\nNow we have two balls with the string S and four balls with the string T.\n\nSample Input 2\n\nred blue\n5 5\nblue\n\nSample Output 2\n\n5 4\n\nTakahashi chose a ball with blue written on it and threw it away.\nNow we have five balls with the string S and four balls with the string T.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 335, "cpu_time_ms": 354, "memory_kb": 27336}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s014273632", "group_id": "codeNet:p02777", "input_text": "object Main extends App {\n val stInput = scala.io.StdIn.readLine()\n val stArray = stInput.split(\" \").toSeq\n val abInput = scala.io.StdIn.readLine()\n val abArray = abInput.split(\" \").map(_.toInt).toSeq\n val u = scala.io.StdIn.readLine()\n if(u == stArray(0)) {\n println((abArray(0) - 1) + \" \" + abArray(1))\n } else {\n println(abArray(0) + \" \" + (abArray(1) - 1))\n }\n\n}", "language": "Scala", "metadata": {"date": 1581278878, "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/s014273632.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s014273632", "user_id": "u105921924"}, "prompt_components": {"gold_output": "2 4\n", "input_to_evaluate": "object Main extends App {\n val stInput = scala.io.StdIn.readLine()\n val stArray = stInput.split(\" \").toSeq\n val abInput = scala.io.StdIn.readLine()\n val abArray = abInput.split(\" \").map(_.toInt).toSeq\n val u = scala.io.StdIn.readLine()\n if(u == stArray(0)) {\n println((abArray(0) - 1) + \" \" + abArray(1))\n } else {\n println(abArray(0) + \" \" + (abArray(1) - 1))\n }\n\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have A balls with the string S written on each of them and B balls with the string T written on each of them.\n\nFrom these balls, Takahashi chooses one with the string U written on it and throws it away.\n\nFind the number of balls with the string S and balls with the string T that we have now.\n\nConstraints\n\nS, T, and U are strings consisting of lowercase English letters.\n\nThe lengths of S and T are each between 1 and 10 (inclusive).\n\nS \\not= T\n\nS=U or T=U.\n\n1 \\leq A,B \\leq 10\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\nA B\nU\n\nOutput\n\nPrint the answer, with space in between.\n\nSample Input 1\n\nred blue\n3 4\nred\n\nSample Output 1\n\n2 4\n\nTakahashi chose a ball with red written on it and threw it away.\nNow we have two balls with the string S and four balls with the string T.\n\nSample Input 2\n\nred blue\n5 5\nblue\n\nSample Output 2\n\n5 4\n\nTakahashi chose a ball with blue written on it and threw it away.\nNow we have five balls with the string S and four balls with the string T.", "sample_input": "red blue\n3 4\nred\n"}, "reference_outputs": ["2 4\n"], "source_document_id": "p02777", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have A balls with the string S written on each of them and B balls with the string T written on each of them.\n\nFrom these balls, Takahashi chooses one with the string U written on it and throws it away.\n\nFind the number of balls with the string S and balls with the string T that we have now.\n\nConstraints\n\nS, T, and U are strings consisting of lowercase English letters.\n\nThe lengths of S and T are each between 1 and 10 (inclusive).\n\nS \\not= T\n\nS=U or T=U.\n\n1 \\leq A,B \\leq 10\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\nA B\nU\n\nOutput\n\nPrint the answer, with space in between.\n\nSample Input 1\n\nred blue\n3 4\nred\n\nSample Output 1\n\n2 4\n\nTakahashi chose a ball with red written on it and threw it away.\nNow we have two balls with the string S and four balls with the string T.\n\nSample Input 2\n\nred blue\n5 5\nblue\n\nSample Output 2\n\n5 4\n\nTakahashi chose a ball with blue written on it and threw it away.\nNow we have five balls with the string S and four balls with the string T.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 383, "cpu_time_ms": 336, "memory_kb": 27348}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s644973531", "group_id": "codeNet:p02778", "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 = List.fill(s.length)(\"x\").mkString\n println(res)\n}\n", "language": "Scala", "metadata": {"date": 1595615072, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/s644973531.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s644973531", "user_id": "u829407811"}, "prompt_components": {"gold_output": "xxxxxxx\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 = List.fill(s.length)(\"x\").mkString\n println(res)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 499, "memory_kb": 55400}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s342002895", "group_id": "codeNet:p02778", "input_text": "object Main extends App{\n import scala.io.StdIn._\n println(\"x\"*readLine().length)\n}\n", "language": "Scala", "metadata": {"date": 1587733691, "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/s342002895.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s342002895", "user_id": "u759091915"}, "prompt_components": {"gold_output": "xxxxxxx\n", "input_to_evaluate": "object Main extends App{\n import scala.io.StdIn._\n println(\"x\"*readLine().length)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 327, "memory_kb": 25412}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s414554761", "group_id": "codeNet:p02778", "input_text": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n\n val s = readLine()\n\n println(s.map(_ => 'x'))\n}\n", "language": "Scala", "metadata": {"date": 1581280723, "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/s414554761.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s414554761", "user_id": "u944710712"}, "prompt_components": {"gold_output": "xxxxxxx\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n\n val s = readLine()\n\n println(s.map(_ => 'x'))\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 110, "cpu_time_ms": 330, "memory_kb": 27180}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s477609628", "group_id": "codeNet:p02780", "input_text": "object Main extends App {\n def getExpect(i: Int): Double = {\n var expect = 0d\n (1 to i).foreach(k => expect = expect + k.toDouble / i.toDouble)\n expect\n }\n val nkInput = scala.io.StdIn.readLine()\n val nkArray = nkInput.split(\" \").map(_.toInt).toSeq\n val n = nkArray(0)\n val k = nkArray(1)\n val pInput = scala.io.StdIn.readLine()\n val pArray = pInput.split(\" \").map(p => getExpect(p.toInt)).toVector\n\n var maxSum = -1d\n var sumTotal = 0\n\n (0 to n - 1).foreach { i =>\n if (i >= k - 1) {\n var tempSum = 0d\n (0 to k - 1).foreach { j =>\n tempSum = tempSum + pArray(i - j)\n }\n if(maxSum < tempSum) {\n maxSum = tempSum\n }\n }\n }\n\n println(maxSum)\n\n}", "language": "Scala", "metadata": {"date": 1581283258, "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/s477609628.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s477609628", "user_id": "u105921924"}, "prompt_components": {"gold_output": "7.000000000000\n", "input_to_evaluate": "object Main extends App {\n def getExpect(i: Int): Double = {\n var expect = 0d\n (1 to i).foreach(k => expect = expect + k.toDouble / i.toDouble)\n expect\n }\n val nkInput = scala.io.StdIn.readLine()\n val nkArray = nkInput.split(\" \").map(_.toInt).toSeq\n val n = nkArray(0)\n val k = nkArray(1)\n val pInput = scala.io.StdIn.readLine()\n val pArray = pInput.split(\" \").map(p => getExpect(p.toInt)).toVector\n\n var maxSum = -1d\n var sumTotal = 0\n\n (0 to n - 1).foreach { i =>\n if (i >= k - 1) {\n var tempSum = 0d\n (0 to k - 1).foreach { j =>\n tempSum = tempSum + pArray(i - j)\n }\n if(maxSum < tempSum) {\n maxSum = tempSum\n }\n }\n }\n\n println(maxSum)\n\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N dice arranged in a line from left to right. The i-th die from the left shows p_i numbers from 1 to p_i with equal probability when thrown.\n\nWe will choose K adjacent dice, throw each of them independently, and compute the sum of the numbers shown. Find the maximum possible value of the expected value of this sum.\n\nConstraints\n\n1 ≤ K ≤ N ≤ 200000\n\n1 ≤ p_i ≤ 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\np_1 ... p_N\n\nOutput\n\nPrint the maximum possible value of the expected value of the sum of the numbers shown.\n\nYour output will be considered correct when its absolute or relative error from our answer is at most 10^{-6}.\n\nSample Input 1\n\n5 3\n1 2 2 4 5\n\nSample Output 1\n\n7.000000000000\n\nWhen we throw the third, fourth, and fifth dice from the left, the expected value of the sum of the numbers shown is 7. This is the maximum value we can achieve.\n\nSample Input 2\n\n4 1\n6 6 6 6\n\nSample Output 2\n\n3.500000000000\n\nRegardless of which die we choose, the expected value of the number shown is 3.5.\n\nSample Input 3\n\n10 4\n17 13 13 12 15 20 10 13 17 11\n\nSample Output 3\n\n32.000000000000", "sample_input": "5 3\n1 2 2 4 5\n"}, "reference_outputs": ["7.000000000000\n"], "source_document_id": "p02780", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have N dice arranged in a line from left to right. The i-th die from the left shows p_i numbers from 1 to p_i with equal probability when thrown.\n\nWe will choose K adjacent dice, throw each of them independently, and compute the sum of the numbers shown. Find the maximum possible value of the expected value of this sum.\n\nConstraints\n\n1 ≤ K ≤ N ≤ 200000\n\n1 ≤ p_i ≤ 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\np_1 ... p_N\n\nOutput\n\nPrint the maximum possible value of the expected value of the sum of the numbers shown.\n\nYour output will be considered correct when its absolute or relative error from our answer is at most 10^{-6}.\n\nSample Input 1\n\n5 3\n1 2 2 4 5\n\nSample Output 1\n\n7.000000000000\n\nWhen we throw the third, fourth, and fifth dice from the left, the expected value of the sum of the numbers shown is 7. This is the maximum value we can achieve.\n\nSample Input 2\n\n4 1\n6 6 6 6\n\nSample Output 2\n\n3.500000000000\n\nRegardless of which die we choose, the expected value of the number shown is 3.5.\n\nSample Input 3\n\n10 4\n17 13 13 12 15 20 10 13 17 11\n\nSample Output 3\n\n32.000000000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 710, "cpu_time_ms": 2111, "memory_kb": 77064}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s088750612", "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: Double = 0\n var l = Array.empty[Int]\n for (i <- 0 to n-k) {\n val sub = pn.slice(i, i+k)\n val sum = sub.sum\n if (max < sum) {max = sum; l = sub}\n }\n\n val exp = l.map(x => (1 to x).sum / x.toDouble).sum\n println(exp)\n}", "language": "Scala", "metadata": {"date": 1581280783, "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/s088750612.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s088750612", "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: Double = 0\n var l = Array.empty[Int]\n for (i <- 0 to n-k) {\n val sub = pn.slice(i, i+k)\n val sum = sub.sum\n if (max < sum) {max = sum; l = sub}\n }\n\n val exp = l.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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 138868}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s670160341", "group_id": "codeNet:p02783", "input_text": "object Main extends App {\n val num = readLine\n val h = num.split(\" \")(0).toInt\n val a = num.split(\" \")(1).toInt\n\n val result = if (h%a==0) (h/a) else ((h/a)+1)\n println(result); \n}", "language": "Scala", "metadata": {"date": 1582108916, "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/s670160341.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s670160341", "user_id": "u985713032"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main extends App {\n val num = readLine\n val h = num.split(\" \")(0).toInt\n val a = num.split(\" \")(1).toInt\n\n val result = if (h%a==0) (h/a) else ((h/a)+1)\n println(result); \n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nServal is fighting with a monster.\n\nThe health of the monster is H.\n\nIn one attack, Serval can decrease the monster's health by A.\nThere is no other way to decrease the monster's health.\n\nServal wins when the monster's health becomes 0 or below.\n\nFind the number of attacks Serval needs to make before winning.\n\nConstraints\n\n1 \\leq H \\leq 10^4\n\n1 \\leq A \\leq 10^4\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH A\n\nOutput\n\nPrint the number of attacks Serval needs to make before winning.\n\nSample Input 1\n\n10 4\n\nSample Output 1\n\n3\n\nAfter one attack, the monster's health will be 6.\n\nAfter two attacks, the monster's health will be 2.\n\nAfter three attacks, the monster's health will be -2.\n\nThus, Serval needs to make three attacks to win.\n\nSample Input 2\n\n1 10000\n\nSample Output 2\n\n1\n\nSample Input 3\n\n10000 1\n\nSample Output 3\n\n10000", "sample_input": "10 4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02783", "source_text": "Score : 100 points\n\nProblem Statement\n\nServal is fighting with a monster.\n\nThe health of the monster is H.\n\nIn one attack, Serval can decrease the monster's health by A.\nThere is no other way to decrease the monster's health.\n\nServal wins when the monster's health becomes 0 or below.\n\nFind the number of attacks Serval needs to make before winning.\n\nConstraints\n\n1 \\leq H \\leq 10^4\n\n1 \\leq A \\leq 10^4\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH A\n\nOutput\n\nPrint the number of attacks Serval needs to make before winning.\n\nSample Input 1\n\n10 4\n\nSample Output 1\n\n3\n\nAfter one attack, the monster's health will be 6.\n\nAfter two attacks, the monster's health will be 2.\n\nAfter three attacks, the monster's health will be -2.\n\nThus, Serval needs to make three attacks to win.\n\nSample Input 2\n\n1 10000\n\nSample Output 2\n\n1\n\nSample Input 3\n\n10000 1\n\nSample Output 3\n\n10000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 200, "cpu_time_ms": 315, "memory_kb": 27324}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s194924152", "group_id": "codeNet:p02784", "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(if (sc.nextLong() <= Array.fill(sc.nextInt())(sc.nextLong()).sum) \"Yes\" else \"No\")\n }\n\n val mod: Long = (1e9 + 7).toLong\n\n @scala.annotation.tailrec\n def recursive(H: Long, monsterCount: Long, attackCount: Long): Long = {\n if (H == 0) attackCount else recursive(H / 2, monsterCount * 2, attackCount + monsterCount)\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": 1580768539, "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/s194924152.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s194924152", "user_id": "u779353743"}, "prompt_components": {"gold_output": "Yes\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(if (sc.nextLong() <= Array.fill(sc.nextInt())(sc.nextLong()).sum) \"Yes\" else \"No\")\n }\n\n val mod: Long = (1e9 + 7).toLong\n\n @scala.annotation.tailrec\n def recursive(H: Long, monsterCount: Long, attackCount: Long): Long = {\n if (H == 0) attackCount else recursive(H / 2, monsterCount * 2, attackCount + monsterCount)\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 : 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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 8383, "cpu_time_ms": 569, "memory_kb": 38224}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s427975546", "group_id": "codeNet:p02784", "input_text": "object Main extends App {\n val hn = scala.io.StdIn.readLine()\n val hnArray = hn.split(\" \").map(_.toLong).toVector\n val h = hnArray(0)\n val n = hnArray(1)\n val a = scala.io.StdIn.readLine()\n val aArray = a.split(\" \").map(_.toLong).toVector\n val aArraySum = aArray.sum\n\n println(if(aArraySum >= h) \"Yes\" else \"No\")\n}", "language": "Scala", "metadata": {"date": 1580069405, "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/s427975546.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s427975546", "user_id": "u105921924"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n val hn = scala.io.StdIn.readLine()\n val hnArray = hn.split(\" \").map(_.toLong).toVector\n val h = hnArray(0)\n val n = hnArray(1)\n val a = scala.io.StdIn.readLine()\n val aArray = a.split(\" \").map(_.toLong).toVector\n val aArraySum = aArray.sum\n\n println(if(aArraySum >= h) \"Yes\" else \"No\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 570, "memory_kb": 46848}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s503219136", "group_id": "codeNet:p02785", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val N, K = sc.nextInt()\n println(List.fill(N)(sc.nextLong()).sorted(Ordering[Long].reverse).drop(K).sum)\n}\n", "language": "Scala", "metadata": {"date": 1596356001, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02785.html", "problem_id": "p02785", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02785/input.txt", "sample_output_relpath": "derived/input_output/data/p02785/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02785/Scala/s503219136.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s503219136", "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 N, K = sc.nextInt()\n println(List.fill(N)(sc.nextLong()).sorted(Ordering[Long].reverse).drop(K).sum)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nFennec is fighting with N monsters.\n\nThe health of the i-th monster is H_i.\n\nFennec can do the following two actions:\n\nAttack: Fennec chooses one monster. That monster's health will decrease by 1.\n\nSpecial Move: Fennec chooses one monster. That monster's health will become 0.\n\nThere is no way other than Attack and Special Move to decrease the monsters' health.\n\nFennec wins when all the monsters' healths become 0 or below.\n\nFind the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning when she can use Special Move at most K times.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq K \\leq 2 \\times 10^5\n\n1 \\leq H_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nH_1 ... H_N\n\nOutput\n\nPrint the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning.\n\nSample Input 1\n\n3 1\n4 1 5\n\nSample Output 1\n\n5\n\nBy using Special Move on the third monster, and doing Attack four times on the first monster and once on the second monster, Fennec can win with five Attacks.\n\nSample Input 2\n\n8 9\n7 9 3 2 3 8 4 6\n\nSample Output 2\n\n0\n\nShe can use Special Move on all the monsters.\n\nSample Input 3\n\n3 0\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n3000000000\n\nWatch out for overflow.", "sample_input": "3 1\n4 1 5\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02785", "source_text": "Score : 300 points\n\nProblem Statement\n\nFennec is fighting with N monsters.\n\nThe health of the i-th monster is H_i.\n\nFennec can do the following two actions:\n\nAttack: Fennec chooses one monster. That monster's health will decrease by 1.\n\nSpecial Move: Fennec chooses one monster. That monster's health will become 0.\n\nThere is no way other than Attack and Special Move to decrease the monsters' health.\n\nFennec wins when all the monsters' healths become 0 or below.\n\nFind the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning when she can use Special Move at most K times.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq K \\leq 2 \\times 10^5\n\n1 \\leq H_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nH_1 ... H_N\n\nOutput\n\nPrint the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning.\n\nSample Input 1\n\n3 1\n4 1 5\n\nSample Output 1\n\n5\n\nBy using Special Move on the third monster, and doing Attack four times on the first monster and once on the second monster, Fennec can win with five Attacks.\n\nSample Input 2\n\n8 9\n7 9 3 2 3 8 4 6\n\nSample Output 2\n\n0\n\nShe can use Special Move on all the monsters.\n\nSample Input 3\n\n3 0\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n3000000000\n\nWatch out for overflow.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 180, "cpu_time_ms": 1271, "memory_kb": 72672}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s881816117", "group_id": "codeNet:p02786", "input_text": "import scala.io.StdIn._\nobject Main extends App {\n val h = readLong\n\n def solve(n: Long): Long = n match {\n case 0 => 0\n case 1 => 1\n case n => 2 * solve(n / 2) + 1\n }\n\n println(solve(h))\n}\n", "language": "Scala", "metadata": {"date": 1580118362, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02786.html", "problem_id": "p02786", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02786/input.txt", "sample_output_relpath": "derived/input_output/data/p02786/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02786/Scala/s881816117.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s881816117", "user_id": "u518641666"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.io.StdIn._\nobject Main extends App {\n val h = readLong\n\n def solve(n: Long): Long = n match {\n case 0 => 0\n case 1 => 1\n case n => 2 * solve(n / 2) + 1\n }\n\n println(solve(h))\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nCaracal is fighting with a monster.\n\nThe health of the monster is H.\n\nCaracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:\n\nIf the monster's health is 1, it drops to 0.\n\nIf the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \\lfloor X/2 \\rfloor.\n\n(\\lfloor r \\rfloor denotes the greatest integer not exceeding r.)\n\nCaracal wins when the healths of all existing monsters become 0 or below.\n\nFind the minimum number of attacks Caracal needs to make before winning.\n\nConstraints\n\n1 \\leq H \\leq 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH\n\nOutput\n\nFind the minimum number of attacks Caracal needs to make before winning.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n3\n\nWhen Caracal attacks the initial monster, it disappears, and two monsters appear, each with the health of 1.\n\nThen, Caracal can attack each of these new monsters once and win with a total of three attacks.\n\nSample Input 2\n\n4\n\nSample Output 2\n\n7\n\nSample Input 3\n\n1000000000000\n\nSample Output 3\n\n1099511627775", "sample_input": "2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02786", "source_text": "Score : 400 points\n\nProblem Statement\n\nCaracal is fighting with a monster.\n\nThe health of the monster is H.\n\nCaracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:\n\nIf the monster's health is 1, it drops to 0.\n\nIf the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \\lfloor X/2 \\rfloor.\n\n(\\lfloor r \\rfloor denotes the greatest integer not exceeding r.)\n\nCaracal wins when the healths of all existing monsters become 0 or below.\n\nFind the minimum number of attacks Caracal needs to make before winning.\n\nConstraints\n\n1 \\leq H \\leq 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH\n\nOutput\n\nFind the minimum number of attacks Caracal needs to make before winning.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n3\n\nWhen Caracal attacks the initial monster, it disappears, and two monsters appear, each with the health of 1.\n\nThen, Caracal can attack each of these new monsters once and win with a total of three attacks.\n\nSample Input 2\n\n4\n\nSample Output 2\n\n7\n\nSample Input 3\n\n1000000000000\n\nSample Output 3\n\n1099511627775", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 203, "cpu_time_ms": 319, "memory_kb": 25536}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s401823417", "group_id": "codeNet:p02789", "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==b)\"Yes\" else \"No\")\n }\n}", "language": "Scala", "metadata": {"date": 1587661456, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02789.html", "problem_id": "p02789", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02789/input.txt", "sample_output_relpath": "derived/input_output/data/p02789/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02789/Scala/s401823417.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s401823417", "user_id": "u759091915"}, "prompt_components": {"gold_output": "Yes\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==b)\"Yes\" else \"No\")\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest, AXC001. He has just submitted his code to Problem A.\n\nThe problem has N test cases, all of which must be passed to get an AC verdict.\n\nTakahashi's submission has passed M cases out of the N test cases.\n\nDetermine whether Takahashi's submission gets an AC.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq M \\leq N\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\nIf Takahashi's submission gets an AC, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 3\n\nSample Output 1\n\nYes\n\nAll three test cases have been passed, so his submission gets an AC.\n\nSample Input 2\n\n3 2\n\nSample Output 2\n\nNo\n\nOnly two out of the three test cases have been passed, so his submission does not get an AC.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\nYes", "sample_input": "3 3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02789", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest, AXC001. He has just submitted his code to Problem A.\n\nThe problem has N test cases, all of which must be passed to get an AC verdict.\n\nTakahashi's submission has passed M cases out of the N test cases.\n\nDetermine whether Takahashi's submission gets an AC.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq M \\leq N\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\nIf Takahashi's submission gets an AC, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 3\n\nSample Output 1\n\nYes\n\nAll three test cases have been passed, so his submission gets an AC.\n\nSample Input 2\n\n3 2\n\nSample Output 2\n\nNo\n\nOnly two out of the three test cases have been passed, so his submission does not get an AC.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 180, "cpu_time_ms": 330, "memory_kb": 25420}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s009203759", "group_id": "codeNet:p02789", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n,m = sc.nextInt\n \n println(if (n == m) \"Yes\" else \"No\")\n}", "language": "Scala", "metadata": {"date": 1579463478, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02789.html", "problem_id": "p02789", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02789/input.txt", "sample_output_relpath": "derived/input_output/data/p02789/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02789/Scala/s009203759.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s009203759", "user_id": "u715268393"}, "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,m = sc.nextInt\n \n println(if (n == m) \"Yes\" else \"No\")\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest, AXC001. He has just submitted his code to Problem A.\n\nThe problem has N test cases, all of which must be passed to get an AC verdict.\n\nTakahashi's submission has passed M cases out of the N test cases.\n\nDetermine whether Takahashi's submission gets an AC.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq M \\leq N\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\nIf Takahashi's submission gets an AC, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 3\n\nSample Output 1\n\nYes\n\nAll three test cases have been passed, so his submission gets an AC.\n\nSample Input 2\n\n3 2\n\nSample Output 2\n\nNo\n\nOnly two out of the three test cases have been passed, so his submission does not get an AC.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\nYes", "sample_input": "3 3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02789", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest, AXC001. He has just submitted his code to Problem A.\n\nThe problem has N test cases, all of which must be passed to get an AC verdict.\n\nTakahashi's submission has passed M cases out of the N test cases.\n\nDetermine whether Takahashi's submission gets an AC.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq M \\leq N\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\nIf Takahashi's submission gets an AC, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 3\n\nSample Output 1\n\nYes\n\nAll three test cases have been passed, so his submission gets an AC.\n\nSample Input 2\n\n3 2\n\nSample Output 2\n\nNo\n\nOnly two out of the three test cases have been passed, so his submission does not get an AC.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 136, "cpu_time_ms": 369, "memory_kb": 25924}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s827745544", "group_id": "codeNet:p02791", "input_text": "object Main extends App {\n val n = scala.io.StdIn.readInt()\n val pInput = scala.io.StdIn.readLine()\n val pArray = pInput.split(\" \").map(_.toInt).toVector\n var target = pArray.head\n var compareArray = pArray.tail\n var tempResult = 0\n\n var maxKey = 0\n var result = 1\n\n compareArray.foreach { p =>\n if (target > p) {\n result = result + 1\n target = p\n }\n }\n println(result)\n}", "language": "Scala", "metadata": {"date": 1579467852, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/s827745544.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s827745544", "user_id": "u105921924"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main extends App {\n val n = scala.io.StdIn.readInt()\n val pInput = scala.io.StdIn.readLine()\n val pArray = pInput.split(\" \").map(_.toInt).toVector\n var target = pArray.head\n var compareArray = pArray.tail\n var tempResult = 0\n\n var maxKey = 0\n var result = 1\n\n compareArray.foreach { p =>\n if (target > p) {\n result = result + 1\n target = p\n }\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 398, "cpu_time_ms": 589, "memory_kb": 56924}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s838430500", "group_id": "codeNet:p02791", "input_text": "import scala.collection.mutable.ArrayBuffer\n\nobject 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 = sc.nextInt\n\tval p = Array.fill(n)(sc.nextInt)\n\t\n\tpw.println( (0 until n).filter(i => (0 until i) forall (j => p(i) <= p(j))).length )\n\tpw.flush()\n}", "language": "Scala", "metadata": {"date": 1579464282, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/s838430500.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s838430500", "user_id": "u822029894"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.collection.mutable.ArrayBuffer\n\nobject 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 = sc.nextInt\n\tval p = Array.fill(n)(sc.nextInt)\n\t\n\tpw.println( (0 until n).filter(i => (0 until i) forall (j => p(i) <= p(j))).length )\n\tpw.flush()\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a permutation P_1, \\ldots, P_N of 1, \\ldots, N.\nFind the number of integers i (1 \\leq i \\leq N) that satisfy the following condition:\n\nFor any integer j (1 \\leq j \\leq i), P_i \\leq P_j.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nP_1, \\ldots, P_N is a permutation of 1, \\ldots, N.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 ... P_N\n\nOutput\n\nPrint the number of integers i that satisfy the condition.\n\nSample Input 1\n\n5\n4 2 5 1 3\n\nSample Output 1\n\n3\n\ni=1, 2, and 4 satisfy the condition, but i=3 does not - for example, P_i > P_j holds for j = 1.\n\nSimilarly, i=5 does not satisfy the condition, either. Thus, there are three integers that satisfy the condition.\n\nSample Input 2\n\n4\n4 3 2 1\n\nSample Output 2\n\n4\n\nAll integers i (1 \\leq i \\leq N) satisfy the condition.\n\nSample Input 3\n\n6\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n\nOnly i=1 satisfies the condition.\n\nSample Input 4\n\n8\n5 7 4 2 6 8 1 3\n\nSample Output 4\n\n4\n\nSample Input 5\n\n1\n1\n\nSample Output 5\n\n1", "sample_input": "5\n4 2 5 1 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02791", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a permutation P_1, \\ldots, P_N of 1, \\ldots, N.\nFind the number of integers i (1 \\leq i \\leq N) that satisfy the following condition:\n\nFor any integer j (1 \\leq j \\leq i), P_i \\leq P_j.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nP_1, \\ldots, P_N is a permutation of 1, \\ldots, N.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 ... P_N\n\nOutput\n\nPrint the number of integers i that satisfy the condition.\n\nSample Input 1\n\n5\n4 2 5 1 3\n\nSample Output 1\n\n3\n\ni=1, 2, and 4 satisfy the condition, but i=3 does not - for example, P_i > P_j holds for j = 1.\n\nSimilarly, i=5 does not satisfy the condition, either. Thus, there are three integers that satisfy the condition.\n\nSample Input 2\n\n4\n4 3 2 1\n\nSample Output 2\n\n4\n\nAll integers i (1 \\leq i \\leq N) satisfy the condition.\n\nSample Input 3\n\n6\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n\nOnly i=1 satisfies the condition.\n\nSample Input 4\n\n8\n5 7 4 2 6 8 1 3\n\nSample Output 4\n\n4\n\nSample Input 5\n\n1\n1\n\nSample Output 5\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 318, "cpu_time_ms": 2111, "memory_kb": 118736}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s846079881", "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 primes.foreach { f =>\n if(x % f == 0) {\n var c = 0\n while (x % f == 0) {\n c += 1\n x /= f\n }\n if(cnt(f) < c) cnt(f) = c\n }\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": 1589382725, "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/s846079881.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s846079881", "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 primes.foreach { f =>\n if(x % f == 0) {\n var c = 0\n while (x % f == 0) {\n c += 1\n x /= f\n }\n if(cnt(f) < c) cnt(f) = c\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4804, "cpu_time_ms": 2111, "memory_kb": 174400}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s659795336", "group_id": "codeNet:p02793", "input_text": "import scala.annotation.tailrec\n\nobject Main{\n // 定数関係\n final private val mod : Int = 1e9.toInt + 7\n \n @tailrec\n def gcd(a : BigInt, b : BigInt): BigInt = {\n if(b == 0) a\n else if(a < b) gcd(b, a)\n else gcd(a % b, b)\n }\n def lcm(a : BigInt, b : BigInt): BigInt = a / gcd(a, b) * b\n \n type INTEGER = Long\n def power(a : Int, n : Int): Int = {\n val hd = 32 - java.lang.Integer.numberOfLeadingZeros(n)\n var isMATCH = 1 << hd\n var ans : INTEGER = 1\n\n while(isMATCH != 0){\n ans = ans * ans % mod\n if((n & isMATCH) != 0){\n ans = a * ans % mod\n }\n isMATCH >>>= 1\n }\n ans.toInt\n }\n def inv(n : Int): Int = power(n, mod - 2)\n \n \n // main 関数本体\n def main(args : Array[String]): Unit = {\n val n = scala.io.StdIn.readLine().toInt\n val A = scala.io.StdIn.readLine().split(' ').map(_.toInt)\n var sumInv : Int = 0\n var LCM : BigInt = 1\n for(ele <- A){\n LCM = lcm(ele, LCM)\n sumInv += inv(ele)\n if(sumInv >= mod) sumInv -= mod\n }\n val lcmMod : Long = (LCM % mod).toLong\n val ans = lcmMod * sumInv.toLong % mod\n println(ans)\n }\n}", "language": "Scala", "metadata": {"date": 1579607345, "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/s659795336.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s659795336", "user_id": "u394853232"}, "prompt_components": {"gold_output": "13\n", "input_to_evaluate": "import scala.annotation.tailrec\n\nobject Main{\n // 定数関係\n final private val mod : Int = 1e9.toInt + 7\n \n @tailrec\n def gcd(a : BigInt, b : BigInt): BigInt = {\n if(b == 0) a\n else if(a < b) gcd(b, a)\n else gcd(a % b, b)\n }\n def lcm(a : BigInt, b : BigInt): BigInt = a / gcd(a, b) * b\n \n type INTEGER = Long\n def power(a : Int, n : Int): Int = {\n val hd = 32 - java.lang.Integer.numberOfLeadingZeros(n)\n var isMATCH = 1 << hd\n var ans : INTEGER = 1\n\n while(isMATCH != 0){\n ans = ans * ans % mod\n if((n & isMATCH) != 0){\n ans = a * ans % mod\n }\n isMATCH >>>= 1\n }\n ans.toInt\n }\n def inv(n : Int): Int = power(n, mod - 2)\n \n \n // main 関数本体\n def main(args : Array[String]): Unit = {\n val n = scala.io.StdIn.readLine().toInt\n val A = scala.io.StdIn.readLine().split(' ').map(_.toInt)\n var sumInv : Int = 0\n var LCM : BigInt = 1\n for(ele <- A){\n LCM = lcm(ele, LCM)\n sumInv += inv(ele)\n if(sumInv >= mod) sumInv -= mod\n }\n val lcmMod : Long = (LCM % mod).toLong\n val ans = lcmMod * sumInv.toLong % mod\n println(ans)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1210, "cpu_time_ms": 1362, "memory_kb": 117040}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s047708931", "group_id": "codeNet:p02802", "input_text": "object Main extends App{\n val Array(n, m) = io.StdIn.readLine().split(' ').map(_.toInt)\n val acs = Iterator.continually(io.StdIn.readLine().split(' ')).take(m).map {\n case Array(p, s) => (p.toInt, s)\n }.toSeq.groupBy(_._1).map {\n case (p, ss) => ss.map(_._2)\n }.filter(_.exists(_ == \"AC\")).toSeq\n \n val correct = acs.length\n val penalty = if (correct == 0)\n 0\n else\n acs.map(_.takeWhile(_ == \"WA\").length).sum\n \n println(s\"$correct $penalty\")\n \n}\n", "language": "Scala", "metadata": {"date": 1578883236, "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/s047708931.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s047708931", "user_id": "u439454233"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "object Main extends App{\n val Array(n, m) = io.StdIn.readLine().split(' ').map(_.toInt)\n val acs = Iterator.continually(io.StdIn.readLine().split(' ')).take(m).map {\n case Array(p, s) => (p.toInt, s)\n }.toSeq.groupBy(_._1).map {\n case (p, ss) => ss.map(_._2)\n }.filter(_.exists(_ == \"AC\")).toSeq\n \n val correct = acs.length\n val penalty = if (correct == 0)\n 0\n else\n acs.map(_.takeWhile(_ == \"WA\").length).sum\n \n println(s\"$correct $penalty\")\n \n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi participated in a contest on AtCoder.\n\nThe contest had N problems.\n\nTakahashi made M submissions during the contest.\n\nThe i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA).\n\nThe number of Takahashi's correct answers is the number of problems on which he received an AC once or more.\n\nThe number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WAs received before receiving an AC for the first time on that problem.\n\nFind the numbers of Takahashi's correct answers and penalties.\n\nConstraints\n\nN, M, and p_i are integers.\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq 10^5\n\n1 \\leq p_i \\leq N\n\nS_i is AC or WA.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\np_1 S_1\n:\np_M S_M\n\nOutput\n\nPrint the number of Takahashi's correct answers and the number of Takahashi's penalties.\n\nSample Input 1\n\n2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n\nSample Output 1\n\n2 2\n\nIn his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.\n\nIn his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.\n\nThus, he has two correct answers and two penalties.\n\nSample Input 2\n\n100000 3\n7777 AC\n7777 AC\n7777 AC\n\nSample Output 2\n\n1 0\n\nNote that it is pointless to get an AC more than once on the same problem.\n\nSample Input 3\n\n6 0\n\nSample Output 3\n\n0 0", "sample_input": "2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n"}, "reference_outputs": ["2 2\n"], "source_document_id": "p02802", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi participated in a contest on AtCoder.\n\nThe contest had N problems.\n\nTakahashi made M submissions during the contest.\n\nThe i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA).\n\nThe number of Takahashi's correct answers is the number of problems on which he received an AC once or more.\n\nThe number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WAs received before receiving an AC for the first time on that problem.\n\nFind the numbers of Takahashi's correct answers and penalties.\n\nConstraints\n\nN, M, and p_i are integers.\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq 10^5\n\n1 \\leq p_i \\leq N\n\nS_i is AC or WA.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\np_1 S_1\n:\np_M S_M\n\nOutput\n\nPrint the number of Takahashi's correct answers and the number of Takahashi's penalties.\n\nSample Input 1\n\n2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n\nSample Output 1\n\n2 2\n\nIn his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.\n\nIn his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.\n\nThus, he has two correct answers and two penalties.\n\nSample Input 2\n\n100000 3\n7777 AC\n7777 AC\n7777 AC\n\nSample Output 2\n\n1 0\n\nNote that it is pointless to get an AC more than once on the same problem.\n\nSample Input 3\n\n6 0\n\nSample Output 3\n\n0 0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 508, "cpu_time_ms": 2115, "memory_kb": 136280}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s508580438", "group_id": "codeNet:p02802", "input_text": "object Main extends App {\n val Array(n, m) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n var ACseq = Map.empty[Int, Int]\n var wacnt = Map.empty[Int, Int]\n\n (1 to m).foreach { i =>\n // println(ACseq)\n // println(wacnt)\n val Array(p, s) = scala.io.StdIn.readLine.split(\" \")\n val pp = p.toInt\n\n if (!ACseq.isDefinedAt(pp)) {\n if (s == \"AC\") {\n val wacnt_tmp = wacnt.getOrElse(pp, 0)\n ACseq += (pp -> wacnt_tmp)\n } else {\n val wacnt_tmp = wacnt.getOrElse(pp, 0)\n wacnt += (pp -> (wacnt_tmp + 1))\n }\n }\n }\n println(ACseq.size + \" \" + wacnt.foldLeft(0)(_ + _._2))\n}\n", "language": "Scala", "metadata": {"date": 1578882817, "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/s508580438.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s508580438", "user_id": "u654455149"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "object Main extends App {\n val Array(n, m) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n var ACseq = Map.empty[Int, Int]\n var wacnt = Map.empty[Int, Int]\n\n (1 to m).foreach { i =>\n // println(ACseq)\n // println(wacnt)\n val Array(p, s) = scala.io.StdIn.readLine.split(\" \")\n val pp = p.toInt\n\n if (!ACseq.isDefinedAt(pp)) {\n if (s == \"AC\") {\n val wacnt_tmp = wacnt.getOrElse(pp, 0)\n ACseq += (pp -> wacnt_tmp)\n } else {\n val wacnt_tmp = wacnt.getOrElse(pp, 0)\n wacnt += (pp -> (wacnt_tmp + 1))\n }\n }\n }\n println(ACseq.size + \" \" + wacnt.foldLeft(0)(_ + _._2))\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi participated in a contest on AtCoder.\n\nThe contest had N problems.\n\nTakahashi made M submissions during the contest.\n\nThe i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA).\n\nThe number of Takahashi's correct answers is the number of problems on which he received an AC once or more.\n\nThe number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WAs received before receiving an AC for the first time on that problem.\n\nFind the numbers of Takahashi's correct answers and penalties.\n\nConstraints\n\nN, M, and p_i are integers.\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq 10^5\n\n1 \\leq p_i \\leq N\n\nS_i is AC or WA.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\np_1 S_1\n:\np_M S_M\n\nOutput\n\nPrint the number of Takahashi's correct answers and the number of Takahashi's penalties.\n\nSample Input 1\n\n2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n\nSample Output 1\n\n2 2\n\nIn his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.\n\nIn his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.\n\nThus, he has two correct answers and two penalties.\n\nSample Input 2\n\n100000 3\n7777 AC\n7777 AC\n7777 AC\n\nSample Output 2\n\n1 0\n\nNote that it is pointless to get an AC more than once on the same problem.\n\nSample Input 3\n\n6 0\n\nSample Output 3\n\n0 0", "sample_input": "2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n"}, "reference_outputs": ["2 2\n"], "source_document_id": "p02802", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi participated in a contest on AtCoder.\n\nThe contest had N problems.\n\nTakahashi made M submissions during the contest.\n\nThe i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA).\n\nThe number of Takahashi's correct answers is the number of problems on which he received an AC once or more.\n\nThe number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WAs received before receiving an AC for the first time on that problem.\n\nFind the numbers of Takahashi's correct answers and penalties.\n\nConstraints\n\nN, M, and p_i are integers.\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq 10^5\n\n1 \\leq p_i \\leq N\n\nS_i is AC or WA.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\np_1 S_1\n:\np_M S_M\n\nOutput\n\nPrint the number of Takahashi's correct answers and the number of Takahashi's penalties.\n\nSample Input 1\n\n2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n\nSample Output 1\n\n2 2\n\nIn his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.\n\nIn his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.\n\nThus, he has two correct answers and two penalties.\n\nSample Input 2\n\n100000 3\n7777 AC\n7777 AC\n7777 AC\n\nSample Output 2\n\n1 0\n\nNote that it is pointless to get an AC more than once on the same problem.\n\nSample Input 3\n\n6 0\n\nSample Output 3\n\n0 0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 630, "cpu_time_ms": 1080, "memory_kb": 77668}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s735885970", "group_id": "codeNet:p02802", "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(n, m) = in.readLine().split(\"\\\\s+\").map(_.toInt)\n\n val pss = (1 to m).map { _ =>\n in.readLine().split(\"\\\\s+\") match {\n case Array(p, s) => (p.toInt, s)\n }\n }\n\n var penalties = 0\n var acs = 0\n val results = Array.ofDim[Int](n)\n\n pss.foreach {\n case (p, s) =>\n if (results(p - 1) != -1) {\n if (s == \"AC\") {\n penalties += results(p - 1)\n results(p - 1) = -1\n acs += 1\n } else {\n results(p - 1) += 1\n }\n }\n }\n\n System.out.println(List(acs, penalties).mkString(\" \"))\n }\n}\n", "language": "Scala", "metadata": {"date": 1578882812, "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/s735885970.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s735885970", "user_id": "u178269371"}, "prompt_components": {"gold_output": "2 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 Array(n, m) = in.readLine().split(\"\\\\s+\").map(_.toInt)\n\n val pss = (1 to m).map { _ =>\n in.readLine().split(\"\\\\s+\") match {\n case Array(p, s) => (p.toInt, s)\n }\n }\n\n var penalties = 0\n var acs = 0\n val results = Array.ofDim[Int](n)\n\n pss.foreach {\n case (p, s) =>\n if (results(p - 1) != -1) {\n if (s == \"AC\") {\n penalties += results(p - 1)\n results(p - 1) = -1\n acs += 1\n } else {\n results(p - 1) += 1\n }\n }\n }\n\n System.out.println(List(acs, penalties).mkString(\" \"))\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi participated in a contest on AtCoder.\n\nThe contest had N problems.\n\nTakahashi made M submissions during the contest.\n\nThe i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA).\n\nThe number of Takahashi's correct answers is the number of problems on which he received an AC once or more.\n\nThe number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WAs received before receiving an AC for the first time on that problem.\n\nFind the numbers of Takahashi's correct answers and penalties.\n\nConstraints\n\nN, M, and p_i are integers.\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq 10^5\n\n1 \\leq p_i \\leq N\n\nS_i is AC or WA.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\np_1 S_1\n:\np_M S_M\n\nOutput\n\nPrint the number of Takahashi's correct answers and the number of Takahashi's penalties.\n\nSample Input 1\n\n2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n\nSample Output 1\n\n2 2\n\nIn his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.\n\nIn his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.\n\nThus, he has two correct answers and two penalties.\n\nSample Input 2\n\n100000 3\n7777 AC\n7777 AC\n7777 AC\n\nSample Output 2\n\n1 0\n\nNote that it is pointless to get an AC more than once on the same problem.\n\nSample Input 3\n\n6 0\n\nSample Output 3\n\n0 0", "sample_input": "2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n"}, "reference_outputs": ["2 2\n"], "source_document_id": "p02802", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi participated in a contest on AtCoder.\n\nThe contest had N problems.\n\nTakahashi made M submissions during the contest.\n\nThe i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA).\n\nThe number of Takahashi's correct answers is the number of problems on which he received an AC once or more.\n\nThe number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WAs received before receiving an AC for the first time on that problem.\n\nFind the numbers of Takahashi's correct answers and penalties.\n\nConstraints\n\nN, M, and p_i are integers.\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq 10^5\n\n1 \\leq p_i \\leq N\n\nS_i is AC or WA.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\np_1 S_1\n:\np_M S_M\n\nOutput\n\nPrint the number of Takahashi's correct answers and the number of Takahashi's penalties.\n\nSample Input 1\n\n2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n\nSample Output 1\n\n2 2\n\nIn his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.\n\nIn his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.\n\nThus, he has two correct answers and two penalties.\n\nSample Input 2\n\n100000 3\n7777 AC\n7777 AC\n7777 AC\n\nSample Output 2\n\n1 0\n\nNote that it is pointless to get an AC more than once on the same problem.\n\nSample Input 3\n\n6 0\n\nSample Output 3\n\n0 0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 787, "cpu_time_ms": 1033, "memory_kb": 76588}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s979215171", "group_id": "codeNet:p02803", "input_text": "import scala.collection.immutable.Queue\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val H, W = sc.nextInt(); sc.nextLine()\n val S = Array.fill(H)(sc.nextLine().trim.toCharArray)\n // スタートの決定にO(H*W)\n // ゴールの決定にO(H*W)\n // 最短路の探索にO(H*W)\n // 全探索するとO(H^3*W^3)\n // 64 * 10^6で間に合わない\n // dist(y)(x)(y')(x') := マスy,xからマスy',x'への最短路としておく\n// def solve(H: Int, W: Int, S: Array[Array[Char]]): Int = {\n// val MAX = Int.MaxValue\n// val dist = Array.fill(H, W, H, W)(MAX)\n// val dx = Array(0, 0, -1, 1)\n// val dy = Array(-1, 1, 0, 0)\n//\n// def bfs(sx: Int, sy: Int, ex: Int, ey: Int): Int = {\n// val UNREACHED = 401\n// val arr = Array.fill(H, W)(MAX)\n// arr(sy)(sx) = 0\n// def loop(queue: Queue[(Int, Int)], min: Int): Int = {\n// if (queue.nonEmpty) {\n// val (x, y) = queue.head\n// if (x == ex && y == ey) {\n// val d = min min arr(ey)(ex)\n// dist(sy)(sx)(y)(x) = d\n// dist(y)(x)(sy)(sx) = d\n// d\n// } else if (dist(y)(x)(ey)(ex) != MAX) {\n// loop(queue.tail, min min (arr(y)(x) + dist(y)(x)(ey)(ex)))\n// } else {\n// if (min == UNREACHED) {\n// dist(sy)(sx)(y)(x) = arr(y)(x)\n// dist(y)(x)(sy)(sx) = arr(y)(x)\n// }\n// loop((0 to 3).foldLeft(queue.tail) { (queue, i) =>\n// val nx = x + dx(i)\n// val ny = y + dy(i)\n// if (nx >= 0 && nx < W &&\n// ny >= 0 && ny < H &&\n// S(ny)(nx) == '.' &&\n// arr(ny)(nx) == MAX) {\n// arr(ny)(nx) = arr(y)(x) + 1\n// queue.enqueue((nx, ny))\n// } else queue\n// }, min)\n// }\n// } else min\n// }\n// loop(Queue((sx, sy)), UNREACHED)\n// }\n//\n// (for {\n// sy <- 0 until H\n// sx <- 0 until W\n// if (S(sy)(sx) == '.')\n// ey <- (0 until H).reverse\n// ex <- (0 until W).reverse\n// if (S(ey)(ex) == '.')\n// if ey > sy || (ey == sy && ex > sx)\n// } yield bfs(sx, sy, ex, ey)).max\n// }\n\n // 開始地点と終了地点を全探索していたが, そもそも開始地点を確定させて\n // BFSをすると, 一回探索した時に全ての終了地点までの最短経路が求まるので\n // 開始地点の列挙O(HW)に、BFSで最後まで探索した時の距離 O(HW)を求め、その最大を求めればいい\n def solve(H: Int, W: Int, S: Array[Array[Char]]): Int = {\n val dx = Array(0, 0, -1, 1)\n val dy = Array(1, -1, 0, 0)\n def bfs(sx: Int, sy: Int): Int = {\n val visited = Array.fill(H, W)(false)\n def loop(queue: Queue[((Int, Int), Int)], max: Int): Int =\n if (queue.nonEmpty) {\n val ((x, y), dist) = queue.head\n loop((0 until 4).foldLeft(queue.tail)((queue, i) => {\n val nx = x + dx(i)\n val ny = y + dy(i)\n if (nx >= 0 && nx < W &&\n ny >= 0 && ny < H &&\n S(ny)(nx) == '.' &&\n !visited(ny)(nx)) {\n visited(ny)(nx) = true\n queue.enqueue(((nx, ny), dist + 1))\n } else queue\n }), max max dist)\n } else max\n loop(Queue(((sx, sy), 0)), 0)\n }\n\n (for {\n sy <- 0 until H\n sx <- 0 until W\n if S(sy)(sx) == '.'\n } yield bfs(sx, sy)).max\n }\n\n println(solve(H, W, S))\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1579990417, "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/s979215171.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s979215171", "user_id": "u891387249"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import scala.collection.immutable.Queue\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val H, W = sc.nextInt(); sc.nextLine()\n val S = Array.fill(H)(sc.nextLine().trim.toCharArray)\n // スタートの決定にO(H*W)\n // ゴールの決定にO(H*W)\n // 最短路の探索にO(H*W)\n // 全探索するとO(H^3*W^3)\n // 64 * 10^6で間に合わない\n // dist(y)(x)(y')(x') := マスy,xからマスy',x'への最短路としておく\n// def solve(H: Int, W: Int, S: Array[Array[Char]]): Int = {\n// val MAX = Int.MaxValue\n// val dist = Array.fill(H, W, H, W)(MAX)\n// val dx = Array(0, 0, -1, 1)\n// val dy = Array(-1, 1, 0, 0)\n//\n// def bfs(sx: Int, sy: Int, ex: Int, ey: Int): Int = {\n// val UNREACHED = 401\n// val arr = Array.fill(H, W)(MAX)\n// arr(sy)(sx) = 0\n// def loop(queue: Queue[(Int, Int)], min: Int): Int = {\n// if (queue.nonEmpty) {\n// val (x, y) = queue.head\n// if (x == ex && y == ey) {\n// val d = min min arr(ey)(ex)\n// dist(sy)(sx)(y)(x) = d\n// dist(y)(x)(sy)(sx) = d\n// d\n// } else if (dist(y)(x)(ey)(ex) != MAX) {\n// loop(queue.tail, min min (arr(y)(x) + dist(y)(x)(ey)(ex)))\n// } else {\n// if (min == UNREACHED) {\n// dist(sy)(sx)(y)(x) = arr(y)(x)\n// dist(y)(x)(sy)(sx) = arr(y)(x)\n// }\n// loop((0 to 3).foldLeft(queue.tail) { (queue, i) =>\n// val nx = x + dx(i)\n// val ny = y + dy(i)\n// if (nx >= 0 && nx < W &&\n// ny >= 0 && ny < H &&\n// S(ny)(nx) == '.' &&\n// arr(ny)(nx) == MAX) {\n// arr(ny)(nx) = arr(y)(x) + 1\n// queue.enqueue((nx, ny))\n// } else queue\n// }, min)\n// }\n// } else min\n// }\n// loop(Queue((sx, sy)), UNREACHED)\n// }\n//\n// (for {\n// sy <- 0 until H\n// sx <- 0 until W\n// if (S(sy)(sx) == '.')\n// ey <- (0 until H).reverse\n// ex <- (0 until W).reverse\n// if (S(ey)(ex) == '.')\n// if ey > sy || (ey == sy && ex > sx)\n// } yield bfs(sx, sy, ex, ey)).max\n// }\n\n // 開始地点と終了地点を全探索していたが, そもそも開始地点を確定させて\n // BFSをすると, 一回探索した時に全ての終了地点までの最短経路が求まるので\n // 開始地点の列挙O(HW)に、BFSで最後まで探索した時の距離 O(HW)を求め、その最大を求めればいい\n def solve(H: Int, W: Int, S: Array[Array[Char]]): Int = {\n val dx = Array(0, 0, -1, 1)\n val dy = Array(1, -1, 0, 0)\n def bfs(sx: Int, sy: Int): Int = {\n val visited = Array.fill(H, W)(false)\n def loop(queue: Queue[((Int, Int), Int)], max: Int): Int =\n if (queue.nonEmpty) {\n val ((x, y), dist) = queue.head\n loop((0 until 4).foldLeft(queue.tail)((queue, i) => {\n val nx = x + dx(i)\n val ny = y + dy(i)\n if (nx >= 0 && nx < W &&\n ny >= 0 && ny < H &&\n S(ny)(nx) == '.' &&\n !visited(ny)(nx)) {\n visited(ny)(nx) = true\n queue.enqueue(((nx, ny), dist + 1))\n } else queue\n }), max max dist)\n } else max\n loop(Queue(((sx, sy), 0)), 0)\n }\n\n (for {\n sy <- 0 until H\n sx <- 0 until W\n if S(sy)(sx) == '.'\n } yield bfs(sx, sy)).max\n }\n\n println(solve(H, W, S))\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3748, "cpu_time_ms": 585, "memory_kb": 41912}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s538764948", "group_id": "codeNet:p02803", "input_text": "import scala.collection.immutable.Queue\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val H, W = sc.nextInt(); sc.nextLine()\n val S = Array.fill(H)(sc.nextLine().trim.toCharArray)\n // スタートの決定にO(H*W)\n // ゴールの決定にO(H*W)\n // 最短路の探索にO(H*W)\n // 全探索するとO(H^3*W^3)\n // 64 * 10^6で間に合わない\n // dist(y)(x)(y')(x') := マスy,xからマスy',x'への最短路としておく\n def solve(H: Int, W: Int, S: Array[Array[Char]]): Int = {\n val MAX = Int.MaxValue\n val dist = Array.fill(H, W, H, W)(MAX)\n val dx = Array(0, 0, -1, 1)\n val dy = Array(-1, 1, 0, 0)\n\n def bfs(sx: Int, sy: Int, ex: Int, ey: Int): Int = {\n val UNREACHED = 401\n val arr = Array.fill(H, W)(MAX)\n arr(sy)(sx) = 0\n def loop(queue: Queue[(Int, Int)], min: Int): Int = {\n if (queue.nonEmpty) {\n val (x, y) = queue.head\n if (x == ex && y == ey) {\n val d = min min arr(ey)(ex)\n dist(sy)(sx)(y)(x) = d\n dist(y)(x)(sy)(sx) = d\n d\n } else if (dist(y)(x)(ey)(ex) != MAX) {\n loop(queue.tail, min min (arr(y)(x) + dist(y)(x)(ey)(ex)))\n } else {\n if (min == UNREACHED) {\n dist(sy)(sx)(y)(x) = arr(y)(x)\n dist(y)(x)(sy)(sx) = arr(y)(x)\n }\n loop((0 to 3).foldLeft(queue.tail) { (queue, i) =>\n val nx = x + dx(i)\n val ny = y + dy(i)\n if (nx >= 0 && nx < W &&\n ny >= 0 && ny < H &&\n S(ny)(nx) == '.' &&\n arr(ny)(nx) == MAX) {\n arr(ny)(nx) = arr(y)(x) + 1\n queue.enqueue((nx, ny))\n } else queue\n }, min)\n }\n } else min\n }\n loop(Queue((sx, sy)), UNREACHED)\n }\n\n val xRange = (0 until W)\n val yRange = (0 until H)\n val xRangeRev = (0 until W).reverse\n val yRangeRev = (0 until H).reverse\n (for {\n sy <- yRange\n sx <- xRange\n if (S(sy)(sx) == '.')\n ey <- yRangeRev\n ex <- xRangeRev\n if (S(ey)(ex) == '.')\n } yield bfs(sx, sy, ex, ey)).max\n }\n\n println(solve(H, W, S))\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1579987767, "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/s538764948.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s538764948", "user_id": "u891387249"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import scala.collection.immutable.Queue\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val H, W = sc.nextInt(); sc.nextLine()\n val S = Array.fill(H)(sc.nextLine().trim.toCharArray)\n // スタートの決定にO(H*W)\n // ゴールの決定にO(H*W)\n // 最短路の探索にO(H*W)\n // 全探索するとO(H^3*W^3)\n // 64 * 10^6で間に合わない\n // dist(y)(x)(y')(x') := マスy,xからマスy',x'への最短路としておく\n def solve(H: Int, W: Int, S: Array[Array[Char]]): Int = {\n val MAX = Int.MaxValue\n val dist = Array.fill(H, W, H, W)(MAX)\n val dx = Array(0, 0, -1, 1)\n val dy = Array(-1, 1, 0, 0)\n\n def bfs(sx: Int, sy: Int, ex: Int, ey: Int): Int = {\n val UNREACHED = 401\n val arr = Array.fill(H, W)(MAX)\n arr(sy)(sx) = 0\n def loop(queue: Queue[(Int, Int)], min: Int): Int = {\n if (queue.nonEmpty) {\n val (x, y) = queue.head\n if (x == ex && y == ey) {\n val d = min min arr(ey)(ex)\n dist(sy)(sx)(y)(x) = d\n dist(y)(x)(sy)(sx) = d\n d\n } else if (dist(y)(x)(ey)(ex) != MAX) {\n loop(queue.tail, min min (arr(y)(x) + dist(y)(x)(ey)(ex)))\n } else {\n if (min == UNREACHED) {\n dist(sy)(sx)(y)(x) = arr(y)(x)\n dist(y)(x)(sy)(sx) = arr(y)(x)\n }\n loop((0 to 3).foldLeft(queue.tail) { (queue, i) =>\n val nx = x + dx(i)\n val ny = y + dy(i)\n if (nx >= 0 && nx < W &&\n ny >= 0 && ny < H &&\n S(ny)(nx) == '.' &&\n arr(ny)(nx) == MAX) {\n arr(ny)(nx) = arr(y)(x) + 1\n queue.enqueue((nx, ny))\n } else queue\n }, min)\n }\n } else min\n }\n loop(Queue((sx, sy)), UNREACHED)\n }\n\n val xRange = (0 until W)\n val yRange = (0 until H)\n val xRangeRev = (0 until W).reverse\n val yRangeRev = (0 until H).reverse\n (for {\n sy <- yRange\n sx <- xRange\n if (S(sy)(sx) == '.')\n ey <- yRangeRev\n ex <- xRangeRev\n if (S(ey)(ex) == '.')\n } yield bfs(sx, sy, ex, ey)).max\n }\n\n println(solve(H, W, S))\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2381, "cpu_time_ms": 2111, "memory_kb": 121592}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s905470354", "group_id": "codeNet:p02803", "input_text": "import scala.collection.immutable.Queue\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val H, W = sc.nextInt(); sc.nextLine()\n val S = Array.fill(H)(sc.nextLine().trim.toCharArray)\n // スタートの決定にO(H*W)\n // ゴールの決定にO(H*W)\n // 最短路の探索にO(H*W)\n // 全探索するとO(H^3*W^3)\n // 64 * 10^6で間に合わない\n // dist(y)(x)(y')(x') := マスy,xからマスy',x'への最短路としておく\n def solve(H: Int, W: Int, S: Array[Array[Char]]): Int = {\n val MAX = Int.MaxValue\n val dist = Array.fill(H, W, H, W)(MAX)\n val dx = Array(0, 0, -1, 1)\n val dy = Array(-1, 1, 0, 0)\n\n def bfs(sx: Int, sy: Int, ex: Int, ey: Int): Int = {\n val UNREACHED = 401\n val arr = Array.fill(H, W)(MAX)\n arr(sy)(sx) = 0\n def loop(queue: Queue[(Int, Int)], min: Int): Int = {\n if (queue.nonEmpty) {\n val (x, y) = queue.head\n if (x == ex && y == ey) {\n val d = min min arr(ey)(ex)\n dist(sy)(sx)(y)(x) = d\n dist(y)(x)(sy)(sx) = d\n d\n } else if (dist(y)(x)(ey)(ex) != MAX) {\n loop(queue.tail, min min (arr(y)(x) + dist(y)(x)(ey)(ex)))\n } else {\n if (min == UNREACHED) {\n dist(sy)(sx)(y)(x) = arr(y)(x)\n dist(y)(x)(sy)(sx) = arr(y)(x)\n }\n loop((0 to 3).foldLeft(queue.tail) { (queue, i) =>\n val nx = x + dx(i)\n val ny = y + dy(i)\n if (nx >= 0 && nx < W &&\n ny >= 0 && ny < H &&\n S(ny)(nx) == '.' &&\n arr(ny)(nx) == MAX) {\n arr(ny)(nx) = arr(y)(x) + 1\n queue.enqueue((nx, ny))\n } else queue\n }, min)\n }\n } else min\n }\n loop(Queue((sx, sy)), UNREACHED)\n }\n\n (for {\n sy <- 0 until H\n sx <- 0 until W\n if (S(sy)(sx) == '.')\n ey <- 0 until H\n ex <- 0 until W\n if (S(ey)(ex) == '.')\n } yield bfs(sx, sy, ex, ey)).max\n }\n\n println(solve(H, W, S))\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1579987221, "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/s905470354.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s905470354", "user_id": "u891387249"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import scala.collection.immutable.Queue\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val H, W = sc.nextInt(); sc.nextLine()\n val S = Array.fill(H)(sc.nextLine().trim.toCharArray)\n // スタートの決定にO(H*W)\n // ゴールの決定にO(H*W)\n // 最短路の探索にO(H*W)\n // 全探索するとO(H^3*W^3)\n // 64 * 10^6で間に合わない\n // dist(y)(x)(y')(x') := マスy,xからマスy',x'への最短路としておく\n def solve(H: Int, W: Int, S: Array[Array[Char]]): Int = {\n val MAX = Int.MaxValue\n val dist = Array.fill(H, W, H, W)(MAX)\n val dx = Array(0, 0, -1, 1)\n val dy = Array(-1, 1, 0, 0)\n\n def bfs(sx: Int, sy: Int, ex: Int, ey: Int): Int = {\n val UNREACHED = 401\n val arr = Array.fill(H, W)(MAX)\n arr(sy)(sx) = 0\n def loop(queue: Queue[(Int, Int)], min: Int): Int = {\n if (queue.nonEmpty) {\n val (x, y) = queue.head\n if (x == ex && y == ey) {\n val d = min min arr(ey)(ex)\n dist(sy)(sx)(y)(x) = d\n dist(y)(x)(sy)(sx) = d\n d\n } else if (dist(y)(x)(ey)(ex) != MAX) {\n loop(queue.tail, min min (arr(y)(x) + dist(y)(x)(ey)(ex)))\n } else {\n if (min == UNREACHED) {\n dist(sy)(sx)(y)(x) = arr(y)(x)\n dist(y)(x)(sy)(sx) = arr(y)(x)\n }\n loop((0 to 3).foldLeft(queue.tail) { (queue, i) =>\n val nx = x + dx(i)\n val ny = y + dy(i)\n if (nx >= 0 && nx < W &&\n ny >= 0 && ny < H &&\n S(ny)(nx) == '.' &&\n arr(ny)(nx) == MAX) {\n arr(ny)(nx) = arr(y)(x) + 1\n queue.enqueue((nx, ny))\n } else queue\n }, min)\n }\n } else min\n }\n loop(Queue((sx, sy)), UNREACHED)\n }\n\n (for {\n sy <- 0 until H\n sx <- 0 until W\n if (S(sy)(sx) == '.')\n ey <- 0 until H\n ex <- 0 until W\n if (S(ey)(ex) == '.')\n } yield bfs(sx, sy, ex, ey)).max\n }\n\n println(solve(H, W, S))\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2241, "cpu_time_ms": 2110, "memory_kb": 120844}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s535245882", "group_id": "codeNet:p02803", "input_text": "import scala.collection.immutable.Queue\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val H, W = sc.nextInt(); sc.nextLine()\n val S = Array.fill(H)(sc.nextLine().trim.toCharArray)\n // スタートの決定にO(H*W)\n // ゴールの決定にO(H*W)\n // 最短路の探索にO(H*W)\n // 全探索するとO(H^3*W^3)\n // 64 * 10^6で間に合わない\n // dist(y)(x)(y')(x') := マスy,xからマスy',x'への最短路としておく\n def solve(H: Int, W: Int, S: Array[Array[Char]]): Int = {\n val MAX = Int.MaxValue\n val dist = Array.fill(H, W, H, W)(MAX)\n val dx = Array(0, 0, -1, 1)\n val dy = Array(-1, 1, 0, 0)\n\n def bfs(sx: Int, sy: Int, ex: Int, ey: Int): Int = {\n val UNREACHED = 401\n val arr = Array.fill(H, W)(MAX)\n arr(sy)(sx) = 0\n def loop(queue: Queue[(Int, Int)], min: Int): Int = {\n if (queue.nonEmpty) {\n val (x, y) = queue.head\n if (x == ex && y == ey) {\n min min arr(ey)(ex)\n } else if (dist(y)(x)(ey)(ex) != MAX) {\n loop(queue.tail, min min (arr(y)(x) + dist(y)(x)(ey)(ex)))\n } else {\n dist(sy)(sx)(y)(x) = dist(sy)(sx)(y)(x) min arr(y)(x)\n dist(y)(x)(sy)(sx) = dist(y)(x)(sy)(sx) min arr(y)(x)\n loop((0 to 3).foldLeft(queue.tail) { (queue, i) =>\n val nx = x + dx(i)\n val ny = y + dy(i)\n if (nx >= 0 && nx < W &&\n ny >= 0 && ny < H &&\n S(ny)(nx) == '.' &&\n arr(ny)(nx) == MAX) {\n arr(ny)(nx) = arr(y)(x) + 1\n queue.enqueue((nx, ny))\n } else queue\n }, min)\n }\n } else min\n }\n loop(Queue((sx, sy)), UNREACHED)\n }\n\n (for {\n sy <- 0 until H\n sx <- 0 until W\n if (S(sy)(sx) == '.')\n ey <- 0 until H\n ex <- 0 until W\n if (S(ey)(ex) == '.')\n } yield bfs(sx, sy, ex, ey)).max\n }\n\n println(solve(H, W, S))\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1579986372, "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/s535245882.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s535245882", "user_id": "u891387249"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import scala.collection.immutable.Queue\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val H, W = sc.nextInt(); sc.nextLine()\n val S = Array.fill(H)(sc.nextLine().trim.toCharArray)\n // スタートの決定にO(H*W)\n // ゴールの決定にO(H*W)\n // 最短路の探索にO(H*W)\n // 全探索するとO(H^3*W^3)\n // 64 * 10^6で間に合わない\n // dist(y)(x)(y')(x') := マスy,xからマスy',x'への最短路としておく\n def solve(H: Int, W: Int, S: Array[Array[Char]]): Int = {\n val MAX = Int.MaxValue\n val dist = Array.fill(H, W, H, W)(MAX)\n val dx = Array(0, 0, -1, 1)\n val dy = Array(-1, 1, 0, 0)\n\n def bfs(sx: Int, sy: Int, ex: Int, ey: Int): Int = {\n val UNREACHED = 401\n val arr = Array.fill(H, W)(MAX)\n arr(sy)(sx) = 0\n def loop(queue: Queue[(Int, Int)], min: Int): Int = {\n if (queue.nonEmpty) {\n val (x, y) = queue.head\n if (x == ex && y == ey) {\n min min arr(ey)(ex)\n } else if (dist(y)(x)(ey)(ex) != MAX) {\n loop(queue.tail, min min (arr(y)(x) + dist(y)(x)(ey)(ex)))\n } else {\n dist(sy)(sx)(y)(x) = dist(sy)(sx)(y)(x) min arr(y)(x)\n dist(y)(x)(sy)(sx) = dist(y)(x)(sy)(sx) min arr(y)(x)\n loop((0 to 3).foldLeft(queue.tail) { (queue, i) =>\n val nx = x + dx(i)\n val ny = y + dy(i)\n if (nx >= 0 && nx < W &&\n ny >= 0 && ny < H &&\n S(ny)(nx) == '.' &&\n arr(ny)(nx) == MAX) {\n arr(ny)(nx) = arr(y)(x) + 1\n queue.enqueue((nx, ny))\n } else queue\n }, min)\n }\n } else min\n }\n loop(Queue((sx, sy)), UNREACHED)\n }\n\n (for {\n sy <- 0 until H\n sx <- 0 until W\n if (S(sy)(sx) == '.')\n ey <- 0 until H\n ex <- 0 until W\n if (S(ey)(ex) == '.')\n } yield bfs(sx, sy, ex, ey)).max\n }\n\n println(solve(H, W, S))\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2131, "cpu_time_ms": 1545, "memory_kb": 120816}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s526294911", "group_id": "codeNet:p02803", "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 H, W = in.next().toInt\n val S = new Array[String](H)\n for (i <- 0 until H)\n S(i) = in.next()\n\n\n //\n var ans = 0\n val q = new Queue[((Int, Int), Int)]\n val dp = Array.ofDim[Boolean](H, W)\n\n for (ny <- 0 until H)\n for (nx <- 0 until W) {\n for (y <- 0 until H; x <- 0 until W) {\n dp(y)(x) = false\n }\n\n q.enqueue(((nx, ny), 0))\n while (!q.isEmpty) {\n val ((x, y), d) = q.dequeue()\n if (!dp(y)(x) && S(y)(x) == '.') {\n dp(y)(x) = true\n ans = ans max d\n\n Seq((x-1, y), (x+1, y), (x, y-1), (x, y+1))\n .filter { case (x, y) => 0 <= x && x < W && 0 <= y && y < H }\n .foreach { p =>\n q.enqueue((p, d+1))\n }\n }\n }\n }\n\n println(ans)\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": 1578882184, "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/s526294911.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s526294911", "user_id": "u098968285"}, "prompt_components": {"gold_output": "4\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 H, W = in.next().toInt\n val S = new Array[String](H)\n for (i <- 0 until H)\n S(i) = in.next()\n\n\n //\n var ans = 0\n val q = new Queue[((Int, Int), Int)]\n val dp = Array.ofDim[Boolean](H, W)\n\n for (ny <- 0 until H)\n for (nx <- 0 until W) {\n for (y <- 0 until H; x <- 0 until W) {\n dp(y)(x) = false\n }\n\n q.enqueue(((nx, ny), 0))\n while (!q.isEmpty) {\n val ((x, y), d) = q.dequeue()\n if (!dp(y)(x) && S(y)(x) == '.') {\n dp(y)(x) = true\n ans = ans max d\n\n Seq((x-1, y), (x+1, y), (x, y-1), (x, y+1))\n .filter { case (x, y) => 0 <= x && x < W && 0 <= y && y < H }\n .foreach { p =>\n q.enqueue((p, d+1))\n }\n }\n }\n }\n\n println(ans)\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 : 400 points\n\nProblem Statement\n\nTakahashi has a maze, which is a grid of H \\times W squares with H horizontal rows and W vertical columns.\n\nThe square at the i-th row from the top and the j-th column is a \"wall\" square if S_{ij} is #, and a \"road\" square if S_{ij} is ..\n\nFrom a road square, you can move to a horizontally or vertically adjacent road square.\n\nYou cannot move out of the maze, move to a wall square, or move diagonally.\n\nTakahashi will choose a starting square and a goal square, which can be any road squares, and give the maze to Aoki.\n\nAoki will then travel from the starting square to the goal square, in the minimum number of moves required.\n\nIn this situation, find the maximum possible number of moves Aoki has to make.\n\nConstraints\n\n1 \\leq H,W \\leq 20\n\nS_{ij} is . or #.\n\nS contains at least two occurrences of ..\n\nAny road square can be reached from any road square in zero or more moves.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nS_{11}...S_{1W}\n:\nS_{H1}...S_{HW}\n\nOutput\n\nPrint the maximum possible number of moves Aoki has to make.\n\nSample Input 1\n\n3 3\n...\n...\n...\n\nSample Output 1\n\n4\n\nIf Takahashi chooses the top-left square as the starting square and the bottom-right square as the goal square, Aoki has to make four moves.\n\nSample Input 2\n\n3 5\n...#.\n.#.#.\n.#...\n\nSample Output 2\n\n10\n\nIf Takahashi chooses the bottom-left square as the starting square and the top-right square as the goal square, Aoki has to make ten moves.", "sample_input": "3 3\n...\n...\n...\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02803", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi has a maze, which is a grid of H \\times W squares with H horizontal rows and W vertical columns.\n\nThe square at the i-th row from the top and the j-th column is a \"wall\" square if S_{ij} is #, and a \"road\" square if S_{ij} is ..\n\nFrom a road square, you can move to a horizontally or vertically adjacent road square.\n\nYou cannot move out of the maze, move to a wall square, or move diagonally.\n\nTakahashi will choose a starting square and a goal square, which can be any road squares, and give the maze to Aoki.\n\nAoki will then travel from the starting square to the goal square, in the minimum number of moves required.\n\nIn this situation, find the maximum possible number of moves Aoki has to make.\n\nConstraints\n\n1 \\leq H,W \\leq 20\n\nS_{ij} is . or #.\n\nS contains at least two occurrences of ..\n\nAny road square can be reached from any road square in zero or more moves.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nS_{11}...S_{1W}\n:\nS_{H1}...S_{HW}\n\nOutput\n\nPrint the maximum possible number of moves Aoki has to make.\n\nSample Input 1\n\n3 3\n...\n...\n...\n\nSample Output 1\n\n4\n\nIf Takahashi chooses the top-left square as the starting square and the bottom-right square as the goal square, Aoki has to make four moves.\n\nSample Input 2\n\n3 5\n...#.\n.#.#.\n.#...\n\nSample Output 2\n\n10\n\nIf Takahashi chooses the bottom-left square as the starting square and the top-right square as the goal square, Aoki has to make ten moves.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1540, "cpu_time_ms": 869, "memory_kb": 70864}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s324850668", "group_id": "codeNet:p02806", "input_text": "object Main extends App {\n val n = scala.io.StdIn.readInt()\n var playList = Vector.empty[(String, Int)]\n (1 to n).foreach { _ =>\n val stInput = scala.io.StdIn.readLine()\n val stInputArray = stInput.split(\" \")\n val title = stInputArray(0)\n val time = stInputArray(1).toInt\n playList :+= (title, time)\n }\n val sleepTitle = scala.io.StdIn.readLine()\n var sleepTitleFind = false\n var sleepTime = 0\n playList.foreach { p =>\n if (sleepTitleFind) {\n sleepTime = sleepTime + p._2\n } else {\n if (p._1 == sleepTitle) {\n sleepTitleFind = true\n }\n }\n }\n println(sleepTime)\n}", "language": "Scala", "metadata": {"date": 1578791593, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/s324850668.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s324850668", "user_id": "u105921924"}, "prompt_components": {"gold_output": "30\n", "input_to_evaluate": "object Main extends App {\n val n = scala.io.StdIn.readInt()\n var playList = Vector.empty[(String, Int)]\n (1 to n).foreach { _ =>\n val stInput = scala.io.StdIn.readLine()\n val stInputArray = stInput.split(\" \")\n val title = stInputArray(0)\n val time = stInputArray(1).toInt\n playList :+= (title, time)\n }\n val sleepTitle = scala.io.StdIn.readLine()\n var sleepTitleFind = false\n var sleepTime = 0\n playList.foreach { p =>\n if (sleepTitleFind) {\n sleepTime = sleepTime + p._2\n } else {\n if (p._1 == sleepTitle) {\n sleepTitleFind = true\n }\n }\n }\n println(sleepTime)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nNiwango created a playlist of N songs.\nThe title and the duration of the i-th song are s_i and t_i seconds, respectively.\nIt is guaranteed that s_1,\\ldots,s_N are all distinct.\n\nNiwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.)\nHowever, he fell asleep during his work, and he woke up after all the songs were played.\nAccording to his record, it turned out that he fell asleep at the very end of the song titled X.\n\nFind the duration of time when some song was played while Niwango was asleep.\n\nConstraints\n\n1 \\leq N \\leq 50\n\ns_i and X are strings of length between 1 and 100 (inclusive) consisting of lowercase English letters.\n\ns_1,\\ldots,s_N are distinct.\n\nThere exists an integer i such that s_i = X.\n\n1 \\leq t_i \\leq 1000\n\nt_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1 t_1\n\\vdots\ns_{N} t_N\nX\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\ndwango 2\nsixth 5\nprelims 25\ndwango\n\nSample Output 1\n\n30\n\nWhile Niwango was asleep, two songs were played: sixth and prelims.\n\nThe answer is the total duration of these songs, 30.\n\nSample Input 2\n\n1\nabcde 1000\nabcde\n\nSample Output 2\n\n0\n\nNo songs were played while Niwango was asleep.\n\nIn such a case, the total duration of songs is 0.\n\nSample Input 3\n\n15\nypnxn 279\nkgjgwx 464\nqquhuwq 327\nrxing 549\npmuduhznoaqu 832\ndagktgdarveusju 595\nwunfagppcoi 200\ndhavrncwfw 720\njpcmigg 658\nwrczqxycivdqn 639\nmcmkkbnjfeod 992\nhtqvkgkbhtytsz 130\ntwflegsjz 467\ndswxxrxuzzfhkp 989\nszfwtzfpnscgue 958\npmuduhznoaqu\n\nSample Output 3\n\n6348", "sample_input": "3\ndwango 2\nsixth 5\nprelims 25\ndwango\n"}, "reference_outputs": ["30\n"], "source_document_id": "p02806", "source_text": "Score : 200 points\n\nProblem Statement\n\nNiwango created a playlist of N songs.\nThe title and the duration of the i-th song are s_i and t_i seconds, respectively.\nIt is guaranteed that s_1,\\ldots,s_N are all distinct.\n\nNiwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.)\nHowever, he fell asleep during his work, and he woke up after all the songs were played.\nAccording to his record, it turned out that he fell asleep at the very end of the song titled X.\n\nFind the duration of time when some song was played while Niwango was asleep.\n\nConstraints\n\n1 \\leq N \\leq 50\n\ns_i and X are strings of length between 1 and 100 (inclusive) consisting of lowercase English letters.\n\ns_1,\\ldots,s_N are distinct.\n\nThere exists an integer i such that s_i = X.\n\n1 \\leq t_i \\leq 1000\n\nt_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1 t_1\n\\vdots\ns_{N} t_N\nX\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\ndwango 2\nsixth 5\nprelims 25\ndwango\n\nSample Output 1\n\n30\n\nWhile Niwango was asleep, two songs were played: sixth and prelims.\n\nThe answer is the total duration of these songs, 30.\n\nSample Input 2\n\n1\nabcde 1000\nabcde\n\nSample Output 2\n\n0\n\nNo songs were played while Niwango was asleep.\n\nIn such a case, the total duration of songs is 0.\n\nSample Input 3\n\n15\nypnxn 279\nkgjgwx 464\nqquhuwq 327\nrxing 549\npmuduhznoaqu 832\ndagktgdarveusju 595\nwunfagppcoi 200\ndhavrncwfw 720\njpcmigg 658\nwrczqxycivdqn 639\nmcmkkbnjfeod 992\nhtqvkgkbhtytsz 130\ntwflegsjz 467\ndswxxrxuzzfhkp 989\nszfwtzfpnscgue 958\npmuduhznoaqu\n\nSample Output 3\n\n6348", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 618, "cpu_time_ms": 324, "memory_kb": 27316}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s958482074", "group_id": "codeNet:p02811", "input_text": "object Main extends App {\n val Array(k,x) = readLine.split(\" \").map{_.toInt}\n println(if (k*500 >= x) \"Yes\" else \"No\")\n}", "language": "Scala", "metadata": {"date": 1578963747, "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/s958482074.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s958482074", "user_id": "u696665136"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n val Array(k,x) = readLine.split(\" \").map{_.toInt}\n println(if (k*500 >= x) \"Yes\" else \"No\")\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi has K 500-yen coins. (Yen is the currency of Japan.)\nIf these coins add up to X yen or more, print Yes; otherwise, print No.\n\nConstraints\n\n1 \\leq K \\leq 100\n\n1 \\leq X \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK X\n\nOutput\n\nIf the coins add up to X yen or more, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 900\n\nSample Output 1\n\nYes\n\nTwo 500-yen coins add up to 1000 yen, which is not less than X = 900 yen.\n\nSample Input 2\n\n1 501\n\nSample Output 2\n\nNo\n\nOne 500-yen coin is worth 500 yen, which is less than X = 501 yen.\n\nSample Input 3\n\n4 2000\n\nSample Output 3\n\nYes\n\nFour 500-yen coins add up to 2000 yen, which is not less than X = 2000 yen.", "sample_input": "2 900\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02811", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi has K 500-yen coins. (Yen is the currency of Japan.)\nIf these coins add up to X yen or more, print Yes; otherwise, print No.\n\nConstraints\n\n1 \\leq K \\leq 100\n\n1 \\leq X \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK X\n\nOutput\n\nIf the coins add up to X yen or more, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 900\n\nSample Output 1\n\nYes\n\nTwo 500-yen coins add up to 1000 yen, which is not less than X = 900 yen.\n\nSample Input 2\n\n1 501\n\nSample Output 2\n\nNo\n\nOne 500-yen coin is worth 500 yen, which is less than X = 501 yen.\n\nSample Input 3\n\n4 2000\n\nSample Output 3\n\nYes\n\nFour 500-yen coins add up to 2000 yen, which is not less than X = 2000 yen.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 122, "cpu_time_ms": 334, "memory_kb": 25432}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s158817326", "group_id": "codeNet:p02811", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val nums = io.StdIn.readLine.split(\" \").map{_.toInt}\n if(500*nums(0) >= nums(1)) println(\"Yes\")\n else println(\"No\")\n }\n}", "language": "Scala", "metadata": {"date": 1578708660, "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/s158817326.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s158817326", "user_id": "u888177577"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val nums = io.StdIn.readLine.split(\" \").map{_.toInt}\n if(500*nums(0) >= nums(1)) println(\"Yes\")\n else println(\"No\")\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi has K 500-yen coins. (Yen is the currency of Japan.)\nIf these coins add up to X yen or more, print Yes; otherwise, print No.\n\nConstraints\n\n1 \\leq K \\leq 100\n\n1 \\leq X \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK X\n\nOutput\n\nIf the coins add up to X yen or more, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 900\n\nSample Output 1\n\nYes\n\nTwo 500-yen coins add up to 1000 yen, which is not less than X = 900 yen.\n\nSample Input 2\n\n1 501\n\nSample Output 2\n\nNo\n\nOne 500-yen coin is worth 500 yen, which is less than X = 501 yen.\n\nSample Input 3\n\n4 2000\n\nSample Output 3\n\nYes\n\nFour 500-yen coins add up to 2000 yen, which is not less than X = 2000 yen.", "sample_input": "2 900\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02811", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi has K 500-yen coins. (Yen is the currency of Japan.)\nIf these coins add up to X yen or more, print Yes; otherwise, print No.\n\nConstraints\n\n1 \\leq K \\leq 100\n\n1 \\leq X \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK X\n\nOutput\n\nIf the coins add up to X yen or more, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 900\n\nSample Output 1\n\nYes\n\nTwo 500-yen coins add up to 1000 yen, which is not less than X = 900 yen.\n\nSample Input 2\n\n1 501\n\nSample Output 2\n\nNo\n\nOne 500-yen coin is worth 500 yen, which is less than X = 501 yen.\n\nSample Input 3\n\n4 2000\n\nSample Output 3\n\nYes\n\nFour 500-yen coins add up to 2000 yen, which is not less than X = 2000 yen.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 208, "cpu_time_ms": 325, "memory_kb": 25528}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s345884419", "group_id": "codeNet:p02811", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val k = sc.nextInt\n val x = sc.nextInt\n if(k * 500 >= x){\n println(\"Yes\")\n }else{\n println(\"No\")\n }\n}\n", "language": "Scala", "metadata": {"date": 1578708458, "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/s345884419.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s345884419", "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 k = sc.nextInt\n val x = sc.nextInt\n if(k * 500 >= x){\n println(\"Yes\")\n }else{\n println(\"No\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 347, "memory_kb": 25668}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s853052694", "group_id": "codeNet:p02812", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n\n val sc = new Scanner(System.in)\n val n = sc.nextLine().toInt\n val s = sc.nextLine()\n\n println(m(0, 0))\n \n def m(i: Int, count: Int): Int = {\n s.indexOf(\"ABC\", i) match {\n case -1 => count\n case ni => m(ni + 1, count + 1)\n }\n }\n \n}\n", "language": "Scala", "metadata": {"date": 1589084255, "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/s853052694.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s853052694", "user_id": "u197909036"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n\n val sc = new Scanner(System.in)\n val n = sc.nextLine().toInt\n val s = sc.nextLine()\n\n println(m(0, 0))\n \n def m(i: Int, count: Int): Int = {\n s.indexOf(\"ABC\", i) match {\n case -1 => count\n case ni => m(ni + 1, count + 1)\n }\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 346, "memory_kb": 25424}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s637482033", "group_id": "codeNet:p02812", "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 s = sc.next\n val replaced = s.replace(\"ABC\",\"\").length\n println((n - replaced) / 3 )\n}\n", "language": "Scala", "metadata": {"date": 1578708366, "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/s637482033.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s637482033", "user_id": "u080987909"}, "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 s = sc.next\n val replaced = s.replace(\"ABC\",\"\").length\n println((n - replaced) / 3 )\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 359, "memory_kb": 25808}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s793298770", "group_id": "codeNet:p02813", "input_text": "import scala.math.abs\n\nobject Main extends App {\n val sc = new java.util.Scanner(System.in) \n val N = sc.nextInt()\n val P = Vector.fill(N)(sc.nextInt())\n val Q = Vector.fill(N)(sc.nextInt())\n val permutations = (1 to N).permutations.toList\n val a = permutations.indexOf(P) + 1\n val b = permutations.indexOf(Q) + 1\n println(abs(a - b))\n}\n\n", "language": "Scala", "metadata": {"date": 1598574519, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/s793298770.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s793298770", "user_id": "u396472025"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.math.abs\n\nobject Main extends App {\n val sc = new java.util.Scanner(System.in) \n val N = sc.nextInt()\n val P = Vector.fill(N)(sc.nextInt())\n val Q = Vector.fill(N)(sc.nextInt())\n val permutations = (1 to N).permutations.toList\n val a = permutations.indexOf(P) + 1\n val b = permutations.indexOf(Q) + 1\n println(abs(a - b))\n}\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)).\n\nThere are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Find |a - b|.\n\nNotes\n\nFor two sequences X and Y, X is said to be lexicographically smaller than Y if and only if there exists an integer k such that X_i = Y_i~(1 \\leq i < k) and X_k < Y_k.\n\nConstraints\n\n2 \\leq N \\leq 8\n\nP and Q are permutations of size N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 P_2 ... P_N\nQ_1 Q_2 ... Q_N\n\nOutput\n\nPrint |a - b|.\n\nSample Input 1\n\n3\n1 3 2\n3 1 2\n\nSample Output 1\n\n3\n\nThere are 6 permutations of size 3: (1,~2,~3), (1,~3,~2), (2,~1,~3), (2,~3,~1), (3,~1,~2), and (3,~2,~1). Among them, (1,~3,~2) and (3,~1,~2) come 2-nd and 5-th in lexicographical order, so the answer is |2 - 5| = 3.\n\nSample Input 2\n\n8\n7 3 5 4 2 1 6 8\n3 8 2 5 4 6 7 1\n\nSample Output 2\n\n17517\n\nSample Input 3\n\n3\n1 2 3\n1 2 3\n\nSample Output 3\n\n0", "sample_input": "3\n1 3 2\n3 1 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02813", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)).\n\nThere are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Find |a - b|.\n\nNotes\n\nFor two sequences X and Y, X is said to be lexicographically smaller than Y if and only if there exists an integer k such that X_i = Y_i~(1 \\leq i < k) and X_k < Y_k.\n\nConstraints\n\n2 \\leq N \\leq 8\n\nP and Q are permutations of size N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 P_2 ... P_N\nQ_1 Q_2 ... Q_N\n\nOutput\n\nPrint |a - b|.\n\nSample Input 1\n\n3\n1 3 2\n3 1 2\n\nSample Output 1\n\n3\n\nThere are 6 permutations of size 3: (1,~2,~3), (1,~3,~2), (2,~1,~3), (2,~3,~1), (3,~1,~2), and (3,~2,~1). Among them, (1,~3,~2) and (3,~1,~2) come 2-nd and 5-th in lexicographical order, so the answer is |2 - 5| = 3.\n\nSample Input 2\n\n8\n7 3 5 4 2 1 6 8\n3 8 2 5 4 6 7 1\n\nSample Output 2\n\n17517\n\nSample Input 3\n\n3\n1 2 3\n1 2 3\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 346, "cpu_time_ms": 648, "memory_kb": 66152}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s116852465", "group_id": "codeNet:p02814", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val factors = io.StdIn.readLine.split(\" \").map{_.toLong}\n val nums = io.StdIn.readLine.split(\" \").map{_.toLong}\n\n var least_common_multiple = 1L\n\n nums.foreach { i =>\n least_common_multiple *= i/2L/calcGcd(least_common_multiple, i/2L)\n }\n\n var count = 0\n var flag = true\n\n while(flag) {\n val check_num = (2*count + 1)*least_common_multiple\n if(check_num <= factors(1)) count += 1\n else flag = false\n }\n\n println(count)\n\n }\n\n def calcGcd(num1: Long, num2: Long): Long = {\n var a = num1\n var b = num2\n if(a > b) {\n val tmp = a\n a = b\n b = tmp\n }\n var r = b%a\n\n while(r != 0L) {\n b = a\n a = r\n r = b%a\n }\n return a\n }\n}", "language": "Scala", "metadata": {"date": 1578711413, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02814.html", "problem_id": "p02814", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02814/input.txt", "sample_output_relpath": "derived/input_output/data/p02814/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02814/Scala/s116852465.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s116852465", "user_id": "u888177577"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val factors = io.StdIn.readLine.split(\" \").map{_.toLong}\n val nums = io.StdIn.readLine.split(\" \").map{_.toLong}\n\n var least_common_multiple = 1L\n\n nums.foreach { i =>\n least_common_multiple *= i/2L/calcGcd(least_common_multiple, i/2L)\n }\n\n var count = 0\n var flag = true\n\n while(flag) {\n val check_num = (2*count + 1)*least_common_multiple\n if(check_num <= factors(1)) count += 1\n else flag = false\n }\n\n println(count)\n\n }\n\n def calcGcd(num1: Long, num2: Long): Long = {\n var a = num1\n var b = num2\n if(a > b) {\n val tmp = a\n a = b\n b = tmp\n }\n var r = b%a\n\n while(r != 0L) {\n b = a\n a = r\n r = b%a\n }\n return a\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are a sequence A= {a_1,a_2,......a_N} of N positive even numbers, and an integer M.\n\nLet a semi-common multiple of A be a positive integer X that satisfies the following condition for every k (1 \\leq k \\leq N):\n\nThere exists a non-negative integer p such that X= a_k \\times (p+0.5).\n\nFind the number of semi-common multiples of A among the integers between 1 and M (inclusive).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^9\n\n2 \\leq a_i \\leq 10^9\n\na_i is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of semi-common multiples of A among the integers between 1 and M (inclusive).\n\nSample Input 1\n\n2 50\n6 10\n\nSample Output 1\n\n2\n\n15 = 6 \\times 2.5\n\n15 = 10 \\times 1.5\n\n45 = 6 \\times 7.5\n\n45 = 10 \\times 4.5\n\nThus, 15 and 45 are semi-common multiples of A. There are no other semi-common multiples of A between 1 and 50, so the answer is 2.\n\nSample Input 2\n\n3 100\n14 22 40\n\nSample Output 2\n\n0\n\nThe answer can be 0.\n\nSample Input 3\n\n5 1000000000\n6 6 2 6 2\n\nSample Output 3\n\n166666667", "sample_input": "2 50\n6 10\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02814", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are a sequence A= {a_1,a_2,......a_N} of N positive even numbers, and an integer M.\n\nLet a semi-common multiple of A be a positive integer X that satisfies the following condition for every k (1 \\leq k \\leq N):\n\nThere exists a non-negative integer p such that X= a_k \\times (p+0.5).\n\nFind the number of semi-common multiples of A among the integers between 1 and M (inclusive).\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^9\n\n2 \\leq a_i \\leq 10^9\n\na_i is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of semi-common multiples of A among the integers between 1 and M (inclusive).\n\nSample Input 1\n\n2 50\n6 10\n\nSample Output 1\n\n2\n\n15 = 6 \\times 2.5\n\n15 = 10 \\times 1.5\n\n45 = 6 \\times 7.5\n\n45 = 10 \\times 4.5\n\nThus, 15 and 45 are semi-common multiples of A. There are no other semi-common multiples of A between 1 and 50, so the answer is 2.\n\nSample Input 2\n\n3 100\n14 22 40\n\nSample Output 2\n\n0\n\nThe answer can be 0.\n\nSample Input 3\n\n5 1000000000\n6 6 2 6 2\n\nSample Output 3\n\n166666667", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 786, "cpu_time_ms": 1019, "memory_kb": 48460}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s924739859", "group_id": "codeNet:p02817", "input_text": "object Main extends App {\n val Array(s,t) = readLine.split(\" \")\n \n println(s\"$t$s\")\n}", "language": "Scala", "metadata": {"date": 1578417365, "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/s924739859.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s924739859", "user_id": "u715268393"}, "prompt_components": {"gold_output": "atcoder\n", "input_to_evaluate": "object Main extends App {\n val Array(s,t) = readLine.split(\" \")\n \n println(s\"$t$s\")\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven are two strings S and T consisting of lowercase English letters. Concatenate T and S in this order, without space in between, and print the resulting string.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\nThe lengths of S and T are between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\noder atc\n\nSample Output 1\n\natcoder\n\nWhen S = oder and T = atc, concatenating T and S in this order results in atcoder.\n\nSample Input 2\n\nhumu humu\n\nSample Output 2\n\nhumuhumu", "sample_input": "oder atc\n"}, "reference_outputs": ["atcoder\n"], "source_document_id": "p02817", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven are two strings S and T consisting of lowercase English letters. Concatenate T and S in this order, without space in between, and print the resulting string.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\nThe lengths of S and T are between 1 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\n\nOutput\n\nPrint the resulting string.\n\nSample Input 1\n\noder atc\n\nSample Output 1\n\natcoder\n\nWhen S = oder and T = atc, concatenating T and S in this order results in atcoder.\n\nSample Input 2\n\nhumu humu\n\nSample Output 2\n\nhumuhumu", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 88, "cpu_time_ms": 332, "memory_kb": 25284}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s589173383", "group_id": "codeNet:p02818", "input_text": "object Main extends App{\n import scala.io.StdIn._\n val Array(a,b,k)=readLine().split(\" \").map(_.toLong)\n println(if(k>a) s\"0 ${Math.max(b - (k - a),0)}\"else s\"${a-k} ${b}\")\n}", "language": "Scala", "metadata": {"date": 1587769104, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02818.html", "problem_id": "p02818", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02818/input.txt", "sample_output_relpath": "derived/input_output/data/p02818/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02818/Scala/s589173383.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s589173383", "user_id": "u759091915"}, "prompt_components": {"gold_output": "0 2\n", "input_to_evaluate": "object Main extends App{\n import scala.io.StdIn._\n val Array(a,b,k)=readLine().split(\" \").map(_.toLong)\n println(if(k>a) s\"0 ${Math.max(b - (k - a),0)}\"else s\"${a-k} ${b}\")\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has A cookies, and Aoki has B cookies.\nTakahashi will do the following action K times:\n\nIf Takahashi has one or more cookies, eat one of his cookies.\n\nOtherwise, if Aoki has one or more cookies, eat one of Aoki's cookies.\n\nIf they both have no cookies, do nothing.\n\nIn the end, how many cookies will Takahashi and Aoki have, respectively?\n\nConstraints\n\n0 \\leq A \\leq 10^{12}\n\n0 \\leq B \\leq 10^{12}\n\n0 \\leq K \\leq 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the numbers of Takahashi's and Aoki's cookies after K actions.\n\nSample Input 1\n\n2 3 3\n\nSample Output 1\n\n0 2\n\nTakahashi will do the following:\n\nHe has two cookies, so he eats one of them.\n\nNow he has one cookie left, and he eats it.\n\nNow he has no cookies left, but Aoki has three, so Takahashi eats one of them.\n\nThus, in the end, Takahashi will have 0 cookies, and Aoki will have 2.\n\nSample Input 2\n\n500000000000 500000000000 1000000000000\n\nSample Output 2\n\n0 0\n\nWatch out for overflows.", "sample_input": "2 3 3\n"}, "reference_outputs": ["0 2\n"], "source_document_id": "p02818", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has A cookies, and Aoki has B cookies.\nTakahashi will do the following action K times:\n\nIf Takahashi has one or more cookies, eat one of his cookies.\n\nOtherwise, if Aoki has one or more cookies, eat one of Aoki's cookies.\n\nIf they both have no cookies, do nothing.\n\nIn the end, how many cookies will Takahashi and Aoki have, respectively?\n\nConstraints\n\n0 \\leq A \\leq 10^{12}\n\n0 \\leq B \\leq 10^{12}\n\n0 \\leq K \\leq 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the numbers of Takahashi's and Aoki's cookies after K actions.\n\nSample Input 1\n\n2 3 3\n\nSample Output 1\n\n0 2\n\nTakahashi will do the following:\n\nHe has two cookies, so he eats one of them.\n\nNow he has one cookie left, and he eats it.\n\nNow he has no cookies left, but Aoki has three, so Takahashi eats one of them.\n\nThus, in the end, Takahashi will have 0 cookies, and Aoki will have 2.\n\nSample Input 2\n\n500000000000 500000000000 1000000000000\n\nSample Output 2\n\n0 0\n\nWatch out for overflows.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 319, "memory_kb": 27208}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s868546538", "group_id": "codeNet:p02818", "input_text": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val A, B, K = sc.nextLong()\n\n val (a, b) = if (K <= A) {\n (A - K, B)\n } else {\n (0, (B - (K - A) max 0))\n }\n println(s\"$a $b\")\n }\n\n}", "language": "Scala", "metadata": {"date": 1577669838, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02818.html", "problem_id": "p02818", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02818/input.txt", "sample_output_relpath": "derived/input_output/data/p02818/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02818/Scala/s868546538.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s868546538", "user_id": "u891387249"}, "prompt_components": {"gold_output": "0 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 A, B, K = sc.nextLong()\n\n val (a, b) = if (K <= A) {\n (A - K, B)\n } else {\n (0, (B - (K - A) max 0))\n }\n println(s\"$a $b\")\n }\n\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has A cookies, and Aoki has B cookies.\nTakahashi will do the following action K times:\n\nIf Takahashi has one or more cookies, eat one of his cookies.\n\nOtherwise, if Aoki has one or more cookies, eat one of Aoki's cookies.\n\nIf they both have no cookies, do nothing.\n\nIn the end, how many cookies will Takahashi and Aoki have, respectively?\n\nConstraints\n\n0 \\leq A \\leq 10^{12}\n\n0 \\leq B \\leq 10^{12}\n\n0 \\leq K \\leq 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the numbers of Takahashi's and Aoki's cookies after K actions.\n\nSample Input 1\n\n2 3 3\n\nSample Output 1\n\n0 2\n\nTakahashi will do the following:\n\nHe has two cookies, so he eats one of them.\n\nNow he has one cookie left, and he eats it.\n\nNow he has no cookies left, but Aoki has three, so Takahashi eats one of them.\n\nThus, in the end, Takahashi will have 0 cookies, and Aoki will have 2.\n\nSample Input 2\n\n500000000000 500000000000 1000000000000\n\nSample Output 2\n\n0 0\n\nWatch out for overflows.", "sample_input": "2 3 3\n"}, "reference_outputs": ["0 2\n"], "source_document_id": "p02818", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has A cookies, and Aoki has B cookies.\nTakahashi will do the following action K times:\n\nIf Takahashi has one or more cookies, eat one of his cookies.\n\nOtherwise, if Aoki has one or more cookies, eat one of Aoki's cookies.\n\nIf they both have no cookies, do nothing.\n\nIn the end, how many cookies will Takahashi and Aoki have, respectively?\n\nConstraints\n\n0 \\leq A \\leq 10^{12}\n\n0 \\leq B \\leq 10^{12}\n\n0 \\leq K \\leq 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the numbers of Takahashi's and Aoki's cookies after K actions.\n\nSample Input 1\n\n2 3 3\n\nSample Output 1\n\n0 2\n\nTakahashi will do the following:\n\nHe has two cookies, so he eats one of them.\n\nNow he has one cookie left, and he eats it.\n\nNow he has no cookies left, but Aoki has three, so Takahashi eats one of them.\n\nThus, in the end, Takahashi will have 0 cookies, and Aoki will have 2.\n\nSample Input 2\n\n500000000000 500000000000 1000000000000\n\nSample Output 2\n\n0 0\n\nWatch out for overflows.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 263, "cpu_time_ms": 350, "memory_kb": 27716}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s180595379", "group_id": "codeNet:p02819", "input_text": "import scala.io.StdIn._\n\nobject Main extends App {\n\n\n val x = readInt()\n\n def solve(): Int = {\n var ans = x\n while(!isPrime(ans)) ans += 1\n ans\n }\n\n def isPrime(num: Int): Boolean = {\n if(num <= 1) false\n else if(num == 2) true\n else (2 until num).forall(num % _ != 0)\n }\n\n println(solve())\n\n}\n\n", "language": "Scala", "metadata": {"date": 1595085352, "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/s180595379.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s180595379", "user_id": "u947008426"}, "prompt_components": {"gold_output": "23\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main extends App {\n\n\n val x = readInt()\n\n def solve(): Int = {\n var ans = x\n while(!isPrime(ans)) ans += 1\n ans\n }\n\n def isPrime(num: Int): Boolean = {\n if(num <= 1) false\n else if(num == 2) true\n else (2 until num).forall(num % _ != 0)\n }\n\n println(solve())\n\n}\n\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nFind the minimum prime number greater than or equal to X.\n\nNotes\n\nA prime number is an integer greater than 1 that cannot be evenly divided by any positive integer except 1 and itself.\n\nFor example, 2, 3, and 5 are prime numbers, while 4 and 6 are not.\n\nConstraints\n\n2 \\le X \\le 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the minimum prime number greater than or equal to X.\n\nSample Input 1\n\n20\n\nSample Output 1\n\n23\n\nThe minimum prime number greater than or equal to 20 is 23.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n2\n\nX itself can be a prime number.\n\nSample Input 3\n\n99992\n\nSample Output 3\n\n100003", "sample_input": "20\n"}, "reference_outputs": ["23\n"], "source_document_id": "p02819", "source_text": "Score: 300 points\n\nProblem Statement\n\nFind the minimum prime number greater than or equal to X.\n\nNotes\n\nA prime number is an integer greater than 1 that cannot be evenly divided by any positive integer except 1 and itself.\n\nFor example, 2, 3, and 5 are prime numbers, while 4 and 6 are not.\n\nConstraints\n\n2 \\le X \\le 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the minimum prime number greater than or equal to X.\n\nSample Input 1\n\n20\n\nSample Output 1\n\n23\n\nThe minimum prime number greater than or equal to 20 is 23.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n2\n\nX itself can be a prime number.\n\nSample Input 3\n\n99992\n\nSample Output 3\n\n100003", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 319, "cpu_time_ms": 495, "memory_kb": 54812}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s413517091", "group_id": "codeNet:p02819", "input_text": "import java.util.Scanner\n\nimport scala.collection.mutable.ListBuffer\n\nobject PrimeInt {\n val ps: Stream[Int] = 2 #:: Stream.from(3).filter(i => ps.takeWhile(j => j * j <= i).forall(k => i % k > 0))\n\n def isPrime(n: Int): Boolean = ps.takeWhile(_ <= n).contains(n)\n}\n\nobject Primes extends Iterable[Long] {\n var checked = 2L\n val xs = ListBuffer(2L)\n\n def contains(i: Long): Boolean = xs.takeWhile(_ <= i).contains(i)\n\n def apply(i: Int): Long = {\n while (xs.length <= i) {\n var n = checked + 1\n while (xs.takeWhile(j => j * j <= n).exists(n % _ == 0)) {\n n += 1\n }\n xs.append(n)\n checked = n\n }\n xs(i)\n }\n\n override def iterator: Iterator[Long] = new Iterator[Long] {\n var i = 0\n\n override def hasNext: Boolean = true\n\n override def next(): Long = {\n val x = apply(i); i += 1; x\n }\n }\n}\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 prime(n: Int, primes: Seq[Int]) = primes.forall(p => n % p != 0)\n\n def solve(sc: Scanner): String = {\n val X = sc.nextInt\n\n var i = X\n while (!PrimeInt.isPrime(i)) i += 1\n\n i.toString\n }\n}\n", "language": "Scala", "metadata": {"date": 1577900030, "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/s413517091.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s413517091", "user_id": "u297767059"}, "prompt_components": {"gold_output": "23\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.collection.mutable.ListBuffer\n\nobject PrimeInt {\n val ps: Stream[Int] = 2 #:: Stream.from(3).filter(i => ps.takeWhile(j => j * j <= i).forall(k => i % k > 0))\n\n def isPrime(n: Int): Boolean = ps.takeWhile(_ <= n).contains(n)\n}\n\nobject Primes extends Iterable[Long] {\n var checked = 2L\n val xs = ListBuffer(2L)\n\n def contains(i: Long): Boolean = xs.takeWhile(_ <= i).contains(i)\n\n def apply(i: Int): Long = {\n while (xs.length <= i) {\n var n = checked + 1\n while (xs.takeWhile(j => j * j <= n).exists(n % _ == 0)) {\n n += 1\n }\n xs.append(n)\n checked = n\n }\n xs(i)\n }\n\n override def iterator: Iterator[Long] = new Iterator[Long] {\n var i = 0\n\n override def hasNext: Boolean = true\n\n override def next(): Long = {\n val x = apply(i); i += 1; x\n }\n }\n}\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 prime(n: Int, primes: Seq[Int]) = primes.forall(p => n % p != 0)\n\n def solve(sc: Scanner): String = {\n val X = sc.nextInt\n\n var i = X\n while (!PrimeInt.isPrime(i)) i += 1\n\n i.toString\n }\n}\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nFind the minimum prime number greater than or equal to X.\n\nNotes\n\nA prime number is an integer greater than 1 that cannot be evenly divided by any positive integer except 1 and itself.\n\nFor example, 2, 3, and 5 are prime numbers, while 4 and 6 are not.\n\nConstraints\n\n2 \\le X \\le 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the minimum prime number greater than or equal to X.\n\nSample Input 1\n\n20\n\nSample Output 1\n\n23\n\nThe minimum prime number greater than or equal to 20 is 23.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n2\n\nX itself can be a prime number.\n\nSample Input 3\n\n99992\n\nSample Output 3\n\n100003", "sample_input": "20\n"}, "reference_outputs": ["23\n"], "source_document_id": "p02819", "source_text": "Score: 300 points\n\nProblem Statement\n\nFind the minimum prime number greater than or equal to X.\n\nNotes\n\nA prime number is an integer greater than 1 that cannot be evenly divided by any positive integer except 1 and itself.\n\nFor example, 2, 3, and 5 are prime numbers, while 4 and 6 are not.\n\nConstraints\n\n2 \\le X \\le 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the minimum prime number greater than or equal to X.\n\nSample Input 1\n\n20\n\nSample Output 1\n\n23\n\nThe minimum prime number greater than or equal to 20 is 23.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n2\n\nX itself can be a prime number.\n\nSample Input 3\n\n99992\n\nSample Output 3\n\n100003", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1265, "cpu_time_ms": 522, "memory_kb": 46684}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s518429145", "group_id": "codeNet:p02820", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val n = sc.nextInt()\n val k = sc.nextInt()\n val r = sc.nextInt()\n val s = sc.nextInt()\n val p = sc.nextInt()\n sc.nextLine()\n val str = sc.nextLine().toCharArray\n val qd = new QD(n, k, r, s, p)\n println(qd.ans(str))\n }\n}\n\nclass QD(n: Int, k: Int, r: Long, s: Long, p: Long) {\n def judge(c: Char):Long = {\n if(c.equals('r')) {\n this.p\n } else if(c.equals('s')) {\n this.r\n } else if(c.equals('p')) {\n this.s\n } else {\n 0\n }\n }\n\n def ans(str: Array[Char]): Long = {\n var result = 0L\n for(i <- Range(0, this.n)) {\n if(i >= k && str(i).equals(str(i-k))) {\n str(i) = '_'\n } else {\n result += judge(str(i))\n }\n }\n result\n }\n}\n", "language": "Scala", "metadata": {"date": 1578020803, "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/s518429145.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s518429145", "user_id": "u291133005"}, "prompt_components": {"gold_output": "27\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val n = sc.nextInt()\n val k = sc.nextInt()\n val r = sc.nextInt()\n val s = sc.nextInt()\n val p = sc.nextInt()\n sc.nextLine()\n val str = sc.nextLine().toCharArray\n val qd = new QD(n, k, r, s, p)\n println(qd.ans(str))\n }\n}\n\nclass QD(n: Int, k: Int, r: Long, s: Long, p: Long) {\n def judge(c: Char):Long = {\n if(c.equals('r')) {\n this.p\n } else if(c.equals('s')) {\n this.r\n } else if(c.equals('p')) {\n this.s\n } else {\n 0\n }\n }\n\n def ans(str: Array[Char]): Long = {\n var result = 0L\n for(i <- Range(0, this.n)) {\n if(i >= k && str(i).equals(str(i-k))) {\n str(i) = '_'\n } else {\n result += judge(str(i))\n }\n }\n result\n }\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 830, "cpu_time_ms": 449, "memory_kb": 30828}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s654103704", "group_id": "codeNet:p02821", "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 _A = Array.fill[Int](N+1)(Int.MaxValue)\n for (i <- 1 to N) {\n _A(i) = in.next().toInt\n }\n\n //\n val A = _A.sorted.reverse\n\n val accs = new Array[Long](N+1)\n accs(1) = A(1)\n for (i <- 2 to N)\n accs(i) = A(i) + A(i-1)\n\n // 条件を満たす最大の値を返す\n def bs(_min: Int, _max: Int, i: Int, m: Int): Int = {\n def check(t: Int): Boolean = {\n A(t) + A(i) >= m\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 binarySearch(_min: Int, _max: Int): Int = {\n def check(m: Int): Boolean = {\n var res = 0\n for (i <- 1 to N) {\n val b = bs(0, N, i, m)\n res += b\n }\n res >= M\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 val maxPair = binarySearch(1, 1e5.toInt * 2)\n var ans = 0L\n for (i <- 1 to N) {\n val ind = bs(0, N, i, maxPair)\n ans += accs(ind) + A(i) * ind\n }\n \n println(ans)\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": 1588185155, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02821.html", "problem_id": "p02821", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02821/input.txt", "sample_output_relpath": "derived/input_output/data/p02821/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02821/Scala/s654103704.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s654103704", "user_id": "u098968285"}, "prompt_components": {"gold_output": "202\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 _A = Array.fill[Int](N+1)(Int.MaxValue)\n for (i <- 1 to N) {\n _A(i) = in.next().toInt\n }\n\n //\n val A = _A.sorted.reverse\n\n val accs = new Array[Long](N+1)\n accs(1) = A(1)\n for (i <- 2 to N)\n accs(i) = A(i) + A(i-1)\n\n // 条件を満たす最大の値を返す\n def bs(_min: Int, _max: Int, i: Int, m: Int): Int = {\n def check(t: Int): Boolean = {\n A(t) + A(i) >= m\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 binarySearch(_min: Int, _max: Int): Int = {\n def check(m: Int): Boolean = {\n var res = 0\n for (i <- 1 to N) {\n val b = bs(0, N, i, m)\n res += b\n }\n res >= M\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 val maxPair = binarySearch(1, 1e5.toInt * 2)\n var ans = 0L\n for (i <- 1 to N) {\n val ind = bs(0, N, i, maxPair)\n ans += accs(ind) + A(i) * ind\n }\n \n println(ans)\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 : 500 points\n\nProblem Statement\n\nTakahashi has come to a party as a special guest.\nThere are N ordinary guests at the party. The i-th ordinary guest has a power of A_i.\n\nTakahashi has decided to perform M handshakes to increase the happiness of the party (let the current happiness be 0).\nA handshake will be performed as follows:\n\nTakahashi chooses one (ordinary) guest x for his left hand and another guest y for his right hand (x and y can be the same).\n\nThen, he shakes the left hand of Guest x and the right hand of Guest y simultaneously to increase the happiness by A_x+A_y.\n\nHowever, Takahashi should not perform the same handshake more than once. Formally, the following condition must hold:\n\nAssume that, in the k-th handshake, Takahashi shakes the left hand of Guest x_k and the right hand of Guest y_k. Then, there is no pair p, q (1 \\leq p < q \\leq M) such that (x_p,y_p)=(x_q,y_q).\n\nWhat is the maximum possible happiness after M handshakes?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq N^2\n\n1 \\leq A_i \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible happiness after M handshakes.\n\nSample Input 1\n\n5 3\n10 14 19 34 33\n\nSample Output 1\n\n202\n\nLet us say that Takahashi performs the following handshakes:\n\nIn the first handshake, Takahashi shakes the left hand of Guest 4 and the right hand of Guest 4.\n\nIn the second handshake, Takahashi shakes the left hand of Guest 4 and the right hand of Guest 5.\n\nIn the third handshake, Takahashi shakes the left hand of Guest 5 and the right hand of Guest 4.\n\nThen, we will have the happiness of (34+34)+(34+33)+(33+34)=202.\n\nWe cannot achieve the happiness of 203 or greater, so the answer is 202.\n\nSample Input 2\n\n9 14\n1 3 5 110 24 21 34 5 3\n\nSample Output 2\n\n1837\n\nSample Input 3\n\n9 73\n67597 52981 5828 66249 75177 64141 40773 79105 16076\n\nSample Output 3\n\n8128170", "sample_input": "5 3\n10 14 19 34 33\n"}, "reference_outputs": ["202\n"], "source_document_id": "p02821", "source_text": "Score : 500 points\n\nProblem Statement\n\nTakahashi has come to a party as a special guest.\nThere are N ordinary guests at the party. The i-th ordinary guest has a power of A_i.\n\nTakahashi has decided to perform M handshakes to increase the happiness of the party (let the current happiness be 0).\nA handshake will be performed as follows:\n\nTakahashi chooses one (ordinary) guest x for his left hand and another guest y for his right hand (x and y can be the same).\n\nThen, he shakes the left hand of Guest x and the right hand of Guest y simultaneously to increase the happiness by A_x+A_y.\n\nHowever, Takahashi should not perform the same handshake more than once. Formally, the following condition must hold:\n\nAssume that, in the k-th handshake, Takahashi shakes the left hand of Guest x_k and the right hand of Guest y_k. Then, there is no pair p, q (1 \\leq p < q \\leq M) such that (x_p,y_p)=(x_q,y_q).\n\nWhat is the maximum possible happiness after M handshakes?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq N^2\n\n1 \\leq A_i \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible happiness after M handshakes.\n\nSample Input 1\n\n5 3\n10 14 19 34 33\n\nSample Output 1\n\n202\n\nLet us say that Takahashi performs the following handshakes:\n\nIn the first handshake, Takahashi shakes the left hand of Guest 4 and the right hand of Guest 4.\n\nIn the second handshake, Takahashi shakes the left hand of Guest 4 and the right hand of Guest 5.\n\nIn the third handshake, Takahashi shakes the left hand of Guest 5 and the right hand of Guest 4.\n\nThen, we will have the happiness of (34+34)+(34+33)+(33+34)=202.\n\nWe cannot achieve the happiness of 203 or greater, so the answer is 202.\n\nSample Input 2\n\n9 14\n1 3 5 110 24 21 34 5 3\n\nSample Output 2\n\n1837\n\nSample Input 3\n\n9 73\n67597 52981 5828 66249 75177 64141 40773 79105 16076\n\nSample Output 3\n\n8128170", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2453, "cpu_time_ms": 864, "memory_kb": 45868}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s951160613", "group_id": "codeNet:p02821", "input_text": "\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 M = sc.nextLong()\n val A = Array.fill(N)(sc.nextLong()).sorted(Ordering.Long.reverse)\n // 左手と右手で握手できる.\n // その時, 左手で握手した人のパワー + 右手で握手した人のパワーが上昇する\n // しかし, 全く同じ握手を二回以上行えない,\n // 右手と左手を入れ替えて握手することは可能, また, 両手で握手することも可能\n // パワーが大きい順に貪欲に握手していけば良さそうな気がする\n // まず、パワーが大きい順にソート.\n // 左から, 両手で握手して, 左手で握手,\n // ただ, Mが10^5なので, このままでは間に合わない\n // 握手を行う人と, 握手を行わない人を分別する必要がある\n // 二分探索でその境界を探す\n // 握手を行う人の, 握手の組み合わせの数, 「握手する人から2つを選ぶ数」がM以上になる境界\n // 「握手する人から2つを選ぶ数」は, 「握手をする人 * 握手をする人」通りある\n // そしてその仮定の素では、選んだ全ての人と1 + 2 * (L - 1)回握手することになる, 両手は一回, 他の人と左手, 右手\n // そして探したM以上になるやつで, Mになるまで小さい順から握手を減らしていけばいい\n // うーーん、違うか\n// def solve(N: Int, M: Long, A: Array[Long]): Long = {\n// // 組み合わせの数が M 以上になる握手人数\n// def lowerBounds(M: Long): Int = {\n// def loop(left: Int, right: Int): Int =\n// if (right - left > 1) {\n// val mid = left + (right - left) / 2\n// if (mid * mid >= M) loop(left, mid)\n// else loop(mid, right)\n// } else right\n// loop(-1, N)\n// }\n// val L = lowerBounds(M)\n// val MAXP = (0 until L).map(i => A(i)).sum * (2 * (L - 1) + 1)// 最大数\n// val AA = A.take(L).sorted // 対象にしているやつのみ選び昇順にソートする\n//\n// println(MAXP, L)\n// def loop(i: Int, rest: Long, acm: Long): Long =\n// if (rest > M) {\n// if (M - rest >= 3) {\n// loop(i + 1, rest - 3, acm - 4 * AA(i) - 2 * AA(i+1))\n// } else if (M - rest >= 2) {\n// loop(i + 1, rest - 2, acm - 3 * AA(i) - 1 * AA(i+1))\n// } else {\n// loop(i + 1, rest - 1, acm - 2 * AA(i))\n// }\n// } else acm\n// loop(0, L, MAXP)\n// }\n\n // 単に全ての組み合わせの中から幸福度が高い順番にM個取り出せば良いが、間に合わない\n // 組み合わせの中から高い順にM個取り出せばいい、ということは,\n // 幸福度が上がる量が X 以上の 組み合わせが M通り以上ある場合の最小のXについて求める\n // 左手で握手する人を決めた場合、右手で握手できる人が何人いるか?\n // 累積和のくだりよくわからんので, 左手で握手する人を決め,\n // 右手で握手できる人数を二分探索で求めることにする\n // 先に大きい順に並び変えておく. O(NlogNlogN)で求まるはず.\n // そのXが求まった場合, それを満たす場合の計算をする\n def solve(N: Int, M: Long, A: Array[Long]): Long = {\n val AMAX = Math.pow(10, 5).toInt * 2\n def lowerBounds(M: Long): Long = {\n def loop(left: Long, right: Long): Long =\n if (right - left > 1) {\n val mid = left + (right - left) / 2\n if (check(mid)) loop(mid, right)\n else loop(left, mid)\n } else left\n loop(-1, AMAX)\n }\n def check(X: Long): Boolean =\n (0 until N).foldLeft(0L)((acm, l) => {\n val r = lowerBounds2(X, l)\n acm + (r + 1)\n }) >= M\n // lを決めた時に,X以上にできる数のindex, = lの時見つからなかかった\n def lowerBounds2(X: Long, l: Int): Int = {\n def loop(left: Int, right: Int): Int =\n if (right - left > 1) {\n val mid = left + (right - left) / 2\n if (A(l) + A(mid) >= X) loop(mid, right)\n else loop(left, mid)\n } else left\n loop(-1, N)\n }\n \n val R = new Array[Long](N)\n R(0) = A(0)\n (1 until N).foreach(i => {\n R(i) += A(i) + R(i-1)\n })\n val X = lowerBounds(M)\n // M回を超える場合があるので, 超えた分を X * 超えた分引く必要がある\n val over = (0 until N).foldLeft(0L)((acm, l) => {\n val r = lowerBounds2(X, l)\n acm + (r + 1)\n }) - M\n (0 until N).foldLeft(0L)((acm, l) => {\n val r = lowerBounds2(X, l)\n if (r >= 0) {\n acm + R(r) + A(l) * (r + 1)\n } else acm\n }) - over * X\n }\n\n println(solve(N, M, A))\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1577687572, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02821.html", "problem_id": "p02821", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02821/input.txt", "sample_output_relpath": "derived/input_output/data/p02821/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02821/Scala/s951160613.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s951160613", "user_id": "u891387249"}, "prompt_components": {"gold_output": "202\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 val N = sc.nextInt()\n val M = sc.nextLong()\n val A = Array.fill(N)(sc.nextLong()).sorted(Ordering.Long.reverse)\n // 左手と右手で握手できる.\n // その時, 左手で握手した人のパワー + 右手で握手した人のパワーが上昇する\n // しかし, 全く同じ握手を二回以上行えない,\n // 右手と左手を入れ替えて握手することは可能, また, 両手で握手することも可能\n // パワーが大きい順に貪欲に握手していけば良さそうな気がする\n // まず、パワーが大きい順にソート.\n // 左から, 両手で握手して, 左手で握手,\n // ただ, Mが10^5なので, このままでは間に合わない\n // 握手を行う人と, 握手を行わない人を分別する必要がある\n // 二分探索でその境界を探す\n // 握手を行う人の, 握手の組み合わせの数, 「握手する人から2つを選ぶ数」がM以上になる境界\n // 「握手する人から2つを選ぶ数」は, 「握手をする人 * 握手をする人」通りある\n // そしてその仮定の素では、選んだ全ての人と1 + 2 * (L - 1)回握手することになる, 両手は一回, 他の人と左手, 右手\n // そして探したM以上になるやつで, Mになるまで小さい順から握手を減らしていけばいい\n // うーーん、違うか\n// def solve(N: Int, M: Long, A: Array[Long]): Long = {\n// // 組み合わせの数が M 以上になる握手人数\n// def lowerBounds(M: Long): Int = {\n// def loop(left: Int, right: Int): Int =\n// if (right - left > 1) {\n// val mid = left + (right - left) / 2\n// if (mid * mid >= M) loop(left, mid)\n// else loop(mid, right)\n// } else right\n// loop(-1, N)\n// }\n// val L = lowerBounds(M)\n// val MAXP = (0 until L).map(i => A(i)).sum * (2 * (L - 1) + 1)// 最大数\n// val AA = A.take(L).sorted // 対象にしているやつのみ選び昇順にソートする\n//\n// println(MAXP, L)\n// def loop(i: Int, rest: Long, acm: Long): Long =\n// if (rest > M) {\n// if (M - rest >= 3) {\n// loop(i + 1, rest - 3, acm - 4 * AA(i) - 2 * AA(i+1))\n// } else if (M - rest >= 2) {\n// loop(i + 1, rest - 2, acm - 3 * AA(i) - 1 * AA(i+1))\n// } else {\n// loop(i + 1, rest - 1, acm - 2 * AA(i))\n// }\n// } else acm\n// loop(0, L, MAXP)\n// }\n\n // 単に全ての組み合わせの中から幸福度が高い順番にM個取り出せば良いが、間に合わない\n // 組み合わせの中から高い順にM個取り出せばいい、ということは,\n // 幸福度が上がる量が X 以上の 組み合わせが M通り以上ある場合の最小のXについて求める\n // 左手で握手する人を決めた場合、右手で握手できる人が何人いるか?\n // 累積和のくだりよくわからんので, 左手で握手する人を決め,\n // 右手で握手できる人数を二分探索で求めることにする\n // 先に大きい順に並び変えておく. O(NlogNlogN)で求まるはず.\n // そのXが求まった場合, それを満たす場合の計算をする\n def solve(N: Int, M: Long, A: Array[Long]): Long = {\n val AMAX = Math.pow(10, 5).toInt * 2\n def lowerBounds(M: Long): Long = {\n def loop(left: Long, right: Long): Long =\n if (right - left > 1) {\n val mid = left + (right - left) / 2\n if (check(mid)) loop(mid, right)\n else loop(left, mid)\n } else left\n loop(-1, AMAX)\n }\n def check(X: Long): Boolean =\n (0 until N).foldLeft(0L)((acm, l) => {\n val r = lowerBounds2(X, l)\n acm + (r + 1)\n }) >= M\n // lを決めた時に,X以上にできる数のindex, = lの時見つからなかかった\n def lowerBounds2(X: Long, l: Int): Int = {\n def loop(left: Int, right: Int): Int =\n if (right - left > 1) {\n val mid = left + (right - left) / 2\n if (A(l) + A(mid) >= X) loop(mid, right)\n else loop(left, mid)\n } else left\n loop(-1, N)\n }\n \n val R = new Array[Long](N)\n R(0) = A(0)\n (1 until N).foreach(i => {\n R(i) += A(i) + R(i-1)\n })\n val X = lowerBounds(M)\n // M回を超える場合があるので, 超えた分を X * 超えた分引く必要がある\n val over = (0 until N).foldLeft(0L)((acm, l) => {\n val r = lowerBounds2(X, l)\n acm + (r + 1)\n }) - M\n (0 until N).foldLeft(0L)((acm, l) => {\n val r = lowerBounds2(X, l)\n if (r >= 0) {\n acm + R(r) + A(l) * (r + 1)\n } else acm\n }) - over * X\n }\n\n println(solve(N, M, A))\n }\n\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nTakahashi has come to a party as a special guest.\nThere are N ordinary guests at the party. The i-th ordinary guest has a power of A_i.\n\nTakahashi has decided to perform M handshakes to increase the happiness of the party (let the current happiness be 0).\nA handshake will be performed as follows:\n\nTakahashi chooses one (ordinary) guest x for his left hand and another guest y for his right hand (x and y can be the same).\n\nThen, he shakes the left hand of Guest x and the right hand of Guest y simultaneously to increase the happiness by A_x+A_y.\n\nHowever, Takahashi should not perform the same handshake more than once. Formally, the following condition must hold:\n\nAssume that, in the k-th handshake, Takahashi shakes the left hand of Guest x_k and the right hand of Guest y_k. Then, there is no pair p, q (1 \\leq p < q \\leq M) such that (x_p,y_p)=(x_q,y_q).\n\nWhat is the maximum possible happiness after M handshakes?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq N^2\n\n1 \\leq A_i \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible happiness after M handshakes.\n\nSample Input 1\n\n5 3\n10 14 19 34 33\n\nSample Output 1\n\n202\n\nLet us say that Takahashi performs the following handshakes:\n\nIn the first handshake, Takahashi shakes the left hand of Guest 4 and the right hand of Guest 4.\n\nIn the second handshake, Takahashi shakes the left hand of Guest 4 and the right hand of Guest 5.\n\nIn the third handshake, Takahashi shakes the left hand of Guest 5 and the right hand of Guest 4.\n\nThen, we will have the happiness of (34+34)+(34+33)+(33+34)=202.\n\nWe cannot achieve the happiness of 203 or greater, so the answer is 202.\n\nSample Input 2\n\n9 14\n1 3 5 110 24 21 34 5 3\n\nSample Output 2\n\n1837\n\nSample Input 3\n\n9 73\n67597 52981 5828 66249 75177 64141 40773 79105 16076\n\nSample Output 3\n\n8128170", "sample_input": "5 3\n10 14 19 34 33\n"}, "reference_outputs": ["202\n"], "source_document_id": "p02821", "source_text": "Score : 500 points\n\nProblem Statement\n\nTakahashi has come to a party as a special guest.\nThere are N ordinary guests at the party. The i-th ordinary guest has a power of A_i.\n\nTakahashi has decided to perform M handshakes to increase the happiness of the party (let the current happiness be 0).\nA handshake will be performed as follows:\n\nTakahashi chooses one (ordinary) guest x for his left hand and another guest y for his right hand (x and y can be the same).\n\nThen, he shakes the left hand of Guest x and the right hand of Guest y simultaneously to increase the happiness by A_x+A_y.\n\nHowever, Takahashi should not perform the same handshake more than once. Formally, the following condition must hold:\n\nAssume that, in the k-th handshake, Takahashi shakes the left hand of Guest x_k and the right hand of Guest y_k. Then, there is no pair p, q (1 \\leq p < q \\leq M) such that (x_p,y_p)=(x_q,y_q).\n\nWhat is the maximum possible happiness after M handshakes?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq N^2\n\n1 \\leq A_i \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible happiness after M handshakes.\n\nSample Input 1\n\n5 3\n10 14 19 34 33\n\nSample Output 1\n\n202\n\nLet us say that Takahashi performs the following handshakes:\n\nIn the first handshake, Takahashi shakes the left hand of Guest 4 and the right hand of Guest 4.\n\nIn the second handshake, Takahashi shakes the left hand of Guest 4 and the right hand of Guest 5.\n\nIn the third handshake, Takahashi shakes the left hand of Guest 5 and the right hand of Guest 4.\n\nThen, we will have the happiness of (34+34)+(34+33)+(33+34)=202.\n\nWe cannot achieve the happiness of 203 or greater, so the answer is 202.\n\nSample Input 2\n\n9 14\n1 3 5 110 24 21 34 5 3\n\nSample Output 2\n\n1837\n\nSample Input 3\n\n9 73\n67597 52981 5828 66249 75177 64141 40773 79105 16076\n\nSample Output 3\n\n8128170", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5000, "cpu_time_ms": 1103, "memory_kb": 74064}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s119281806", "group_id": "codeNet:p02823", "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, A, B = sc.nextLong()\n\n // 負けが右, 勝ちが左へ\n // 一番左で勝っても動かず、一番右で負けても動かない\n // 同時に動く場合, 一度に2ずつ近づける\n // * L = 2N + 1 台間にある場合には N ラウンドでOK\n // * L = 2N 台間にある場合には そのまま近づいていってもダメなので\n // (A max B) min ((N - A) max (N - B)) で良い?\n def solve(N: Long, A: Long, B: Long): Long = {\n val L = B - A\n if ((L - 1L) % 2L == 1L) L / 2L\n else ((A - 1) min (N - B) + 1 + (B - A - 1) / 2)\n }\n\n println(solve(N, A, B))\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1577597101, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02823.html", "problem_id": "p02823", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02823/input.txt", "sample_output_relpath": "derived/input_output/data/p02823/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02823/Scala/s119281806.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s119281806", "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 val N, A, B = sc.nextLong()\n\n // 負けが右, 勝ちが左へ\n // 一番左で勝っても動かず、一番右で負けても動かない\n // 同時に動く場合, 一度に2ずつ近づける\n // * L = 2N + 1 台間にある場合には N ラウンドでOK\n // * L = 2N 台間にある場合には そのまま近づいていってもダメなので\n // (A max B) min ((N - A) max (N - B)) で良い?\n def solve(N: Long, A: Long, B: Long): Long = {\n val L = B - A\n if ((L - 1L) % 2L == 1L) L / 2L\n else ((A - 1) min (N - B) + 1 + (B - A - 1) / 2)\n }\n\n println(solve(N, A, B))\n }\n\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\n2N players are running a competitive table tennis training on N tables numbered from 1 to N.\n\nThe training consists of rounds.\nIn each round, the players form N pairs, one pair per table.\nIn each pair, competitors play a match against each other.\nAs a result, one of them wins and the other one loses.\n\nThe winner of the match on table X plays on table X-1 in the next round,\nexcept for the winner of the match on table 1 who stays at table 1.\n\nSimilarly, the loser of the match on table X plays on table X+1 in the next round,\nexcept for the loser of the match on table N who stays at table N.\n\nTwo friends are playing their first round matches on distinct tables A and B.\nLet's assume that the friends are strong enough to win or lose any match at will.\nWhat is the smallest number of rounds after which the friends can get to play a match against each other?\n\nConstraints\n\n2 \\leq N \\leq 10^{18}\n\n1 \\leq A < B \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the smallest number of rounds after which the friends can get to play a match against each other.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\n1\n\nIf the first friend loses their match and the second friend wins their match, they will both move to table 3 and play each other in the next round.\n\nSample Input 2\n\n5 2 3\n\nSample Output 2\n\n2\n\nIf both friends win two matches in a row, they will both move to table 1.", "sample_input": "5 2 4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02823", "source_text": "Score : 300 points\n\nProblem Statement\n\n2N players are running a competitive table tennis training on N tables numbered from 1 to N.\n\nThe training consists of rounds.\nIn each round, the players form N pairs, one pair per table.\nIn each pair, competitors play a match against each other.\nAs a result, one of them wins and the other one loses.\n\nThe winner of the match on table X plays on table X-1 in the next round,\nexcept for the winner of the match on table 1 who stays at table 1.\n\nSimilarly, the loser of the match on table X plays on table X+1 in the next round,\nexcept for the loser of the match on table N who stays at table N.\n\nTwo friends are playing their first round matches on distinct tables A and B.\nLet's assume that the friends are strong enough to win or lose any match at will.\nWhat is the smallest number of rounds after which the friends can get to play a match against each other?\n\nConstraints\n\n2 \\leq N \\leq 10^{18}\n\n1 \\leq A < B \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the smallest number of rounds after which the friends can get to play a match against each other.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\n1\n\nIf the first friend loses their match and the second friend wins their match, they will both move to table 3 and play each other in the next round.\n\nSample Input 2\n\n5 2 3\n\nSample Output 2\n\n2\n\nIf both friends win two matches in a row, they will both move to table 1.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 743, "cpu_time_ms": 342, "memory_kb": 27332}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s410429729", "group_id": "codeNet:p02830", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val str_len = io.StdIn.readInt\n val Array(str1, str2) = io.StdIn.readLine.split(\" \")\n var ans_str = \"\"\n\n (0 until str_len).foreach{ i =>\n ans_str += str1(i).toString + str2(i)\n }\n println(ans_str)\n }\n}", "language": "Scala", "metadata": {"date": 1577067017, "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/s410429729.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s410429729", "user_id": "u888177577"}, "prompt_components": {"gold_output": "icpc\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val str_len = io.StdIn.readInt\n val Array(str1, str2) = io.StdIn.readLine.split(\" \")\n var ans_str = \"\"\n\n (0 until str_len).foreach{ i =>\n ans_str += str1(i).toString + str2(i)\n }\n println(ans_str)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 282, "cpu_time_ms": 326, "memory_kb": 25404}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s622964012", "group_id": "codeNet:p02832", "input_text": "object Main extends App {\n @scala.annotation.tailrec\n def loop(ints: Seq[Int], i: Int): Int = ints match {\n case Seq() => i\n case x :: xs if x == i => loop(xs, i + 1)\n case _ :: xs => loop(xs, i)\n }\n val sc = new java.util.Scanner(System.in)\n val N = sc.nextInt()\n val count = loop(List.fill(N)(sc.nextInt()), 1) - 1\n println(if (count == 0) -1 else N - count)\n}\n", "language": "Scala", "metadata": {"date": 1593655770, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02832.html", "problem_id": "p02832", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02832/input.txt", "sample_output_relpath": "derived/input_output/data/p02832/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02832/Scala/s622964012.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s622964012", "user_id": "u737111725"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main extends App {\n @scala.annotation.tailrec\n def loop(ints: Seq[Int], i: Int): Int = ints match {\n case Seq() => i\n case x :: xs if x == i => loop(xs, i + 1)\n case _ :: xs => loop(xs, i)\n }\n val sc = new java.util.Scanner(System.in)\n val N = sc.nextInt()\n val count = loop(List.fill(N)(sc.nextInt()), 1) - 1\n println(if (count == 0) -1 else N - count)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N bricks arranged in a row from left to right.\n\nThe i-th brick from the left (1 \\leq i \\leq N) has an integer a_i written on it.\n\nAmong them, you can break at most N-1 bricks of your choice.\n\nLet us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \\leq i \\leq K), the i-th of those brick from the left has the integer i written on it.\n\nFind the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print -1 instead.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 200000\n\n1 \\leq a_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print -1 if his desire is unsatisfiable.\n\nSample Input 1\n\n3\n2 1 2\n\nSample Output 1\n\n1\n\nIf we break the leftmost brick, the remaining bricks have integers 1 and 2 written on them from left to right, in which case Snuke will be satisfied.\n\nSample Input 2\n\n3\n2 2 2\n\nSample Output 2\n\n-1\n\nIn this case, there is no way to break some of the bricks to satisfy Snuke's desire.\n\nSample Input 3\n\n10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 3\n\n7\n\nSample Input 4\n\n1\n1\n\nSample Output 4\n\n0\n\nThere may be no need to break the bricks at all.", "sample_input": "3\n2 1 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02832", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have N bricks arranged in a row from left to right.\n\nThe i-th brick from the left (1 \\leq i \\leq N) has an integer a_i written on it.\n\nAmong them, you can break at most N-1 bricks of your choice.\n\nLet us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \\leq i \\leq K), the i-th of those brick from the left has the integer i written on it.\n\nFind the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print -1 instead.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 200000\n\n1 \\leq a_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print -1 if his desire is unsatisfiable.\n\nSample Input 1\n\n3\n2 1 2\n\nSample Output 1\n\n1\n\nIf we break the leftmost brick, the remaining bricks have integers 1 and 2 written on them from left to right, in which case Snuke will be satisfied.\n\nSample Input 2\n\n3\n2 2 2\n\nSample Output 2\n\n-1\n\nIn this case, there is no way to break some of the bricks to satisfy Snuke's desire.\n\nSample Input 3\n\n10\n3 1 4 1 5 9 2 6 5 3\n\nSample Output 3\n\n7\n\nSample Input 4\n\n1\n1\n\nSample Output 4\n\n0\n\nThere may be no need to break the bricks at all.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 379, "cpu_time_ms": 935, "memory_kb": 66196}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s780183026", "group_id": "codeNet:p02833", "input_text": "import java.util.Scanner\nobject Main extends App {\n val in = new Scanner(System.in)\n val n = in.nextLong\n val divs: Stream[Long] = 10 #:: divs.map(_ * 5).takeWhile(_ <= 1000000000000000000L)\n println(if (n % 2 == 1) 0 else divs.map(n / _).sum)\n}", "language": "Scala", "metadata": {"date": 1577214302, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02833.html", "problem_id": "p02833", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02833/input.txt", "sample_output_relpath": "derived/input_output/data/p02833/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02833/Scala/s780183026.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s780183026", "user_id": "u132324749"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.Scanner\nobject Main extends App {\n val in = new Scanner(System.in)\n val n = in.nextLong\n val divs: Stream[Long] = 10 #:: divs.map(_ * 5).takeWhile(_ <= 1000000000000000000L)\n println(if (n % 2 == 1) 0 else divs.map(n / _).sum)\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nFor an integer n not less than 0, let us define f(n) as follows:\n\nf(n) = 1 (if n < 2)\n\nf(n) = n f(n-2) (if n \\geq 2)\n\nGiven is an integer N. Find the number of trailing zeros in the decimal notation of f(N).\n\nConstraints\n\n0 \\leq N \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of trailing zeros in the decimal notation of f(N).\n\nSample Input 1\n\n12\n\nSample Output 1\n\n1\n\nf(12) = 12 × 10 × 8 × 6 × 4 × 2 = 46080, which has one trailing zero.\n\nSample Input 2\n\n5\n\nSample Output 2\n\n0\n\nf(5) = 5 × 3 × 1 = 15, which has no trailing zeros.\n\nSample Input 3\n\n1000000000000000000\n\nSample Output 3\n\n124999999999999995", "sample_input": "12\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02833", "source_text": "Score : 500 points\n\nProblem Statement\n\nFor an integer n not less than 0, let us define f(n) as follows:\n\nf(n) = 1 (if n < 2)\n\nf(n) = n f(n-2) (if n \\geq 2)\n\nGiven is an integer N. Find the number of trailing zeros in the decimal notation of f(N).\n\nConstraints\n\n0 \\leq N \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of trailing zeros in the decimal notation of f(N).\n\nSample Input 1\n\n12\n\nSample Output 1\n\n1\n\nf(12) = 12 × 10 × 8 × 6 × 4 × 2 = 46080, which has one trailing zero.\n\nSample Input 2\n\n5\n\nSample Output 2\n\n0\n\nf(5) = 5 × 3 × 1 = 15, which has no trailing zeros.\n\nSample Input 3\n\n1000000000000000000\n\nSample Output 3\n\n124999999999999995", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 249, "cpu_time_ms": 349, "memory_kb": 27312}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s812402426", "group_id": "codeNet:p02833", "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\n //\n if (N % 2 == 1)\n println(0)\n else {\n var a = N / 2L\n\n var ans = 0L\n while (a > 0) {\n ans += a / 5\n a /= 5\n }\n\n println(ans)\n }\n\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": 1577072471, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02833.html", "problem_id": "p02833", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02833/input.txt", "sample_output_relpath": "derived/input_output/data/p02833/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02833/Scala/s812402426.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s812402426", "user_id": "u098968285"}, "prompt_components": {"gold_output": "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 = in.next().toInt\n\n //\n if (N % 2 == 1)\n println(0)\n else {\n var a = N / 2L\n\n var ans = 0L\n while (a > 0) {\n ans += a / 5\n a /= 5\n }\n\n println(ans)\n }\n\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\nFor an integer n not less than 0, let us define f(n) as follows:\n\nf(n) = 1 (if n < 2)\n\nf(n) = n f(n-2) (if n \\geq 2)\n\nGiven is an integer N. Find the number of trailing zeros in the decimal notation of f(N).\n\nConstraints\n\n0 \\leq N \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of trailing zeros in the decimal notation of f(N).\n\nSample Input 1\n\n12\n\nSample Output 1\n\n1\n\nf(12) = 12 × 10 × 8 × 6 × 4 × 2 = 46080, which has one trailing zero.\n\nSample Input 2\n\n5\n\nSample Output 2\n\n0\n\nf(5) = 5 × 3 × 1 = 15, which has no trailing zeros.\n\nSample Input 3\n\n1000000000000000000\n\nSample Output 3\n\n124999999999999995", "sample_input": "12\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02833", "source_text": "Score : 500 points\n\nProblem Statement\n\nFor an integer n not less than 0, let us define f(n) as follows:\n\nf(n) = 1 (if n < 2)\n\nf(n) = n f(n-2) (if n \\geq 2)\n\nGiven is an integer N. Find the number of trailing zeros in the decimal notation of f(N).\n\nConstraints\n\n0 \\leq N \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of trailing zeros in the decimal notation of f(N).\n\nSample Input 1\n\n12\n\nSample Output 1\n\n1\n\nf(12) = 12 × 10 × 8 × 6 × 4 × 2 = 46080, which has one trailing zero.\n\nSample Input 2\n\n5\n\nSample Output 2\n\n0\n\nf(5) = 5 × 3 × 1 = 15, which has no trailing zeros.\n\nSample Input 3\n\n1000000000000000000\n\nSample Output 3\n\n124999999999999995", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 962, "cpu_time_ms": 341, "memory_kb": 25668}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s939478656", "group_id": "codeNet:p02837", "input_text": "import util.control.Breaks._\n\nobject Main extends App {\n val n = io.StdIn.readLine().toInt\n val testimony = Array.fill(n)(Array.fill(n)(-1))\n var max = 0\n\n for (i <- 0 until n) {\n val a = io.StdIn.readLine().toInt\n for (_ <- 0 until a) {\n val Array(x, y) = io.StdIn.readLine().split(' ').map(_.toInt)\n testimony(i)(x-1) = y\n }\n }\n\n for (b <- 0 until 1 << n) {\n breakable {\n var count = 0\n for (i <- 0 until n; if (b & (1 << i)) != 0) {\n testimony(i).indices.withFilter(testimony(i)(_) != -1).foreach {j =>\n val x = (1 << j) & b\n if (testimony(i)(j) == 1 && x == 0) break()\n if (testimony(i)(j) == 0 && x != 0) break()\n count += 1\n }\n }\n if (max < count) max = count\n }\n }\n\n println(max)\n}", "language": "Scala", "metadata": {"date": 1575910847, "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/s939478656.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s939478656", "user_id": "u269739894"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import util.control.Breaks._\n\nobject Main extends App {\n val n = io.StdIn.readLine().toInt\n val testimony = Array.fill(n)(Array.fill(n)(-1))\n var max = 0\n\n for (i <- 0 until n) {\n val a = io.StdIn.readLine().toInt\n for (_ <- 0 until a) {\n val Array(x, y) = io.StdIn.readLine().split(' ').map(_.toInt)\n testimony(i)(x-1) = y\n }\n }\n\n for (b <- 0 until 1 << n) {\n breakable {\n var count = 0\n for (i <- 0 until n; if (b & (1 << i)) != 0) {\n testimony(i).indices.withFilter(testimony(i)(_) != -1).foreach {j =>\n val x = (1 << j) & b\n if (testimony(i)(j) == 1 && x == 0) break()\n if (testimony(i)(j) == 0 && x != 0) break()\n count += 1\n }\n }\n if (max < count) max = count\n }\n }\n\n println(max)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 514, "memory_kb": 40188}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s025968981", "group_id": "codeNet:p02837", "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 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 n).map { i =>\n val persons = new Array[Int](n)\n persons(i) = 1\n\n val honestsQueue = new mutable.Queue[Int]()\n honestsQueue += i\n\n var inconsistence = false\n\n while (honestsQueue.nonEmpty) {\n val honest = honestsQueue.dequeue()\n evs(honest).foreach { ev =>\n if (ev(1) == 1) {\n if (persons(ev(0)) == 2) {\n inconsistence = true\n } else if (persons(ev(0)) == 0) {\n persons(ev(0)) = 1\n honestsQueue += ev(0)\n }\n } else {\n if (persons(ev(0)) == 1) {\n inconsistence = true\n } else if (persons(ev(0)) == 0) {\n persons(ev(0)) = 2\n }\n }\n }\n }\n\n if (inconsistence) {\n 0\n } else {\n persons.count(_ == 1)\n }\n }.max\n )\n }\n}\n", "language": "Scala", "metadata": {"date": 1575860354, "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/s025968981.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s025968981", "user_id": "u178269371"}, "prompt_components": {"gold_output": "2\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 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 n).map { i =>\n val persons = new Array[Int](n)\n persons(i) = 1\n\n val honestsQueue = new mutable.Queue[Int]()\n honestsQueue += i\n\n var inconsistence = false\n\n while (honestsQueue.nonEmpty) {\n val honest = honestsQueue.dequeue()\n evs(honest).foreach { ev =>\n if (ev(1) == 1) {\n if (persons(ev(0)) == 2) {\n inconsistence = true\n } else if (persons(ev(0)) == 0) {\n persons(ev(0)) = 1\n honestsQueue += ev(0)\n }\n } else {\n if (persons(ev(0)) == 1) {\n inconsistence = true\n } else if (persons(ev(0)) == 0) {\n persons(ev(0)) = 2\n }\n }\n }\n }\n\n if (inconsistence) {\n 0\n } else {\n persons.count(_ == 1)\n }\n }.max\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1447, "cpu_time_ms": 364, "memory_kb": 25528}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s120468627", "group_id": "codeNet:p02842", "input_text": "object Main extends App {\n import scala.io.StdIn.readInt\n import scala.math.floor\n \n val n = readInt.toFloat\n \n if((n / 1.08) <= floor((n+1)/1.08))println(floor((n+1)/ 1.08).toInt.toString);\n else println(\":(\");\n \n}", "language": "Scala", "metadata": {"date": 1594479962, "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/s120468627.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s120468627", "user_id": "u189998431"}, "prompt_components": {"gold_output": "400\n", "input_to_evaluate": "object Main extends App {\n import scala.io.StdIn.readInt\n import scala.math.floor\n \n val n = readInt.toFloat\n \n if((n / 1.08) <= floor((n+1)/1.08))println(floor((n+1)/ 1.08).toInt.toString);\n else println(\":(\");\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 489, "memory_kb": 54492}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s645350226", "group_id": "codeNet:p02844", "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 sc.nextInt()\n val S = sc.next()\n val T = S.reverse\n val A = S.scanLeft(Set[Char]())((x: Set[Char], y: Char) => x + y)\n val B = T.scanLeft(Set[Char]())((x: Set[Char], y: Char) => x + y).reverse.tail\n\n // val X = Array.fill(10)(Set[String]())\n val ans =\n A.zip(B).zip(S).foldLeft(Set[String]()) {\n case (prev, ((x: Set[Char], y: Set[Char]), s: Char)) =>\n val now: Set[String] = for {\n i <- x\n j <- y\n } yield i.toString + s + j\n prev ++ now\n }\n println(ans.size)\n // println(ans.mkString(\" \"))\n //\n // println(A.mkString(\" \"))\n // println(B.mkString(\" \"))\n }\n\n def recursive(a: Int, b: Int, c: Int, cost: Int, X: Array[Int]): Array[((Int, Int, Int), Int)] = {\n if (X.length == 0)\n if (a != 0 && b != 0 && c != 0) Array(((a, b, c), cost))\n else Array()\n else {\n val top = X.head\n val tail = X.tail\n recursive(a + top, b, c, cost + 10, tail) ++\n recursive(a, b + top, c, cost + 10, tail) ++\n recursive(a, b, c + top, cost + 10, tail) ++\n recursive(a, b, c, cost, tail)\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", "language": "Scala", "metadata": {"date": 1575433180, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02844.html", "problem_id": "p02844", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02844/input.txt", "sample_output_relpath": "derived/input_output/data/p02844/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02844/Scala/s645350226.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s645350226", "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 sc.nextInt()\n val S = sc.next()\n val T = S.reverse\n val A = S.scanLeft(Set[Char]())((x: Set[Char], y: Char) => x + y)\n val B = T.scanLeft(Set[Char]())((x: Set[Char], y: Char) => x + y).reverse.tail\n\n // val X = Array.fill(10)(Set[String]())\n val ans =\n A.zip(B).zip(S).foldLeft(Set[String]()) {\n case (prev, ((x: Set[Char], y: Set[Char]), s: Char)) =>\n val now: Set[String] = for {\n i <- x\n j <- y\n } yield i.toString + s + j\n prev ++ now\n }\n println(ans.size)\n // println(ans.mkString(\" \"))\n //\n // println(A.mkString(\" \"))\n // println(B.mkString(\" \"))\n }\n\n def recursive(a: Int, b: Int, c: Int, cost: Int, X: Array[Int]): Array[((Int, Int, Int), Int)] = {\n if (X.length == 0)\n if (a != 0 && b != 0 && c != 0) Array(((a, b, c), cost))\n else Array()\n else {\n val top = X.head\n val tail = X.tail\n recursive(a + top, b, c, cost + 10, tail) ++\n recursive(a, b + top, c, cost + 10, tail) ++\n recursive(a, b, c + top, cost + 10, tail) ++\n recursive(a, b, c, cost, tail)\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", "problem_context": "Score: 400 points\n\nProblem Statement\n\nAtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code.\n\nThe company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code.\n\nHow many different PIN codes can he set this way?\n\nBoth the lucky number and the PIN code may begin with a 0.\n\nConstraints\n\n4 \\leq N \\leq 30000\n\nS is a string of length N consisting of digits.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of different PIN codes Takahashi can set.\n\nSample Input 1\n\n4\n0224\n\nSample Output 1\n\n3\n\nTakahashi has the following options:\n\nErase the first digit of S and set 224.\n\nErase the second digit of S and set 024.\n\nErase the third digit of S and set 024.\n\nErase the fourth digit of S and set 022.\n\nThus, he can set three different PIN codes: 022, 024, and 224.\n\nSample Input 2\n\n6\n123123\n\nSample Output 2\n\n17\n\nSample Input 3\n\n19\n3141592653589793238\n\nSample Output 3\n\n329", "sample_input": "4\n0224\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02844", "source_text": "Score: 400 points\n\nProblem Statement\n\nAtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code.\n\nThe company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code.\n\nHow many different PIN codes can he set this way?\n\nBoth the lucky number and the PIN code may begin with a 0.\n\nConstraints\n\n4 \\leq N \\leq 30000\n\nS is a string of length N consisting of digits.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of different PIN codes Takahashi can set.\n\nSample Input 1\n\n4\n0224\n\nSample Output 1\n\n3\n\nTakahashi has the following options:\n\nErase the first digit of S and set 224.\n\nErase the second digit of S and set 024.\n\nErase the third digit of S and set 024.\n\nErase the fourth digit of S and set 022.\n\nThus, he can set three different PIN codes: 022, 024, and 224.\n\nSample Input 2\n\n6\n123123\n\nSample Output 2\n\n17\n\nSample Input 3\n\n19\n3141592653589793238\n\nSample Output 3\n\n329", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 7885, "cpu_time_ms": 2111, "memory_kb": 122568}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s662233461", "group_id": "codeNet:p02844", "input_text": "import scala.io.StdIn._\nobject Main extends App {\n val n = readInt\n val s = readLine\n\n println((1000 to 1999).count { i =>\n i.toString.takeRight(3).foldLeft(0){(z, c) =>\n val i = s.indexOf(c, z)\n if (i == -1) 100000 else i + 1\n } != 100000\n })\n}", "language": "Scala", "metadata": {"date": 1575305230, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02844.html", "problem_id": "p02844", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02844/input.txt", "sample_output_relpath": "derived/input_output/data/p02844/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02844/Scala/s662233461.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s662233461", "user_id": "u132324749"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.io.StdIn._\nobject Main extends App {\n val n = readInt\n val s = readLine\n\n println((1000 to 1999).count { i =>\n i.toString.takeRight(3).foldLeft(0){(z, c) =>\n val i = s.indexOf(c, z)\n if (i == -1) 100000 else i + 1\n } != 100000\n })\n}", "problem_context": "Score: 400 points\n\nProblem Statement\n\nAtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code.\n\nThe company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code.\n\nHow many different PIN codes can he set this way?\n\nBoth the lucky number and the PIN code may begin with a 0.\n\nConstraints\n\n4 \\leq N \\leq 30000\n\nS is a string of length N consisting of digits.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of different PIN codes Takahashi can set.\n\nSample Input 1\n\n4\n0224\n\nSample Output 1\n\n3\n\nTakahashi has the following options:\n\nErase the first digit of S and set 224.\n\nErase the second digit of S and set 024.\n\nErase the third digit of S and set 024.\n\nErase the fourth digit of S and set 022.\n\nThus, he can set three different PIN codes: 022, 024, and 224.\n\nSample Input 2\n\n6\n123123\n\nSample Output 2\n\n17\n\nSample Input 3\n\n19\n3141592653589793238\n\nSample Output 3\n\n329", "sample_input": "4\n0224\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02844", "source_text": "Score: 400 points\n\nProblem Statement\n\nAtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code.\n\nThe company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code.\n\nHow many different PIN codes can he set this way?\n\nBoth the lucky number and the PIN code may begin with a 0.\n\nConstraints\n\n4 \\leq N \\leq 30000\n\nS is a string of length N consisting of digits.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of different PIN codes Takahashi can set.\n\nSample Input 1\n\n4\n0224\n\nSample Output 1\n\n3\n\nTakahashi has the following options:\n\nErase the first digit of S and set 224.\n\nErase the second digit of S and set 024.\n\nErase the third digit of S and set 024.\n\nErase the fourth digit of S and set 022.\n\nThus, he can set three different PIN codes: 022, 024, and 224.\n\nSample Input 2\n\n6\n123123\n\nSample Output 2\n\n17\n\nSample Input 3\n\n19\n3141592653589793238\n\nSample Output 3\n\n329", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 265, "cpu_time_ms": 370, "memory_kb": 29372}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s686078276", "group_id": "codeNet:p02846", "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\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val T1, T2 = in.next().toLong\n val A1, A2 = in.next().toLong\n val B1, B2 = in.next().toLong\n\n\n //\n val a1 = A1 * T1\n val a2 = A2 * T2\n\n val b1 = B1 * T1\n val b2 = B2 * T2\n\n val asum = a1 + a2\n val bsum = b1 + b2\n \n val hoge = (a1 > b1)\n val fuga = (a2 > b2)\n\n if (asum == bsum) {\n println(\"infinity\")\n }\n else if (hoge == fuga) {\n println(0)\n }\n else {\n\n val c1 = (a1 - b1).abs\n val c2 = (a2 - b2).abs\n\n val c3 = (c1 - c2).abs\n\n if (c1 > c2) {\n println(0)\n }\n else {\n var ans = (c1 / c3) * 2\n\n if (c1 % c3 != 0)\n ans += 1\n\n println(ans)\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\n", "language": "Scala", "metadata": {"date": 1575260263, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02846.html", "problem_id": "p02846", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02846/input.txt", "sample_output_relpath": "derived/input_output/data/p02846/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02846/Scala/s686078276.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s686078276", "user_id": "u098968285"}, "prompt_components": {"gold_output": "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}\n\nobject Main extends App {\n\n val in = new InputReader(System.in)\n val pw = new PrintWriter(System.out)\n\n val T1, T2 = in.next().toLong\n val A1, A2 = in.next().toLong\n val B1, B2 = in.next().toLong\n\n\n //\n val a1 = A1 * T1\n val a2 = A2 * T2\n\n val b1 = B1 * T1\n val b2 = B2 * T2\n\n val asum = a1 + a2\n val bsum = b1 + b2\n \n val hoge = (a1 > b1)\n val fuga = (a2 > b2)\n\n if (asum == bsum) {\n println(\"infinity\")\n }\n else if (hoge == fuga) {\n println(0)\n }\n else {\n\n val c1 = (a1 - b1).abs\n val c2 = (a2 - b2).abs\n\n val c3 = (c1 - c2).abs\n\n if (c1 > c2) {\n println(0)\n }\n else {\n var ans = (c1 / c3) * 2\n\n if (c1 % c3 != 0)\n ans += 1\n\n println(ans)\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\n", "problem_context": "Score: 600 points\n\nProblem Statement\n\nTakahashi and Aoki are training for long-distance races in an infinitely long straight course running from west to east.\n\nThey start simultaneously at the same point and moves as follows towards the east:\n\nTakahashi runs A_1 meters per minute for the first T_1 minutes, then runs at A_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever.\n\nAoki runs B_1 meters per minute for the first T_1 minutes, then runs at B_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever.\n\nHow many times will Takahashi and Aoki meet each other, that is, come to the same point? We do not count the start of the run. If they meet infinitely many times, report that fact.\n\nConstraints\n\n1 \\leq T_i \\leq 100000\n\n1 \\leq A_i \\leq 10^{10}\n\n1 \\leq B_i \\leq 10^{10}\n\nA_1 \\neq B_1\n\nA_2 \\neq B_2\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT_1 T_2\nA_1 A_2\nB_1 B_2\n\nOutput\n\nPrint the number of times Takahashi and Aoki will meet each other.\n\nIf they meet infinitely many times, print infinity instead.\n\nSample Input 1\n\n1 2\n10 10\n12 4\n\nSample Output 1\n\n1\n\nThey will meet just once, \\frac{4}{3} minutes after they start, at \\frac{40}{3} meters from where they start.\n\nSample Input 2\n\n100 1\n101 101\n102 1\n\nSample Output 2\n\ninfinity\n\nThey will meet 101, 202, 303, 404, 505, 606, ... minutes after they start, that is, they will meet infinitely many times.\n\nSample Input 3\n\n12000 15700\n3390000000 3810000000\n5550000000 2130000000\n\nSample Output 3\n\n113\n\nThe values in input may not fit into a 32-bit integer type.", "sample_input": "1 2\n10 10\n12 4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02846", "source_text": "Score: 600 points\n\nProblem Statement\n\nTakahashi and Aoki are training for long-distance races in an infinitely long straight course running from west to east.\n\nThey start simultaneously at the same point and moves as follows towards the east:\n\nTakahashi runs A_1 meters per minute for the first T_1 minutes, then runs at A_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever.\n\nAoki runs B_1 meters per minute for the first T_1 minutes, then runs at B_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever.\n\nHow many times will Takahashi and Aoki meet each other, that is, come to the same point? We do not count the start of the run. If they meet infinitely many times, report that fact.\n\nConstraints\n\n1 \\leq T_i \\leq 100000\n\n1 \\leq A_i \\leq 10^{10}\n\n1 \\leq B_i \\leq 10^{10}\n\nA_1 \\neq B_1\n\nA_2 \\neq B_2\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT_1 T_2\nA_1 A_2\nB_1 B_2\n\nOutput\n\nPrint the number of times Takahashi and Aoki will meet each other.\n\nIf they meet infinitely many times, print infinity instead.\n\nSample Input 1\n\n1 2\n10 10\n12 4\n\nSample Output 1\n\n1\n\nThey will meet just once, \\frac{4}{3} minutes after they start, at \\frac{40}{3} meters from where they start.\n\nSample Input 2\n\n100 1\n101 101\n102 1\n\nSample Output 2\n\ninfinity\n\nThey will meet 101, 202, 303, 404, 505, 606, ... minutes after they start, that is, they will meet infinitely many times.\n\nSample Input 3\n\n12000 15700\n3390000000 3810000000\n5550000000 2130000000\n\nSample Output 3\n\n113\n\nThe values in input may not fit into a 32-bit integer type.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1382, "cpu_time_ms": 320, "memory_kb": 25552}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s604759460", "group_id": "codeNet:p02850", "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 tree = Array.fill[List[(Int, Int)]](N+1)(Nil) // (to, ind)\n for (i <- 1 to N-1) {\n val a, b = in.next().toInt\n tree(a) = (b, i) :: tree(a)\n tree(b) = (a, i) :: tree(b)\n }\n\n //\n val color = tree.map(_.length).max\n val ans = new Array[Int](N)\n\n case class Node(n: Int, preColor: Int)\n val stack = new Stack[Node]()\n\n var _color = 1\n for ((e, i) <- tree(1)) {\n ans(i) = _color\n val node = Node(e, _color)\n _color += 1\n stack.push(node)\n }\n\n while (!stack.isEmpty) {\n val Node(n, preColor) = stack.pop()\n\n var color = 1\n\n for ((e, ind) <- tree(n) if ans(ind) == 0) {\n if (color == preColor)\n color += 1\n\n val node = Node(e, color)\n stack.push(node)\n\n ans(ind) = color\n color += 1\n }\n\n }\n\n pw.println(color)\n ans.drop(1).foreach(pw.println)\n\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": 1586817589, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02850.html", "problem_id": "p02850", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02850/input.txt", "sample_output_relpath": "derived/input_output/data/p02850/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02850/Scala/s604759460.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s604759460", "user_id": "u098968285"}, "prompt_components": {"gold_output": "2\n1\n2\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 tree = Array.fill[List[(Int, Int)]](N+1)(Nil) // (to, ind)\n for (i <- 1 to N-1) {\n val a, b = in.next().toInt\n tree(a) = (b, i) :: tree(a)\n tree(b) = (a, i) :: tree(b)\n }\n\n //\n val color = tree.map(_.length).max\n val ans = new Array[Int](N)\n\n case class Node(n: Int, preColor: Int)\n val stack = new Stack[Node]()\n\n var _color = 1\n for ((e, i) <- tree(1)) {\n ans(i) = _color\n val node = Node(e, _color)\n _color += 1\n stack.push(node)\n }\n\n while (!stack.isEmpty) {\n val Node(n, preColor) = stack.pop()\n\n var color = 1\n\n for ((e, ind) <- tree(n) if ans(ind) == 0) {\n if (color == preColor)\n color += 1\n\n val node = Node(e, color)\n stack.push(node)\n\n ans(ind) = color\n color += 1\n }\n\n }\n\n pw.println(color)\n ans.drop(1).foreach(pw.println)\n\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": "Score : 400 points\n\nProblem Statement\n\nGiven is a tree G with N vertices.\nThe vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i.\n\nConsider painting the edges in G with some number of colors.\nWe want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different.\n\nAmong the colorings satisfying the condition above, construct one that uses the minimum number of colors.\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le a_i \\lt b_i \\le N\n\nAll values in input are integers.\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\na_2 b_2\n\\vdots\na_{N-1} b_{N-1}\n\nOutput\n\nPrint N lines.\n\nThe first line should contain K, the number of colors used.\n\nThe (i+1)-th line (1 \\le i \\le N-1) should contain c_i, the integer representing the color of the i-th edge, where 1 \\le c_i \\le K must hold.\n\nIf there are multiple colorings with the minimum number of colors that satisfy the condition, printing any of them will be accepted.\n\nSample Input 1\n\n3\n1 2\n2 3\n\nSample Output 1\n\n2\n1\n2\n\nSample Input 2\n\n8\n1 2\n2 3\n2 4\n2 5\n4 7\n5 6\n6 8\n\nSample Output 2\n\n4\n1\n2\n3\n4\n1\n1\n2\n\nSample Input 3\n\n6\n1 2\n1 3\n1 4\n1 5\n1 6\n\nSample Output 3\n\n5\n1\n2\n3\n4\n5", "sample_input": "3\n1 2\n2 3\n"}, "reference_outputs": ["2\n1\n2\n"], "source_document_id": "p02850", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is a tree G with N vertices.\nThe vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i.\n\nConsider painting the edges in G with some number of colors.\nWe want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different.\n\nAmong the colorings satisfying the condition above, construct one that uses the minimum number of colors.\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le a_i \\lt b_i \\le N\n\nAll values in input are integers.\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\na_2 b_2\n\\vdots\na_{N-1} b_{N-1}\n\nOutput\n\nPrint N lines.\n\nThe first line should contain K, the number of colors used.\n\nThe (i+1)-th line (1 \\le i \\le N-1) should contain c_i, the integer representing the color of the i-th edge, where 1 \\le c_i \\le K must hold.\n\nIf there are multiple colorings with the minimum number of colors that satisfy the condition, printing any of them will be accepted.\n\nSample Input 1\n\n3\n1 2\n2 3\n\nSample Output 1\n\n2\n1\n2\n\nSample Input 2\n\n8\n1 2\n2 3\n2 4\n2 5\n4 7\n5 6\n6 8\n\nSample Output 2\n\n4\n1\n2\n3\n4\n1\n1\n2\n\nSample Input 3\n\n6\n1 2\n1 3\n1 4\n1 5\n1 6\n\nSample Output 3\n\n5\n1\n2\n3\n4\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1631, "cpu_time_ms": 899, "memory_kb": 62332}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s522914492", "group_id": "codeNet:p02852", "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 S = in.next()\n\n //\n val imos = new Array[Int](N+1)\n for (i <- 0 to N) {\n if (S(i) == '0')\n imos(i) = 1\n }\n\n for (i <- 1 to N)\n imos(i) += imos(i-1)\n\n // 条件を満たす最小の値を返す\n def binarySearch(_min: Int, _max: Int, base: Int): Int = {\n def check(i: Int): Boolean = {\n imos(i) == base\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 = List[Int]()\n\n var now = 0\n var flag = false\n breakable {\n while (now + M < N) {\n if (imos(now) == imos(now+M)) {\n flag = true\n break\n }\n else {\n val next = binarySearch(now+1, now+M, imos(now+M))\n ans = (next - now) :: ans\n now = next\n }\n }\n }\n\n ans = (N-now) :: ans\n\n if (flag)\n println(-1)\n else\n println(ans.reverse.mkString(\" \"))\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": 1586819156, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02852.html", "problem_id": "p02852", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02852/input.txt", "sample_output_relpath": "derived/input_output/data/p02852/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02852/Scala/s522914492.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s522914492", "user_id": "u098968285"}, "prompt_components": {"gold_output": "1 3 2 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, 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 S = in.next()\n\n //\n val imos = new Array[Int](N+1)\n for (i <- 0 to N) {\n if (S(i) == '0')\n imos(i) = 1\n }\n\n for (i <- 1 to N)\n imos(i) += imos(i-1)\n\n // 条件を満たす最小の値を返す\n def binarySearch(_min: Int, _max: Int, base: Int): Int = {\n def check(i: Int): Boolean = {\n imos(i) == base\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 = List[Int]()\n\n var now = 0\n var flag = false\n breakable {\n while (now + M < N) {\n if (imos(now) == imos(now+M)) {\n flag = true\n break\n }\n else {\n val next = binarySearch(now+1, now+M, imos(now+M))\n ans = (next - now) :: ans\n now = next\n }\n }\n }\n\n ans = (N-now) :: ans\n\n if (flag)\n println(-1)\n else\n println(ans.reverse.mkString(\" \"))\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 : 600 points\n\nProblem Statement\n\nTakahashi is playing a board game called Sugoroku.\n\nOn the board, there are N + 1 squares numbered 0 to N. Takahashi starts at Square 0, and he has to stop exactly at Square N to win the game.\n\nThe game uses a roulette with the M numbers from 1 to M. In each turn, Takahashi spins the roulette. If the number x comes up when he is at Square s, he moves to Square s+x. If this makes him go beyond Square N, he loses the game.\n\nAdditionally, some of the squares are Game Over Squares. He also loses the game if he stops at one of those squares. You are given a string S of length N + 1, representing which squares are Game Over Squares. For each i (0 \\leq i \\leq N), Square i is a Game Over Square if S[i] = 1 and not if S[i] = 0.\n\nFind the sequence of numbers coming up in the roulette in which Takahashi can win the game in the fewest number of turns possible. If there are multiple such sequences, find the lexicographically smallest such sequence. If Takahashi cannot win the game, print -1.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n|S| = N + 1\n\nS consists of 0 and 1.\n\nS[0] = 0\n\nS[N] = 0\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nS\n\nOutput\n\nIf Takahashi can win the game, print the lexicographically smallest sequence among the shortest sequences of numbers coming up in the roulette in which Takahashi can win the game, with spaces in between.\n\nIf Takahashi cannot win the game, print -1.\n\nSample Input 1\n\n9 3\n0001000100\n\nSample Output 1\n\n1 3 2 3\n\nIf the numbers 1, 3, 2, 3 come up in this order, Takahashi can reach Square 9 via Square 1, 4, and 6. He cannot reach Square 9 in three or fewer turns, and this is the lexicographically smallest sequence in which he reaches Square 9 in four turns.\n\nSample Input 2\n\n5 4\n011110\n\nSample Output 2\n\n-1\n\nTakahashi cannot reach Square 5.\n\nSample Input 3\n\n6 6\n0101010\n\nSample Output 3\n\n6", "sample_input": "9 3\n0001000100\n"}, "reference_outputs": ["1 3 2 3\n"], "source_document_id": "p02852", "source_text": "Score : 600 points\n\nProblem Statement\n\nTakahashi is playing a board game called Sugoroku.\n\nOn the board, there are N + 1 squares numbered 0 to N. Takahashi starts at Square 0, and he has to stop exactly at Square N to win the game.\n\nThe game uses a roulette with the M numbers from 1 to M. In each turn, Takahashi spins the roulette. If the number x comes up when he is at Square s, he moves to Square s+x. If this makes him go beyond Square N, he loses the game.\n\nAdditionally, some of the squares are Game Over Squares. He also loses the game if he stops at one of those squares. You are given a string S of length N + 1, representing which squares are Game Over Squares. For each i (0 \\leq i \\leq N), Square i is a Game Over Square if S[i] = 1 and not if S[i] = 0.\n\nFind the sequence of numbers coming up in the roulette in which Takahashi can win the game in the fewest number of turns possible. If there are multiple such sequences, find the lexicographically smallest such sequence. If Takahashi cannot win the game, print -1.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n|S| = N + 1\n\nS consists of 0 and 1.\n\nS[0] = 0\n\nS[N] = 0\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nS\n\nOutput\n\nIf Takahashi can win the game, print the lexicographically smallest sequence among the shortest sequences of numbers coming up in the roulette in which Takahashi can win the game, with spaces in between.\n\nIf Takahashi cannot win the game, print -1.\n\nSample Input 1\n\n9 3\n0001000100\n\nSample Output 1\n\n1 3 2 3\n\nIf the numbers 1, 3, 2, 3 come up in this order, Takahashi can reach Square 9 via Square 1, 4, and 6. He cannot reach Square 9 in three or fewer turns, and this is the lexicographically smallest sequence in which he reaches Square 9 in four turns.\n\nSample Input 2\n\n5 4\n011110\n\nSample Output 2\n\n-1\n\nTakahashi cannot reach Square 5.\n\nSample Input 3\n\n6 6\n0101010\n\nSample Output 3\n\n6", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1971, "cpu_time_ms": 501, "memory_kb": 40432}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s174012298", "group_id": "codeNet:p02856", "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 m = Scanner.nextInt()\n val data = Array.fill[Int](m, 2)(Scanner.nextInt())\n\n\n var count = -1\n var sumTmp = 0\n\n def plus(a: Int, b: Int): Int = {\n count += 1\n val v = a + b\n val one = v % 10\n val ten = (v - one) / 10\n if (v >= 10) plus(one, ten) else one\n }\n def plusLoop(parentSum: Int, oneValue: Int, oneCount: Int): Int = {\n if (oneCount >= 1) {\n plusLoop(plus(parentSum, oneValue), oneValue, oneCount - 1)\n } else parentSum\n }\n\n Loop.rep(m, i => {\n val oneValue = data(i)(0)\n val oneCount = data(i)(1)\n sumTmp = plusLoop(sumTmp, oneValue, oneCount)\n })\n\n if (sumTmp >= 10) plus(sumTmp, 0)\n\n println(count)\n\n}", "language": "Scala", "metadata": {"date": 1574565743, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02856.html", "problem_id": "p02856", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02856/input.txt", "sample_output_relpath": "derived/input_output/data/p02856/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02856/Scala/s174012298.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s174012298", "user_id": "u817495853"}, "prompt_components": {"gold_output": "3\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 m = Scanner.nextInt()\n val data = Array.fill[Int](m, 2)(Scanner.nextInt())\n\n\n var count = -1\n var sumTmp = 0\n\n def plus(a: Int, b: Int): Int = {\n count += 1\n val v = a + b\n val one = v % 10\n val ten = (v - one) / 10\n if (v >= 10) plus(one, ten) else one\n }\n def plusLoop(parentSum: Int, oneValue: Int, oneCount: Int): Int = {\n if (oneCount >= 1) {\n plusLoop(plus(parentSum, oneValue), oneValue, oneCount - 1)\n } else parentSum\n }\n\n Loop.rep(m, i => {\n val oneValue = data(i)(0)\n val oneCount = data(i)(1)\n sumTmp = plusLoop(sumTmp, oneValue, oneCount)\n })\n\n if (sumTmp >= 10) plus(sumTmp, 0)\n\n println(count)\n\n}", "problem_context": "Score: 500 points\n\nProblem Statement\n\nN programmers are going to participate in the preliminary stage of DDCC 20XX. Due to the size of the venue, however, at most 9 contestants can participate in the finals.\n\nThe preliminary stage consists of several rounds, which will take place as follows:\n\nAll the N contestants will participate in the first round.\n\nWhen X contestants participate in some round, the number of contestants advancing to the next round will be decided as follows:\n\nThe organizer will choose two consecutive digits in the decimal notation of X, and replace them with the sum of these digits. The number resulted will be the number of contestants advancing to the next round.\n\nFor example, when X = 2378, the number of contestants advancing to the next round will be 578 (if 2 and 3 are chosen), 2108 (if 3 and 7 are chosen), or 2315 (if 7 and 8 are chosen).\n\nWhen X = 100, the number of contestants advancing to the next round will be 10, no matter which two digits are chosen.\n\nThe preliminary stage ends when 9 or fewer contestants remain.\n\nRingo, the chief organizer, wants to hold as many rounds as possible.\nFind the maximum possible number of rounds in the preliminary stage.\n\nSince the number of contestants, N, can be enormous, it is given to you as two integer sequences d_1, \\ldots, d_M and c_1, \\ldots, c_M, which means the following: the decimal notation of N consists of c_1 + c_2 + \\ldots + c_M digits, whose first c_1 digits are all d_1, the following c_2 digits are all d_2, \\ldots, and the last c_M digits are all d_M.\n\nConstraints\n\n1 \\leq M \\leq 200000\n\n0 \\leq d_i \\leq 9\n\nd_1 \\neq 0\n\nd_i \\neq d_{i+1}\n\nc_i \\geq 1\n\n2 \\leq c_1 + \\ldots + c_M \\leq 10^{15}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nM\nd_1 c_1\nd_2 c_2\n:\nd_M c_M\n\nOutput\n\nPrint the maximum possible number of rounds in the preliminary stage.\n\nSample Input 1\n\n2\n2 2\n9 1\n\nSample Output 1\n\n3\n\nIn this case, N = 229 contestants will participate in the first round. One possible progression of the preliminary stage is as follows:\n\n229 contestants participate in Round 1, 49 contestants participate in Round 2, 13 contestants participate in Round 3, and 4 contestants advance to the finals.\n\nHere, three rounds take place in the preliminary stage, which is the maximum possible number.\n\nSample Input 2\n\n3\n1 1\n0 8\n7 1\n\nSample Output 2\n\n9\n\nIn this case, 1000000007 will participate in the first round.", "sample_input": "2\n2 2\n9 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02856", "source_text": "Score: 500 points\n\nProblem Statement\n\nN programmers are going to participate in the preliminary stage of DDCC 20XX. Due to the size of the venue, however, at most 9 contestants can participate in the finals.\n\nThe preliminary stage consists of several rounds, which will take place as follows:\n\nAll the N contestants will participate in the first round.\n\nWhen X contestants participate in some round, the number of contestants advancing to the next round will be decided as follows:\n\nThe organizer will choose two consecutive digits in the decimal notation of X, and replace them with the sum of these digits. The number resulted will be the number of contestants advancing to the next round.\n\nFor example, when X = 2378, the number of contestants advancing to the next round will be 578 (if 2 and 3 are chosen), 2108 (if 3 and 7 are chosen), or 2315 (if 7 and 8 are chosen).\n\nWhen X = 100, the number of contestants advancing to the next round will be 10, no matter which two digits are chosen.\n\nThe preliminary stage ends when 9 or fewer contestants remain.\n\nRingo, the chief organizer, wants to hold as many rounds as possible.\nFind the maximum possible number of rounds in the preliminary stage.\n\nSince the number of contestants, N, can be enormous, it is given to you as two integer sequences d_1, \\ldots, d_M and c_1, \\ldots, c_M, which means the following: the decimal notation of N consists of c_1 + c_2 + \\ldots + c_M digits, whose first c_1 digits are all d_1, the following c_2 digits are all d_2, \\ldots, and the last c_M digits are all d_M.\n\nConstraints\n\n1 \\leq M \\leq 200000\n\n0 \\leq d_i \\leq 9\n\nd_1 \\neq 0\n\nd_i \\neq d_{i+1}\n\nc_i \\geq 1\n\n2 \\leq c_1 + \\ldots + c_M \\leq 10^{15}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nM\nd_1 c_1\nd_2 c_2\n:\nd_M c_M\n\nOutput\n\nPrint the maximum possible number of rounds in the preliminary stage.\n\nSample Input 1\n\n2\n2 2\n9 1\n\nSample Output 1\n\n3\n\nIn this case, N = 229 contestants will participate in the first round. One possible progression of the preliminary stage is as follows:\n\n229 contestants participate in Round 1, 49 contestants participate in Round 2, 13 contestants participate in Round 3, and 4 contestants advance to the finals.\n\nHere, three rounds take place in the preliminary stage, which is the maximum possible number.\n\nSample Input 2\n\n3\n1 1\n0 8\n7 1\n\nSample Output 2\n\n9\n\nIn this case, 1000000007 will participate in the first round.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3684, "cpu_time_ms": 328, "memory_kb": 27208}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s875371138", "group_id": "codeNet:p02859", "input_text": "import scala.io.StdIn._\n\nobject Main extends App {\n\n\n val r = readInt()\n\n def solve() = {\n r * r\n }\n\n println(solve())\n\n}\n\n", "language": "Scala", "metadata": {"date": 1595296598, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/s875371138.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s875371138", "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 r = readInt()\n\n def solve() = {\n r * r\n }\n\n println(solve())\n\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 491, "memory_kb": 54720}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s384879857", "group_id": "codeNet:p02862", "input_text": "import scala.collection.mutable.ArrayBuffer\n\nobject 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 x, y = sc.nextInt\n\t\n\tval M = BigInt(1000000007)\n\tval nm = (x+y) / 3\n\t\n\tdef cmb(n: Int, k: Int): BigInt =\n\t\t(BigInt(1) to BigInt(k)).foldLeft(BigInt(1))((z, i) => (n - k + i) * i.modInverse(M) * z % M)\n\t\n\tpw.println(if (((x+y) % 3 != 0) || (2*y < x || 2*x < y)) 0 else cmb(nm, x - nm).toInt)\n\tpw.flush()\n}", "language": "Scala", "metadata": {"date": 1579444465, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02862.html", "problem_id": "p02862", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02862/input.txt", "sample_output_relpath": "derived/input_output/data/p02862/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02862/Scala/s384879857.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s384879857", "user_id": "u822029894"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.collection.mutable.ArrayBuffer\n\nobject 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 x, y = sc.nextInt\n\t\n\tval M = BigInt(1000000007)\n\tval nm = (x+y) / 3\n\t\n\tdef cmb(n: Int, k: Int): BigInt =\n\t\t(BigInt(1) to BigInt(k)).foldLeft(BigInt(1))((z, i) => (n - k + i) * i.modInverse(M) * z % M)\n\t\n\tpw.println(if (((x+y) % 3 != 0) || (2*y < x || 2*x < y)) 0 else cmb(nm, x - nm).toInt)\n\tpw.flush()\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.\n\nWhen the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).\n\nIn how many ways can the knight reach the square (X, Y)?\n\nFind the number of ways modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq X \\leq 10^6\n\n1 \\leq Y \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the number of ways for the knight to reach (X, Y) from (0, 0), modulo 10^9 + 7.\n\nSample Input 1\n\n3 3\n\nSample Output 1\n\n2\n\nThere are two ways: (0,0) \\to (1,2) \\to (3,3) and (0,0) \\to (2,1) \\to (3,3).\n\nSample Input 2\n\n2 2\n\nSample Output 2\n\n0\n\nThe knight cannot reach (2,2).\n\nSample Input 3\n\n999999 999999\n\nSample Output 3\n\n151840682\n\nPrint the number of ways modulo 10^9 + 7.", "sample_input": "3 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02862", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.\n\nWhen the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).\n\nIn how many ways can the knight reach the square (X, Y)?\n\nFind the number of ways modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq X \\leq 10^6\n\n1 \\leq Y \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the number of ways for the knight to reach (X, Y) from (0, 0), modulo 10^9 + 7.\n\nSample Input 1\n\n3 3\n\nSample Output 1\n\n2\n\nThere are two ways: (0,0) \\to (1,2) \\to (3,3) and (0,0) \\to (2,1) \\to (3,3).\n\nSample Input 2\n\n2 2\n\nSample Output 2\n\n0\n\nThe knight cannot reach (2,2).\n\nSample Input 3\n\n999999 999999\n\nSample Output 3\n\n151840682\n\nPrint the number of ways modulo 10^9 + 7.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 471, "cpu_time_ms": 1372, "memory_kb": 112984}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s206191803", "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 = 0\n while (i < N) {\n val nextT = (t + A(i)) min T\n dp(nextT)(i+1) = dp(nextT)(i+1) max (dp(t)(i) + B(i))\n dp(t)(i+1) = dp(t)(i+1) max dp(t)(i)\n dp(t+1)(i+1) = dp(t+1)(i+1) max dp(t)(i)\n i += 1\n }\n t += 1\n }\n\n println(dp(T)(N))\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1574039887, "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/s206191803.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s206191803", "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 = 0\n while (i < N) {\n val nextT = (t + A(i)) min T\n dp(nextT)(i+1) = dp(nextT)(i+1) max (dp(t)(i) + B(i))\n dp(t)(i+1) = dp(t)(i+1) max dp(t)(i)\n dp(t+1)(i+1) = dp(t+1)(i+1) max dp(t)(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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 629, "cpu_time_ms": 722, "memory_kb": 82820}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s977761515", "group_id": "codeNet:p02863", "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, T = in.next().toInt\n val A = new Array[Int](N+1)\n val B = new Array[Int](N+1)\n for (i <- 1 to N) {\n val a, b = in.next().toInt\n A(i) = a\n B(i) = b\n }\n\n // \n val dp = Array.fill[Int](2*T)(-1)\n dp(0) = 0\n\n for (k <- 1 to N) {\n val t = A(k)\n val score = B(k)\n\n if (T >= t) {\n for (i <- (T - t)*2 + 1 until 2*T by 2) {\n if(dp(i-1) != -1)\n dp(i) = Math.max(dp(i), dp(i-1) + score)\n }\n\n for (i <- (0 until (T - t)*2 + 1).reverse) {\n if(dp(i) != -1) {\n dp(i+2*t) = Math.max(dp(i+2*t), dp(i) + score)\n }\n }\n }\n else {\n for (i <- 1 until 2*T by 2) {\n if(dp(i-1) != -1)\n dp(i) = Math.max(dp(i), dp(i-1) + score)\n }\n }\n }\n\n// println(dp.deep)\n\n println(dp.max)\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": 1573961954, "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/s977761515.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s977761515", "user_id": "u098968285"}, "prompt_components": {"gold_output": "110\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, T = in.next().toInt\n val A = new Array[Int](N+1)\n val B = new Array[Int](N+1)\n for (i <- 1 to N) {\n val a, b = in.next().toInt\n A(i) = a\n B(i) = b\n }\n\n // \n val dp = Array.fill[Int](2*T)(-1)\n dp(0) = 0\n\n for (k <- 1 to N) {\n val t = A(k)\n val score = B(k)\n\n if (T >= t) {\n for (i <- (T - t)*2 + 1 until 2*T by 2) {\n if(dp(i-1) != -1)\n dp(i) = Math.max(dp(i), dp(i-1) + score)\n }\n\n for (i <- (0 until (T - t)*2 + 1).reverse) {\n if(dp(i) != -1) {\n dp(i+2*t) = Math.max(dp(i+2*t), dp(i) + score)\n }\n }\n }\n else {\n for (i <- 1 until 2*T by 2) {\n if(dp(i-1) != -1)\n dp(i) = Math.max(dp(i), dp(i-1) + score)\n }\n }\n }\n\n// println(dp.deep)\n\n println(dp.max)\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\nTakahashi is at an all-you-can-eat restaurant.\n\nThe restaurant offers N kinds of dishes. It takes A_i minutes to eat the i-th dish, whose deliciousness is B_i.\n\nThe restaurant has the following rules:\n\nYou can only order one dish at a time. The dish ordered will be immediately served and ready to eat.\n\nYou cannot order the same kind of dish more than once.\n\nUntil you finish eating the dish already served, you cannot order a new dish.\n\nAfter T-0.5 minutes from the first order, you can no longer place a new order, but you can continue eating the dish already served.\n\nLet Takahashi's happiness be the sum of the deliciousness of the dishes he eats in this restaurant.\n\nWhat is the maximum possible happiness achieved by making optimal choices?\n\nConstraints\n\n2 \\leq N \\leq 3000\n\n1 \\leq T \\leq 3000\n\n1 \\leq A_i \\leq 3000\n\n1 \\leq B_i \\leq 3000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the maximum possible happiness Takahashi can achieve.\n\nSample Input 1\n\n2 60\n10 10\n100 100\n\nSample Output 1\n\n110\n\nBy ordering the first and second dishes in this order, Takahashi's happiness will be 110.\n\nNote that, if we manage to order a dish in time, we can spend any amount of time to eat it.\n\nSample Input 2\n\n3 60\n10 10\n10 20\n10 30\n\nSample Output 2\n\n60\n\nTakahashi can eat all the dishes within 60 minutes.\n\nSample Input 3\n\n3 60\n30 10\n30 20\n30 30\n\nSample Output 3\n\n50\n\nBy ordering the second and third dishes in this order, Takahashi's happiness will be 50.\n\nWe cannot order three dishes, in whatever order we place them.\n\nSample Input 4\n\n10 100\n15 23\n20 18\n13 17\n24 12\n18 29\n19 27\n23 21\n18 20\n27 15\n22 25\n\nSample Output 4\n\n145", "sample_input": "2 60\n10 10\n100 100\n"}, "reference_outputs": ["110\n"], "source_document_id": "p02863", "source_text": "Score : 500 points\n\nProblem Statement\n\nTakahashi is at an all-you-can-eat restaurant.\n\nThe restaurant offers N kinds of dishes. It takes A_i minutes to eat the i-th dish, whose deliciousness is B_i.\n\nThe restaurant has the following rules:\n\nYou can only order one dish at a time. The dish ordered will be immediately served and ready to eat.\n\nYou cannot order the same kind of dish more than once.\n\nUntil you finish eating the dish already served, you cannot order a new dish.\n\nAfter T-0.5 minutes from the first order, you can no longer place a new order, but you can continue eating the dish already served.\n\nLet Takahashi's happiness be the sum of the deliciousness of the dishes he eats in this restaurant.\n\nWhat is the maximum possible happiness achieved by making optimal choices?\n\nConstraints\n\n2 \\leq N \\leq 3000\n\n1 \\leq T \\leq 3000\n\n1 \\leq A_i \\leq 3000\n\n1 \\leq B_i \\leq 3000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the maximum possible happiness Takahashi can achieve.\n\nSample Input 1\n\n2 60\n10 10\n100 100\n\nSample Output 1\n\n110\n\nBy ordering the first and second dishes in this order, Takahashi's happiness will be 110.\n\nNote that, if we manage to order a dish in time, we can spend any amount of time to eat it.\n\nSample Input 2\n\n3 60\n10 10\n10 20\n10 30\n\nSample Output 2\n\n60\n\nTakahashi can eat all the dishes within 60 minutes.\n\nSample Input 3\n\n3 60\n30 10\n30 20\n30 30\n\nSample Output 3\n\n50\n\nBy ordering the second and third dishes in this order, Takahashi's happiness will be 50.\n\nWe cannot order three dishes, in whatever order we place them.\n\nSample Input 4\n\n10 100\n15 23\n20 18\n13 17\n24 12\n18 29\n19 27\n23 21\n18 20\n27 15\n22 25\n\nSample Output 4\n\n145", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1545, "cpu_time_ms": 520, "memory_kb": 29848}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s221122282", "group_id": "codeNet:p02864", "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 val n, k = Scanner.nextInt()\n val data = Array.fill(n)(Scanner.nextLong())\n val dp = Array.fill[Long](n + 1, n + 1)(-1)\n\n def pure(i: Int, k: Int, x: Long): Long = {\n val d = dp(i)(k)\n if (d >= 0) d else {\n val r =\n if (i == 0) {\n 0\n } else if (i == k) {\n 0\n } else if (k > 0) {\n val x1 = data(i - 1)\n val count = Math.max(0, x1 - x)\n val leave = count + pure(i - 1, k, x1)\n val erase = pure(i - 1, k - 1, x)\n Math.min(erase, leave)\n } else {\n val x1 = data(i - 1)\n val count = Math.max(0, x1 - x)\n val leave = count + pure(i - 1, k, x1)\n leave\n }\n dp(i)(k) = r\n r\n }\n }\n println(pure(n, k, 0))\n}", "language": "Scala", "metadata": {"date": 1574368050, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02864.html", "problem_id": "p02864", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02864/input.txt", "sample_output_relpath": "derived/input_output/data/p02864/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02864/Scala/s221122282.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s221122282", "user_id": "u817495853"}, "prompt_components": {"gold_output": "3\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 val n, k = Scanner.nextInt()\n val data = Array.fill(n)(Scanner.nextLong())\n val dp = Array.fill[Long](n + 1, n + 1)(-1)\n\n def pure(i: Int, k: Int, x: Long): Long = {\n val d = dp(i)(k)\n if (d >= 0) d else {\n val r =\n if (i == 0) {\n 0\n } else if (i == k) {\n 0\n } else if (k > 0) {\n val x1 = data(i - 1)\n val count = Math.max(0, x1 - x)\n val leave = count + pure(i - 1, k, x1)\n val erase = pure(i - 1, k - 1, x)\n Math.min(erase, leave)\n } else {\n val x1 = data(i - 1)\n val count = Math.max(0, x1 - x)\n val leave = count + pure(i - 1, k, x1)\n leave\n }\n dp(i)(k) = r\n r\n }\n }\n println(pure(n, k, 0))\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe will create an artwork by painting black some squares in a white square grid with 10^9 rows and N columns.\n\nThe current plan is as follows: for the i-th column from the left, we will paint the H_i bottommost squares and will not paint the other squares in that column.\n\nBefore starting to work, you can choose at most K columns (possibly zero) and change the values of H_i for these columns to any integers of your choice between 0 and 10^9 (inclusive).\n\nDifferent values can be chosen for different columns.\n\nThen, you will create the modified artwork by repeating the following operation:\n\nChoose one or more consecutive squares in one row and paint them black. (Squares already painted black can be painted again, but squares not to be painted according to the modified plan should not be painted.)\n\nFind the minimum number of times you need to perform this operation.\n\nConstraints\n\n1 \\leq N \\leq 300\n\n0 \\leq K \\leq N\n\n0 \\leq H_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 1\n2 3 4 1\n\nSample Output 1\n\n3\n\nFor example, by changing the value of H_3 to 2, you can create the modified artwork by the following three operations:\n\nPaint black the 1-st through 4-th squares from the left in the 1-st row from the bottom.\n\nPaint black the 1-st through 3-rd squares from the left in the 2-nd row from the bottom.\n\nPaint black the 2-nd square from the left in the 3-rd row from the bottom.\n\nSample Input 2\n\n6 2\n8 6 9 1 2 1\n\nSample Output 2\n\n7\n\nSample Input 3\n\n10 0\n1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000\n\nSample Output 3\n\n4999999996", "sample_input": "4 1\n2 3 4 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02864", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe will create an artwork by painting black some squares in a white square grid with 10^9 rows and N columns.\n\nThe current plan is as follows: for the i-th column from the left, we will paint the H_i bottommost squares and will not paint the other squares in that column.\n\nBefore starting to work, you can choose at most K columns (possibly zero) and change the values of H_i for these columns to any integers of your choice between 0 and 10^9 (inclusive).\n\nDifferent values can be chosen for different columns.\n\nThen, you will create the modified artwork by repeating the following operation:\n\nChoose one or more consecutive squares in one row and paint them black. (Squares already painted black can be painted again, but squares not to be painted according to the modified plan should not be painted.)\n\nFind the minimum number of times you need to perform this operation.\n\nConstraints\n\n1 \\leq N \\leq 300\n\n0 \\leq K \\leq N\n\n0 \\leq H_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 1\n2 3 4 1\n\nSample Output 1\n\n3\n\nFor example, by changing the value of H_3 to 2, you can create the modified artwork by the following three operations:\n\nPaint black the 1-st through 4-th squares from the left in the 1-st row from the bottom.\n\nPaint black the 1-st through 3-rd squares from the left in the 2-nd row from the bottom.\n\nPaint black the 2-nd square from the left in the 3-rd row from the bottom.\n\nSample Input 2\n\n6 2\n8 6 9 1 2 1\n\nSample Output 2\n\n7\n\nSample Input 3\n\n10 0\n1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000\n\nSample Output 3\n\n4999999996", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3781, "cpu_time_ms": 381, "memory_kb": 27788}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s449532385", "group_id": "codeNet:p02866", "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 println(\n if (A(0) == 0 && A.count(_ == 0) == 1) if (A.length != 1)\n A.groupBy(identity)\n .toArray\n .sortBy(x => x._1)\n .sliding(2)\n .map(x => (x(0), x(1)))\n .map { case (x, y) => if (x._1 + 1 == y._1) PowMod.powMod(x._2.length, y._2.length, 998244353L) else 0L }\n .reduceLeft((x, y) => (x * y) % 998244353L)\n else 1 else 0\n )\n }\n\n def recursive(a: Int): Int = {\n if (a == 0) 0 else recursive(a / 10) + a % 10\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 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": 1576556594, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02866.html", "problem_id": "p02866", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02866/input.txt", "sample_output_relpath": "derived/input_output/data/p02866/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02866/Scala/s449532385.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s449532385", "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 = Array.fill(sc.nextInt())(sc.nextLong())\n println(\n if (A(0) == 0 && A.count(_ == 0) == 1) if (A.length != 1)\n A.groupBy(identity)\n .toArray\n .sortBy(x => x._1)\n .sliding(2)\n .map(x => (x(0), x(1)))\n .map { case (x, y) => if (x._1 + 1 == y._1) PowMod.powMod(x._2.length, y._2.length, 998244353L) else 0L }\n .reduceLeft((x, y) => (x * y) % 998244353L)\n else 1 else 0\n )\n }\n\n def recursive(a: Int): Int = {\n if (a == 0) 0 else recursive(a / 10) + a % 10\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 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 : 300 points\n\nProblem Statement\n\nGiven is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition:\n\nFor every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.\n\nNotes\n\nA tree of N vertices is a connected undirected graph with N vertices and N-1 edges, and the distance between two vertices are the number of edges in the shortest path between them.\n\nTwo trees are considered different if and only if there are two vertices x and y such that there is an edge between x and y in one of those trees and not in the other.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq D_i \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_1 D_2 ... D_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4\n0 1 1 2\n\nSample Output 1\n\n2\n\nFor example, a tree with edges (1,2), (1,3), and (2,4) satisfies the condition.\n\nSample Input 2\n\n4\n1 1 1 1\n\nSample Output 2\n\n0\n\nSample Input 3\n\n7\n0 3 2 1 2 2 1\n\nSample Output 3\n\n24", "sample_input": "4\n0 1 1 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02866", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition:\n\nFor every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.\n\nNotes\n\nA tree of N vertices is a connected undirected graph with N vertices and N-1 edges, and the distance between two vertices are the number of edges in the shortest path between them.\n\nTwo trees are considered different if and only if there are two vertices x and y such that there is an edge between x and y in one of those trees and not in the other.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq D_i \\leq N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD_1 D_2 ... D_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4\n0 1 1 2\n\nSample Output 1\n\n2\n\nFor example, a tree with edges (1,2), (1,3), and (2,4) satisfies the condition.\n\nSample Input 2\n\n4\n1 1 1 1\n\nSample Output 2\n\n0\n\nSample Input 3\n\n7\n0 3 2 1 2 2 1\n\nSample Output 3\n\n24", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 7707, "cpu_time_ms": 1971, "memory_kb": 136200}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s237971094", "group_id": "codeNet:p02867", "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 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 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\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 private def merge(node: Int, rt: Int): Int = {\n par(node) = rt\n rank(rt) += rank(node)\n rt\n }\n\n def unite(x: Int, y: Int): Boolean = {\n val x1 = find(x)\n val y1 = find(y)\n if (x1 == y1) false\n else {\n if (rank(x1) < rank(y1))\n merge(x1, y1)\n else\n merge(y1, x1)\n\n true\n }\n }\n\n /**\n * xを解決する必要がないときは直にrankをみる\n */\n def cntNodes(x: Int): Int = rank(find(x))\n\n def countDisjointSets(): Int = {\n var cnt = 0\n REP(n) { i =>\n // 同じかどうかだけを見るので、find使ってどの集合に属するかを解決する必要がない\n if (par(i) == i) cnt += 1\n }\n cnt\n }\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 import Workspace._\n\n // toIntとか+7とかするならvalにしろ\n final private[this] val MOD = 1000000007\n\n def solve(): Unit = {\n val n = ni()\n val A, B = na(n)\n val Sa_withIx = A.zipWithIndex.sorted\n val Sa = Sa_withIx.map(_._1)\n val Sb = B.sorted\n val rev = Sa_withIx.map(_._2)\n val P = Array.ofDim[Int](n)\n REP(n) { i =>\n P(rev(i)) = i\n }\n\n debug(P)\n\n def test: Boolean = {\n REP(n) { i =>\n if (Sa(i) > Sb(i)) return false\n }\n\n val uf = new UnionFind(n)\n REP(n) { i =>\n uf.unite(i, P(i))\n }\n if (uf.countDisjointSets() > 1) return true\n\n REP(n - 1) { i =>\n if (Sa(i + 1) <= Sb(i)) return true\n }\n\n false\n }\n\n if (test) out.println(\"Yes\")\n else out.println(\"No\")\n }\n}", "language": "Scala", "metadata": {"date": 1573528774, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02867.html", "problem_id": "p02867", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02867/input.txt", "sample_output_relpath": "derived/input_output/data/p02867/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02867/Scala/s237971094.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s237971094", "user_id": "u460609472"}, "prompt_components": {"gold_output": "Yes\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 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 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\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 private def merge(node: Int, rt: Int): Int = {\n par(node) = rt\n rank(rt) += rank(node)\n rt\n }\n\n def unite(x: Int, y: Int): Boolean = {\n val x1 = find(x)\n val y1 = find(y)\n if (x1 == y1) false\n else {\n if (rank(x1) < rank(y1))\n merge(x1, y1)\n else\n merge(y1, x1)\n\n true\n }\n }\n\n /**\n * xを解決する必要がないときは直にrankをみる\n */\n def cntNodes(x: Int): Int = rank(find(x))\n\n def countDisjointSets(): Int = {\n var cnt = 0\n REP(n) { i =>\n // 同じかどうかだけを見るので、find使ってどの集合に属するかを解決する必要がない\n if (par(i) == i) cnt += 1\n }\n cnt\n }\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 import Workspace._\n\n // toIntとか+7とかするならvalにしろ\n final private[this] val MOD = 1000000007\n\n def solve(): Unit = {\n val n = ni()\n val A, B = na(n)\n val Sa_withIx = A.zipWithIndex.sorted\n val Sa = Sa_withIx.map(_._1)\n val Sb = B.sorted\n val rev = Sa_withIx.map(_._2)\n val P = Array.ofDim[Int](n)\n REP(n) { i =>\n P(rev(i)) = i\n }\n\n debug(P)\n\n def test: Boolean = {\n REP(n) { i =>\n if (Sa(i) > Sb(i)) return false\n }\n\n val uf = new UnionFind(n)\n REP(n) { i =>\n uf.unite(i, P(i))\n }\n if (uf.countDisjointSets() > 1) return true\n\n REP(n - 1) { i =>\n if (Sa(i + 1) <= Sb(i)) return true\n }\n\n false\n }\n\n if (test) out.println(\"Yes\")\n else out.println(\"No\")\n }\n}", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven are two integer sequences of N elements each: A_1,...,A_N and B_1,...,B_N.\nDetermine if it is possible to do the following operation at most N-2 times (possibly zero) so that, for every integer i from 1 to N, A_i \\leq B_i holds:\n\nChoose two distinct integers x and y between 1 and N (inclusive), and swap the values of A_x and A_y.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq A_i,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\nB_1 B_2 ... B_N\n\nOutput\n\nIf the objective is achievable, print Yes; if it is not, print No.\n\nSample Input 1\n\n3\n1 3 2\n1 2 3\n\nSample Output 1\n\nYes\n\nWe should swap the values of A_2 and A_3.\n\nSample Input 2\n\n3\n1 2 3\n2 2 2\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n6\n3 1 2 6 3 4\n2 2 8 3 4 3\n\nSample Output 3\n\nYes", "sample_input": "3\n1 3 2\n1 2 3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02867", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven are two integer sequences of N elements each: A_1,...,A_N and B_1,...,B_N.\nDetermine if it is possible to do the following operation at most N-2 times (possibly zero) so that, for every integer i from 1 to N, A_i \\leq B_i holds:\n\nChoose two distinct integers x and y between 1 and N (inclusive), and swap the values of A_x and A_y.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq A_i,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\nB_1 B_2 ... B_N\n\nOutput\n\nIf the objective is achievable, print Yes; if it is not, print No.\n\nSample Input 1\n\n3\n1 3 2\n1 2 3\n\nSample Output 1\n\nYes\n\nWe should swap the values of A_2 and A_3.\n\nSample Input 2\n\n3\n1 2 3\n2 2 2\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n6\n3 1 2 6 3 4\n2 2 8 3 4 3\n\nSample Output 3\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5957, "cpu_time_ms": 1308, "memory_kb": 71988}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s232414030", "group_id": "codeNet:p02880", "input_text": "\nobject Main extends App {\n\n val n = scala.io.StdIn.readInt()\n\n\n def solve() = {\n val list: Seq[Double] = (1 to 9).map(_.toDouble)\n val divisions = (1 to 9).map { num => n.toDouble / num }\n val isKuKu = divisions.exists(list.contains)\n if(isKuKu) \"Yes\" else \"No\"\n }\n\n println(solve)\n\n}\n", "language": "Scala", "metadata": {"date": 1572490204, "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/s232414030.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s232414030", "user_id": "u947008426"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "\nobject Main extends App {\n\n val n = scala.io.StdIn.readInt()\n\n\n def solve() = {\n val list: Seq[Double] = (1 to 9).map(_.toDouble)\n val divisions = (1 to 9).map { num => n.toDouble / num }\n val isKuKu = divisions.exists(list.contains)\n if(isKuKu) \"Yes\" else \"No\"\n }\n\n println(solve)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 303, "cpu_time_ms": 322, "memory_kb": 27456}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s167342379", "group_id": "codeNet:p02881", "input_text": "import scala.io.StdIn._\n\nobject Main extends App {\n def div(n: Long, d: Int, divs: List[Long]): List[Long] = {\n if (d > 1000000) {\n (if (n == 1) divs else n :: divs)\n } else {\n (n % d) match {\n case 0 => div(n / d, d, d :: divs)\n case _ => div(n, d + 1, divs)\n }\n }\n }\n\n def mult(l: Long, r: Long, divs: List[Long]): (Long, Long) = {\n divs match {\n case Nil => (l, r)\n case x :: xs => if (l < r) mult(l * x, r, xs) else mult(l, r * x, xs)\n }\n }\n\n val (l, r) = mult(1, 1, div(readLong, 2, Nil))\n println(l + r - 2)\n}", "language": "Scala", "metadata": {"date": 1572276146, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02881.html", "problem_id": "p02881", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02881/input.txt", "sample_output_relpath": "derived/input_output/data/p02881/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02881/Scala/s167342379.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s167342379", "user_id": "u132324749"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main extends App {\n def div(n: Long, d: Int, divs: List[Long]): List[Long] = {\n if (d > 1000000) {\n (if (n == 1) divs else n :: divs)\n } else {\n (n % d) match {\n case 0 => div(n / d, d, d :: divs)\n case _ => div(n, d + 1, divs)\n }\n }\n }\n\n def mult(l: Long, r: Long, divs: List[Long]): (Long, Long) = {\n divs match {\n case Nil => (l, r)\n case x :: xs => if (l < r) mult(l * x, r, xs) else mult(l, r * x, xs)\n }\n }\n\n val (l, r) = mult(1, 1, div(readLong, 2, Nil))\n println(l + r - 2)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi is standing on a multiplication table with infinitely many rows and columns.\n\nThe square (i,j) contains the integer i \\times j. Initially, Takahashi is standing at (1,1).\n\nIn one move, he can move from (i,j) to either (i+1,j) or (i,j+1).\n\nGiven an integer N, find the minimum number of moves needed to reach a square that contains N.\n\nConstraints\n\n2 \\leq N \\leq 10^{12}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum number of moves needed to reach a square that contains the integer N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n5\n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10 in less than five moves.\n\nSample Input 2\n\n50\n\nSample Output 2\n\n13\n\n(5, 10) can be reached in 13 moves.\n\nSample Input 3\n\n10000000019\n\nSample Output 3\n\n10000000018\n\nBoth input and output may be enormous.", "sample_input": "10\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02881", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi is standing on a multiplication table with infinitely many rows and columns.\n\nThe square (i,j) contains the integer i \\times j. Initially, Takahashi is standing at (1,1).\n\nIn one move, he can move from (i,j) to either (i+1,j) or (i,j+1).\n\nGiven an integer N, find the minimum number of moves needed to reach a square that contains N.\n\nConstraints\n\n2 \\leq N \\leq 10^{12}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum number of moves needed to reach a square that contains the integer N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n5\n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10 in less than five moves.\n\nSample Input 2\n\n50\n\nSample Output 2\n\n13\n\n(5, 10) can be reached in 13 moves.\n\nSample Input 3\n\n10000000019\n\nSample Output 3\n\n10000000018\n\nBoth input and output may be enormous.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 575, "cpu_time_ms": 341, "memory_kb": 25540}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s890510579", "group_id": "codeNet:p02881", "input_text": "object Main {\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n var n = sc.nextLong\n var norg = n\n var ns = new Array[Int](0)\n var a, b = 1L\n for(i <- 2 to Math.sqrt(n).toInt+1 if n%i == 0) {\n while(n%i ==0) {\n n = n / i\n ns :+= i\n }\n }\n if (n == norg) {\n println(n-1)\n System.exit(0)\n }\n a = n\n ns.reverse.foreach { v =>\n if (a < b) {\n a = a*v\n } else {\n b = b*v\n }\n }\n println(ns.deep)\n //println(a)\n //println(b)\n println((a-1)+(b-1))\n }\n}\n", "language": "Scala", "metadata": {"date": 1572229469, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02881.html", "problem_id": "p02881", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02881/input.txt", "sample_output_relpath": "derived/input_output/data/p02881/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02881/Scala/s890510579.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s890510579", "user_id": "u894128391"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "object Main {\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n var n = sc.nextLong\n var norg = n\n var ns = new Array[Int](0)\n var a, b = 1L\n for(i <- 2 to Math.sqrt(n).toInt+1 if n%i == 0) {\n while(n%i ==0) {\n n = n / i\n ns :+= i\n }\n }\n if (n == norg) {\n println(n-1)\n System.exit(0)\n }\n a = n\n ns.reverse.foreach { v =>\n if (a < b) {\n a = a*v\n } else {\n b = b*v\n }\n }\n println(ns.deep)\n //println(a)\n //println(b)\n println((a-1)+(b-1))\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi is standing on a multiplication table with infinitely many rows and columns.\n\nThe square (i,j) contains the integer i \\times j. Initially, Takahashi is standing at (1,1).\n\nIn one move, he can move from (i,j) to either (i+1,j) or (i,j+1).\n\nGiven an integer N, find the minimum number of moves needed to reach a square that contains N.\n\nConstraints\n\n2 \\leq N \\leq 10^{12}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum number of moves needed to reach a square that contains the integer N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n5\n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10 in less than five moves.\n\nSample Input 2\n\n50\n\nSample Output 2\n\n13\n\n(5, 10) can be reached in 13 moves.\n\nSample Input 3\n\n10000000019\n\nSample Output 3\n\n10000000018\n\nBoth input and output may be enormous.", "sample_input": "10\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02881", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi is standing on a multiplication table with infinitely many rows and columns.\n\nThe square (i,j) contains the integer i \\times j. Initially, Takahashi is standing at (1,1).\n\nIn one move, he can move from (i,j) to either (i+1,j) or (i,j+1).\n\nGiven an integer N, find the minimum number of moves needed to reach a square that contains N.\n\nConstraints\n\n2 \\leq N \\leq 10^{12}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum number of moves needed to reach a square that contains the integer N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n5\n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10 in less than five moves.\n\nSample Input 2\n\n50\n\nSample Output 2\n\n13\n\n(5, 10) can be reached in 13 moves.\n\nSample Input 3\n\n10000000019\n\nSample Output 3\n\n10000000018\n\nBoth input and output may be enormous.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 584, "cpu_time_ms": 423, "memory_kb": 36296}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s823667817", "group_id": "codeNet:p02882", "input_text": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val a, b, x = sc.nextDouble()\n\n val h = x / (a * a)\n if (h >= b / 2) {\n println(Math.atan2(b - h, a / 2) * 180 / Math.PI)\n } else {\n println(Math.atan2(b, 2 * x / (a * b)) * 180 / Math.PI)\n }\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1573885127, "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/s823667817.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s823667817", "user_id": "u891387249"}, "prompt_components": {"gold_output": "45.0000000000\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 a, b, x = sc.nextDouble()\n\n val h = x / (a * a)\n if (h >= b / 2) {\n println(Math.atan2(b - h, a / 2) * 180 / Math.PI)\n } else {\n println(Math.atan2(b, 2 * x / (a * b)) * 180 / Math.PI)\n }\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 353, "memory_kb": 25424}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s651441182", "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.nextLong()).sorted\n val F = Array.fill(N)(sc.nextLong()).sorted(Ordering.Long.reverse)\n val AF: Array[(Long, Long)] = 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) / 2L\n val _K = AF.foldLeft(0L) { case (r, (a, f)) =>\n r + (a - X / f)\n }\n if (_K <= K) binarySearch(l, X)\n else binarySearch(X, r)\n } else r\n\n println(binarySearch(-1, MAX))\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1574315148, "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/s651441182.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s651441182", "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.nextLong()).sorted\n val F = Array.fill(N)(sc.nextLong()).sorted(Ordering.Long.reverse)\n val AF: Array[(Long, Long)] = 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) / 2L\n val _K = AF.foldLeft(0L) { case (r, (a, f)) =>\n r + (a - X / f)\n }\n if (_K <= K) binarySearch(l, X)\n else binarySearch(X, r)\n } else r\n\n println(binarySearch(-1, MAX))\n }\n\n}\n", "problem_context": "Score: 500 points\n\nProblem Statement\n\nTakahashi will take part in an eating contest. Teams of N members will compete in this contest, and Takahashi's team consists of N players numbered 1 through N from youngest to oldest. The consumption coefficient of Member i is A_i.\n\nIn the contest, N foods numbered 1 through N will be presented, and the difficulty of Food i is F_i. The details of the contest are as follows:\n\nA team should assign one member to each food, and should not assign the same member to multiple foods.\n\nIt will take x \\times y seconds for a member to finish the food, where x is the consumption coefficient of the member and y is the difficulty of the dish.\n\nThe score of a team is the longest time it takes for an individual member to finish the food.\n\nBefore the contest, Takahashi's team decided to do some training. In one set of training, a member can reduce his/her consumption coefficient by 1, as long as it does not go below 0. However, for financial reasons, the N members can do at most K sets of training in total.\n\nWhat is the minimum possible score of the team, achieved by choosing the amounts of members' training and allocating the dishes optimally?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq K \\leq 10^{18}\n\n1 \\leq A_i \\leq 10^6\\ (1 \\leq i \\leq N)\n\n1 \\leq F_i \\leq 10^6\\ (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\nF_1 F_2 ... F_N\n\nOutput\n\nPrint the minimum possible score of the team.\n\nSample Input 1\n\n3 5\n4 2 1\n2 3 1\n\nSample Output 1\n\n2\n\nThey can achieve the score of 2, as follows:\n\nMember 1 does 4 sets of training and eats Food 2 in (4-4) \\times 3 = 0 seconds.\n\nMember 2 does 1 set of training and eats Food 3 in (2-1) \\times 1 = 1 second.\n\nMember 3 does 0 sets of training and eats Food 1 in (1-0) \\times 2 = 2 seconds.\n\nThey cannot achieve a score of less than 2, so the answer is 2.\n\nSample Input 2\n\n3 8\n4 2 1\n2 3 1\n\nSample Output 2\n\n0\n\nThey can choose not to do exactly K sets of training.\n\nSample Input 3\n\n11 14\n3 1 4 1 5 9 2 6 5 3 5\n8 9 7 9 3 2 3 8 4 6 2\n\nSample Output 3\n\n12", "sample_input": "3 5\n4 2 1\n2 3 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02883", "source_text": "Score: 500 points\n\nProblem Statement\n\nTakahashi will take part in an eating contest. Teams of N members will compete in this contest, and Takahashi's team consists of N players numbered 1 through N from youngest to oldest. The consumption coefficient of Member i is A_i.\n\nIn the contest, N foods numbered 1 through N will be presented, and the difficulty of Food i is F_i. The details of the contest are as follows:\n\nA team should assign one member to each food, and should not assign the same member to multiple foods.\n\nIt will take x \\times y seconds for a member to finish the food, where x is the consumption coefficient of the member and y is the difficulty of the dish.\n\nThe score of a team is the longest time it takes for an individual member to finish the food.\n\nBefore the contest, Takahashi's team decided to do some training. In one set of training, a member can reduce his/her consumption coefficient by 1, as long as it does not go below 0. However, for financial reasons, the N members can do at most K sets of training in total.\n\nWhat is the minimum possible score of the team, achieved by choosing the amounts of members' training and allocating the dishes optimally?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq K \\leq 10^{18}\n\n1 \\leq A_i \\leq 10^6\\ (1 \\leq i \\leq N)\n\n1 \\leq F_i \\leq 10^6\\ (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\nF_1 F_2 ... F_N\n\nOutput\n\nPrint the minimum possible score of the team.\n\nSample Input 1\n\n3 5\n4 2 1\n2 3 1\n\nSample Output 1\n\n2\n\nThey can achieve the score of 2, as follows:\n\nMember 1 does 4 sets of training and eats Food 2 in (4-4) \\times 3 = 0 seconds.\n\nMember 2 does 1 set of training and eats Food 3 in (2-1) \\times 1 = 1 second.\n\nMember 3 does 0 sets of training and eats Food 1 in (1-0) \\times 2 = 2 seconds.\n\nThey cannot achieve a score of less than 2, so the answer is 2.\n\nSample Input 2\n\n3 8\n4 2 1\n2 3 1\n\nSample Output 2\n\n0\n\nThey can choose not to do exactly K sets of training.\n\nSample Input 3\n\n11 14\n3 1 4 1 5 9 2 6 5 3 5\n8 9 7 9 3 2 3 8 4 6 2\n\nSample Output 3\n\n12", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 671, "cpu_time_ms": 1874, "memory_kb": 148380}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s374333850", "group_id": "codeNet:p02883", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val N, K = sc.nextInt\n val As = Seq.fill(N)(sc.nextInt)\n val Fs = Seq.fill(N)(sc.nextInt)\n val pq = collection.mutable.PriorityQueue[(Int, Int)]()(Ordering.by{t => t._1 * t._2})\n val as = As.sorted\n val fs = Fs.sorted(Ordering[Int].reverse)\n as.zip(fs).foreach(pq.enqueue(_))\n for(i <- 1 to K) {\n val t = pq.dequeue\n pq.enqueue((t._1 - 1, t._2))\n }\n val t = pq.dequeue\n println(t._1 * t._2)\n}", "language": "Scala", "metadata": {"date": 1572445703, "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/s374333850.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s374333850", "user_id": "u304198114"}, "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.nextInt\n val As = Seq.fill(N)(sc.nextInt)\n val Fs = Seq.fill(N)(sc.nextInt)\n val pq = collection.mutable.PriorityQueue[(Int, Int)]()(Ordering.by{t => t._1 * t._2})\n val as = As.sorted\n val fs = Fs.sorted(Ordering[Int].reverse)\n as.zip(fs).foreach(pq.enqueue(_))\n for(i <- 1 to K) {\n val t = pq.dequeue\n pq.enqueue((t._1 - 1, t._2))\n }\n val t = pq.dequeue\n println(t._1 * t._2)\n}", "problem_context": "Score: 500 points\n\nProblem Statement\n\nTakahashi will take part in an eating contest. Teams of N members will compete in this contest, and Takahashi's team consists of N players numbered 1 through N from youngest to oldest. The consumption coefficient of Member i is A_i.\n\nIn the contest, N foods numbered 1 through N will be presented, and the difficulty of Food i is F_i. The details of the contest are as follows:\n\nA team should assign one member to each food, and should not assign the same member to multiple foods.\n\nIt will take x \\times y seconds for a member to finish the food, where x is the consumption coefficient of the member and y is the difficulty of the dish.\n\nThe score of a team is the longest time it takes for an individual member to finish the food.\n\nBefore the contest, Takahashi's team decided to do some training. In one set of training, a member can reduce his/her consumption coefficient by 1, as long as it does not go below 0. However, for financial reasons, the N members can do at most K sets of training in total.\n\nWhat is the minimum possible score of the team, achieved by choosing the amounts of members' training and allocating the dishes optimally?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq K \\leq 10^{18}\n\n1 \\leq A_i \\leq 10^6\\ (1 \\leq i \\leq N)\n\n1 \\leq F_i \\leq 10^6\\ (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\nF_1 F_2 ... F_N\n\nOutput\n\nPrint the minimum possible score of the team.\n\nSample Input 1\n\n3 5\n4 2 1\n2 3 1\n\nSample Output 1\n\n2\n\nThey can achieve the score of 2, as follows:\n\nMember 1 does 4 sets of training and eats Food 2 in (4-4) \\times 3 = 0 seconds.\n\nMember 2 does 1 set of training and eats Food 3 in (2-1) \\times 1 = 1 second.\n\nMember 3 does 0 sets of training and eats Food 1 in (1-0) \\times 2 = 2 seconds.\n\nThey cannot achieve a score of less than 2, so the answer is 2.\n\nSample Input 2\n\n3 8\n4 2 1\n2 3 1\n\nSample Output 2\n\n0\n\nThey can choose not to do exactly K sets of training.\n\nSample Input 3\n\n11 14\n3 1 4 1 5 9 2 6 5 3 5\n8 9 7 9 3 2 3 8 4 6 2\n\nSample Output 3\n\n12", "sample_input": "3 5\n4 2 1\n2 3 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02883", "source_text": "Score: 500 points\n\nProblem Statement\n\nTakahashi will take part in an eating contest. Teams of N members will compete in this contest, and Takahashi's team consists of N players numbered 1 through N from youngest to oldest. The consumption coefficient of Member i is A_i.\n\nIn the contest, N foods numbered 1 through N will be presented, and the difficulty of Food i is F_i. The details of the contest are as follows:\n\nA team should assign one member to each food, and should not assign the same member to multiple foods.\n\nIt will take x \\times y seconds for a member to finish the food, where x is the consumption coefficient of the member and y is the difficulty of the dish.\n\nThe score of a team is the longest time it takes for an individual member to finish the food.\n\nBefore the contest, Takahashi's team decided to do some training. In one set of training, a member can reduce his/her consumption coefficient by 1, as long as it does not go below 0. However, for financial reasons, the N members can do at most K sets of training in total.\n\nWhat is the minimum possible score of the team, achieved by choosing the amounts of members' training and allocating the dishes optimally?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq K \\leq 10^{18}\n\n1 \\leq A_i \\leq 10^6\\ (1 \\leq i \\leq N)\n\n1 \\leq F_i \\leq 10^6\\ (1 \\leq i \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\nF_1 F_2 ... F_N\n\nOutput\n\nPrint the minimum possible score of the team.\n\nSample Input 1\n\n3 5\n4 2 1\n2 3 1\n\nSample Output 1\n\n2\n\nThey can achieve the score of 2, as follows:\n\nMember 1 does 4 sets of training and eats Food 2 in (4-4) \\times 3 = 0 seconds.\n\nMember 2 does 1 set of training and eats Food 3 in (2-1) \\times 1 = 1 second.\n\nMember 3 does 0 sets of training and eats Food 1 in (1-0) \\times 2 = 2 seconds.\n\nThey cannot achieve a score of less than 2, so the answer is 2.\n\nSample Input 2\n\n3 8\n4 2 1\n2 3 1\n\nSample Output 2\n\n0\n\nThey can choose not to do exactly K sets of training.\n\nSample Input 3\n\n11 14\n3 1 4 1 5 9 2 6 5 3 5\n8 9 7 9 3 2 3 8 4 6 2\n\nSample Output 3\n\n12", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 480, "cpu_time_ms": 2111, "memory_kb": 156396}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s063120423", "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).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": 1586227243, "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/s063120423.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s063120423", "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).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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1294, "cpu_time_ms": 2111, "memory_kb": 122664}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s357295978", "group_id": "codeNet:p02885", "input_text": "object Main extends App {\n val input = scala.io.StdIn.readLine.split(\" \").map(_.toInt).toSeq\n val A = input(0)\n val B = input(1)\n\n val answer = A - B * 2 match {\n case n if n < 0 => 0\n case n => n\n }\n\n println(answer)\n}", "language": "Scala", "metadata": {"date": 1585606010, "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/s357295978.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s357295978", "user_id": "u102400818"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "object Main extends App {\n val input = scala.io.StdIn.readLine.split(\" \").map(_.toInt).toSeq\n val A = input(0)\n val B = input(1)\n\n val answer = A - B * 2 match {\n case n if n < 0 => 0\n case n => n\n }\n\n println(answer)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThe window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.)\n\nWe will close the window so as to minimize the total horizontal length of the uncovered part of the window.\nFind the total horizontal length of the uncovered parts of the window then.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\leq B \\leq 100\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the total horizontal length of the uncovered parts of the window.\n\nSample Input 1\n\n12 4\n\nSample Output 1\n\n4\n\nWe have a window with a horizontal length of 12, and two curtains, each of length 4, that cover both ends of the window, for example. The uncovered part has a horizontal length of 4.\n\nSample Input 2\n\n20 15\n\nSample Output 2\n\n0\n\nIf the window is completely covered, print 0.\n\nSample Input 3\n\n20 30\n\nSample Output 3\n\n0\n\nEach curtain may be longer than the window.", "sample_input": "12 4\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02885", "source_text": "Score : 100 points\n\nProblem Statement\n\nThe window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.)\n\nWe will close the window so as to minimize the total horizontal length of the uncovered part of the window.\nFind the total horizontal length of the uncovered parts of the window then.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\leq B \\leq 100\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the total horizontal length of the uncovered parts of the window.\n\nSample Input 1\n\n12 4\n\nSample Output 1\n\n4\n\nWe have a window with a horizontal length of 12, and two curtains, each of length 4, that cover both ends of the window, for example. The uncovered part has a horizontal length of 4.\n\nSample Input 2\n\n20 15\n\nSample Output 2\n\n0\n\nIf the window is completely covered, print 0.\n\nSample Input 3\n\n20 30\n\nSample Output 3\n\n0\n\nEach curtain may be longer than the window.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 247, "cpu_time_ms": 349, "memory_kb": 25512}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s622235269", "group_id": "codeNet:p02885", "input_text": "import scala.io.StdIn._\nobject Main extends App {\n println(\n readLine.split(\" \").map(_.toInt).reduce((a, b) => math.max(0, a - b * 2))\n )\n}\n", "language": "Scala", "metadata": {"date": 1581110897, "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/s622235269.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s622235269", "user_id": "u518641666"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import scala.io.StdIn._\nobject Main extends App {\n println(\n readLine.split(\" \").map(_.toInt).reduce((a, b) => math.max(0, a - b * 2))\n )\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 325, "memory_kb": 27332}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s131690376", "group_id": "codeNet:p02886", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n println(\n List\n .fill(sc.nextInt())(sc.nextInt())\n .tails\n .toList\n .init\n .map { case x :: xs => x * xs.sum }\n .sum\n )\n}\n", "language": "Scala", "metadata": {"date": 1596593064, "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/s131690376.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s131690376", "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 println(\n List\n .fill(sc.nextInt())(sc.nextInt())\n .tails\n .toList\n .init\n .map { case x :: xs => x * xs.sum }\n .sum\n )\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 510, "memory_kb": 55660}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s659730296", "group_id": "codeNet:p02887", "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 s = in.readLine()\n\n System.out.println(\n s.toList.zip(s.toList.tail).count {\n case (a,b) => a != b\n } + 1\n )\n }\n}\n", "language": "Scala", "metadata": {"date": 1571535138, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02887.html", "problem_id": "p02887", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02887/input.txt", "sample_output_relpath": "derived/input_output/data/p02887/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02887/Scala/s659730296.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s659730296", "user_id": "u178269371"}, "prompt_components": {"gold_output": "5\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 s = in.readLine()\n\n System.out.println(\n s.toList.zip(s.toList.tail).count {\n case (a,b) => a != b\n } + 1\n )\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S.\n\nAdjacent slimes with the same color will fuse into one larger slime without changing the color. If there were a slime adjacent to this group of slimes before fusion, that slime is now adjacent to the new larger slime.\n\nUltimately, how many slimes will be there?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = N\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the final number of slimes.\n\nSample Input 1\n\n10\naabbbbaaca\n\nSample Output 1\n\n5\n\nUltimately, these slimes will fuse into abaca.\n\nSample Input 2\n\n5\naaaaa\n\nSample Output 2\n\n1\n\nAll the slimes will fuse into one.\n\nSample Input 3\n\n20\nxxzaffeeeeddfkkkkllq\n\nSample Output 3\n\n10", "sample_input": "10\naabbbbaaca\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02887", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S.\n\nAdjacent slimes with the same color will fuse into one larger slime without changing the color. If there were a slime adjacent to this group of slimes before fusion, that slime is now adjacent to the new larger slime.\n\nUltimately, how many slimes will be there?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = N\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the final number of slimes.\n\nSample Input 1\n\n10\naabbbbaaca\n\nSample Output 1\n\n5\n\nUltimately, these slimes will fuse into abaca.\n\nSample Input 2\n\n5\naaaaa\n\nSample Output 2\n\n1\n\nAll the slimes will fuse into one.\n\nSample Input 3\n\n20\nxxzaffeeeeddfkkkkllq\n\nSample Output 3\n\n10", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 352, "cpu_time_ms": 487, "memory_kb": 44028}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s965217550", "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 def count(l:Array[Int],k:Int, ans:Int, ab:Int):Int = {\n\n if(l.length <= k)\n ans\n else if(l(k) >= ab)\n ans\n else\n count(l, k + 1, ans + 1, ab)\n } \n \n for(i <- 0 until n) {\n for(j <- i + 1 until n) {\n var ab = input(i) + input(j)\n ans = count(input,j + 1, ans, ab)\n }\n }\n println(ans) \n}\n", "language": "Scala", "metadata": {"date": 1571615043, "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/s965217550.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s965217550", "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 def count(l:Array[Int],k:Int, ans:Int, ab:Int):Int = {\n\n if(l.length <= k)\n ans\n else if(l(k) >= ab)\n ans\n else\n count(l, k + 1, ans + 1, ab)\n } \n \n for(i <- 0 until n) {\n for(j <- i + 1 until n) {\n var ab = input(i) + input(j)\n ans = count(input,j + 1, ans, ab)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 431, "cpu_time_ms": 885, "memory_kb": 27500}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s657870080", "group_id": "codeNet:p02888", "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 ls = in.readLine().split(\"\\\\s+\").map(_.toInt)\n\n System.out.println(\n (for {\n ai <- 0 until ls.length - 2\n a = ls(ai)\n bi <- (ai + 1) until ls.length - 1\n b = ls(bi)\n ab = a + b\n ci <- (bi + 1) until ls.length\n c = ls(ci)\n } yield {\n c < ab && a < b + c && b < c + a\n }).count(b => b)\n )\n }\n}\n", "language": "Scala", "metadata": {"date": 1571536079, "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/s657870080.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s657870080", "user_id": "u178269371"}, "prompt_components": {"gold_output": "1\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 ls = in.readLine().split(\"\\\\s+\").map(_.toInt)\n\n System.out.println(\n (for {\n ai <- 0 until ls.length - 2\n a = ls(ai)\n bi <- (ai + 1) until ls.length - 1\n b = ls(bi)\n ab = a + b\n ci <- (bi + 1) until ls.length\n c = ls(ci)\n } yield {\n c < ab && a < b + c && b < c + a\n }).count(b => b)\n )\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.\n\nHe is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:\n\na < b + c\n\nb < c + a\n\nc < a + b\n\nHow many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq L_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_N\n\nConstraints\n\nPrint the number of different triangles that can be formed.\n\nSample Input 1\n\n4\n3 4 2 1\n\nSample Output 1\n\n1\n\nOnly one triangle can be formed: the triangle formed by the first, second, and third sticks.\n\nSample Input 2\n\n3\n1 1000 1\n\nSample Output 2\n\n0\n\nNo triangles can be formed.\n\nSample Input 3\n\n7\n218 786 704 233 645 728 389\n\nSample Output 3\n\n23", "sample_input": "4\n3 4 2 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02888", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.\n\nHe is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:\n\na < b + c\n\nb < c + a\n\nc < a + b\n\nHow many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq L_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_N\n\nConstraints\n\nPrint the number of different triangles that can be formed.\n\nSample Input 1\n\n4\n3 4 2 1\n\nSample Output 1\n\n1\n\nOnly one triangle can be formed: the triangle formed by the first, second, and third sticks.\n\nSample Input 2\n\n3\n1 1000 1\n\nSample Output 2\n\n0\n\nNo triangles can be formed.\n\nSample Input 3\n\n7\n218 786 704 233 645 728 389\n\nSample Output 3\n\n23", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 584, "cpu_time_ms": 2115, "memory_kb": 202460}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s780969189", "group_id": "codeNet:p02888", "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 ls = in.readLine().split(\"\\\\s+\").map(_.toInt)\n\n System.out.println(\n (for {\n ai <- 0 until ls.length - 2\n bi <- (ai + 1) until ls.length - 1\n ci <- (bi + 1) until ls.length\n } yield {\n val (a, b, c) = (ls(ai), ls(bi), ls(ci))\n\n a < b + c && b < c + a && c < a + b\n }).count(b => b)\n )\n }\n}\n", "language": "Scala", "metadata": {"date": 1571535732, "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/s780969189.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s780969189", "user_id": "u178269371"}, "prompt_components": {"gold_output": "1\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 ls = in.readLine().split(\"\\\\s+\").map(_.toInt)\n\n System.out.println(\n (for {\n ai <- 0 until ls.length - 2\n bi <- (ai + 1) until ls.length - 1\n ci <- (bi + 1) until ls.length\n } yield {\n val (a, b, c) = (ls(ai), ls(bi), ls(ci))\n\n a < b + c && b < c + a && c < a + b\n }).count(b => b)\n )\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.\n\nHe is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:\n\na < b + c\n\nb < c + a\n\nc < a + b\n\nHow many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq L_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_N\n\nConstraints\n\nPrint the number of different triangles that can be formed.\n\nSample Input 1\n\n4\n3 4 2 1\n\nSample Output 1\n\n1\n\nOnly one triangle can be formed: the triangle formed by the first, second, and third sticks.\n\nSample Input 2\n\n3\n1 1000 1\n\nSample Output 2\n\n0\n\nNo triangles can be formed.\n\nSample Input 3\n\n7\n218 786 704 233 645 728 389\n\nSample Output 3\n\n23", "sample_input": "4\n3 4 2 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02888", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.\n\nHe is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:\n\na < b + c\n\nb < c + a\n\nc < a + b\n\nHow many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq L_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_N\n\nConstraints\n\nPrint the number of different triangles that can be formed.\n\nSample Input 1\n\n4\n3 4 2 1\n\nSample Output 1\n\n1\n\nOnly one triangle can be formed: the triangle formed by the first, second, and third sticks.\n\nSample Input 2\n\n3\n1 1000 1\n\nSample Output 2\n\n0\n\nNo triangles can be formed.\n\nSample Input 3\n\n7\n218 786 704 233 645 728 389\n\nSample Output 3\n\n23", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 561, "cpu_time_ms": 2119, "memory_kb": 208508}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s039530587", "group_id": "codeNet:p02888", "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 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 n = ni()\n val l = na(n)\n// val MAX = isDebug(5, 1000)\n val MAX = 1000\n val cnt = Array.ofDim[Int](MAX + 1)\n REP(n) { i =>\n cnt(l(i)) += 1\n }\n val cum = cumSum(cnt);\n// debug(cum)\n // a < b < c\n var ans = 0L\n TO(1, MAX - 1) { a =>\n TO(a + 1, MAX) { c =>\n val b_min = max(a + 1, c - a + 1) // c < a + b\n val b_max = c - 1\n val v = max(0, cum(b_max + 1) - cum(b_min))\n if (cnt(a) > 0 && cnt(c) > 0) debug(s\"a:$a c:$c b_min:$b_min b_max:$b_max v:$v\")\n ans += v * cnt(a) * cnt(c)\n }\n }\n\n // a = b < c, a < b == c\n\n TO(1, MAX - 1) { a =>\n TO(a + 1, MAX) { c =>\n if (2 * a > c && cnt(a) >= 2) ans += cnt(a) * (cnt(a) - 1) * cnt(c) / 2\n if (cnt(c) >= 2) ans += cnt(c) * (cnt(c) - 1) * cnt(a) / 2\n }\n }\n\n // a == b == c\n TO(1, MAX) { a =>\n if (cnt(a) >= 3) {\n ans += cnt(a) * (cnt(a) - 1) * (cnt(a) - 2) / 6\n }\n }\n\n out.println(ans)\n }\n}", "language": "Scala", "metadata": {"date": 1571535176, "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/s039530587.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s039530587", "user_id": "u460609472"}, "prompt_components": {"gold_output": "1\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 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 n = ni()\n val l = na(n)\n// val MAX = isDebug(5, 1000)\n val MAX = 1000\n val cnt = Array.ofDim[Int](MAX + 1)\n REP(n) { i =>\n cnt(l(i)) += 1\n }\n val cum = cumSum(cnt);\n// debug(cum)\n // a < b < c\n var ans = 0L\n TO(1, MAX - 1) { a =>\n TO(a + 1, MAX) { c =>\n val b_min = max(a + 1, c - a + 1) // c < a + b\n val b_max = c - 1\n val v = max(0, cum(b_max + 1) - cum(b_min))\n if (cnt(a) > 0 && cnt(c) > 0) debug(s\"a:$a c:$c b_min:$b_min b_max:$b_max v:$v\")\n ans += v * cnt(a) * cnt(c)\n }\n }\n\n // a = b < c, a < b == c\n\n TO(1, MAX - 1) { a =>\n TO(a + 1, MAX) { c =>\n if (2 * a > c && cnt(a) >= 2) ans += cnt(a) * (cnt(a) - 1) * cnt(c) / 2\n if (cnt(c) >= 2) ans += cnt(c) * (cnt(c) - 1) * cnt(a) / 2\n }\n }\n\n // a == b == c\n TO(1, MAX) { a =>\n if (cnt(a) >= 3) {\n ans += cnt(a) * (cnt(a) - 1) * (cnt(a) - 2) / 6\n }\n }\n\n out.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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4949, "cpu_time_ms": 381, "memory_kb": 29492}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s385120835", "group_id": "codeNet:p02889", "input_text": "import scala.math.min\n\nobject Main extends App {\n val sc = new java.util.Scanner(System.in)\n val N, M, L = sc.nextInt\n val ABCs = Seq.fill(M)(sc.nextInt, sc.nextInt, sc.nextInt)\n val Q = sc.nextInt\n val STs = Seq.fill(Q)((sc.nextInt, sc.nextInt))\n\n val d = Array.fill(N + 1, N + 1)(L + 1)\n ABCs.foreach{case(a, b, c) => d(a)(b) = c; d(b)(a) = c}\n for(i <- 1 to N; j <- 1 to N; k <- 1 to N) d(i)(j) = min(d(i)(j), d(i)(k) + d(k)(j))\n val x = d.map(_.map{v => if(v <= L) 1 else L + 1})\n for(i <- 1 to N; j <- 1 to N; k <- 1 to N) x(i)(j) = min(x(i)(j), x(i)(k) + x(k)(j))\n STs.foreach{case(s, t) => println(if(x(s)(t) > L) -1 else x(s)(t) - 1)}\n}", "language": "Scala", "metadata": {"date": 1572456264, "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/s385120835.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s385120835", "user_id": "u304198114"}, "prompt_components": {"gold_output": "0\n1\n", "input_to_evaluate": "import scala.math.min\n\nobject Main extends App {\n val sc = new java.util.Scanner(System.in)\n val N, M, L = sc.nextInt\n val ABCs = Seq.fill(M)(sc.nextInt, sc.nextInt, sc.nextInt)\n val Q = sc.nextInt\n val STs = Seq.fill(Q)((sc.nextInt, sc.nextInt))\n\n val d = Array.fill(N + 1, N + 1)(L + 1)\n ABCs.foreach{case(a, b, c) => d(a)(b) = c; d(b)(a) = c}\n for(i <- 1 to N; j <- 1 to N; k <- 1 to N) d(i)(j) = min(d(i)(j), d(i)(k) + d(k)(j))\n val x = d.map(_.map{v => if(v <= L) 1 else L + 1})\n for(i <- 1 to N; j <- 1 to N; k <- 1 to N) x(i)(j) = min(x(i)(j), x(i)(k) + x(k)(j))\n STs.foreach{case(s, t) => println(if(x(s)(t) > L) -1 else x(s)(t) - 1)}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1838, "memory_kb": 113632}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s532853000", "group_id": "codeNet:p02898", "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 println(Array.fill(N)(sc.nextLong()).count(x => x >= K))\n }\n\n def recursive(A: Long): Long = {\n if (A == 1) 1 else recursive(A / 2) * 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": 1569985730, "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/s532853000.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s532853000", "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 N, K = sc.nextInt()\n println(Array.fill(N)(sc.nextLong()).count(x => x >= K))\n }\n\n def recursive(A: Long): Long = {\n if (A == 1) 1 else recursive(A / 2) * 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 : 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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6826, "cpu_time_ms": 552, "memory_kb": 37980}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s893805907", "group_id": "codeNet:p02898", "input_text": "object Main{\n def main(args: Array[String]){\n val input=io.Source.stdin.getLines().mkString(\"\\n\")\n println(solve(input).trim())\n }\n\n def solve(input:String):String={\n val k = input.split(\"\\n\")(0).split(\" \")(1).toInt\n val hs = input.split(\"\\n\")(1).split(\" \").map(_.toInt)\n hs.filter{_>=k}.size.toString\n }\n}\n", "language": "Scala", "metadata": {"date": 1569955094, "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/s893805907.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s893805907", "user_id": "u394033362"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main{\n def main(args: Array[String]){\n val input=io.Source.stdin.getLines().mkString(\"\\n\")\n println(solve(input).trim())\n }\n\n def solve(input:String):String={\n val k = input.split(\"\\n\")(0).split(\" \")(1).toInt\n val hs = input.split(\"\\n\")(1).split(\" \").map(_.toInt)\n hs.filter{_>=k}.size.toString\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 326, "cpu_time_ms": 520, "memory_kb": 42820}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s503672648", "group_id": "codeNet:p02898", "input_text": "object Main{\n def main(args: Array[String]){\n val input=io.Source.stdin.getLines().mkString(\"\\n\")\n println(solve(input).trim())\n }\n\n def solve(input:String):String={\n val k = input.split(\"\\n\")(0).split(\" \")(1).toInt\n val hs = input.split(\"\\n\")(1).split(\" \").map(_.toInt)\n hs.filter{_ 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 val As = recursive(A, 2)\n val Bs = recursive(B, 2)\n println(As.intersect(Bs).size + 1)\n }\n\n\n def recursive(now: Long, minV: Long): Set[Long] = {\n if (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", "language": "Scala", "metadata": {"date": 1572840857, "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/s416337787.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s416337787", "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 val As = recursive(A, 2)\n val Bs = recursive(B, 2)\n println(As.intersect(Bs).size + 1)\n }\n\n\n def recursive(now: Long, minV: Long): Set[Long] = {\n if (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", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are positive integers A and B.\n\nLet us choose some number of positive common divisors of A and B.\n\nHere, any two of the chosen divisors must be coprime.\n\nAt most, how many divisors can we choose?\n\nDefinition of common divisor\n\nAn integer d is said to be a common divisor of integers x and y when d divides both x and y.\n\nDefinition of being coprime\n\nIntegers x and y are said to be coprime when x and y have no positive common divisors other than 1.\n\nDefinition of dividing\n\nAn integer x is said to divide another integer y when there exists an integer \\alpha such that y = \\alpha x.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the maximum number of divisors that can be chosen to satisfy the condition.\n\nSample Input 1\n\n12 18\n\nSample Output 1\n\n3\n\n12 and 18 have the following positive common divisors: 1, 2, 3, and 6.\n\n1 and 2 are coprime, 2 and 3 are coprime, and 3 and 1 are coprime, so we can choose 1, 2, and 3, which achieve the maximum result.\n\nSample Input 2\n\n420 660\n\nSample Output 2\n\n4\n\nSample Input 3\n\n1 2019\n\nSample Output 3\n\n1\n\n1 and 2019 have no positive common divisors other than 1.", "sample_input": "12 18\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02900", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are positive integers A and B.\n\nLet us choose some number of positive common divisors of A and B.\n\nHere, any two of the chosen divisors must be coprime.\n\nAt most, how many divisors can we choose?\n\nDefinition of common divisor\n\nAn integer d is said to be a common divisor of integers x and y when d divides both x and y.\n\nDefinition of being coprime\n\nIntegers x and y are said to be coprime when x and y have no positive common divisors other than 1.\n\nDefinition of dividing\n\nAn integer x is said to divide another integer y when there exists an integer \\alpha such that y = \\alpha x.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the maximum number of divisors that can be chosen to satisfy the condition.\n\nSample Input 1\n\n12 18\n\nSample Output 1\n\n3\n\n12 and 18 have the following positive common divisors: 1, 2, 3, and 6.\n\n1 and 2 are coprime, 2 and 3 are coprime, and 3 and 1 are coprime, so we can choose 1, 2, and 3, which achieve the maximum result.\n\nSample Input 2\n\n420 660\n\nSample Output 2\n\n4\n\nSample Input 3\n\n1 2019\n\nSample Output 3\n\n1\n\n1 and 2019 have no positive common divisors other than 1.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 7070, "cpu_time_ms": 2111, "memory_kb": 26944}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s444971846", "group_id": "codeNet:p02900", "input_text": "import scala.io.StdIn._\n\nobject Main extends App {\n val Array(a, b) = readLine.split(\" \").map(_.toLong)\n\n def gcd(l: Long, r: Long): Long = if (r == 0) l else gcd(r, l % r)\n\n def div(n: Long, d: Int, cnt: Int): Int = {\n if (n < d * d) {\n cnt + (if (n == 1) 1 else 2)\n } else {\n def divP(l: Long): Long = if (l % d == 0) divP(l / d) else l\n divP(n) match {\n case `n` => div(n, d + 1, cnt)\n case other => div(other, d + 1, cnt + 1)\n }\n }\n }\n\n println(div(gcd(a, b), 2, 0))\n}", "language": "Scala", "metadata": {"date": 1572025023, "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/s444971846.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s444971846", "user_id": "u132324749"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main extends App {\n val Array(a, b) = readLine.split(\" \").map(_.toLong)\n\n def gcd(l: Long, r: Long): Long = if (r == 0) l else gcd(r, l % r)\n\n def div(n: Long, d: Int, cnt: Int): Int = {\n if (n < d * d) {\n cnt + (if (n == 1) 1 else 2)\n } else {\n def divP(l: Long): Long = if (l % d == 0) divP(l / d) else l\n divP(n) match {\n case `n` => div(n, d + 1, cnt)\n case other => div(other, d + 1, cnt + 1)\n }\n }\n }\n\n println(div(gcd(a, b), 2, 0))\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are positive integers A and B.\n\nLet us choose some number of positive common divisors of A and B.\n\nHere, any two of the chosen divisors must be coprime.\n\nAt most, how many divisors can we choose?\n\nDefinition of common divisor\n\nAn integer d is said to be a common divisor of integers x and y when d divides both x and y.\n\nDefinition of being coprime\n\nIntegers x and y are said to be coprime when x and y have no positive common divisors other than 1.\n\nDefinition of dividing\n\nAn integer x is said to divide another integer y when there exists an integer \\alpha such that y = \\alpha x.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the maximum number of divisors that can be chosen to satisfy the condition.\n\nSample Input 1\n\n12 18\n\nSample Output 1\n\n3\n\n12 and 18 have the following positive common divisors: 1, 2, 3, and 6.\n\n1 and 2 are coprime, 2 and 3 are coprime, and 3 and 1 are coprime, so we can choose 1, 2, and 3, which achieve the maximum result.\n\nSample Input 2\n\n420 660\n\nSample Output 2\n\n4\n\nSample Input 3\n\n1 2019\n\nSample Output 3\n\n1\n\n1 and 2019 have no positive common divisors other than 1.", "sample_input": "12 18\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02900", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are positive integers A and B.\n\nLet us choose some number of positive common divisors of A and B.\n\nHere, any two of the chosen divisors must be coprime.\n\nAt most, how many divisors can we choose?\n\nDefinition of common divisor\n\nAn integer d is said to be a common divisor of integers x and y when d divides both x and y.\n\nDefinition of being coprime\n\nIntegers x and y are said to be coprime when x and y have no positive common divisors other than 1.\n\nDefinition of dividing\n\nAn integer x is said to divide another integer y when there exists an integer \\alpha such that y = \\alpha x.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the maximum number of divisors that can be chosen to satisfy the condition.\n\nSample Input 1\n\n12 18\n\nSample Output 1\n\n3\n\n12 and 18 have the following positive common divisors: 1, 2, 3, and 6.\n\n1 and 2 are coprime, 2 and 3 are coprime, and 3 and 1 are coprime, so we can choose 1, 2, and 3, which achieve the maximum result.\n\nSample Input 2\n\n420 660\n\nSample Output 2\n\n4\n\nSample Input 3\n\n1 2019\n\nSample Output 3\n\n1\n\n1 and 2019 have no positive common divisors other than 1.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 520, "cpu_time_ms": 2111, "memory_kb": 27428}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s803735515", "group_id": "codeNet:p02900", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n val Array(a, b) = StdIn.readLine().split(\" \").map(_.toLong)\n val gcd_v = gcd(a, b)\n\n println(primeDivSize(gcd_v))\n \n\n def isPrime(i: Long) : Boolean = {\n if (i == 2l)\n true\n else\n !(2l to (i-1l)).exists(x => i % x == 0l)\n }\n\n def primeDivSize(i: Long) : Int = {\n val range :Long = Math.sqrt(i).ceil.toLong\n var target = i\n val ans :scala.collection.mutable.Set[Long] = scala.collection.mutable.Set[Long](1)\n var j = 2\n while (j <= range) {\n if (target % j == 0) {\n ans += j\n target = target / j }\n else j = j + 1\n }\n\n if (target != 1) ans += target\n\n ans.size\n }\n \n def gcd(a: Long,b: Long): Long = {\n if(b ==0l) a else gcd(b, a%b)\n }\n}\n \n\n", "language": "Scala", "metadata": {"date": 1569771057, "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/s803735515.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s803735515", "user_id": "u258933429"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n val Array(a, b) = StdIn.readLine().split(\" \").map(_.toLong)\n val gcd_v = gcd(a, b)\n\n println(primeDivSize(gcd_v))\n \n\n def isPrime(i: Long) : Boolean = {\n if (i == 2l)\n true\n else\n !(2l to (i-1l)).exists(x => i % x == 0l)\n }\n\n def primeDivSize(i: Long) : Int = {\n val range :Long = Math.sqrt(i).ceil.toLong\n var target = i\n val ans :scala.collection.mutable.Set[Long] = scala.collection.mutable.Set[Long](1)\n var j = 2\n while (j <= range) {\n if (target % j == 0) {\n ans += j\n target = target / j }\n else j = j + 1\n }\n\n if (target != 1) ans += target\n\n ans.size\n }\n \n def gcd(a: Long,b: Long): Long = {\n if(b ==0l) a else gcd(b, a%b)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 770, "cpu_time_ms": 339, "memory_kb": 25540}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s276964086", "group_id": "codeNet:p02900", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n val Array(a, b) = StdIn.readLine().split(\" \").map(_.toInt)\n var can : Array[Int] = Array.empty\n\n (1 to a.min(b)).foreach {i =>\n if (a % i == 0 && b % i == 0) can = can :+ i\n }\n\n println(can.filter(j => isPrime(j)).length)\n \n\n def isPrime(i: Int) : Boolean = {\n if (i == 1)\n true\n else if (i == 2)\n true\n else\n !(2 to (i-1)).exists(x => i % x == 0)\n }\n}\n \n\n", "language": "Scala", "metadata": {"date": 1569721921, "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/s276964086.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s276964086", "user_id": "u258933429"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n val Array(a, b) = StdIn.readLine().split(\" \").map(_.toInt)\n var can : Array[Int] = Array.empty\n\n (1 to a.min(b)).foreach {i =>\n if (a % i == 0 && b % i == 0) can = can :+ i\n }\n\n println(can.filter(j => isPrime(j)).length)\n \n\n def isPrime(i: Int) : Boolean = {\n if (i == 1)\n true\n else if (i == 2)\n true\n else\n !(2 to (i-1)).exists(x => i % x == 0)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 442, "cpu_time_ms": 339, "memory_kb": 27168}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s494179755", "group_id": "codeNet:p02901", "input_text": "import scala.io.StdIn._\n\nobject Main extends App {\n type Cost = Int\n type Boxes = Int\n val Array(n, m) = readLine.split(\" \").map(_.toInt)\n val boxPatterns = 1 << n\n val allKeys: Seq[(Cost, Boxes)] = (1 to m).map { i =>\n val Array(a, b) = readLine.split(\" \").map(_.toInt)\n (a, readLine.split(\" \").map(_.toInt).foldLeft(0){(z, bb) => z + (1 << (bb - 1))})\n }\n\n val Impossible = -1\n def dp(keys: List[(Cost, Boxes)], prev: Array[Int]): Int = {\n keys match {\n case Nil => prev(boxPatterns - 1)\n case (cost, boxes) :: ks =>\n val cur = new Array[Int](boxPatterns)\n (0 until boxPatterns).foreach { b =>\n cur(b) =\n if ((b & boxes) == 0) prev(b)\n else {\n (prev(b), prev(b - (b & boxes))) match {\n case (Impossible, Impossible) =>\n if ((b | boxes) == boxes) cost\n else Impossible\n case (Impossible, y) => y + cost\n case (x, Impossible) => Math.min(x, cost)\n case (x, y) => Math.min(x, y + cost)\n }\n }\n }\n dp(ks, cur)\n }\n }\n\n println(dp(allKeys.toList, Array.fill(boxPatterns)(Impossible)))\n}", "language": "Scala", "metadata": {"date": 1571952218, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02901.html", "problem_id": "p02901", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02901/input.txt", "sample_output_relpath": "derived/input_output/data/p02901/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02901/Scala/s494179755.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s494179755", "user_id": "u132324749"}, "prompt_components": {"gold_output": "25\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main extends App {\n type Cost = Int\n type Boxes = Int\n val Array(n, m) = readLine.split(\" \").map(_.toInt)\n val boxPatterns = 1 << n\n val allKeys: Seq[(Cost, Boxes)] = (1 to m).map { i =>\n val Array(a, b) = readLine.split(\" \").map(_.toInt)\n (a, readLine.split(\" \").map(_.toInt).foldLeft(0){(z, bb) => z + (1 << (bb - 1))})\n }\n\n val Impossible = -1\n def dp(keys: List[(Cost, Boxes)], prev: Array[Int]): Int = {\n keys match {\n case Nil => prev(boxPatterns - 1)\n case (cost, boxes) :: ks =>\n val cur = new Array[Int](boxPatterns)\n (0 until boxPatterns).foreach { b =>\n cur(b) =\n if ((b & boxes) == 0) prev(b)\n else {\n (prev(b), prev(b - (b & boxes))) match {\n case (Impossible, Impossible) =>\n if ((b | boxes) == boxes) cost\n else Impossible\n case (Impossible, y) => y + cost\n case (x, Impossible) => Math.min(x, cost)\n case (x, y) => Math.min(x, y + cost)\n }\n }\n }\n dp(ks, cur)\n }\n }\n\n println(dp(allKeys.toList, Array.fill(boxPatterns)(Impossible)))\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nWe have N locked treasure boxes, numbered 1 to N.\n\nA shop sells M keys. The i-th key is sold for a_i yen (the currency of Japan), and it can unlock b_i of the boxes: Box c_{i1}, c_{i2}, ..., c_{i{b_i}}. Each key purchased can be used any number of times.\n\nFind the minimum cost required to unlock all the treasure boxes. If it is impossible to unlock all of them, print -1.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 12\n\n1 \\leq M \\leq 10^3\n\n1 \\leq a_i \\leq 10^5\n\n1 \\leq b_i \\leq N\n\n1 \\leq c_{i1} < c_{i2} < ... < c_{i{b_i}} \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\nc_{11} c_{12} ... c_{1{b_1}}\n:\na_M b_M\nc_{M1} c_{M2} ... c_{M{b_M}}\n\nOutput\n\nPrint the minimum cost required to unlock all the treasure boxes.\nIf it is impossible to unlock all of them, print -1.\n\nSample Input 1\n\n2 3\n10 1\n1\n15 1\n2\n30 2\n1 2\n\nSample Output 1\n\n25\n\nWe can unlock all the boxes by purchasing the first and second keys, at the cost of 25 yen, which is the minimum cost required.\n\nSample Input 2\n\n12 1\n100000 1\n2\n\nSample Output 2\n\n-1\n\nWe cannot unlock all the boxes.\n\nSample Input 3\n\n4 6\n67786 3\n1 3 4\n3497 1\n2\n44908 3\n2 3 4\n2156 3\n2 3 4\n26230 1\n2\n86918 1\n3\n\nSample Output 3\n\n69942", "sample_input": "2 3\n10 1\n1\n15 1\n2\n30 2\n1 2\n"}, "reference_outputs": ["25\n"], "source_document_id": "p02901", "source_text": "Score : 500 points\n\nProblem Statement\n\nWe have N locked treasure boxes, numbered 1 to N.\n\nA shop sells M keys. The i-th key is sold for a_i yen (the currency of Japan), and it can unlock b_i of the boxes: Box c_{i1}, c_{i2}, ..., c_{i{b_i}}. Each key purchased can be used any number of times.\n\nFind the minimum cost required to unlock all the treasure boxes. If it is impossible to unlock all of them, print -1.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 12\n\n1 \\leq M \\leq 10^3\n\n1 \\leq a_i \\leq 10^5\n\n1 \\leq b_i \\leq N\n\n1 \\leq c_{i1} < c_{i2} < ... < c_{i{b_i}} \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\nc_{11} c_{12} ... c_{1{b_1}}\n:\na_M b_M\nc_{M1} c_{M2} ... c_{M{b_M}}\n\nOutput\n\nPrint the minimum cost required to unlock all the treasure boxes.\nIf it is impossible to unlock all of them, print -1.\n\nSample Input 1\n\n2 3\n10 1\n1\n15 1\n2\n30 2\n1 2\n\nSample Output 1\n\n25\n\nWe can unlock all the boxes by purchasing the first and second keys, at the cost of 25 yen, which is the minimum cost required.\n\nSample Input 2\n\n12 1\n100000 1\n2\n\nSample Output 2\n\n-1\n\nWe cannot unlock all the boxes.\n\nSample Input 3\n\n4 6\n67786 3\n1 3 4\n3497 1\n2\n44908 3\n2 3 4\n2156 3\n2 3 4\n26230 1\n2\n86918 1\n3\n\nSample Output 3\n\n69942", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1203, "cpu_time_ms": 636, "memory_kb": 37256}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s247656634", "group_id": "codeNet:p02902", "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 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 def mkAns(now: Int, lst: List[Int]): List[Int] = {\n lst match {\n case a :: rest =>\n if (a == now)\n List(a)\n else\n a :: mkAns(now, rest)\n }\n }\n\n //\n val done = new Array[Boolean](N+1)\n var ans: List[Int] = Nil\n breakable {\n for (i <- 1 to N) {\n if (!done(i)) {\n done(i) = true\n\n val q = new Queue[(Int, List[Int])]\n //val dp = new Array[Boolean](N+1)\n //dp(i) = true\n q.enqueue((i, List()))\n\n breakable {\n while (!q.isEmpty) {\n val (now, alr) = q.dequeue()\n if (!done(now))\n done(now) = true\n\n if (alr.contains(now)) {\n ans = mkAns(now, alr)\n break\n }\n else {\n for (e <- graph(now))\n q.enqueue((e, now :: alr))\n }\n }\n }\n }\n\n if (ans != Nil)\n break\n }\n }\n\n if (ans == Nil)\n pw.println(-1)\n else {\n pw.println(ans.length)\n ans.foreach { x => pw.println(x) }\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": 1569808630, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02902.html", "problem_id": "p02902", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02902/input.txt", "sample_output_relpath": "derived/input_output/data/p02902/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02902/Scala/s247656634.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s247656634", "user_id": "u098968285"}, "prompt_components": {"gold_output": "3\n1\n2\n4\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 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 def mkAns(now: Int, lst: List[Int]): List[Int] = {\n lst match {\n case a :: rest =>\n if (a == now)\n List(a)\n else\n a :: mkAns(now, rest)\n }\n }\n\n //\n val done = new Array[Boolean](N+1)\n var ans: List[Int] = Nil\n breakable {\n for (i <- 1 to N) {\n if (!done(i)) {\n done(i) = true\n\n val q = new Queue[(Int, List[Int])]\n //val dp = new Array[Boolean](N+1)\n //dp(i) = true\n q.enqueue((i, List()))\n\n breakable {\n while (!q.isEmpty) {\n val (now, alr) = q.dequeue()\n if (!done(now))\n done(now) = true\n\n if (alr.contains(now)) {\n ans = mkAns(now, alr)\n break\n }\n else {\n for (e <- graph(now))\n q.enqueue((e, now :: alr))\n }\n }\n }\n }\n\n if (ans != Nil)\n break\n }\n }\n\n if (ans == Nil)\n pw.println(-1)\n else {\n pw.println(ans.length)\n ans.foreach { x => pw.println(x) }\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 : 600 points\n\nProblem Statement\n\nGiven is a directed graph G with N vertices and M edges.\n\nThe vertices are numbered 1 to N, and the i-th edge is directed from Vertex A_i to Vertex B_i.\n\nIt is guaranteed that the graph contains no self-loops or multiple edges.\n\nDetermine whether there exists an induced subgraph (see Notes) of G such that the in-degree and out-degree of every vertex are both 1. If the answer is yes, show one such subgraph.\n\nHere the null graph is not considered as a subgraph.\n\nNotes\n\nFor a directed graph G = (V, E), we call a directed graph G' = (V', E') satisfying the following conditions an induced subgraph of G:\n\nV' is a (non-empty) subset of V.\n\nE' is the set of all the edges in E that have both endpoints in V'.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n0 \\leq M \\leq 2000\n\n1 \\leq A_i,B_i \\leq N\n\nA_i \\neq B_i\n\nAll pairs (A_i, B_i) are distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n:\nA_M B_M\n\nOutput\n\nIf there is no induced subgraph of G that satisfies the condition, print -1.\nOtherwise, print an induced subgraph of G that satisfies the condition, in the following format:\n\nK\nv_1\nv_2\n:\nv_K\n\nThis represents the induced subgraph of G with K vertices whose vertex set is \\{v_1, v_2, \\ldots, v_K\\}. (The order of v_1, v_2, \\ldots, v_K does not matter.)\nIf there are multiple subgraphs of G that satisfy the condition, printing any of them is accepted.\n\nSample Input 1\n\n4 5\n1 2\n2 3\n2 4\n4 1\n4 3\n\nSample Output 1\n\n3\n1\n2\n4\n\nThe induced subgraph of G whose vertex set is \\{1, 2, 4\\} has the edge set \\{(1, 2), (2, 4), (4, 1)\\}. The in-degree and out-degree of every vertex in this graph are both 1.\n\nSample Input 2\n\n4 5\n1 2\n2 3\n2 4\n1 4\n4 3\n\nSample Output 2\n\n-1\n\nThere is no induced subgraph of G that satisfies the condition.\n\nSample Input 3\n\n6 9\n1 2\n2 3\n3 4\n4 5\n5 6\n5 1\n5 2\n6 1\n6 2\n\nSample Output 3\n\n4\n2\n3\n4\n5", "sample_input": "4 5\n1 2\n2 3\n2 4\n4 1\n4 3\n"}, "reference_outputs": ["3\n1\n2\n4\n"], "source_document_id": "p02902", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven is a directed graph G with N vertices and M edges.\n\nThe vertices are numbered 1 to N, and the i-th edge is directed from Vertex A_i to Vertex B_i.\n\nIt is guaranteed that the graph contains no self-loops or multiple edges.\n\nDetermine whether there exists an induced subgraph (see Notes) of G such that the in-degree and out-degree of every vertex are both 1. If the answer is yes, show one such subgraph.\n\nHere the null graph is not considered as a subgraph.\n\nNotes\n\nFor a directed graph G = (V, E), we call a directed graph G' = (V', E') satisfying the following conditions an induced subgraph of G:\n\nV' is a (non-empty) subset of V.\n\nE' is the set of all the edges in E that have both endpoints in V'.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n0 \\leq M \\leq 2000\n\n1 \\leq A_i,B_i \\leq N\n\nA_i \\neq B_i\n\nAll pairs (A_i, B_i) are distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n:\nA_M B_M\n\nOutput\n\nIf there is no induced subgraph of G that satisfies the condition, print -1.\nOtherwise, print an induced subgraph of G that satisfies the condition, in the following format:\n\nK\nv_1\nv_2\n:\nv_K\n\nThis represents the induced subgraph of G with K vertices whose vertex set is \\{v_1, v_2, \\ldots, v_K\\}. (The order of v_1, v_2, \\ldots, v_K does not matter.)\nIf there are multiple subgraphs of G that satisfy the condition, printing any of them is accepted.\n\nSample Input 1\n\n4 5\n1 2\n2 3\n2 4\n4 1\n4 3\n\nSample Output 1\n\n3\n1\n2\n4\n\nThe induced subgraph of G whose vertex set is \\{1, 2, 4\\} has the edge set \\{(1, 2), (2, 4), (4, 1)\\}. The in-degree and out-degree of every vertex in this graph are both 1.\n\nSample Input 2\n\n4 5\n1 2\n2 3\n2 4\n1 4\n4 3\n\nSample Output 2\n\n-1\n\nThere is no induced subgraph of G that satisfies the condition.\n\nSample Input 3\n\n6 9\n1 2\n2 3\n3 4\n4 5\n5 6\n5 1\n5 2\n6 1\n6 2\n\nSample Output 3\n\n4\n2\n3\n4\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1851, "cpu_time_ms": 491, "memory_kb": 30580}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s997608282", "group_id": "codeNet:p02903", "input_text": "object Main {\n def main(args: Array[String]) = {\n val pw = new java.io.PrintWriter(System.out)\n val sc = new java.util.Scanner(System.in)\n val h, w, a, b = sc.nextInt\n sc.close()\n\n if ((w - a * 2) != (h - b * 2)) {\n pw.println(\"No\")\n } else {\n (0 until h).foreach(hh => {\n (0 until w).foreach(ww => {\n val range = if (b == 0) 1 else hh / b * b\n pw.print(if (ww >= range && ww < range + a) \"1\" else \"0\")\n })\n pw.println()\n })\n }\n\n pw.flush()\n }\n}", "language": "Scala", "metadata": {"date": 1569118763, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02903.html", "problem_id": "p02903", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02903/input.txt", "sample_output_relpath": "derived/input_output/data/p02903/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02903/Scala/s997608282.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s997608282", "user_id": "u889604426"}, "prompt_components": {"gold_output": "100\n010\n001\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]) = {\n val pw = new java.io.PrintWriter(System.out)\n val sc = new java.util.Scanner(System.in)\n val h, w, a, b = sc.nextInt\n sc.close()\n\n if ((w - a * 2) != (h - b * 2)) {\n pw.println(\"No\")\n } else {\n (0 until h).foreach(hh => {\n (0 until w).foreach(ww => {\n val range = if (b == 0) 1 else hh / b * b\n pw.print(if (ww >= range && ww < range + a) \"1\" else \"0\")\n })\n pw.println()\n })\n }\n\n pw.flush()\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have a square grid with H rows and W columns.\nSnuke wants to write 0 or 1 in each of the squares.\nHere, all of the following conditions have to be satisfied:\n\nFor every row, the smaller of the following is A: the number of 0s contained in the row, and the number of 1s contained in the row. (If these two numbers are equal, “the smaller” should be read as “either”.)\n\nFor every column, the smaller of the following is B: the number of 0s contained in the column, and the number of 1s contained in the column.\n\nDetermine if these conditions can be satisfied by writing 0 or 1 in each of the squares. If the answer is yes, show one way to fill the squares so that the conditions are satisfied.\n\nConstraints\n\n1 \\leq H,W \\leq 1000\n\n0 \\leq A\n\n2 \\times A \\leq W\n\n0 \\leq B\n\n2 \\times B \\leq H\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W A B\n\nOutput\n\nIf the conditions cannot be satisfied by writing 0 or 1 in each of the squares, print -1.\n\nIf the conditions can be satisfied, print one way to fill the squares so that the conditions are satisfied, in the following format:\n\ns_{11}s_{12}\\cdots s_{1W}\ns_{21}s_{22}\\cdots s_{2W}\n\\vdots\ns_{H1}s_{H2}\\cdots s_{HW}\n\nHere s_{ij} is the digit written in the square at the i-th row from the top and the j-th column from the left in the grid.\n\nIf multiple solutions exist, printing any of them will be accepted.\n\nSample Input 1\n\n3 3 1 1\n\nSample Output 1\n\n100\n010\n001\n\nEvery row contains two 0s and one 1, so the first condition is satisfied.\nAlso, every column contains two 0s and one 1, so the second condition is satisfied.\n\nSample Input 2\n\n1 5 2 0\n\nSample Output 2\n\n01010", "sample_input": "3 3 1 1\n"}, "reference_outputs": ["100\n010\n001\n"], "source_document_id": "p02903", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have a square grid with H rows and W columns.\nSnuke wants to write 0 or 1 in each of the squares.\nHere, all of the following conditions have to be satisfied:\n\nFor every row, the smaller of the following is A: the number of 0s contained in the row, and the number of 1s contained in the row. (If these two numbers are equal, “the smaller” should be read as “either”.)\n\nFor every column, the smaller of the following is B: the number of 0s contained in the column, and the number of 1s contained in the column.\n\nDetermine if these conditions can be satisfied by writing 0 or 1 in each of the squares. If the answer is yes, show one way to fill the squares so that the conditions are satisfied.\n\nConstraints\n\n1 \\leq H,W \\leq 1000\n\n0 \\leq A\n\n2 \\times A \\leq W\n\n0 \\leq B\n\n2 \\times B \\leq H\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W A B\n\nOutput\n\nIf the conditions cannot be satisfied by writing 0 or 1 in each of the squares, print -1.\n\nIf the conditions can be satisfied, print one way to fill the squares so that the conditions are satisfied, in the following format:\n\ns_{11}s_{12}\\cdots s_{1W}\ns_{21}s_{22}\\cdots s_{2W}\n\\vdots\ns_{H1}s_{H2}\\cdots s_{HW}\n\nHere s_{ij} is the digit written in the square at the i-th row from the top and the j-th column from the left in the grid.\n\nIf multiple solutions exist, printing any of them will be accepted.\n\nSample Input 1\n\n3 3 1 1\n\nSample Output 1\n\n100\n010\n001\n\nEvery row contains two 0s and one 1, so the first condition is satisfied.\nAlso, every column contains two 0s and one 1, so the second condition is satisfied.\n\nSample Input 2\n\n1 5 2 0\n\nSample Output 2\n\n01010", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 525, "cpu_time_ms": 435, "memory_kb": 27232}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s687799905", "group_id": "codeNet:p02903", "input_text": "object Main {\n def main(args: Array[String]) = {\n val pw = new java.io.PrintWriter(System.out)\n val sc = new java.util.Scanner(System.in)\n val h, w, a, b = sc.nextInt\n sc.close()\n\n if ((w - a * 2) - (h - b * 2) != 0) {\n pw.println(\"No\")\n } else {\n (0 until h).foreach(hh => {\n (0 until w).foreach(ww => {\n val range = if (b == 0) 1 else hh / b * b\n pw.print(if (ww >= range && ww < range + a) \"1\" else \"0\")\n })\n pw.println()\n })\n }\n\n pw.flush()\n }\n}", "language": "Scala", "metadata": {"date": 1569118384, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02903.html", "problem_id": "p02903", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02903/input.txt", "sample_output_relpath": "derived/input_output/data/p02903/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02903/Scala/s687799905.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s687799905", "user_id": "u889604426"}, "prompt_components": {"gold_output": "100\n010\n001\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]) = {\n val pw = new java.io.PrintWriter(System.out)\n val sc = new java.util.Scanner(System.in)\n val h, w, a, b = sc.nextInt\n sc.close()\n\n if ((w - a * 2) - (h - b * 2) != 0) {\n pw.println(\"No\")\n } else {\n (0 until h).foreach(hh => {\n (0 until w).foreach(ww => {\n val range = if (b == 0) 1 else hh / b * b\n pw.print(if (ww >= range && ww < range + a) \"1\" else \"0\")\n })\n pw.println()\n })\n }\n\n pw.flush()\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have a square grid with H rows and W columns.\nSnuke wants to write 0 or 1 in each of the squares.\nHere, all of the following conditions have to be satisfied:\n\nFor every row, the smaller of the following is A: the number of 0s contained in the row, and the number of 1s contained in the row. (If these two numbers are equal, “the smaller” should be read as “either”.)\n\nFor every column, the smaller of the following is B: the number of 0s contained in the column, and the number of 1s contained in the column.\n\nDetermine if these conditions can be satisfied by writing 0 or 1 in each of the squares. If the answer is yes, show one way to fill the squares so that the conditions are satisfied.\n\nConstraints\n\n1 \\leq H,W \\leq 1000\n\n0 \\leq A\n\n2 \\times A \\leq W\n\n0 \\leq B\n\n2 \\times B \\leq H\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W A B\n\nOutput\n\nIf the conditions cannot be satisfied by writing 0 or 1 in each of the squares, print -1.\n\nIf the conditions can be satisfied, print one way to fill the squares so that the conditions are satisfied, in the following format:\n\ns_{11}s_{12}\\cdots s_{1W}\ns_{21}s_{22}\\cdots s_{2W}\n\\vdots\ns_{H1}s_{H2}\\cdots s_{HW}\n\nHere s_{ij} is the digit written in the square at the i-th row from the top and the j-th column from the left in the grid.\n\nIf multiple solutions exist, printing any of them will be accepted.\n\nSample Input 1\n\n3 3 1 1\n\nSample Output 1\n\n100\n010\n001\n\nEvery row contains two 0s and one 1, so the first condition is satisfied.\nAlso, every column contains two 0s and one 1, so the second condition is satisfied.\n\nSample Input 2\n\n1 5 2 0\n\nSample Output 2\n\n01010", "sample_input": "3 3 1 1\n"}, "reference_outputs": ["100\n010\n001\n"], "source_document_id": "p02903", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have a square grid with H rows and W columns.\nSnuke wants to write 0 or 1 in each of the squares.\nHere, all of the following conditions have to be satisfied:\n\nFor every row, the smaller of the following is A: the number of 0s contained in the row, and the number of 1s contained in the row. (If these two numbers are equal, “the smaller” should be read as “either”.)\n\nFor every column, the smaller of the following is B: the number of 0s contained in the column, and the number of 1s contained in the column.\n\nDetermine if these conditions can be satisfied by writing 0 or 1 in each of the squares. If the answer is yes, show one way to fill the squares so that the conditions are satisfied.\n\nConstraints\n\n1 \\leq H,W \\leq 1000\n\n0 \\leq A\n\n2 \\times A \\leq W\n\n0 \\leq B\n\n2 \\times B \\leq H\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W A B\n\nOutput\n\nIf the conditions cannot be satisfied by writing 0 or 1 in each of the squares, print -1.\n\nIf the conditions can be satisfied, print one way to fill the squares so that the conditions are satisfied, in the following format:\n\ns_{11}s_{12}\\cdots s_{1W}\ns_{21}s_{22}\\cdots s_{2W}\n\\vdots\ns_{H1}s_{H2}\\cdots s_{HW}\n\nHere s_{ij} is the digit written in the square at the i-th row from the top and the j-th column from the left in the grid.\n\nIf multiple solutions exist, printing any of them will be accepted.\n\nSample Input 1\n\n3 3 1 1\n\nSample Output 1\n\n100\n010\n001\n\nEvery row contains two 0s and one 1, so the first condition is satisfied.\nAlso, every column contains two 0s and one 1, so the second condition is satisfied.\n\nSample Input 2\n\n1 5 2 0\n\nSample Output 2\n\n01010", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 440, "memory_kb": 27332}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s404949590", "group_id": "codeNet:p02909", "input_text": "import scala.io.Source\n\nobject Main {\n val list = Seq(\"Sunny\", \"Cloudy\", \"Rainy\")\n\n def succ(x: String): String = {\n (list zip (list.tail :+ list.head)).toMap.get(x).get\n }\n\n def main(args: Array[String]) {\n val s = Source.stdin.getLines.toSeq.head\n println(succ(s))\n }\n}\n", "language": "Scala", "metadata": {"date": 1570908855, "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/s404949590.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s404949590", "user_id": "u469282027"}, "prompt_components": {"gold_output": "Cloudy\n", "input_to_evaluate": "import scala.io.Source\n\nobject Main {\n val list = Seq(\"Sunny\", \"Cloudy\", \"Rainy\")\n\n def succ(x: String): String = {\n (list zip (list.tail :+ list.head)).toMap.get(x).get\n }\n\n def main(args: Array[String]) {\n val s = Source.stdin.getLines.toSeq.head\n println(succ(s))\n }\n}\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThe weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ...\n\nGiven is a string S representing the weather in the town today. Predict the weather tomorrow.\n\nConstraints\n\nS is Sunny, Cloudy, or Rainy.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint a string representing the expected weather tomorrow, in the same format in which input is given.\n\nSample Input 1\n\nSunny\n\nSample Output 1\n\nCloudy\n\nIn Takahashi's town, a sunny day is followed by a cloudy day.\n\nSample Input 2\n\nRainy\n\nSample Output 2\n\nSunny", "sample_input": "Sunny\n"}, "reference_outputs": ["Cloudy\n"], "source_document_id": "p02909", "source_text": "Score: 100 points\n\nProblem Statement\n\nThe weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ...\n\nGiven is a string S representing the weather in the town today. Predict the weather tomorrow.\n\nConstraints\n\nS is Sunny, Cloudy, or Rainy.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint a string representing the expected weather tomorrow, in the same format in which input is given.\n\nSample Input 1\n\nSunny\n\nSample Output 1\n\nCloudy\n\nIn Takahashi's town, a sunny day is followed by a cloudy day.\n\nSample Input 2\n\nRainy\n\nSample Output 2\n\nSunny", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 286, "cpu_time_ms": 333, "memory_kb": 25540}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s145795100", "group_id": "codeNet:p02909", "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 = in.next().toInt\n private[this] val S = \"0\" + in.next()\n\n\n //\n // a は bに含まれているか\n def contain(a: String, b: String): Boolean = {\n val B = 5570293\n val h = 1e9.toLong\n\n val al = a.length; val bl = b.length\n if (al > bl)\n return false\n\n // B の al 乗を計算\n var t = 1L\n for (_ <- 1 to al) {\n t *= B\n t %= h\n }\n\n // aとbの最初のal文字に関するハッシュ値を計算\n var ah = 0L; var bh = 0L\n for (i <- 0 until al)\n ah = (ah * B + a(i).toLong) % h\n for (i <- 0 until al)\n bh = (bh * B + b(i).toLong) % h\n\n // bの場所を1つずつ進めながらハッシュ値をチェック\n for (i <- 0 to bl-al) {\n if (ah == bh && a == b.substring(i, i+al))\n return true\n if (i + al < bl) {\n bh *= B\n bh %= h\n bh += b(i+al).toLong - b(i).toLong * t\n if(bh < 0)\n bh += h * 1000\n bh %= h\n }\n }\n\n false\n }\n\n\n private[this] def check(end: Int, begin: Int): Boolean = {\n val a = S.substring(begin, end+1)\n val b = S.substring(end+1, N+1)\n\n contain(a, b)\n }\n\n // 条件を満たす最大の値を返す\n private[this] def binarySearch(min: Int, max: Int, begin: Int): Int = {\n val mid: Int = (max + min) / 2\n (max - min) match{\n case 0 | 1 =>\n check(max, begin) match{\n case true => max\n case false => min\n }\n case _ =>\n (check(mid, begin)) match{\n case true => binarySearch(mid, max, begin)\n case false => binarySearch(min, mid, begin)\n }\n }\n }\n\n\n\n private[this] var ans = 0\n for (i <- 1 to N-1) {\n if (check(i, i)) {\n val tmp = binarySearch(i, i + (N-i) / 2, i) - (i-1)\n ans = Math.max(ans, tmp)\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", "language": "Scala", "metadata": {"date": 1568778994, "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/s145795100.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s145795100", "user_id": "u098968285"}, "prompt_components": {"gold_output": "Cloudy\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 = in.next().toInt\n private[this] val S = \"0\" + in.next()\n\n\n //\n // a は bに含まれているか\n def contain(a: String, b: String): Boolean = {\n val B = 5570293\n val h = 1e9.toLong\n\n val al = a.length; val bl = b.length\n if (al > bl)\n return false\n\n // B の al 乗を計算\n var t = 1L\n for (_ <- 1 to al) {\n t *= B\n t %= h\n }\n\n // aとbの最初のal文字に関するハッシュ値を計算\n var ah = 0L; var bh = 0L\n for (i <- 0 until al)\n ah = (ah * B + a(i).toLong) % h\n for (i <- 0 until al)\n bh = (bh * B + b(i).toLong) % h\n\n // bの場所を1つずつ進めながらハッシュ値をチェック\n for (i <- 0 to bl-al) {\n if (ah == bh && a == b.substring(i, i+al))\n return true\n if (i + al < bl) {\n bh *= B\n bh %= h\n bh += b(i+al).toLong - b(i).toLong * t\n if(bh < 0)\n bh += h * 1000\n bh %= h\n }\n }\n\n false\n }\n\n\n private[this] def check(end: Int, begin: Int): Boolean = {\n val a = S.substring(begin, end+1)\n val b = S.substring(end+1, N+1)\n\n contain(a, b)\n }\n\n // 条件を満たす最大の値を返す\n private[this] def binarySearch(min: Int, max: Int, begin: Int): Int = {\n val mid: Int = (max + min) / 2\n (max - min) match{\n case 0 | 1 =>\n check(max, begin) match{\n case true => max\n case false => min\n }\n case _ =>\n (check(mid, begin)) match{\n case true => binarySearch(mid, max, begin)\n case false => binarySearch(min, mid, begin)\n }\n }\n }\n\n\n\n private[this] var ans = 0\n for (i <- 1 to N-1) {\n if (check(i, i)) {\n val tmp = binarySearch(i, i + (N-i) / 2, i) - (i-1)\n ans = Math.max(ans, tmp)\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", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThe weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ...\n\nGiven is a string S representing the weather in the town today. Predict the weather tomorrow.\n\nConstraints\n\nS is Sunny, Cloudy, or Rainy.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint a string representing the expected weather tomorrow, in the same format in which input is given.\n\nSample Input 1\n\nSunny\n\nSample Output 1\n\nCloudy\n\nIn Takahashi's town, a sunny day is followed by a cloudy day.\n\nSample Input 2\n\nRainy\n\nSample Output 2\n\nSunny", "sample_input": "Sunny\n"}, "reference_outputs": ["Cloudy\n"], "source_document_id": "p02909", "source_text": "Score: 100 points\n\nProblem Statement\n\nThe weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ...\n\nGiven is a string S representing the weather in the town today. Predict the weather tomorrow.\n\nConstraints\n\nS is Sunny, Cloudy, or Rainy.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint a string representing the expected weather tomorrow, in the same format in which input is given.\n\nSample Input 1\n\nSunny\n\nSample Output 1\n\nCloudy\n\nIn Takahashi's town, a sunny day is followed by a cloudy day.\n\nSample Input 2\n\nRainy\n\nSample Output 2\n\nSunny", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2445, "cpu_time_ms": 322, "memory_kb": 25288}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s338841174", "group_id": "codeNet:p02909", "input_text": "object Main extends App {\t\n val in = readLine\n val weather = List(\"Sunny\", \"Cloudy\", \"Rainy\")\n val idx = weather.indexOf(in) + 1\n println(weather(if(idx < weather.length - 1) idx else 0))\n}", "language": "Scala", "metadata": {"date": 1568596759, "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/s338841174.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s338841174", "user_id": "u190068878"}, "prompt_components": {"gold_output": "Cloudy\n", "input_to_evaluate": "object Main extends App {\t\n val in = readLine\n val weather = List(\"Sunny\", \"Cloudy\", \"Rainy\")\n val idx = weather.indexOf(in) + 1\n println(weather(if(idx < weather.length - 1) idx else 0))\n}", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThe weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ...\n\nGiven is a string S representing the weather in the town today. Predict the weather tomorrow.\n\nConstraints\n\nS is Sunny, Cloudy, or Rainy.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint a string representing the expected weather tomorrow, in the same format in which input is given.\n\nSample Input 1\n\nSunny\n\nSample Output 1\n\nCloudy\n\nIn Takahashi's town, a sunny day is followed by a cloudy day.\n\nSample Input 2\n\nRainy\n\nSample Output 2\n\nSunny", "sample_input": "Sunny\n"}, "reference_outputs": ["Cloudy\n"], "source_document_id": "p02909", "source_text": "Score: 100 points\n\nProblem Statement\n\nThe weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ...\n\nGiven is a string S representing the weather in the town today. Predict the weather tomorrow.\n\nConstraints\n\nS is Sunny, Cloudy, or Rainy.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint a string representing the expected weather tomorrow, in the same format in which input is given.\n\nSample Input 1\n\nSunny\n\nSample Output 1\n\nCloudy\n\nIn Takahashi's town, a sunny day is followed by a cloudy day.\n\nSample Input 2\n\nRainy\n\nSample Output 2\n\nSunny", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 193, "cpu_time_ms": 332, "memory_kb": 25536}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s156177795", "group_id": "codeNet:p02910", "input_text": "import java.util.Scanner\n\nobject Main {\n def readable(input: String): Boolean = {\n def readableOdd(str: String) = {\n str match {\n case \"\" => true\n case _ => List('R', 'U', 'D').contains(str.charAt(0)) && readableEven(str.substring(1))\n }\n }\n def readableEven(str: String): Boolean = {\n str match {\n case \"\" => true\n case _ => List('L', 'U', 'D').contains(str.charAt(0)) && readableOdd(str.substring(1))\n }\n }\n input match {\n case \"\" => true\n case _ => readableOdd(input)\n }\n }\n\n def main(args: Array[String]) = {\n val input = new Scanner(System.in).next()\n if(readable(input)) println(\"Yes\")\n else println(\"No\")\n }\n}\n", "language": "Scala", "metadata": {"date": 1568687059, "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/s156177795.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s156177795", "user_id": "u455379185"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def readable(input: String): Boolean = {\n def readableOdd(str: String) = {\n str match {\n case \"\" => true\n case _ => List('R', 'U', 'D').contains(str.charAt(0)) && readableEven(str.substring(1))\n }\n }\n def readableEven(str: String): Boolean = {\n str match {\n case \"\" => true\n case _ => List('L', 'U', 'D').contains(str.charAt(0)) && readableOdd(str.substring(1))\n }\n }\n input match {\n case \"\" => true\n case _ => readableOdd(input)\n }\n }\n\n def main(args: Array[String]) = {\n val input = new Scanner(System.in).next()\n if(readable(input)) println(\"Yes\")\n else println(\"No\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 706, "cpu_time_ms": 333, "memory_kb": 25524}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s970675457", "group_id": "codeNet:p02910", "input_text": "object Main extends App {\t\n val in = readLine.split(\"\").tail\n val evenStr = List(\"R\", \"U\", \"D\")\n val oddStr = List(\"L\", \"U\", \"D\")\n val odd = (1 to in.length - 1 by 2).map(i => in(i)).forall(s => oddStr.contains(s))\n val even = (0 to in.length - 1 by 2).map(i => in(i)).forall(s => evenStr.contains(s))\n println(if(even && odd) \"Yes\" else \"NO\")\n}", "language": "Scala", "metadata": {"date": 1568598341, "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/s970675457.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s970675457", "user_id": "u190068878"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\t\n val in = readLine.split(\"\").tail\n val evenStr = List(\"R\", \"U\", \"D\")\n val oddStr = List(\"L\", \"U\", \"D\")\n val odd = (1 to in.length - 1 by 2).map(i => in(i)).forall(s => oddStr.contains(s))\n val even = (0 to in.length - 1 by 2).map(i => in(i)).forall(s => evenStr.contains(s))\n println(if(even && odd) \"Yes\" else \"NO\")\n}", "problem_context": "Score: 200 points\n\nProblem Statement\n\nTakahashi will do a tap dance. The dance is described by a string S where each character is L, R, U, or D. These characters indicate the positions on which Takahashi should step. He will follow these instructions one by one in order, starting with the first character.\n\nS is said to be easily playable if and only if it satisfies both of the following conditions:\n\nEvery character in an odd position (1-st, 3-rd, 5-th, \\ldots) is R, U, or D.\n\nEvery character in an even position (2-nd, 4-th, 6-th, \\ldots) is L, U, or D.\n\nYour task is to print Yes if S is easily playable, and No otherwise.\n\nConstraints\n\nS is a string of length between 1 and 100 (inclusive).\n\nEach character of S is L, R, U, or D.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint Yes if S is easily playable, and No otherwise.\n\nSample Input 1\n\nRUDLUDR\n\nSample Output 1\n\nYes\n\nEvery character in an odd position (1-st, 3-rd, 5-th, 7-th) is R, U, or D.\n\nEvery character in an even position (2-nd, 4-th, 6-th) is L, U, or D.\n\nThus, S is easily playable.\n\nSample Input 2\n\nDULL\n\nSample Output 2\n\nNo\n\nThe 3-rd character is not R, U, nor D, so S is not easily playable.\n\nSample Input 3\n\nUUUUUUUUUUUUUUU\n\nSample Output 3\n\nYes\n\nSample Input 4\n\nULURU\n\nSample Output 4\n\nNo\n\nSample Input 5\n\nRDULULDURURLRDULRLR\n\nSample Output 5\n\nYes", "sample_input": "RUDLUDR\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02910", "source_text": "Score: 200 points\n\nProblem Statement\n\nTakahashi will do a tap dance. The dance is described by a string S where each character is L, R, U, or D. These characters indicate the positions on which Takahashi should step. He will follow these instructions one by one in order, starting with the first character.\n\nS is said to be easily playable if and only if it satisfies both of the following conditions:\n\nEvery character in an odd position (1-st, 3-rd, 5-th, \\ldots) is R, U, or D.\n\nEvery character in an even position (2-nd, 4-th, 6-th, \\ldots) is L, U, or D.\n\nYour task is to print Yes if S is easily playable, and No otherwise.\n\nConstraints\n\nS is a string of length between 1 and 100 (inclusive).\n\nEach character of S is L, R, U, or D.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint Yes if S is easily playable, and No otherwise.\n\nSample Input 1\n\nRUDLUDR\n\nSample Output 1\n\nYes\n\nEvery character in an odd position (1-st, 3-rd, 5-th, 7-th) is R, U, or D.\n\nEvery character in an even position (2-nd, 4-th, 6-th) is L, U, or D.\n\nThus, S is easily playable.\n\nSample Input 2\n\nDULL\n\nSample Output 2\n\nNo\n\nThe 3-rd character is not R, U, nor D, so S is not easily playable.\n\nSample Input 3\n\nUUUUUUUUUUUUUUU\n\nSample Output 3\n\nYes\n\nSample Input 4\n\nULURU\n\nSample Output 4\n\nNo\n\nSample Input 5\n\nRDULULDURURLRDULRLR\n\nSample Output 5\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 351, "cpu_time_ms": 356, "memory_kb": 27324}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s667852905", "group_id": "codeNet:p02911", "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 k = sc.nextLong\n val q = sc.nextInt\n val array: Array[Long] = Array.fill(q)(sc.nextLong)\n\n (1L to n).map(i => (k - q + array.count(winner => winner == i) > 0)).foreach(isRemainig => {\n if(isRemainig){\n println(\"Yes\")\n }else{\n println(\"No\")\n }\n })\n\n}\n", "language": "Scala", "metadata": {"date": 1576824669, "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/s667852905.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s667852905", "user_id": "u080987909"}, "prompt_components": {"gold_output": "No\nNo\nYes\nNo\nNo\nNo\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 k = sc.nextLong\n val q = sc.nextInt\n val array: Array[Long] = Array.fill(q)(sc.nextLong)\n\n (1L to n).map(i => (k - q + array.count(winner => winner == i) > 0)).foreach(isRemainig => {\n if(isRemainig){\n println(\"Yes\")\n }else{\n println(\"No\")\n }\n })\n\n}\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nTakahashi has decided to hold fastest-finger-fast quiz games. Kizahashi, who is in charge of making the scoreboard, is struggling to write the program that manages the players' scores in a game, which proceeds as follows.\n\nA game is played by N players, numbered 1 to N. At the beginning of a game, each player has K points.\n\nWhen a player correctly answers a question, each of the other N-1 players receives minus one (-1) point. There is no other factor that affects the players' scores.\n\nAt the end of a game, the players with 0 points or lower are eliminated, and the remaining players survive.\n\nIn the last game, the players gave a total of Q correct answers, the i-th of which was given by Player A_i.\nFor Kizahashi, write a program that determines whether each of the N players survived this game.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq K \\leq 10^9\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq A_i \\leq N\\ (1 \\leq i \\leq Q)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K Q\nA_1\nA_2\n.\n.\n.\nA_Q\n\nOutput\n\nPrint N lines. The i-th line should contain Yes if Player i survived the game, and No otherwise.\n\nSample Input 1\n\n6 3 4\n3\n1\n3\n2\n\nSample Output 1\n\nNo\nNo\nYes\nNo\nNo\nNo\n\nIn the beginning, the players' scores are (3, 3, 3, 3, 3, 3).\n\nPlayer 3 correctly answers a question. The players' scores are now (2, 2, 3, 2, 2, 2).\n\nPlayer 1 correctly answers a question. The players' scores are now (2, 1, 2, 1, 1, 1).\n\nPlayer 3 correctly answers a question. The players' scores are now (1, 0, 2, 0, 0, 0).\n\nPlayer 2 correctly answers a question. The players' scores are now (0, 0, 1, -1, -1, -1).\n\nPlayers 1, 2, 4, 5 and 6, who have 0 points or lower, are eliminated, and Player 3 survives this game.\n\nSample Input 2\n\n6 5 4\n3\n1\n3\n2\n\nSample Output 2\n\nYes\nYes\nYes\nYes\nYes\nYes\n\nSample Input 3\n\n10 13 15\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\n\nSample Output 3\n\nNo\nNo\nNo\nNo\nYes\nNo\nNo\nNo\nYes\nNo", "sample_input": "6 3 4\n3\n1\n3\n2\n"}, "reference_outputs": ["No\nNo\nYes\nNo\nNo\nNo\n"], "source_document_id": "p02911", "source_text": "Score: 300 points\n\nProblem Statement\n\nTakahashi has decided to hold fastest-finger-fast quiz games. Kizahashi, who is in charge of making the scoreboard, is struggling to write the program that manages the players' scores in a game, which proceeds as follows.\n\nA game is played by N players, numbered 1 to N. At the beginning of a game, each player has K points.\n\nWhen a player correctly answers a question, each of the other N-1 players receives minus one (-1) point. There is no other factor that affects the players' scores.\n\nAt the end of a game, the players with 0 points or lower are eliminated, and the remaining players survive.\n\nIn the last game, the players gave a total of Q correct answers, the i-th of which was given by Player A_i.\nFor Kizahashi, write a program that determines whether each of the N players survived this game.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq K \\leq 10^9\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq A_i \\leq N\\ (1 \\leq i \\leq Q)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K Q\nA_1\nA_2\n.\n.\n.\nA_Q\n\nOutput\n\nPrint N lines. The i-th line should contain Yes if Player i survived the game, and No otherwise.\n\nSample Input 1\n\n6 3 4\n3\n1\n3\n2\n\nSample Output 1\n\nNo\nNo\nYes\nNo\nNo\nNo\n\nIn the beginning, the players' scores are (3, 3, 3, 3, 3, 3).\n\nPlayer 3 correctly answers a question. The players' scores are now (2, 2, 3, 2, 2, 2).\n\nPlayer 1 correctly answers a question. The players' scores are now (2, 1, 2, 1, 1, 1).\n\nPlayer 3 correctly answers a question. The players' scores are now (1, 0, 2, 0, 0, 0).\n\nPlayer 2 correctly answers a question. The players' scores are now (0, 0, 1, -1, -1, -1).\n\nPlayers 1, 2, 4, 5 and 6, who have 0 points or lower, are eliminated, and Player 3 survives this game.\n\nSample Input 2\n\n6 5 4\n3\n1\n3\n2\n\nSample Output 2\n\nYes\nYes\nYes\nYes\nYes\nYes\n\nSample Input 3\n\n10 13 15\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\n\nSample Output 3\n\nNo\nNo\nNo\nNo\nYes\nNo\nNo\nNo\nYes\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 387, "cpu_time_ms": 2112, "memory_kb": 120860}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s454815236", "group_id": "codeNet:p02911", "input_text": "import scala.io.StdIn.{readLine, readInt}\n\nobject Main extends App {\n val Array(n, k, q) = readLine().split(\" \").map(_.toInt)\n var scores = Array.fill(n)(k)\n\n for (_ <- 1 to q) {\n val answer = readInt - 1\n scores = scores.map(e => e - 1)\n scores(answer) += 1\n }\n\n scores.foreach(e => if (e > 0) println(\"YES\") else println(\"No\"))\n}", "language": "Scala", "metadata": {"date": 1568933310, "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/s454815236.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s454815236", "user_id": "u233347979"}, "prompt_components": {"gold_output": "No\nNo\nYes\nNo\nNo\nNo\n", "input_to_evaluate": "import scala.io.StdIn.{readLine, readInt}\n\nobject Main extends App {\n val Array(n, k, q) = readLine().split(\" \").map(_.toInt)\n var scores = Array.fill(n)(k)\n\n for (_ <- 1 to q) {\n val answer = readInt - 1\n scores = scores.map(e => e - 1)\n scores(answer) += 1\n }\n\n scores.foreach(e => if (e > 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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 116368}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s126433942", "group_id": "codeNet:p02911", "input_text": "\nobject Main extends App {\n import scala.io.StdIn._\n val Array(n, k, q) = readLine.trim.split(' ').map(_.toInt)\n val score = Array.fill(n){k - q}\n for (_ ← 0 until q) {\n val winner = readInt()\n score(winner - 1) += 1\n }\n println(score.map{\n case i if i > 0 ⇒ \"Yes\"\n case _ ⇒ \"No\"\n }.mkString(\"\\n\"))\n}", "language": "Scala", "metadata": {"date": 1568596122, "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/s126433942.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s126433942", "user_id": "u419330815"}, "prompt_components": {"gold_output": "No\nNo\nYes\nNo\nNo\nNo\n", "input_to_evaluate": "\nobject Main extends App {\n import scala.io.StdIn._\n val Array(n, k, q) = readLine.trim.split(' ').map(_.toInt)\n val score = Array.fill(n){k - q}\n for (_ ← 0 until q) {\n val winner = readInt()\n score(winner - 1) += 1\n }\n println(score.map{\n case i if i > 0 ⇒ \"Yes\"\n case _ ⇒ \"No\"\n }.mkString(\"\\n\"))\n}", "problem_context": "Score: 300 points\n\nProblem Statement\n\nTakahashi has decided to hold fastest-finger-fast quiz games. Kizahashi, who is in charge of making the scoreboard, is struggling to write the program that manages the players' scores in a game, which proceeds as follows.\n\nA game is played by N players, numbered 1 to N. At the beginning of a game, each player has K points.\n\nWhen a player correctly answers a question, each of the other N-1 players receives minus one (-1) point. There is no other factor that affects the players' scores.\n\nAt the end of a game, the players with 0 points or lower are eliminated, and the remaining players survive.\n\nIn the last game, the players gave a total of Q correct answers, the i-th of which was given by Player A_i.\nFor Kizahashi, write a program that determines whether each of the N players survived this game.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq K \\leq 10^9\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq A_i \\leq N\\ (1 \\leq i \\leq Q)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K Q\nA_1\nA_2\n.\n.\n.\nA_Q\n\nOutput\n\nPrint N lines. The i-th line should contain Yes if Player i survived the game, and No otherwise.\n\nSample Input 1\n\n6 3 4\n3\n1\n3\n2\n\nSample Output 1\n\nNo\nNo\nYes\nNo\nNo\nNo\n\nIn the beginning, the players' scores are (3, 3, 3, 3, 3, 3).\n\nPlayer 3 correctly answers a question. The players' scores are now (2, 2, 3, 2, 2, 2).\n\nPlayer 1 correctly answers a question. The players' scores are now (2, 1, 2, 1, 1, 1).\n\nPlayer 3 correctly answers a question. The players' scores are now (1, 0, 2, 0, 0, 0).\n\nPlayer 2 correctly answers a question. The players' scores are now (0, 0, 1, -1, -1, -1).\n\nPlayers 1, 2, 4, 5 and 6, who have 0 points or lower, are eliminated, and Player 3 survives this game.\n\nSample Input 2\n\n6 5 4\n3\n1\n3\n2\n\nSample Output 2\n\nYes\nYes\nYes\nYes\nYes\nYes\n\nSample Input 3\n\n10 13 15\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\n\nSample Output 3\n\nNo\nNo\nNo\nNo\nYes\nNo\nNo\nNo\nYes\nNo", "sample_input": "6 3 4\n3\n1\n3\n2\n"}, "reference_outputs": ["No\nNo\nYes\nNo\nNo\nNo\n"], "source_document_id": "p02911", "source_text": "Score: 300 points\n\nProblem Statement\n\nTakahashi has decided to hold fastest-finger-fast quiz games. Kizahashi, who is in charge of making the scoreboard, is struggling to write the program that manages the players' scores in a game, which proceeds as follows.\n\nA game is played by N players, numbered 1 to N. At the beginning of a game, each player has K points.\n\nWhen a player correctly answers a question, each of the other N-1 players receives minus one (-1) point. There is no other factor that affects the players' scores.\n\nAt the end of a game, the players with 0 points or lower are eliminated, and the remaining players survive.\n\nIn the last game, the players gave a total of Q correct answers, the i-th of which was given by Player A_i.\nFor Kizahashi, write a program that determines whether each of the N players survived this game.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq K \\leq 10^9\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq A_i \\leq N\\ (1 \\leq i \\leq Q)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K Q\nA_1\nA_2\n.\n.\n.\nA_Q\n\nOutput\n\nPrint N lines. The i-th line should contain Yes if Player i survived the game, and No otherwise.\n\nSample Input 1\n\n6 3 4\n3\n1\n3\n2\n\nSample Output 1\n\nNo\nNo\nYes\nNo\nNo\nNo\n\nIn the beginning, the players' scores are (3, 3, 3, 3, 3, 3).\n\nPlayer 3 correctly answers a question. The players' scores are now (2, 2, 3, 2, 2, 2).\n\nPlayer 1 correctly answers a question. The players' scores are now (2, 1, 2, 1, 1, 1).\n\nPlayer 3 correctly answers a question. The players' scores are now (1, 0, 2, 0, 0, 0).\n\nPlayer 2 correctly answers a question. The players' scores are now (0, 0, 1, -1, -1, -1).\n\nPlayers 1, 2, 4, 5 and 6, who have 0 points or lower, are eliminated, and Player 3 survives this game.\n\nSample Input 2\n\n6 5 4\n3\n1\n3\n2\n\nSample Output 2\n\nYes\nYes\nYes\nYes\nYes\nYes\n\nSample Input 3\n\n10 13 15\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\n\nSample Output 3\n\nNo\nNo\nNo\nNo\nYes\nNo\nNo\nNo\nYes\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 325, "cpu_time_ms": 632, "memory_kb": 38400}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s724764173", "group_id": "codeNet:p02916", "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 _ = in.readLine().toInt\n val as = in.readLine().split(\"\\\\s+\").map(_.toInt)\n val bs = in.readLine().split(\"\\\\s+\").map(_.toInt)\n val cs = in.readLine().split(\"\\\\s+\").map(_.toInt)\n\n System.out.println(\n bs.sum + as.zip(as.tail).filter {\n case (a1, a2) => a1 + 1 == a2\n }.map {\n case (a1, _) => cs.apply(a1 - 1)\n }.sum\n )\n }\n}\n", "language": "Scala", "metadata": {"date": 1575496563, "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/s724764173.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s724764173", "user_id": "u178269371"}, "prompt_components": {"gold_output": "14\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 _ = in.readLine().toInt\n val as = in.readLine().split(\"\\\\s+\").map(_.toInt)\n val bs = in.readLine().split(\"\\\\s+\").map(_.toInt)\n val cs = in.readLine().split(\"\\\\s+\").map(_.toInt)\n\n System.out.println(\n bs.sum + as.zip(as.tail).filter {\n case (a1, a2) => a1 + 1 == a2\n }.map {\n case (a1, _) => cs.apply(a1 - 1)\n }.sum\n )\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi went to an all-you-can-eat buffet with N kinds of dishes and ate all of them (Dish 1, Dish 2, \\ldots, Dish N) once.\n\nThe i-th dish (1 \\leq i \\leq N) he ate was Dish A_i.\n\nWhen he eats Dish i (1 \\leq i \\leq N), he gains B_i satisfaction points.\n\nAdditionally, when he eats Dish i+1 just after eating Dish i (1 \\leq i \\leq N - 1), he gains C_i more satisfaction points.\n\nFind the sum of the satisfaction points he gained.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 20\n\n1 \\leq A_i \\leq N\n\nA_1, A_2, ..., A_N are all different.\n\n1 \\leq B_i \\leq 50\n\n1 \\leq C_i \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\nB_1 B_2 ... B_N\nC_1 C_2 ... C_{N-1}\n\nOutput\n\nPrint the sum of the satisfaction points Takahashi gained, as an integer.\n\nSample Input 1\n\n3\n3 1 2\n2 5 4\n3 6\n\nSample Output 1\n\n14\n\nTakahashi gained 14 satisfaction points in total, as follows:\n\nFirst, he ate Dish 3 and gained 4 satisfaction points.\n\nNext, he ate Dish 1 and gained 2 satisfaction points.\n\nLastly, he ate Dish 2 and gained 5 + 3 = 8 satisfaction points.\n\nSample Input 2\n\n4\n2 3 4 1\n13 5 8 24\n45 9 15\n\nSample Output 2\n\n74\n\nSample Input 3\n\n2\n1 2\n50 50\n50\n\nSample Output 3\n\n150", "sample_input": "3\n3 1 2\n2 5 4\n3 6\n"}, "reference_outputs": ["14\n"], "source_document_id": "p02916", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi went to an all-you-can-eat buffet with N kinds of dishes and ate all of them (Dish 1, Dish 2, \\ldots, Dish N) once.\n\nThe i-th dish (1 \\leq i \\leq N) he ate was Dish A_i.\n\nWhen he eats Dish i (1 \\leq i \\leq N), he gains B_i satisfaction points.\n\nAdditionally, when he eats Dish i+1 just after eating Dish i (1 \\leq i \\leq N - 1), he gains C_i more satisfaction points.\n\nFind the sum of the satisfaction points he gained.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 20\n\n1 \\leq A_i \\leq N\n\nA_1, A_2, ..., A_N are all different.\n\n1 \\leq B_i \\leq 50\n\n1 \\leq C_i \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\nB_1 B_2 ... B_N\nC_1 C_2 ... C_{N-1}\n\nOutput\n\nPrint the sum of the satisfaction points Takahashi gained, as an integer.\n\nSample Input 1\n\n3\n3 1 2\n2 5 4\n3 6\n\nSample Output 1\n\n14\n\nTakahashi gained 14 satisfaction points in total, as follows:\n\nFirst, he ate Dish 3 and gained 4 satisfaction points.\n\nNext, he ate Dish 1 and gained 2 satisfaction points.\n\nLastly, he ate Dish 2 and gained 5 + 3 = 8 satisfaction points.\n\nSample Input 2\n\n4\n2 3 4 1\n13 5 8 24\n45 9 15\n\nSample Output 2\n\n74\n\nSample Input 3\n\n2\n1 2\n50 50\n50\n\nSample Output 3\n\n150", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 550, "cpu_time_ms": 332, "memory_kb": 27204}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s069387073", "group_id": "codeNet:p02921", "input_text": "object Main extends App {\n val forecast = scala.io.StdIn.readLine.toList\n val actual = scala.io.StdIn.readLine.toList\n val zipped = forecast zip actual\n val answer = zipped count { z => z._1 == z._2 }\n println(answer)\n}", "language": "Scala", "metadata": {"date": 1583170702, "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/s069387073.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s069387073", "user_id": "u102400818"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n val forecast = scala.io.StdIn.readLine.toList\n val actual = scala.io.StdIn.readLine.toList\n val zipped = forecast zip actual\n val answer = zipped count { z => z._1 == z._2 }\n println(answer)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou will be given a string S of length 3 representing the weather forecast for three days in the past.\n\nThe i-th character (1 \\leq i \\leq 3) of S represents the forecast for the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\n\nYou will also be given a string T of length 3 representing the actual weather on those three days.\n\nThe i-th character (1 \\leq i \\leq 3) of S represents the actual weather on the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\n\nPrint the number of days for which the forecast was correct.\n\nConstraints\n\nS and T are strings of length 3 each.\n\nS and T consist of S, C, and R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the number of days for which the forecast was correct.\n\nSample Input 1\n\nCSS\nCSR\n\nSample Output 1\n\n2\n\nFor the first day, it was forecast to be cloudy, and it was indeed cloudy.\n\nFor the second day, it was forecast to be sunny, and it was indeed sunny.\n\nFor the third day, it was forecast to be sunny, but it was rainy.\n\nThus, the forecast was correct for two days in this case.\n\nSample Input 2\n\nSSR\nSSR\n\nSample Output 2\n\n3\n\nSample Input 3\n\nRRR\nSSS\n\nSample Output 3\n\n0", "sample_input": "CSS\nCSR\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02921", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou will be given a string S of length 3 representing the weather forecast for three days in the past.\n\nThe i-th character (1 \\leq i \\leq 3) of S represents the forecast for the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\n\nYou will also be given a string T of length 3 representing the actual weather on those three days.\n\nThe i-th character (1 \\leq i \\leq 3) of S represents the actual weather on the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\n\nPrint the number of days for which the forecast was correct.\n\nConstraints\n\nS and T are strings of length 3 each.\n\nS and T consist of S, C, and R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the number of days for which the forecast was correct.\n\nSample Input 1\n\nCSS\nCSR\n\nSample Output 1\n\n2\n\nFor the first day, it was forecast to be cloudy, and it was indeed cloudy.\n\nFor the second day, it was forecast to be sunny, and it was indeed sunny.\n\nFor the third day, it was forecast to be sunny, but it was rainy.\n\nThus, the forecast was correct for two days in this case.\n\nSample Input 2\n\nSSR\nSSR\n\nSample Output 2\n\n3\n\nSample Input 3\n\nRRR\nSSS\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 224, "cpu_time_ms": 322, "memory_kb": 27352}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s449843124", "group_id": "codeNet:p02921", "input_text": "object Main {\n def main(args: Array[String]): Unit ={\n val sc = new java.util.Scanner(System.in)\n val s = sc.nextLine()\n val t = sc.nextLine()\n\n var cnt = 0\n for(i <- 0 to 2){\n if(s.charAt(i) == t.charAt(i)) cnt+=1\n }\n\n println(cnt)\n }\n}", "language": "Scala", "metadata": {"date": 1568552048, "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/s449843124.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s449843124", "user_id": "u526532903"}, "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 s = sc.nextLine()\n val t = sc.nextLine()\n\n var cnt = 0\n for(i <- 0 to 2){\n if(s.charAt(i) == t.charAt(i)) cnt+=1\n }\n\n println(cnt)\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou will be given a string S of length 3 representing the weather forecast for three days in the past.\n\nThe i-th character (1 \\leq i \\leq 3) of S represents the forecast for the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\n\nYou will also be given a string T of length 3 representing the actual weather on those three days.\n\nThe i-th character (1 \\leq i \\leq 3) of S represents the actual weather on the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\n\nPrint the number of days for which the forecast was correct.\n\nConstraints\n\nS and T are strings of length 3 each.\n\nS and T consist of S, C, and R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the number of days for which the forecast was correct.\n\nSample Input 1\n\nCSS\nCSR\n\nSample Output 1\n\n2\n\nFor the first day, it was forecast to be cloudy, and it was indeed cloudy.\n\nFor the second day, it was forecast to be sunny, and it was indeed sunny.\n\nFor the third day, it was forecast to be sunny, but it was rainy.\n\nThus, the forecast was correct for two days in this case.\n\nSample Input 2\n\nSSR\nSSR\n\nSample Output 2\n\n3\n\nSample Input 3\n\nRRR\nSSS\n\nSample Output 3\n\n0", "sample_input": "CSS\nCSR\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02921", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou will be given a string S of length 3 representing the weather forecast for three days in the past.\n\nThe i-th character (1 \\leq i \\leq 3) of S represents the forecast for the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\n\nYou will also be given a string T of length 3 representing the actual weather on those three days.\n\nThe i-th character (1 \\leq i \\leq 3) of S represents the actual weather on the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\n\nPrint the number of days for which the forecast was correct.\n\nConstraints\n\nS and T are strings of length 3 each.\n\nS and T consist of S, C, and R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the number of days for which the forecast was correct.\n\nSample Input 1\n\nCSS\nCSR\n\nSample Output 1\n\n2\n\nFor the first day, it was forecast to be cloudy, and it was indeed cloudy.\n\nFor the second day, it was forecast to be sunny, and it was indeed sunny.\n\nFor the third day, it was forecast to be sunny, but it was rainy.\n\nThus, the forecast was correct for two days in this case.\n\nSample Input 2\n\nSSR\nSSR\n\nSample Output 2\n\n3\n\nSample Input 3\n\nRRR\nSSS\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 265, "cpu_time_ms": 349, "memory_kb": 26008}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s744524031", "group_id": "codeNet:p02922", "input_text": "import java.util.Scanner\n\n\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 Math.floor(b / a).toInt\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": 1567365644, "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/s744524031.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s744524031", "user_id": "u947008426"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Scanner\n\n\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 Math.floor(b / a).toInt\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 : 200 points\n\nProblem Statement\n\nTakahashi's house has only one socket.\n\nTakahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.\n\nOne power strip with A sockets can extend one empty socket into A empty sockets.\n\nFind the minimum number of power strips required.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq A \\leq 20\n\n1 \\leq B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the minimum number of power strips required.\n\nSample Input 1\n\n4 10\n\nSample Output 1\n\n3\n\n3 power strips, each with 4 sockets, extend the socket into 10 empty sockets.\n\nSample Input 2\n\n8 9\n\nSample Output 2\n\n2\n\n2 power strips, each with 8 sockets, extend the socket into 15 empty sockets.\n\nSample Input 3\n\n8 8\n\nSample Output 3\n\n1", "sample_input": "4 10\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02922", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi's house has only one socket.\n\nTakahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.\n\nOne power strip with A sockets can extend one empty socket into A empty sockets.\n\nFind the minimum number of power strips required.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq A \\leq 20\n\n1 \\leq B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the minimum number of power strips required.\n\nSample Input 1\n\n4 10\n\nSample Output 1\n\n3\n\n3 power strips, each with 4 sockets, extend the socket into 10 empty sockets.\n\nSample Input 2\n\n8 9\n\nSample Output 2\n\n2\n\n2 power strips, each with 8 sockets, extend the socket into 15 empty sockets.\n\nSample Input 3\n\n8 8\n\nSample Output 3\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 343, "cpu_time_ms": 351, "memory_kb": 25920}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s749984898", "group_id": "codeNet:p02923", "input_text": "object Main extends App {\n val input = scala.io.Source.stdin.getLines.toList\n val n = input(0).toInt\n val stairs = input(1).split(\" \").map(_.toInt)\n var max = 0\n var current = 0\n for (i <- 0 until n - 1) {\n if (stairs(i) >= stairs(i + 1))\n current = current + 1\n else {\n if (current > max) {\n max = current\n }\n current = 0\n }\n }\n if (current > max)\n max = current\n \n println(max)\n}", "language": "Scala", "metadata": {"date": 1583422895, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/s749984898.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s749984898", "user_id": "u102400818"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n val input = scala.io.Source.stdin.getLines.toList\n val n = input(0).toInt\n val stairs = input(1).split(\" \").map(_.toInt)\n var max = 0\n var current = 0\n for (i <- 0 until n - 1) {\n if (stairs(i) >= stairs(i + 1))\n current = current + 1\n else {\n if (current > max) {\n max = current\n }\n current = 0\n }\n }\n if (current > max)\n max = current\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 519, "memory_kb": 46876}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s781136448", "group_id": "codeNet:p02923", "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 v = new Array[Long](n)\n for (i <- 0 until n) {\n v(i) = sc.nextLong\n }\n var count = 0\n var max = 0\n for (i <- 0 until n - 1) {\n if (v(i) >= v(i + 1)) {\n count += 1\n max = math.max(max, count)\n } else {\n count = 0\n }\n }\n\n println(max)\n }\n}\n", "language": "Scala", "metadata": {"date": 1581507478, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/s781136448.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s781136448", "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 solve(): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val v = new Array[Long](n)\n for (i <- 0 until n) {\n v(i) = sc.nextLong\n }\n var count = 0\n var max = 0\n for (i <- 0 until n - 1) {\n if (v(i) >= v(i + 1)) {\n count += 1\n max = math.max(max, count)\n } else {\n count = 0\n }\n }\n\n println(max)\n }\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 473, "cpu_time_ms": 699, "memory_kb": 53512}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s147061570", "group_id": "codeNet:p02923", "input_text": "object Main extends App {\n var n = readLine.toInt\n val in = readLine().split(\" \").map(i => i.toInt)\n var a = 0\n while (in(n - 2) >= in(n - 1)) {\n n -= 1\n \ta += 1\n }\n println(a)\n}", "language": "Scala", "metadata": {"date": 1567368069, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/s147061570.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s147061570", "user_id": "u190068878"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n var n = readLine.toInt\n val in = readLine().split(\" \").map(i => i.toInt)\n var a = 0\n while (in(n - 2) >= in(n - 1)) {\n n -= 1\n \ta += 1\n }\n println(a)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 507, "memory_kb": 44920}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s966184732", "group_id": "codeNet:p02934", "input_text": "object Main extends App {\n val N = io.StdIn.readInt()\n val numArray = io.StdIn.readLine().split(\" \").map(_.toFloat).map(1/_)\n println(1/numArray.sum)\n}", "language": "Scala", "metadata": {"date": 1566187540, "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/s966184732.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s966184732", "user_id": "u941028483"}, "prompt_components": {"gold_output": "7.5\n", "input_to_evaluate": "object Main extends App {\n val N = io.StdIn.readInt()\n val numArray = io.StdIn.readLine().split(\" \").map(_.toFloat).map(1/_)\n println(1/numArray.sum)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven is a sequence of N integers A_1, \\ldots, A_N.\n\nFind the (multiplicative) inverse of the sum of the inverses of these numbers, \\frac{1}{\\frac{1}{A_1} + \\ldots + \\frac{1}{A_N}}.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\ldots A_N\n\nOutput\n\nPrint a decimal number (or an integer) representing the value of \\frac{1}{\\frac{1}{A_1} + \\ldots + \\frac{1}{A_N}}.\n\nYour output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n10 30\n\nSample Output 1\n\n7.5\n\n\\frac{1}{\\frac{1}{10} + \\frac{1}{30}} = \\frac{1}{\\frac{4}{30}} = \\frac{30}{4} = 7.5.\n\nPrinting 7.50001, 7.49999, and so on will also be accepted.\n\nSample Input 2\n\n3\n200 200 200\n\nSample Output 2\n\n66.66666666666667\n\n\\frac{1}{\\frac{1}{200} + \\frac{1}{200} + \\frac{1}{200}} = \\frac{1}{\\frac{3}{200}} = \\frac{200}{3} = 66.6666....\n\nPrinting 6.66666e+1 and so on will also be accepted.\n\nSample Input 3\n\n1\n1000\n\nSample Output 3\n\n1000\n\n\\frac{1}{\\frac{1}{1000}} = 1000.\n\nPrinting +1000.0 and so on will also be accepted.", "sample_input": "2\n10 30\n"}, "reference_outputs": ["7.5\n"], "source_document_id": "p02934", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven is a sequence of N integers A_1, \\ldots, A_N.\n\nFind the (multiplicative) inverse of the sum of the inverses of these numbers, \\frac{1}{\\frac{1}{A_1} + \\ldots + \\frac{1}{A_N}}.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\ldots A_N\n\nOutput\n\nPrint a decimal number (or an integer) representing the value of \\frac{1}{\\frac{1}{A_1} + \\ldots + \\frac{1}{A_N}}.\n\nYour output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n10 30\n\nSample Output 1\n\n7.5\n\n\\frac{1}{\\frac{1}{10} + \\frac{1}{30}} = \\frac{1}{\\frac{4}{30}} = \\frac{30}{4} = 7.5.\n\nPrinting 7.50001, 7.49999, and so on will also be accepted.\n\nSample Input 2\n\n3\n200 200 200\n\nSample Output 2\n\n66.66666666666667\n\n\\frac{1}{\\frac{1}{200} + \\frac{1}{200} + \\frac{1}{200}} = \\frac{1}{\\frac{3}{200}} = \\frac{200}{3} = 66.6666....\n\nPrinting 6.66666e+1 and so on will also be accepted.\n\nSample Input 3\n\n1\n1000\n\nSample Output 3\n\n1000\n\n\\frac{1}{\\frac{1}{1000}} = 1000.\n\nPrinting +1000.0 and so on will also be accepted.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 154, "cpu_time_ms": 324, "memory_kb": 25548}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s678481354", "group_id": "codeNet:p02934", "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.nextDouble())\n\n println(1 / A.map(1 / _).sum)\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1566176626, "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/s678481354.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s678481354", "user_id": "u891387249"}, "prompt_components": {"gold_output": "7.5\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.nextDouble())\n\n println(1 / A.map(1 / _).sum)\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 214, "cpu_time_ms": 360, "memory_kb": 25796}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s984800393", "group_id": "codeNet:p02935", "input_text": "object Main extends App {\n val n = scala.io.StdIn.readInt\n val v = scala.io.StdIn.readLine.split(\" \").map(_.toDouble).sorted\n \n println(v.reduce((e1,e2) => (e1 +e2) / 2.0))\n}", "language": "Scala", "metadata": {"date": 1589440153, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/s984800393.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s984800393", "user_id": "u104354966"}, "prompt_components": {"gold_output": "3.5\n", "input_to_evaluate": "object Main extends App {\n val n = scala.io.StdIn.readInt\n val v = scala.io.StdIn.readLine.split(\" \").map(_.toDouble).sorted\n \n println(v.reduce((e1,e2) => (e1 +e2) / 2.0))\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou have a pot and N ingredients. Each ingredient has a real number parameter called value, and the value of the i-th ingredient (1 \\leq i \\leq N) is v_i.\n\nWhen you put two ingredients in the pot, they will vanish and result in the formation of a new ingredient. The value of the new ingredient will be (x + y) / 2 where x and y are the values of the ingredients consumed, and you can put this ingredient again in the pot.\n\nAfter you compose ingredients in this way N-1 times, you will end up with one ingredient. Find the maximum possible value of this ingredient.\n\nConstraints\n\n2 \\leq N \\leq 50\n\n1 \\leq v_i \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nv_1 v_2 \\ldots v_N\n\nOutput\n\nPrint a decimal number (or an integer) representing the maximum possible value of the last ingredient remaining.\n\nYour output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n3 4\n\nSample Output 1\n\n3.5\n\nIf you start with two ingredients, the only choice is to put both of them in the pot. The value of the ingredient resulting from the ingredients of values 3 and 4 is (3 + 4) / 2 = 3.5.\n\nPrinting 3.50001, 3.49999, and so on will also be accepted.\n\nSample Input 2\n\n3\n500 300 200\n\nSample Output 2\n\n375\n\nYou start with three ingredients this time, and you can choose what to use in the first composition. There are three possible choices:\n\nUse the ingredients of values 500 and 300 to produce an ingredient of value (500 + 300) / 2 = 400. The next composition will use this ingredient and the ingredient of value 200, resulting in an ingredient of value (400 + 200) / 2 = 300.\n\nUse the ingredients of values 500 and 200 to produce an ingredient of value (500 + 200) / 2 = 350. The next composition will use this ingredient and the ingredient of value 300, resulting in an ingredient of value (350 + 300) / 2 = 325.\n\nUse the ingredients of values 300 and 200 to produce an ingredient of value (300 + 200) / 2 = 250. The next composition will use this ingredient and the ingredient of value 500, resulting in an ingredient of value (250 + 500) / 2 = 375.\n\nThus, the maximum possible value of the last ingredient remaining is 375.\n\nPrinting 375.0 and so on will also be accepted.\n\nSample Input 3\n\n5\n138 138 138 138 138\n\nSample Output 3\n\n138", "sample_input": "2\n3 4\n"}, "reference_outputs": ["3.5\n"], "source_document_id": "p02935", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou have a pot and N ingredients. Each ingredient has a real number parameter called value, and the value of the i-th ingredient (1 \\leq i \\leq N) is v_i.\n\nWhen you put two ingredients in the pot, they will vanish and result in the formation of a new ingredient. The value of the new ingredient will be (x + y) / 2 where x and y are the values of the ingredients consumed, and you can put this ingredient again in the pot.\n\nAfter you compose ingredients in this way N-1 times, you will end up with one ingredient. Find the maximum possible value of this ingredient.\n\nConstraints\n\n2 \\leq N \\leq 50\n\n1 \\leq v_i \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nv_1 v_2 \\ldots v_N\n\nOutput\n\nPrint a decimal number (or an integer) representing the maximum possible value of the last ingredient remaining.\n\nYour output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n3 4\n\nSample Output 1\n\n3.5\n\nIf you start with two ingredients, the only choice is to put both of them in the pot. The value of the ingredient resulting from the ingredients of values 3 and 4 is (3 + 4) / 2 = 3.5.\n\nPrinting 3.50001, 3.49999, and so on will also be accepted.\n\nSample Input 2\n\n3\n500 300 200\n\nSample Output 2\n\n375\n\nYou start with three ingredients this time, and you can choose what to use in the first composition. There are three possible choices:\n\nUse the ingredients of values 500 and 300 to produce an ingredient of value (500 + 300) / 2 = 400. The next composition will use this ingredient and the ingredient of value 200, resulting in an ingredient of value (400 + 200) / 2 = 300.\n\nUse the ingredients of values 500 and 200 to produce an ingredient of value (500 + 200) / 2 = 350. The next composition will use this ingredient and the ingredient of value 300, resulting in an ingredient of value (350 + 300) / 2 = 325.\n\nUse the ingredients of values 300 and 200 to produce an ingredient of value (300 + 200) / 2 = 250. The next composition will use this ingredient and the ingredient of value 500, resulting in an ingredient of value (250 + 500) / 2 = 375.\n\nThus, the maximum possible value of the last ingredient remaining is 375.\n\nPrinting 375.0 and so on will also be accepted.\n\nSample Input 3\n\n5\n138 138 138 138 138\n\nSample Output 3\n\n138", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 186, "cpu_time_ms": 499, "memory_kb": 55036}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s854188903", "group_id": "codeNet:p02935", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new java.util.Scanner(System.in)\n val itemCount: Int = sc.nextInt\n val items = List.fill(itemCount)(sc.nextInt).map(_.toDouble).sortWith(_.compareTo(_) < 0)\n println(items)\n val ans = items.fold(items(0))((acc, curr) => ( acc + curr ) / 2)\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1570658167, "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/s854188903.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s854188903", "user_id": "u624523023"}, "prompt_components": {"gold_output": "3.5\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new java.util.Scanner(System.in)\n val itemCount: Int = sc.nextInt\n val items = List.fill(itemCount)(sc.nextInt).map(_.toDouble).sortWith(_.compareTo(_) < 0)\n println(items)\n val ans = items.fold(items(0))((acc, curr) => ( acc + curr ) / 2)\n println(ans)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou have a pot and N ingredients. Each ingredient has a real number parameter called value, and the value of the i-th ingredient (1 \\leq i \\leq N) is v_i.\n\nWhen you put two ingredients in the pot, they will vanish and result in the formation of a new ingredient. The value of the new ingredient will be (x + y) / 2 where x and y are the values of the ingredients consumed, and you can put this ingredient again in the pot.\n\nAfter you compose ingredients in this way N-1 times, you will end up with one ingredient. Find the maximum possible value of this ingredient.\n\nConstraints\n\n2 \\leq N \\leq 50\n\n1 \\leq v_i \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nv_1 v_2 \\ldots v_N\n\nOutput\n\nPrint a decimal number (or an integer) representing the maximum possible value of the last ingredient remaining.\n\nYour output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n3 4\n\nSample Output 1\n\n3.5\n\nIf you start with two ingredients, the only choice is to put both of them in the pot. The value of the ingredient resulting from the ingredients of values 3 and 4 is (3 + 4) / 2 = 3.5.\n\nPrinting 3.50001, 3.49999, and so on will also be accepted.\n\nSample Input 2\n\n3\n500 300 200\n\nSample Output 2\n\n375\n\nYou start with three ingredients this time, and you can choose what to use in the first composition. There are three possible choices:\n\nUse the ingredients of values 500 and 300 to produce an ingredient of value (500 + 300) / 2 = 400. The next composition will use this ingredient and the ingredient of value 200, resulting in an ingredient of value (400 + 200) / 2 = 300.\n\nUse the ingredients of values 500 and 200 to produce an ingredient of value (500 + 200) / 2 = 350. The next composition will use this ingredient and the ingredient of value 300, resulting in an ingredient of value (350 + 300) / 2 = 325.\n\nUse the ingredients of values 300 and 200 to produce an ingredient of value (300 + 200) / 2 = 250. The next composition will use this ingredient and the ingredient of value 500, resulting in an ingredient of value (250 + 500) / 2 = 375.\n\nThus, the maximum possible value of the last ingredient remaining is 375.\n\nPrinting 375.0 and so on will also be accepted.\n\nSample Input 3\n\n5\n138 138 138 138 138\n\nSample Output 3\n\n138", "sample_input": "2\n3 4\n"}, "reference_outputs": ["3.5\n"], "source_document_id": "p02935", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou have a pot and N ingredients. Each ingredient has a real number parameter called value, and the value of the i-th ingredient (1 \\leq i \\leq N) is v_i.\n\nWhen you put two ingredients in the pot, they will vanish and result in the formation of a new ingredient. The value of the new ingredient will be (x + y) / 2 where x and y are the values of the ingredients consumed, and you can put this ingredient again in the pot.\n\nAfter you compose ingredients in this way N-1 times, you will end up with one ingredient. Find the maximum possible value of this ingredient.\n\nConstraints\n\n2 \\leq N \\leq 50\n\n1 \\leq v_i \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nv_1 v_2 \\ldots v_N\n\nOutput\n\nPrint a decimal number (or an integer) representing the maximum possible value of the last ingredient remaining.\n\nYour output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n3 4\n\nSample Output 1\n\n3.5\n\nIf you start with two ingredients, the only choice is to put both of them in the pot. The value of the ingredient resulting from the ingredients of values 3 and 4 is (3 + 4) / 2 = 3.5.\n\nPrinting 3.50001, 3.49999, and so on will also be accepted.\n\nSample Input 2\n\n3\n500 300 200\n\nSample Output 2\n\n375\n\nYou start with three ingredients this time, and you can choose what to use in the first composition. There are three possible choices:\n\nUse the ingredients of values 500 and 300 to produce an ingredient of value (500 + 300) / 2 = 400. The next composition will use this ingredient and the ingredient of value 200, resulting in an ingredient of value (400 + 200) / 2 = 300.\n\nUse the ingredients of values 500 and 200 to produce an ingredient of value (500 + 200) / 2 = 350. The next composition will use this ingredient and the ingredient of value 300, resulting in an ingredient of value (350 + 300) / 2 = 325.\n\nUse the ingredients of values 300 and 200 to produce an ingredient of value (300 + 200) / 2 = 250. The next composition will use this ingredient and the ingredient of value 500, resulting in an ingredient of value (250 + 500) / 2 = 375.\n\nThus, the maximum possible value of the last ingredient remaining is 375.\n\nPrinting 375.0 and so on will also be accepted.\n\nSample Input 3\n\n5\n138 138 138 138 138\n\nSample Output 3\n\n138", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 323, "cpu_time_ms": 337, "memory_kb": 25540}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s414251272", "group_id": "codeNet:p02935", "input_text": "\n\nimport scala.io.StdIn\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n\n val n = StdIn.readLine().toInt\n val vs = StdIn.readLine().split(' ').toVector.map(_.toDouble).sorted\n assert(!vs.isEmpty)\n val ans = vs.tail.foldLeft(vs.head)((acc, v) => (acc + v) / 2)\n println(ans)\n\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1566221535, "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/s414251272.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s414251272", "user_id": "u252817963"}, "prompt_components": {"gold_output": "3.5\n", "input_to_evaluate": "\n\nimport scala.io.StdIn\n\nobject Main {\n\n def main(args: Array[String]): Unit = {\n\n val n = StdIn.readLine().toInt\n val vs = StdIn.readLine().split(' ').toVector.map(_.toDouble).sorted\n assert(!vs.isEmpty)\n val ans = vs.tail.foldLeft(vs.head)((acc, v) => (acc + v) / 2)\n println(ans)\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 332, "memory_kb": 25416}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s768242920", "group_id": "codeNet:p02945", "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 A, B = ni()\n val ans = max(A + B, max(A - B, A * B))\n out.println(ans)\n }\n}", "language": "Scala", "metadata": {"date": 1565485418, "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/s768242920.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s768242920", "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 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 A, B = ni()\n val ans = max(A + B, max(A - B, A * B))\n out.println(ans)\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have two integers: A and B.\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nConstraints\n\nAll values in input are integers.\n\n-100 \\leq A,\\ B \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nSample Input 1\n\n-13 3\n\nSample Output 1\n\n-10\n\nThe largest number among A + B = -10, A - B = -16, and A \\times B = -39 is -10.\n\nSample Input 2\n\n1 -33\n\nSample Output 2\n\n34\n\nThe largest number among A + B = -32, A - B = 34, and A \\times B = -33 is 34.\n\nSample Input 3\n\n13 3\n\nSample Output 3\n\n39\n\nThe largest number among A + B = 16, A - B = 10, and A \\times B = 39 is 39.", "sample_input": "-13 3\n"}, "reference_outputs": ["-10\n"], "source_document_id": "p02945", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have two integers: A and B.\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nConstraints\n\nAll values in input are integers.\n\n-100 \\leq A,\\ B \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nSample Input 1\n\n-13 3\n\nSample Output 1\n\n-10\n\nThe largest number among A + B = -10, A - B = -16, and A \\times B = -39 is -10.\n\nSample Input 2\n\n1 -33\n\nSample Output 2\n\n34\n\nThe largest number among A + B = -32, A - B = 34, and A \\times B = -33 is 34.\n\nSample Input 3\n\n13 3\n\nSample Output 3\n\n39\n\nThe largest number among A + B = 16, A - B = 10, and A \\times B = 39 is 39.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3697, "cpu_time_ms": 335, "memory_kb": 25664}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s131059411", "group_id": "codeNet:p02946", "input_text": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n val Array(k, x) = readLine().split(' ').map(_.toInt)\n val excludeK = k - 1\n println((x - excludeK to x + excludeK).mkString(\" \"))\n}", "language": "Scala", "metadata": {"date": 1596485604, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/s131059411.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s131059411", "user_id": "u598844232"}, "prompt_components": {"gold_output": "5 6 7 8 9\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n val Array(k, x) = readLine().split(' ').map(_.toInt)\n val excludeK = k - 1\n println((x - excludeK to x + excludeK).mkString(\" \"))\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 502, "memory_kb": 54788}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s407290759", "group_id": "codeNet:p02946", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val k, x = sc.nextInt\n val min = x - k + 1\n val max = x + k - 1\n println((min to max).mkString(\" \"))\n}\n", "language": "Scala", "metadata": {"date": 1577249537, "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/s407290759.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s407290759", "user_id": "u080987909"}, "prompt_components": {"gold_output": "5 6 7 8 9\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val k, x = sc.nextInt\n val min = x - k + 1\n val max = x + k - 1\n println((min to max).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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 194, "cpu_time_ms": 339, "memory_kb": 27452}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s329968093", "group_id": "codeNet:p02947", "input_text": "object Main{\n def main(args: Array[String]) : Unit = {\nval arr1 = io.StdIn.readLine().split(' ')\n val n = arr1(0).toInt\n var mm = scala.collection.mutable.HashMap.empty[String, Long]\n\n (0 until n).foreach{\n i =>\n val s = io.StdIn.readLine().toString\n val str = s.sorted\n\n if(mm.contains(str)){\n mm(str) = mm(str) + 1L\n }else{\n mm.update(str, 0L)\n }\n }\n\n var max: Long = mm.values.map(i => (0L to i).sum).sum\n\n println(max)\n }\n}", "language": "Scala", "metadata": {"date": 1565490265, "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/s329968093.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s329968093", "user_id": "u173561231"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main{\n def main(args: Array[String]) : Unit = {\nval arr1 = io.StdIn.readLine().split(' ')\n val n = arr1(0).toInt\n var mm = scala.collection.mutable.HashMap.empty[String, Long]\n\n (0 until n).foreach{\n i =>\n val s = io.StdIn.readLine().toString\n val str = s.sorted\n\n if(mm.contains(str)){\n mm(str) = mm(str) + 1L\n }else{\n mm.update(str, 0L)\n }\n }\n\n var max: Long = mm.values.map(i => (0L to i).sum).sum\n\n println(max)\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1028, "memory_kb": 56236}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s581873967", "group_id": "codeNet:p02947", "input_text": "object Main extends App {\n val n = scala.io.StdIn.readInt()\n var sArray = Vector.empty[String]\n (1 to n).foreach { _ =>\n val readS = scala.io.StdIn.readLine()\n sArray :+= readS.sorted\n }\n val result = sArray.groupBy(s => s).map(s => s._2.size).filter(_ >= 2).map(s => ( (s * (s - 1)) / 2 ).toLong).sum\n println(result)\n}", "language": "Scala", "metadata": {"date": 1565488384, "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/s581873967.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s581873967", "user_id": "u105921924"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main extends App {\n val n = scala.io.StdIn.readInt()\n var sArray = Vector.empty[String]\n (1 to n).foreach { _ =>\n val readS = scala.io.StdIn.readLine()\n sArray :+= readS.sorted\n }\n val result = sArray.groupBy(s => s).map(s => s._2.size).filter(_ >= 2).map(s => ( (s * (s - 1)) / 2 ).toLong).sum\n println(result)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 332, "cpu_time_ms": 1483, "memory_kb": 128216}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s312980750", "group_id": "codeNet:p02947", "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(); sc.nextLine()\n val S = List.fill(N)(sc.nextLine()).map(_.sorted)\n val count =\n scala.collection.mutable.Map[String, Int](\n S.groupBy(identity).mapValues(_.length - 1).toSeq: _*)\n\n var r = BigInt(0)\n var i = 0\n while (i < N) {\n val c = count(S(i))\n if (c > 0) {\n r += c\n count.update(S(i), c - 1)\n }\n i += 1\n }\n\n println(r)\n }\n\n}", "language": "Scala", "metadata": {"date": 1565486833, "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/s312980750.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s312980750", "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 val N = sc.nextInt(); sc.nextLine()\n val S = List.fill(N)(sc.nextLine()).map(_.sorted)\n val count =\n scala.collection.mutable.Map[String, Int](\n S.groupBy(identity).mapValues(_.length - 1).toSeq: _*)\n\n var r = BigInt(0)\n var i = 0\n while (i < N) {\n val c = count(S(i))\n if (c > 0) {\n r += c\n count.update(S(i), c - 1)\n }\n i += 1\n }\n\n println(r)\n }\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 526, "cpu_time_ms": 2111, "memory_kb": 154416}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s911472734", "group_id": "codeNet:p02948", "input_text": "import scala.io.StdIn._\nimport scala.collection.mutable.{ArrayBuffer, PriorityQueue}\nobject Main extends App {\n val Array(n, m) = readLine.split(\" \").map(_.toInt)\n val arbeits = Array.fill(m + 1)(new ArrayBuffer[Int]())\n for (i <- 1 to n) {\n val Array(a, b) = readLine.split(\" \").map(_.toInt)\n arbeits(a) += b\n }\n\n def exec(day: Int, possible: PriorityQueue[Int], income: Int): Int = {\n println(s\"$day, $possible, $income\")\n if (day > m) income\n else {\n val newPossible = possible ++ arbeits(day)\n if (newPossible.isEmpty) {\n exec(day + 1, newPossible, income)\n } else {\n val a = newPossible.dequeue()\n exec(day + 1, newPossible, income + a)\n }\n }\n }\n\n println(exec(1, PriorityQueue[Int](), 0))\n}", "language": "Scala", "metadata": {"date": 1574370604, "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/s911472734.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s911472734", "user_id": "u132324749"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import scala.io.StdIn._\nimport scala.collection.mutable.{ArrayBuffer, PriorityQueue}\nobject Main extends App {\n val Array(n, m) = readLine.split(\" \").map(_.toInt)\n val arbeits = Array.fill(m + 1)(new ArrayBuffer[Int]())\n for (i <- 1 to n) {\n val Array(a, b) = readLine.split(\" \").map(_.toInt)\n arbeits(a) += b\n }\n\n def exec(day: Int, possible: PriorityQueue[Int], income: Int): Int = {\n println(s\"$day, $possible, $income\")\n if (day > m) income\n else {\n val newPossible = possible ++ arbeits(day)\n if (newPossible.isEmpty) {\n exec(day + 1, newPossible, income)\n } else {\n val a = newPossible.dequeue()\n exec(day + 1, newPossible, income + a)\n }\n }\n }\n\n println(exec(1, PriorityQueue[Int](), 0))\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.\n\nYou can take and complete at most one of these jobs in a day.\n\nHowever, you cannot retake a job that you have already done.\n\nFind the maximum total reward that you can earn no later than M days from today.\n\nYou can already start working today.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i \\leq 10^5\n\n1 \\leq B_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_N B_N\n\nOutput\n\nPrint the maximum total reward that you can earn no later than M days from today.\n\nSample Input 1\n\n3 4\n4 3\n4 1\n2 2\n\nSample Output 1\n\n5\n\nYou can earn the total reward of 5 by taking the jobs as follows:\n\nTake and complete the first job today. You will earn the reward of 3 after four days from today.\n\nTake and complete the third job tomorrow. You will earn the reward of 2 after two days from tomorrow, that is, after three days from today.\n\nSample Input 2\n\n5 3\n1 2\n1 3\n1 4\n2 1\n2 3\n\nSample Output 2\n\n10\n\nSample Input 3\n\n1 1\n2 1\n\nSample Output 3\n\n0", "sample_input": "3 4\n4 3\n4 1\n2 2\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02948", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.\n\nYou can take and complete at most one of these jobs in a day.\n\nHowever, you cannot retake a job that you have already done.\n\nFind the maximum total reward that you can earn no later than M days from today.\n\nYou can already start working today.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i \\leq 10^5\n\n1 \\leq B_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_N B_N\n\nOutput\n\nPrint the maximum total reward that you can earn no later than M days from today.\n\nSample Input 1\n\n3 4\n4 3\n4 1\n2 2\n\nSample Output 1\n\n5\n\nYou can earn the total reward of 5 by taking the jobs as follows:\n\nTake and complete the first job today. You will earn the reward of 3 after four days from today.\n\nTake and complete the third job tomorrow. You will earn the reward of 2 after two days from tomorrow, that is, after three days from today.\n\nSample Input 2\n\n5 3\n1 2\n1 3\n1 4\n2 1\n2 3\n\nSample Output 2\n\n10\n\nSample Input 3\n\n1 1\n2 1\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 762, "cpu_time_ms": 2111, "memory_kb": 160792}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s750883946", "group_id": "codeNet:p02948", "input_text": "import scala.collection.mutable.PriorityQueue\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 \n var array = new Array[fuckingJob](n)\n val pq : PriorityQueue[fuckingJob] = PriorityQueue()(Ordering.by(_.money))\n var ans = 0L\n\n for (i <- 0 until n) {\n val a = sc.nextInt()\n val b = sc.nextInt()\n array(i) = fuckingJob(a,b)\n }\n\n array.sortBy(_.days)\n\n for(i <- 0 until array.length)\n pq.enqueue(array(i))\n\n while(mwhile >= 0 && pq.nonEmpty){\n val wara = pq.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": 1565732247, "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/s750883946.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s750883946", "user_id": "u287800514"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import scala.collection.mutable.PriorityQueue\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 \n var array = new Array[fuckingJob](n)\n val pq : PriorityQueue[fuckingJob] = PriorityQueue()(Ordering.by(_.money))\n var ans = 0L\n\n for (i <- 0 until n) {\n val a = sc.nextInt()\n val b = sc.nextInt()\n array(i) = fuckingJob(a,b)\n }\n\n array.sortBy(_.days)\n\n for(i <- 0 until array.length)\n pq.enqueue(array(i))\n\n while(mwhile >= 0 && pq.nonEmpty){\n val wara = pq.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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1274, "memory_kb": 114388}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s179484573", "group_id": "codeNet:p02951", "input_text": "import scala.io.StdIn\nobject Main extends App {\n val List(a,b,c) = StdIn.readLine().split(\" \").map(_.toInt).toList\n println(if (c >= (a-b)) c - (a-b) else 0)\n}\n", "language": "Scala", "metadata": {"date": 1567903388, "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/s179484573.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s179484573", "user_id": "u407005073"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import scala.io.StdIn\nobject Main extends App {\n val List(a,b,c) = StdIn.readLine().split(\" \").map(_.toInt).toList\n println(if (c >= (a-b)) c - (a-b) else 0)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have two bottles for holding water.\n\nBottle 1 can hold up to A milliliters of water, and now it contains B milliliters of water.\n\nBottle 2 contains C milliliters of water.\n\nWe will transfer water from Bottle 2 to Bottle 1 as much as possible.\n\nHow much amount of water will remain in Bottle 2?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq B \\leq A \\leq 20\n\n1 \\leq C \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the integer representing the amount of water, in milliliters, that will remain in Bottle 2.\n\nSample Input 1\n\n6 4 3\n\nSample Output 1\n\n1\n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one milliliter of water will remain in Bottle 2.\n\nSample Input 2\n\n8 3 9\n\nSample Output 2\n\n4\n\nSample Input 3\n\n12 3 7\n\nSample Output 3\n\n0", "sample_input": "6 4 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02951", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have two bottles for holding water.\n\nBottle 1 can hold up to A milliliters of water, and now it contains B milliliters of water.\n\nBottle 2 contains C milliliters of water.\n\nWe will transfer water from Bottle 2 to Bottle 1 as much as possible.\n\nHow much amount of water will remain in Bottle 2?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq B \\leq A \\leq 20\n\n1 \\leq C \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the integer representing the amount of water, in milliliters, that will remain in Bottle 2.\n\nSample Input 1\n\n6 4 3\n\nSample Output 1\n\n1\n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one milliliter of water will remain in Bottle 2.\n\nSample Input 2\n\n8 3 9\n\nSample Output 2\n\n4\n\nSample Input 3\n\n12 3 7\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 162, "cpu_time_ms": 331, "memory_kb": 27184}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s296191791", "group_id": "codeNet:p02951", "input_text": "import scala.io.StdIn\n\nobject Main {\n \n def main(args: Array[String]): Unit = {\n val Array(a, b, c) = StdIn.readLine().split(' ').map(_.toInt)\n println((c - (a - b)) max 0)\n }\n \n}", "language": "Scala", "metadata": {"date": 1564967295, "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/s296191791.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s296191791", "user_id": "u252817963"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main {\n \n def main(args: Array[String]): Unit = {\n val Array(a, b, c) = StdIn.readLine().split(' ').map(_.toInt)\n println((c - (a - b)) max 0)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 326, "memory_kb": 27208}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s260681271", "group_id": "codeNet:p02954", "input_text": "object Main {\n def main(args:Array[String]) {\n val S = readLine()\n var ansarr = Array.fill(S.length)(1)\n\n for(i <- 0 until S.length) {\n if(S(i) == 'R') {\n if(S(i + 1) == 'R') {\n ansarr(i + 2) += ansarr(i)\n ansarr(i) = 0\n }\n }\n }\n for(i <- S.length - 1 to 0 by -1) {\n if(S(i) == 'L') {\n if(S(i - 1) == 'L') {\n ansarr(i - 2) += ansarr(i)\n ansarr(i) = 0\n }\n }\n }\n ansarr.map(a => print(a))\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1567396016, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02954.html", "problem_id": "p02954", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02954/input.txt", "sample_output_relpath": "derived/input_output/data/p02954/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02954/Scala/s260681271.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s260681271", "user_id": "u240766189"}, "prompt_components": {"gold_output": "0 1 2 1 1\n", "input_to_evaluate": "object Main {\n def main(args:Array[String]) {\n val S = readLine()\n var ansarr = Array.fill(S.length)(1)\n\n for(i <- 0 until S.length) {\n if(S(i) == 'R') {\n if(S(i + 1) == 'R') {\n ansarr(i + 2) += ansarr(i)\n ansarr(i) = 0\n }\n }\n }\n for(i <- S.length - 1 to 0 by -1) {\n if(S(i) == 'L') {\n if(S(i - 1) == 'L') {\n ansarr(i - 2) += ansarr(i)\n ansarr(i) = 0\n }\n }\n }\n ansarr.map(a => print(a))\n }\n}\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is a string S consisting of L and R.\n\nLet N be the length of S. There are N squares arranged from left to right, and the i-th character of S from the left is written on the i-th square from the left.\n\nThe character written on the leftmost square is always R, and the character written on the rightmost square is always L.\n\nInitially, one child is standing on each square.\n\nEach child will perform the move below 10^{100} times:\n\nMove one square in the direction specified by the character written in the square on which the child is standing. L denotes left, and R denotes right.\n\nFind the number of children standing on each square after the children performed the moves.\n\nConstraints\n\nS is a string of length between 2 and 10^5 (inclusive).\n\nEach character of S is L or R.\n\nThe first and last characters of S are R and L, respectively.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of children standing on each square after the children performed the moves, in order from left to right.\n\nSample Input 1\n\nRRLRL\n\nSample Output 1\n\n0 1 2 1 1\n\nAfter each child performed one move, the number of children standing on each square is 0, 2, 1, 1, 1 from left to right.\n\nAfter each child performed two moves, the number of children standing on each square is 0, 1, 2, 1, 1 from left to right.\n\nAfter each child performed 10^{100} moves, the number of children standing on each square is 0, 1, 2, 1, 1 from left to right.\n\nSample Input 2\n\nRRLLLLRLRRLL\n\nSample Output 2\n\n0 3 3 0 0 0 1 1 0 2 2 0\n\nSample Input 3\n\nRRRLLRLLRRRLLLLL\n\nSample Output 3\n\n0 0 3 2 0 2 1 0 0 0 4 4 0 0 0 0", "sample_input": "RRLRL\n"}, "reference_outputs": ["0 1 2 1 1\n"], "source_document_id": "p02954", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is a string S consisting of L and R.\n\nLet N be the length of S. There are N squares arranged from left to right, and the i-th character of S from the left is written on the i-th square from the left.\n\nThe character written on the leftmost square is always R, and the character written on the rightmost square is always L.\n\nInitially, one child is standing on each square.\n\nEach child will perform the move below 10^{100} times:\n\nMove one square in the direction specified by the character written in the square on which the child is standing. L denotes left, and R denotes right.\n\nFind the number of children standing on each square after the children performed the moves.\n\nConstraints\n\nS is a string of length between 2 and 10^5 (inclusive).\n\nEach character of S is L or R.\n\nThe first and last characters of S are R and L, respectively.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of children standing on each square after the children performed the moves, in order from left to right.\n\nSample Input 1\n\nRRLRL\n\nSample Output 1\n\n0 1 2 1 1\n\nAfter each child performed one move, the number of children standing on each square is 0, 2, 1, 1, 1 from left to right.\n\nAfter each child performed two moves, the number of children standing on each square is 0, 1, 2, 1, 1 from left to right.\n\nAfter each child performed 10^{100} moves, the number of children standing on each square is 0, 1, 2, 1, 1 from left to right.\n\nSample Input 2\n\nRRLLLLRLRRLL\n\nSample Output 2\n\n0 3 3 0 0 0 1 1 0 2 2 0\n\nSample Input 3\n\nRRRLLRLLRRRLLLLL\n\nSample Output 3\n\n0 0 3 2 0 2 1 0 0 0 4 4 0 0 0 0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 500, "cpu_time_ms": 1160, "memory_kb": 44192}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s743327222", "group_id": "codeNet:p02955", "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, K = 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 //\n val S = A.sum\n var B = new Array[Int](N+1)\n\n var ans = 1L\n var n = 1\n while (n * n <= S) {\n if (S % n == 0) {\n for (i <- 1 to N) {\n B(i) = A(i) % n\n }\n B = B.sorted\n\n var fu = 0L\n var sei = 0L\n var l = 1\n var r = N\n while (l <= r) {\n if (fu > sei) {\n fu += B(l)\n l += 1\n }\n else {\n sei += n - B(r)\n r -= 1\n }\n }\n\n if (fu == sei && sei <= K)\n ans = ans max n\n }\n\n val m = S / n\n if (S % m == 0) {\n for (i <- 1 to N) {\n B(i) = A(i) % m\n }\n B = B.sorted\n\n var fu = 0L\n var sei = 0L\n var l = 1\n var r = N\n while (l <= r) {\n if (fu < sei) {\n fu += B(l)\n l += 1\n }\n else {\n sei += m - B(r)\n r -= 1\n }\n }\n\n if (fu == sei && sei <= K)\n ans = ans max m\n }\n\n\n n += 1\n }\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": 1580787953, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02955.html", "problem_id": "p02955", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02955/input.txt", "sample_output_relpath": "derived/input_output/data/p02955/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02955/Scala/s743327222.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s743327222", "user_id": "u098968285"}, "prompt_components": {"gold_output": "7\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, K = 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 //\n val S = A.sum\n var B = new Array[Int](N+1)\n\n var ans = 1L\n var n = 1\n while (n * n <= S) {\n if (S % n == 0) {\n for (i <- 1 to N) {\n B(i) = A(i) % n\n }\n B = B.sorted\n\n var fu = 0L\n var sei = 0L\n var l = 1\n var r = N\n while (l <= r) {\n if (fu > sei) {\n fu += B(l)\n l += 1\n }\n else {\n sei += n - B(r)\n r -= 1\n }\n }\n\n if (fu == sei && sei <= K)\n ans = ans max n\n }\n\n val m = S / n\n if (S % m == 0) {\n for (i <- 1 to N) {\n B(i) = A(i) % m\n }\n B = B.sorted\n\n var fu = 0L\n var sei = 0L\n var l = 1\n var r = N\n while (l <= r) {\n if (fu < sei) {\n fu += B(l)\n l += 1\n }\n else {\n sei += m - B(r)\n r -= 1\n }\n }\n\n if (fu == sei && sei <= K)\n ans = ans max m\n }\n\n\n n += 1\n }\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 : 500 points\n\nProblem Statement\n\nWe have a sequence of N integers: A_1, A_2, \\cdots, A_N.\n\nYou can perform the following operation between 0 and K times (inclusive):\n\nChoose two integers i and j such that i \\neq j, each between 1 and N (inclusive). Add 1 to A_i and -1 to A_j, possibly producing a negative element.\n\nCompute the maximum possible positive integer that divides every element of A after the operations. Here a positive integer x divides an integer y if and only if there exists an integer z such that y = xz.\n\nConstraints\n\n2 \\leq N \\leq 500\n\n1 \\leq A_i \\leq 10^6\n\n0 \\leq K \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 \\cdots A_{N-1} A_{N}\n\nOutput\n\nPrint the maximum possible positive integer that divides every element of A after the operations.\n\nSample Input 1\n\n2 3\n8 20\n\nSample Output 1\n\n7\n\n7 will divide every element of A if, for example, we perform the following operation:\n\nChoose i = 2, j = 1. A becomes (7, 21).\n\nWe cannot reach the situation where 8 or greater integer divides every element of A.\n\nSample Input 2\n\n2 10\n3 5\n\nSample Output 2\n\n8\n\nConsider performing the following five operations:\n\nChoose i = 2, j = 1. A becomes (2, 6).\n\nChoose i = 2, j = 1. A becomes (1, 7).\n\nChoose i = 2, j = 1. A becomes (0, 8).\n\nChoose i = 2, j = 1. A becomes (-1, 9).\n\nChoose i = 1, j = 2. A becomes (0, 8).\n\nThen, 0 = 8 \\times 0 and 8 = 8 \\times 1, so 8 divides every element of A. We cannot reach the situation where 9 or greater integer divides every element of A.\n\nSample Input 3\n\n4 5\n10 1 2 22\n\nSample Output 3\n\n7\n\nSample Input 4\n\n8 7\n1 7 5 6 8 2 6 5\n\nSample Output 4\n\n5", "sample_input": "2 3\n8 20\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02955", "source_text": "Score : 500 points\n\nProblem Statement\n\nWe have a sequence of N integers: A_1, A_2, \\cdots, A_N.\n\nYou can perform the following operation between 0 and K times (inclusive):\n\nChoose two integers i and j such that i \\neq j, each between 1 and N (inclusive). Add 1 to A_i and -1 to A_j, possibly producing a negative element.\n\nCompute the maximum possible positive integer that divides every element of A after the operations. Here a positive integer x divides an integer y if and only if there exists an integer z such that y = xz.\n\nConstraints\n\n2 \\leq N \\leq 500\n\n1 \\leq A_i \\leq 10^6\n\n0 \\leq K \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 \\cdots A_{N-1} A_{N}\n\nOutput\n\nPrint the maximum possible positive integer that divides every element of A after the operations.\n\nSample Input 1\n\n2 3\n8 20\n\nSample Output 1\n\n7\n\n7 will divide every element of A if, for example, we perform the following operation:\n\nChoose i = 2, j = 1. A becomes (7, 21).\n\nWe cannot reach the situation where 8 or greater integer divides every element of A.\n\nSample Input 2\n\n2 10\n3 5\n\nSample Output 2\n\n8\n\nConsider performing the following five operations:\n\nChoose i = 2, j = 1. A becomes (2, 6).\n\nChoose i = 2, j = 1. A becomes (1, 7).\n\nChoose i = 2, j = 1. A becomes (0, 8).\n\nChoose i = 2, j = 1. A becomes (-1, 9).\n\nChoose i = 1, j = 2. A becomes (0, 8).\n\nThen, 0 = 8 \\times 0 and 8 = 8 \\times 1, so 8 divides every element of A. We cannot reach the situation where 9 or greater integer divides every element of A.\n\nSample Input 3\n\n4 5\n10 1 2 22\n\nSample Output 3\n\n7\n\nSample Input 4\n\n8 7\n1 7 5 6 8 2 6 5\n\nSample Output 4\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1843, "cpu_time_ms": 662, "memory_kb": 40352}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s482478494", "group_id": "codeNet:p02955", "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[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}\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 N, K = ni()\n val A = na(N)\n val S = A.sum\n\n def ok(d: Int): Boolean = {\n val P = map(N) { i =>\n val m = A(i) % d\n if (m == 0) 0 else d - m\n }\n sort(P)\n val cumP = cumSum(P)\n val cumM = Array.ofDim[Int](N + 1)\n REP(N) { i =>\n val m = if (P(i) == 0) 0 else d - P(i)\n cumM(i + 1) = cumM(i) + m\n }\n\n debug(P)\n debug(cumP)\n debug(cumM)\n\n var k = 1e9.toInt\n REP(N - 1) { i =>\n val plus = cumP(i + 1)\n val minus = cumM(N) - cumM(i + 1)\n debug(s\"plus:$plus minus:$minus\")\n k = min(k, plus + max(0, minus - plus))\n }\n\n debug(s\"ok($d) k:$k\")\n\n k <= K\n }\n\n val D = divisors(S)\n var ans = 0\n REP(D.length) { i =>\n val d = D(i)\n if (ok(d)) {\n ans = max(ans, d)\n }\n }\n\n out.println(ans)\n }\n\n /**\n * O(√x)\n */\n def divisors(x: Int): Array[Int] = {\n val pre = ArrayBuffer[Int]()\n val post = ArrayBuffer[Int]()\n REP(math.sqrt(x).toInt, 1) { d =>\n if (x % d == 0) {\n pre += d\n if (d * d != x) post += x / d\n }\n }\n\n val res = Array.ofDim[Int](pre.length + post.length)\n REP(pre.length)(i => res(i) = pre(i))\n val preLen = pre.length\n val postLen = post.length\n REP(postLen)(i => res(i + preLen) = post(postLen - 1 - i))\n res\n }\n}", "language": "Scala", "metadata": {"date": 1564970990, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02955.html", "problem_id": "p02955", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02955/input.txt", "sample_output_relpath": "derived/input_output/data/p02955/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02955/Scala/s482478494.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s482478494", "user_id": "u460609472"}, "prompt_components": {"gold_output": "7\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[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}\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 N, K = ni()\n val A = na(N)\n val S = A.sum\n\n def ok(d: Int): Boolean = {\n val P = map(N) { i =>\n val m = A(i) % d\n if (m == 0) 0 else d - m\n }\n sort(P)\n val cumP = cumSum(P)\n val cumM = Array.ofDim[Int](N + 1)\n REP(N) { i =>\n val m = if (P(i) == 0) 0 else d - P(i)\n cumM(i + 1) = cumM(i) + m\n }\n\n debug(P)\n debug(cumP)\n debug(cumM)\n\n var k = 1e9.toInt\n REP(N - 1) { i =>\n val plus = cumP(i + 1)\n val minus = cumM(N) - cumM(i + 1)\n debug(s\"plus:$plus minus:$minus\")\n k = min(k, plus + max(0, minus - plus))\n }\n\n debug(s\"ok($d) k:$k\")\n\n k <= K\n }\n\n val D = divisors(S)\n var ans = 0\n REP(D.length) { i =>\n val d = D(i)\n if (ok(d)) {\n ans = max(ans, d)\n }\n }\n\n out.println(ans)\n }\n\n /**\n * O(√x)\n */\n def divisors(x: Int): Array[Int] = {\n val pre = ArrayBuffer[Int]()\n val post = ArrayBuffer[Int]()\n REP(math.sqrt(x).toInt, 1) { d =>\n if (x % d == 0) {\n pre += d\n if (d * d != x) post += x / d\n }\n }\n\n val res = Array.ofDim[Int](pre.length + post.length)\n REP(pre.length)(i => res(i) = pre(i))\n val preLen = pre.length\n val postLen = post.length\n REP(postLen)(i => res(i + preLen) = post(postLen - 1 - i))\n res\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nWe have a sequence of N integers: A_1, A_2, \\cdots, A_N.\n\nYou can perform the following operation between 0 and K times (inclusive):\n\nChoose two integers i and j such that i \\neq j, each between 1 and N (inclusive). Add 1 to A_i and -1 to A_j, possibly producing a negative element.\n\nCompute the maximum possible positive integer that divides every element of A after the operations. Here a positive integer x divides an integer y if and only if there exists an integer z such that y = xz.\n\nConstraints\n\n2 \\leq N \\leq 500\n\n1 \\leq A_i \\leq 10^6\n\n0 \\leq K \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 \\cdots A_{N-1} A_{N}\n\nOutput\n\nPrint the maximum possible positive integer that divides every element of A after the operations.\n\nSample Input 1\n\n2 3\n8 20\n\nSample Output 1\n\n7\n\n7 will divide every element of A if, for example, we perform the following operation:\n\nChoose i = 2, j = 1. A becomes (7, 21).\n\nWe cannot reach the situation where 8 or greater integer divides every element of A.\n\nSample Input 2\n\n2 10\n3 5\n\nSample Output 2\n\n8\n\nConsider performing the following five operations:\n\nChoose i = 2, j = 1. A becomes (2, 6).\n\nChoose i = 2, j = 1. A becomes (1, 7).\n\nChoose i = 2, j = 1. A becomes (0, 8).\n\nChoose i = 2, j = 1. A becomes (-1, 9).\n\nChoose i = 1, j = 2. A becomes (0, 8).\n\nThen, 0 = 8 \\times 0 and 8 = 8 \\times 1, so 8 divides every element of A. We cannot reach the situation where 9 or greater integer divides every element of A.\n\nSample Input 3\n\n4 5\n10 1 2 22\n\nSample Output 3\n\n7\n\nSample Input 4\n\n8 7\n1 7 5 6 8 2 6 5\n\nSample Output 4\n\n5", "sample_input": "2 3\n8 20\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02955", "source_text": "Score : 500 points\n\nProblem Statement\n\nWe have a sequence of N integers: A_1, A_2, \\cdots, A_N.\n\nYou can perform the following operation between 0 and K times (inclusive):\n\nChoose two integers i and j such that i \\neq j, each between 1 and N (inclusive). Add 1 to A_i and -1 to A_j, possibly producing a negative element.\n\nCompute the maximum possible positive integer that divides every element of A after the operations. Here a positive integer x divides an integer y if and only if there exists an integer z such that y = xz.\n\nConstraints\n\n2 \\leq N \\leq 500\n\n1 \\leq A_i \\leq 10^6\n\n0 \\leq K \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 \\cdots A_{N-1} A_{N}\n\nOutput\n\nPrint the maximum possible positive integer that divides every element of A after the operations.\n\nSample Input 1\n\n2 3\n8 20\n\nSample Output 1\n\n7\n\n7 will divide every element of A if, for example, we perform the following operation:\n\nChoose i = 2, j = 1. A becomes (7, 21).\n\nWe cannot reach the situation where 8 or greater integer divides every element of A.\n\nSample Input 2\n\n2 10\n3 5\n\nSample Output 2\n\n8\n\nConsider performing the following five operations:\n\nChoose i = 2, j = 1. A becomes (2, 6).\n\nChoose i = 2, j = 1. A becomes (1, 7).\n\nChoose i = 2, j = 1. A becomes (0, 8).\n\nChoose i = 2, j = 1. A becomes (-1, 9).\n\nChoose i = 1, j = 2. A becomes (0, 8).\n\nThen, 0 = 8 \\times 0 and 8 = 8 \\times 1, so 8 divides every element of A. We cannot reach the situation where 9 or greater integer divides every element of A.\n\nSample Input 3\n\n4 5\n10 1 2 22\n\nSample Output 3\n\n7\n\nSample Input 4\n\n8 7\n1 7 5 6 8 2 6 5\n\nSample Output 4\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4969, "cpu_time_ms": 559, "memory_kb": 46400}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s808859461", "group_id": "codeNet:p02958", "input_text": "object Main extends App {\n val n = io.StdIn.readLine.toInt\n val p = io.StdIn.readLine.split(\" \").map(_.toInt)\n\n var c = 0\n for(i <- 0 to p.length - 2; if /*p(i) >= p(i + 1)*/p(i) != i + 1) c += 1\n//条件が違っていた, p(i) != i で カウントを増やし 2まで許容する\n if(/*c < 2*/c < 3){\n println(\"YES\")\n }else{\n println(\"NO\")\n }\n}\n", "language": "Scala", "metadata": {"date": 1564312091, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02958.html", "problem_id": "p02958", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02958/input.txt", "sample_output_relpath": "derived/input_output/data/p02958/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02958/Scala/s808859461.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s808859461", "user_id": "u432621419"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "object Main extends App {\n val n = io.StdIn.readLine.toInt\n val p = io.StdIn.readLine.split(\" \").map(_.toInt)\n\n var c = 0\n for(i <- 0 to p.length - 2; if /*p(i) >= p(i + 1)*/p(i) != i + 1) c += 1\n//条件が違っていた, p(i) != i で カウントを増やし 2まで許容する\n if(/*c < 2*/c < 3){\n println(\"YES\")\n }else{\n println(\"NO\")\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a sequence p = {p_1,\\ p_2,\\ ...,\\ p_N} which is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nYou can perform the following operation at most once: choose integers i and j (1 \\leq i < j \\leq N), and swap p_i and p_j. Note that you can also choose not to perform it.\n\nPrint YES if you can sort p in ascending order in this way, and NO otherwise.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 50\n\np is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1 p_2 ... p_N\n\nOutput\n\nPrint YES if you can sort p in ascending order in the way stated in the problem statement, and NO otherwise.\n\nSample Input 1\n\n5\n5 2 3 4 1\n\nSample Output 1\n\nYES\n\nYou can sort p in ascending order by swapping p_1 and p_5.\n\nSample Input 2\n\n5\n2 4 3 5 1\n\nSample Output 2\n\nNO\n\nIn this case, swapping any two elements does not sort p in ascending order.\n\nSample Input 3\n\n7\n1 2 3 4 5 6 7\n\nSample Output 3\n\nYES\n\np is already sorted in ascending order, so no operation is needed.", "sample_input": "5\n5 2 3 4 1\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p02958", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a sequence p = {p_1,\\ p_2,\\ ...,\\ p_N} which is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nYou can perform the following operation at most once: choose integers i and j (1 \\leq i < j \\leq N), and swap p_i and p_j. Note that you can also choose not to perform it.\n\nPrint YES if you can sort p in ascending order in this way, and NO otherwise.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 50\n\np is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1 p_2 ... p_N\n\nOutput\n\nPrint YES if you can sort p in ascending order in the way stated in the problem statement, and NO otherwise.\n\nSample Input 1\n\n5\n5 2 3 4 1\n\nSample Output 1\n\nYES\n\nYou can sort p in ascending order by swapping p_1 and p_5.\n\nSample Input 2\n\n5\n2 4 3 5 1\n\nSample Output 2\n\nNO\n\nIn this case, swapping any two elements does not sort p in ascending order.\n\nSample Input 3\n\n7\n1 2 3 4 5 6 7\n\nSample Output 3\n\nYES\n\np is already sorted in ascending order, so no operation is needed.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 361, "cpu_time_ms": 328, "memory_kb": 25520}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s566949461", "group_id": "codeNet:p02958", "input_text": "object Main extends App {\n val n = scala.io.StdIn.readInt()\n val read = scala.io.StdIn.readLine()\n val array = read.split(\" \").map(_.toInt).toVector\n val array_sorted = array.sorted\n var diff = 0\n array.zipWithIndex.foreach { case (j, index) =>\n if(j != array_sorted(index)) {\n diff = diff + 1\n }\n }\n if (diff <= 2) {\n println(\"YES\")\n } else {\n println(\"NO\")\n }\n}", "language": "Scala", "metadata": {"date": 1564277185, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02958.html", "problem_id": "p02958", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02958/input.txt", "sample_output_relpath": "derived/input_output/data/p02958/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02958/Scala/s566949461.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s566949461", "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 read = scala.io.StdIn.readLine()\n val array = read.split(\" \").map(_.toInt).toVector\n val array_sorted = array.sorted\n var diff = 0\n array.zipWithIndex.foreach { case (j, index) =>\n if(j != array_sorted(index)) {\n diff = diff + 1\n }\n }\n if (diff <= 2) {\n println(\"YES\")\n } else {\n println(\"NO\")\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a sequence p = {p_1,\\ p_2,\\ ...,\\ p_N} which is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nYou can perform the following operation at most once: choose integers i and j (1 \\leq i < j \\leq N), and swap p_i and p_j. Note that you can also choose not to perform it.\n\nPrint YES if you can sort p in ascending order in this way, and NO otherwise.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 50\n\np is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1 p_2 ... p_N\n\nOutput\n\nPrint YES if you can sort p in ascending order in the way stated in the problem statement, and NO otherwise.\n\nSample Input 1\n\n5\n5 2 3 4 1\n\nSample Output 1\n\nYES\n\nYou can sort p in ascending order by swapping p_1 and p_5.\n\nSample Input 2\n\n5\n2 4 3 5 1\n\nSample Output 2\n\nNO\n\nIn this case, swapping any two elements does not sort p in ascending order.\n\nSample Input 3\n\n7\n1 2 3 4 5 6 7\n\nSample Output 3\n\nYES\n\np is already sorted in ascending order, so no operation is needed.", "sample_input": "5\n5 2 3 4 1\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p02958", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a sequence p = {p_1,\\ p_2,\\ ...,\\ p_N} which is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nYou can perform the following operation at most once: choose integers i and j (1 \\leq i < j \\leq N), and swap p_i and p_j. Note that you can also choose not to perform it.\n\nPrint YES if you can sort p in ascending order in this way, and NO otherwise.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 50\n\np is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1 p_2 ... p_N\n\nOutput\n\nPrint YES if you can sort p in ascending order in the way stated in the problem statement, and NO otherwise.\n\nSample Input 1\n\n5\n5 2 3 4 1\n\nSample Output 1\n\nYES\n\nYou can sort p in ascending order by swapping p_1 and p_5.\n\nSample Input 2\n\n5\n2 4 3 5 1\n\nSample Output 2\n\nNO\n\nIn this case, swapping any two elements does not sort p in ascending order.\n\nSample Input 3\n\n7\n1 2 3 4 5 6 7\n\nSample Output 3\n\nYES\n\np is already sorted in ascending order, so no operation is needed.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 391, "cpu_time_ms": 330, "memory_kb": 27332}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s177843939", "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 = 0L\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": 1586738329, "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/s177843939.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s177843939", "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 = 0L\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 761, "cpu_time_ms": 759, "memory_kb": 68128}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s259371337", "group_id": "codeNet:p02959", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val N: Int = sc.nextInt\n val monsters :List[Int] = List.fill(N + 1)(sc.nextInt)\n val savers :List[Int] = List.fill(N)(sc.nextInt)\n\n def go(monster: Int, monsters: List[Int], savers :List[Int], sum: Int): Int = savers match {\n case Nil => sum\n case h::t if h < monster => go(monsters.head, monsters.tail, t, sum + h)\n case h::t => go(math.max(0, monsters.head - (h - monster)), monsters.tail, t, sum + math.min(h, monster + monsters.head))\n }\n println(go(monsters.head, monsters.tail, savers, 0))\n}", "language": "Scala", "metadata": {"date": 1571337967, "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/s259371337.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s259371337", "user_id": "u624523023"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val N: Int = sc.nextInt\n val monsters :List[Int] = List.fill(N + 1)(sc.nextInt)\n val savers :List[Int] = List.fill(N)(sc.nextInt)\n\n def go(monster: Int, monsters: List[Int], savers :List[Int], sum: Int): Int = savers match {\n case Nil => sum\n case h::t if h < monster => go(monsters.head, monsters.tail, t, sum + h)\n case h::t => go(math.max(0, monsters.head - (h - monster)), monsters.tail, t, sum + math.min(h, monster + monsters.head))\n }\n println(go(monsters.head, monsters.tail, savers, 0))\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N+1 towns. The i-th town is being attacked by A_i monsters.\n\nWe have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters.\n\nWhat is the maximum total number of monsters the heroes can cooperate to defeat?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N+1}\nB_1 B_2 ... B_N\n\nOutput\n\nPrint the maximum total number of monsters the heroes can defeat.\n\nSample Input 1\n\n2\n3 5 2\n4 5\n\nSample Output 1\n\n9\n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine monsters in total, which is the maximum result.\n\nThe first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n\nThe second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\nSample Input 2\n\n3\n5 6 3 8\n5 100 8\n\nSample Output 2\n\n22\n\nSample Input 3\n\n2\n100 1 1\n1 100\n\nSample Output 3\n\n3", "sample_input": "2\n3 5 2\n4 5\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02959", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N+1 towns. The i-th town is being attacked by A_i monsters.\n\nWe have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters.\n\nWhat is the maximum total number of monsters the heroes can cooperate to defeat?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N+1}\nB_1 B_2 ... B_N\n\nOutput\n\nPrint the maximum total number of monsters the heroes can defeat.\n\nSample Input 1\n\n2\n3 5 2\n4 5\n\nSample Output 1\n\n9\n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine monsters in total, which is the maximum result.\n\nThe first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n\nThe second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\nSample Input 2\n\n3\n5 6 3 8\n5 100 8\n\nSample Output 2\n\n22\n\nSample Input 3\n\n2\n100 1 1\n1 100\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 583, "cpu_time_ms": 901, "memory_kb": 79824}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s204941576", "group_id": "codeNet:p02959", "input_text": "object Main extends App {\n val max = (x:Int,y:Int)=>if(x>y)x else y\n val min = (x:Int,y:Int)=>if(x\n beat += min(bs(i)+rest, as(i))\n rest = max(bs(i)-max(as(i)-rest, 0), 0)\n }\n println(beat)\n}", "language": "Scala", "metadata": {"date": 1566107471, "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/s204941576.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s204941576", "user_id": "u782685137"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "object Main extends App {\n val max = (x:Int,y:Int)=>if(x>y)x else y\n val min = (x:Int,y:Int)=>if(x\n beat += min(bs(i)+rest, as(i))\n rest = max(bs(i)-max(as(i)-rest, 0), 0)\n }\n println(beat)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N+1 towns. The i-th town is being attacked by A_i monsters.\n\nWe have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters.\n\nWhat is the maximum total number of monsters the heroes can cooperate to defeat?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N+1}\nB_1 B_2 ... B_N\n\nOutput\n\nPrint the maximum total number of monsters the heroes can defeat.\n\nSample Input 1\n\n2\n3 5 2\n4 5\n\nSample Output 1\n\n9\n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine monsters in total, which is the maximum result.\n\nThe first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n\nThe second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\nSample Input 2\n\n3\n5 6 3 8\n5 100 8\n\nSample Output 2\n\n22\n\nSample Input 3\n\n2\n100 1 1\n1 100\n\nSample Output 3\n\n3", "sample_input": "2\n3 5 2\n4 5\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02959", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N+1 towns. The i-th town is being attacked by A_i monsters.\n\nWe have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters.\n\nWhat is the maximum total number of monsters the heroes can cooperate to defeat?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N+1}\nB_1 B_2 ... B_N\n\nOutput\n\nPrint the maximum total number of monsters the heroes can defeat.\n\nSample Input 1\n\n2\n3 5 2\n4 5\n\nSample Output 1\n\n9\n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine monsters in total, which is the maximum result.\n\nThe first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n\nThe second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\nSample Input 2\n\n3\n5 6 3 8\n5 100 8\n\nSample Output 2\n\n22\n\nSample Input 3\n\n2\n100 1 1\n1 100\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 383, "cpu_time_ms": 704, "memory_kb": 69240}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s696902847", "group_id": "codeNet:p02959", "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 A = Array.fill(N + 1)(sc.nextLong())\n val B = Array.fill(N)(sc.nextLong())\n println(A.tail.zip(B).foldLeft((0L, A.head)) { case (a, b) => {\n val x = Math.max(0, a._2 + b._1 - b._2)\n (Math.max(Math.min(a._2 + b._1, b._2), 0L) + a._1, Math.max(0L, Math.max(b._1, a._2 + b._1 - x)))\n }\n }._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(N: Long, S: String): Long = {\n if (S.length == 0) {\n if (N % 13 == 5) 1 else 0\n } else {\n S.head match {\n case '?' => (0 to 9).map(i => recursive(N * 10 + i, S.tail)).sum\n case c => recursive(N * 10 + c.toLong, S.tail)\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": 1564624741, "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/s696902847.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s696902847", "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 N = sc.nextInt()\n val A = Array.fill(N + 1)(sc.nextLong())\n val B = Array.fill(N)(sc.nextLong())\n println(A.tail.zip(B).foldLeft((0L, A.head)) { case (a, b) => {\n val x = Math.max(0, a._2 + b._1 - b._2)\n (Math.max(Math.min(a._2 + b._1, b._2), 0L) + a._1, Math.max(0L, Math.max(b._1, a._2 + b._1 - x)))\n }\n }._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(N: Long, S: String): Long = {\n if (S.length == 0) {\n if (N % 13 == 5) 1 else 0\n } else {\n S.head match {\n case '?' => (0 to 9).map(i => recursive(N * 10 + i, S.tail)).sum\n case c => recursive(N * 10 + c.toLong, S.tail)\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\nThere are N+1 towns. The i-th town is being attacked by A_i monsters.\n\nWe have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters.\n\nWhat is the maximum total number of monsters the heroes can cooperate to defeat?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N+1}\nB_1 B_2 ... B_N\n\nOutput\n\nPrint the maximum total number of monsters the heroes can defeat.\n\nSample Input 1\n\n2\n3 5 2\n4 5\n\nSample Output 1\n\n9\n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine monsters in total, which is the maximum result.\n\nThe first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n\nThe second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\nSample Input 2\n\n3\n5 6 3 8\n5 100 8\n\nSample Output 2\n\n22\n\nSample Input 3\n\n2\n100 1 1\n1 100\n\nSample Output 3\n\n3", "sample_input": "2\n3 5 2\n4 5\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02959", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N+1 towns. The i-th town is being attacked by A_i monsters.\n\nWe have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters.\n\nWhat is the maximum total number of monsters the heroes can cooperate to defeat?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N+1}\nB_1 B_2 ... B_N\n\nOutput\n\nPrint the maximum total number of monsters the heroes can defeat.\n\nSample Input 1\n\n2\n3 5 2\n4 5\n\nSample Output 1\n\n9\n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine monsters in total, which is the maximum result.\n\nThe first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n\nThe second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\nSample Input 2\n\n3\n5 6 3 8\n5 100 8\n\nSample Output 2\n\n22\n\nSample Input 3\n\n2\n100 1 1\n1 100\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 7310, "cpu_time_ms": 886, "memory_kb": 71200}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s576906162", "group_id": "codeNet:p02959", "input_text": "object Main extends App {\n import scala.util.control.Breaks\n\n val n = io.StdIn.readLine.toInt\n val a = io.StdIn.readLine.split(\" \").map(_.toInt)\n val b = io.StdIn.readLine.split(\" \").map(_.toInt)\n\n var s = 0\n\n for(i <- 0 to n - 1){\n\n if (a(i) >= b(i) ) {\n s += b(i)\n }\n if (a(i) < b(i)) {\n s += a(i)\n b(i) -= a(i)\n if(a(i+1) < b(i)){\n s += a(i+1)\n a(i+1) = 0\n }else{\n s += b(i)\n a(i+1) -= b(i)\n }\n /*\n if (a(i+1) >= b(i)) {\n s += b(i)\n a(i+1) -= b(i)\n b(i) += a(i + 1)\n }else{\n s += a(i+1)\n a(i+1) = 0\n }\n */\n }\n }\n println(s)\n}\n", "language": "Scala", "metadata": {"date": 1564313263, "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/s576906162.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s576906162", "user_id": "u432621419"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "object Main extends App {\n import scala.util.control.Breaks\n\n val n = io.StdIn.readLine.toInt\n val a = io.StdIn.readLine.split(\" \").map(_.toInt)\n val b = io.StdIn.readLine.split(\" \").map(_.toInt)\n\n var s = 0\n\n for(i <- 0 to n - 1){\n\n if (a(i) >= b(i) ) {\n s += b(i)\n }\n if (a(i) < b(i)) {\n s += a(i)\n b(i) -= a(i)\n if(a(i+1) < b(i)){\n s += a(i+1)\n a(i+1) = 0\n }else{\n s += b(i)\n a(i+1) -= b(i)\n }\n /*\n if (a(i+1) >= b(i)) {\n s += b(i)\n a(i+1) -= b(i)\n b(i) += a(i + 1)\n }else{\n s += a(i+1)\n a(i+1) = 0\n }\n */\n }\n }\n println(s)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N+1 towns. The i-th town is being attacked by A_i monsters.\n\nWe have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters.\n\nWhat is the maximum total number of monsters the heroes can cooperate to defeat?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N+1}\nB_1 B_2 ... B_N\n\nOutput\n\nPrint the maximum total number of monsters the heroes can defeat.\n\nSample Input 1\n\n2\n3 5 2\n4 5\n\nSample Output 1\n\n9\n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine monsters in total, which is the maximum result.\n\nThe first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n\nThe second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\nSample Input 2\n\n3\n5 6 3 8\n5 100 8\n\nSample Output 2\n\n22\n\nSample Input 3\n\n2\n100 1 1\n1 100\n\nSample Output 3\n\n3", "sample_input": "2\n3 5 2\n4 5\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02959", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N+1 towns. The i-th town is being attacked by A_i monsters.\n\nWe have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters.\n\nWhat is the maximum total number of monsters the heroes can cooperate to defeat?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N+1}\nB_1 B_2 ... B_N\n\nOutput\n\nPrint the maximum total number of monsters the heroes can defeat.\n\nSample Input 1\n\n2\n3 5 2\n4 5\n\nSample Output 1\n\n9\n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine monsters in total, which is the maximum result.\n\nThe first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n\nThe second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\nSample Input 2\n\n3\n5 6 3 8\n5 100 8\n\nSample Output 2\n\n22\n\nSample Input 3\n\n2\n100 1 1\n1 100\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 668, "cpu_time_ms": 708, "memory_kb": 73308}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s616004428", "group_id": "codeNet:p02959", "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+1)(sc.nextInt())\n val B = Array.fill(N)(sc.nextInt())\n\n // 倒せる分だけ倒す\n var i = 0\n var score = 0L\n while (i < N) {\n val at = A(i) min B(i) // aiで倒した数\n B(i) -= at // 倒した数で残り数を更新\n val att = A(i+1) min B(i) // ai+1で倒した数\n A(i+1) -= att\n score += at + att\n i += 1\n }\n println(score)\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1564277446, "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/s616004428.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s616004428", "user_id": "u891387249"}, "prompt_components": {"gold_output": "9\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+1)(sc.nextInt())\n val B = Array.fill(N)(sc.nextInt())\n\n // 倒せる分だけ倒す\n var i = 0\n var score = 0L\n while (i < N) {\n val at = A(i) min B(i) // aiで倒した数\n B(i) -= at // 倒した数で残り数を更新\n val att = A(i+1) min B(i) // ai+1で倒した数\n A(i+1) -= att\n score += at + att\n i += 1\n }\n println(score)\n }\n\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N+1 towns. The i-th town is being attacked by A_i monsters.\n\nWe have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters.\n\nWhat is the maximum total number of monsters the heroes can cooperate to defeat?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N+1}\nB_1 B_2 ... B_N\n\nOutput\n\nPrint the maximum total number of monsters the heroes can defeat.\n\nSample Input 1\n\n2\n3 5 2\n4 5\n\nSample Output 1\n\n9\n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine monsters in total, which is the maximum result.\n\nThe first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n\nThe second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\nSample Input 2\n\n3\n5 6 3 8\n5 100 8\n\nSample Output 2\n\n22\n\nSample Input 3\n\n2\n100 1 1\n1 100\n\nSample Output 3\n\n3", "sample_input": "2\n3 5 2\n4 5\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02959", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N+1 towns. The i-th town is being attacked by A_i monsters.\n\nWe have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters.\n\nWhat is the maximum total number of monsters the heroes can cooperate to defeat?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N+1}\nB_1 B_2 ... B_N\n\nOutput\n\nPrint the maximum total number of monsters the heroes can defeat.\n\nSample Input 1\n\n2\n3 5 2\n4 5\n\nSample Output 1\n\n9\n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine monsters in total, which is the maximum result.\n\nThe first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n\nThe second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\nSample Input 2\n\n3\n5 6 3 8\n5 100 8\n\nSample Output 2\n\n22\n\nSample Input 3\n\n2\n100 1 1\n1 100\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 545, "cpu_time_ms": 814, "memory_kb": 68508}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s775682834", "group_id": "codeNet:p02959", "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 N = ni()\n val A = na(N + 1)\n val B = na(N)\n var ans = 0L\n REP(N) { i =>\n val l = min(B(i), A(i))\n B(i) -= l\n ans += l\n val r = min(B(i), A(i + 1))\n A(i + 1) -= r\n ans += r\n }\n\n out.println(ans)\n }\n}", "language": "Scala", "metadata": {"date": 1564276010, "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/s775682834.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s775682834", "user_id": "u460609472"}, "prompt_components": {"gold_output": "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 N = ni()\n val A = na(N + 1)\n val B = na(N)\n var ans = 0L\n REP(N) { i =>\n val l = min(B(i), A(i))\n B(i) -= l\n ans += l\n val r = min(B(i), A(i + 1))\n A(i + 1) -= r\n ans += r\n }\n\n out.println(ans)\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N+1 towns. The i-th town is being attacked by A_i monsters.\n\nWe have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters.\n\nWhat is the maximum total number of monsters the heroes can cooperate to defeat?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N+1}\nB_1 B_2 ... B_N\n\nOutput\n\nPrint the maximum total number of monsters the heroes can defeat.\n\nSample Input 1\n\n2\n3 5 2\n4 5\n\nSample Output 1\n\n9\n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine monsters in total, which is the maximum result.\n\nThe first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n\nThe second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\nSample Input 2\n\n3\n5 6 3 8\n5 100 8\n\nSample Output 2\n\n22\n\nSample Input 3\n\n2\n100 1 1\n1 100\n\nSample Output 3\n\n3", "sample_input": "2\n3 5 2\n4 5\n"}, "reference_outputs": ["9\n"], "source_document_id": "p02959", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N+1 towns. The i-th town is being attacked by A_i monsters.\n\nWe have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters.\n\nWhat is the maximum total number of monsters the heroes can cooperate to defeat?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N+1}\nB_1 B_2 ... B_N\n\nOutput\n\nPrint the maximum total number of monsters the heroes can defeat.\n\nSample Input 1\n\n2\n3 5 2\n4 5\n\nSample Output 1\n\n9\n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine monsters in total, which is the maximum result.\n\nThe first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n\nThe second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\nSample Input 2\n\n3\n5 6 3 8\n5 100 8\n\nSample Output 2\n\n22\n\nSample Input 3\n\n2\n100 1 1\n1 100\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3862, "cpu_time_ms": 621, "memory_kb": 50648}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s432051620", "group_id": "codeNet:p02963", "input_text": "object Main {\n def main(args: Array[String]) = {\n\n val pw = new java.io.PrintWriter(System.out)\n val sc = new java.util.Scanner(System.in)\n val S = sc.nextLong\n sc.close()\n\n pw.println(s\"${S / 2} ${S % 2} 0 2 0 0\")\n\n pw.flush()\n }\n}", "language": "Scala", "metadata": {"date": 1563761849, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02963.html", "problem_id": "p02963", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02963/input.txt", "sample_output_relpath": "derived/input_output/data/p02963/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02963/Scala/s432051620.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s432051620", "user_id": "u889604426"}, "prompt_components": {"gold_output": "1 0 2 2 0 1\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]) = {\n\n val pw = new java.io.PrintWriter(System.out)\n val sc = new java.util.Scanner(System.in)\n val S = sc.nextLong\n sc.close()\n\n pw.println(s\"${S / 2} ${S % 2} 0 2 0 0\")\n\n pw.flush()\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is an integer S.\nFind a combination of six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfies all of the following conditions:\n\n0 \\leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \\leq 10^9\n\nThe area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.\n\nWe can prove that there always exist six integers that satisfy the conditions under the constraints of this problem.\n\nConstraints\n\n1 \\leq S \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions, in this order, with spaces in between.\nIf multiple solutions exist, any of them will be accepted.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n1 0 2 2 0 1\n\nThe area of the triangle in a two-dimensional plane whose vertices are (1,0),(2,2), and (0,1) is 3/2.\nPrinting 3 0 3 1 0 1 or 1 0 0 1 2 2 will also be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n0 0 10 0 0 10\n\nSample Input 3\n\n311114770564041497\n\nSample Output 3\n\n314159265 358979323 846264338 327950288 419716939 937510582", "sample_input": "3\n"}, "reference_outputs": ["1 0 2 2 0 1\n"], "source_document_id": "p02963", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is an integer S.\nFind a combination of six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfies all of the following conditions:\n\n0 \\leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \\leq 10^9\n\nThe area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.\n\nWe can prove that there always exist six integers that satisfy the conditions under the constraints of this problem.\n\nConstraints\n\n1 \\leq S \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions, in this order, with spaces in between.\nIf multiple solutions exist, any of them will be accepted.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n1 0 2 2 0 1\n\nThe area of the triangle in a two-dimensional plane whose vertices are (1,0),(2,2), and (0,1) is 3/2.\nPrinting 3 0 3 1 0 1 or 1 0 0 1 2 2 will also be accepted.\n\nSample Input 2\n\n100\n\nSample Output 2\n\n0 0 10 0 0 10\n\nSample Input 3\n\n311114770564041497\n\nSample Output 3\n\n314159265 358979323 846264338 327950288 419716939 937510582", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 252, "cpu_time_ms": 354, "memory_kb": 25808}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s112940735", "group_id": "codeNet:p02969", "input_text": "import scala.io.StdIn._\nobject Main extends App {\n val r = readInt\n println(3 * r * r)\n}", "language": "Scala", "metadata": {"date": 1575049012, "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/s112940735.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s112940735", "user_id": "u132324749"}, "prompt_components": {"gold_output": "48\n", "input_to_evaluate": "import scala.io.StdIn._\nobject Main extends App {\n val r = readInt\n println(3 * r * r)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIt is known that the area of a regular dodecagon inscribed in a circle of radius a is 3a^2.\n\nGiven an integer r, find the area of a regular dodecagon inscribed in a circle of radius r.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nr is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint an integer representing the area of the regular dodecagon.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n48\n\nThe area of the regular dodecagon is 3 \\times 4^2 = 48.\n\nSample Input 2\n\n15\n\nSample Output 2\n\n675\n\nSample Input 3\n\n80\n\nSample Output 3\n\n19200", "sample_input": "4\n"}, "reference_outputs": ["48\n"], "source_document_id": "p02969", "source_text": "Score : 100 points\n\nProblem Statement\n\nIt is known that the area of a regular dodecagon inscribed in a circle of radius a is 3a^2.\n\nGiven an integer r, find the area of a regular dodecagon inscribed in a circle of radius r.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nr is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint an integer representing the area of the regular dodecagon.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n48\n\nThe area of the regular dodecagon is 3 \\times 4^2 = 48.\n\nSample Input 2\n\n15\n\nSample Output 2\n\n675\n\nSample Input 3\n\n80\n\nSample Output 3\n\n19200", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 90, "cpu_time_ms": 326, "memory_kb": 27216}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s792138160", "group_id": "codeNet:p02969", "input_text": "object Main extends App {\n println(((t:Int) => 3 * t * t)(readLine.toInt))\n}", "language": "Scala", "metadata": {"date": 1564813578, "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/s792138160.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s792138160", "user_id": "u782685137"}, "prompt_components": {"gold_output": "48\n", "input_to_evaluate": "object Main extends App {\n println(((t:Int) => 3 * t * t)(readLine.toInt))\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIt is known that the area of a regular dodecagon inscribed in a circle of radius a is 3a^2.\n\nGiven an integer r, find the area of a regular dodecagon inscribed in a circle of radius r.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nr is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint an integer representing the area of the regular dodecagon.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n48\n\nThe area of the regular dodecagon is 3 \\times 4^2 = 48.\n\nSample Input 2\n\n15\n\nSample Output 2\n\n675\n\nSample Input 3\n\n80\n\nSample Output 3\n\n19200", "sample_input": "4\n"}, "reference_outputs": ["48\n"], "source_document_id": "p02969", "source_text": "Score : 100 points\n\nProblem Statement\n\nIt is known that the area of a regular dodecagon inscribed in a circle of radius a is 3a^2.\n\nGiven an integer r, find the area of a regular dodecagon inscribed in a circle of radius r.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nr is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint an integer representing the area of the regular dodecagon.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n48\n\nThe area of the regular dodecagon is 3 \\times 4^2 = 48.\n\nSample Input 2\n\n15\n\nSample Output 2\n\n675\n\nSample Input 3\n\n80\n\nSample Output 3\n\n19200", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 79, "cpu_time_ms": 324, "memory_kb": 25520}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s477059019", "group_id": "codeNet:p02969", "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 r = sc.nextInt\n// val list = List.fill(3)(sc.nextInt)\n\n val ans = 3 * pow(r, 2)\n\n println(ans.toInt)\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": 1564274575, "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/s477059019.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s477059019", "user_id": "u040380439"}, "prompt_components": {"gold_output": "48\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 r = sc.nextInt\n// val list = List.fill(3)(sc.nextInt)\n\n val ans = 3 * pow(r, 2)\n\n println(ans.toInt)\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\nIt is known that the area of a regular dodecagon inscribed in a circle of radius a is 3a^2.\n\nGiven an integer r, find the area of a regular dodecagon inscribed in a circle of radius r.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nr is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint an integer representing the area of the regular dodecagon.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n48\n\nThe area of the regular dodecagon is 3 \\times 4^2 = 48.\n\nSample Input 2\n\n15\n\nSample Output 2\n\n675\n\nSample Input 3\n\n80\n\nSample Output 3\n\n19200", "sample_input": "4\n"}, "reference_outputs": ["48\n"], "source_document_id": "p02969", "source_text": "Score : 100 points\n\nProblem Statement\n\nIt is known that the area of a regular dodecagon inscribed in a circle of radius a is 3a^2.\n\nGiven an integer r, find the area of a regular dodecagon inscribed in a circle of radius r.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nr is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint an integer representing the area of the regular dodecagon.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n48\n\nThe area of the regular dodecagon is 3 \\times 4^2 = 48.\n\nSample Input 2\n\n15\n\nSample Output 2\n\n675\n\nSample Input 3\n\n80\n\nSample Output 3\n\n19200", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 941, "cpu_time_ms": 348, "memory_kb": 25424}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s295468522", "group_id": "codeNet:p02971", "input_text": "import scala.io.StdIn._\nobject Main extends App {\n val n = readInt\n val as = Array.fill(n)(readInt)\n val sorted = as.sorted\n val max = sorted(n - 1)\n val second = sorted(n - 2)\n\n val pw = new java.io.PrintWriter(System.out)\n as.foreach {a => pw.println(if (a == max) second else max)}\n pw.flush()\n}", "language": "Scala", "metadata": {"date": 1575044669, "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/s295468522.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s295468522", "user_id": "u132324749"}, "prompt_components": {"gold_output": "4\n3\n4\n", "input_to_evaluate": "import scala.io.StdIn._\nobject Main extends App {\n val n = readInt\n val as = Array.fill(n)(readInt)\n val sorted = as.sorted\n val max = sorted(n - 1)\n val second = sorted(n - 2)\n\n val pw = new java.io.PrintWriter(System.out)\n as.foreach {a => pw.println(if (a == max) second else max)}\n pw.flush()\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of length N: A_1, A_2, ..., A_N.\nFor each integer i between 1 and N (inclusive), answer the following question:\n\nFind the maximum value among the N-1 elements other than A_i in the sequence.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 200000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint N lines. The i-th line (1 \\leq i \\leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence.\n\nSample Input 1\n\n3\n1\n4\n3\n\nSample Output 1\n\n4\n3\n4\n\nThe maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n\nThe maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n\nThe maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\nSample Input 2\n\n2\n5\n5\n\nSample Output 2\n\n5\n5", "sample_input": "3\n1\n4\n3\n"}, "reference_outputs": ["4\n3\n4\n"], "source_document_id": "p02971", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of length N: A_1, A_2, ..., A_N.\nFor each integer i between 1 and N (inclusive), answer the following question:\n\nFind the maximum value among the N-1 elements other than A_i in the sequence.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 200000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint N lines. The i-th line (1 \\leq i \\leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence.\n\nSample Input 1\n\n3\n1\n4\n3\n\nSample Output 1\n\n4\n3\n4\n\nThe maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n\nThe maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n\nThe maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\nSample Input 2\n\n2\n5\n5\n\nSample Output 2\n\n5\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 306, "cpu_time_ms": 795, "memory_kb": 44712}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s014138915", "group_id": "codeNet:p02971", "input_text": "object Main extends App {\n val n = scala.io.StdIn.readInt\n val a = Array.tabulate(n)(i => scala.io.StdIn.readInt)\n var b = a.sorted.reverse\n var m0 = b(0)\n var m1 = b(1)\n for(i <- 0 until n) {\n if(a(i) == m0) {\n println(m1)\n } else {\n println(m0)\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1570418568, "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/s014138915.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s014138915", "user_id": "u363207161"}, "prompt_components": {"gold_output": "4\n3\n4\n", "input_to_evaluate": "object Main extends App {\n val n = scala.io.StdIn.readInt\n val a = Array.tabulate(n)(i => scala.io.StdIn.readInt)\n var b = a.sorted.reverse\n var m0 = b(0)\n var m1 = b(1)\n for(i <- 0 until n) {\n if(a(i) == m0) {\n println(m1)\n } else {\n println(m0)\n }\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of length N: A_1, A_2, ..., A_N.\nFor each integer i between 1 and N (inclusive), answer the following question:\n\nFind the maximum value among the N-1 elements other than A_i in the sequence.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 200000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint N lines. The i-th line (1 \\leq i \\leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence.\n\nSample Input 1\n\n3\n1\n4\n3\n\nSample Output 1\n\n4\n3\n4\n\nThe maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n\nThe maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n\nThe maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\nSample Input 2\n\n2\n5\n5\n\nSample Output 2\n\n5\n5", "sample_input": "3\n1\n4\n3\n"}, "reference_outputs": ["4\n3\n4\n"], "source_document_id": "p02971", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of length N: A_1, A_2, ..., A_N.\nFor each integer i between 1 and N (inclusive), answer the following question:\n\nFind the maximum value among the N-1 elements other than A_i in the sequence.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 200000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint N lines. The i-th line (1 \\leq i \\leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence.\n\nSample Input 1\n\n3\n1\n4\n3\n\nSample Output 1\n\n4\n3\n4\n\nThe maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n\nThe maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n\nThe maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\nSample Input 2\n\n2\n5\n5\n\nSample Output 2\n\n5\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 281, "cpu_time_ms": 1724, "memory_kb": 51280}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s920949476", "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 = Vector.fill(N)(sc.nextInt)\n sc.close()\n\n val max2 = A.sorted.takeRight(2)\n A.foreach(d => {\n if (d == max2.last) {\n println(max2.head)\n } else {\n println(max2.last)\n }\n })\n }\n}", "language": "Scala", "metadata": {"date": 1563677728, "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/s920949476.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s920949476", "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 = Vector.fill(N)(sc.nextInt)\n sc.close()\n\n val max2 = A.sorted.takeRight(2)\n A.foreach(d => {\n if (d == max2.last) {\n println(max2.head)\n } else {\n println(max2.last)\n }\n })\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of length N: A_1, A_2, ..., A_N.\nFor each integer i between 1 and N (inclusive), answer the following question:\n\nFind the maximum value among the N-1 elements other than A_i in the sequence.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 200000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint N lines. The i-th line (1 \\leq i \\leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence.\n\nSample Input 1\n\n3\n1\n4\n3\n\nSample Output 1\n\n4\n3\n4\n\nThe maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n\nThe maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n\nThe maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\nSample Input 2\n\n2\n5\n5\n\nSample Output 2\n\n5\n5", "sample_input": "3\n1\n4\n3\n"}, "reference_outputs": ["4\n3\n4\n"], "source_document_id": "p02971", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of length N: A_1, A_2, ..., A_N.\nFor each integer i between 1 and N (inclusive), answer the following question:\n\nFind the maximum value among the N-1 elements other than A_i in the sequence.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq A_i \\leq 200000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint N lines. The i-th line (1 \\leq i \\leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence.\n\nSample Input 1\n\n3\n1\n4\n3\n\nSample Output 1\n\n4\n3\n4\n\nThe maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n\nThe maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n\nThe maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\nSample Input 2\n\n2\n5\n5\n\nSample Output 2\n\n5\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 355, "cpu_time_ms": 2006, "memory_kb": 76080}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s333377412", "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 = IndexedSeq.fill(n)(sc.nextInt)\n\n for (i <- (0 to n - 1)) {\n val tmp = a.splitAt(i)\n println((tmp._1 ++ tmp._2.tail).max)\n }\n}", "language": "Scala", "metadata": {"date": 1563673590, "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/s333377412.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s333377412", "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 = IndexedSeq.fill(n)(sc.nextInt)\n\n for (i <- (0 to n - 1)) {\n val tmp = a.splitAt(i)\n println((tmp._1 ++ tmp._2.tail).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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 114896}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s113521532", "group_id": "codeNet:p02972", "input_text": "\nobject Main extends App {\n\n import scala.collection.mutable\n\n val n = scala.io.StdIn.readLine.toInt\n val a = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\n var data = mutable.TreeSet.empty[Int]\n\n var cnt = n\n\n def getOdd(cnt: Int): Boolean = {\n data.count { a => a % cnt == 0 } % 2 == 0\n }\n\n def getOdd2(cnt: Int): Boolean = {\n var sumcnt = 0\n var now = cnt + cnt\n while (now <= n) {\n if (data(now)) {\n sumcnt += 1\n }\n\n now += cnt\n }\n\n sumcnt % 2 == 0\n }\n\n while (cnt >= 1) {\n val array_cnt = cnt - 1\n // 偶数 or 奇数\n val odd = getOdd2(cnt)\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.toList.sorted.mkString(\" \"))\n }\n}\n", "language": "Scala", "metadata": {"date": 1563673322, "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/s113521532.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s113521532", "user_id": "u654455149"}, "prompt_components": {"gold_output": "1\n1\n", "input_to_evaluate": "\nobject Main extends App {\n\n import scala.collection.mutable\n\n val n = scala.io.StdIn.readLine.toInt\n val a = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\n var data = mutable.TreeSet.empty[Int]\n\n var cnt = n\n\n def getOdd(cnt: Int): Boolean = {\n data.count { a => a % cnt == 0 } % 2 == 0\n }\n\n def getOdd2(cnt: Int): Boolean = {\n var sumcnt = 0\n var now = cnt + cnt\n while (now <= n) {\n if (data(now)) {\n sumcnt += 1\n }\n\n now += cnt\n }\n\n sumcnt % 2 == 0\n }\n\n while (cnt >= 1) {\n val array_cnt = cnt - 1\n // 偶数 or 奇数\n val odd = getOdd2(cnt)\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.toList.sorted.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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1145, "cpu_time_ms": 1349, "memory_kb": 102524}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s523499540", "group_id": "codeNet:p02975", "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 N = ni()\n val C = mutable.Map[Int, Int]().withDefaultValue(0)\n REP(N) { _ =>\n val a = ni()\n C(a) += 1\n }\n\n val ok = (C.size == 1 && C(0) > 0) ||\n (C.size == 2 && C(0) > 0 && {\n val Ca = C.toArray\n val (a, aCnt) = Ca(0)\n val (_, bCnt) = Ca(1)\n if (a == 0) {\n aCnt * 2 == bCnt\n } else {\n aCnt == bCnt * 2\n }\n }) ||\n (C.size == 3 && {\n val Ca = C.toArray\n val (a, aCnt) = Ca(0)\n val (b, bCnt) = Ca(1)\n val (c, cCnt) = Ca(2)\n (a ^ b) == c && aCnt == bCnt && bCnt == cCnt\n })\n\n if (ok) out.println(\"Yes\")\n else out.println(\"No\")\n }\n}", "language": "Scala", "metadata": {"date": 1563155311, "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/s523499540.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s523499540", "user_id": "u460609472"}, "prompt_components": {"gold_output": "Yes\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 N = ni()\n val C = mutable.Map[Int, Int]().withDefaultValue(0)\n REP(N) { _ =>\n val a = ni()\n C(a) += 1\n }\n\n val ok = (C.size == 1 && C(0) > 0) ||\n (C.size == 2 && C(0) > 0 && {\n val Ca = C.toArray\n val (a, aCnt) = Ca(0)\n val (_, bCnt) = Ca(1)\n if (a == 0) {\n aCnt * 2 == bCnt\n } else {\n aCnt == bCnt * 2\n }\n }) ||\n (C.size == 3 && {\n val Ca = C.toArray\n val (a, aCnt) = Ca(0)\n val (b, bCnt) = Ca(1)\n val (c, cCnt) = Ca(2)\n (a ^ b) == c && aCnt == bCnt && bCnt == cCnt\n })\n\n if (ok) out.println(\"Yes\")\n else out.println(\"No\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4287, "cpu_time_ms": 675, "memory_kb": 43016}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s045744861", "group_id": "codeNet:p02981", "input_text": "import scala.io.StdIn._\nobject Main extends App {\n val Array(n, a, b) = readLine.split(\" \").map(_.toInt)\n println(Math.min(n * a, b))\n}", "language": "Scala", "metadata": {"date": 1575056708, "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/s045744861.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s045744861", "user_id": "u132324749"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import scala.io.StdIn._\nobject Main extends App {\n val Array(n, a, b) = readLine.split(\" \").map(_.toInt)\n println(Math.min(n * a, b))\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nN of us are going on a trip, by train or taxi.\n\nThe train will cost each of us A yen (the currency of Japan).\n\nThe taxi will cost us a total of B yen.\n\nHow much is our minimum total travel expense?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq A \\leq 50\n\n1 \\leq B \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint an integer representing the minimum total travel expense.\n\nSample Input 1\n\n4 2 9\n\nSample Output 1\n\n8\n\nThe train will cost us 4 \\times 2 = 8 yen, and the taxi will cost us 9 yen, so the minimum total travel expense is 8 yen.\n\nSample Input 2\n\n4 2 7\n\nSample Output 2\n\n7\n\nSample Input 3\n\n4 2 8\n\nSample Output 3\n\n8", "sample_input": "4 2 9\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02981", "source_text": "Score : 100 points\n\nProblem Statement\n\nN of us are going on a trip, by train or taxi.\n\nThe train will cost each of us A yen (the currency of Japan).\n\nThe taxi will cost us a total of B yen.\n\nHow much is our minimum total travel expense?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq A \\leq 50\n\n1 \\leq B \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint an integer representing the minimum total travel expense.\n\nSample Input 1\n\n4 2 9\n\nSample Output 1\n\n8\n\nThe train will cost us 4 \\times 2 = 8 yen, and the taxi will cost us 9 yen, so the minimum total travel expense is 8 yen.\n\nSample Input 2\n\n4 2 7\n\nSample Output 2\n\n7\n\nSample Input 3\n\n4 2 8\n\nSample Output 3\n\n8", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 137, "cpu_time_ms": 324, "memory_kb": 25416}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s959221079", "group_id": "codeNet:p02981", "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, A, B = sc.nextInt()\n\n println((A * N) min B)\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1562548680, "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/s959221079.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s959221079", "user_id": "u891387249"}, "prompt_components": {"gold_output": "8\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, A, B = sc.nextInt()\n\n println((A * N) min B)\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 172, "cpu_time_ms": 357, "memory_kb": 25804}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s618241986", "group_id": "codeNet:p02981", "input_text": "object Main extends App {\n var a = readLine.split(\" \").map(_.toInt)\n if(a(0)*a(1)\n scala.io.StdIn.readLine.split(\" \").map(_.toInt).toList\n }\n\n var ans = 0\n (0 until n - 1).foreach { i =>\n (i + 1 until n).foreach { j =>\n val sum = (0 until d).map { k =>\n //println(x(i)(k) + \" \" + x(j)(k))\n Math.pow(abs(x(i)(k) - x(j)(k)), 2)\n }.sum\n // println(sum)\n val sq = sqrt(sum).toInt\n if (sq * sq == sum) {\n ans += 1\n }\n }\n }\n\n println(ans)\n}\n", "language": "Scala", "metadata": {"date": 1562548334, "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/s247404342.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s247404342", "user_id": "u654455149"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main extends App {\n\n import scala.math._\n\n val Array(n, d) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\n val x = (1 to n).map { i =>\n scala.io.StdIn.readLine.split(\" \").map(_.toInt).toList\n }\n\n var ans = 0\n (0 until n - 1).foreach { i =>\n (i + 1 until n).foreach { j =>\n val sum = (0 until d).map { k =>\n //println(x(i)(k) + \" \" + x(j)(k))\n Math.pow(abs(x(i)(k) - x(j)(k)), 2)\n }.sum\n // println(sum)\n val sq = sqrt(sum).toInt\n if (sq * sq == sum) {\n ans += 1\n }\n }\n }\n\n println(ans)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N points in a D-dimensional space.\n\nThe coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).\n\nThe distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \\sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.\n\nHow many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10\n\n1 \\leq D \\leq 10\n\n-20 \\leq X_{ij} \\leq 20\n\nNo two given points have the same coordinates. That is, if i \\neq j, there exists k such that X_{ik} \\neq X_{jk}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_{11} X_{12} ... X_{1D}\nX_{21} X_{22} ... X_{2D}\n\\vdots\nX_{N1} X_{N2} ... X_{ND}\n\nOutput\n\nPrint the number of pairs (i, j) (i < j) such that the distance between the i-th point and the j-th point is an integer.\n\nSample Input 1\n\n3 2\n1 2\n5 5\n-2 8\n\nSample Output 1\n\n1\n\nThe number of pairs with an integer distance is one, as follows:\n\nThe distance between the first point and the second point is \\sqrt{|1-5|^2 + |2-5|^2} = 5, which is an integer.\n\nThe distance between the second point and the third point is \\sqrt{|5-(-2)|^2 + |5-8|^2} = \\sqrt{58}, which is not an integer.\n\nThe distance between the third point and the first point is \\sqrt{|-2-1|^2+|8-2|^2} = 3\\sqrt{5}, which is not an integer.\n\nSample Input 2\n\n3 4\n-3 7 8 2\n-12 1 10 2\n-2 8 9 3\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 1\n1\n2\n3\n4\n5\n\nSample Output 3\n\n10", "sample_input": "3 2\n1 2\n5 5\n-2 8\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02982", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N points in a D-dimensional space.\n\nThe coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).\n\nThe distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \\sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.\n\nHow many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10\n\n1 \\leq D \\leq 10\n\n-20 \\leq X_{ij} \\leq 20\n\nNo two given points have the same coordinates. That is, if i \\neq j, there exists k such that X_{ik} \\neq X_{jk}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_{11} X_{12} ... X_{1D}\nX_{21} X_{22} ... X_{2D}\n\\vdots\nX_{N1} X_{N2} ... X_{ND}\n\nOutput\n\nPrint the number of pairs (i, j) (i < j) such that the distance between the i-th point and the j-th point is an integer.\n\nSample Input 1\n\n3 2\n1 2\n5 5\n-2 8\n\nSample Output 1\n\n1\n\nThe number of pairs with an integer distance is one, as follows:\n\nThe distance between the first point and the second point is \\sqrt{|1-5|^2 + |2-5|^2} = 5, which is an integer.\n\nThe distance between the second point and the third point is \\sqrt{|5-(-2)|^2 + |5-8|^2} = \\sqrt{58}, which is not an integer.\n\nThe distance between the third point and the first point is \\sqrt{|-2-1|^2+|8-2|^2} = 3\\sqrt{5}, which is not an integer.\n\nSample Input 2\n\n3 4\n-3 7 8 2\n-12 1 10 2\n-2 8 9 3\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 1\n1\n2\n3\n4\n5\n\nSample Output 3\n\n10", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 566, "cpu_time_ms": 349, "memory_kb": 25536}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s375576913", "group_id": "codeNet:p02984", "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 val A = new Array[Int](N+1)\n for (i <- 1 to N)\n A(i) = in.next().toInt\n\n\n\n\n //\n def check(num: Int): Int = {\n val memo = new Array[Int](N+1)\n memo(1) = num\n memo(N) = num\n for (i <- 2 to N) {\n val tmp = A(i-1) - memo(i-1)\n memo(i-1) += tmp\n memo(i) += tmp\n }\n\n val res = A(N) - memo(N)\n Math.abs(res)\n }\n\n // 下に凸のグラフの最小値\n def ternarySearchInt(small: Int, big: Int): Int = {\n if(big - small <= 2) {\n val mid = (big + small) / 2\n if(check(big) <= check(mid)) big\n else if(check(small) <= check(mid)) small\n else mid\n }\n else{\n val midl = (big + small) / 2\n val midr = midl + 1\n if (check(midl) >= check(midr))\n ternarySearchInt(midl, big)\n else\n ternarySearchInt(small, midr)\n }\n }\n\n\n val ans = ternarySearchInt(0, 1e9.toInt)\n\n val memo = new Array[Int](N+1)\n val com = new Array[Int](N+1)\n memo(1) = ans\n memo(N) = ans\n com(1) = ans\n for (i <- 2 to N) {\n val tmp = A(i-1) - memo(i-1)\n com(i) = tmp\n memo(i-1) += tmp\n memo(i) += tmp\n }\n\n val res = A(N) - memo(N)\n Math.abs(res)\n\n pw.print(com(1)*2)\n for(i <- 2 to N)\n pw.print(s\" ${com(i)*2}\")\n pw.println\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": 1562550707, "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/s375576913.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s375576913", "user_id": "u098968285"}, "prompt_components": {"gold_output": "4 0 4\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 val A = new Array[Int](N+1)\n for (i <- 1 to N)\n A(i) = in.next().toInt\n\n\n\n\n //\n def check(num: Int): Int = {\n val memo = new Array[Int](N+1)\n memo(1) = num\n memo(N) = num\n for (i <- 2 to N) {\n val tmp = A(i-1) - memo(i-1)\n memo(i-1) += tmp\n memo(i) += tmp\n }\n\n val res = A(N) - memo(N)\n Math.abs(res)\n }\n\n // 下に凸のグラフの最小値\n def ternarySearchInt(small: Int, big: Int): Int = {\n if(big - small <= 2) {\n val mid = (big + small) / 2\n if(check(big) <= check(mid)) big\n else if(check(small) <= check(mid)) small\n else mid\n }\n else{\n val midl = (big + small) / 2\n val midr = midl + 1\n if (check(midl) >= check(midr))\n ternarySearchInt(midl, big)\n else\n ternarySearchInt(small, midr)\n }\n }\n\n\n val ans = ternarySearchInt(0, 1e9.toInt)\n\n val memo = new Array[Int](N+1)\n val com = new Array[Int](N+1)\n memo(1) = ans\n memo(N) = ans\n com(1) = ans\n for (i <- 2 to N) {\n val tmp = A(i-1) - memo(i-1)\n com(i) = tmp\n memo(i-1) += tmp\n memo(i) += tmp\n }\n\n val res = A(N) - memo(N)\n Math.abs(res)\n\n pw.print(com(1)*2)\n for(i <- 2 to N)\n pw.print(s\" ${com(i)*2}\")\n pw.println\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 : 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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1898, "cpu_time_ms": 843, "memory_kb": 65672}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s508334968", "group_id": "codeNet:p02989", "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 d = Array.fill(N)(sc.nextInt)\n\n val x = d.sorted\n val abc = x(N / 2 - 1)\n val arc = x(N / 2)\n println(arc - abc)\n}\n", "language": "Scala", "metadata": {"date": 1594575247, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02989.html", "problem_id": "p02989", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02989/input.txt", "sample_output_relpath": "derived/input_output/data/p02989/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02989/Scala/s508334968.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s508334968", "user_id": "u786167609"}, "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 d = Array.fill(N)(sc.nextInt)\n\n val x = d.sorted\n val abc = x(N / 2 - 1)\n val arc = x(N / 2)\n println(arc - abc)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi made N problems for competitive programming.\nThe problems are numbered 1 to N, and the difficulty of Problem i is represented as an integer d_i (the higher, the harder).\n\nHe is dividing the problems into two categories by choosing an integer K, as follows:\n\nA problem with difficulty K or higher will be for ARCs.\n\nA problem with difficulty lower than K will be for ABCs.\n\nHow many choices of the integer K make the number of problems for ARCs and the number of problems for ABCs the same?\n\nProblem Statement\n\n2 \\leq N \\leq 10^5\n\nN is an even number.\n\n1 \\leq d_i \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1 d_2 ... d_N\n\nOutput\n\nPrint the number of choices of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 1\n\n6\n9 1 4 4 6 7\n\nSample Output 1\n\n2\n\nIf we choose K=5 or 6, Problem 1, 5, and 6 will be for ARCs, Problem 2, 3, and 4 will be for ABCs, and the objective is achieved.\nThus, the answer is 2.\n\nSample Input 2\n\n8\n9 1 14 5 5 4 4 14\n\nSample Output 2\n\n0\n\nThere may be no choice of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 3\n\n14\n99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1\n\nSample Output 3\n\n42685", "sample_input": "6\n9 1 4 4 6 7\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02989", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi made N problems for competitive programming.\nThe problems are numbered 1 to N, and the difficulty of Problem i is represented as an integer d_i (the higher, the harder).\n\nHe is dividing the problems into two categories by choosing an integer K, as follows:\n\nA problem with difficulty K or higher will be for ARCs.\n\nA problem with difficulty lower than K will be for ABCs.\n\nHow many choices of the integer K make the number of problems for ARCs and the number of problems for ABCs the same?\n\nProblem Statement\n\n2 \\leq N \\leq 10^5\n\nN is an even number.\n\n1 \\leq d_i \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1 d_2 ... d_N\n\nOutput\n\nPrint the number of choices of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 1\n\n6\n9 1 4 4 6 7\n\nSample Output 1\n\n2\n\nIf we choose K=5 or 6, Problem 1, 5, and 6 will be for ARCs, Problem 2, 3, and 4 will be for ABCs, and the objective is achieved.\nThus, the answer is 2.\n\nSample Input 2\n\n8\n9 1 14 5 5 4 4 14\n\nSample Output 2\n\n0\n\nThere may be no choice of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 3\n\n14\n99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1\n\nSample Output 3\n\n42685", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 232, "cpu_time_ms": 782, "memory_kb": 59888}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s564437329", "group_id": "codeNet:p02989", "input_text": "object Main extends App{\n val n = readInt\n val ds = readLine.split(\" \").map(_.toInt).sorted\n println(ds(n/2)-ds(n/2-1))\n}", "language": "Scala", "metadata": {"date": 1566869918, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02989.html", "problem_id": "p02989", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02989/input.txt", "sample_output_relpath": "derived/input_output/data/p02989/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02989/Scala/s564437329.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s564437329", "user_id": "u782685137"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App{\n val n = readInt\n val ds = readLine.split(\" \").map(_.toInt).sorted\n println(ds(n/2)-ds(n/2-1))\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi made N problems for competitive programming.\nThe problems are numbered 1 to N, and the difficulty of Problem i is represented as an integer d_i (the higher, the harder).\n\nHe is dividing the problems into two categories by choosing an integer K, as follows:\n\nA problem with difficulty K or higher will be for ARCs.\n\nA problem with difficulty lower than K will be for ABCs.\n\nHow many choices of the integer K make the number of problems for ARCs and the number of problems for ABCs the same?\n\nProblem Statement\n\n2 \\leq N \\leq 10^5\n\nN is an even number.\n\n1 \\leq d_i \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1 d_2 ... d_N\n\nOutput\n\nPrint the number of choices of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 1\n\n6\n9 1 4 4 6 7\n\nSample Output 1\n\n2\n\nIf we choose K=5 or 6, Problem 1, 5, and 6 will be for ARCs, Problem 2, 3, and 4 will be for ABCs, and the objective is achieved.\nThus, the answer is 2.\n\nSample Input 2\n\n8\n9 1 14 5 5 4 4 14\n\nSample Output 2\n\n0\n\nThere may be no choice of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 3\n\n14\n99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1\n\nSample Output 3\n\n42685", "sample_input": "6\n9 1 4 4 6 7\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02989", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi made N problems for competitive programming.\nThe problems are numbered 1 to N, and the difficulty of Problem i is represented as an integer d_i (the higher, the harder).\n\nHe is dividing the problems into two categories by choosing an integer K, as follows:\n\nA problem with difficulty K or higher will be for ARCs.\n\nA problem with difficulty lower than K will be for ABCs.\n\nHow many choices of the integer K make the number of problems for ARCs and the number of problems for ABCs the same?\n\nProblem Statement\n\n2 \\leq N \\leq 10^5\n\nN is an even number.\n\n1 \\leq d_i \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1 d_2 ... d_N\n\nOutput\n\nPrint the number of choices of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 1\n\n6\n9 1 4 4 6 7\n\nSample Output 1\n\n2\n\nIf we choose K=5 or 6, Problem 1, 5, and 6 will be for ARCs, Problem 2, 3, and 4 will be for ABCs, and the objective is achieved.\nThus, the answer is 2.\n\nSample Input 2\n\n8\n9 1 14 5 5 4 4 14\n\nSample Output 2\n\n0\n\nThere may be no choice of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 3\n\n14\n99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1\n\nSample Output 3\n\n42685", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 124, "cpu_time_ms": 698, "memory_kb": 43096}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s109210839", "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[Long] = {\n val MAX: Long = Math.pow(10, 9).toLong + 7\n val nCr = Array.fill(N+1, K+1)(0L)\n for {\n i <- 0 to N\n } {\n nCr(i)(0) = 1\n for {\n j <- 1 to (i min K)\n } nCr(i)(j) = nCr(i-1)(j-1) + nCr(i-1)(j)\n }\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": 1577559175, "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/s109210839.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s109210839", "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[Long] = {\n val MAX: Long = Math.pow(10, 9).toLong + 7\n val nCr = Array.fill(N+1, K+1)(0L)\n for {\n i <- 0 to N\n } {\n nCr(i)(0) = 1\n for {\n j <- 1 to (i min K)\n } nCr(i)(j) = nCr(i-1)(j-1) + nCr(i-1)(j)\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1312, "cpu_time_ms": 457, "memory_kb": 69884}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s415025843", "group_id": "codeNet:p02994", "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 val A: Array[Int] = (0 to 100001).toArray\n\n def solve(sc: => Scanner): Unit = {\n val N, L = sc.nextLong()\n val A = (1L to N).map(i => L + i - 1)\n val B = A.map(i => Math.abs(i)).min\n println(A.sum - (if (A.contains(B)) B else -B))\n }\n\n def recursive(now: Int, M: Int): Int = {\n if (now > M) -1 else {\n if (A(now) == now) {\n A(now) += 1\n A(now)\n } else {\n val B = recursive(A(now), M)\n if (B == -1) -1 else {\n A(now) = B\n A(now)\n }\n }\n }\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\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": 1566164897, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02994.html", "problem_id": "p02994", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02994/input.txt", "sample_output_relpath": "derived/input_output/data/p02994/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02994/Scala/s415025843.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s415025843", "user_id": "u779353743"}, "prompt_components": {"gold_output": "18\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 val A: Array[Int] = (0 to 100001).toArray\n\n def solve(sc: => Scanner): Unit = {\n val N, L = sc.nextLong()\n val A = (1L to N).map(i => L + i - 1)\n val B = A.map(i => Math.abs(i)).min\n println(A.sum - (if (A.contains(B)) B else -B))\n }\n\n def recursive(now: Int, M: Int): Int = {\n if (now > M) -1 else {\n if (A(now) == now) {\n A(now) += 1\n A(now)\n } else {\n val B = recursive(A(now), M)\n if (B == -1) -1 else {\n A(now) = B\n A(now)\n }\n }\n }\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\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\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "sample_input": "5 2\n"}, "reference_outputs": ["18\n"], "source_document_id": "p02994", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 7027, "cpu_time_ms": 377, "memory_kb": 27928}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s699079526", "group_id": "codeNet:p02994", "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,l = s.nextInt\n val apples = (l until (l + n))\n val aMin = apples.minBy(Math.abs(_))\n apples.filter(_ != aMin).sum.toString\n }\n\n val tests = List(\n \"\"\"5 2\"\"\".stripMargin -> \"\"\"18\"\"\",\n \"\"\"3 -1\"\"\".stripMargin -> \"\"\"0\"\"\",\n \"\"\"30 -50\"\"\".stripMargin -> \"\"\"-1044\"\"\"\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": 1563509778, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02994.html", "problem_id": "p02994", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02994/input.txt", "sample_output_relpath": "derived/input_output/data/p02994/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02994/Scala/s699079526.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s699079526", "user_id": "u334087399"}, "prompt_components": {"gold_output": "18\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,l = s.nextInt\n val apples = (l until (l + n))\n val aMin = apples.minBy(Math.abs(_))\n apples.filter(_ != aMin).sum.toString\n }\n\n val tests = List(\n \"\"\"5 2\"\"\".stripMargin -> \"\"\"18\"\"\",\n \"\"\"3 -1\"\"\".stripMargin -> \"\"\"0\"\"\",\n \"\"\"30 -50\"\"\".stripMargin -> \"\"\"-1044\"\"\"\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\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "sample_input": "5 2\n"}, "reference_outputs": ["18\n"], "source_document_id": "p02994", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 994, "cpu_time_ms": 344, "memory_kb": 25652}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s379444092", "group_id": "codeNet:p02994", "input_text": "object Main extends App {\n val input = io.StdIn.readLine().split(\" \").map(_.toInt)\n val N = input(0)\n val L = input(1)\n\n val apples = (1 to N).toArray\n val tastes = apples.map { a => L + a - 1 }\n val totalTaste = tastes.sum\n // 全てが正の時→最小の整数\n // 正と負の時→最小の整数\n // 全てが負の時→最大の整数\n\n val result = if (tastes.head >= 0) tastes.tail.sum\n else if (tastes.last <= 0) tastes.init.sum\n else {\n var isFound = false\n tastes.foldLeft(scala.collection.mutable.ArrayBuffer.empty[Int]) { (acc, v) =>\n if (isFound) {\n acc += v\n } else {\n if (v >= 0) {\n isFound = true\n acc\n } else {\n acc += v\n }\n }\n }.sum\n }\n\n println(result)\n}\n", "language": "Scala", "metadata": {"date": 1563460549, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02994.html", "problem_id": "p02994", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02994/input.txt", "sample_output_relpath": "derived/input_output/data/p02994/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02994/Scala/s379444092.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s379444092", "user_id": "u209719129"}, "prompt_components": {"gold_output": "18\n", "input_to_evaluate": "object Main extends App {\n val input = io.StdIn.readLine().split(\" \").map(_.toInt)\n val N = input(0)\n val L = input(1)\n\n val apples = (1 to N).toArray\n val tastes = apples.map { a => L + a - 1 }\n val totalTaste = tastes.sum\n // 全てが正の時→最小の整数\n // 正と負の時→最小の整数\n // 全てが負の時→最大の整数\n\n val result = if (tastes.head >= 0) tastes.tail.sum\n else if (tastes.last <= 0) tastes.init.sum\n else {\n var isFound = false\n tastes.foldLeft(scala.collection.mutable.ArrayBuffer.empty[Int]) { (acc, v) =>\n if (isFound) {\n acc += v\n } else {\n if (v >= 0) {\n isFound = true\n acc\n } else {\n acc += v\n }\n }\n }.sum\n }\n\n println(result)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "sample_input": "5 2\n"}, "reference_outputs": ["18\n"], "source_document_id": "p02994", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 771, "cpu_time_ms": 325, "memory_kb": 25536}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s547654415", "group_id": "codeNet:p02994", "input_text": "import scala.io.StdIn._\n\nobject Main extends App {\n\n val arr = readLine().split(\" \").map(_.toInt)\n val n = arr(0)\n val l = arr(1)\n val ajiArr: Array[Int] = Array.fill(n)(0)\n for(i <- 0 until n){ ajiArr(i) = l + i }\n val removedOne = ajiArr(n-1) match {\n case i if i < 0 => i\n case i if i == 0 => 0\n case _ => ajiArr(0)\n }\n val result = ajiArr.sum - removedOne\n println(result)\n}", "language": "Scala", "metadata": {"date": 1561255705, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02994.html", "problem_id": "p02994", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02994/input.txt", "sample_output_relpath": "derived/input_output/data/p02994/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02994/Scala/s547654415.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s547654415", "user_id": "u947008426"}, "prompt_components": {"gold_output": "18\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main extends App {\n\n val arr = readLine().split(\" \").map(_.toInt)\n val n = arr(0)\n val l = arr(1)\n val ajiArr: Array[Int] = Array.fill(n)(0)\n for(i <- 0 until n){ ajiArr(i) = l + i }\n val removedOne = ajiArr(n-1) match {\n case i if i < 0 => i\n case i if i == 0 => 0\n case _ => ajiArr(0)\n }\n val result = ajiArr.sum - removedOne\n println(result)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "sample_input": "5 2\n"}, "reference_outputs": ["18\n"], "source_document_id": "p02994", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 407, "cpu_time_ms": 321, "memory_kb": 27340}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s933759057", "group_id": "codeNet:p02994", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n, l = sc.nextInt\n val apples = (l until l + n).toList\n println(apples.sum - apples.minBy(_.abs))\n }\n}", "language": "Scala", "metadata": {"date": 1561255160, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02994.html", "problem_id": "p02994", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02994/input.txt", "sample_output_relpath": "derived/input_output/data/p02994/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02994/Scala/s933759057.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s933759057", "user_id": "u889604426"}, "prompt_components": {"gold_output": "18\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, l = sc.nextInt\n val apples = (l until l + n).toList\n println(apples.sum - apples.minBy(_.abs))\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "sample_input": "5 2\n"}, "reference_outputs": ["18\n"], "source_document_id": "p02994", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 219, "cpu_time_ms": 371, "memory_kb": 25772}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s035543192", "group_id": "codeNet:p02994", "input_text": "import scala.io.StdIn\n\n\nobject Main extends App {\n val Array(n, l) = StdIn.readLine.toString.split(\" \").map(_.toInt)\n\n def solve(n: Int, l: Int) : Int = {\n\n val ls = (1 to n).map(l + _ -1)\n var m = Int.MaxValue\n\n ls.foreach {i =>\n if (Math.abs(m) > Math.abs(i))\n m = i\n }\n ls.sum - m\n }\n println(solve(n, l))\n\n}\n \n\n", "language": "Scala", "metadata": {"date": 1561253091, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02994.html", "problem_id": "p02994", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02994/input.txt", "sample_output_relpath": "derived/input_output/data/p02994/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02994/Scala/s035543192.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s035543192", "user_id": "u258933429"}, "prompt_components": {"gold_output": "18\n", "input_to_evaluate": "import scala.io.StdIn\n\n\nobject Main extends App {\n val Array(n, l) = StdIn.readLine.toString.split(\" \").map(_.toInt)\n\n def solve(n: Int, l: Int) : Int = {\n\n val ls = (1 to n).map(l + _ -1)\n var m = Int.MaxValue\n\n ls.foreach {i =>\n if (Math.abs(m) > Math.abs(i))\n m = i\n }\n ls.sum - m\n }\n println(solve(n, l))\n\n}\n \n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "sample_input": "5 2\n"}, "reference_outputs": ["18\n"], "source_document_id": "p02994", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 349, "cpu_time_ms": 334, "memory_kb": 25420}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s235067999", "group_id": "codeNet:p02995", "input_text": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n\n readLine.trim.split(' ').map(_.toLong) match {\n case Array(a, b, c, d) =>\n val toB = b - b / c - b / d + b / lcm(c, d)\n val untilA = (a - 1) - (a - 1) / c - (a - 1) / d + (a - 1) / lcm(c, d)\n println(toB - untilA)\n case _ => ???\n }\n\n def lcm(a: Long, b: Long): Long = {\n a / gcd(a, b) * b\n }\n def gcd(a: Long, b: Long): Long = {\n b match {\n case 0 => a\n case _ => gcd(b, a % b)\n }\n }\n}", "language": "Scala", "metadata": {"date": 1598642663, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p02995.html", "problem_id": "p02995", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02995/input.txt", "sample_output_relpath": "derived/input_output/data/p02995/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02995/Scala/s235067999.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s235067999", "user_id": "u419330815"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n\n readLine.trim.split(' ').map(_.toLong) match {\n case Array(a, b, c, d) =>\n val toB = b - b / c - b / d + b / lcm(c, d)\n val untilA = (a - 1) - (a - 1) / c - (a - 1) / d + (a - 1) / lcm(c, d)\n println(toB - untilA)\n case _ => ???\n }\n\n def lcm(a: Long, b: Long): Long = {\n a / gcd(a, b) * b\n }\n def gcd(a: Long, b: Long): Long = {\n b match {\n case 0 => a\n case _ => gcd(b, a % b)\n }\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nConstraints\n\n1\\leq A\\leq B\\leq 10^{18}\n\n1\\leq C,D\\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C D\n\nOutput\n\nPrint the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nSample Input 1\n\n4 9 2 3\n\nSample Output 1\n\n2\n\n5 and 7 satisfy the condition.\n\nSample Input 2\n\n10 40 6 8\n\nSample Output 2\n\n23\n\nSample Input 3\n\n314159265358979323 846264338327950288 419716939 937510582\n\nSample Output 3\n\n532105071133627368", "sample_input": "4 9 2 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02995", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nConstraints\n\n1\\leq A\\leq B\\leq 10^{18}\n\n1\\leq C,D\\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C D\n\nOutput\n\nPrint the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nSample Input 1\n\n4 9 2 3\n\nSample Output 1\n\n2\n\n5 and 7 satisfy the condition.\n\nSample Input 2\n\n10 40 6 8\n\nSample Output 2\n\n23\n\nSample Input 3\n\n314159265358979323 846264338327950288 419716939 937510582\n\nSample Output 3\n\n532105071133627368", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 491, "cpu_time_ms": 488, "memory_kb": 54668}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s153012995", "group_id": "codeNet:p02995", "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 a = input.split(\" \").head.toLong - 1\n val b = input.split(\" \").tail.head.toLong\n val c = input.split(\" \").tail.tail.head.toLong\n val d = input.split(\" \").tail.tail.tail.head.toLong\n val nc = b / c - a / c\n val nd = b / d - a / d\n val ncd = b / lcm(c, d) - a / lcm(c, d)\n\n (b - a - (nc + nd - ncd)).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 \"\"\"4 9 2 3\"\"\".stripMargin -> \"\"\"2\n |\"\"\".stripMargin,\n \"\"\"10 40 6 8\"\"\".stripMargin -> \"\"\"23\"\"\".stripMargin,\n \"\"\"314159265358979323 846264338327950288 419716939 937510582\"\"\" -> \"532105071133627368\"\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": 1590613942, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02995.html", "problem_id": "p02995", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02995/input.txt", "sample_output_relpath": "derived/input_output/data/p02995/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02995/Scala/s153012995.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s153012995", "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 a = input.split(\" \").head.toLong - 1\n val b = input.split(\" \").tail.head.toLong\n val c = input.split(\" \").tail.tail.head.toLong\n val d = input.split(\" \").tail.tail.tail.head.toLong\n val nc = b / c - a / c\n val nd = b / d - a / d\n val ncd = b / lcm(c, d) - a / lcm(c, d)\n\n (b - a - (nc + nd - ncd)).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 \"\"\"4 9 2 3\"\"\".stripMargin -> \"\"\"2\n |\"\"\".stripMargin,\n \"\"\"10 40 6 8\"\"\".stripMargin -> \"\"\"23\"\"\".stripMargin,\n \"\"\"314159265358979323 846264338327950288 419716939 937510582\"\"\" -> \"532105071133627368\"\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 : 300 points\n\nProblem Statement\n\nYou are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nConstraints\n\n1\\leq A\\leq B\\leq 10^{18}\n\n1\\leq C,D\\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C D\n\nOutput\n\nPrint the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nSample Input 1\n\n4 9 2 3\n\nSample Output 1\n\n2\n\n5 and 7 satisfy the condition.\n\nSample Input 2\n\n10 40 6 8\n\nSample Output 2\n\n23\n\nSample Input 3\n\n314159265358979323 846264338327950288 419716939 937510582\n\nSample Output 3\n\n532105071133627368", "sample_input": "4 9 2 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02995", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nConstraints\n\n1\\leq A\\leq B\\leq 10^{18}\n\n1\\leq C,D\\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C D\n\nOutput\n\nPrint the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nSample Input 1\n\n4 9 2 3\n\nSample Output 1\n\n2\n\n5 and 7 satisfy the condition.\n\nSample Input 2\n\n10 40 6 8\n\nSample Output 2\n\n23\n\nSample Input 3\n\n314159265358979323 846264338327950288 419716939 937510582\n\nSample Output 3\n\n532105071133627368", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2098, "cpu_time_ms": 333, "memory_kb": 25532}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s930541099", "group_id": "codeNet:p02995", "input_text": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val Array(a, b, c, d) = in.readLine.split(\" \").map(_.toLong)\n\n val a1 = b / c\n val a2 = a / c\n val b1 = b / d\n val b2 = a / d\n\n val a3 = a1 - a2\n val b3 = b1 - b2\n\n def gcd(a:Long, b:Long):Long = {\n if(b == 0) a\n else gcd(b, a%b)\n }\n\n val lcm = c * d / gcd(c, d)\n\n val c1 = b / lcm\n val c2 = a / lcm\n\n val c3 = c1 - c2\n\n val t = a match {\n case x if a % c == 0 && a % d == 0 && a % lcm == 0 => 3\n case x if a % c == 0 && a % d == 0 => 2\n case x if a % c == 0 && a % lcm == 0 => 2\n case x if a % lcm == 0 && a % d == 0 => 2\n case x if a % c == 0 || a % d == 0 => 1\n case _ => 0\n }\n debug(a3, b3, c3, lcm, t, b-a)\n val ans = ((1 + b - a - t) - (a3 + b3 - c3)) max 0\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": 1561235507, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02995.html", "problem_id": "p02995", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02995/input.txt", "sample_output_relpath": "derived/input_output/data/p02995/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02995/Scala/s930541099.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s930541099", "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(a, b, c, d) = in.readLine.split(\" \").map(_.toLong)\n\n val a1 = b / c\n val a2 = a / c\n val b1 = b / d\n val b2 = a / d\n\n val a3 = a1 - a2\n val b3 = b1 - b2\n\n def gcd(a:Long, b:Long):Long = {\n if(b == 0) a\n else gcd(b, a%b)\n }\n\n val lcm = c * d / gcd(c, d)\n\n val c1 = b / lcm\n val c2 = a / lcm\n\n val c3 = c1 - c2\n\n val t = a match {\n case x if a % c == 0 && a % d == 0 && a % lcm == 0 => 3\n case x if a % c == 0 && a % d == 0 => 2\n case x if a % c == 0 && a % lcm == 0 => 2\n case x if a % lcm == 0 && a % d == 0 => 2\n case x if a % c == 0 || a % d == 0 => 1\n case _ => 0\n }\n debug(a3, b3, c3, lcm, t, b-a)\n val ans = ((1 + b - a - t) - (a3 + b3 - c3)) max 0\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 : 300 points\n\nProblem Statement\n\nYou are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nConstraints\n\n1\\leq A\\leq B\\leq 10^{18}\n\n1\\leq C,D\\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C D\n\nOutput\n\nPrint the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nSample Input 1\n\n4 9 2 3\n\nSample Output 1\n\n2\n\n5 and 7 satisfy the condition.\n\nSample Input 2\n\n10 40 6 8\n\nSample Output 2\n\n23\n\nSample Input 3\n\n314159265358979323 846264338327950288 419716939 937510582\n\nSample Output 3\n\n532105071133627368", "sample_input": "4 9 2 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02995", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nConstraints\n\n1\\leq A\\leq B\\leq 10^{18}\n\n1\\leq C,D\\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C D\n\nOutput\n\nPrint the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\nSample Input 1\n\n4 9 2 3\n\nSample Output 1\n\n2\n\n5 and 7 satisfy the condition.\n\nSample Input 2\n\n10 40 6 8\n\nSample Output 2\n\n23\n\nSample Input 3\n\n314159265358979323 846264338327950288 419716939 937510582\n\nSample Output 3\n\n532105071133627368", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 896, "cpu_time_ms": 325, "memory_kb": 25424}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s116742049", "group_id": "codeNet:p02997", "input_text": "\nobject Main extends App {\n import scala.io.StdIn._\n val Array(n, k) = readLine.trim.split(' ').map(_.toInt)\n if ((n - 1) * (n - 2) / 2 < k) {\n println(\"-1\")\n }else {\n var rest = (n - 1) * (n - 2) / 2 - k\n println(n - 1 + rest)\n for (i <- 1 until n) {\n println(s\"$i $n\")\n }\n for (i <- 1 until n; j <- 1 until i) {\n if (rest > 0) {\n println(s\"$i $j\")\n rest -= 1\n }\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1587074298, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02997.html", "problem_id": "p02997", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02997/input.txt", "sample_output_relpath": "derived/input_output/data/p02997/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02997/Scala/s116742049.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s116742049", "user_id": "u419330815"}, "prompt_components": {"gold_output": "5\n4 3\n1 2\n3 1\n4 5\n2 3\n", "input_to_evaluate": "\nobject Main extends App {\n import scala.io.StdIn._\n val Array(n, k) = readLine.trim.split(' ').map(_.toInt)\n if ((n - 1) * (n - 2) / 2 < k) {\n println(\"-1\")\n }else {\n var rest = (n - 1) * (n - 2) / 2 - k\n println(n - 1 + rest)\n for (i <- 1 until n) {\n println(s\"$i $n\")\n }\n for (i <- 1 until n; j <- 1 until i) {\n if (rest > 0) {\n println(s\"$i $j\")\n rest -= 1\n }\n }\n }\n}\n", "problem_context": "Score: 500 points\n\nProblem Statement\n\nDoes there exist an undirected graph with N vertices satisfying the following conditions?\n\nThe graph is simple and connected.\n\nThe vertices are numbered 1, 2, ..., N.\n\nLet M be the number of edges in the graph. The edges are numbered 1, 2, ..., M, the length of each edge is 1, and Edge i connects Vertex u_i and Vertex v_i.\n\nThere are exactly K pairs of vertices (i,\\ j)\\ (i < j) such that the shortest distance between them is 2.\n\nIf there exists such a graph, construct an example.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n0 \\leq K \\leq \\frac{N(N - 1)}{2}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nIf there does not exist an undirected graph with N vertices satisfying the conditions, print -1.\n\nIf there exists such a graph, print an example in the following format (refer to Problem Statement for what the symbols stand for):\n\nM\nu_1 v_1\n:\nu_M v_M\n\nIf there exist multiple graphs satisfying the conditions, any of them will be accepted.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n5\n4 3\n1 2\n3 1\n4 5\n2 3\n\nThis graph has three pairs of vertices such that the shortest distance between them is 2: (1,\\ 4), (2,\\ 4), and (3,\\ 5). Thus, the condition is satisfied.\n\nSample Input 2\n\n5 8\n\nSample Output 2\n\n-1\n\nThere is no graph satisfying the conditions.", "sample_input": "5 3\n"}, "reference_outputs": ["5\n4 3\n1 2\n3 1\n4 5\n2 3\n"], "source_document_id": "p02997", "source_text": "Score: 500 points\n\nProblem Statement\n\nDoes there exist an undirected graph with N vertices satisfying the following conditions?\n\nThe graph is simple and connected.\n\nThe vertices are numbered 1, 2, ..., N.\n\nLet M be the number of edges in the graph. The edges are numbered 1, 2, ..., M, the length of each edge is 1, and Edge i connects Vertex u_i and Vertex v_i.\n\nThere are exactly K pairs of vertices (i,\\ j)\\ (i < j) such that the shortest distance between them is 2.\n\nIf there exists such a graph, construct an example.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n0 \\leq K \\leq \\frac{N(N - 1)}{2}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nIf there does not exist an undirected graph with N vertices satisfying the conditions, print -1.\n\nIf there exists such a graph, print an example in the following format (refer to Problem Statement for what the symbols stand for):\n\nM\nu_1 v_1\n:\nu_M v_M\n\nIf there exist multiple graphs satisfying the conditions, any of them will be accepted.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n5\n4 3\n1 2\n3 1\n4 5\n2 3\n\nThis graph has three pairs of vertices such that the shortest distance between them is 2: (1,\\ 4), (2,\\ 4), and (3,\\ 5). Thus, the condition is satisfied.\n\nSample Input 2\n\n5 8\n\nSample Output 2\n\n-1\n\nThere is no graph satisfying the conditions.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 570, "memory_kb": 32140}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s248002676", "group_id": "codeNet:p02997", "input_text": "import java.io._\nimport java.util.StringTokenizer\n\nimport scala.collection.mutable.ListBuffer\nimport scala.reflect.ClassTag\n\nclass Megalomania(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 k = ni()\n\n val x = ((n-1)*(n-2)) / 2\n if(k > x) out.println(-1)\n else {\n val list = new ListBuffer[(Int, Int)]\n var add = x - k\n REP(n-1, 1) { i =>\n REP(n-1, 1) { j =>\n if(j > i && add > 0) {\n list += ((i, j))\n add -= 1\n }\n }\n }\n REP(n-1, 1) { i =>\n list += ((i, n))\n }\n out.println(list.size)\n list.foreach(f => out.println(f._1 + \" \" + f._2))\n }\n }\n}\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 Megalomania(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", "language": "Scala", "metadata": {"date": 1582299280, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02997.html", "problem_id": "p02997", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02997/input.txt", "sample_output_relpath": "derived/input_output/data/p02997/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02997/Scala/s248002676.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s248002676", "user_id": "u685944401"}, "prompt_components": {"gold_output": "5\n4 3\n1 2\n3 1\n4 5\n2 3\n", "input_to_evaluate": "import java.io._\nimport java.util.StringTokenizer\n\nimport scala.collection.mutable.ListBuffer\nimport scala.reflect.ClassTag\n\nclass Megalomania(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 k = ni()\n\n val x = ((n-1)*(n-2)) / 2\n if(k > x) out.println(-1)\n else {\n val list = new ListBuffer[(Int, Int)]\n var add = x - k\n REP(n-1, 1) { i =>\n REP(n-1, 1) { j =>\n if(j > i && add > 0) {\n list += ((i, j))\n add -= 1\n }\n }\n }\n REP(n-1, 1) { i =>\n list += ((i, n))\n }\n out.println(list.size)\n list.foreach(f => out.println(f._1 + \" \" + f._2))\n }\n }\n}\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 Megalomania(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", "problem_context": "Score: 500 points\n\nProblem Statement\n\nDoes there exist an undirected graph with N vertices satisfying the following conditions?\n\nThe graph is simple and connected.\n\nThe vertices are numbered 1, 2, ..., N.\n\nLet M be the number of edges in the graph. The edges are numbered 1, 2, ..., M, the length of each edge is 1, and Edge i connects Vertex u_i and Vertex v_i.\n\nThere are exactly K pairs of vertices (i,\\ j)\\ (i < j) such that the shortest distance between them is 2.\n\nIf there exists such a graph, construct an example.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n0 \\leq K \\leq \\frac{N(N - 1)}{2}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nIf there does not exist an undirected graph with N vertices satisfying the conditions, print -1.\n\nIf there exists such a graph, print an example in the following format (refer to Problem Statement for what the symbols stand for):\n\nM\nu_1 v_1\n:\nu_M v_M\n\nIf there exist multiple graphs satisfying the conditions, any of them will be accepted.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n5\n4 3\n1 2\n3 1\n4 5\n2 3\n\nThis graph has three pairs of vertices such that the shortest distance between them is 2: (1,\\ 4), (2,\\ 4), and (3,\\ 5). Thus, the condition is satisfied.\n\nSample Input 2\n\n5 8\n\nSample Output 2\n\n-1\n\nThere is no graph satisfying the conditions.", "sample_input": "5 3\n"}, "reference_outputs": ["5\n4 3\n1 2\n3 1\n4 5\n2 3\n"], "source_document_id": "p02997", "source_text": "Score: 500 points\n\nProblem Statement\n\nDoes there exist an undirected graph with N vertices satisfying the following conditions?\n\nThe graph is simple and connected.\n\nThe vertices are numbered 1, 2, ..., N.\n\nLet M be the number of edges in the graph. The edges are numbered 1, 2, ..., M, the length of each edge is 1, and Edge i connects Vertex u_i and Vertex v_i.\n\nThere are exactly K pairs of vertices (i,\\ j)\\ (i < j) such that the shortest distance between them is 2.\n\nIf there exists such a graph, construct an example.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n0 \\leq K \\leq \\frac{N(N - 1)}{2}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nIf there does not exist an undirected graph with N vertices satisfying the conditions, print -1.\n\nIf there exists such a graph, print an example in the following format (refer to Problem Statement for what the symbols stand for):\n\nM\nu_1 v_1\n:\nu_M v_M\n\nIf there exist multiple graphs satisfying the conditions, any of them will be accepted.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n5\n4 3\n1 2\n3 1\n4 5\n2 3\n\nThis graph has three pairs of vertices such that the shortest distance between them is 2: (1,\\ 4), (2,\\ 4), and (3,\\ 5). Thus, the condition is satisfied.\n\nSample Input 2\n\n5 8\n\nSample Output 2\n\n-1\n\nThere is no graph satisfying the conditions.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3573, "cpu_time_ms": 415, "memory_kb": 28176}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s428710891", "group_id": "codeNet:p02997", "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 a = new Array[Int](N)\n\n val N, K = in.next().toInt\n\n if (N == 2) {\n if (K == 0) {\n println(1)\n println(1, 2)\n }\n else {\n println(-1)\n }\n }\n else if (N == 3) {\n if (K == 0) {\n println(3)\n println(1, 2)\n println(2, 3)\n println(3, 1)\n }\n else if (K == 1) {\n println(2)\n println(1, 2)\n println(2, 3)\n }\n else\n println(-1)\n }\n else {\n if (K == N) {\n pw.println(N)\n pw.println(N, 1)\n for (i <- 1 until N)\n pw.println(i, i+1)\n }\n else {\n var tmp = ((N-2) * (N-1)) / 2\n\n if (tmp < K)\n pw.println(-1)\n else {\n var ans: List[(Int, Int)] = Nil\n\n for (i <- 2 to N) {\n ans = (i, 1) :: ans\n }\n\n\n var l = 2\n var r = 3\n while(tmp > K) {\n ans = (l, r) :: ans\n\n if (r == N) {\n l += 1\n r = l + 1\n }\n else {\n r += 1\n }\n\n tmp -= 1\n }\n\n pw.println(ans.length)\n ans.foreach {case (a, b) => pw.println(s\"$a $b\")}\n }\n }\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": 1561234566, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p02997.html", "problem_id": "p02997", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p02997/input.txt", "sample_output_relpath": "derived/input_output/data/p02997/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02997/Scala/s428710891.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s428710891", "user_id": "u098968285"}, "prompt_components": {"gold_output": "5\n4 3\n1 2\n3 1\n4 5\n2 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 a = new Array[Int](N)\n\n val N, K = in.next().toInt\n\n if (N == 2) {\n if (K == 0) {\n println(1)\n println(1, 2)\n }\n else {\n println(-1)\n }\n }\n else if (N == 3) {\n if (K == 0) {\n println(3)\n println(1, 2)\n println(2, 3)\n println(3, 1)\n }\n else if (K == 1) {\n println(2)\n println(1, 2)\n println(2, 3)\n }\n else\n println(-1)\n }\n else {\n if (K == N) {\n pw.println(N)\n pw.println(N, 1)\n for (i <- 1 until N)\n pw.println(i, i+1)\n }\n else {\n var tmp = ((N-2) * (N-1)) / 2\n\n if (tmp < K)\n pw.println(-1)\n else {\n var ans: List[(Int, Int)] = Nil\n\n for (i <- 2 to N) {\n ans = (i, 1) :: ans\n }\n\n\n var l = 2\n var r = 3\n while(tmp > K) {\n ans = (l, r) :: ans\n\n if (r == N) {\n l += 1\n r = l + 1\n }\n else {\n r += 1\n }\n\n tmp -= 1\n }\n\n pw.println(ans.length)\n ans.foreach {case (a, b) => pw.println(s\"$a $b\")}\n }\n }\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: 500 points\n\nProblem Statement\n\nDoes there exist an undirected graph with N vertices satisfying the following conditions?\n\nThe graph is simple and connected.\n\nThe vertices are numbered 1, 2, ..., N.\n\nLet M be the number of edges in the graph. The edges are numbered 1, 2, ..., M, the length of each edge is 1, and Edge i connects Vertex u_i and Vertex v_i.\n\nThere are exactly K pairs of vertices (i,\\ j)\\ (i < j) such that the shortest distance between them is 2.\n\nIf there exists such a graph, construct an example.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n0 \\leq K \\leq \\frac{N(N - 1)}{2}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nIf there does not exist an undirected graph with N vertices satisfying the conditions, print -1.\n\nIf there exists such a graph, print an example in the following format (refer to Problem Statement for what the symbols stand for):\n\nM\nu_1 v_1\n:\nu_M v_M\n\nIf there exist multiple graphs satisfying the conditions, any of them will be accepted.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n5\n4 3\n1 2\n3 1\n4 5\n2 3\n\nThis graph has three pairs of vertices such that the shortest distance between them is 2: (1,\\ 4), (2,\\ 4), and (3,\\ 5). Thus, the condition is satisfied.\n\nSample Input 2\n\n5 8\n\nSample Output 2\n\n-1\n\nThere is no graph satisfying the conditions.", "sample_input": "5 3\n"}, "reference_outputs": ["5\n4 3\n1 2\n3 1\n4 5\n2 3\n"], "source_document_id": "p02997", "source_text": "Score: 500 points\n\nProblem Statement\n\nDoes there exist an undirected graph with N vertices satisfying the following conditions?\n\nThe graph is simple and connected.\n\nThe vertices are numbered 1, 2, ..., N.\n\nLet M be the number of edges in the graph. The edges are numbered 1, 2, ..., M, the length of each edge is 1, and Edge i connects Vertex u_i and Vertex v_i.\n\nThere are exactly K pairs of vertices (i,\\ j)\\ (i < j) such that the shortest distance between them is 2.\n\nIf there exists such a graph, construct an example.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n0 \\leq K \\leq \\frac{N(N - 1)}{2}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nIf there does not exist an undirected graph with N vertices satisfying the conditions, print -1.\n\nIf there exists such a graph, print an example in the following format (refer to Problem Statement for what the symbols stand for):\n\nM\nu_1 v_1\n:\nu_M v_M\n\nIf there exist multiple graphs satisfying the conditions, any of them will be accepted.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n5\n4 3\n1 2\n3 1\n4 5\n2 3\n\nThis graph has three pairs of vertices such that the shortest distance between them is 2: (1,\\ 4), (2,\\ 4), and (3,\\ 5). Thus, the condition is satisfied.\n\nSample Input 2\n\n5 8\n\nSample Output 2\n\n-1\n\nThere is no graph satisfying the conditions.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1699, "cpu_time_ms": 478, "memory_kb": 28956}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s769856624", "group_id": "codeNet:p03000", "input_text": "object Main {\n def main(args:Array[String]) = {\n // val seq = readLine.split(\"\")\n val input=io.Source.stdin.getLines().mkString(\"\\n\")\n // println(solve(input).toString.trim())\n val a = input.split(\"\\n\")\n println(solve(a(0),a(1)).toString.trim())\n // print(input)\n }\n \n def solve(aaa:String,bbb:String): Int={\n var ctm = aaa.split(\" \")(0).toInt + 1\n var gl = aaa.split(\" \")(1).toInt\n val parr= bbb.split(\" \").map(_ .toInt)\n var ps =0\n var ct =1\n for(i<-0 until ctm){\n \tif(ps <= gl){\n val ss= if (i!= ctm-1) parr(i) else 0\n \tps = ps + ss\n ct =i\n }\n }\n ct+1\n}\n}", "language": "Scala", "metadata": {"date": 1562296401, "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/s769856624.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s769856624", "user_id": "u100418016"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main {\n def main(args:Array[String]) = {\n // val seq = readLine.split(\"\")\n val input=io.Source.stdin.getLines().mkString(\"\\n\")\n // println(solve(input).toString.trim())\n val a = input.split(\"\\n\")\n println(solve(a(0),a(1)).toString.trim())\n // print(input)\n }\n \n def solve(aaa:String,bbb:String): Int={\n var ctm = aaa.split(\" \")(0).toInt + 1\n var gl = aaa.split(\" \")(1).toInt\n val parr= bbb.split(\" \").map(_ .toInt)\n var ps =0\n var ct =1\n for(i<-0 until ctm){\n \tif(ps <= gl){\n val ss= if (i!= ctm-1) parr(i) else 0\n \tps = ps + ss\n ct =i\n }\n }\n ct+1\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 602, "cpu_time_ms": 327, "memory_kb": 25544}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s687708156", "group_id": "codeNet:p03000", "input_text": "import scala.util.control.Breaks\nobject Main extends App {\n val read = scala.io.StdIn.readLine()\n val NxArray = read.split(\" \").map(_.toInt).toVector\n var sum = 0\n var count = 1\n val read2 = scala.io.StdIn.readLine()\n val LArray = read2.split(\" \").map(_.toInt).toVector\n\n val b = new Breaks\n b.breakable{\n LArray.foreach { l =>\n if (sum + l > NxArray(1)) {\n b.break()\n } else {\n count = count + 1\n sum = sum + l\n }\n\n }\n }\n println(count)\n\n}", "language": "Scala", "metadata": {"date": 1560712593, "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/s687708156.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s687708156", "user_id": "u105921924"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.util.control.Breaks\nobject Main extends App {\n val read = scala.io.StdIn.readLine()\n val NxArray = read.split(\" \").map(_.toInt).toVector\n var sum = 0\n var count = 1\n val read2 = scala.io.StdIn.readLine()\n val LArray = read2.split(\" \").map(_.toInt).toVector\n\n val b = new Breaks\n b.breakable{\n LArray.foreach { l =>\n if (sum + l > NxArray(1)) {\n b.break()\n } else {\n count = count + 1\n sum = sum + l\n }\n\n }\n }\n println(count)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 360, "memory_kb": 25544}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s238408164", "group_id": "codeNet:p03001", "input_text": "object Main extends App {\n\n val Array(w,h,x,y) = scala.io.StdIn.readLine().split(\" \").map(_.toLong)\n\n def solve() = {\n val s = w.toDouble * h / 2\n val hasMultiWay = if(x == w.toDouble/2 || x == h.toDouble/2) 1 else 0\n s\"$s $hasMultiWay\"\n }\n\n\n println(solve)\n\n}\n", "language": "Scala", "metadata": {"date": 1574597257, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03001.html", "problem_id": "p03001", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03001/input.txt", "sample_output_relpath": "derived/input_output/data/p03001/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03001/Scala/s238408164.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s238408164", "user_id": "u947008426"}, "prompt_components": {"gold_output": "3.000000 0\n", "input_to_evaluate": "object Main extends App {\n\n val Array(w,h,x,y) = scala.io.StdIn.readLine().split(\" \").map(_.toLong)\n\n def solve() = {\n val s = w.toDouble * h / 2\n val hasMultiWay = if(x == w.toDouble/2 || x == h.toDouble/2) 1 else 0\n s\"$s $hasMultiWay\"\n }\n\n\n println(solve)\n\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a rectangle in a coordinate plane. The coordinates of the four vertices are (0,0), (W,0), (W,H), and (0,H).\nYou are given a point (x,y) which is within the rectangle or on its border. We will draw a straight line passing through (x,y) to cut the rectangle into two parts. Find the maximum possible area of the part whose area is not larger than that of the other. Additionally, determine if there are multiple ways to cut the rectangle and achieve that maximum.\n\nConstraints\n\n1 \\leq W,H \\leq 10^9\n\n0\\leq x\\leq W\n\n0\\leq y\\leq H\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nW H x y\n\nOutput\n\nPrint the maximum possible area of the part whose area is not larger than that of the other, followed by 1 if there are multiple ways to cut the rectangle and achieve that maximum, and 0 otherwise.\n\nThe area printed will be judged correct when its absolute or relative error is at most 10^{-9}.\n\nSample Input 1\n\n2 3 1 2\n\nSample Output 1\n\n3.000000 0\n\nThe line x=1 gives the optimal cut, and no other line does.\n\nSample Input 2\n\n2 2 1 1\n\nSample Output 2\n\n2.000000 1", "sample_input": "2 3 1 2\n"}, "reference_outputs": ["3.000000 0\n"], "source_document_id": "p03001", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a rectangle in a coordinate plane. The coordinates of the four vertices are (0,0), (W,0), (W,H), and (0,H).\nYou are given a point (x,y) which is within the rectangle or on its border. We will draw a straight line passing through (x,y) to cut the rectangle into two parts. Find the maximum possible area of the part whose area is not larger than that of the other. Additionally, determine if there are multiple ways to cut the rectangle and achieve that maximum.\n\nConstraints\n\n1 \\leq W,H \\leq 10^9\n\n0\\leq x\\leq W\n\n0\\leq y\\leq H\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nW H x y\n\nOutput\n\nPrint the maximum possible area of the part whose area is not larger than that of the other, followed by 1 if there are multiple ways to cut the rectangle and achieve that maximum, and 0 otherwise.\n\nThe area printed will be judged correct when its absolute or relative error is at most 10^{-9}.\n\nSample Input 1\n\n2 3 1 2\n\nSample Output 1\n\n3.000000 0\n\nThe line x=1 gives the optimal cut, and no other line does.\n\nSample Input 2\n\n2 2 1 1\n\nSample Output 2\n\n2.000000 1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 274, "cpu_time_ms": 371, "memory_kb": 27480}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s876700941", "group_id": "codeNet:p03007", "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\ncase class Ans(a: Long, b: 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 val N = ni()\n val A = na(N)\n val neg = A.count(_ < 0)\n\n val ans = ArrayBuffer[Ans]()\n var x = 0L\n if (neg == 0) {\n sort(A)\n ans += Ans(A(0), A(1))\n x = A(0) - A(1)\n REP(N - 3, 2) { i =>\n ans += Ans(x, A(i))\n x = x - A(i)\n }\n ans += Ans(A(N - 1), x)\n x = A(N - 1) - x\n\n } else if (N == neg) {\n sort(A)\n ans += Ans(A(N - 1), A(N - 2))\n x = A(N - 1) - A(N - 2)\n REP_r(N - 2) { i =>\n ans += Ans(x, A(i))\n x = x - A(i)\n }\n } else {\n import java.util\n val Pos, Neg = new util.ArrayDeque[Int]\n REP(N) { i =>\n if (A(i) >= 0) Pos.add(A(i))\n else Neg.add(A(i))\n }\n\n def add(a: Long, b: Long): Unit = {\n x = b - a\n // この先にPosがあるようだとxをマイナスにする\n if (!Pos.isEmpty) {\n if (x >= 0) {\n ans += Ans(a, b)\n x *= -1\n } else {\n ans += Ans(b, a)\n }\n } else {\n // Negしかないようならxをプラスにする\n if (x < 0) {\n ans += Ans(a, b)\n x *= -1\n } else {\n ans += Ans(b, a)\n }\n }\n }\n add(Pos.poll(), Neg.poll())\n\n def addFromQueue(): Unit = {\n if (!Pos.isEmpty) {\n add(x, Pos.poll())\n } else {\n add(x, Neg.poll())\n }\n }\n\n REP(N - 3) { _ =>\n addFromQueue()\n }\n\n addFromQueue()\n }\n\n out.println(x)\n REP(ans.length) { i =>\n out.println(s\"${ans(i).a} ${ans(i).b}\")\n }\n }\n}", "language": "Scala", "metadata": {"date": 1560653469, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03007.html", "problem_id": "p03007", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03007/input.txt", "sample_output_relpath": "derived/input_output/data/p03007/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03007/Scala/s876700941.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s876700941", "user_id": "u460609472"}, "prompt_components": {"gold_output": "4\n-1 1\n2 -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\ncase class Ans(a: Long, b: 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 val N = ni()\n val A = na(N)\n val neg = A.count(_ < 0)\n\n val ans = ArrayBuffer[Ans]()\n var x = 0L\n if (neg == 0) {\n sort(A)\n ans += Ans(A(0), A(1))\n x = A(0) - A(1)\n REP(N - 3, 2) { i =>\n ans += Ans(x, A(i))\n x = x - A(i)\n }\n ans += Ans(A(N - 1), x)\n x = A(N - 1) - x\n\n } else if (N == neg) {\n sort(A)\n ans += Ans(A(N - 1), A(N - 2))\n x = A(N - 1) - A(N - 2)\n REP_r(N - 2) { i =>\n ans += Ans(x, A(i))\n x = x - A(i)\n }\n } else {\n import java.util\n val Pos, Neg = new util.ArrayDeque[Int]\n REP(N) { i =>\n if (A(i) >= 0) Pos.add(A(i))\n else Neg.add(A(i))\n }\n\n def add(a: Long, b: Long): Unit = {\n x = b - a\n // この先にPosがあるようだとxをマイナスにする\n if (!Pos.isEmpty) {\n if (x >= 0) {\n ans += Ans(a, b)\n x *= -1\n } else {\n ans += Ans(b, a)\n }\n } else {\n // Negしかないようならxをプラスにする\n if (x < 0) {\n ans += Ans(a, b)\n x *= -1\n } else {\n ans += Ans(b, a)\n }\n }\n }\n add(Pos.poll(), Neg.poll())\n\n def addFromQueue(): Unit = {\n if (!Pos.isEmpty) {\n add(x, Pos.poll())\n } else {\n add(x, Neg.poll())\n }\n }\n\n REP(N - 3) { _ =>\n addFromQueue()\n }\n\n addFromQueue()\n }\n\n out.println(x)\n REP(ans.length) { i =>\n out.println(s\"${ans(i).a} ${ans(i).b}\")\n }\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N integers, A_1, A_2, ..., A_N, written on a blackboard.\n\nWe will repeat the following operation N-1 times so that we have only one integer on the blackboard.\n\nChoose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y.\n\nFind the maximum possible value of the final integer on the blackboard and a sequence of operations that maximizes the final integer.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n-10^4 \\leq A_i \\leq 10^4\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible value M of the final integer on the blackboard, and a sequence of operations x_i, y_i that maximizes the final integer, in the format below.\n\nHere x_i and y_i represent the integers x and y chosen in the i-th operation, respectively.\n\nIf there are multiple sequences of operations that maximize the final integer, any of them will be accepted.\n\nM\nx_1 y_1\n:\nx_{N-1} y_{N-1}\n\nSample Input 1\n\n3\n1 -1 2\n\nSample Output 1\n\n4\n-1 1\n2 -2\n\nIf we choose x = -1 and y = 1 in the first operation, the set of integers written on the blackboard becomes (-2, 2).\n\nThen, if we choose x = 2 and y = -2 in the second operation, the set of integers written on the blackboard becomes (4).\n\nIn this case, we have 4 as the final integer. We cannot end with a greater integer, so the answer is 4.\n\nSample Input 2\n\n3\n1 1 1\n\nSample Output 2\n\n1\n1 1\n1 0", "sample_input": "3\n1 -1 2\n"}, "reference_outputs": ["4\n-1 1\n2 -2\n"], "source_document_id": "p03007", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N integers, A_1, A_2, ..., A_N, written on a blackboard.\n\nWe will repeat the following operation N-1 times so that we have only one integer on the blackboard.\n\nChoose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y.\n\nFind the maximum possible value of the final integer on the blackboard and a sequence of operations that maximizes the final integer.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n-10^4 \\leq A_i \\leq 10^4\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible value M of the final integer on the blackboard, and a sequence of operations x_i, y_i that maximizes the final integer, in the format below.\n\nHere x_i and y_i represent the integers x and y chosen in the i-th operation, respectively.\n\nIf there are multiple sequences of operations that maximize the final integer, any of them will be accepted.\n\nM\nx_1 y_1\n:\nx_{N-1} y_{N-1}\n\nSample Input 1\n\n3\n1 -1 2\n\nSample Output 1\n\n4\n-1 1\n2 -2\n\nIf we choose x = -1 and y = 1 in the first operation, the set of integers written on the blackboard becomes (-2, 2).\n\nThen, if we choose x = 2 and y = -2 in the second operation, the set of integers written on the blackboard becomes (4).\n\nIn this case, we have 4 as the final integer. We cannot end with a greater integer, so the answer is 4.\n\nSample Input 2\n\n3\n1 1 1\n\nSample Output 2\n\n1\n1 1\n1 0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5245, "cpu_time_ms": 1058, "memory_kb": 62096}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s997887902", "group_id": "codeNet:p03011", "input_text": "object Main {\n import Array._\n import scala.io.StdIn.readLine\n\n def main(args: Array[String]): Unit = {\n val Array(p, q, r) = readLine split(\" \") map(_.toInt)\n println(Array(p + q, q + r, r + p).min)\n }\n}\n", "language": "Scala", "metadata": {"date": 1561247724, "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/s997887902.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s997887902", "user_id": "u434509016"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "object Main {\n import Array._\n import scala.io.StdIn.readLine\n\n def main(args: Array[String]): Unit = {\n val Array(p, q, r) = readLine split(\" \") map(_.toInt)\n println(Array(p + q, q + r, r + p).min)\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 215, "cpu_time_ms": 323, "memory_kb": 25416}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s064498119", "group_id": "codeNet:p03011", "input_text": " object Main extends App {\n var n = readInt\n \tvar get = readLine.split(\" \")\n \tvar sum1 = 0\n \tvar sum2 = 0\n var sum3 = 100\n for(i <- 0 to n-2) {\n sum1 = sum1 + get(i).toInt\n for(j <- i+1 to n-1){\n sum2 = sum2 + get(j).toInt\n }\n sum3 = math.min(sum3,math.max(sum1,sum2)-math.min(sum1,sum2))\n sum2=0\n }\n println(sum3)\n }", "language": "Scala", "metadata": {"date": 1560135265, "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/s064498119.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s064498119", "user_id": "u533688845"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": " object Main extends App {\n var n = readInt\n \tvar get = readLine.split(\" \")\n \tvar sum1 = 0\n \tvar sum2 = 0\n var sum3 = 100\n for(i <- 0 to n-2) {\n sum1 = sum1 + get(i).toInt\n for(j <- i+1 to n-1){\n sum2 = sum2 + get(j).toInt\n }\n sum3 = math.min(sum3,math.max(sum1,sum2)-math.min(sum1,sum2))\n sum2=0\n }\n println(sum3)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 323, "memory_kb": 27180}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s254715861", "group_id": "codeNet:p03011", "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 P, Q, R = ni()\n val rm = max(P, max(Q, R))\n val ans = P + Q + R - rm\n out.println(ans)\n }\n}", "language": "Scala", "metadata": {"date": 1560128526, "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/s254715861.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s254715861", "user_id": "u460609472"}, "prompt_components": {"gold_output": "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 def solve(): Unit = {\n val P, Q, R = ni()\n val rm = max(P, max(Q, R))\n val ans = P + Q + R - rm\n out.println(ans)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3716, "cpu_time_ms": 321, "memory_kb": 25640}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s777839407", "group_id": "codeNet:p03012", "input_text": "object Main extends App {\n val n = scala.io.StdIn.readLine.toInt\n val w = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n var ans = 999999\n (1 until w.length).foreach { i =>\n val a = w.splitAt(i)\n\n ans = List(Math.abs(a._1.sum - a._2.sum), ans).min\n }\n println(ans)\n}\n", "language": "Scala", "metadata": {"date": 1560128797, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03012.html", "problem_id": "p03012", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03012/input.txt", "sample_output_relpath": "derived/input_output/data/p03012/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03012/Scala/s777839407.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s777839407", "user_id": "u654455149"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "object Main extends App {\n val n = scala.io.StdIn.readLine.toInt\n val w = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n var ans = 999999\n (1 until w.length).foreach { i =>\n val a = w.splitAt(i)\n\n ans = List(Math.abs(a._1.sum - a._2.sum), ans).min\n }\n println(ans)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have N weights indexed 1 to N. The \bmass of the weight indexed i is W_i.\n\nWe will divide these weights into two groups: the weights with indices not greater than T, and those with indices greater than T, for some integer 1 \\leq T < N. Let S_1 be the sum of the masses of the weights in the former group, and S_2 be the sum of the masses of the weights in the latter group.\n\nConsider all possible such divisions and find the minimum possible absolute difference of S_1 and S_2.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n1 \\leq W_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\nW_1 W_2 ... W_{N-1} W_N\n\nOutput\n\nPrint the minimum possible absolute difference of S_1 and S_2.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n0\n\nIf T = 2, S_1 = 1 + 2 = 3 and S_2 = 3, with the absolute difference of 0.\n\nSample Input 2\n\n4\n1 3 1 1\n\nSample Output 2\n\n2\n\nIf T = 2, S_1 = 1 + 3 = 4 and S_2 = 1 + 1 = 2, with the absolute difference of 2. We cannot have a smaller absolute difference.\n\nSample Input 3\n\n8\n27 23 76 2 3 5 62 52\n\nSample Output 3\n\n2", "sample_input": "3\n1 2 3\n"}, "reference_outputs": ["0\n"], "source_document_id": "p03012", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have N weights indexed 1 to N. The \bmass of the weight indexed i is W_i.\n\nWe will divide these weights into two groups: the weights with indices not greater than T, and those with indices greater than T, for some integer 1 \\leq T < N. Let S_1 be the sum of the masses of the weights in the former group, and S_2 be the sum of the masses of the weights in the latter group.\n\nConsider all possible such divisions and find the minimum possible absolute difference of S_1 and S_2.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n1 \\leq W_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\nW_1 W_2 ... W_{N-1} W_N\n\nOutput\n\nPrint the minimum possible absolute difference of S_1 and S_2.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n0\n\nIf T = 2, S_1 = 1 + 2 = 3 and S_2 = 3, with the absolute difference of 0.\n\nSample Input 2\n\n4\n1 3 1 1\n\nSample Output 2\n\n2\n\nIf T = 2, S_1 = 1 + 3 = 4 and S_2 = 1 + 1 = 2, with the absolute difference of 2. We cannot have a smaller absolute difference.\n\nSample Input 3\n\n8\n27 23 76 2 3 5 62 52\n\nSample Output 3\n\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 281, "cpu_time_ms": 354, "memory_kb": 27200}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s650521592", "group_id": "codeNet:p03014", "input_text": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val H, W = sc.nextInt()\n val S = new Array[String](H)\n var s = 0\n while (s < H) {\n S(s) = sc.next()\n s += 1\n }\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": 1560137873, "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/s650521592.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s650521592", "user_id": "u891387249"}, "prompt_components": {"gold_output": "8\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 H, W = sc.nextInt()\n val S = new Array[String](H)\n var s = 0\n while (s < H) {\n S(s) = sc.next()\n s += 1\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1670, "cpu_time_ms": 2115, "memory_kb": 244080}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s792071097", "group_id": "codeNet:p03014", "input_text": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n\n val H, W = sc.nextInt()\n val S = Array.fill(H)(sc.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": 1560137587, "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/s792071097.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s792071097", "user_id": "u891387249"}, "prompt_components": {"gold_output": "8\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 H, W = sc.nextInt()\n val S = Array.fill(H)(sc.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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1598, "cpu_time_ms": 2115, "memory_kb": 232272}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s663767474", "group_id": "codeNet:p03014", "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(h, w) = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n val S = (0 until h) map (_ => scala.io.StdIn.readLine())\n println(S.mkString(\"\\n\"))\n val dp = Array.fill(h, w, 2)(-1) // 未計算の場合-1, dp(i)(j)(0) 縦の数 dp(i)(j)(1)横の数\n (0 until h) foreach { i =>\n (0 until w) foreach { j =>\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 (0 until di) foreach { dii =>\n dp(i+dii)(j)(0) = di - 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 (0 until dj) foreach { djj =>\n dp(i)(j+djj)(1) = dj - 1\n }\n }\n }\n }\n }\n\n var max = 0\n (0 until h) foreach { i =>\n (0 until w) foreach { j =>\n max = Math.max(max, dp(i)(j)(0) + dp(i)(j)(1) + 1)\n }\n }\n println(max)\n }\n\n}", "language": "Scala", "metadata": {"date": 1560133636, "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/s663767474.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s663767474", "user_id": "u891387249"}, "prompt_components": {"gold_output": "8\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(h, w) = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n val S = (0 until h) map (_ => scala.io.StdIn.readLine())\n println(S.mkString(\"\\n\"))\n val dp = Array.fill(h, w, 2)(-1) // 未計算の場合-1, dp(i)(j)(0) 縦の数 dp(i)(j)(1)横の数\n (0 until h) foreach { i =>\n (0 until w) foreach { j =>\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 (0 until di) foreach { dii =>\n dp(i+dii)(j)(0) = di - 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 (0 until dj) foreach { djj =>\n dp(i)(j+djj)(1) = dj - 1\n }\n }\n }\n }\n }\n\n var max = 0\n (0 until h) foreach { i =>\n (0 until w) foreach { j =>\n max = Math.max(max, dp(i)(j)(0) + dp(i)(j)(1) + 1)\n }\n }\n println(max)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1398, "cpu_time_ms": 2119, "memory_kb": 246844}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s283225576", "group_id": "codeNet:p03029", "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\n val a, p = sc.nextInt()\n\n val apples = a * 3 + p\n\n println(apples / 2)\n\n }\n def debug(args: Any*): Unit = {\n Console.err.println(args.mkString(\" \"))\n }\n\n def printExecTime(process: => Unit): Unit = {\n val start = System.currentTimeMillis\n process\n debug(\"処理時間: \" + (System.currentTimeMillis - start) + \" ミリ秒\")\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1588631283, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03029.html", "problem_id": "p03029", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03029/input.txt", "sample_output_relpath": "derived/input_output/data/p03029/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03029/Scala/s283225576.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s283225576", "user_id": "u336949031"}, "prompt_components": {"gold_output": "3\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\n val a, p = sc.nextInt()\n\n val apples = a * 3 + p\n\n println(apples / 2)\n\n }\n def debug(args: Any*): Unit = {\n Console.err.println(args.mkString(\" \"))\n }\n\n def printExecTime(process: => Unit): Unit = {\n val start = System.currentTimeMillis\n process\n debug(\"処理時間: \" + (System.currentTimeMillis - start) + \" ミリ秒\")\n }\n\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have A apples and P pieces of apple.\n\nWe can cut an apple into three pieces of apple, and make one apple pie by simmering two pieces of apple in a pan.\n\nFind the maximum number of apple pies we can make with what we have now.\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A, P \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA P\n\nOutput\n\nPrint the maximum number of apple pies we can make with what we have.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\n3\n\nWe can first make one apple pie by simmering two of the three pieces of apple. Then, we can make two more by simmering the remaining piece and three more pieces obtained by cutting the whole apple.\n\nSample Input 2\n\n0 1\n\nSample Output 2\n\n0\n\nWe cannot make an apple pie in this case, unfortunately.\n\nSample Input 3\n\n32 21\n\nSample Output 3\n\n58", "sample_input": "1 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03029", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have A apples and P pieces of apple.\n\nWe can cut an apple into three pieces of apple, and make one apple pie by simmering two pieces of apple in a pan.\n\nFind the maximum number of apple pies we can make with what we have now.\n\nConstraints\n\nAll values in input are integers.\n\n0 \\leq A, P \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA P\n\nOutput\n\nPrint the maximum number of apple pies we can make with what we have.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\n3\n\nWe can first make one apple pie by simmering two of the three pieces of apple. Then, we can make two more by simmering the remaining piece and three more pieces obtained by cutting the whole apple.\n\nSample Input 2\n\n0 1\n\nSample Output 2\n\n0\n\nWe cannot make an apple pie in this case, unfortunately.\n\nSample Input 3\n\n32 21\n\nSample Output 3\n\n58", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 530, "cpu_time_ms": 338, "memory_kb": 25648}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s603549911", "group_id": "codeNet:p03030", "input_text": "object Main extends App {\n\tval N = scala.io.StdIn.readInt\n\tval a = new Array[(String, Int, Int)](N)\n\n\tfor(i<-0 until N){\n\t\tval Array(ta, tb) = scala.io.StdIn.readLine.split(\" \")\n\t\ta(i) = (ta, tb.toInt, i+1)\n\t}\n\n\tval b = a.sortBy(x => (x._1, -x._2))\n\t\n\tfor(x <- b){\n\t\tprintln(x._3)\n\t}\n\n}", "language": "Scala", "metadata": {"date": 1562547231, "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/s603549911.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s603549911", "user_id": "u675876401"}, "prompt_components": {"gold_output": "3\n4\n6\n1\n5\n2\n", "input_to_evaluate": "object Main extends App {\n\tval N = scala.io.StdIn.readInt\n\tval a = new Array[(String, Int, Int)](N)\n\n\tfor(i<-0 until N){\n\t\tval Array(ta, tb) = scala.io.StdIn.readLine.split(\" \")\n\t\ta(i) = (ta, tb.toInt, i+1)\n\t}\n\n\tval b = a.sortBy(x => (x._1, -x._2))\n\t\n\tfor(x <- b){\n\t\tprintln(x._3)\n\t}\n\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have decided to write a book introducing good restaurants.\nThere are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i.\nNo two restaurants have the same score.\n\nYou want to introduce the restaurants in the following order:\n\nThe restaurants are arranged in lexicographical order of the names of their cities.\n\nIf there are multiple restaurants in the same city, they are arranged in descending order of score.\n\nPrint the identification numbers of the restaurants in the order they are introduced in the book.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nS is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.\n\n0 ≤ P_i ≤ 100\n\nP_i is an integer.\n\nP_i ≠ P_j (1 ≤ i < j ≤ N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1 P_1\n:\nS_N P_N\n\nOutput\n\nPrint N lines. The i-th line (1 ≤ i ≤ N) should contain the identification number of the restaurant that is introduced i-th in the book.\n\nSample Input 1\n\n6\nkhabarovsk 20\nmoscow 10\nkazan 50\nkazan 35\nmoscow 60\nkhabarovsk 40\n\nSample Output 1\n\n3\n4\n6\n1\n5\n2\n\nThe lexicographical order of the names of the three cities is kazan < khabarovsk < moscow. For each of these cities, the restaurants in it are introduced in descending order of score. Thus, the restaurants are introduced in the order 3,4,6,1,5,2.\n\nSample Input 2\n\n10\nyakutsk 10\nyakutsk 20\nyakutsk 30\nyakutsk 40\nyakutsk 50\nyakutsk 60\nyakutsk 70\nyakutsk 80\nyakutsk 90\nyakutsk 100\n\nSample Output 2\n\n10\n9\n8\n7\n6\n5\n4\n3\n2\n1", "sample_input": "6\nkhabarovsk 20\nmoscow 10\nkazan 50\nkazan 35\nmoscow 60\nkhabarovsk 40\n"}, "reference_outputs": ["3\n4\n6\n1\n5\n2\n"], "source_document_id": "p03030", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have decided to write a book introducing good restaurants.\nThere are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i.\nNo two restaurants have the same score.\n\nYou want to introduce the restaurants in the following order:\n\nThe restaurants are arranged in lexicographical order of the names of their cities.\n\nIf there are multiple restaurants in the same city, they are arranged in descending order of score.\n\nPrint the identification numbers of the restaurants in the order they are introduced in the book.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nS is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.\n\n0 ≤ P_i ≤ 100\n\nP_i is an integer.\n\nP_i ≠ P_j (1 ≤ i < j ≤ N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1 P_1\n:\nS_N P_N\n\nOutput\n\nPrint N lines. The i-th line (1 ≤ i ≤ N) should contain the identification number of the restaurant that is introduced i-th in the book.\n\nSample Input 1\n\n6\nkhabarovsk 20\nmoscow 10\nkazan 50\nkazan 35\nmoscow 60\nkhabarovsk 40\n\nSample Output 1\n\n3\n4\n6\n1\n5\n2\n\nThe lexicographical order of the names of the three cities is kazan < khabarovsk < moscow. For each of these cities, the restaurants in it are introduced in descending order of score. Thus, the restaurants are introduced in the order 3,4,6,1,5,2.\n\nSample Input 2\n\n10\nyakutsk 10\nyakutsk 20\nyakutsk 30\nyakutsk 40\nyakutsk 50\nyakutsk 60\nyakutsk 70\nyakutsk 80\nyakutsk 90\nyakutsk 100\n\nSample Output 2\n\n10\n9\n8\n7\n6\n5\n4\n3\n2\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 286, "cpu_time_ms": 327, "memory_kb": 25532}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s806346717", "group_id": "codeNet:p03030", "input_text": "import java.util.Scanner\n\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\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 case class Restaurant(num: Int, city: String, score: Int)\n\n def solve(sc: Scanner): String = {\n val n = sc.nextInt()\n val evaluations = Vector.fill(n)((sc.next(), sc.nextInt())) // (市名, 評価点)\n val restaurants = evaluations.zipWithIndex.map { case ((city, score), i) => Restaurant(i + 1, city, score) }\n debug(n, evaluations)\n\n val cities = evaluations.map(_._1).sorted.distinct // Vector(kazan, khabarovsk, moscow)\n\n val restaurantNumBuf = ArrayBuffer.empty[Int]\n\n cities.foreach { city =>\n restaurants.filter(_.city == city).sortBy(_.score).reverse.foreach { restaurant =>\n restaurantNumBuf += restaurant.num\n }\n }\n debug(restaurantNumBuf)\n\n restaurantNumBuf.mkString(\"\\n\")\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": 1558987967, "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/s806346717.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s806346717", "user_id": "u088326922"}, "prompt_components": {"gold_output": "3\n4\n6\n1\n5\n2\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\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 case class Restaurant(num: Int, city: String, score: Int)\n\n def solve(sc: Scanner): String = {\n val n = sc.nextInt()\n val evaluations = Vector.fill(n)((sc.next(), sc.nextInt())) // (市名, 評価点)\n val restaurants = evaluations.zipWithIndex.map { case ((city, score), i) => Restaurant(i + 1, city, score) }\n debug(n, evaluations)\n\n val cities = evaluations.map(_._1).sorted.distinct // Vector(kazan, khabarovsk, moscow)\n\n val restaurantNumBuf = ArrayBuffer.empty[Int]\n\n cities.foreach { city =>\n restaurants.filter(_.city == city).sortBy(_.score).reverse.foreach { restaurant =>\n restaurantNumBuf += restaurant.num\n }\n }\n debug(restaurantNumBuf)\n\n restaurantNumBuf.mkString(\"\\n\")\n }\n\n private def debug(x: Any): Unit = {\n if (System.getenv(\"LOCAL_DEBUG\") != null) println(x)\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have decided to write a book introducing good restaurants.\nThere are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i.\nNo two restaurants have the same score.\n\nYou want to introduce the restaurants in the following order:\n\nThe restaurants are arranged in lexicographical order of the names of their cities.\n\nIf there are multiple restaurants in the same city, they are arranged in descending order of score.\n\nPrint the identification numbers of the restaurants in the order they are introduced in the book.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nS is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.\n\n0 ≤ P_i ≤ 100\n\nP_i is an integer.\n\nP_i ≠ P_j (1 ≤ i < j ≤ N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1 P_1\n:\nS_N P_N\n\nOutput\n\nPrint N lines. The i-th line (1 ≤ i ≤ N) should contain the identification number of the restaurant that is introduced i-th in the book.\n\nSample Input 1\n\n6\nkhabarovsk 20\nmoscow 10\nkazan 50\nkazan 35\nmoscow 60\nkhabarovsk 40\n\nSample Output 1\n\n3\n4\n6\n1\n5\n2\n\nThe lexicographical order of the names of the three cities is kazan < khabarovsk < moscow. For each of these cities, the restaurants in it are introduced in descending order of score. Thus, the restaurants are introduced in the order 3,4,6,1,5,2.\n\nSample Input 2\n\n10\nyakutsk 10\nyakutsk 20\nyakutsk 30\nyakutsk 40\nyakutsk 50\nyakutsk 60\nyakutsk 70\nyakutsk 80\nyakutsk 90\nyakutsk 100\n\nSample Output 2\n\n10\n9\n8\n7\n6\n5\n4\n3\n2\n1", "sample_input": "6\nkhabarovsk 20\nmoscow 10\nkazan 50\nkazan 35\nmoscow 60\nkhabarovsk 40\n"}, "reference_outputs": ["3\n4\n6\n1\n5\n2\n"], "source_document_id": "p03030", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have decided to write a book introducing good restaurants.\nThere are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i.\nNo two restaurants have the same score.\n\nYou want to introduce the restaurants in the following order:\n\nThe restaurants are arranged in lexicographical order of the names of their cities.\n\nIf there are multiple restaurants in the same city, they are arranged in descending order of score.\n\nPrint the identification numbers of the restaurants in the order they are introduced in the book.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nS is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.\n\n0 ≤ P_i ≤ 100\n\nP_i is an integer.\n\nP_i ≠ P_j (1 ≤ i < j ≤ N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1 P_1\n:\nS_N P_N\n\nOutput\n\nPrint N lines. The i-th line (1 ≤ i ≤ N) should contain the identification number of the restaurant that is introduced i-th in the book.\n\nSample Input 1\n\n6\nkhabarovsk 20\nmoscow 10\nkazan 50\nkazan 35\nmoscow 60\nkhabarovsk 40\n\nSample Output 1\n\n3\n4\n6\n1\n5\n2\n\nThe lexicographical order of the names of the three cities is kazan < khabarovsk < moscow. For each of these cities, the restaurants in it are introduced in descending order of score. Thus, the restaurants are introduced in the order 3,4,6,1,5,2.\n\nSample Input 2\n\n10\nyakutsk 10\nyakutsk 20\nyakutsk 30\nyakutsk 40\nyakutsk 50\nyakutsk 60\nyakutsk 70\nyakutsk 80\nyakutsk 90\nyakutsk 100\n\nSample Output 2\n\n10\n9\n8\n7\n6\n5\n4\n3\n2\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1110, "cpu_time_ms": 365, "memory_kb": 27352}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s511069265", "group_id": "codeNet:p03031", "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 numWithNbits(n: Int): Int = (1 << n) - 1\n def checkBitOn(n: Int, b: Int): Int = (n >> (b - 1)) & 1\n def countBitsOn(n: Int, bl: List[Int]): Int = bl match {\n case Nil => 0\n case bh::bt => checkBitOn(n, bh) + countBitsOn(n, bt)\n }\n\n def isAllOn(n: Int, is: List[(List[Int], Int)]): Boolean = is match {\n case Nil => true\n case (bits, parity) :: irs =>\n if (countBitsOn(n, bits) % 2 != parity) false\n else isAllOn(n, irs)\n }\n\n def solve(input: String): String = {\n val s: Scanner = new Scanner(input)\n val (n, m) = (s.nextInt, s.nextInt)\n val ks = List.fill(m)(List.fill(s.nextInt)(s.nextInt))\n val ps = List.fill(m)(s.nextInt)\n val is = ks.zip(ps)\n (1 to numWithNbits(n)).count(i => isAllOn(i, is)).toString()\n }\n\n val tests = List(\n \"\"\"2 2\n |2 1 2\n |1 2\n |0 1\n \"\"\".stripMargin -> \"\"\"1\"\"\",\n \"\"\"2 1\n |2 1 2\n |0\n \"\"\".stripMargin -> \"\"\"1\"\"\",\n \"\"\"2 3\n |2 1 2\n |1 1\n |1 2\n |0 0 1\n \"\"\".stripMargin -> \"\"\"0\"\"\",\n \"\"\"5 2\n |3 1 2 5\n |2 2 3\n |1 0\n \"\"\".stripMargin -> \"8\"\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": 1559971191, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03031.html", "problem_id": "p03031", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03031/input.txt", "sample_output_relpath": "derived/input_output/data/p03031/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03031/Scala/s511069265.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s511069265", "user_id": "u334087399"}, "prompt_components": {"gold_output": "1\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 numWithNbits(n: Int): Int = (1 << n) - 1\n def checkBitOn(n: Int, b: Int): Int = (n >> (b - 1)) & 1\n def countBitsOn(n: Int, bl: List[Int]): Int = bl match {\n case Nil => 0\n case bh::bt => checkBitOn(n, bh) + countBitsOn(n, bt)\n }\n\n def isAllOn(n: Int, is: List[(List[Int], Int)]): Boolean = is match {\n case Nil => true\n case (bits, parity) :: irs =>\n if (countBitsOn(n, bits) % 2 != parity) false\n else isAllOn(n, irs)\n }\n\n def solve(input: String): String = {\n val s: Scanner = new Scanner(input)\n val (n, m) = (s.nextInt, s.nextInt)\n val ks = List.fill(m)(List.fill(s.nextInt)(s.nextInt))\n val ps = List.fill(m)(s.nextInt)\n val is = ks.zip(ps)\n (1 to numWithNbits(n)).count(i => isAllOn(i, is)).toString()\n }\n\n val tests = List(\n \"\"\"2 2\n |2 1 2\n |1 2\n |0 1\n \"\"\".stripMargin -> \"\"\"1\"\"\",\n \"\"\"2 1\n |2 1 2\n |0\n \"\"\".stripMargin -> \"\"\"1\"\"\",\n \"\"\"2 3\n |2 1 2\n |1 1\n |1 2\n |0 0 1\n \"\"\".stripMargin -> \"\"\"0\"\"\",\n \"\"\"5 2\n |3 1 2 5\n |2 2 3\n |1 0\n \"\"\".stripMargin -> \"8\"\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\nWe have N switches with \"on\" and \"off\" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.\n\nBulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are \"on\" among these switches is congruent to p_i modulo 2.\n\nHow many combinations of \"on\" and \"off\" states of the switches light all the bulbs?\n\nConstraints\n\n1 \\leq N, M \\leq 10\n\n1 \\leq k_i \\leq N\n\n1 \\leq s_{ij} \\leq N\n\ns_{ia} \\neq s_{ib} (a \\neq b)\n\np_i is 0 or 1.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nk_1 s_{11} s_{12} ... s_{1k_1}\n:\nk_M s_{M1} s_{M2} ... s_{Mk_M}\np_1 p_2 ... p_M\n\nOutput\n\nPrint the number of combinations of \"on\" and \"off\" states of the switches that light all the bulbs.\n\nSample Input 1\n\n2 2\n2 1 2\n1 2\n0 1\n\nSample Output 1\n\n1\n\nBulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n\nBulb 2 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nThere are four possible combinations of states of (Switch 1, Switch 2): (on, on), (on, off), (off, on) and (off, off). Among them, only (on, on) lights all the bulbs, so we should print 1.\n\nSample Input 2\n\n2 3\n2 1 2\n1 1\n1 2\n0 0 1\n\nSample Output 2\n\n0\n\nBulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n\nBulb 2 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1.\n\nBulb 3 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nSwitch 1 has to be \"off\" to light Bulb 2 and Switch 2 has to be \"on\" to light Bulb 3, but then Bulb 1 will not be lighted. Thus, there are no combinations of states of the switches that light all the bulbs, so we should print 0.\n\nSample Input 3\n\n5 2\n3 1 2 5\n2 2 3\n1 0\n\nSample Output 3\n\n8", "sample_input": "2 2\n2 1 2\n1 2\n0 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03031", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have N switches with \"on\" and \"off\" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.\n\nBulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are \"on\" among these switches is congruent to p_i modulo 2.\n\nHow many combinations of \"on\" and \"off\" states of the switches light all the bulbs?\n\nConstraints\n\n1 \\leq N, M \\leq 10\n\n1 \\leq k_i \\leq N\n\n1 \\leq s_{ij} \\leq N\n\ns_{ia} \\neq s_{ib} (a \\neq b)\n\np_i is 0 or 1.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nk_1 s_{11} s_{12} ... s_{1k_1}\n:\nk_M s_{M1} s_{M2} ... s_{Mk_M}\np_1 p_2 ... p_M\n\nOutput\n\nPrint the number of combinations of \"on\" and \"off\" states of the switches that light all the bulbs.\n\nSample Input 1\n\n2 2\n2 1 2\n1 2\n0 1\n\nSample Output 1\n\n1\n\nBulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n\nBulb 2 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nThere are four possible combinations of states of (Switch 1, Switch 2): (on, on), (on, off), (off, on) and (off, off). Among them, only (on, on) lights all the bulbs, so we should print 1.\n\nSample Input 2\n\n2 3\n2 1 2\n1 1\n1 2\n0 0 1\n\nSample Output 2\n\n0\n\nBulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n\nBulb 2 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1.\n\nBulb 3 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nSwitch 1 has to be \"off\" to light Bulb 2 and Switch 2 has to be \"on\" to light Bulb 3, but then Bulb 1 will not be lighted. Thus, there are no combinations of states of the switches that light all the bulbs, so we should print 0.\n\nSample Input 3\n\n5 2\n3 1 2 5\n2 2 3\n1 0\n\nSample Output 3\n\n8", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1723, "cpu_time_ms": 363, "memory_kb": 27448}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s413808736", "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.toLong*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": 1574477706, "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/s413808736.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s413808736", "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.toLong*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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1388, "cpu_time_ms": 1809, "memory_kb": 117248}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s964669404", "group_id": "codeNet:p03035", "input_text": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val Array(a, b) = in.readLine.split(\" \").map(_.toInt)\n val ans = a match {\n case x if x <= 5 => 0\n case x if x <=12 => b / 2\n case _ => b\n }\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1558833134, "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/s964669404.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s964669404", "user_id": "u217010036"}, "prompt_components": {"gold_output": "100\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 val ans = a match {\n case x if x <= 5 => 0\n case x if x <=12 => b / 2\n case _ => b\n }\n println(ans)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi, who is A years old, is riding a Ferris wheel.\n\nIt costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.)\n\nFind the cost of the Ferris wheel for Takahashi.\n\nConstraints\n\n0 ≤ A ≤ 100\n\n2 ≤ B ≤ 1000\n\nB is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the cost of the Ferris wheel for Takahashi.\n\nSample Input 1\n\n30 100\n\nSample Output 1\n\n100\n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\nSample Input 2\n\n12 100\n\nSample Output 2\n\n50\n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100 yen, that is, 50 yen.\n\nSample Input 3\n\n0 100\n\nSample Output 3\n\n0\n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free.", "sample_input": "30 100\n"}, "reference_outputs": ["100\n"], "source_document_id": "p03035", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi, who is A years old, is riding a Ferris wheel.\n\nIt costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.)\n\nFind the cost of the Ferris wheel for Takahashi.\n\nConstraints\n\n0 ≤ A ≤ 100\n\n2 ≤ B ≤ 1000\n\nB is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the cost of the Ferris wheel for Takahashi.\n\nSample Input 1\n\n30 100\n\nSample Output 1\n\n100\n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\nSample Input 2\n\n12 100\n\nSample Output 2\n\n50\n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100 yen, that is, 50 yen.\n\nSample Input 3\n\n0 100\n\nSample Output 3\n\n0\n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 227, "cpu_time_ms": 329, "memory_kb": 25552}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s159153344", "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 val pass = Array.fill(n+1)(true)\n\n var l = 1\n var r = n\n Iterator.continually(in.readLine)\n .take(m)\n .map(_.split(\" \").map(_.toInt))\n .foreach { e =>\n if(e(0) > l) (l until e(0)).foreach(i => pass(i) = false)\n if(e(1) < r) (e(0) to r).foreach(i => pass(i) = false)\n val x = l max e(0)\n val y = r min e(1)\n }\n val ans = pass.tail.count(_ == true)\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1558835410, "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/s159153344.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s159153344", "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 val pass = Array.fill(n+1)(true)\n\n var l = 1\n var r = n\n Iterator.continually(in.readLine)\n .take(m)\n .map(_.split(\" \").map(_.toInt))\n .foreach { e =>\n if(e(0) > l) (l until e(0)).foreach(i => pass(i) = false)\n if(e(1) < r) (e(0) to r).foreach(i => pass(i) = false)\n val x = l max e(0)\n val y = r min e(1)\n }\n val ans = pass.tail.count(_ == true)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 44028}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s785436987", "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 ls = l.foldLeft(List.fill(N)(0L)) {\n case (pre, (num, v)) =>\n val (less, remain) = pre.sorted.splitAt(num)\n less.map(a => if (a < v) v else a) ::: remain\n }*/\n val ls = l.foldLeft(List.empty[Long]) {\n case (pre, (num, v)) => List.fill(num)(v) ::: pre\n }\n /*\n\n val r = ls.foldLeft(As) {\n case (pre, v) =>\n (v :: pre).sorted.tail\n }\n\n */\n val r = (ls ::: As).sorted.takeRight(N)\n\n println(r.sum)\n }\n}", "language": "Scala", "metadata": {"date": 1558837729, "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/s785436987.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s785436987", "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 ls = l.foldLeft(List.fill(N)(0L)) {\n case (pre, (num, v)) =>\n val (less, remain) = pre.sorted.splitAt(num)\n less.map(a => if (a < v) v else a) ::: remain\n }*/\n val ls = l.foldLeft(List.empty[Long]) {\n case (pre, (num, v)) => List.fill(num)(v) ::: pre\n }\n /*\n\n val r = ls.foldLeft(As) {\n case (pre, v) =>\n (v :: pre).sorted.tail\n }\n\n */\n val r = (ls ::: As).sorted.takeRight(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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 221988}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s017928570", "group_id": "codeNet:p03039", "input_text": "import java.util.Scanner\n\nobject Main {\n\n case class RR(representative: Long) extends AnyVal {\n def +(that: RR): RR = RR((this.representative + that.representative) % RR.mod)\n\n def -(that: RR): RR = RR((this.representative - that.representative + RR.mod) % RR.mod)\n\n def *(that: RR): RR = RR((this.representative * that.representative) % RR.mod)\n\n def unary_- : RR = RR((-this.representative + RR.mod) % RR.mod)\n }\n\n\n object RR {\n val mod: Long = (1e9 + 7).toLong\n\n val _0: RR = RR(0)\n val _1: RR = RR(1)\n }\n\n def read() = {\n val sc = new Scanner(System.in)\n val n, m, k = sc.nextInt()\n (n, m, k)\n }\n\n def comb(a: Int, b: Int): Int = {\n if (a < b) 0\n else if (b == 0) 1\n else comb(a - 1, b - 1) + comb(a - 1, b)\n }\n\n def fracRR(n: Int): RR = (1 to n).map(RR(_)).foldLeft(RR(1))(_ * _)\n\n\n def combRR(n: Int, r: Int): RR = {\n // comb(n,r) = n!/(r! (n-r)!)\n val x = fracRR(n) // n!\n val y = fracRR(r) // r!\n val z = fracRR(n - r) // (n-r)!\n\n val yz = y * z\n x * rrInv(yz)\n }\n\n def mypow(x: Long, t: Long): Long = {\n if (t == 0) {\n return 1\n }\n val y = mypow(x, t / 2)\n if (t % 2 == 0) {\n y * y\n } else {\n x * y * y\n }\n }\n\n def mypowRR(x: RR, t: Long): RR = {\n if (t == 0) {\n return RR(1)\n }\n val y = mypowRR(x, t / 2)\n if (t % 2 == 0) {\n y * y\n } else {\n x * y * y\n }\n }\n\n def rrInv(x: RR): RR = mypowRR(x, RR.mod - 2)\n\n def solve(h: Int, w: Int, k: Int): Int = {\n // 1 + 2 + ... + tを求める\n def sum(t: Int) = t * (t + 1) / 2\n\n def sumDist(x: Int, y: Int): Int = {\n // 0-origin\n // xより左側: [0,x) (xマス)\n // xより右側: [x+1,w) (w-x-1マス)\n // yより上側: [0,y) (yマス)\n // yより下側: [y+1, h) (h-y-1マス)\n (sum(x) + sum(w - x - 1)) * h + (sum(y) + sum(h - y - 1)) * w\n }\n\n comb(w * h - 2, k - 2) * (for (y <- 0 until h; x <- 0 until w) yield sumDist(x, y) / 2).sum\n }\n\n def solve2(h: Int, w: Int, k: Int): Long = {\n // 1 + 2 + ... + tを求める\n def sum(t: Long) = t * (t + 1) / 2\n\n def sumDist(x: Long, y: Long): Long = {\n // 0-origin\n // xより左側: [0,x) (xマス)\n // xより右側: [x+1,w) (w-x-1マス)\n // yより上側: [0,y) (yマス)\n // yより下側: [y+1, h) (h-y-1マス)\n (sum(x) + sum(w - x - 1)) * h + (sum(y) + sum(h - y - 1)) * w\n }\n\n val result = combRR(w * h - 2, k - 2) * RR((for (y <- 0 until h; x <- 0 until w) yield sumDist(x, y) / 2).sum)\n result.representative\n }\n\n def main(args: Array[String]): Unit = {\n val (n, m, k) = read()\n println(solve2(n, m, k))\n }\n}", "language": "Scala", "metadata": {"date": 1558895205, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03039.html", "problem_id": "p03039", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03039/input.txt", "sample_output_relpath": "derived/input_output/data/p03039/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03039/Scala/s017928570.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s017928570", "user_id": "u494788559"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n\n case class RR(representative: Long) extends AnyVal {\n def +(that: RR): RR = RR((this.representative + that.representative) % RR.mod)\n\n def -(that: RR): RR = RR((this.representative - that.representative + RR.mod) % RR.mod)\n\n def *(that: RR): RR = RR((this.representative * that.representative) % RR.mod)\n\n def unary_- : RR = RR((-this.representative + RR.mod) % RR.mod)\n }\n\n\n object RR {\n val mod: Long = (1e9 + 7).toLong\n\n val _0: RR = RR(0)\n val _1: RR = RR(1)\n }\n\n def read() = {\n val sc = new Scanner(System.in)\n val n, m, k = sc.nextInt()\n (n, m, k)\n }\n\n def comb(a: Int, b: Int): Int = {\n if (a < b) 0\n else if (b == 0) 1\n else comb(a - 1, b - 1) + comb(a - 1, b)\n }\n\n def fracRR(n: Int): RR = (1 to n).map(RR(_)).foldLeft(RR(1))(_ * _)\n\n\n def combRR(n: Int, r: Int): RR = {\n // comb(n,r) = n!/(r! (n-r)!)\n val x = fracRR(n) // n!\n val y = fracRR(r) // r!\n val z = fracRR(n - r) // (n-r)!\n\n val yz = y * z\n x * rrInv(yz)\n }\n\n def mypow(x: Long, t: Long): Long = {\n if (t == 0) {\n return 1\n }\n val y = mypow(x, t / 2)\n if (t % 2 == 0) {\n y * y\n } else {\n x * y * y\n }\n }\n\n def mypowRR(x: RR, t: Long): RR = {\n if (t == 0) {\n return RR(1)\n }\n val y = mypowRR(x, t / 2)\n if (t % 2 == 0) {\n y * y\n } else {\n x * y * y\n }\n }\n\n def rrInv(x: RR): RR = mypowRR(x, RR.mod - 2)\n\n def solve(h: Int, w: Int, k: Int): Int = {\n // 1 + 2 + ... + tを求める\n def sum(t: Int) = t * (t + 1) / 2\n\n def sumDist(x: Int, y: Int): Int = {\n // 0-origin\n // xより左側: [0,x) (xマス)\n // xより右側: [x+1,w) (w-x-1マス)\n // yより上側: [0,y) (yマス)\n // yより下側: [y+1, h) (h-y-1マス)\n (sum(x) + sum(w - x - 1)) * h + (sum(y) + sum(h - y - 1)) * w\n }\n\n comb(w * h - 2, k - 2) * (for (y <- 0 until h; x <- 0 until w) yield sumDist(x, y) / 2).sum\n }\n\n def solve2(h: Int, w: Int, k: Int): Long = {\n // 1 + 2 + ... + tを求める\n def sum(t: Long) = t * (t + 1) / 2\n\n def sumDist(x: Long, y: Long): Long = {\n // 0-origin\n // xより左側: [0,x) (xマス)\n // xより右側: [x+1,w) (w-x-1マス)\n // yより上側: [0,y) (yマス)\n // yより下側: [y+1, h) (h-y-1マス)\n (sum(x) + sum(w - x - 1)) * h + (sum(y) + sum(h - y - 1)) * w\n }\n\n val result = combRR(w * h - 2, k - 2) * RR((for (y <- 0 until h; x <- 0 until w) yield sumDist(x, y) / 2).sum)\n result.representative\n }\n\n def main(args: Array[String]): Unit = {\n val (n, m, k) = read()\n println(solve2(n, m, k))\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nWe have a grid of squares with N rows and M columns. Let (i, j) denote the square at the i-th row from the top and j-th column from the left. We will choose K of the squares and put a piece on each of them.\n\nIf we place the K pieces on squares (x_1, y_1), (x_2, y_2), ..., and (x_K, y_K), the cost of this arrangement is computed as:\n\n\\sum_{i=1}^{K-1} \\sum_{j=i+1}^K (|x_i - x_j| + |y_i - y_j|)\n\nFind the sum of the costs of all possible arrangements of the pieces. Since this value can be tremendous, print it modulo 10^9+7.\n\nWe consider two arrangements of the pieces different if and only if there is a square that contains a piece in one of the arrangements but not in the other.\n\nConstraints\n\n2 \\leq N \\times M \\leq 2 \\times 10^5\n\n2 \\leq K \\leq N \\times M\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\n\nOutput\n\nPrint the sum of the costs of all possible arrangements of the pieces, modulo 10^9+7.\n\nSample Input 1\n\n2 2 2\n\nSample Output 1\n\n8\n\nThere are six possible arrangements of the pieces, as follows:\n\n((1,1),(1,2)), with the cost |1-1|+|1-2| = 1\n\n((1,1),(2,1)), with the cost |1-2|+|1-1| = 1\n\n((1,1),(2,2)), with the cost |1-2|+|1-2| = 2\n\n((1,2),(2,1)), with the cost |1-2|+|2-1| = 2\n\n((1,2),(2,2)), with the cost |1-2|+|2-2| = 1\n\n((2,1),(2,2)), with the cost |2-2|+|1-2| = 1\n\nThe sum of these costs is 8.\n\nSample Input 2\n\n4 5 4\n\nSample Output 2\n\n87210\n\nSample Input 3\n\n100 100 5000\n\nSample Output 3\n\n817260251\n\nBe sure to print the sum modulo 10^9+7.", "sample_input": "2 2 2\n"}, "reference_outputs": ["8\n"], "source_document_id": "p03039", "source_text": "Score : 500 points\n\nProblem Statement\n\nWe have a grid of squares with N rows and M columns. Let (i, j) denote the square at the i-th row from the top and j-th column from the left. We will choose K of the squares and put a piece on each of them.\n\nIf we place the K pieces on squares (x_1, y_1), (x_2, y_2), ..., and (x_K, y_K), the cost of this arrangement is computed as:\n\n\\sum_{i=1}^{K-1} \\sum_{j=i+1}^K (|x_i - x_j| + |y_i - y_j|)\n\nFind the sum of the costs of all possible arrangements of the pieces. Since this value can be tremendous, print it modulo 10^9+7.\n\nWe consider two arrangements of the pieces different if and only if there is a square that contains a piece in one of the arrangements but not in the other.\n\nConstraints\n\n2 \\leq N \\times M \\leq 2 \\times 10^5\n\n2 \\leq K \\leq N \\times M\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\n\nOutput\n\nPrint the sum of the costs of all possible arrangements of the pieces, modulo 10^9+7.\n\nSample Input 1\n\n2 2 2\n\nSample Output 1\n\n8\n\nThere are six possible arrangements of the pieces, as follows:\n\n((1,1),(1,2)), with the cost |1-1|+|1-2| = 1\n\n((1,1),(2,1)), with the cost |1-2|+|1-1| = 1\n\n((1,1),(2,2)), with the cost |1-2|+|1-2| = 2\n\n((1,2),(2,1)), with the cost |1-2|+|2-1| = 2\n\n((1,2),(2,2)), with the cost |1-2|+|2-2| = 1\n\n((2,1),(2,2)), with the cost |2-2|+|1-2| = 1\n\nThe sum of these costs is 8.\n\nSample Input 2\n\n4 5 4\n\nSample Output 2\n\n87210\n\nSample Input 3\n\n100 100 5000\n\nSample Output 3\n\n817260251\n\nBe sure to print the sum modulo 10^9+7.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2664, "cpu_time_ms": 794, "memory_kb": 81112}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s249284532", "group_id": "codeNet:p03040", "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 Q = in.next().toInt\n var stack: List[Int] = Nil\n var elem = -1\n var sum = 0L\n var hoge = 0L\n var (minus, zero, plus) = (0, 0, 0)\n\n for (_ <- 0 until Q) {\n val com = in.next().toInt\n\n if (com == 1) {\n val a, b = in.next().toInt\n sum += b\n hoge += a.abs\n if (a > 0)\n plus += 1\n else if (a == 0)\n zero += 1\n else\n minus += 1\n\n stack = a :: stack\n elem += 1\n }\n else {\n val now = stack.sorted.toArray\n val mid = now(elem / 2).toLong\n\n var ans = sum + hoge\n \n if (mid > 0)\n ans += mid * (minus - plus + zero)\n else if (mid < 0)\n ans += mid.abs * (plus - minus + zero)\n\n pw.println(s\"$mid $ans\")\n }\n }\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": 1558911380, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03040.html", "problem_id": "p03040", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03040/input.txt", "sample_output_relpath": "derived/input_output/data/p03040/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03040/Scala/s249284532.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s249284532", "user_id": "u098968285"}, "prompt_components": {"gold_output": "4 2\n1 -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 Q = in.next().toInt\n var stack: List[Int] = Nil\n var elem = -1\n var sum = 0L\n var hoge = 0L\n var (minus, zero, plus) = (0, 0, 0)\n\n for (_ <- 0 until Q) {\n val com = in.next().toInt\n\n if (com == 1) {\n val a, b = in.next().toInt\n sum += b\n hoge += a.abs\n if (a > 0)\n plus += 1\n else if (a == 0)\n zero += 1\n else\n minus += 1\n\n stack = a :: stack\n elem += 1\n }\n else {\n val now = stack.sorted.toArray\n val mid = now(elem / 2).toLong\n\n var ans = sum + hoge\n \n if (mid > 0)\n ans += mid * (minus - plus + zero)\n else if (mid < 0)\n ans += mid.abs * (plus - minus + zero)\n\n pw.println(s\"$mid $ans\")\n }\n }\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 : 600 points\n\nProblem Statement\n\nThere is a function f(x), which is initially a constant function f(x) = 0.\n\nWe will ask you to process Q queries in order. There are two kinds of queries, update queries and evaluation queries, as follows:\n\nAn update query 1 a b: Given two integers a and b, let g(x) = f(x) + |x - a| + b and replace f(x) with g(x).\n\nAn evaluation query 2: Print x that minimizes f(x), and the minimum value of f(x). If there are multiple such values of x, choose the minimum such value.\n\nWe can show that the values to be output in an evaluation query are always integers, so we ask you to print those values as integers without decimal points.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq Q \\leq 2 \\times 10^5\n\n-10^9 \\leq a, b \\leq 10^9\n\nThe first query is an update query.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ\nQuery_1\n:\nQuery_Q\n\nSee Sample Input 1 for an example.\n\nOutput\n\nFor each evaluation query, print a line containing the response, in the order in which the queries are given.\n\nThe response to each evaluation query should be the minimum value of x that minimizes f(x), and the minimum value of f(x), in this order, with space in between.\n\nSample Input 1\n\n4\n1 4 2\n2\n1 1 -8\n2\n\nSample Output 1\n\n4 2\n1 -3\n\nIn the first evaluation query, f(x) = |x - 4| + 2, which attains the minimum value of 2 at x = 4.\n\nIn the second evaluation query, f(x) = |x - 1| + |x - 4| - 6, which attains the minimum value of -3 when 1 \\leq x \\leq 4. Among the multiple values of x that minimize f(x), we ask you to print the minimum, that is, 1.\n\nSample Input 2\n\n4\n1 -1000000000 1000000000\n1 -1000000000 1000000000\n1 -1000000000 1000000000\n2\n\nSample Output 2\n\n-1000000000 3000000000", "sample_input": "4\n1 4 2\n2\n1 1 -8\n2\n"}, "reference_outputs": ["4 2\n1 -3\n"], "source_document_id": "p03040", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere is a function f(x), which is initially a constant function f(x) = 0.\n\nWe will ask you to process Q queries in order. There are two kinds of queries, update queries and evaluation queries, as follows:\n\nAn update query 1 a b: Given two integers a and b, let g(x) = f(x) + |x - a| + b and replace f(x) with g(x).\n\nAn evaluation query 2: Print x that minimizes f(x), and the minimum value of f(x). If there are multiple such values of x, choose the minimum such value.\n\nWe can show that the values to be output in an evaluation query are always integers, so we ask you to print those values as integers without decimal points.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq Q \\leq 2 \\times 10^5\n\n-10^9 \\leq a, b \\leq 10^9\n\nThe first query is an update query.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ\nQuery_1\n:\nQuery_Q\n\nSee Sample Input 1 for an example.\n\nOutput\n\nFor each evaluation query, print a line containing the response, in the order in which the queries are given.\n\nThe response to each evaluation query should be the minimum value of x that minimizes f(x), and the minimum value of f(x), in this order, with space in between.\n\nSample Input 1\n\n4\n1 4 2\n2\n1 1 -8\n2\n\nSample Output 1\n\n4 2\n1 -3\n\nIn the first evaluation query, f(x) = |x - 4| + 2, which attains the minimum value of 2 at x = 4.\n\nIn the second evaluation query, f(x) = |x - 1| + |x - 4| - 6, which attains the minimum value of -3 when 1 \\leq x \\leq 4. Among the multiple values of x that minimize f(x), we ask you to print the minimum, that is, 1.\n\nSample Input 2\n\n4\n1 -1000000000 1000000000\n1 -1000000000 1000000000\n1 -1000000000 1000000000\n2\n\nSample Output 2\n\n-1000000000 3000000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2112, "memory_kb": 115572}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s232712244", "group_id": "codeNet:p03041", "input_text": "object Main extends App {\n\n val Array(n, k) = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n val s = scala.io.StdIn.readLine()\n\n\n def solve() = {\n s.updated(k-1, s(k-1).toLower)\n }\n\n println(solve)\n\n}", "language": "Scala", "metadata": {"date": 1572664704, "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/s232712244.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s232712244", "user_id": "u947008426"}, "prompt_components": {"gold_output": "aBC\n", "input_to_evaluate": "object Main extends App {\n\n val Array(n, k) = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n val s = scala.io.StdIn.readLine()\n\n\n def solve() = {\n s.updated(k-1, s(k-1).toLower)\n }\n\n println(solve)\n\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of A, B and C, and an integer K which is between 1 and N (inclusive).\nPrint the string S after lowercasing the K-th character in it.\n\nConstraints\n\n1 ≤ N ≤ 50\n\n1 ≤ K ≤ N\n\nS is a string of length N consisting of A, B and C.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the string S after lowercasing the K-th character in it.\n\nSample Input 1\n\n3 1\nABC\n\nSample Output 1\n\naBC\n\nSample Input 2\n\n4 3\nCABA\n\nSample Output 2\n\nCAbA", "sample_input": "3 1\nABC\n"}, "reference_outputs": ["aBC\n"], "source_document_id": "p03041", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of A, B and C, and an integer K which is between 1 and N (inclusive).\nPrint the string S after lowercasing the K-th character in it.\n\nConstraints\n\n1 ≤ N ≤ 50\n\n1 ≤ K ≤ N\n\nS is a string of length N consisting of A, B and C.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the string S after lowercasing the K-th character in it.\n\nSample Input 1\n\n3 1\nABC\n\nSample Output 1\n\naBC\n\nSample Input 2\n\n4 3\nCABA\n\nSample Output 2\n\nCAbA", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 213, "cpu_time_ms": 321, "memory_kb": 25508}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s453947913", "group_id": "codeNet:p03042", "input_text": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val s = in.readLine\n\n val month = (1 to 12)\n val first = if(month.contains(s.take(2).toInt)) true else false\n val second = if(month.contains(s.drop(2).toInt)) true else false\n\n val ans = (first, second) match {\n case (true, true) => \"AMBIGUOUS\"\n case (true, false) => \"MMYY\"\n case (false, true) => \"YYMM\"\n case _ => \"NA\"\n }\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1558380886, "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/s453947913.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s453947913", "user_id": "u217010036"}, "prompt_components": {"gold_output": "YYMM\n", "input_to_evaluate": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val s = in.readLine\n\n val month = (1 to 12)\n val first = if(month.contains(s.take(2).toInt)) true else false\n val second = if(month.contains(s.drop(2).toInt)) true else false\n\n val ans = (first, second) match {\n case (true, true) => \"AMBIGUOUS\"\n case (true, false) => \"MMYY\"\n case (false, true) => \"YYMM\"\n case _ => \"NA\"\n }\n println(ans)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have a digit sequence S of length 4. You are wondering which of the following formats S is in:\n\nYYMM format: the last two digits of the year and the two-digit representation of the month (example: 01 for January), concatenated in this order\n\nMMYY format: the two-digit representation of the month and the last two digits of the year, concatenated in this order\n\nIf S is valid in only YYMM format, print YYMM; if S is valid in only MMYY format, print MMYY; if S is valid in both formats, print AMBIGUOUS; if S is valid in neither format, print NA.\n\nConstraints\n\nS is a digit sequence of length 4.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the specified string: YYMM, MMYY, AMBIGUOUS or NA.\n\nSample Input 1\n\n1905\n\nSample Output 1\n\nYYMM\n\nMay XX19 is a valid date, but 19 is not valid as a month. Thus, this string is only valid in YYMM format.\n\nSample Input 2\n\n0112\n\nSample Output 2\n\nAMBIGUOUS\n\nBoth December XX01 and January XX12 are valid dates. Thus, this string is valid in both formats.\n\nSample Input 3\n\n1700\n\nSample Output 3\n\nNA\n\nNeither 0 nor 17 is valid as a month. Thus, this string is valid in neither format.", "sample_input": "1905\n"}, "reference_outputs": ["YYMM\n"], "source_document_id": "p03042", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have a digit sequence S of length 4. You are wondering which of the following formats S is in:\n\nYYMM format: the last two digits of the year and the two-digit representation of the month (example: 01 for January), concatenated in this order\n\nMMYY format: the two-digit representation of the month and the last two digits of the year, concatenated in this order\n\nIf S is valid in only YYMM format, print YYMM; if S is valid in only MMYY format, print MMYY; if S is valid in both formats, print AMBIGUOUS; if S is valid in neither format, print NA.\n\nConstraints\n\nS is a digit sequence of length 4.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the specified string: YYMM, MMYY, AMBIGUOUS or NA.\n\nSample Input 1\n\n1905\n\nSample Output 1\n\nYYMM\n\nMay XX19 is a valid date, but 19 is not valid as a month. Thus, this string is only valid in YYMM format.\n\nSample Input 2\n\n0112\n\nSample Output 2\n\nAMBIGUOUS\n\nBoth December XX01 and January XX12 are valid dates. Thus, this string is valid in both formats.\n\nSample Input 3\n\n1700\n\nSample Output 3\n\nNA\n\nNeither 0 nor 17 is valid as a month. Thus, this string is valid in neither format.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 416, "cpu_time_ms": 328, "memory_kb": 25548}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s586433206", "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: Long)\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.nextLong\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, Long]()\n\n def dfs(node: Int, depth: Long): 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": 1561233317, "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/s586433206.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s586433206", "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: Long)\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.nextLong\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, Long]()\n\n def dfs(node: Int, depth: Long): 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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2115, "memory_kb": 126024}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s477060478", "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 E = Array.fill(N)(new scala.collection.mutable.ArrayBuffer[(Int, Byte)]())\n val ru, rv, rw = sc.nextInt()\n E(ru-1).append((rv-1, (rw % 2).toByte))\n E(rv-1).append((ru-1, (rw % 2).toByte))\n (0 until N - 2) foreach { _ =>\n val u, v, w = sc.nextInt()\n E(u-1).append((v-1, (w % 2).toByte))\n E(v-1).append((u-1, (w % 2).toByte))\n }\n\n val visited = new Array[Boolean](N)\n val color = new Array[Byte](N)\n color(ru) = 0\n visited(ru) = true\n\n def dfs(u: Int): Unit =\n E(u) foreach { case (v, w) =>\n if (!visited(v)) {\n visited(v) = true\n if (w == 0) {\n color(v) = color(u)\n dfs(v)\n } else {\n color(v) = (1 - color(u)).toByte\n dfs(v)\n }\n }\n }\n\n dfs(ru)\n color.foreach(println)\n }\n\n}", "language": "Scala", "metadata": {"date": 1559257884, "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/s477060478.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s477060478", "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 E = Array.fill(N)(new scala.collection.mutable.ArrayBuffer[(Int, Byte)]())\n val ru, rv, rw = sc.nextInt()\n E(ru-1).append((rv-1, (rw % 2).toByte))\n E(rv-1).append((ru-1, (rw % 2).toByte))\n (0 until N - 2) foreach { _ =>\n val u, v, w = sc.nextInt()\n E(u-1).append((v-1, (w % 2).toByte))\n E(v-1).append((u-1, (w % 2).toByte))\n }\n\n val visited = new Array[Boolean](N)\n val color = new Array[Byte](N)\n color(ru) = 0\n visited(ru) = true\n\n def dfs(u: Int): Unit =\n E(u) foreach { case (v, w) =>\n if (!visited(v)) {\n visited(v) = true\n if (w == 0) {\n color(v) = color(u)\n dfs(v)\n } else {\n color(v) = (1 - color(u)).toByte\n dfs(v)\n }\n }\n }\n\n dfs(ru)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 966, "cpu_time_ms": 1730, "memory_kb": 122564}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s218328730", "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)(-1)\n\n (0 until N - 1).map { _ =>\n val u, v, w = sc.nextInt()\n (u - 1, v - 1, w % 2)\n }. foreach { e =>\n val (u, v, w) = e\n distance(u)(v) = w\n distance(v)(u) = w\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": 1559198312, "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/s218328730.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s218328730", "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)(-1)\n\n (0 until N - 1).map { _ =>\n val u, v, w = sc.nextInt()\n (u - 1, v - 1, w % 2)\n }. foreach { e =>\n val (u, v, w) = e\n distance(u)(v) = w\n distance(v)(u) = w\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 855, "cpu_time_ms": 741, "memory_kb": 299144}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s254031045", "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 // ここ、0オリジン化した方がいい\n val edges = IndexedSeq.fill(n - 1)(Edge(sc.nextInt(), sc.nextInt(), sc.nextInt()))\n (n, edges)\n }\n\n def read2() = {\n val input = io.Source.stdin.getLines()\n val n = input.next().toInt\n val edges = IndexedSeq.fill(n - 1) {\n val strs = input.next().split(\" \")\n Edge(strs(0).toInt, strs(1).toInt, strs(2).toInt)\n }\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 output1(result: IndexedSeq[Int]) = {\n result.foreach(println)\n }\n\n def output2(result: IndexedSeq[Int]) = {\n result.foreach(System.out.println)\n }\n\n def output3(result: IndexedSeq[Int]) = {\n val out = new java.io.PrintWriter(System.out)\n result.foreach(out.println)\n out.flush()\n }\n\n def main(args: Array[String]): Unit = {\n val (n, edges) = read2()\n output3(solve(n, edges))\n }\n}", "language": "Scala", "metadata": {"date": 1558815152, "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/s254031045.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s254031045", "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 // ここ、0オリジン化した方がいい\n val edges = IndexedSeq.fill(n - 1)(Edge(sc.nextInt(), sc.nextInt(), sc.nextInt()))\n (n, edges)\n }\n\n def read2() = {\n val input = io.Source.stdin.getLines()\n val n = input.next().toInt\n val edges = IndexedSeq.fill(n - 1) {\n val strs = input.next().split(\" \")\n Edge(strs(0).toInt, strs(1).toInt, strs(2).toInt)\n }\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 output1(result: IndexedSeq[Int]) = {\n result.foreach(println)\n }\n\n def output2(result: IndexedSeq[Int]) = {\n result.foreach(System.out.println)\n }\n\n def output3(result: IndexedSeq[Int]) = {\n val out = new java.io.PrintWriter(System.out)\n result.foreach(out.println)\n out.flush()\n }\n\n def main(args: Array[String]): Unit = {\n val (n, edges) = read2()\n output3(solve(n, edges))\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a tree with N vertices numbered 1 to N.\nThe i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i.\nYour objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied:\n\nFor any two vertices painted in the same color, the distance between them is an even number.\n\nFind a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq u_i < v_i \\leq N\n\n1 \\leq w_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nu_1 v_1 w_1\nu_2 v_2 w_2\n.\n.\n.\nu_{N - 1} v_{N - 1} w_{N - 1}\n\nOutput\n\nPrint a coloring of the vertices that satisfies the condition, in N lines.\nThe i-th line should contain 0 if Vertex i is painted white and 1 if it is painted black.\n\nIf there are multiple colorings that satisfy the condition, any of them will be accepted.\n\nSample Input 1\n\n3\n1 2 2\n2 3 1\n\nSample Output 1\n\n0\n0\n1\n\nSample Input 2\n\n5\n2 5 2\n2 3 10\n1 3 8\n3 4 2\n\nSample Output 2\n\n1\n0\n1\n0\n1", "sample_input": "3\n1 2 2\n2 3 1\n"}, "reference_outputs": ["0\n0\n1\n"], "source_document_id": "p03044", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a tree with N vertices numbered 1 to N.\nThe i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i.\nYour objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied:\n\nFor any two vertices painted in the same color, the distance between them is an even number.\n\nFind a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq u_i < v_i \\leq N\n\n1 \\leq w_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nu_1 v_1 w_1\nu_2 v_2 w_2\n.\n.\n.\nu_{N - 1} v_{N - 1} w_{N - 1}\n\nOutput\n\nPrint a coloring of the vertices that satisfies the condition, in N lines.\nThe i-th line should contain 0 if Vertex i is painted white and 1 if it is painted black.\n\nIf there are multiple colorings that satisfy the condition, any of them will be accepted.\n\nSample Input 1\n\n3\n1 2 2\n2 3 1\n\nSample Output 1\n\n0\n0\n1\n\nSample Input 2\n\n5\n2 5 2\n2 3 10\n1 3 8\n3 4 2\n\nSample Output 2\n\n1\n0\n1\n0\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2094, "cpu_time_ms": 1081, "memory_kb": 69640}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s563245578", "group_id": "codeNet:p03044", "input_text": "import scala.io.{StdIn => in}\nimport scala.collection.{mutable => mu}\n\nobject Main extends App {\n val n = in.readInt\n\n case class edge(v:Int, d:Int)\n val tree = Array.fill(n)(mu.ListBuffer.empty[edge])\n\n Iterator.continually(in.readLine)\n .take(n-1)\n .map(_.split(\" \").map(_.toInt))\n .foreach { e =>\n tree(e(0)-1) :+= new edge(e(1)-1, e(2))\n tree(e(1)-1) :+= new edge(e(0)-1, e(2))\n }\n\n val colors = Array.ofDim[Int](n)\n val visit = Array.ofDim[Boolean](n)\n\n def dfs(v:Int, d:Int):Unit = {\n if(!visit(v)) {\n // println(\"v:\" + v + \" \" + d)\n visit(v) = true\n colors(v) = if(d % 2 == 0) 0 else 1\n for(nv <- tree(v))\n dfs(nv.v, d + nv.d)\n }\n }\n\n dfs(0,0)\n println(colors.mkString(\"\\n\"))\n}", "language": "Scala", "metadata": {"date": 1558385646, "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/s563245578.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s563245578", "user_id": "u217010036"}, "prompt_components": {"gold_output": "0\n0\n1\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\n case class edge(v:Int, d:Int)\n val tree = Array.fill(n)(mu.ListBuffer.empty[edge])\n\n Iterator.continually(in.readLine)\n .take(n-1)\n .map(_.split(\" \").map(_.toInt))\n .foreach { e =>\n tree(e(0)-1) :+= new edge(e(1)-1, e(2))\n tree(e(1)-1) :+= new edge(e(0)-1, e(2))\n }\n\n val colors = Array.ofDim[Int](n)\n val visit = Array.ofDim[Boolean](n)\n\n def dfs(v:Int, d:Int):Unit = {\n if(!visit(v)) {\n // println(\"v:\" + v + \" \" + d)\n visit(v) = true\n colors(v) = if(d % 2 == 0) 0 else 1\n for(nv <- tree(v))\n dfs(nv.v, d + nv.d)\n }\n }\n\n dfs(0,0)\n println(colors.mkString(\"\\n\"))\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a tree with N vertices numbered 1 to N.\nThe i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i.\nYour objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied:\n\nFor any two vertices painted in the same color, the distance between them is an even number.\n\nFind a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq u_i < v_i \\leq N\n\n1 \\leq w_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nu_1 v_1 w_1\nu_2 v_2 w_2\n.\n.\n.\nu_{N - 1} v_{N - 1} w_{N - 1}\n\nOutput\n\nPrint a coloring of the vertices that satisfies the condition, in N lines.\nThe i-th line should contain 0 if Vertex i is painted white and 1 if it is painted black.\n\nIf there are multiple colorings that satisfy the condition, any of them will be accepted.\n\nSample Input 1\n\n3\n1 2 2\n2 3 1\n\nSample Output 1\n\n0\n0\n1\n\nSample Input 2\n\n5\n2 5 2\n2 3 10\n1 3 8\n3 4 2\n\nSample Output 2\n\n1\n0\n1\n0\n1", "sample_input": "3\n1 2 2\n2 3 1\n"}, "reference_outputs": ["0\n0\n1\n"], "source_document_id": "p03044", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a tree with N vertices numbered 1 to N.\nThe i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i.\nYour objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied:\n\nFor any two vertices painted in the same color, the distance between them is an even number.\n\nFind a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq u_i < v_i \\leq N\n\n1 \\leq w_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nu_1 v_1 w_1\nu_2 v_2 w_2\n.\n.\n.\nu_{N - 1} v_{N - 1} w_{N - 1}\n\nOutput\n\nPrint a coloring of the vertices that satisfies the condition, in N lines.\nThe i-th line should contain 0 if Vertex i is painted white and 1 if it is painted black.\n\nIf there are multiple colorings that satisfy the condition, any of them will be accepted.\n\nSample Input 1\n\n3\n1 2 2\n2 3 1\n\nSample Output 1\n\n0\n0\n1\n\nSample Input 2\n\n5\n2 5 2\n2 3 10\n1 3 8\n3 4 2\n\nSample Output 2\n\n1\n0\n1\n0\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 749, "cpu_time_ms": 2111, "memory_kb": 122788}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s240553242", "group_id": "codeNet:p03045", "input_text": "import java.util.Scanner\n\nimport scala.collection.mutable.ArrayBuffer\n\n\nobject Main {\n case class Edge(x: Int, y: Int, z: Long)\n \n def read() = {\n val sc = new Scanner(System.in)\n val n, m = sc.nextInt()\n //0-index化\n val edges = IndexedSeq.fill(m)(Edge(sc.nextInt() - 1, sc.nextInt() - 1, sc.nextInt()))\n\n (n, m, edges)\n }\n\n\n def solve2(n: Int, m: Int, edges: IndexedSeq[Edge]): Int = {\n var cnt = 0 // 連結成分数\n\n val nextList = IndexedSeq.fill(n)(ArrayBuffer.empty[Edge])\n for (edge <- edges) {\n val from = edge.x\n val to = edge.y\n nextList(from).append(edge)\n nextList(to).append(Edge(to, from, edge.z))\n }\n\n val visited = Array.fill(n)(false)\n for (i <- 0 until n) {\n if (!visited(i)) {\n visited(i) = true\n cnt += 1\n //BFS\n val open: java.util.Queue[Int] = new java.util.ArrayDeque[Int]()\n open.add(i)\n while (!open.isEmpty) {\n val current = open.remove()\n for (edge <- nextList(current)) {\n val next = edge.y\n if(!visited(next)) {\n open.add(next)\n visited(next) = true\n }\n }\n }\n\n }\n }\n cnt\n }\n\n def main(args: Array[String]): Unit = {\n val (n, m, edges) = read()\n println(solve2(n, m, edges))\n }\n}\n", "language": "Scala", "metadata": {"date": 1558725374, "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/s240553242.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s240553242", "user_id": "u494788559"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.collection.mutable.ArrayBuffer\n\n\nobject Main {\n case class Edge(x: Int, y: Int, z: Long)\n \n def read() = {\n val sc = new Scanner(System.in)\n val n, m = sc.nextInt()\n //0-index化\n val edges = IndexedSeq.fill(m)(Edge(sc.nextInt() - 1, sc.nextInt() - 1, sc.nextInt()))\n\n (n, m, edges)\n }\n\n\n def solve2(n: Int, m: Int, edges: IndexedSeq[Edge]): Int = {\n var cnt = 0 // 連結成分数\n\n val nextList = IndexedSeq.fill(n)(ArrayBuffer.empty[Edge])\n for (edge <- edges) {\n val from = edge.x\n val to = edge.y\n nextList(from).append(edge)\n nextList(to).append(Edge(to, from, edge.z))\n }\n\n val visited = Array.fill(n)(false)\n for (i <- 0 until n) {\n if (!visited(i)) {\n visited(i) = true\n cnt += 1\n //BFS\n val open: java.util.Queue[Int] = new java.util.ArrayDeque[Int]()\n open.add(i)\n while (!open.isEmpty) {\n val current = open.remove()\n for (edge <- nextList(current)) {\n val next = edge.y\n if(!visited(next)) {\n open.add(next)\n visited(next) = true\n }\n }\n }\n\n }\n }\n cnt\n }\n\n def main(args: Array[String]): Unit = {\n val (n, m, edges) = read()\n println(solve2(n, m, edges))\n }\n}\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N cards placed face down in a row. On each card, an integer 1 or 2 is written.\n\nLet A_i be the integer written on the i-th card.\n\nYour objective is to guess A_1, A_2, ..., A_N correctly.\n\nYou know the following facts:\n\nFor each i = 1, 2, ..., M, the value A_{X_i} + A_{Y_i} + Z_i is an even number.\n\nYou are a magician and can use the following magic any number of times:\n\nMagic: Choose one card and know the integer A_i written on it. The cost of using this magic is 1.\n\nWhat is the minimum cost required to determine all of A_1, A_2, ..., A_N?\n\nIt is guaranteed that there is no contradiction in given input.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq X_i < Y_i \\leq N\n\n1 \\leq Z_i \\leq 100\n\nThe pairs (X_i, Y_i) are distinct.\n\nThere is no contradiction in input. (That is, there exist integers A_1, A_2, ..., A_N that satisfy the conditions.)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 Y_1 Z_1\nX_2 Y_2 Z_2\n\\vdots\nX_M Y_M Z_M\n\nOutput\n\nPrint the minimum total cost required to determine all of A_1, A_2, ..., A_N.\n\nSample Input 1\n\n3 1\n1 2 1\n\nSample Output 1\n\n2\n\nYou can determine all of A_1, A_2, A_3 by using the magic for the first and third cards.\n\nSample Input 2\n\n6 5\n1 2 1\n2 3 2\n1 3 3\n4 5 4\n5 6 5\n\nSample Output 2\n\n2\n\nSample Input 3\n\n100000 1\n1 100000 100\n\nSample Output 3\n\n99999", "sample_input": "3 1\n1 2 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03045", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N cards placed face down in a row. On each card, an integer 1 or 2 is written.\n\nLet A_i be the integer written on the i-th card.\n\nYour objective is to guess A_1, A_2, ..., A_N correctly.\n\nYou know the following facts:\n\nFor each i = 1, 2, ..., M, the value A_{X_i} + A_{Y_i} + Z_i is an even number.\n\nYou are a magician and can use the following magic any number of times:\n\nMagic: Choose one card and know the integer A_i written on it. The cost of using this magic is 1.\n\nWhat is the minimum cost required to determine all of A_1, A_2, ..., A_N?\n\nIt is guaranteed that there is no contradiction in given input.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq X_i < Y_i \\leq N\n\n1 \\leq Z_i \\leq 100\n\nThe pairs (X_i, Y_i) are distinct.\n\nThere is no contradiction in input. (That is, there exist integers A_1, A_2, ..., A_N that satisfy the conditions.)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 Y_1 Z_1\nX_2 Y_2 Z_2\n\\vdots\nX_M Y_M Z_M\n\nOutput\n\nPrint the minimum total cost required to determine all of A_1, A_2, ..., A_N.\n\nSample Input 1\n\n3 1\n1 2 1\n\nSample Output 1\n\n2\n\nYou can determine all of A_1, A_2, A_3 by using the magic for the first and third cards.\n\nSample Input 2\n\n6 5\n1 2 1\n2 3 2\n1 3 3\n4 5 4\n5 6 5\n\nSample Output 2\n\n2\n\nSample Input 3\n\n100000 1\n1 100000 100\n\nSample Output 3\n\n99999", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1329, "cpu_time_ms": 1122, "memory_kb": 117904}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s005309009", "group_id": "codeNet:p03047", "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 Array(n, k) = in.readLine().split(\"\\\\s+\").map(_.toInt)\n\n out.println(n - k + 1)\n out.flush()\n }\n}\n", "language": "Scala", "metadata": {"date": 1585969686, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03047.html", "problem_id": "p03047", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03047/input.txt", "sample_output_relpath": "derived/input_output/data/p03047/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03047/Scala/s005309009.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s005309009", "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 Array(n, k) = in.readLine().split(\"\\\\s+\").map(_.toInt)\n\n out.println(n - k + 1)\n out.flush()\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSnuke has N integers: 1,2,\\ldots,N.\nHe will choose K of them and give those to Takahashi.\n\nHow many ways are there to choose K consecutive integers?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq K \\leq N \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n2\n\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2\n\n13 3\n\nSample Output 2\n\n11", "sample_input": "3 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03047", "source_text": "Score : 100 points\n\nProblem Statement\n\nSnuke has N integers: 1,2,\\ldots,N.\nHe will choose K of them and give those to Takahashi.\n\nHow many ways are there to choose K consecutive integers?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq K \\leq N \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n2\n\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2\n\n13 3\n\nSample Output 2\n\n11", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 390, "cpu_time_ms": 322, "memory_kb": 25420}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s232095132", "group_id": "codeNet:p03047", "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.nextLine.split(\" \").map(i => i.toInt)\n var i = 0\n var count = 0\n var res = 0\n while (i < a(0)){\n i += 1\n count += 1\n if (count == a(1)){\n res += 1\n count = 0\n i -= (a(1) - 1)\n }\n }\n println(res)\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": 1559820670, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03047.html", "problem_id": "p03047", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03047/input.txt", "sample_output_relpath": "derived/input_output/data/p03047/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03047/Scala/s232095132.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s232095132", "user_id": "u992675902"}, "prompt_components": {"gold_output": "2\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.nextLine.split(\" \").map(i => i.toInt)\n var i = 0\n var count = 0\n var res = 0\n while (i < a(0)){\n i += 1\n count += 1\n if (count == a(1)){\n res += 1\n count = 0\n i -= (a(1) - 1)\n }\n }\n println(res)\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 N integers: 1,2,\\ldots,N.\nHe will choose K of them and give those to Takahashi.\n\nHow many ways are there to choose K consecutive integers?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq K \\leq N \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n2\n\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2\n\n13 3\n\nSample Output 2\n\n11", "sample_input": "3 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03047", "source_text": "Score : 100 points\n\nProblem Statement\n\nSnuke has N integers: 1,2,\\ldots,N.\nHe will choose K of them and give those to Takahashi.\n\nHow many ways are there to choose K consecutive integers?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq K \\leq N \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n2\n\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2\n\n13 3\n\nSample Output 2\n\n11", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1588, "cpu_time_ms": 326, "memory_kb": 25540}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s130926880", "group_id": "codeNet:p03049", "input_text": "import java.util.Scanner\n\nimport scala.util.Random\n\n\nobject Main {\n def read() = {\n val sc = new Scanner(System.in)\n val n = sc.nextInt()\n val strs = for (_ <- 0 until n) yield sc.next()\n (n, strs)\n }\n\n def solve(n:Int, strs: IndexedSeq[String]): Int={\n // AB含み\n // A終わり\n // B始まり\n // A終わりB始まり\n\n val nContainsAB = strs.map(str => {\n (0 until str.length-1).count(i=> str(i) == 'A' && str(i+1)=='B')\n }).sum\n val nAEnd = strs.count(str => str.last == 'A')\n val nBBegin = strs.count(str => str.head == 'B')\n val nAEndBBegin = strs.count(str => str.last == 'A' && str.head=='B')\n\n if(nAEndBBegin > 0 && nAEndBBegin == nAEnd && nAEndBBegin == nBBegin){\n nContainsAB + nAEndBBegin - 1\n }else{\n nContainsAB + Math.min(nAEnd, nBBegin)\n }\n }\n\n def solveNaive(n:Int, strs: IndexedSeq[String]): Int={\n def countAB(str:String) = (0 until str.length-1).count(i=> str(i) == 'A' && str(i+1)=='B')\n strs.permutations.map(pstrs => pstrs.flatten.mkString).map(countAB).max\n }\n\n def rand(n:Int) = {\n Random.setSeed(123)\n val chars = \"ABH\"\n val strs =(0 until n).map{ k =>\n val len = Random.nextInt(6) + 1\n (0 until len).map(_=>chars(Random.nextInt(3))).mkString\n }\n println(n)\n strs.foreach(println)\n (n,strs)\n }\n\n def experiment(n:Int) ={\n for (_ <- 0 until 100){\n val (n, strs) = rand(5)\n val resultNormal = solve(n, strs)\n val resultNaive = solveNaive(n, strs)\n println(s\"$resultNormal, $resultNaive, ${resultNormal == resultNaive}\")\n }\n }\n\n def main(args: Array[String]): Unit = {\n val (n, strs) = read()\n //val (n, strs) = rand(5)\n println(solve(n,strs))\n //println(solveNaive(n,strs))\n //experiment(5)\n }\n}", "language": "Scala", "metadata": {"date": 1557686509, "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/s130926880.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s130926880", "user_id": "u494788559"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.util.Random\n\n\nobject Main {\n def read() = {\n val sc = new Scanner(System.in)\n val n = sc.nextInt()\n val strs = for (_ <- 0 until n) yield sc.next()\n (n, strs)\n }\n\n def solve(n:Int, strs: IndexedSeq[String]): Int={\n // AB含み\n // A終わり\n // B始まり\n // A終わりB始まり\n\n val nContainsAB = strs.map(str => {\n (0 until str.length-1).count(i=> str(i) == 'A' && str(i+1)=='B')\n }).sum\n val nAEnd = strs.count(str => str.last == 'A')\n val nBBegin = strs.count(str => str.head == 'B')\n val nAEndBBegin = strs.count(str => str.last == 'A' && str.head=='B')\n\n if(nAEndBBegin > 0 && nAEndBBegin == nAEnd && nAEndBBegin == nBBegin){\n nContainsAB + nAEndBBegin - 1\n }else{\n nContainsAB + Math.min(nAEnd, nBBegin)\n }\n }\n\n def solveNaive(n:Int, strs: IndexedSeq[String]): Int={\n def countAB(str:String) = (0 until str.length-1).count(i=> str(i) == 'A' && str(i+1)=='B')\n strs.permutations.map(pstrs => pstrs.flatten.mkString).map(countAB).max\n }\n\n def rand(n:Int) = {\n Random.setSeed(123)\n val chars = \"ABH\"\n val strs =(0 until n).map{ k =>\n val len = Random.nextInt(6) + 1\n (0 until len).map(_=>chars(Random.nextInt(3))).mkString\n }\n println(n)\n strs.foreach(println)\n (n,strs)\n }\n\n def experiment(n:Int) ={\n for (_ <- 0 until 100){\n val (n, strs) = rand(5)\n val resultNormal = solve(n, strs)\n val resultNaive = solveNaive(n, strs)\n println(s\"$resultNormal, $resultNaive, ${resultNormal == resultNaive}\")\n }\n }\n\n def main(args: Array[String]): Unit = {\n val (n, strs) = read()\n //val (n, strs) = rand(5)\n println(solve(n,strs))\n //println(solveNaive(n,strs))\n //experiment(5)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1773, "cpu_time_ms": 844, "memory_kb": 38728}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s409010733", "group_id": "codeNet:p03050", "input_text": "object Main {\n\n def main(args: Array[String]): Unit = {\n import scala.io.StdIn._\n val N = readLine().toLong\n\n val start = Math.floor((1 + Math.sqrt(4 * N + 1))/2).toLong\n\n def rec(m: Long, acm: Long): Long =\n if (m < N) {\n if ((N / m) == (N % m)) rec(m + 1, acm + m)\n else rec(m + 1, acm)\n } else acm\n\n println(rec(start, 0))\n }\n\n}", "language": "Scala", "metadata": {"date": 1557631022, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03050.html", "problem_id": "p03050", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03050/input.txt", "sample_output_relpath": "derived/input_output/data/p03050/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03050/Scala/s409010733.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s409010733", "user_id": "u891387249"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "object Main {\n\n def main(args: Array[String]): Unit = {\n import scala.io.StdIn._\n val N = readLine().toLong\n\n val start = Math.floor((1 + Math.sqrt(4 * N + 1))/2).toLong\n\n def rec(m: Long, acm: Long): Long =\n if (m < N) {\n if ((N / m) == (N % m)) rec(m + 1, acm + m)\n else rec(m + 1, acm)\n } else acm\n\n println(rec(start, 0))\n }\n\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nSnuke received a positive integer N from Takahashi.\nA positive integer m is called a favorite number when the following condition is satisfied:\n\nThe quotient and remainder of N divided by m are equal, that is, \\lfloor \\frac{N}{m} \\rfloor = N \\bmod m holds.\n\nFind all favorite numbers and print the sum of those.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n10\n\nThere are two favorite numbers: 3 and 7. Print the sum of these, 10.\n\nSample Input 2\n\n1000000000000\n\nSample Output 2\n\n2499686339916\n\nWatch out for overflow.", "sample_input": "8\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03050", "source_text": "Score : 500 points\n\nProblem Statement\n\nSnuke received a positive integer N from Takahashi.\nA positive integer m is called a favorite number when the following condition is satisfied:\n\nThe quotient and remainder of N divided by m are equal, that is, \\lfloor \\frac{N}{m} \\rfloor = N \\bmod m holds.\n\nFind all favorite numbers and print the sum of those.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n10\n\nThere are two favorite numbers: 3 and 7. Print the sum of these, 10.\n\nSample Input 2\n\n1000000000000\n\nSample Output 2\n\n2499686339916\n\nWatch out for overflow.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 25384}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s347337881", "group_id": "codeNet:p03059", "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, T = sc.nextLong()\n println(T / A * B)\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, maxV: Long): Long = {\n if (!memo.contains((input, maxV))) {\n val ans = if (input == 0) 1 else (1L to Math.min(input, maxV)).map(i => recursive(input - i, i)).sum\n memo += ((input, maxV) -> ans)\n }\n memo((input, maxV))\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": 1556669911, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03059.html", "problem_id": "p03059", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03059/input.txt", "sample_output_relpath": "derived/input_output/data/p03059/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03059/Scala/s347337881.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s347337881", "user_id": "u779353743"}, "prompt_components": {"gold_output": "10\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, T = sc.nextLong()\n println(T / A * B)\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, maxV: Long): Long = {\n if (!memo.contains((input, maxV))) {\n val ans = if (input == 0) 1 else (1L to Math.min(input, maxV)).map(i => recursive(input - i, i)).sum\n memo += ((input, maxV) -> ans)\n }\n memo((input, maxV))\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\nA biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation.\n\nFind the total number of biscuits produced within T + 0.5 seconds after activation.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B, T \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B T\n\nOutput\n\nPrint the total number of biscuits produced within T + 0.5 seconds after activation.\n\nSample Input 1\n\n3 5 7\n\nSample Output 1\n\n10\n\nFive biscuits will be produced three seconds after activation.\n\nAnother five biscuits will be produced six seconds after activation.\n\nThus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\nSample Input 2\n\n3 2 9\n\nSample Output 2\n\n6\n\nSample Input 3\n\n20 20 19\n\nSample Output 3\n\n0", "sample_input": "3 5 7\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03059", "source_text": "Score : 100 points\n\nProblem Statement\n\nA biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation.\n\nFind the total number of biscuits produced within T + 0.5 seconds after activation.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B, T \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B T\n\nOutput\n\nPrint the total number of biscuits produced within T + 0.5 seconds after activation.\n\nSample Input 1\n\n3 5 7\n\nSample Output 1\n\n10\n\nFive biscuits will be produced three seconds after activation.\n\nAnother five biscuits will be produced six seconds after activation.\n\nThus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\nSample Input 2\n\n3 2 9\n\nSample Output 2\n\n6\n\nSample Input 3\n\n20 20 19\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6516, "cpu_time_ms": 329, "memory_kb": 27208}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s929504118", "group_id": "codeNet:p03059", "input_text": "\nimport java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val a, b, t = sc.nextInt\n println(t / a * b)\n}\n", "language": "Scala", "metadata": {"date": 1556477196, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03059.html", "problem_id": "p03059", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03059/input.txt", "sample_output_relpath": "derived/input_output/data/p03059/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03059/Scala/s929504118.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s929504118", "user_id": "u726872801"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "\nimport java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val a, b, t = sc.nextInt\n println(t / a * b)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation.\n\nFind the total number of biscuits produced within T + 0.5 seconds after activation.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B, T \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B T\n\nOutput\n\nPrint the total number of biscuits produced within T + 0.5 seconds after activation.\n\nSample Input 1\n\n3 5 7\n\nSample Output 1\n\n10\n\nFive biscuits will be produced three seconds after activation.\n\nAnother five biscuits will be produced six seconds after activation.\n\nThus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\nSample Input 2\n\n3 2 9\n\nSample Output 2\n\n6\n\nSample Input 3\n\n20 20 19\n\nSample Output 3\n\n0", "sample_input": "3 5 7\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03059", "source_text": "Score : 100 points\n\nProblem Statement\n\nA biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation.\n\nFind the total number of biscuits produced within T + 0.5 seconds after activation.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B, T \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B T\n\nOutput\n\nPrint the total number of biscuits produced within T + 0.5 seconds after activation.\n\nSample Input 1\n\n3 5 7\n\nSample Output 1\n\n10\n\nFive biscuits will be produced three seconds after activation.\n\nAnother five biscuits will be produced six seconds after activation.\n\nThus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\nSample Input 2\n\n3 2 9\n\nSample Output 2\n\n6\n\nSample Input 3\n\n20 20 19\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 138, "cpu_time_ms": 357, "memory_kb": 25780}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s438944415", "group_id": "codeNet:p03060", "input_text": "\n\n import io.StdIn._\n object Main extends App {\n val diamonds = Input(readInt(), readLine(), readLine()).diamonds().foldLeft[Diamonds](Diamonds(Nil)) { (purchased: Diamonds, diamond: Diamond) =>\n val next = purchased.add(diamond)\n if (next.value() > purchased.value() && next.cost() < purchased.cost()) next\n else purchased\n }\n\n println(diamonds.value())\n }\n\n case class Input(numberOfDiamond: Int, values: Seq[Int], costs: Seq[Int]) {\n def diamonds(): Seq[Diamond] = {\n values.zip(costs).map { case (value, cost) => Diamond.apply(value, cost) }\n }\n }\n\n object Input {\n def apply(n: Int, values: String, costs: String): Input = {\n Input(n.toInt, values.split(' ').map(_.toInt), costs.split(' ').map(_.toInt))\n }\n }\n\ncase class Diamond(value:Int, cost: Int)\n\ncase class Diamonds(values: Seq[Diamond]) {\n def value(): Int =\n values.foldLeft(0)(_ + _.value)\n\n def cost(): Int =\n values.foldLeft(0)(_ + _.cost)\n\n def add(diamond: Diamond): Diamonds = Diamonds(values :+ diamond)\n}", "language": "Scala", "metadata": {"date": 1596812902, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03060.html", "problem_id": "p03060", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03060/input.txt", "sample_output_relpath": "derived/input_output/data/p03060/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03060/Scala/s438944415.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s438944415", "user_id": "u388106329"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "\n\n import io.StdIn._\n object Main extends App {\n val diamonds = Input(readInt(), readLine(), readLine()).diamonds().foldLeft[Diamonds](Diamonds(Nil)) { (purchased: Diamonds, diamond: Diamond) =>\n val next = purchased.add(diamond)\n if (next.value() > purchased.value() && next.cost() < purchased.cost()) next\n else purchased\n }\n\n println(diamonds.value())\n }\n\n case class Input(numberOfDiamond: Int, values: Seq[Int], costs: Seq[Int]) {\n def diamonds(): Seq[Diamond] = {\n values.zip(costs).map { case (value, cost) => Diamond.apply(value, cost) }\n }\n }\n\n object Input {\n def apply(n: Int, values: String, costs: String): Input = {\n Input(n.toInt, values.split(' ').map(_.toInt), costs.split(' ').map(_.toInt))\n }\n }\n\ncase class Diamond(value:Int, cost: Int)\n\ncase class Diamonds(values: Seq[Diamond]) {\n def value(): Int =\n values.foldLeft(0)(_ + _.value)\n\n def cost(): Int =\n values.foldLeft(0)(_ + _.cost)\n\n def add(diamond: Diamond): Diamonds = Diamonds(values :+ diamond)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N gems. The value of the i-th gem is V_i.\n\nYou will choose some of these gems, possibly all or none, and get them.\n\nHowever, you need to pay a cost of C_i to get the i-th gem.\n\nLet X be the sum of the values of the gems obtained, and Y be the sum of the costs paid.\n\nFind the maximum possible value of X-Y.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq C_i, V_i \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nV_1 V_2 ... V_N\nC_1 C_2 ... C_N\n\nOutput\n\nPrint the maximum possible value of X-Y.\n\nSample Input 1\n\n3\n10 2 5\n6 3 4\n\nSample Output 1\n\n5\n\nIf we choose the first and third gems, X = 10 + 5 = 15 and Y = 6 + 4 = 10.\nWe have X-Y = 5 here, which is the maximum possible value.\n\nSample Input 2\n\n4\n13 21 6 19\n11 30 6 15\n\nSample Output 2\n\n6\n\nSample Input 3\n\n1\n1\n50\n\nSample Output 3\n\n0", "sample_input": "3\n10 2 5\n6 3 4\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03060", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N gems. The value of the i-th gem is V_i.\n\nYou will choose some of these gems, possibly all or none, and get them.\n\nHowever, you need to pay a cost of C_i to get the i-th gem.\n\nLet X be the sum of the values of the gems obtained, and Y be the sum of the costs paid.\n\nFind the maximum possible value of X-Y.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq C_i, V_i \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nV_1 V_2 ... V_N\nC_1 C_2 ... C_N\n\nOutput\n\nPrint the maximum possible value of X-Y.\n\nSample Input 1\n\n3\n10 2 5\n6 3 4\n\nSample Output 1\n\n5\n\nIf we choose the first and third gems, X = 10 + 5 = 15 and Y = 6 + 4 = 10.\nWe have X-Y = 5 here, which is the maximum possible value.\n\nSample Input 2\n\n4\n13 21 6 19\n11 30 6 15\n\nSample Output 2\n\n6\n\nSample Input 3\n\n1\n1\n50\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1038, "cpu_time_ms": 502, "memory_kb": 54940}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s157370569", "group_id": "codeNet:p03060", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val jewelry_nums = io.StdIn.readInt\n val jewelry_values = io.StdIn.readLine.split(\" \").map{_.toInt}\n var jewelry_costs = io.StdIn.readLine.split(\" \").map{_.toInt}\n var max_profits = 0\n\n (0 until jewelry_nums).foreach { i =>\n val profit = jewelry_values(i) - jewelry_costs(i)\n if(profit > 0) {\n max_profits += profit\n }\n }\n println(max_profits)\n\n }\n}", "language": "Scala", "metadata": {"date": 1578376882, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03060.html", "problem_id": "p03060", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03060/input.txt", "sample_output_relpath": "derived/input_output/data/p03060/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03060/Scala/s157370569.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s157370569", "user_id": "u888177577"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val jewelry_nums = io.StdIn.readInt\n val jewelry_values = io.StdIn.readLine.split(\" \").map{_.toInt}\n var jewelry_costs = io.StdIn.readLine.split(\" \").map{_.toInt}\n var max_profits = 0\n\n (0 until jewelry_nums).foreach { i =>\n val profit = jewelry_values(i) - jewelry_costs(i)\n if(profit > 0) {\n max_profits += profit\n }\n }\n println(max_profits)\n\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N gems. The value of the i-th gem is V_i.\n\nYou will choose some of these gems, possibly all or none, and get them.\n\nHowever, you need to pay a cost of C_i to get the i-th gem.\n\nLet X be the sum of the values of the gems obtained, and Y be the sum of the costs paid.\n\nFind the maximum possible value of X-Y.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq C_i, V_i \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nV_1 V_2 ... V_N\nC_1 C_2 ... C_N\n\nOutput\n\nPrint the maximum possible value of X-Y.\n\nSample Input 1\n\n3\n10 2 5\n6 3 4\n\nSample Output 1\n\n5\n\nIf we choose the first and third gems, X = 10 + 5 = 15 and Y = 6 + 4 = 10.\nWe have X-Y = 5 here, which is the maximum possible value.\n\nSample Input 2\n\n4\n13 21 6 19\n11 30 6 15\n\nSample Output 2\n\n6\n\nSample Input 3\n\n1\n1\n50\n\nSample Output 3\n\n0", "sample_input": "3\n10 2 5\n6 3 4\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03060", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N gems. The value of the i-th gem is V_i.\n\nYou will choose some of these gems, possibly all or none, and get them.\n\nHowever, you need to pay a cost of C_i to get the i-th gem.\n\nLet X be the sum of the values of the gems obtained, and Y be the sum of the costs paid.\n\nFind the maximum possible value of X-Y.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq C_i, V_i \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nV_1 V_2 ... V_N\nC_1 C_2 ... C_N\n\nOutput\n\nPrint the maximum possible value of X-Y.\n\nSample Input 1\n\n3\n10 2 5\n6 3 4\n\nSample Output 1\n\n5\n\nIf we choose the first and third gems, X = 10 + 5 = 15 and Y = 6 + 4 = 10.\nWe have X-Y = 5 here, which is the maximum possible value.\n\nSample Input 2\n\n4\n13 21 6 19\n11 30 6 15\n\nSample Output 2\n\n6\n\nSample Input 3\n\n1\n1\n50\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 456, "cpu_time_ms": 341, "memory_kb": 25420}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s614761502", "group_id": "codeNet:p03062", "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 a = Array.fill(n)(s.nextLong)\n\t\tfor(i <- 0 to n - 2) {\n\t\t\tif(a(i) < 0) {\n\t\t\t\ta(i) *= -1\n\t\t\t\ta(i + 1) *= -1\n\t\t\t}\n\t\t}\n\n\t\tval sum=a.sum\n\n\t\tprintln(math.max(sum,sum-(a(0)+a(n-1))*2))\n\t}\n}\n", "language": "Scala", "metadata": {"date": 1557235330, "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/s614761502.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s614761502", "user_id": "u059234158"}, "prompt_components": {"gold_output": "19\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 a = Array.fill(n)(s.nextLong)\n\t\tfor(i <- 0 to n - 2) {\n\t\t\tif(a(i) < 0) {\n\t\t\t\ta(i) *= -1\n\t\t\t\ta(i + 1) *= -1\n\t\t\t}\n\t\t}\n\n\t\tval sum=a.sum\n\n\t\tprintln(math.max(sum,sum-(a(0)+a(n-1))*2))\n\t}\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.\n\nYou can perform the following operation on this integer sequence any number of times:\n\nOperation: Choose an integer i satisfying 1 \\leq i \\leq N-1. Multiply both A_i and A_{i+1} by -1.\n\nLet B_1, B_2, ..., B_N be the integer sequence after your operations.\n\nFind the maximum possible value of B_1 + B_2 + ... + B_N.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible value of B_1 + B_2 + ... + B_N.\n\nSample Input 1\n\n3\n-10 5 -4\n\nSample Output 1\n\n19\n\nIf we perform the operation as follows:\n\nChoose 1 as i, which changes the sequence to 10, -5, -4.\n\nChoose 2 as i, which changes the sequence to 10, 5, 4.\n\nwe have B_1 = 10, B_2 = 5, B_3 = 4. The sum here, B_1 + B_2 + B_3 = 10 + 5 + 4 = 19, is the maximum possible result.\n\nSample Input 2\n\n5\n10 -4 -8 -11 3\n\nSample Output 2\n\n30\n\nSample Input 3\n\n11\n-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000\n\nSample Output 3\n\n10000000000\n\nThe output may not fit into a 32-bit integer type.", "sample_input": "3\n-10 5 -4\n"}, "reference_outputs": ["19\n"], "source_document_id": "p03062", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.\n\nYou can perform the following operation on this integer sequence any number of times:\n\nOperation: Choose an integer i satisfying 1 \\leq i \\leq N-1. Multiply both A_i and A_{i+1} by -1.\n\nLet B_1, B_2, ..., B_N be the integer sequence after your operations.\n\nFind the maximum possible value of B_1 + B_2 + ... + B_N.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible value of B_1 + B_2 + ... + B_N.\n\nSample Input 1\n\n3\n-10 5 -4\n\nSample Output 1\n\n19\n\nIf we perform the operation as follows:\n\nChoose 1 as i, which changes the sequence to 10, -5, -4.\n\nChoose 2 as i, which changes the sequence to 10, 5, 4.\n\nwe have B_1 = 10, B_2 = 5, B_3 = 4. The sum here, B_1 + B_2 + B_3 = 10 + 5 + 4 = 19, is the maximum possible result.\n\nSample Input 2\n\n5\n10 -4 -8 -11 3\n\nSample Output 2\n\n30\n\nSample Input 3\n\n11\n-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000\n\nSample Output 3\n\n10000000000\n\nThe output may not fit into a 32-bit integer type.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 297, "cpu_time_ms": 730, "memory_kb": 60216}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s331440252", "group_id": "codeNet:p03062", "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 import java.util.Arrays.sort\n\n import scala.collection.mutable\n import math.{abs, max, min}\n import mutable.ArrayBuffer\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 = nal(N)\n val dp = Array.fill[Long](N + 1, 2)(-1e18.toLong)\n dp(0)(0) = 0\n REP(N) { i =>\n REP(2) { j =>\n REP(2) { k =>\n val sig = if (((j + k) & 1) == 0) 1 else -1\n debug(s\"i:$i j:$j k:$k sig:$sig\")\n dp(i + 1)(j) = max(dp(i + 1)(j), dp(i)(k) + sig * A(i))\n }\n }\n }\n\n debugDim(dp)\n\n val ans = dp(N)(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 debugDim(m: Array[Array[Long]]): Unit = DEBUG {\n REP(m.length) { i =>\n debug(m(i))\n }\n }\n\n def debugDimFlip(m: Array[Array[Long]]): Unit = DEBUG {\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\n def debug(s: => String): Unit = DEBUG {\n System.err.println(s)\n }\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 = 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 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}", "language": "Scala", "metadata": {"date": 1556414583, "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/s331440252.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s331440252", "user_id": "u460609472"}, "prompt_components": {"gold_output": "19\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 import java.util.Arrays.sort\n\n import scala.collection.mutable\n import math.{abs, max, min}\n import mutable.ArrayBuffer\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 = nal(N)\n val dp = Array.fill[Long](N + 1, 2)(-1e18.toLong)\n dp(0)(0) = 0\n REP(N) { i =>\n REP(2) { j =>\n REP(2) { k =>\n val sig = if (((j + k) & 1) == 0) 1 else -1\n debug(s\"i:$i j:$j k:$k sig:$sig\")\n dp(i + 1)(j) = max(dp(i + 1)(j), dp(i)(k) + sig * A(i))\n }\n }\n }\n\n debugDim(dp)\n\n val ans = dp(N)(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 debugDim(m: Array[Array[Long]]): Unit = DEBUG {\n REP(m.length) { i =>\n debug(m(i))\n }\n }\n\n def debugDimFlip(m: Array[Array[Long]]): Unit = DEBUG {\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\n def debug(s: => String): Unit = DEBUG {\n System.err.println(s)\n }\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 = 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 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}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.\n\nYou can perform the following operation on this integer sequence any number of times:\n\nOperation: Choose an integer i satisfying 1 \\leq i \\leq N-1. Multiply both A_i and A_{i+1} by -1.\n\nLet B_1, B_2, ..., B_N be the integer sequence after your operations.\n\nFind the maximum possible value of B_1 + B_2 + ... + B_N.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible value of B_1 + B_2 + ... + B_N.\n\nSample Input 1\n\n3\n-10 5 -4\n\nSample Output 1\n\n19\n\nIf we perform the operation as follows:\n\nChoose 1 as i, which changes the sequence to 10, -5, -4.\n\nChoose 2 as i, which changes the sequence to 10, 5, 4.\n\nwe have B_1 = 10, B_2 = 5, B_3 = 4. The sum here, B_1 + B_2 + B_3 = 10 + 5 + 4 = 19, is the maximum possible result.\n\nSample Input 2\n\n5\n10 -4 -8 -11 3\n\nSample Output 2\n\n30\n\nSample Input 3\n\n11\n-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000\n\nSample Output 3\n\n10000000000\n\nThe output may not fit into a 32-bit integer type.", "sample_input": "3\n-10 5 -4\n"}, "reference_outputs": ["19\n"], "source_document_id": "p03062", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.\n\nYou can perform the following operation on this integer sequence any number of times:\n\nOperation: Choose an integer i satisfying 1 \\leq i \\leq N-1. Multiply both A_i and A_{i+1} by -1.\n\nLet B_1, B_2, ..., B_N be the integer sequence after your operations.\n\nFind the maximum possible value of B_1 + B_2 + ... + B_N.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible value of B_1 + B_2 + ... + B_N.\n\nSample Input 1\n\n3\n-10 5 -4\n\nSample Output 1\n\n19\n\nIf we perform the operation as follows:\n\nChoose 1 as i, which changes the sequence to 10, -5, -4.\n\nChoose 2 as i, which changes the sequence to 10, 5, 4.\n\nwe have B_1 = 10, B_2 = 5, B_3 = 4. The sum here, B_1 + B_2 + B_3 = 10 + 5 + 4 = 19, is the maximum possible result.\n\nSample Input 2\n\n5\n10 -4 -8 -11 3\n\nSample Output 2\n\n30\n\nSample Input 3\n\n11\n-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000\n\nSample Output 3\n\n10000000000\n\nThe output may not fit into a 32-bit integer type.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3800, "cpu_time_ms": 638, "memory_kb": 56804}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s523656991", "group_id": "codeNet:p03063", "input_text": "import scala.io.StdIn._\n\nobject Main extends App {\n def foo(n: Int, s: String): Unit = {\n if (s.count(_ == '#') == 0) {\n println(0)\n }\n else {\n val ns = s.substring(s.indexOf('#'), s.length)\n println(\n math.min(ns.count(_ == '.'),\n ns.count(_ == '#')))\n }\n }\n foo(readInt(), readLine.toString)\n}", "language": "Scala", "metadata": {"date": 1559964950, "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/s523656991.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s523656991", "user_id": "u689562091"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main extends App {\n def foo(n: Int, s: String): Unit = {\n if (s.count(_ == '#') == 0) {\n println(0)\n }\n else {\n val ns = s.substring(s.indexOf('#'), s.length)\n println(\n math.min(ns.count(_ == '.'),\n ns.count(_ == '#')))\n }\n }\n foo(readInt(), readLine.toString)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 430, "memory_kb": 29580}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s043883016", "group_id": "codeNet:p03063", "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 import java.util.Arrays.sort\n\n import scala.collection.mutable\n import math.{abs, max, min}\n import mutable.ArrayBuffer\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 S = ns(N)\n var cnt = 0\n\n REP_r(N) { i =>\n if (i > 0) {\n if (S(i - 1) == '#' && S(i) == '.') {\n S(i) = '#'\n cnt += 1\n }\n }\n }\n\n out.println(cnt)\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 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 = 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[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}", "language": "Scala", "metadata": {"date": 1555808663, "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/s043883016.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s043883016", "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 import java.util.Arrays.sort\n\n import scala.collection.mutable\n import math.{abs, max, min}\n import mutable.ArrayBuffer\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 S = ns(N)\n var cnt = 0\n\n REP_r(N) { i =>\n if (i > 0) {\n if (S(i - 1) == '#' && S(i) == '.') {\n S(i) = '#'\n cnt += 1\n }\n }\n }\n\n out.println(cnt)\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 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 = 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[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}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3263, "cpu_time_ms": 381, "memory_kb": 29332}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s278915486", "group_id": "codeNet:p03069", "input_text": "import java.io.{BufferedOutputStream, BufferedReader, FileOutputStream, InputStreamReader, PrintWriter}\nimport java.lang\n\nimport scala.annotation.tailrec\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 log(\"=== start\")\n\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 s = get[String]\n\n def count: ArrayBuffer[Int] = {\n val counts = ArrayBuffer.empty[Int]\n var current = 'x'\n var count = 0\n\n for (c <- s) {\n if (current == c) {\n count += 1\n } else {\n if (count != 0) {\n counts += count\n }\n current = c\n count = 1\n }\n }\n\n if (count > 0) {\n counts += count\n }\n\n counts\n }\n\n val allCounts =\n s.head match {\n case '.' =>\n s.last match {\n case '.' => count.tail\n case '#' => count.tail.init\n }\n case '#' =>\n s.last match {\n case '.' => count\n case '#' => count.init\n }\n }\n\n val counts = Array.ofDim[Int](2)\n for (i <- allCounts.indices) {\n counts(i % 2) += allCounts(i)\n }\n\n out.println(counts.min)\n\n out.flush()\n log(\"=== end\")\n debug {\n debugOut.flush()\n }\n }\n}", "language": "Scala", "metadata": {"date": 1598406507, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/s278915486.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s278915486", "user_id": "u178269371"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.io.{BufferedOutputStream, BufferedReader, FileOutputStream, InputStreamReader, PrintWriter}\nimport java.lang\n\nimport scala.annotation.tailrec\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 log(\"=== start\")\n\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 s = get[String]\n\n def count: ArrayBuffer[Int] = {\n val counts = ArrayBuffer.empty[Int]\n var current = 'x'\n var count = 0\n\n for (c <- s) {\n if (current == c) {\n count += 1\n } else {\n if (count != 0) {\n counts += count\n }\n current = c\n count = 1\n }\n }\n\n if (count > 0) {\n counts += count\n }\n\n counts\n }\n\n val allCounts =\n s.head match {\n case '.' =>\n s.last match {\n case '.' => count.tail\n case '#' => count.tail.init\n }\n case '#' =>\n s.last match {\n case '.' => count\n case '#' => count.init\n }\n }\n\n val counts = Array.ofDim[Int](2)\n for (i <- allCounts.indices) {\n counts(i % 2) += allCounts(i)\n }\n\n out.println(counts.min)\n\n out.flush()\n log(\"=== end\")\n debug {\n debugOut.flush()\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5206, "cpu_time_ms": 583, "memory_kb": 59908}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s128138516", "group_id": "codeNet:p03069", "input_text": "import scala.io._\nobject Main extends App {\n val n = StdIn.readLine.toInt\n val s = StdIn.readLine\n\n def checkMin(i: Int, changes: Int): Int = {\n if (i == n) changes\n else {\n checkMin(i + 1, changes + (if (s.charAt(i) == '#') 1 else -1))\n }\n }\n println(checkMin(0, s.count(_ == '.')))\n}", "language": "Scala", "metadata": {"date": 1555811751, "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/s128138516.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s128138516", "user_id": "u132324749"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import scala.io._\nobject Main extends App {\n val n = StdIn.readLine.toInt\n val s = StdIn.readLine\n\n def checkMin(i: Int, changes: Int): Int = {\n if (i == n) changes\n else {\n checkMin(i + 1, changes + (if (s.charAt(i) == '#') 1 else -1))\n }\n }\n println(checkMin(0, s.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": "p03069", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N stones arranged in a row. Every stone is painted white or black.\nA string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is ., and the stone is black if the character is #.\n\nTakahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone.\nFind the minimum number of stones that needs to be recolored.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS is a string of length N consisting of . and #.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the minimum number of stones that needs to be recolored.\n\nSample Input 1\n\n3\n#.#\n\nSample Output 1\n\n1\n\nIt is enough to change the color of the first stone to white.\n\nSample Input 2\n\n5\n#.##.\n\nSample Output 2\n\n2\n\nSample Input 3\n\n9\n.........\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 304, "cpu_time_ms": 401, "memory_kb": 31476}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s074596313", "group_id": "codeNet:p03071", "input_text": "import scala.math._\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val lines = io.Source.stdin.getLines().toSeq\n println(solve(lines))\n }\n\n def solve(lines: Seq[String]): String = {\n val Array(a, b) = lines.head.split(\" \").map(_.toInt)\n var result = 0\n if (a == b) {\n result = a + b\n } else {\n result = max(a, b) + (max(a, b) - 1)\n }\n result.toString\n }\n}\n", "language": "Scala", "metadata": {"date": 1556373259, "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/s074596313.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s074596313", "user_id": "u088326922"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import scala.math._\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val lines = io.Source.stdin.getLines().toSeq\n println(solve(lines))\n }\n\n def solve(lines: Seq[String]): String = {\n val Array(a, b) = lines.head.split(\" \").map(_.toInt)\n var result = 0\n if (a == b) {\n result = a + b\n } else {\n result = max(a, b) + (max(a, b) - 1)\n }\n result.toString\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are two buttons, one of size A and one of size B.\n\nWhen you press a button of size X, you get X coins and the size of that button decreases by 1.\n\nYou will press a button twice. Here, you can press the same button twice, or press both buttons once.\n\nAt most how many coins can you get?\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq A, B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the maximum number of coins you can get.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n9\n\nYou can get 5 + 4 = 9 coins by pressing the button of size 5 twice, and this is the maximum result.\n\nSample Input 2\n\n3 4\n\nSample Output 2\n\n7\n\nSample Input 3\n\n6 6\n\nSample Output 3\n\n12", "sample_input": "5 3\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03071", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are two buttons, one of size A and one of size B.\n\nWhen you press a button of size X, you get X coins and the size of that button decreases by 1.\n\nYou will press a button twice. Here, you can press the same button twice, or press both buttons once.\n\nAt most how many coins can you get?\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq A, B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the maximum number of coins you can get.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n9\n\nYou can get 5 + 4 = 9 coins by pressing the button of size 5 twice, and this is the maximum result.\n\nSample Input 2\n\n3 4\n\nSample Output 2\n\n7\n\nSample Input 3\n\n6 6\n\nSample Output 3\n\n12", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 404, "cpu_time_ms": 331, "memory_kb": 27212}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s497522569", "group_id": "codeNet:p03071", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n val input = StdIn.readLine().split(\" \").map(_.toInt)\n var a = input(0)\n var b = input(1)\n var ret = 0\n ret = exec\n ret += exec\n println(ret)\n\n def exec() = {\n var ret = 0\n if (a > b) {\n ret = a\n a -= 1\n } else {\n ret = b\n b -= 1\n }\n ret\n }\n}", "language": "Scala", "metadata": {"date": 1555183193, "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/s497522569.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s497522569", "user_id": "u517283742"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n val input = StdIn.readLine().split(\" \").map(_.toInt)\n var a = input(0)\n var b = input(1)\n var ret = 0\n ret = exec\n ret += exec\n println(ret)\n\n def exec() = {\n var ret = 0\n if (a > b) {\n ret = a\n a -= 1\n } else {\n ret = b\n b -= 1\n }\n ret\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are two buttons, one of size A and one of size B.\n\nWhen you press a button of size X, you get X coins and the size of that button decreases by 1.\n\nYou will press a button twice. Here, you can press the same button twice, or press both buttons once.\n\nAt most how many coins can you get?\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq A, B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the maximum number of coins you can get.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n9\n\nYou can get 5 + 4 = 9 coins by pressing the button of size 5 twice, and this is the maximum result.\n\nSample Input 2\n\n3 4\n\nSample Output 2\n\n7\n\nSample Input 3\n\n6 6\n\nSample Output 3\n\n12", "sample_input": "5 3\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03071", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are two buttons, one of size A and one of size B.\n\nWhen you press a button of size X, you get X coins and the size of that button decreases by 1.\n\nYou will press a button twice. Here, you can press the same button twice, or press both buttons once.\n\nAt most how many coins can you get?\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq A, B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the maximum number of coins you can get.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n9\n\nYou can get 5 + 4 = 9 coins by pressing the button of size 5 twice, and this is the maximum result.\n\nSample Input 2\n\n3 4\n\nSample Output 2\n\n7\n\nSample Input 3\n\n6 6\n\nSample Output 3\n\n12", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 335, "cpu_time_ms": 320, "memory_kb": 25552}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s788525706", "group_id": "codeNet:p03071", "input_text": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]) = {\n val sc = new Scanner(System.in)\n val A, B = sc.nextInt()\n val c = A.max(B) + A.max(B) - 1\n \n def foo(a: Int, b: Int, sum: Int = 0, deps: Int = 1): Int = {\n if (deps == 0) sum else {\n if (a < b) {\n foo(a, b - 1, b, deps - 1)\n } else {\n foo(a - 1, b, a, deps - 1)\n }\n }\n }\n \n foo(A, B)\n println(c)\n }\n}\n", "language": "Scala", "metadata": {"date": 1555182805, "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/s788525706.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s788525706", "user_id": "u775137545"}, "prompt_components": {"gold_output": "9\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 A, B = sc.nextInt()\n val c = A.max(B) + A.max(B) - 1\n \n def foo(a: Int, b: Int, sum: Int = 0, deps: Int = 1): Int = {\n if (deps == 0) sum else {\n if (a < b) {\n foo(a, b - 1, b, deps - 1)\n } else {\n foo(a - 1, b, a, deps - 1)\n }\n }\n }\n \n foo(A, B)\n println(c)\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are two buttons, one of size A and one of size B.\n\nWhen you press a button of size X, you get X coins and the size of that button decreases by 1.\n\nYou will press a button twice. Here, you can press the same button twice, or press both buttons once.\n\nAt most how many coins can you get?\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq A, B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the maximum number of coins you can get.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n9\n\nYou can get 5 + 4 = 9 coins by pressing the button of size 5 twice, and this is the maximum result.\n\nSample Input 2\n\n3 4\n\nSample Output 2\n\n7\n\nSample Input 3\n\n6 6\n\nSample Output 3\n\n12", "sample_input": "5 3\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03071", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are two buttons, one of size A and one of size B.\n\nWhen you press a button of size X, you get X coins and the size of that button decreases by 1.\n\nYou will press a button twice. Here, you can press the same button twice, or press both buttons once.\n\nAt most how many coins can you get?\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq A, B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the maximum number of coins you can get.\n\nSample Input 1\n\n5 3\n\nSample Output 1\n\n9\n\nYou can get 5 + 4 = 9 coins by pressing the button of size 5 twice, and this is the maximum result.\n\nSample Input 2\n\n3 4\n\nSample Output 2\n\n7\n\nSample Input 3\n\n6 6\n\nSample Output 3\n\n12", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 455, "cpu_time_ms": 353, "memory_kb": 25764}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s035064559", "group_id": "codeNet:p03072", "input_text": "object Main extends App {\n val in = scala.io.Source.stdin.getLines.toSeq\n val H = in.map(_.split(' ').map(_.toInt)).tail.head\n\n var ret = 0\n H.foldLeft(0){ (a,e) =>\n if(a<=e) ret+=1\n Math.max(a,e)\n }\n println(ret)\n}\n", "language": "Scala", "metadata": {"date": 1555182942, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03072.html", "problem_id": "p03072", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03072/input.txt", "sample_output_relpath": "derived/input_output/data/p03072/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03072/Scala/s035064559.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s035064559", "user_id": "u699236457"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main extends App {\n val in = scala.io.Source.stdin.getLines.toSeq\n val H = in.map(_.split(' ').map(_.toInt)).tail.head\n\n var ret = 0\n H.foldLeft(0){ (a,e) =>\n if(a<=e) ret+=1\n Math.max(a,e)\n }\n println(ret)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N mountains ranging from east to west, and an ocean to the west.\n\nAt the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.\n\nThe height of the i-th mountain from the west is H_i.\n\nYou can certainly see the ocean from the inn at the top of the westmost mountain.\n\nFor the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N), you can see the ocean if and only if H_1 \\leq H_i, H_2 \\leq H_i, ..., and H_{i-1} \\leq H_i.\n\nFrom how many of these N inns can you see the ocean?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq H_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the number of inns from which you can see the ocean.\n\nSample Input 1\n\n4\n6 5 6 8\n\nSample Output 1\n\n3\n\nYou can see the ocean from the first, third and fourth inns from the west.\n\nSample Input 2\n\n5\n4 5 3 5 4\n\nSample Output 2\n\n3\n\nSample Input 3\n\n5\n9 5 6 8 4\n\nSample Output 3\n\n1", "sample_input": "4\n6 5 6 8\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03072", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N mountains ranging from east to west, and an ocean to the west.\n\nAt the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.\n\nThe height of the i-th mountain from the west is H_i.\n\nYou can certainly see the ocean from the inn at the top of the westmost mountain.\n\nFor the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N), you can see the ocean if and only if H_1 \\leq H_i, H_2 \\leq H_i, ..., and H_{i-1} \\leq H_i.\n\nFrom how many of these N inns can you see the ocean?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq H_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the number of inns from which you can see the ocean.\n\nSample Input 1\n\n4\n6 5 6 8\n\nSample Output 1\n\n3\n\nYou can see the ocean from the first, third and fourth inns from the west.\n\nSample Input 2\n\n5\n4 5 3 5 4\n\nSample Output 2\n\n3\n\nSample Input 3\n\n5\n9 5 6 8 4\n\nSample Output 3\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 228, "cpu_time_ms": 329, "memory_kb": 25536}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s469065853", "group_id": "codeNet:p03074", "input_text": "object Main extends App {\n\n val line1 = io.StdIn.readLine.split(' ').map(_.toInt)\n val s = io.StdIn.readLine\n\n val N = line1(0)\n val K = line1(1)\n\n var previous = '-'\n\n var seq = Seq.empty[Int]\n var accum = 0\n\n for (i <- 0 until s.size) {\n s(i) match {\n case ss if ss == previous => accum += 1\n case ss if ss != previous && accum > 0=> {\n seq = accum +: seq\n accum = 1\n }\n case _ => accum += 1\n }\n previous = s(i)\n }\n\n if (accum > 0)\n seq = accum +: seq\n\n val num = if (s.head == '0') 2*K else 2*K+1\n val ans = seq.sliding(num).map(_.sum).max\n\n println(ans)\n\n}", "language": "Scala", "metadata": {"date": 1555190055, "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/s469065853.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s469065853", "user_id": "u620456020"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "object Main extends App {\n\n val line1 = io.StdIn.readLine.split(' ').map(_.toInt)\n val s = io.StdIn.readLine\n\n val N = line1(0)\n val K = line1(1)\n\n var previous = '-'\n\n var seq = Seq.empty[Int]\n var accum = 0\n\n for (i <- 0 until s.size) {\n s(i) match {\n case ss if ss == previous => accum += 1\n case ss if ss != previous && accum > 0=> {\n seq = accum +: seq\n accum = 1\n }\n case _ => accum += 1\n }\n previous = s(i)\n }\n\n if (accum > 0)\n seq = accum +: seq\n\n val num = if (s.head == '0') 2*K else 2*K+1\n val ans = seq.sliding(num).map(_.sum).max\n\n println(ans)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 619, "cpu_time_ms": 2111, "memory_kb": 125984}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s601554972", "group_id": "codeNet:p03074", "input_text": "\nimport java.util.Scanner\n\nimport scala.collection.mutable.ArrayBuffer\n\n\nobject Main {\n def read(): (Int, Int, String) = {\n val sc = new Scanner(System.in)\n val n, k = sc.nextInt()\n val s = sc.next()\n (n, k, s)\n }\n\n def compressRunlength(s: String): IndexedSeq[(Int, Char)] = {\n\n var currentChar = s(0)\n var currentCount = 1\n var buf = ArrayBuffer.empty[(Int, Char)]\n for (i <- 1 until s.length) {\n if (currentChar == s(i)) {\n currentCount += 1\n } else {\n buf.append((currentCount, currentChar))\n currentChar = s(i)\n currentCount = 1\n }\n }\n buf.append((currentCount, currentChar))\n buf.toIndexedSeq\n }\n\n def solve(n: Int, k: Int, s: String): Int = {\n // s.length == n\n val runLength = compressRunlength(s)\n val cumSum = runLength.map(_._1).scanLeft(0)(_ + _)\n\n // (i, ..., j-1)の和: cumSum(j)-cumSum(i)\n def sum(min: Int, max: Int): Int = cumSum(max + 1) - cumSum(min)\n\n def cut(i: Int) = Math.min(i, runLength.length - 1)\n\n // i番目が0: i, i+1,...,i+2k-1\n // i番目が1: i, i+1,...,i+2k\n runLength.indices\n .map(i =>\n if (runLength(i)._2 == '0') (i, cut(i + 2 * k - 1)) else (i, cut(i + 2 * k)))\n .map { case (min, max) =>\n sum(min, max)\n }.max\n }\n\n\n def main(args: Array[String]): Unit = {\n val (n, k, s) = read()\n println(solve(n, k, s))\n }\n}", "language": "Scala", "metadata": {"date": 1555185195, "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/s601554972.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s601554972", "user_id": "u494788559"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "\nimport java.util.Scanner\n\nimport scala.collection.mutable.ArrayBuffer\n\n\nobject Main {\n def read(): (Int, Int, String) = {\n val sc = new Scanner(System.in)\n val n, k = sc.nextInt()\n val s = sc.next()\n (n, k, s)\n }\n\n def compressRunlength(s: String): IndexedSeq[(Int, Char)] = {\n\n var currentChar = s(0)\n var currentCount = 1\n var buf = ArrayBuffer.empty[(Int, Char)]\n for (i <- 1 until s.length) {\n if (currentChar == s(i)) {\n currentCount += 1\n } else {\n buf.append((currentCount, currentChar))\n currentChar = s(i)\n currentCount = 1\n }\n }\n buf.append((currentCount, currentChar))\n buf.toIndexedSeq\n }\n\n def solve(n: Int, k: Int, s: String): Int = {\n // s.length == n\n val runLength = compressRunlength(s)\n val cumSum = runLength.map(_._1).scanLeft(0)(_ + _)\n\n // (i, ..., j-1)の和: cumSum(j)-cumSum(i)\n def sum(min: Int, max: Int): Int = cumSum(max + 1) - cumSum(min)\n\n def cut(i: Int) = Math.min(i, runLength.length - 1)\n\n // i番目が0: i, i+1,...,i+2k-1\n // i番目が1: i, i+1,...,i+2k\n runLength.indices\n .map(i =>\n if (runLength(i)._2 == '0') (i, cut(i + 2 * k - 1)) else (i, cut(i + 2 * k)))\n .map { case (min, max) =>\n sum(min, max)\n }.max\n }\n\n\n def main(args: Array[String]): Unit = {\n val (n, k, s) = read()\n println(solve(n, k, s))\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1397, "cpu_time_ms": 792, "memory_kb": 46748}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s990873063", "group_id": "codeNet:p03075", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val a = io.StdIn.readInt()\n val b = io.StdIn.readInt()\n val c = io.StdIn.readInt()\n val d = io.StdIn.readInt()\n val e = io.StdIn.readInt()\n val k = io.StdIn.readInt()\n\n if(e - a <= k) println(\"Yay!\")\n else println(\":(\")\n }\n}", "language": "Scala", "metadata": {"date": 1577148043, "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/s990873063.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s990873063", "user_id": "u888177577"}, "prompt_components": {"gold_output": "Yay!\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val a = io.StdIn.readInt()\n val b = io.StdIn.readInt()\n val c = io.StdIn.readInt()\n val d = io.StdIn.readInt()\n val e = io.StdIn.readInt()\n val k = io.StdIn.readInt()\n\n if(e - a <= k) println(\"Yay!\")\n else println(\":(\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 320, "memory_kb": 27212}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s309206771", "group_id": "codeNet:p03075", "input_text": "object Main extends App {\n\tval a = new Array[Int](5)\n\n\tfor(i<-0 until 5){\n\t\ta(i) = scala.io.StdIn.readInt\n\t}\n\n\tval k = scala.io.StdIn.readInt\n\n\tvar flag = true\n\n\tfor(i<-0 to 3){\n\t\tfor(j<-i to 4){\n\t\t\tif((a(j) - a(i)).abs > k) flag = false\n\t\t}\n\t}\n\n\tif(flag) println(\"Yay!\")\n\telse println(\":(\")\n\n}", "language": "Scala", "metadata": {"date": 1554579160, "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/s309206771.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s309206771", "user_id": "u675876401"}, "prompt_components": {"gold_output": "Yay!\n", "input_to_evaluate": "object Main extends App {\n\tval a = new Array[Int](5)\n\n\tfor(i<-0 until 5){\n\t\ta(i) = scala.io.StdIn.readInt\n\t}\n\n\tval k = scala.io.StdIn.readInt\n\n\tvar flag = true\n\n\tfor(i<-0 to 3){\n\t\tfor(j<-i to 4){\n\t\t\tif((a(j) - a(i)).abs > k) flag = false\n\t\t}\n\t}\n\n\tif(flag) println(\"Yay!\")\n\telse println(\":(\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 294, "cpu_time_ms": 330, "memory_kb": 25516}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s207898000", "group_id": "codeNet:p03075", "input_text": "import scala.io.StdIn._\nobject Main extends App {\n\n\n val antennas = Array.tabulate(5){_ ⇒ readInt()}\n val k = readInt()\n println(\n if (antennas.max - antennas.min <= k) \"Yay!\" else \":(\"\n )\n\n}", "language": "Scala", "metadata": {"date": 1554577350, "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/s207898000.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s207898000", "user_id": "u419330815"}, "prompt_components": {"gold_output": "Yay!\n", "input_to_evaluate": "import scala.io.StdIn._\nobject Main extends App {\n\n\n val antennas = Array.tabulate(5){_ ⇒ readInt()}\n val k = readInt()\n println(\n if (antennas.max - antennas.min <= k) \"Yay!\" else \":(\"\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 362, "memory_kb": 27052}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s547861094", "group_id": "codeNet:p03076", "input_text": "object Main{\n\tdef main(args:Array[String]){\n\t\tval s = new java.util.Scanner(System.in)\n\n\t\tval a=Array.fill(5)(s.nextInt).sortBy(i=>(i+9)%10)\n\n\t\tfor(i<-1 to 4)\n\t\t\ta(i)=(a(i) + 9) / 10 * 10\n\n\t\tprintln(a.sum)\n\t}\n}", "language": "Scala", "metadata": {"date": 1556993105, "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/s547861094.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s547861094", "user_id": "u059234158"}, "prompt_components": {"gold_output": "215\n", "input_to_evaluate": "object Main{\n\tdef main(args:Array[String]){\n\t\tval s = new java.util.Scanner(System.in)\n\n\t\tval a=Array.fill(5)(s.nextInt).sortBy(i=>(i+9)%10)\n\n\t\tfor(i<-1 to 4)\n\t\t\ta(i)=(a(i) + 9) / 10 * 10\n\n\t\tprintln(a.sum)\n\t}\n}", "problem_context": "Score: 200 points\n\nProblem Statement\n\nThe restaurant AtCoder serves the following five dishes:\n\nABC Don (rice bowl): takes A minutes to serve.\n\nARC Curry: takes B minutes to serve.\n\nAGC Pasta: takes C minutes to serve.\n\nAPC Ramen: takes D minutes to serve.\n\nATC Hanbagu (hamburger patty): takes E minutes to serve.\n\nHere, the time to serve a dish is the time between when an order is placed and when the dish is delivered.\n\nThis restaurant has the following rules on orders:\n\nAn order can only be placed at a time that is a multiple of 10 (time 0, 10, 20, ...).\n\nOnly one dish can be ordered at a time.\n\nNo new order can be placed when an order is already placed and the dish is still not delivered, but a new order can be placed at the exact time when the dish is delivered.\n\nE869120 arrives at this restaurant at time 0. He will order all five dishes. Find the earliest possible time for the last dish to be delivered.\n\nHere, he can order the dishes in any order he likes, and he can place an order already at time 0.\n\nConstraints\n\nA, B, C, D and E are integers between 1 and 123 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the earliest possible time for the last dish to be delivered, as an integer.\n\nSample Input 1\n\n29\n20\n7\n35\n120\n\nSample Output 1\n\n215\n\nIf we decide to order the dishes in the order ABC Don, ARC Curry, AGC Pasta, ATC Hanbagu, APC Ramen, the earliest possible time for each order is as follows:\n\nOrder ABC Don at time 0, which will be delivered at time 29.\n\nOrder ARC Curry at time 30, which will be delivered at time 50.\n\nOrder AGC Pasta at time 50, which will be delivered at time 57.\n\nOrder ATC Hanbagu at time 60, which will be delivered at time 180.\n\nOrder APC Ramen at time 180, which will be delivered at time 215.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 2\n\n101\n86\n119\n108\n57\n\nSample Output 2\n\n481\n\nIf we decide to order the dishes in the order AGC Pasta, ARC Curry, ATC Hanbagu, APC Ramen, ABC Don, the earliest possible time for each order is as follows:\n\nOrder AGC Pasta at time 0, which will be delivered at time 119.\n\nOrder ARC Curry at time 120, which will be delivered at time 206.\n\nOrder ATC Hanbagu at time 210, which will be delivered at time 267.\n\nOrder APC Ramen at time 270, which will be delivered at time 378.\n\nOrder ABC Don at time 380, which will be delivered at time 481.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 3\n\n123\n123\n123\n123\n123\n\nSample Output 3\n\n643\n\nThis is the largest valid case.", "sample_input": "29\n20\n7\n35\n120\n"}, "reference_outputs": ["215\n"], "source_document_id": "p03076", "source_text": "Score: 200 points\n\nProblem Statement\n\nThe restaurant AtCoder serves the following five dishes:\n\nABC Don (rice bowl): takes A minutes to serve.\n\nARC Curry: takes B minutes to serve.\n\nAGC Pasta: takes C minutes to serve.\n\nAPC Ramen: takes D minutes to serve.\n\nATC Hanbagu (hamburger patty): takes E minutes to serve.\n\nHere, the time to serve a dish is the time between when an order is placed and when the dish is delivered.\n\nThis restaurant has the following rules on orders:\n\nAn order can only be placed at a time that is a multiple of 10 (time 0, 10, 20, ...).\n\nOnly one dish can be ordered at a time.\n\nNo new order can be placed when an order is already placed and the dish is still not delivered, but a new order can be placed at the exact time when the dish is delivered.\n\nE869120 arrives at this restaurant at time 0. He will order all five dishes. Find the earliest possible time for the last dish to be delivered.\n\nHere, he can order the dishes in any order he likes, and he can place an order already at time 0.\n\nConstraints\n\nA, B, C, D and E are integers between 1 and 123 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the earliest possible time for the last dish to be delivered, as an integer.\n\nSample Input 1\n\n29\n20\n7\n35\n120\n\nSample Output 1\n\n215\n\nIf we decide to order the dishes in the order ABC Don, ARC Curry, AGC Pasta, ATC Hanbagu, APC Ramen, the earliest possible time for each order is as follows:\n\nOrder ABC Don at time 0, which will be delivered at time 29.\n\nOrder ARC Curry at time 30, which will be delivered at time 50.\n\nOrder AGC Pasta at time 50, which will be delivered at time 57.\n\nOrder ATC Hanbagu at time 60, which will be delivered at time 180.\n\nOrder APC Ramen at time 180, which will be delivered at time 215.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 2\n\n101\n86\n119\n108\n57\n\nSample Output 2\n\n481\n\nIf we decide to order the dishes in the order AGC Pasta, ARC Curry, ATC Hanbagu, APC Ramen, ABC Don, the earliest possible time for each order is as follows:\n\nOrder AGC Pasta at time 0, which will be delivered at time 119.\n\nOrder ARC Curry at time 120, which will be delivered at time 206.\n\nOrder ATC Hanbagu at time 210, which will be delivered at time 267.\n\nOrder APC Ramen at time 270, which will be delivered at time 378.\n\nOrder ABC Don at time 380, which will be delivered at time 481.\n\nThere is no way to order the dishes in which the last dish will be delivered earlier than this.\n\nSample Input 3\n\n123\n123\n123\n123\n123\n\nSample Output 3\n\n643\n\nThis is the largest valid case.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 210, "cpu_time_ms": 369, "memory_kb": 25560}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s044247302", "group_id": "codeNet:p03077", "input_text": "import scala.io.StdIn._\n\nobject Main extends App {\n\n val n = readLong()\n val A = Array.fill(5)(readLong())\n\n def solve() = {\n val bottleneck = A.min\n if(n <= bottleneck) 5L\n else 4 + (n + bottleneck - 1)/bottleneck\n }\n println(solve())\n\n}\n\n", "language": "Scala", "metadata": {"date": 1595540795, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/s044247302.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s044247302", "user_id": "u947008426"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main extends App {\n\n val n = readLong()\n val A = Array.fill(5)(readLong())\n\n def solve() = {\n val bottleneck = A.min\n if(n <= bottleneck) 5L\n else 4 + (n + bottleneck - 1)/bottleneck\n }\n println(solve())\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 254, "cpu_time_ms": 506, "memory_kb": 54968}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s317491829", "group_id": "codeNet:p03077", "input_text": "object Main extends App {\n val (us, limits) = {\n val s = new java.util.Scanner(System.in)\n (s.nextLong(), (1 to 5).map(_ => s.nextInt).toList)\n }\n\n // ボトルネックで切り上げ + 残りの移動回数\n val ans = (us + limits.min - 1) / 2 + 4\n\n println(ans.toLong)\n}\n", "language": "Scala", "metadata": {"date": 1556182030, "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/s317491829.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s317491829", "user_id": "u116092729"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "object Main extends App {\n val (us, limits) = {\n val s = new java.util.Scanner(System.in)\n (s.nextLong(), (1 to 5).map(_ => s.nextInt).toList)\n }\n\n // ボトルネックで切り上げ + 残りの移動回数\n val ans = (us + limits.min - 1) / 2 + 4\n\n println(ans.toLong)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 359, "memory_kb": 27200}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s908529375", "group_id": "codeNet:p03077", "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.nextLong()\n println((N - 1) / Array.fill(5)(sc.nextLong()).min + 5)\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 def recursive(now: Long, count: Long): Long = {\n if (count == 1000) now else {\n if (now % 2 == 1) recursive(now * 3 + 1, count + 1) else recursive(now / 2, count + 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 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": 1554664133, "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/s908529375.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s908529375", "user_id": "u779353743"}, "prompt_components": {"gold_output": "7\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.nextLong()\n println((N - 1) / Array.fill(5)(sc.nextLong()).min + 5)\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 def recursive(now: Long, count: Long): Long = {\n if (count == 1000) now else {\n if (now % 2 == 1) recursive(now * 3 + 1, count + 1) else recursive(now / 2, count + 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 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: 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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6399, "cpu_time_ms": 332, "memory_kb": 25528}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s571597223", "group_id": "codeNet:p03078", "input_text": "object Main extends App {\n var count = readLine.split(\" \")\n var k = count(3).toInt\n var a, b , c = readLine.split(\" \").map(_.toLong)\n var sum = for(v1 <- a;v2 <- b) yield {\n \t\t\t\tv1 + v2\n\t\t\t }\n sum = sum.take(k)\n sum = sum.sorted(Ordering[Long].reverse)\n var sum2 = for(v1 <- sum;v2 <- c) yield {\n \t\t\t\tv1 + v2\n\t\t\t }\n sum2 = sum2.take(k)\n sum2 = sum2.sorted(Ordering[Long].reverse)\n \n val out = new java.io.PrintWriter(System.out)\n for(i <- 0 to k - 1){\n out.println(sum2(i))\n }\n out.flush\n}", "language": "Scala", "metadata": {"date": 1555019046, "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/s571597223.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s571597223", "user_id": "u533688845"}, "prompt_components": {"gold_output": "19\n17\n15\n14\n13\n12\n10\n8\n", "input_to_evaluate": "object Main extends App {\n var count = readLine.split(\" \")\n var k = count(3).toInt\n var a, b , c = readLine.split(\" \").map(_.toLong)\n var sum = for(v1 <- a;v2 <- b) yield {\n \t\t\t\tv1 + v2\n\t\t\t }\n sum = sum.take(k)\n sum = sum.sorted(Ordering[Long].reverse)\n var sum2 = for(v1 <- sum;v2 <- c) yield {\n \t\t\t\tv1 + v2\n\t\t\t }\n sum2 = sum2.take(k)\n sum2 = sum2.sorted(Ordering[Long].reverse)\n \n val out = new java.io.PrintWriter(System.out)\n for(i <- 0 to k - 1){\n out.println(sum2(i))\n }\n out.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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 511, "cpu_time_ms": 749, "memory_kb": 163656}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s059332090", "group_id": "codeNet:p03078", "input_text": "import java.util.Scanner\n\n// [x1 + x2 | x1<- l1, x2<- l2]をソート (TLE)\nobject Main {\n def read(): (Int, Int, Int, Int, IndexedSeq[Long], IndexedSeq[Long], IndexedSeq[Long]) = {\n val sc = new Scanner(System.in)\n val n1, n2, n3, k = sc.nextInt()\n val l1 = for (_ <- 0 until n1) yield sc.nextLong()\n val l2 = for (_ <- 0 until n2) yield sc.nextLong()\n val l3 = for (_ <- 0 until n3) yield sc.nextLong()\n (n1, n2, n3, k, l1, l2, l3)\n }\n\n\n def solve(n1: Int, n2: Int, n3: Int, k: Int, l1: IndexedSeq[Long], l2: IndexedSeq[Long], l3: IndexedSeq[Long]): IndexedSeq[Long] = {\n val l1_plus_l2 = for (x1 <- l1; x2 <- l2) yield x1 + x2\n // O(n1*n2)\n // l1+l2の時点でtop kにないものはl3を足してもtop kにならない。\n val sorted_l1_plus_l2_top_k = l1_plus_l2.sorted.reverse.take(k)\n //O((n1*n2)log(n1*n2))\n // k個取れない場合もエラーは出ない。取れるだけ取る\n val sorted_l1_plus_l2_top_k_plus_l3 = for (x12 <- sorted_l1_plus_l2_top_k; x3 <- l3) yield x12 + x3\n // O(k*n3)\n val sorted_sorted_l1_plus_l2_top_k_plus_l3_topk = sorted_l1_plus_l2_top_k_plus_l3.sorted.reverse.take(k) //O((k*n3)log(k*n3))\n sorted_sorted_l1_plus_l2_top_k_plus_l3_topk\n }\n\n def printResult(result: IndexedSeq[Long]) = {\n result.foreach(println)\n }\n\n\n def main(args: Array[String]): Unit = {\n val (n1, n2, n3, k, l1, l2, l3) = read()\n printResult(solve(n1, n2, n3, k, l1, l2, l3))\n }\n}", "language": "Scala", "metadata": {"date": 1554641595, "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/s059332090.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s059332090", "user_id": "u494788559"}, "prompt_components": {"gold_output": "19\n17\n15\n14\n13\n12\n10\n8\n", "input_to_evaluate": "import java.util.Scanner\n\n// [x1 + x2 | x1<- l1, x2<- l2]をソート (TLE)\nobject Main {\n def read(): (Int, Int, Int, Int, IndexedSeq[Long], IndexedSeq[Long], IndexedSeq[Long]) = {\n val sc = new Scanner(System.in)\n val n1, n2, n3, k = sc.nextInt()\n val l1 = for (_ <- 0 until n1) yield sc.nextLong()\n val l2 = for (_ <- 0 until n2) yield sc.nextLong()\n val l3 = for (_ <- 0 until n3) yield sc.nextLong()\n (n1, n2, n3, k, l1, l2, l3)\n }\n\n\n def solve(n1: Int, n2: Int, n3: Int, k: Int, l1: IndexedSeq[Long], l2: IndexedSeq[Long], l3: IndexedSeq[Long]): IndexedSeq[Long] = {\n val l1_plus_l2 = for (x1 <- l1; x2 <- l2) yield x1 + x2\n // O(n1*n2)\n // l1+l2の時点でtop kにないものはl3を足してもtop kにならない。\n val sorted_l1_plus_l2_top_k = l1_plus_l2.sorted.reverse.take(k)\n //O((n1*n2)log(n1*n2))\n // k個取れない場合もエラーは出ない。取れるだけ取る\n val sorted_l1_plus_l2_top_k_plus_l3 = for (x12 <- sorted_l1_plus_l2_top_k; x3 <- l3) yield x12 + x3\n // O(k*n3)\n val sorted_sorted_l1_plus_l2_top_k_plus_l3_topk = sorted_l1_plus_l2_top_k_plus_l3.sorted.reverse.take(k) //O((k*n3)log(k*n3))\n sorted_sorted_l1_plus_l2_top_k_plus_l3_topk\n }\n\n def printResult(result: IndexedSeq[Long]) = {\n result.foreach(println)\n }\n\n\n def main(args: Array[String]): Unit = {\n val (n1, n2, n3, k, l1, l2, l3) = read()\n printResult(solve(n1, n2, n3, k, l1, l2, l3))\n }\n}", "problem_context": "Score: 400 points\n\nProblem Statement\n\nThe Patisserie AtCoder sells cakes with number-shaped candles.\nThere are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively.\nEach cake has an integer value called deliciousness, as follows:\n\nThe deliciousness of the cakes with 1-shaped candles are A_1, A_2, ..., A_X.\n\nThe deliciousness of the cakes with 2-shaped candles are B_1, B_2, ..., B_Y.\n\nThe deliciousness of the cakes with 3-shaped candles are C_1, C_2, ..., C_Z.\n\nTakahashi decides to buy three cakes, one for each of the three shapes of the candles, to celebrate ABC 123.\n\nThere are X \\times Y \\times Z such ways to choose three cakes.\n\nWe will arrange these X \\times Y \\times Z ways in descending order of the sum of the deliciousness of the cakes.\n\nPrint the sums of the deliciousness of the cakes for the first, second, ..., K-th ways in this list.\n\nConstraints\n\n1 \\leq X \\leq 1 \\ 000\n\n1 \\leq Y \\leq 1 \\ 000\n\n1 \\leq Z \\leq 1 \\ 000\n\n1 \\leq K \\leq \\min(3 \\ 000, X \\times Y \\times Z)\n\n1 \\leq A_i \\leq 10 \\ 000 \\ 000 \\ 000\n\n1 \\leq B_i \\leq 10 \\ 000 \\ 000 \\ 000\n\n1 \\leq C_i \\leq 10 \\ 000 \\ 000 \\ 000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y Z K\nA_1 \\ A_2 \\ A_3 \\ ... \\ A_X\nB_1 \\ B_2 \\ B_3 \\ ... \\ B_Y\nC_1 \\ C_2 \\ C_3 \\ ... \\ C_Z\n\nOutput\n\nPrint K lines. The i-th line should contain the i-th value stated in the problem statement.\n\nSample Input 1\n\n2 2 2 8\n4 6\n1 5\n3 8\n\nSample Output 1\n\n19\n17\n15\n14\n13\n12\n10\n8\n\nThere are 2 \\times 2 \\times 2 = 8 ways to choose three cakes, as shown below in descending order of the sum of the deliciousness of the cakes:\n\n(A_2, B_2, C_2): 6 + 5 + 8 = 19\n\n(A_1, B_2, C_2): 4 + 5 + 8 = 17\n\n(A_2, B_1, C_2): 6 + 1 + 8 = 15\n\n(A_2, B_2, C_1): 6 + 5 + 3 = 14\n\n(A_1, B_1, C_2): 4 + 1 + 8 = 13\n\n(A_1, B_2, C_1): 4 + 5 + 3 = 12\n\n(A_2, B_1, C_1): 6 + 1 + 3 = 10\n\n(A_1, B_1, C_1): 4 + 1 + 3 = 8\n\nSample Input 2\n\n3 3 3 5\n1 10 100\n2 20 200\n1 10 100\n\nSample Output 2\n\n400\n310\n310\n301\n301\n\nThere may be multiple combinations of cakes with the same sum of the deliciousness. For example, in this test case, the sum of A_1, B_3, C_3 and the sum of A_3, B_3, C_1 are both 301.\nHowever, they are different ways of choosing cakes, so 301 occurs twice in the output.\n\nSample Input 3\n\n10 10 10 20\n7467038376 5724769290 292794712 2843504496 3381970101 8402252870 249131806 6310293640 6690322794 6082257488\n1873977926 2576529623 1144842195 1379118507 6003234687 4925540914 3902539811 3326692703 484657758 2877436338\n4975681328 8974383988 2882263257 7690203955 514305523 6679823484 4263279310 585966808 3752282379 620585736\n\nSample Output 3\n\n23379871545\n22444657051\n22302177772\n22095691512\n21667941469\n21366963278\n21287912315\n21279176669\n21160477018\n21085311041\n21059876163\n21017997739\n20703329561\n20702387965\n20590247696\n20383761436\n20343962175\n20254073196\n20210218542\n20150096547\n\nNote that the input or output may not fit into a 32-bit integer type.", "sample_input": "2 2 2 8\n4 6\n1 5\n3 8\n"}, "reference_outputs": ["19\n17\n15\n14\n13\n12\n10\n8\n"], "source_document_id": "p03078", "source_text": "Score: 400 points\n\nProblem Statement\n\nThe Patisserie AtCoder sells cakes with number-shaped candles.\nThere are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively.\nEach cake has an integer value called deliciousness, as follows:\n\nThe deliciousness of the cakes with 1-shaped candles are A_1, A_2, ..., A_X.\n\nThe deliciousness of the cakes with 2-shaped candles are B_1, B_2, ..., B_Y.\n\nThe deliciousness of the cakes with 3-shaped candles are C_1, C_2, ..., C_Z.\n\nTakahashi decides to buy three cakes, one for each of the three shapes of the candles, to celebrate ABC 123.\n\nThere are X \\times Y \\times Z such ways to choose three cakes.\n\nWe will arrange these X \\times Y \\times Z ways in descending order of the sum of the deliciousness of the cakes.\n\nPrint the sums of the deliciousness of the cakes for the first, second, ..., K-th ways in this list.\n\nConstraints\n\n1 \\leq X \\leq 1 \\ 000\n\n1 \\leq Y \\leq 1 \\ 000\n\n1 \\leq Z \\leq 1 \\ 000\n\n1 \\leq K \\leq \\min(3 \\ 000, X \\times Y \\times Z)\n\n1 \\leq A_i \\leq 10 \\ 000 \\ 000 \\ 000\n\n1 \\leq B_i \\leq 10 \\ 000 \\ 000 \\ 000\n\n1 \\leq C_i \\leq 10 \\ 000 \\ 000 \\ 000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y Z K\nA_1 \\ A_2 \\ A_3 \\ ... \\ A_X\nB_1 \\ B_2 \\ B_3 \\ ... \\ B_Y\nC_1 \\ C_2 \\ C_3 \\ ... \\ C_Z\n\nOutput\n\nPrint K lines. The i-th line should contain the i-th value stated in the problem statement.\n\nSample Input 1\n\n2 2 2 8\n4 6\n1 5\n3 8\n\nSample Output 1\n\n19\n17\n15\n14\n13\n12\n10\n8\n\nThere are 2 \\times 2 \\times 2 = 8 ways to choose three cakes, as shown below in descending order of the sum of the deliciousness of the cakes:\n\n(A_2, B_2, C_2): 6 + 5 + 8 = 19\n\n(A_1, B_2, C_2): 4 + 5 + 8 = 17\n\n(A_2, B_1, C_2): 6 + 1 + 8 = 15\n\n(A_2, B_2, C_1): 6 + 5 + 3 = 14\n\n(A_1, B_1, C_2): 4 + 1 + 8 = 13\n\n(A_1, B_2, C_1): 4 + 5 + 3 = 12\n\n(A_2, B_1, C_1): 6 + 1 + 3 = 10\n\n(A_1, B_1, C_1): 4 + 1 + 3 = 8\n\nSample Input 2\n\n3 3 3 5\n1 10 100\n2 20 200\n1 10 100\n\nSample Output 2\n\n400\n310\n310\n301\n301\n\nThere may be multiple combinations of cakes with the same sum of the deliciousness. For example, in this test case, the sum of A_1, B_3, C_3 and the sum of A_3, B_3, C_1 are both 301.\nHowever, they are different ways of choosing cakes, so 301 occurs twice in the output.\n\nSample Input 3\n\n10 10 10 20\n7467038376 5724769290 292794712 2843504496 3381970101 8402252870 249131806 6310293640 6690322794 6082257488\n1873977926 2576529623 1144842195 1379118507 6003234687 4925540914 3902539811 3326692703 484657758 2877436338\n4975681328 8974383988 2882263257 7690203955 514305523 6679823484 4263279310 585966808 3752282379 620585736\n\nSample Output 3\n\n23379871545\n22444657051\n22302177772\n22095691512\n21667941469\n21366963278\n21287912315\n21279176669\n21160477018\n21085311041\n21059876163\n21017997739\n20703329561\n20702387965\n20590247696\n20383761436\n20343962175\n20254073196\n20210218542\n20150096547\n\nNote that the input or output may not fit into a 32-bit integer type.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1457, "cpu_time_ms": 2119, "memory_kb": 226208}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s015745761", "group_id": "codeNet:p03078", "input_text": "import java.util.Scanner\n\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 X = sc.nextInt\n val Y = sc.nextInt\n val Z = sc.nextInt\n val K = sc.nextInt\n val A = Array.fill(X)(sc.nextLong).sorted.reverse\n val B = Array.fill(X)(sc.nextLong).sorted.reverse\n val C = Array.fill(X)(sc.nextLong).sorted.reverse\n\n val ar = new ArrayBuffer[Long]()\n var ai = 0\n while (ai < A.length) {\n var bi = 0\n while (bi < B.length && (ai + 1) * (bi * 1) <= K) {\n var ci = 0\n while (ci < C.length && (ai + 1) * (bi + 1) * (ci + 1) <= K) {\n ar.append(A(ai) + B(bi) + C(ci))\n ci += 1\n }\n bi += 1\n }\n ai += 1\n }\n ar.sorted.reverse.take(K).mkString(\"\\n\")\n }\n}\n", "language": "Scala", "metadata": {"date": 1554630504, "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/s015745761.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s015745761", "user_id": "u297767059"}, "prompt_components": {"gold_output": "19\n17\n15\n14\n13\n12\n10\n8\n", "input_to_evaluate": "import java.util.Scanner\n\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 X = sc.nextInt\n val Y = sc.nextInt\n val Z = sc.nextInt\n val K = sc.nextInt\n val A = Array.fill(X)(sc.nextLong).sorted.reverse\n val B = Array.fill(X)(sc.nextLong).sorted.reverse\n val C = Array.fill(X)(sc.nextLong).sorted.reverse\n\n val ar = new ArrayBuffer[Long]()\n var ai = 0\n while (ai < A.length) {\n var bi = 0\n while (bi < B.length && (ai + 1) * (bi * 1) <= K) {\n var ci = 0\n while (ci < C.length && (ai + 1) * (bi + 1) * (ci + 1) <= K) {\n ar.append(A(ai) + B(bi) + C(ci))\n ci += 1\n }\n bi += 1\n }\n ai += 1\n }\n ar.sorted.reverse.take(K).mkString(\"\\n\")\n }\n}\n", "problem_context": "Score: 400 points\n\nProblem Statement\n\nThe Patisserie AtCoder sells cakes with number-shaped candles.\nThere are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively.\nEach cake has an integer value called deliciousness, as follows:\n\nThe deliciousness of the cakes with 1-shaped candles are A_1, A_2, ..., A_X.\n\nThe deliciousness of the cakes with 2-shaped candles are B_1, B_2, ..., B_Y.\n\nThe deliciousness of the cakes with 3-shaped candles are C_1, C_2, ..., C_Z.\n\nTakahashi decides to buy three cakes, one for each of the three shapes of the candles, to celebrate ABC 123.\n\nThere are X \\times Y \\times Z such ways to choose three cakes.\n\nWe will arrange these X \\times Y \\times Z ways in descending order of the sum of the deliciousness of the cakes.\n\nPrint the sums of the deliciousness of the cakes for the first, second, ..., K-th ways in this list.\n\nConstraints\n\n1 \\leq X \\leq 1 \\ 000\n\n1 \\leq Y \\leq 1 \\ 000\n\n1 \\leq Z \\leq 1 \\ 000\n\n1 \\leq K \\leq \\min(3 \\ 000, X \\times Y \\times Z)\n\n1 \\leq A_i \\leq 10 \\ 000 \\ 000 \\ 000\n\n1 \\leq B_i \\leq 10 \\ 000 \\ 000 \\ 000\n\n1 \\leq C_i \\leq 10 \\ 000 \\ 000 \\ 000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y Z K\nA_1 \\ A_2 \\ A_3 \\ ... \\ A_X\nB_1 \\ B_2 \\ B_3 \\ ... \\ B_Y\nC_1 \\ C_2 \\ C_3 \\ ... \\ C_Z\n\nOutput\n\nPrint K lines. The i-th line should contain the i-th value stated in the problem statement.\n\nSample Input 1\n\n2 2 2 8\n4 6\n1 5\n3 8\n\nSample Output 1\n\n19\n17\n15\n14\n13\n12\n10\n8\n\nThere are 2 \\times 2 \\times 2 = 8 ways to choose three cakes, as shown below in descending order of the sum of the deliciousness of the cakes:\n\n(A_2, B_2, C_2): 6 + 5 + 8 = 19\n\n(A_1, B_2, C_2): 4 + 5 + 8 = 17\n\n(A_2, B_1, C_2): 6 + 1 + 8 = 15\n\n(A_2, B_2, C_1): 6 + 5 + 3 = 14\n\n(A_1, B_1, C_2): 4 + 1 + 8 = 13\n\n(A_1, B_2, C_1): 4 + 5 + 3 = 12\n\n(A_2, B_1, C_1): 6 + 1 + 3 = 10\n\n(A_1, B_1, C_1): 4 + 1 + 3 = 8\n\nSample Input 2\n\n3 3 3 5\n1 10 100\n2 20 200\n1 10 100\n\nSample Output 2\n\n400\n310\n310\n301\n301\n\nThere may be multiple combinations of cakes with the same sum of the deliciousness. For example, in this test case, the sum of A_1, B_3, C_3 and the sum of A_3, B_3, C_1 are both 301.\nHowever, they are different ways of choosing cakes, so 301 occurs twice in the output.\n\nSample Input 3\n\n10 10 10 20\n7467038376 5724769290 292794712 2843504496 3381970101 8402252870 249131806 6310293640 6690322794 6082257488\n1873977926 2576529623 1144842195 1379118507 6003234687 4925540914 3902539811 3326692703 484657758 2877436338\n4975681328 8974383988 2882263257 7690203955 514305523 6679823484 4263279310 585966808 3752282379 620585736\n\nSample Output 3\n\n23379871545\n22444657051\n22302177772\n22095691512\n21667941469\n21366963278\n21287912315\n21279176669\n21160477018\n21085311041\n21059876163\n21017997739\n20703329561\n20702387965\n20590247696\n20383761436\n20343962175\n20254073196\n20210218542\n20150096547\n\nNote that the input or output may not fit into a 32-bit integer type.", "sample_input": "2 2 2 8\n4 6\n1 5\n3 8\n"}, "reference_outputs": ["19\n17\n15\n14\n13\n12\n10\n8\n"], "source_document_id": "p03078", "source_text": "Score: 400 points\n\nProblem Statement\n\nThe Patisserie AtCoder sells cakes with number-shaped candles.\nThere are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively.\nEach cake has an integer value called deliciousness, as follows:\n\nThe deliciousness of the cakes with 1-shaped candles are A_1, A_2, ..., A_X.\n\nThe deliciousness of the cakes with 2-shaped candles are B_1, B_2, ..., B_Y.\n\nThe deliciousness of the cakes with 3-shaped candles are C_1, C_2, ..., C_Z.\n\nTakahashi decides to buy three cakes, one for each of the three shapes of the candles, to celebrate ABC 123.\n\nThere are X \\times Y \\times Z such ways to choose three cakes.\n\nWe will arrange these X \\times Y \\times Z ways in descending order of the sum of the deliciousness of the cakes.\n\nPrint the sums of the deliciousness of the cakes for the first, second, ..., K-th ways in this list.\n\nConstraints\n\n1 \\leq X \\leq 1 \\ 000\n\n1 \\leq Y \\leq 1 \\ 000\n\n1 \\leq Z \\leq 1 \\ 000\n\n1 \\leq K \\leq \\min(3 \\ 000, X \\times Y \\times Z)\n\n1 \\leq A_i \\leq 10 \\ 000 \\ 000 \\ 000\n\n1 \\leq B_i \\leq 10 \\ 000 \\ 000 \\ 000\n\n1 \\leq C_i \\leq 10 \\ 000 \\ 000 \\ 000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y Z K\nA_1 \\ A_2 \\ A_3 \\ ... \\ A_X\nB_1 \\ B_2 \\ B_3 \\ ... \\ B_Y\nC_1 \\ C_2 \\ C_3 \\ ... \\ C_Z\n\nOutput\n\nPrint K lines. The i-th line should contain the i-th value stated in the problem statement.\n\nSample Input 1\n\n2 2 2 8\n4 6\n1 5\n3 8\n\nSample Output 1\n\n19\n17\n15\n14\n13\n12\n10\n8\n\nThere are 2 \\times 2 \\times 2 = 8 ways to choose three cakes, as shown below in descending order of the sum of the deliciousness of the cakes:\n\n(A_2, B_2, C_2): 6 + 5 + 8 = 19\n\n(A_1, B_2, C_2): 4 + 5 + 8 = 17\n\n(A_2, B_1, C_2): 6 + 1 + 8 = 15\n\n(A_2, B_2, C_1): 6 + 5 + 3 = 14\n\n(A_1, B_1, C_2): 4 + 1 + 8 = 13\n\n(A_1, B_2, C_1): 4 + 5 + 3 = 12\n\n(A_2, B_1, C_1): 6 + 1 + 3 = 10\n\n(A_1, B_1, C_1): 4 + 1 + 3 = 8\n\nSample Input 2\n\n3 3 3 5\n1 10 100\n2 20 200\n1 10 100\n\nSample Output 2\n\n400\n310\n310\n301\n301\n\nThere may be multiple combinations of cakes with the same sum of the deliciousness. For example, in this test case, the sum of A_1, B_3, C_3 and the sum of A_3, B_3, C_1 are both 301.\nHowever, they are different ways of choosing cakes, so 301 occurs twice in the output.\n\nSample Input 3\n\n10 10 10 20\n7467038376 5724769290 292794712 2843504496 3381970101 8402252870 249131806 6310293640 6690322794 6082257488\n1873977926 2576529623 1144842195 1379118507 6003234687 4925540914 3902539811 3326692703 484657758 2877436338\n4975681328 8974383988 2882263257 7690203955 514305523 6679823484 4263279310 585966808 3752282379 620585736\n\nSample Output 3\n\n23379871545\n22444657051\n22302177772\n22095691512\n21667941469\n21366963278\n21287912315\n21279176669\n21160477018\n21085311041\n21059876163\n21017997739\n20703329561\n20702387965\n20590247696\n20383761436\n20343962175\n20254073196\n20210218542\n20150096547\n\nNote that the input or output may not fit into a 32-bit integer type.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 975, "cpu_time_ms": 864, "memory_kb": 40984}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s882103864", "group_id": "codeNet:p03079", "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 import java.util.Arrays\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 A, B, C = ni()\n if (A == B && B == C) out.println(\"Yes\")\n else out.println(\"No\")\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 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 = 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": 1553976133, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03079.html", "problem_id": "p03079", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03079/input.txt", "sample_output_relpath": "derived/input_output/data/p03079/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03079/Scala/s882103864.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s882103864", "user_id": "u460609472"}, "prompt_components": {"gold_output": "Yes\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 import java.util.Arrays\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 A, B, C = ni()\n if (A == B && B == C) out.println(\"Yes\")\n else out.println(\"No\")\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 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 = 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\nYou are given three integers A, B and C.\n\nDetermine if there exists an equilateral triangle whose sides have lengths A, B and C.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A,B,C \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf there exists an equilateral triangle whose sides have lengths A, B and C, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 2 2\n\nSample Output 1\n\nYes\n\nThere exists an equilateral triangle whose sides have lengths 2, 2 and 2.\n\nSample Input 2\n\n3 4 5\n\nSample Output 2\n\nNo\n\nThere is no equilateral triangle whose sides have lengths 3, 4 and 5.", "sample_input": "2 2 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03079", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given three integers A, B and C.\n\nDetermine if there exists an equilateral triangle whose sides have lengths A, B and C.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A,B,C \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf there exists an equilateral triangle whose sides have lengths A, B and C, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 2 2\n\nSample Output 1\n\nYes\n\nThere exists an equilateral triangle whose sides have lengths 2, 2 and 2.\n\nSample Input 2\n\n3 4 5\n\nSample Output 2\n\nNo\n\nThere is no equilateral triangle whose sides have lengths 3, 4 and 5.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3172, "cpu_time_ms": 323, "memory_kb": 25428}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s796180477", "group_id": "codeNet:p03079", "input_text": "\n\nimport java.util.Scanner\n\n\nobject Main {\n def read() = {\n val sc = new Scanner(System.in)\n val a, b, c = sc.nextInt()\n (a,b,c)\n }\n\n def solve(a: Int, b:Int, c:Int) : String = {\n val isOK :Boolean= a==b && b == c\n if(isOK) \"Yes\" else \"No\"\n }\n\n def main(args: Array[String]): Unit = {\n val (a,b,c) = read()\n println(solve(a,b,c))\n }\n}", "language": "Scala", "metadata": {"date": 1553976131, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03079.html", "problem_id": "p03079", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03079/input.txt", "sample_output_relpath": "derived/input_output/data/p03079/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03079/Scala/s796180477.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s796180477", "user_id": "u494788559"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "\n\nimport java.util.Scanner\n\n\nobject Main {\n def read() = {\n val sc = new Scanner(System.in)\n val a, b, c = sc.nextInt()\n (a,b,c)\n }\n\n def solve(a: Int, b:Int, c:Int) : String = {\n val isOK :Boolean= a==b && b == c\n if(isOK) \"Yes\" else \"No\"\n }\n\n def main(args: Array[String]): Unit = {\n val (a,b,c) = read()\n println(solve(a,b,c))\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given three integers A, B and C.\n\nDetermine if there exists an equilateral triangle whose sides have lengths A, B and C.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A,B,C \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf there exists an equilateral triangle whose sides have lengths A, B and C, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 2 2\n\nSample Output 1\n\nYes\n\nThere exists an equilateral triangle whose sides have lengths 2, 2 and 2.\n\nSample Input 2\n\n3 4 5\n\nSample Output 2\n\nNo\n\nThere is no equilateral triangle whose sides have lengths 3, 4 and 5.", "sample_input": "2 2 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03079", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given three integers A, B and C.\n\nDetermine if there exists an equilateral triangle whose sides have lengths A, B and C.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A,B,C \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf there exists an equilateral triangle whose sides have lengths A, B and C, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 2 2\n\nSample Output 1\n\nYes\n\nThere exists an equilateral triangle whose sides have lengths 2, 2 and 2.\n\nSample Input 2\n\n3 4 5\n\nSample Output 2\n\nNo\n\nThere is no equilateral triangle whose sides have lengths 3, 4 and 5.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 361, "cpu_time_ms": 356, "memory_kb": 25928}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s356083803", "group_id": "codeNet:p03079", "input_text": "object Main {\n import java.util.Scanner\n\n implicit class RichScanner(sc: Scanner) {\n def readStrings(n: Int): Array[String] = Array.fill(n) { sc.next() }\n def readInts(n: Int): Array[Int] = Array.fill(n) { sc.nextInt() }\n def readLongs(n: Int): Array[Long] = Array.fill(n) { sc.nextLong() }\n def readLineStrings: Array[String] = sc.nextLine().split(' ')\n def readLineInts: Array[Int] = readLineStrings.map(_.toInt)\n def readLineLongs: Array[Long] = readLineStrings.map(_.toLong)\n }\n\n def main(args: Array[String]): Unit = solve(new Scanner(System.in))\n\n def solve(sc: Scanner): Unit = {\n val Array(a, b, c) = sc.readLineInts\n if (a == b && b == c) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1553976053, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03079.html", "problem_id": "p03079", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03079/input.txt", "sample_output_relpath": "derived/input_output/data/p03079/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03079/Scala/s356083803.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s356083803", "user_id": "u909304507"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main {\n import java.util.Scanner\n\n implicit class RichScanner(sc: Scanner) {\n def readStrings(n: Int): Array[String] = Array.fill(n) { sc.next() }\n def readInts(n: Int): Array[Int] = Array.fill(n) { sc.nextInt() }\n def readLongs(n: Int): Array[Long] = Array.fill(n) { sc.nextLong() }\n def readLineStrings: Array[String] = sc.nextLine().split(' ')\n def readLineInts: Array[Int] = readLineStrings.map(_.toInt)\n def readLineLongs: Array[Long] = readLineStrings.map(_.toLong)\n }\n\n def main(args: Array[String]): Unit = solve(new Scanner(System.in))\n\n def solve(sc: Scanner): Unit = {\n val Array(a, b, c) = sc.readLineInts\n if (a == b && b == c) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given three integers A, B and C.\n\nDetermine if there exists an equilateral triangle whose sides have lengths A, B and C.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A,B,C \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf there exists an equilateral triangle whose sides have lengths A, B and C, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 2 2\n\nSample Output 1\n\nYes\n\nThere exists an equilateral triangle whose sides have lengths 2, 2 and 2.\n\nSample Input 2\n\n3 4 5\n\nSample Output 2\n\nNo\n\nThere is no equilateral triangle whose sides have lengths 3, 4 and 5.", "sample_input": "2 2 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03079", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given three integers A, B and C.\n\nDetermine if there exists an equilateral triangle whose sides have lengths A, B and C.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A,B,C \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf there exists an equilateral triangle whose sides have lengths A, B and C, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 2 2\n\nSample Output 1\n\nYes\n\nThere exists an equilateral triangle whose sides have lengths 2, 2 and 2.\n\nSample Input 2\n\n3 4 5\n\nSample Output 2\n\nNo\n\nThere is no equilateral triangle whose sides have lengths 3, 4 and 5.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 745, "cpu_time_ms": 352, "memory_kb": 25784}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s011357176", "group_id": "codeNet:p03080", "input_text": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val n = in.readInt\n val s = in.readLine.toCharArray\n val ans = if(s.count(_ == 'R') > s.count(_ == 'B')) \"Yes\" else \"No\"\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1553977096, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03080.html", "problem_id": "p03080", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03080/input.txt", "sample_output_relpath": "derived/input_output/data/p03080/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03080/Scala/s011357176.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s011357176", "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.readInt\n val s = in.readLine.toCharArray\n val ans = if(s.count(_ == 'R') > s.count(_ == 'B')) \"Yes\" else \"No\"\n println(ans)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N people numbered 1 to N. Each person wears a red hat or a blue hat.\n\nYou are given a string s representing the colors of the people. Person i wears a red hat if s_i is R, and a blue hat if s_i is B.\n\nDetermine if there are more people wearing a red hat than people wearing a blue hat.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n|s| = N\n\ns_i is R or B.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns\n\nOutput\n\nIf there are more people wearing a red hat than there are people wearing a blue hat, print Yes; otherwise, print No.\n\nSample Input 1\n\n4\nRRBR\n\nSample Output 1\n\nYes\n\nThere are three people wearing a red hat, and one person wearing a blue hat.\n\nSince there are more people wearing a red hat than people wearing a blue hat, the answer is Yes.\n\nSample Input 2\n\n4\nBRBR\n\nSample Output 2\n\nNo\n\nThere are two people wearing a red hat, and two people wearing a blue hat.\n\nSince there are as many people wearing a red hat as people wearing a blue hat, the answer is No.", "sample_input": "4\nRRBR\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03080", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N people numbered 1 to N. Each person wears a red hat or a blue hat.\n\nYou are given a string s representing the colors of the people. Person i wears a red hat if s_i is R, and a blue hat if s_i is B.\n\nDetermine if there are more people wearing a red hat than people wearing a blue hat.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n|s| = N\n\ns_i is R or B.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns\n\nOutput\n\nIf there are more people wearing a red hat than there are people wearing a blue hat, print Yes; otherwise, print No.\n\nSample Input 1\n\n4\nRRBR\n\nSample Output 1\n\nYes\n\nThere are three people wearing a red hat, and one person wearing a blue hat.\n\nSince there are more people wearing a red hat than people wearing a blue hat, the answer is Yes.\n\nSample Input 2\n\n4\nBRBR\n\nSample Output 2\n\nNo\n\nThere are two people wearing a red hat, and two people wearing a blue hat.\n\nSince there are as many people wearing a red hat as people wearing a blue hat, the answer is No.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 198, "cpu_time_ms": 318, "memory_kb": 25400}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s810539226", "group_id": "codeNet:p03080", "input_text": "object Main extends App {\n var num = readInt\n var get = readLine\n var r = 0\n var b = 0\n for(i <- 0 to num-1) {\n if(get.charAt(i)=='R')\n r+=1\n else\n b+=1\n }\n if(r>b)\n println(\"Yes\")\n else\n println(\"No\")\n }", "language": "Scala", "metadata": {"date": 1553976892, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03080.html", "problem_id": "p03080", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03080/input.txt", "sample_output_relpath": "derived/input_output/data/p03080/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03080/Scala/s810539226.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s810539226", "user_id": "u533688845"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n var num = readInt\n var get = readLine\n var r = 0\n var b = 0\n for(i <- 0 to num-1) {\n if(get.charAt(i)=='R')\n r+=1\n else\n b+=1\n }\n if(r>b)\n println(\"Yes\")\n else\n println(\"No\")\n }", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N people numbered 1 to N. Each person wears a red hat or a blue hat.\n\nYou are given a string s representing the colors of the people. Person i wears a red hat if s_i is R, and a blue hat if s_i is B.\n\nDetermine if there are more people wearing a red hat than people wearing a blue hat.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n|s| = N\n\ns_i is R or B.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns\n\nOutput\n\nIf there are more people wearing a red hat than there are people wearing a blue hat, print Yes; otherwise, print No.\n\nSample Input 1\n\n4\nRRBR\n\nSample Output 1\n\nYes\n\nThere are three people wearing a red hat, and one person wearing a blue hat.\n\nSince there are more people wearing a red hat than people wearing a blue hat, the answer is Yes.\n\nSample Input 2\n\n4\nBRBR\n\nSample Output 2\n\nNo\n\nThere are two people wearing a red hat, and two people wearing a blue hat.\n\nSince there are as many people wearing a red hat as people wearing a blue hat, the answer is No.", "sample_input": "4\nRRBR\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03080", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N people numbered 1 to N. Each person wears a red hat or a blue hat.\n\nYou are given a string s representing the colors of the people. Person i wears a red hat if s_i is R, and a blue hat if s_i is B.\n\nDetermine if there are more people wearing a red hat than people wearing a blue hat.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n|s| = N\n\ns_i is R or B.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns\n\nOutput\n\nIf there are more people wearing a red hat than there are people wearing a blue hat, print Yes; otherwise, print No.\n\nSample Input 1\n\n4\nRRBR\n\nSample Output 1\n\nYes\n\nThere are three people wearing a red hat, and one person wearing a blue hat.\n\nSince there are more people wearing a red hat than people wearing a blue hat, the answer is Yes.\n\nSample Input 2\n\n4\nBRBR\n\nSample Output 2\n\nNo\n\nThere are two people wearing a red hat, and two people wearing a blue hat.\n\nSince there are as many people wearing a red hat as people wearing a blue hat, the answer is No.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 236, "cpu_time_ms": 324, "memory_kb": 27324}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s290569405", "group_id": "codeNet:p03080", "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 import java.util.Arrays\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 S = ns(N)\n val R = S.count(_ == 'R')\n val B = N - R\n if (R > B) out.println(\"Yes\")\n else out.println(\"No\")\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 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 = 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": 1553976199, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03080.html", "problem_id": "p03080", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03080/input.txt", "sample_output_relpath": "derived/input_output/data/p03080/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03080/Scala/s290569405.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s290569405", "user_id": "u460609472"}, "prompt_components": {"gold_output": "Yes\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 import java.util.Arrays\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 S = ns(N)\n val R = S.count(_ == 'R')\n val B = N - R\n if (R > B) out.println(\"Yes\")\n else out.println(\"No\")\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 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 = 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 : 200 points\n\nProblem Statement\n\nThere are N people numbered 1 to N. Each person wears a red hat or a blue hat.\n\nYou are given a string s representing the colors of the people. Person i wears a red hat if s_i is R, and a blue hat if s_i is B.\n\nDetermine if there are more people wearing a red hat than people wearing a blue hat.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n|s| = N\n\ns_i is R or B.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns\n\nOutput\n\nIf there are more people wearing a red hat than there are people wearing a blue hat, print Yes; otherwise, print No.\n\nSample Input 1\n\n4\nRRBR\n\nSample Output 1\n\nYes\n\nThere are three people wearing a red hat, and one person wearing a blue hat.\n\nSince there are more people wearing a red hat than people wearing a blue hat, the answer is Yes.\n\nSample Input 2\n\n4\nBRBR\n\nSample Output 2\n\nNo\n\nThere are two people wearing a red hat, and two people wearing a blue hat.\n\nSince there are as many people wearing a red hat as people wearing a blue hat, the answer is No.", "sample_input": "4\nRRBR\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03080", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N people numbered 1 to N. Each person wears a red hat or a blue hat.\n\nYou are given a string s representing the colors of the people. Person i wears a red hat if s_i is R, and a blue hat if s_i is B.\n\nDetermine if there are more people wearing a red hat than people wearing a blue hat.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n|s| = N\n\ns_i is R or B.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns\n\nOutput\n\nIf there are more people wearing a red hat than there are people wearing a blue hat, print Yes; otherwise, print No.\n\nSample Input 1\n\n4\nRRBR\n\nSample Output 1\n\nYes\n\nThere are three people wearing a red hat, and one person wearing a blue hat.\n\nSince there are more people wearing a red hat than people wearing a blue hat, the answer is Yes.\n\nSample Input 2\n\n4\nBRBR\n\nSample Output 2\n\nNo\n\nThere are two people wearing a red hat, and two people wearing a blue hat.\n\nSince there are as many people wearing a red hat as people wearing a blue hat, the answer is No.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3221, "cpu_time_ms": 323, "memory_kb": 25408}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s369408444", "group_id": "codeNet:p03082", "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 MOD = 1e9.toInt + 7\n // (x ^ n) % mod\n def repeatSquares(x: Long, n: Int, mod: Int): Long = {\n if(n == 0)\n 1\n else if(n % 2 == 0)\n repeatSquares(x*x % mod, n/2, mod)\n else\n (x * repeatSquares(x*x % mod, n/2, mod)) % mod\n }\n\n val N = in.next().toInt\n val X = in.next().toInt\n val _S = new Array[Int](N)\n\n for (i <- 0 until N)\n _S(i) = in.next().toInt\n\n\n //\n val S = 0 +: _S.sorted.reverse\n val dp = Array.ofDim[Long](N+1, X+1)\n for (n <- 0 to N; x <- 0 to X)\n dp(n)(x) = -1L\n\n def calc(i: Int, X: Int): Long = {\n if(i == N)\n X % S(i)\n else if(dp(i)(X) != -1L)\n dp(i)(X)\n else {\n val denom = repeatSquares(N+1-i, MOD-2, MOD)\n val r1 = (denom * calc(i+1, X % S(i))) % MOD\n val r2 = ((N-i) * denom % MOD) * calc(i+1, X) % MOD\n dp(i)(X) = (r1 + r2) % MOD\n dp(i)(X) \n }\n }\n\n def fact(n: Long, acc: Long): Long =\n if(n == 1)\n acc\n else\n fact(n-1, (n*acc) % MOD)\n\n val expected = calc(1, X) % MOD\n val ans = expected * fact(N, 1L)\n println(ans % 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\n", "language": "Scala", "metadata": {"date": 1554505362, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03082.html", "problem_id": "p03082", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03082/input.txt", "sample_output_relpath": "derived/input_output/data/p03082/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03082/Scala/s369408444.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s369408444", "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 MOD = 1e9.toInt + 7\n // (x ^ n) % mod\n def repeatSquares(x: Long, n: Int, mod: Int): Long = {\n if(n == 0)\n 1\n else if(n % 2 == 0)\n repeatSquares(x*x % mod, n/2, mod)\n else\n (x * repeatSquares(x*x % mod, n/2, mod)) % mod\n }\n\n val N = in.next().toInt\n val X = in.next().toInt\n val _S = new Array[Int](N)\n\n for (i <- 0 until N)\n _S(i) = in.next().toInt\n\n\n //\n val S = 0 +: _S.sorted.reverse\n val dp = Array.ofDim[Long](N+1, X+1)\n for (n <- 0 to N; x <- 0 to X)\n dp(n)(x) = -1L\n\n def calc(i: Int, X: Int): Long = {\n if(i == N)\n X % S(i)\n else if(dp(i)(X) != -1L)\n dp(i)(X)\n else {\n val denom = repeatSquares(N+1-i, MOD-2, MOD)\n val r1 = (denom * calc(i+1, X % S(i))) % MOD\n val r2 = ((N-i) * denom % MOD) * calc(i+1, X) % MOD\n dp(i)(X) = (r1 + r2) % MOD\n dp(i)(X) \n }\n }\n\n def fact(n: Long, acc: Long): Long =\n if(n == 1)\n acc\n else\n fact(n-1, (n*acc) % MOD)\n\n val expected = calc(1, X) % MOD\n val ans = expected * fact(N, 1L)\n println(ans % 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\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nSnuke has a blackboard and a set S consisting of N integers.\nThe i-th element in S is S_i.\n\nHe wrote an integer X on the blackboard, then performed the following operation N times:\n\nChoose one element from S and remove it.\n\nLet x be the number written on the blackboard now, and y be the integer removed from S. Replace the number on the blackboard with x \\bmod {y}.\n\nThere are N! possible orders in which the elements are removed from S.\nFor each of them, find the number that would be written on the blackboard after the N operations, and compute the sum of all those N! numbers modulo 10^{9}+7.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 200\n\n1 \\leq S_i, X \\leq 10^{5}\n\nS_i are pairwise distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nS_1 S_2 \\ldots S_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2 19\n3 7\n\nSample Output 1\n\n3\n\nThere are two possible orders in which we remove the numbers from S.\n\nIf we remove 3 and 7 in this order, the number on the blackboard changes as follows: 19 \\rightarrow 1 \\rightarrow 1.\n\nIf we remove 7 and 3 in this order, the number on the blackboard changes as follows: 19 \\rightarrow 5 \\rightarrow 2.\n\nThe output should be the sum of these: 3.\n\nSample Input 2\n\n5 82\n22 11 6 5 13\n\nSample Output 2\n\n288\n\nSample Input 3\n\n10 100000\n50000 50001 50002 50003 50004 50005 50006 50007 50008 50009\n\nSample Output 3\n\n279669259\n\nBe sure to compute the sum modulo 10^{9}+7.", "sample_input": "2 19\n3 7\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03082", "source_text": "Score : 600 points\n\nProblem Statement\n\nSnuke has a blackboard and a set S consisting of N integers.\nThe i-th element in S is S_i.\n\nHe wrote an integer X on the blackboard, then performed the following operation N times:\n\nChoose one element from S and remove it.\n\nLet x be the number written on the blackboard now, and y be the integer removed from S. Replace the number on the blackboard with x \\bmod {y}.\n\nThere are N! possible orders in which the elements are removed from S.\nFor each of them, find the number that would be written on the blackboard after the N operations, and compute the sum of all those N! numbers modulo 10^{9}+7.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 200\n\n1 \\leq S_i, X \\leq 10^{5}\n\nS_i are pairwise distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nS_1 S_2 \\ldots S_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2 19\n3 7\n\nSample Output 1\n\n3\n\nThere are two possible orders in which we remove the numbers from S.\n\nIf we remove 3 and 7 in this order, the number on the blackboard changes as follows: 19 \\rightarrow 1 \\rightarrow 1.\n\nIf we remove 7 and 3 in this order, the number on the blackboard changes as follows: 19 \\rightarrow 5 \\rightarrow 2.\n\nThe output should be the sum of these: 3.\n\nSample Input 2\n\n5 82\n22 11 6 5 13\n\nSample Output 2\n\n288\n\nSample Input 3\n\n10 100000\n50000 50001 50002 50003 50004 50005 50006 50007 50008 50009\n\nSample Output 3\n\n279669259\n\nBe sure to compute the sum modulo 10^{9}+7.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1632, "cpu_time_ms": 1303, "memory_kb": 227140}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s284541635", "group_id": "codeNet:p03085", "input_text": "object Main extends App {\n println(new java.util.Scanner(System.in).next match {\n\tcase \"A\" => \"T\"\n case \"T\" => \"A\"\n case \"G\" => \"C\"\n case _ => \"G\"\n })\n}", "language": "Scala", "metadata": {"date": 1576160920, "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/s284541635.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s284541635", "user_id": "u132324749"}, "prompt_components": {"gold_output": "T\n", "input_to_evaluate": "object Main extends App {\n println(new java.util.Scanner(System.in).next match {\n\tcase \"A\" => \"T\"\n case \"T\" => \"A\"\n case \"G\" => \"C\"\n case _ => \"G\"\n })\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nOn the Planet AtCoder, there are four types of bases: A, C, G and T. A bonds with T, and C bonds with G.\n\nYou are given a letter b as input, which is A, C, G or T. Write a program that prints the letter representing the base that bonds with the base b.\n\nConstraints\n\nb is one of the letters A, C, G and T.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nb\n\nOutput\n\nPrint the letter representing the base that bonds with the base b.\n\nSample Input 1\n\nA\n\nSample Output 1\n\nT\n\nSample Input 2\n\nG\n\nSample Output 2\n\nC", "sample_input": "A\n"}, "reference_outputs": ["T\n"], "source_document_id": "p03085", "source_text": "Score : 100 points\n\nProblem Statement\n\nOn the Planet AtCoder, there are four types of bases: A, C, G and T. A bonds with T, and C bonds with G.\n\nYou are given a letter b as input, which is A, C, G or T. Write a program that prints the letter representing the base that bonds with the base b.\n\nConstraints\n\nb is one of the letters A, C, G and T.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nb\n\nOutput\n\nPrint the letter representing the base that bonds with the base b.\n\nSample Input 1\n\nA\n\nSample Output 1\n\nT\n\nSample Input 2\n\nG\n\nSample Output 2\n\nC", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 163, "cpu_time_ms": 349, "memory_kb": 25660}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s648901723", "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(\"C\")\n }\n if (b == \"C\") {\n println(\"A\")\n }\n if (b == \"G\") {\n println(\"T\")\n }\n println(\"G\")\n }\n}", "language": "Scala", "metadata": {"date": 1564065665, "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/s648901723.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s648901723", "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(\"C\")\n }\n if (b == \"C\") {\n println(\"A\")\n }\n if (b == \"G\") {\n println(\"T\")\n }\n println(\"G\")\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nOn the Planet AtCoder, there are four types of bases: A, C, G and T. A bonds with T, and C bonds with G.\n\nYou are given a letter b as input, which is A, C, G or T. Write a program that prints the letter representing the base that bonds with the base b.\n\nConstraints\n\nb is one of the letters A, C, G and T.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nb\n\nOutput\n\nPrint the letter representing the base that bonds with the base b.\n\nSample Input 1\n\nA\n\nSample Output 1\n\nT\n\nSample Input 2\n\nG\n\nSample Output 2\n\nC", "sample_input": "A\n"}, "reference_outputs": ["T\n"], "source_document_id": "p03085", "source_text": "Score : 100 points\n\nProblem Statement\n\nOn the Planet AtCoder, there are four types of bases: A, C, G and T. A bonds with T, and C bonds with G.\n\nYou are given a letter b as input, which is A, C, G or T. Write a program that prints the letter representing the base that bonds with the base b.\n\nConstraints\n\nb is one of the letters A, C, G and T.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nb\n\nOutput\n\nPrint the letter representing the base that bonds with the base b.\n\nSample Input 1\n\nA\n\nSample Output 1\n\nT\n\nSample Input 2\n\nG\n\nSample Output 2\n\nC", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 298, "cpu_time_ms": 329, "memory_kb": 25376}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s744230450", "group_id": "codeNet:p03085", "input_text": "\nimport java.util.Scanner\n\nobject Main extends App {\n\n val sc = new Scanner(System.in)\n\n val s = sc.next.toCharArray\n\n s.map(c => c match {\n case 'A' => 'T'\n case 'T' => 'A'\n case 'C' => 'G'\n case 'G' => 'C'\n }\n ).foreach(print)\n println()\n}\n", "language": "Scala", "metadata": {"date": 1553459151, "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/s744230450.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s744230450", "user_id": "u726872801"}, "prompt_components": {"gold_output": "T\n", "input_to_evaluate": "\nimport java.util.Scanner\n\nobject Main extends App {\n\n val sc = new Scanner(System.in)\n\n val s = sc.next.toCharArray\n\n s.map(c => c match {\n case 'A' => 'T'\n case 'T' => 'A'\n case 'C' => 'G'\n case 'G' => 'C'\n }\n ).foreach(print)\n println()\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nOn the Planet AtCoder, there are four types of bases: A, C, G and T. A bonds with T, and C bonds with G.\n\nYou are given a letter b as input, which is A, C, G or T. Write a program that prints the letter representing the base that bonds with the base b.\n\nConstraints\n\nb is one of the letters A, C, G and T.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nb\n\nOutput\n\nPrint the letter representing the base that bonds with the base b.\n\nSample Input 1\n\nA\n\nSample Output 1\n\nT\n\nSample Input 2\n\nG\n\nSample Output 2\n\nC", "sample_input": "A\n"}, "reference_outputs": ["T\n"], "source_document_id": "p03085", "source_text": "Score : 100 points\n\nProblem Statement\n\nOn the Planet AtCoder, there are four types of bases: A, C, G and T. A bonds with T, and C bonds with G.\n\nYou are given a letter b as input, which is A, C, G or T. Write a program that prints the letter representing the base that bonds with the base b.\n\nConstraints\n\nb is one of the letters A, C, G and T.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nb\n\nOutput\n\nPrint the letter representing the base that bonds with the base b.\n\nSample Input 1\n\nA\n\nSample Output 1\n\nT\n\nSample Input 2\n\nG\n\nSample Output 2\n\nC", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 260, "cpu_time_ms": 341, "memory_kb": 25496}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s172863493", "group_id": "codeNet:p03086", "input_text": "object Main extends App {\n import scala.io.StdIn._\n\n val tg = \"ATCG\"\n val line = readLine()\n\n val result =\n line\n .foldLeft((0, 0)) {\n case ((maxCount, count), c) =>\n if (tg.contains(c)) (Math.max(maxCount, count + 1), count + 1)\n else (maxCount, 0)\n }\n ._1\n\n println(result)\n}\n", "language": "Scala", "metadata": {"date": 1554380442, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03086.html", "problem_id": "p03086", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03086/input.txt", "sample_output_relpath": "derived/input_output/data/p03086/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03086/Scala/s172863493.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s172863493", "user_id": "u657217027"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main extends App {\n import scala.io.StdIn._\n\n val tg = \"ATCG\"\n val line = readLine()\n\n val result =\n line\n .foldLeft((0, 0)) {\n case ((maxCount, count), c) =>\n if (tg.contains(c)) (Math.max(maxCount, count + 1), count + 1)\n else (maxCount, 0)\n }\n ._1\n\n println(result)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S consisting of uppercase English letters. Find the length of the longest ACGT string that is a substring (see Notes) of S.\n\nHere, a ACGT string is a string that contains no characters other than A, C, G and T.\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\nS is a string of length between 1 and 10 (inclusive).\n\nEach character in S is an uppercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the length of the longest ACGT string that is a substring of S.\n\nSample Input 1\n\nATCODER\n\nSample Output 1\n\n3\n\nAmong the ACGT strings that are substrings of ATCODER, the longest one is ATC.\n\nSample Input 2\n\nHATAGAYA\n\nSample Output 2\n\n5\n\nAmong the ACGT strings that are substrings of HATAGAYA, the longest one is ATAGA.\n\nSample Input 3\n\nSHINJUKU\n\nSample Output 3\n\n0\n\nAmong the ACGT strings that are substrings of SHINJUKU, the longest one is (the empty string).", "sample_input": "ATCODER\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03086", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S consisting of uppercase English letters. Find the length of the longest ACGT string that is a substring (see Notes) of S.\n\nHere, a ACGT string is a string that contains no characters other than A, C, G and T.\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\nS is a string of length between 1 and 10 (inclusive).\n\nEach character in S is an uppercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the length of the longest ACGT string that is a substring of S.\n\nSample Input 1\n\nATCODER\n\nSample Output 1\n\n3\n\nAmong the ACGT strings that are substrings of ATCODER, the longest one is ATC.\n\nSample Input 2\n\nHATAGAYA\n\nSample Output 2\n\n5\n\nAmong the ACGT strings that are substrings of HATAGAYA, the longest one is ATAGA.\n\nSample Input 3\n\nSHINJUKU\n\nSample Output 3\n\n0\n\nAmong the ACGT strings that are substrings of SHINJUKU, the longest one is (the empty string).", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 328, "cpu_time_ms": 325, "memory_kb": 25292}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s620059807", "group_id": "codeNet:p03086", "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 s = sc.next\n\n\n val bl = s.split(\"(?<=.)\").map{\"ATGC\".contains(_)}\n val res =\n bl.foldLeft(List.empty[Int]){ case (l, b) =>\n if( l.isEmpty) if(b) List(1) else List(0)\n else if(b) l :+ (l.last + 1) else l :+ 0\n }\n println(res.max)\n }\n}", "language": "Scala", "metadata": {"date": 1553458691, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03086.html", "problem_id": "p03086", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03086/input.txt", "sample_output_relpath": "derived/input_output/data/p03086/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03086/Scala/s620059807.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s620059807", "user_id": "u829407811"}, "prompt_components": {"gold_output": "3\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 s = sc.next\n\n\n val bl = s.split(\"(?<=.)\").map{\"ATGC\".contains(_)}\n val res =\n bl.foldLeft(List.empty[Int]){ case (l, b) =>\n if( l.isEmpty) if(b) List(1) else List(0)\n else if(b) l :+ (l.last + 1) else l :+ 0\n }\n println(res.max)\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S consisting of uppercase English letters. Find the length of the longest ACGT string that is a substring (see Notes) of S.\n\nHere, a ACGT string is a string that contains no characters other than A, C, G and T.\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\nS is a string of length between 1 and 10 (inclusive).\n\nEach character in S is an uppercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the length of the longest ACGT string that is a substring of S.\n\nSample Input 1\n\nATCODER\n\nSample Output 1\n\n3\n\nAmong the ACGT strings that are substrings of ATCODER, the longest one is ATC.\n\nSample Input 2\n\nHATAGAYA\n\nSample Output 2\n\n5\n\nAmong the ACGT strings that are substrings of HATAGAYA, the longest one is ATAGA.\n\nSample Input 3\n\nSHINJUKU\n\nSample Output 3\n\n0\n\nAmong the ACGT strings that are substrings of SHINJUKU, the longest one is (the empty string).", "sample_input": "ATCODER\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03086", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S consisting of uppercase English letters. Find the length of the longest ACGT string that is a substring (see Notes) of S.\n\nHere, a ACGT string is a string that contains no characters other than A, C, G and T.\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\nS is a string of length between 1 and 10 (inclusive).\n\nEach character in S is an uppercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the length of the longest ACGT string that is a substring of S.\n\nSample Input 1\n\nATCODER\n\nSample Output 1\n\n3\n\nAmong the ACGT strings that are substrings of ATCODER, the longest one is ATC.\n\nSample Input 2\n\nHATAGAYA\n\nSample Output 2\n\n5\n\nAmong the ACGT strings that are substrings of HATAGAYA, the longest one is ATAGA.\n\nSample Input 3\n\nSHINJUKU\n\nSample Output 3\n\n0\n\nAmong the ACGT strings that are substrings of SHINJUKU, the longest one is (the empty string).", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 391, "cpu_time_ms": 341, "memory_kb": 27348}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s308867501", "group_id": "codeNet:p03087", "input_text": "import scala.io.StdIn._\n\nobject Main extends App {\n\n val Array(n,q) = readLine().split(\" \").map(_.toInt)\n val s = readLine()\n val lr = Array.fill(q)(readLine().split(\" \").map(_.toInt -1))\n\n def solve() = {\n val cSum = Array.fill(n)(0)\n for(i <- 0 until n) {\n if(i == 0) cSum(i) = 0\n else if(s(i-1) == 'A' && s(i) == 'C') cSum(i) = cSum(i-1) + 1\n else cSum(i) = cSum(i-1)\n }\n lr.map{ list =>\n cSum(list(1)) - cSum(list(0))\n }.mkString(\"\\n\")\n }\n println(solve())\n\n}\n\n", "language": "Scala", "metadata": {"date": 1595542079, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/s308867501.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s308867501", "user_id": "u947008426"}, "prompt_components": {"gold_output": "2\n0\n3\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main extends App {\n\n val Array(n,q) = readLine().split(\" \").map(_.toInt)\n val s = readLine()\n val lr = Array.fill(q)(readLine().split(\" \").map(_.toInt -1))\n\n def solve() = {\n val cSum = Array.fill(n)(0)\n for(i <- 0 until n) {\n if(i == 0) cSum(i) = 0\n else if(s(i-1) == 'A' && s(i) == 'C') cSum(i) = cSum(i-1) + 1\n else cSum(i) = cSum(i-1)\n }\n lr.map{ list =>\n cSum(list(1)) - cSum(list(0))\n }.mkString(\"\\n\")\n }\n println(solve())\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 506, "cpu_time_ms": 791, "memory_kb": 63780}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s137011784", "group_id": "codeNet:p03087", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n\n val sc = new Scanner(System.in)\n\n val n = sc.nextInt\n val q = sc.nextInt\n val s = sc.next\n\n // (li, ri) の組 として扱う\n val lrs = Seq.fill(q)((sc.nextInt, sc.nextInt))\n\n // Vector[Int]は略せるが、わかりやすさのため。。。\n val commutativeCount: Vector[Int] = {\n s.tail.foldLeft((Vector(0), s.head)){case ((vec, pre), ch) =>\n (pre, ch) match {\n case ('A', 'C') => ( vec :+ (vec.last + 1), ch )\n case _ => ( vec :+ vec.last , ch )\n }\n }._1\n }\n\n val res = lrs.map{ case (l,r) =>\n commutativeCount(r - 1) - commutativeCount(l - 1)\n }\n\n res.foreach(println)\n\n\n\n //文字列Sに含まれるACの個数を求めるメソッド countAC を実装する\n// def countAC(str: String): Int = {\n// str.tail.foldLeft((0, str.head)){ case ( (cnt, pre), ch) =>\n// (pre, ch) match {\n// case ('A','C') => (cnt + 1, ch)\n// case _ => (cnt , ch)\n// }\n// }._1\n// }\n\n //各iに対して文字列Sを左からli,右からriだけ切り出してcountACを施す\n// val res =\n// lrs.map{ case (l, r) =>\n// val subStr = s.substring(l - 1, r)\n// countAC(subStr)\n// }\n// res.foreach(println)\n}\n", "language": "Scala", "metadata": {"date": 1576281925, "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/s137011784.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s137011784", "user_id": "u829407811"}, "prompt_components": {"gold_output": "2\n0\n3\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n\n val sc = new Scanner(System.in)\n\n val n = sc.nextInt\n val q = sc.nextInt\n val s = sc.next\n\n // (li, ri) の組 として扱う\n val lrs = Seq.fill(q)((sc.nextInt, sc.nextInt))\n\n // Vector[Int]は略せるが、わかりやすさのため。。。\n val commutativeCount: Vector[Int] = {\n s.tail.foldLeft((Vector(0), s.head)){case ((vec, pre), ch) =>\n (pre, ch) match {\n case ('A', 'C') => ( vec :+ (vec.last + 1), ch )\n case _ => ( vec :+ vec.last , ch )\n }\n }._1\n }\n\n val res = lrs.map{ case (l,r) =>\n commutativeCount(r - 1) - commutativeCount(l - 1)\n }\n\n res.foreach(println)\n\n\n\n //文字列Sに含まれるACの個数を求めるメソッド countAC を実装する\n// def countAC(str: String): Int = {\n// str.tail.foldLeft((0, str.head)){ case ( (cnt, pre), ch) =>\n// (pre, ch) match {\n// case ('A','C') => (cnt + 1, ch)\n// case _ => (cnt , ch)\n// }\n// }._1\n// }\n\n //各iに対して文字列Sを左からli,右からriだけ切り出してcountACを施す\n// val res =\n// lrs.map{ case (l, r) =>\n// val subStr = s.substring(l - 1, r)\n// countAC(subStr)\n// }\n// res.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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1265, "cpu_time_ms": 1760, "memory_kb": 98312}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s051254970", "group_id": "codeNet:p03087", "input_text": "object Main extends App {\nvar get1 = readLine.split(\" \")\nvar loop = get1(1).toInt\nvar word = readLine.split(\"\")\nvar count : Array[Int] = new Array(word.size)\n\tfor(i <- word.indexOf(\"A\") to word.size - 1) {\n \tif(word(i-1)==\"A\" && word(i)==\"C\")\n \t\tcount(i) = count(i - 1) + 1\n else\n count(i) = count(i - 1)\n }\n \tfor(i <- 0 to loop - 1) {\n var position = readLine.split(\" \")\n \tprintln(count(position(1).toInt) - count(position(0).toInt))\n }\n}", "language": "Scala", "metadata": {"date": 1554320823, "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/s051254970.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s051254970", "user_id": "u533688845"}, "prompt_components": {"gold_output": "2\n0\n3\n", "input_to_evaluate": "object Main extends App {\nvar get1 = readLine.split(\" \")\nvar loop = get1(1).toInt\nvar word = readLine.split(\"\")\nvar count : Array[Int] = new Array(word.size)\n\tfor(i <- word.indexOf(\"A\") to word.size - 1) {\n \tif(word(i-1)==\"A\" && word(i)==\"C\")\n \t\tcount(i) = count(i - 1) + 1\n else\n count(i) = count(i - 1)\n }\n \tfor(i <- 0 to loop - 1) {\n var position = readLine.split(\" \")\n \tprintln(count(position(1).toInt) - count(position(0).toInt))\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 478, "cpu_time_ms": 1372, "memory_kb": 56688}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s745640863", "group_id": "codeNet:p03087", "input_text": "import java.util.Scanner\n\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 Q = sc.nextInt\n val S = sc.next\n val lr = Array.fill(Q)(sc.nextInt, sc.nextInt)\n\n val L = ArrayBuffer.fill(N + 2)(0)\n var n = 0\n for (i <- S.indices if i < S.length - 1) {\n if (S(i) == 'A' && S(i + 1) == 'C') {\n n += 1\n }\n L(i + 1) = n\n }\n L(S.length + 1) = n\n\n val R = ArrayBuffer.fill(N + 2)(0)\n n = 0\n for (i <- S.indices.reverse if i > 0) {\n if (S(i - 1) == 'A' && S(i) == 'C') {\n n += 1\n }\n R(i + 1) = n\n }\n R(S.length + 1) = 0\n R(1) = R(2)\n R(0) = R(1)\n val all = n\n\n // println(L.map(_.toString).mkString(\" \"))\n // println(R.map(_.toString).mkString(\" \"))\n\n lr.map { case (l, r) =>\n (all - L(l - 1) - R(r + 1)).toString\n }.mkString(\"\\n\")\n }\n}\n", "language": "Scala", "metadata": {"date": 1553461937, "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/s745640863.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s745640863", "user_id": "u297767059"}, "prompt_components": {"gold_output": "2\n0\n3\n", "input_to_evaluate": "import java.util.Scanner\n\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 Q = sc.nextInt\n val S = sc.next\n val lr = Array.fill(Q)(sc.nextInt, sc.nextInt)\n\n val L = ArrayBuffer.fill(N + 2)(0)\n var n = 0\n for (i <- S.indices if i < S.length - 1) {\n if (S(i) == 'A' && S(i + 1) == 'C') {\n n += 1\n }\n L(i + 1) = n\n }\n L(S.length + 1) = n\n\n val R = ArrayBuffer.fill(N + 2)(0)\n n = 0\n for (i <- S.indices.reverse if i > 0) {\n if (S(i - 1) == 'A' && S(i) == 'C') {\n n += 1\n }\n R(i + 1) = n\n }\n R(S.length + 1) = 0\n R(1) = R(2)\n R(0) = R(1)\n val all = n\n\n // println(L.map(_.toString).mkString(\" \"))\n // println(R.map(_.toString).mkString(\" \"))\n\n lr.map { case (l, r) =>\n (all - L(l - 1) - R(r + 1)).toString\n }.mkString(\"\\n\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1103, "cpu_time_ms": 1201, "memory_kb": 78028}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s285019406", "group_id": "codeNet:p03089", "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 = get[Int]\n val bs = getArray[Int]\n\n @tailrec\n def take(bs: ArrayBuffer[Int], operations: ArrayBuffer[Int]): Option[ArrayBuffer[Int]] = {\n if (bs.isEmpty) {\n Some(operations)\n } else {\n bs.zipWithIndex.findLast {\n case (b, index) => b == index + 1\n } match {\n case Some((b, index)) =>\n operations += b\n bs.remove(index)\n take(bs, operations)\n case None =>\n None\n }\n }\n }\n\n take(ArrayBuffer(bs: _*), ArrayBuffer.empty[Int]) match {\n case Some(operations) => operations.reverse.foreach(out.println)\n case None => out.println(-1)\n }\n\n out.flush()\n }\n}", "language": "Scala", "metadata": {"date": 1592941975, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03089.html", "problem_id": "p03089", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03089/input.txt", "sample_output_relpath": "derived/input_output/data/p03089/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03089/Scala/s285019406.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s285019406", "user_id": "u178269371"}, "prompt_components": {"gold_output": "1\n1\n2\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 = get[Int]\n val bs = getArray[Int]\n\n @tailrec\n def take(bs: ArrayBuffer[Int], operations: ArrayBuffer[Int]): Option[ArrayBuffer[Int]] = {\n if (bs.isEmpty) {\n Some(operations)\n } else {\n bs.zipWithIndex.findLast {\n case (b, index) => b == index + 1\n } match {\n case Some((b, index)) =>\n operations += b\n bs.remove(index)\n take(bs, operations)\n case None =>\n None\n }\n }\n }\n\n take(ArrayBuffer(bs: _*), ArrayBuffer.empty[Int]) match {\n case Some(operations) => operations.reverse.foreach(out.println)\n case None => out.println(-1)\n }\n\n out.flush()\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nSnuke has an empty sequence a.\n\nHe will perform N operations on this sequence.\n\nIn the i-th operation, he chooses an integer j satisfying 1 \\leq j \\leq i, and insert j at position j in a (the beginning is position 1).\n\nYou are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq b_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nb_1 \\dots b_N\n\nOutput\n\nIf there is no sequence of N operations after which a would be equal to b, print -1.\nIf there is, print N lines. In the i-th line, the integer chosen in the i-th operation should be printed. If there are multiple solutions, any of them is accepted.\n\nSample Input 1\n\n3\n1 2 1\n\nSample Output 1\n\n1\n1\n2\n\nIn this sequence of operations, the sequence a changes as follows:\n\nAfter the first operation: (1)\n\nAfter the second operation: (1,1)\n\nAfter the third operation: (1,2,1)\n\nSample Input 2\n\n2\n2 2\n\nSample Output 2\n\n-1\n\n2 cannot be inserted at the beginning of the sequence, so this is impossible.\n\nSample Input 3\n\n9\n1 1 1 2 2 1 2 3 2\n\nSample Output 3\n\n1\n2\n2\n3\n1\n2\n2\n1\n1", "sample_input": "3\n1 2 1\n"}, "reference_outputs": ["1\n1\n2\n"], "source_document_id": "p03089", "source_text": "Score : 400 points\n\nProblem Statement\n\nSnuke has an empty sequence a.\n\nHe will perform N operations on this sequence.\n\nIn the i-th operation, he chooses an integer j satisfying 1 \\leq j \\leq i, and insert j at position j in a (the beginning is position 1).\n\nYou are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq b_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nb_1 \\dots b_N\n\nOutput\n\nIf there is no sequence of N operations after which a would be equal to b, print -1.\nIf there is, print N lines. In the i-th line, the integer chosen in the i-th operation should be printed. If there are multiple solutions, any of them is accepted.\n\nSample Input 1\n\n3\n1 2 1\n\nSample Output 1\n\n1\n1\n2\n\nIn this sequence of operations, the sequence a changes as follows:\n\nAfter the first operation: (1)\n\nAfter the second operation: (1,1)\n\nAfter the third operation: (1,2,1)\n\nSample Input 2\n\n2\n2 2\n\nSample Output 2\n\n-1\n\n2 cannot be inserted at the beginning of the sequence, so this is impossible.\n\nSample Input 3\n\n9\n1 1 1 2 2 1 2 3 2\n\nSample Output 3\n\n1\n2\n2\n3\n1\n2\n2\n1\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4073, "cpu_time_ms": 503, "memory_kb": 57276}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s235852406", "group_id": "codeNet:p03089", "input_text": "import scala.collection.mutable.ArrayBuffer\n\nobject Main extends App {\n val n = readInt\n val arr = readLine.split(\" \").map(_.toInt).toBuffer\n val outBuf = ArrayBuffer.fill(n)(0)\n var i = 0\n \n var arraySize = n\n while(i < n) {\n var j = arraySize\n var found = false\n while (found == false) {\n j -= 1\n val num = arr(j)\n \n if (num == j + 1) {\n outBuf(arraySize - 1) = num\n arr.remove(j)\n found = true\n }\n \n if (j == 0 && found == false) {\n println(-1)\n sys.exit(-1)\n }\n }\n arraySize -= 1\n i += 1\n }\n \n outBuf.foreach(println)\n}", "language": "Scala", "metadata": {"date": 1553391762, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03089.html", "problem_id": "p03089", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03089/input.txt", "sample_output_relpath": "derived/input_output/data/p03089/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03089/Scala/s235852406.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s235852406", "user_id": "u909991537"}, "prompt_components": {"gold_output": "1\n1\n2\n", "input_to_evaluate": "import scala.collection.mutable.ArrayBuffer\n\nobject Main extends App {\n val n = readInt\n val arr = readLine.split(\" \").map(_.toInt).toBuffer\n val outBuf = ArrayBuffer.fill(n)(0)\n var i = 0\n \n var arraySize = n\n while(i < n) {\n var j = arraySize\n var found = false\n while (found == false) {\n j -= 1\n val num = arr(j)\n \n if (num == j + 1) {\n outBuf(arraySize - 1) = num\n arr.remove(j)\n found = true\n }\n \n if (j == 0 && found == false) {\n println(-1)\n sys.exit(-1)\n }\n }\n arraySize -= 1\n i += 1\n }\n \n outBuf.foreach(println)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nSnuke has an empty sequence a.\n\nHe will perform N operations on this sequence.\n\nIn the i-th operation, he chooses an integer j satisfying 1 \\leq j \\leq i, and insert j at position j in a (the beginning is position 1).\n\nYou are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq b_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nb_1 \\dots b_N\n\nOutput\n\nIf there is no sequence of N operations after which a would be equal to b, print -1.\nIf there is, print N lines. In the i-th line, the integer chosen in the i-th operation should be printed. If there are multiple solutions, any of them is accepted.\n\nSample Input 1\n\n3\n1 2 1\n\nSample Output 1\n\n1\n1\n2\n\nIn this sequence of operations, the sequence a changes as follows:\n\nAfter the first operation: (1)\n\nAfter the second operation: (1,1)\n\nAfter the third operation: (1,2,1)\n\nSample Input 2\n\n2\n2 2\n\nSample Output 2\n\n-1\n\n2 cannot be inserted at the beginning of the sequence, so this is impossible.\n\nSample Input 3\n\n9\n1 1 1 2 2 1 2 3 2\n\nSample Output 3\n\n1\n2\n2\n3\n1\n2\n2\n1\n1", "sample_input": "3\n1 2 1\n"}, "reference_outputs": ["1\n1\n2\n"], "source_document_id": "p03089", "source_text": "Score : 400 points\n\nProblem Statement\n\nSnuke has an empty sequence a.\n\nHe will perform N operations on this sequence.\n\nIn the i-th operation, he chooses an integer j satisfying 1 \\leq j \\leq i, and insert j at position j in a (the beginning is position 1).\n\nYou are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq b_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nb_1 \\dots b_N\n\nOutput\n\nIf there is no sequence of N operations after which a would be equal to b, print -1.\nIf there is, print N lines. In the i-th line, the integer chosen in the i-th operation should be printed. If there are multiple solutions, any of them is accepted.\n\nSample Input 1\n\n3\n1 2 1\n\nSample Output 1\n\n1\n1\n2\n\nIn this sequence of operations, the sequence a changes as follows:\n\nAfter the first operation: (1)\n\nAfter the second operation: (1,1)\n\nAfter the third operation: (1,2,1)\n\nSample Input 2\n\n2\n2 2\n\nSample Output 2\n\n-1\n\n2 cannot be inserted at the beginning of the sequence, so this is impossible.\n\nSample Input 3\n\n9\n1 1 1 2 2 1 2 3 2\n\nSample Output 3\n\n1\n2\n2\n3\n1\n2\n2\n1\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 626, "cpu_time_ms": 330, "memory_kb": 27336}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s340101509", "group_id": "codeNet:p03089", "input_text": "object Main extends App {\n val in = scala.io.Source.stdin.getLines.toSeq\n val B = in.tail.head.split(' ').map(_.toInt.toChar).toArray\n \n private def func(b:Array[Char]):Seq[Int] = {\n if(b.isEmpty) return Seq()\n //println(b)\n var i=b.size - 1\n val sz=b.size\n while(i >= 0){\n if((i+1) == b(i) && b(i) <= sz ){ \n val sub = func(b.take(i) ++ b.drop(i+1) )\n //println(sub)\n if(sub != null) return sub :+ (i+1)\n }\n i -= 1\n }\n return null\n }\n val ret = func(B)\n if(ret == null) println(-1) else println(ret.mkString(\"\\n\"))\n}\n", "language": "Scala", "metadata": {"date": 1553379259, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03089.html", "problem_id": "p03089", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03089/input.txt", "sample_output_relpath": "derived/input_output/data/p03089/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03089/Scala/s340101509.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s340101509", "user_id": "u699236457"}, "prompt_components": {"gold_output": "1\n1\n2\n", "input_to_evaluate": "object Main extends App {\n val in = scala.io.Source.stdin.getLines.toSeq\n val B = in.tail.head.split(' ').map(_.toInt.toChar).toArray\n \n private def func(b:Array[Char]):Seq[Int] = {\n if(b.isEmpty) return Seq()\n //println(b)\n var i=b.size - 1\n val sz=b.size\n while(i >= 0){\n if((i+1) == b(i) && b(i) <= sz ){ \n val sub = func(b.take(i) ++ b.drop(i+1) )\n //println(sub)\n if(sub != null) return sub :+ (i+1)\n }\n i -= 1\n }\n return null\n }\n val ret = func(B)\n if(ret == null) println(-1) else println(ret.mkString(\"\\n\"))\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nSnuke has an empty sequence a.\n\nHe will perform N operations on this sequence.\n\nIn the i-th operation, he chooses an integer j satisfying 1 \\leq j \\leq i, and insert j at position j in a (the beginning is position 1).\n\nYou are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq b_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nb_1 \\dots b_N\n\nOutput\n\nIf there is no sequence of N operations after which a would be equal to b, print -1.\nIf there is, print N lines. In the i-th line, the integer chosen in the i-th operation should be printed. If there are multiple solutions, any of them is accepted.\n\nSample Input 1\n\n3\n1 2 1\n\nSample Output 1\n\n1\n1\n2\n\nIn this sequence of operations, the sequence a changes as follows:\n\nAfter the first operation: (1)\n\nAfter the second operation: (1,1)\n\nAfter the third operation: (1,2,1)\n\nSample Input 2\n\n2\n2 2\n\nSample Output 2\n\n-1\n\n2 cannot be inserted at the beginning of the sequence, so this is impossible.\n\nSample Input 3\n\n9\n1 1 1 2 2 1 2 3 2\n\nSample Output 3\n\n1\n2\n2\n3\n1\n2\n2\n1\n1", "sample_input": "3\n1 2 1\n"}, "reference_outputs": ["1\n1\n2\n"], "source_document_id": "p03089", "source_text": "Score : 400 points\n\nProblem Statement\n\nSnuke has an empty sequence a.\n\nHe will perform N operations on this sequence.\n\nIn the i-th operation, he chooses an integer j satisfying 1 \\leq j \\leq i, and insert j at position j in a (the beginning is position 1).\n\nYou are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq b_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nb_1 \\dots b_N\n\nOutput\n\nIf there is no sequence of N operations after which a would be equal to b, print -1.\nIf there is, print N lines. In the i-th line, the integer chosen in the i-th operation should be printed. If there are multiple solutions, any of them is accepted.\n\nSample Input 1\n\n3\n1 2 1\n\nSample Output 1\n\n1\n1\n2\n\nIn this sequence of operations, the sequence a changes as follows:\n\nAfter the first operation: (1)\n\nAfter the second operation: (1,1)\n\nAfter the third operation: (1,2,1)\n\nSample Input 2\n\n2\n2 2\n\nSample Output 2\n\n-1\n\n2 cannot be inserted at the beginning of the sequence, so this is impossible.\n\nSample Input 3\n\n9\n1 1 1 2 2 1 2 3 2\n\nSample Output 3\n\n1\n2\n2\n3\n1\n2\n2\n1\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 582, "cpu_time_ms": 2111, "memory_kb": 114628}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s360898579", "group_id": "codeNet:p03096", "input_text": "object Main extends App {\n var n = scala.io.StdIn.readInt()\n var vectorCList = Vector.empty[Vector[Int]]\n val divideVal:Long = 1000000007\n\n for(i <- 1 to n) {\n var newVectorCList = Vector.empty[Vector[Int]]\n val cInput = scala.io.StdIn.readLine()\n val c = cInput.toInt\n if (vectorCList.length == 0) {\n var list = Vector.empty[Int]\n list :+= c\n newVectorCList :+= list\n } else {\n for(k <- 0 to (vectorCList.length - 1)){\n var list = vectorCList(k)\n if(list.exists(_ == c) && list(list.length - 1) != c) {\n var newList = Vector.empty[Int]\n val findIndex = list.lastIndexOf(c)\n for(l <- 0 to list.length) {\n if(findIndex < l) {\n newList :+= c\n } else {\n newList :+= list(l)\n }\n }\n newVectorCList :+= newList\n }\n list :+= c\n newVectorCList :+= list\n }\n }\n vectorCList = newVectorCList.distinct\n }\n println(vectorCList.size % divideVal)\n}\n", "language": "Scala", "metadata": {"date": 1552776059, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03096.html", "problem_id": "p03096", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03096/input.txt", "sample_output_relpath": "derived/input_output/data/p03096/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03096/Scala/s360898579.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s360898579", "user_id": "u105921924"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main extends App {\n var n = scala.io.StdIn.readInt()\n var vectorCList = Vector.empty[Vector[Int]]\n val divideVal:Long = 1000000007\n\n for(i <- 1 to n) {\n var newVectorCList = Vector.empty[Vector[Int]]\n val cInput = scala.io.StdIn.readLine()\n val c = cInput.toInt\n if (vectorCList.length == 0) {\n var list = Vector.empty[Int]\n list :+= c\n newVectorCList :+= list\n } else {\n for(k <- 0 to (vectorCList.length - 1)){\n var list = vectorCList(k)\n if(list.exists(_ == c) && list(list.length - 1) != c) {\n var newList = Vector.empty[Int]\n val findIndex = list.lastIndexOf(c)\n for(l <- 0 to list.length) {\n if(findIndex < l) {\n newList :+= c\n } else {\n newList :+= list(l)\n }\n }\n newVectorCList :+= newList\n }\n list :+= c\n newVectorCList :+= list\n }\n }\n vectorCList = newVectorCList.distinct\n }\n println(vectorCList.size % divideVal)\n}\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nThere are N stones arranged in a row. The i-th stone from the left is painted in the color C_i.\n\nSnuke will perform the following operation zero or more times:\n\nChoose two stones painted in the same color. Repaint all the stones between them, with the color of the chosen stones.\n\nFind the number of possible final sequences of colors of the stones, modulo 10^9+7.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq C_i \\leq 2\\times 10^5(1\\leq i\\leq N)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nC_1\n:\nC_N\n\nOutput\n\nPrint the number of possible final sequences of colors of the stones, modulo 10^9+7.\n\nSample Input 1\n\n5\n1\n2\n1\n2\n2\n\nSample Output 1\n\n3\n\nWe can make three sequences of colors of stones, as follows:\n\n(1,2,1,2,2), by doing nothing.\n\n(1,1,1,2,2), by choosing the first and third stones to perform the operation.\n\n(1,2,2,2,2), by choosing the second and fourth stones to perform the operation.\n\nSample Input 2\n\n6\n4\n2\n5\n4\n2\n4\n\nSample Output 2\n\n5\n\nSample Input 3\n\n7\n1\n3\n1\n2\n3\n3\n2\n\nSample Output 3\n\n5", "sample_input": "5\n1\n2\n1\n2\n2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03096", "source_text": "Score : 700 points\n\nProblem Statement\n\nThere are N stones arranged in a row. The i-th stone from the left is painted in the color C_i.\n\nSnuke will perform the following operation zero or more times:\n\nChoose two stones painted in the same color. Repaint all the stones between them, with the color of the chosen stones.\n\nFind the number of possible final sequences of colors of the stones, modulo 10^9+7.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq C_i \\leq 2\\times 10^5(1\\leq i\\leq N)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nC_1\n:\nC_N\n\nOutput\n\nPrint the number of possible final sequences of colors of the stones, modulo 10^9+7.\n\nSample Input 1\n\n5\n1\n2\n1\n2\n2\n\nSample Output 1\n\n3\n\nWe can make three sequences of colors of stones, as follows:\n\n(1,2,1,2,2), by doing nothing.\n\n(1,1,1,2,2), by choosing the first and third stones to perform the operation.\n\n(1,2,2,2,2), by choosing the second and fourth stones to perform the operation.\n\nSample Input 2\n\n6\n4\n2\n5\n4\n2\n4\n\nSample Output 2\n\n5\n\nSample Input 3\n\n7\n1\n3\n1\n2\n3\n3\n2\n\nSample Output 3\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1025, "cpu_time_ms": 2119, "memory_kb": 184064}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s853919370", "group_id": "codeNet:p03101", "input_text": "\nobject Main extends App {\n \n val Array(ttlRow, ttlCol) = io.StdIn.readLine.split(\" \").map(_.toInt)\n val Array(row, col) = io.StdIn.readLine.split(\" \").map(_.toInt)\n println(balanceCell(ttlRow, ttlCol, row, col))\n def balanceCell(ttlRow:Int, ttlCol:Int, row:Int, col:Int):Int = {\n val rowBal = ttlRow - row \n val colBal = ttlCol - col \n rowBal * colBal \n }\n}", "language": "Scala", "metadata": {"date": 1553604194, "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/s853919370.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s853919370", "user_id": "u360779536"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "\nobject Main extends App {\n \n val Array(ttlRow, ttlCol) = io.StdIn.readLine.split(\" \").map(_.toInt)\n val Array(row, col) = io.StdIn.readLine.split(\" \").map(_.toInt)\n println(balanceCell(ttlRow, ttlCol, row, col))\n def balanceCell(ttlRow:Int, ttlCol:Int, row:Int, col:Int):Int = {\n val rowBal = ttlRow - row \n val colBal = ttlCol - col \n rowBal * colBal \n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are H rows and W columns of white square cells.\n\nYou will choose h of the rows and w of the columns, and paint all of the cells contained in those rows or columns.\n\nHow many white cells will remain?\n\nIt can be proved that this count does not depend on what rows and columns are chosen.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq H, W \\leq 20\n\n1 \\leq h \\leq H\n\n1 \\leq w \\leq W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nh w\n\nOutput\n\nPrint the number of white cells that will remain.\n\nSample Input 1\n\n3 2\n2 1\n\nSample Output 1\n\n1\n\nThere are 3 rows and 2 columns of cells. When two rows and one column are chosen and painted in black, there is always one white cell that remains.\n\nSample Input 2\n\n5 5\n2 3\n\nSample Output 2\n\n6\n\nSample Input 3\n\n2 4\n2 4\n\nSample Output 3\n\n0", "sample_input": "3 2\n2 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03101", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are H rows and W columns of white square cells.\n\nYou will choose h of the rows and w of the columns, and paint all of the cells contained in those rows or columns.\n\nHow many white cells will remain?\n\nIt can be proved that this count does not depend on what rows and columns are chosen.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq H, W \\leq 20\n\n1 \\leq h \\leq H\n\n1 \\leq w \\leq W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nh w\n\nOutput\n\nPrint the number of white cells that will remain.\n\nSample Input 1\n\n3 2\n2 1\n\nSample Output 1\n\n1\n\nThere are 3 rows and 2 columns of cells. When two rows and one column are chosen and painted in black, there is always one white cell that remains.\n\nSample Input 2\n\n5 5\n2 3\n\nSample Output 2\n\n6\n\nSample Input 3\n\n2 4\n2 4\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 400, "cpu_time_ms": 322, "memory_kb": 25492}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s063099253", "group_id": "codeNet:p03101", "input_text": "object Main extends App {\n var get = readLine\n var get2 = readLine\n var a = get.split(\" \")(0).toInt - get2.split(\" \")(0).toInt\n \n var c = get.split(\" \")(1).toInt - get2.split(\" \")(1).toInt\n println(a*c)\n}", "language": "Scala", "metadata": {"date": 1552162166, "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/s063099253.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s063099253", "user_id": "u533688845"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main extends App {\n var get = readLine\n var get2 = readLine\n var a = get.split(\" \")(0).toInt - get2.split(\" \")(0).toInt\n \n var c = get.split(\" \")(1).toInt - get2.split(\" \")(1).toInt\n println(a*c)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are H rows and W columns of white square cells.\n\nYou will choose h of the rows and w of the columns, and paint all of the cells contained in those rows or columns.\n\nHow many white cells will remain?\n\nIt can be proved that this count does not depend on what rows and columns are chosen.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq H, W \\leq 20\n\n1 \\leq h \\leq H\n\n1 \\leq w \\leq W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nh w\n\nOutput\n\nPrint the number of white cells that will remain.\n\nSample Input 1\n\n3 2\n2 1\n\nSample Output 1\n\n1\n\nThere are 3 rows and 2 columns of cells. When two rows and one column are chosen and painted in black, there is always one white cell that remains.\n\nSample Input 2\n\n5 5\n2 3\n\nSample Output 2\n\n6\n\nSample Input 3\n\n2 4\n2 4\n\nSample Output 3\n\n0", "sample_input": "3 2\n2 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03101", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are H rows and W columns of white square cells.\n\nYou will choose h of the rows and w of the columns, and paint all of the cells contained in those rows or columns.\n\nHow many white cells will remain?\n\nIt can be proved that this count does not depend on what rows and columns are chosen.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq H, W \\leq 20\n\n1 \\leq h \\leq H\n\n1 \\leq w \\leq W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nh w\n\nOutput\n\nPrint the number of white cells that will remain.\n\nSample Input 1\n\n3 2\n2 1\n\nSample Output 1\n\n1\n\nThere are 3 rows and 2 columns of cells. When two rows and one column are chosen and painted in black, there is always one white cell that remains.\n\nSample Input 2\n\n5 5\n2 3\n\nSample Output 2\n\n6\n\nSample Input 3\n\n2 4\n2 4\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 221, "cpu_time_ms": 326, "memory_kb": 27180}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s761897304", "group_id": "codeNet:p03103", "input_text": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val N, M = sc.nextInt()\n val ABs = Array.fill(N, 2)(sc.nextLong())\n val s = ABs.sortBy(_.head)\n println(s.foldLeft((0L, M.toLong)) {\n case ((acc, m), arr) if m == 0 =>\n (acc, 0)\n case ((acc, m), arr) =>\n val a = arr.head\n val b = arr.last\n val buy = Math.min(m, b)\n (acc + (a * buy), m - buy)\n }._1)\n }\n}\n", "language": "Scala", "metadata": {"date": 1552756949, "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/s761897304.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s761897304", "user_id": "u917048429"}, "prompt_components": {"gold_output": "12\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, M = sc.nextInt()\n val ABs = Array.fill(N, 2)(sc.nextLong())\n val s = ABs.sortBy(_.head)\n println(s.foldLeft((0L, M.toLong)) {\n case ((acc, m), arr) if m == 0 =>\n (acc, 0)\n case ((acc, m), arr) =>\n val a = arr.head\n val b = arr.last\n val buy = Math.min(m, b)\n (acc + (a * buy), m - buy)\n }._1)\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nHearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.\n\nThere are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.\n\nWhat is the minimum amount of money with which he can buy M cans of energy drinks?\n\nIt is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^5\n\nB_1 + ... + B_N \\geq M\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_N B_N\n\nOutput\n\nPrint the minimum amount of money with which Takahashi can buy M cans of energy drinks.\n\nSample Input 1\n\n2 5\n4 9\n2 4\n\nSample Output 1\n\n12\n\nWith 12 yen, we can buy one drink at the first store and four drinks at the second store, for the total of five drinks. However, we cannot buy 5 drinks with 11 yen or less.\n\nSample Input 2\n\n4 30\n6 18\n2 5\n3 10\n7 9\n\nSample Output 2\n\n130\n\nSample Input 3\n\n1 100000\n1000000000 100000\n\nSample Output 3\n\n100000000000000\n\nThe output may not fit into a 32-bit integer type.", "sample_input": "2 5\n4 9\n2 4\n"}, "reference_outputs": ["12\n"], "source_document_id": "p03103", "source_text": "Score : 300 points\n\nProblem Statement\n\nHearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.\n\nThere are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.\n\nWhat is the minimum amount of money with which he can buy M cans of energy drinks?\n\nIt is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^5\n\nB_1 + ... + B_N \\geq M\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_N B_N\n\nOutput\n\nPrint the minimum amount of money with which Takahashi can buy M cans of energy drinks.\n\nSample Input 1\n\n2 5\n4 9\n2 4\n\nSample Output 1\n\n12\n\nWith 12 yen, we can buy one drink at the first store and four drinks at the second store, for the total of five drinks. However, we cannot buy 5 drinks with 11 yen or less.\n\nSample Input 2\n\n4 30\n6 18\n2 5\n3 10\n7 9\n\nSample Output 2\n\n130\n\nSample Input 3\n\n1 100000\n1000000000 100000\n\nSample Output 3\n\n100000000000000\n\nThe output may not fit into a 32-bit integer type.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 470, "cpu_time_ms": 1066, "memory_kb": 108160}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s515949049", "group_id": "codeNet:p03106", "input_text": "object Main extends App {\n\n val Array(a,b,k) = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n\n def solve(): Int = {\n (Math.min(a, b) to 1 by -1).filter { i =>\n a % i == 0 && b % i == 0\n }(k-1)\n }\n\n\n\n println(solve)\n\n}\n", "language": "Scala", "metadata": {"date": 1583362995, "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/s515949049.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s515949049", "user_id": "u947008426"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n\n val Array(a,b,k) = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n\n def solve(): Int = {\n (Math.min(a, b) to 1 by -1).filter { i =>\n a % i == 0 && b % i == 0\n }(k-1)\n }\n\n\n\n println(solve)\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 332, "memory_kb": 27344}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s292532909", "group_id": "codeNet:p03106", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val A = sc.nextInt\n val B = sc.nextInt\n val K = sc.nextInt\n val result = (List(A, B).min to 1 by -1).filter(x => A % x == 0 && B % x == 0)(K - 1)\n println(result)\n}", "language": "Scala", "metadata": {"date": 1555941733, "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/s292532909.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s292532909", "user_id": "u537859408"}, "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 = sc.nextInt\n val B = sc.nextInt\n val K = sc.nextInt\n val result = (List(A, B).min to 1 by -1).filter(x => A % x == 0 && B % x == 0)(K - 1)\n println(result)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 350, "memory_kb": 25756}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s187948493", "group_id": "codeNet:p03106", "input_text": "import java.util.Scanner\n\n\nobject Main {\n def read() = {\n val sc = new Scanner(System.in)\n val a = sc.nextInt()\n val b = sc.nextInt()\n val k = sc.nextInt()\n (a, b, k)\n }\n\n\n def solve(a: Int, b: Int, k: Int)= {\n def isDevidedByAandB(n:Int) = a%n ==0 && b%n==0\n\n val cmList = (1 to 100).filter(isDevidedByAandB) // 小さい順で並んだaとbの公約数\n cmList.reverse(k-1)\n }\n\n\n def main(args: Array[String]): Unit = {\n val (a, b, k) = read()\n println(solve(a, b, k))\n }\n}", "language": "Scala", "metadata": {"date": 1551644431, "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/s187948493.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s187948493", "user_id": "u494788559"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner\n\n\nobject Main {\n def read() = {\n val sc = new Scanner(System.in)\n val a = sc.nextInt()\n val b = sc.nextInt()\n val k = sc.nextInt()\n (a, b, k)\n }\n\n\n def solve(a: Int, b: Int, k: Int)= {\n def isDevidedByAandB(n:Int) = a%n ==0 && b%n==0\n\n val cmList = (1 to 100).filter(isDevidedByAandB) // 小さい順で並んだaとbの公約数\n cmList.reverse(k-1)\n }\n\n\n def main(args: Array[String]): Unit = {\n val (a, b, k) = read()\n println(solve(a, b, k))\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 511, "cpu_time_ms": 345, "memory_kb": 25688}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s947855851", "group_id": "codeNet:p03107", "input_text": "import scala.io.StdIn._\nobject Main extends App {\n val s = readLine\n println(math.min(s.count(_ == '0'), s.count(_ == '1')) * 2)\n}\n", "language": "Scala", "metadata": {"date": 1580978303, "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/s947855851.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s947855851", "user_id": "u518641666"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import scala.io.StdIn._\nobject Main extends App {\n val s = readLine\n println(math.min(s.count(_ == '0'), s.count(_ == '1')) * 2)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 406, "memory_kb": 27364}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s234593779", "group_id": "codeNet:p03107", "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(sc.next().groupBy(c => c).toArray.map(x => x._2.length).min * 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(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 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": 1551737171, "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/s234593779.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s234593779", "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 println(sc.next().groupBy(c => c).toArray.map(x => x._2.length).min * 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(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 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\nThere are N cubes stacked vertically on a desk.\n\nYou are given a string S of length N. The color of the i-th cube from the bottom is red if the i-th character in S is 0, and blue if that character is 1.\n\nYou can perform the following operation any number of times: choose a red cube and a blue cube that are adjacent, and remove them. Here, the cubes that were stacked on the removed cubes will fall down onto the object below them.\n\nAt most how many cubes can be removed?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = N\n\nEach character in S is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of cubes that can be removed.\n\nSample Input 1\n\n0011\n\nSample Output 1\n\n4\n\nAll four cubes can be removed, by performing the operation as follows:\n\nRemove the second and third cubes from the bottom. Then, the fourth cube drops onto the first cube.\n\nRemove the first and second cubes from the bottom.\n\nSample Input 2\n\n11011010001011\n\nSample Output 2\n\n12\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "sample_input": "0011\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03107", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N cubes stacked vertically on a desk.\n\nYou are given a string S of length N. The color of the i-th cube from the bottom is red if the i-th character in S is 0, and blue if that character is 1.\n\nYou can perform the following operation any number of times: choose a red cube and a blue cube that are adjacent, and remove them. Here, the cubes that were stacked on the removed cubes will fall down onto the object below them.\n\nAt most how many cubes can be removed?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = N\n\nEach character in S is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of cubes that can be removed.\n\nSample Input 1\n\n0011\n\nSample Output 1\n\n4\n\nAll four cubes can be removed, by performing the operation as follows:\n\nRemove the second and third cubes from the bottom. Then, the fourth cube drops onto the first cube.\n\nRemove the first and second cubes from the bottom.\n\nSample Input 2\n\n11011010001011\n\nSample Output 2\n\n12\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6000, "cpu_time_ms": 487, "memory_kb": 31188}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s916717311", "group_id": "codeNet:p03107", "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 S = ns()\n val N = S.length\n val zero = S.count(_ == '0')\n val one = S.count(_ == '1')\n val remain = abs(zero - one)\n val ans = N - remain\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 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": 1551643654, "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/s916717311.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s916717311", "user_id": "u460609472"}, "prompt_components": {"gold_output": "4\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 S = ns()\n val N = S.length\n val zero = S.count(_ == '0')\n val one = S.count(_ == '1')\n val remain = abs(zero - one)\n val ans = N - remain\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 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 : 300 points\n\nProblem Statement\n\nThere are N cubes stacked vertically on a desk.\n\nYou are given a string S of length N. The color of the i-th cube from the bottom is red if the i-th character in S is 0, and blue if that character is 1.\n\nYou can perform the following operation any number of times: choose a red cube and a blue cube that are adjacent, and remove them. Here, the cubes that were stacked on the removed cubes will fall down onto the object below them.\n\nAt most how many cubes can be removed?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = N\n\nEach character in S is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of cubes that can be removed.\n\nSample Input 1\n\n0011\n\nSample Output 1\n\n4\n\nAll four cubes can be removed, by performing the operation as follows:\n\nRemove the second and third cubes from the bottom. Then, the fourth cube drops onto the first cube.\n\nRemove the first and second cubes from the bottom.\n\nSample Input 2\n\n11011010001011\n\nSample Output 2\n\n12\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "sample_input": "0011\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03107", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N cubes stacked vertically on a desk.\n\nYou are given a string S of length N. The color of the i-th cube from the bottom is red if the i-th character in S is 0, and blue if that character is 1.\n\nYou can perform the following operation any number of times: choose a red cube and a blue cube that are adjacent, and remove them. Here, the cubes that were stacked on the removed cubes will fall down onto the object below them.\n\nAt most how many cubes can be removed?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = N\n\nEach character in S is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of cubes that can be removed.\n\nSample Input 1\n\n0011\n\nSample Output 1\n\n4\n\nAll four cubes can be removed, by performing the operation as follows:\n\nRemove the second and third cubes from the bottom. Then, the fourth cube drops onto the first cube.\n\nRemove the first and second cubes from the bottom.\n\nSample Input 2\n\n11011010001011\n\nSample Output 2\n\n12\n\nSample Input 3\n\n0\n\nSample Output 3\n\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3008, "cpu_time_ms": 410, "memory_kb": 27400}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s630633629", "group_id": "codeNet:p03109", "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 S = sc.next\n val ymd = S.split(\"/\").map(_.toInt)\n\n if (ymd(0) <= 2019 && ymd(1) <=4 && ymd(2) <= 30) \"Heisei\" else \"TBD\"\n }\n}\n", "language": "Scala", "metadata": {"date": 1551038553, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03109.html", "problem_id": "p03109", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03109/input.txt", "sample_output_relpath": "derived/input_output/data/p03109/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03109/Scala/s630633629.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s630633629", "user_id": "u297767059"}, "prompt_components": {"gold_output": "Heisei\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 S = sc.next\n val ymd = S.split(\"/\").map(_.toInt)\n\n if (ymd(0) <= 2019 && ymd(1) <=4 && ymd(2) <= 30) \"Heisei\" else \"TBD\"\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S as input. This represents a valid date in the year 2019 in the yyyy/mm/dd format. (For example, April 30, 2019 is represented as 2019/04/30.)\n\nWrite a program that prints Heisei if the date represented by S is not later than April 30, 2019, and prints TBD otherwise.\n\nConstraints\n\nS is a string that represents a valid date in the year 2019 in the yyyy/mm/dd format.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint Heisei if the date represented by S is not later than April 30, 2019, and print TBD otherwise.\n\nSample Input 1\n\n2019/04/30\n\nSample Output 1\n\nHeisei\n\nSample Input 2\n\n2019/11/01\n\nSample Output 2\n\nTBD", "sample_input": "2019/04/30\n"}, "reference_outputs": ["Heisei\n"], "source_document_id": "p03109", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S as input. This represents a valid date in the year 2019 in the yyyy/mm/dd format. (For example, April 30, 2019 is represented as 2019/04/30.)\n\nWrite a program that prints Heisei if the date represented by S is not later than April 30, 2019, and prints TBD otherwise.\n\nConstraints\n\nS is a string that represents a valid date in the year 2019 in the yyyy/mm/dd format.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint Heisei if the date represented by S is not later than April 30, 2019, and print TBD otherwise.\n\nSample Input 1\n\n2019/04/30\n\nSample Output 1\n\nHeisei\n\nSample Input 2\n\n2019/11/01\n\nSample Output 2\n\nTBD", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 346, "memory_kb": 25804}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s077780324", "group_id": "codeNet:p03111", "input_text": "import java.util.Scanner\n\nobject Main {\n val sc = new Scanner(System.in)\n def main(args: Array[String]): Unit = {\n\n\n val n = sc.nextInt\n val iSeq = Seq(sc.nextInt, sc.nextInt, sc.nextInt)\n\n val ll = List.fill(n)(sc.nextInt)\n\n val target = (1 to Math.pow(4,n).toInt).toArray.map{l => s\"%0${n}d\".format(l_adic(l,4).mkString.toInt)}.filter{s => s.contains('1') && s.contains('2') && s.contains('3')}\n\n val res =\n target.foldLeft(Int.MaxValue){ case (min, str) =>\n val temp = str zip ll\n val sum = temp.toArray.filter(t => t._1 != '0').foldLeft( Array((0,0),(0,0),(0,0)) ){case (arr, (i,num)) =>\n i match{\n case '1' => val x = arr(0); arr.update(0, (x._1 + num, x._2 + 1) ) ; arr\n case '2' => val x = arr(1); arr.update(1, (x._1 + num, x._2 + 1) ) ; arr\n case '3' => val x = arr(2); arr.update(2, (x._1 + num, x._2 + 1) ) ; arr\n }\n }\n val sumSeq = sum.map(_._1).toSeq\n val jointNum = sum.map(_._2 - 1).sum\n if( sumSeq.count(_ == 0 ) > 0) min\n else {\n Math.min( (sumSeq zip iSeq).map(t => Math.abs(t._1 - t._2)).sum + 10 * jointNum, min)\n }\n }\n println(res)\n }\n\n def l_adic(n: Int, l: Int): List[Int] ={\n def loop(m: Int, acc: List[Int]): List[Int] ={\n m match {\n case 0 => acc\n case x => loop( x / l, (x % l) +: acc)\n }\n }\n loop(n,List.empty[Int])\n }\n}", "language": "Scala", "metadata": {"date": 1555514254, "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/s077780324.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s077780324", "user_id": "u829407811"}, "prompt_components": {"gold_output": "23\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\n\n val n = sc.nextInt\n val iSeq = Seq(sc.nextInt, sc.nextInt, sc.nextInt)\n\n val ll = List.fill(n)(sc.nextInt)\n\n val target = (1 to Math.pow(4,n).toInt).toArray.map{l => s\"%0${n}d\".format(l_adic(l,4).mkString.toInt)}.filter{s => s.contains('1') && s.contains('2') && s.contains('3')}\n\n val res =\n target.foldLeft(Int.MaxValue){ case (min, str) =>\n val temp = str zip ll\n val sum = temp.toArray.filter(t => t._1 != '0').foldLeft( Array((0,0),(0,0),(0,0)) ){case (arr, (i,num)) =>\n i match{\n case '1' => val x = arr(0); arr.update(0, (x._1 + num, x._2 + 1) ) ; arr\n case '2' => val x = arr(1); arr.update(1, (x._1 + num, x._2 + 1) ) ; arr\n case '3' => val x = arr(2); arr.update(2, (x._1 + num, x._2 + 1) ) ; arr\n }\n }\n val sumSeq = sum.map(_._1).toSeq\n val jointNum = sum.map(_._2 - 1).sum\n if( sumSeq.count(_ == 0 ) > 0) min\n else {\n Math.min( (sumSeq zip iSeq).map(t => Math.abs(t._1 - t._2)).sum + 10 * jointNum, min)\n }\n }\n println(res)\n }\n\n def l_adic(n: Int, l: Int): List[Int] ={\n def loop(m: Int, acc: List[Int]): List[Int] ={\n m match {\n case 0 => acc\n case x => loop( x / l, (x % l) +: acc)\n }\n }\n loop(n,List.empty[Int])\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou have N bamboos. The lengths (in centimeters) of these are l_1, l_2, ..., l_N, respectively.\n\nYour objective is to use some of these bamboos (possibly all) to obtain three bamboos of length A, B, C. For that, you can use the following three kinds of magics any number:\n\nExtension Magic: Consumes 1 MP (magic point). Choose one bamboo and increase its length by 1.\n\nShortening Magic: Consumes 1 MP. Choose one bamboo of length at least 2 and decrease its length by 1.\n\nComposition Magic: Consumes 10 MP. Choose two bamboos and combine them into one bamboo. The length of this new bamboo is equal to the sum of the lengths of the two bamboos combined. (Afterwards, further magics can be used on this bamboo.)\n\nAt least how much MP is needed to achieve the objective?\n\nConstraints\n\n3 \\leq N \\leq 8\n\n1 \\leq C < B < A \\leq 1000\n\n1 \\leq l_i \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C\nl_1\nl_2\n:\nl_N\n\nOutput\n\nPrint the minimum amount of MP needed to achieve the objective.\n\nSample Input 1\n\n5 100 90 80\n98\n40\n30\n21\n80\n\nSample Output 1\n\n23\n\nWe are obtaining three bamboos of lengths 100, 90, 80 from five bamboos 98, 40, 30, 21, 80. We already have a bamboo of length 80, and we can obtain bamboos of lengths 100, 90 by using the magics as follows at the total cost of 23 MP, which is optimal.\n\nUse Extension Magic twice on the bamboo of length 98 to obtain a bamboo of length 100. (MP consumed: 2)\n\nUse Composition Magic on the bamboos of lengths 40, 30 to obtain a bamboo of length 70. (MP consumed: 10)\n\nUse Shortening Magic once on the bamboo of length 21 to obtain a bamboo of length 20. (MP consumed: 1)\n\nUse Composition Magic on the bamboo of length 70 obtained in step 2 and the bamboo of length 20 obtained in step 3 to obtain a bamboo of length 90. (MP consumed: 10)\n\nSample Input 2\n\n8 100 90 80\n100\n100\n90\n90\n90\n80\n80\n80\n\nSample Output 2\n\n0\n\nIf we already have all bamboos of the desired lengths, the amount of MP needed is 0. As seen here, we do not necessarily need to use all the bamboos.\n\nSample Input 3\n\n8 1000 800 100\n300\n333\n400\n444\n500\n555\n600\n666\n\nSample Output 3\n\n243", "sample_input": "5 100 90 80\n98\n40\n30\n21\n80\n"}, "reference_outputs": ["23\n"], "source_document_id": "p03111", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou have N bamboos. The lengths (in centimeters) of these are l_1, l_2, ..., l_N, respectively.\n\nYour objective is to use some of these bamboos (possibly all) to obtain three bamboos of length A, B, C. For that, you can use the following three kinds of magics any number:\n\nExtension Magic: Consumes 1 MP (magic point). Choose one bamboo and increase its length by 1.\n\nShortening Magic: Consumes 1 MP. Choose one bamboo of length at least 2 and decrease its length by 1.\n\nComposition Magic: Consumes 10 MP. Choose two bamboos and combine them into one bamboo. The length of this new bamboo is equal to the sum of the lengths of the two bamboos combined. (Afterwards, further magics can be used on this bamboo.)\n\nAt least how much MP is needed to achieve the objective?\n\nConstraints\n\n3 \\leq N \\leq 8\n\n1 \\leq C < B < A \\leq 1000\n\n1 \\leq l_i \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C\nl_1\nl_2\n:\nl_N\n\nOutput\n\nPrint the minimum amount of MP needed to achieve the objective.\n\nSample Input 1\n\n5 100 90 80\n98\n40\n30\n21\n80\n\nSample Output 1\n\n23\n\nWe are obtaining three bamboos of lengths 100, 90, 80 from five bamboos 98, 40, 30, 21, 80. We already have a bamboo of length 80, and we can obtain bamboos of lengths 100, 90 by using the magics as follows at the total cost of 23 MP, which is optimal.\n\nUse Extension Magic twice on the bamboo of length 98 to obtain a bamboo of length 100. (MP consumed: 2)\n\nUse Composition Magic on the bamboos of lengths 40, 30 to obtain a bamboo of length 70. (MP consumed: 10)\n\nUse Shortening Magic once on the bamboo of length 21 to obtain a bamboo of length 20. (MP consumed: 1)\n\nUse Composition Magic on the bamboo of length 70 obtained in step 2 and the bamboo of length 20 obtained in step 3 to obtain a bamboo of length 90. (MP consumed: 10)\n\nSample Input 2\n\n8 100 90 80\n100\n100\n90\n90\n90\n80\n80\n80\n\nSample Output 2\n\n0\n\nIf we already have all bamboos of the desired lengths, the amount of MP needed is 0. As seen here, we do not necessarily need to use all the bamboos.\n\nSample Input 3\n\n8 1000 800 100\n300\n333\n400\n444\n500\n555\n600\n666\n\nSample Output 3\n\n243", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1430, "cpu_time_ms": 2116, "memory_kb": 118256}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s702947592", "group_id": "codeNet:p03125", "input_text": "\nobject Main extends App {\n val AB = io.StdIn.readLine.split(' ')\n val A = AB.head.toInt\n val B = AB.last.toInt\n\n val out = B % A match {\n case 0 => B + A\n case _ => B - A\n }\n\n println(out)\n}\n", "language": "Scala", "metadata": {"date": 1556230409, "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/s702947592.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s702947592", "user_id": "u620456020"}, "prompt_components": {"gold_output": "16\n", "input_to_evaluate": "\nobject Main extends App {\n val AB = io.StdIn.readLine.split(' ')\n val A = AB.head.toInt\n val B = AB.last.toInt\n\n val out = B % A match {\n case 0 => B + A\n case _ => B - A\n }\n\n println(out)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given positive integers A and B.\n\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\nSample Input 1\n\n4 12\n\nSample Output 1\n\n16\n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\nSample Input 2\n\n8 20\n\nSample Output 2\n\n12\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n2\n\n1 is a divisor of 1.", "sample_input": "4 12\n"}, "reference_outputs": ["16\n"], "source_document_id": "p03125", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given positive integers A and B.\n\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\nSample Input 1\n\n4 12\n\nSample Output 1\n\n16\n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\nSample Input 2\n\n8 20\n\nSample Output 2\n\n12\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n2\n\n1 is a divisor of 1.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 204, "cpu_time_ms": 329, "memory_kb": 27312}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s468530978", "group_id": "codeNet:p03125", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val a, b = sc.nextInt\n\n val ans = {\n if (b % a == 0) a + b\n else b - a\n }\n \n println(ans)\n}\n", "language": "Scala", "metadata": {"date": 1551569364, "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/s468530978.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s468530978", "user_id": "u837225517"}, "prompt_components": {"gold_output": "16\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 ans = {\n if (b % a == 0) a + b\n else b - a\n }\n \n println(ans)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given positive integers A and B.\n\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\nSample Input 1\n\n4 12\n\nSample Output 1\n\n16\n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\nSample Input 2\n\n8 20\n\nSample Output 2\n\n12\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n2\n\n1 is a divisor of 1.", "sample_input": "4 12\n"}, "reference_outputs": ["16\n"], "source_document_id": "p03125", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given positive integers A and B.\n\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\nSample Input 1\n\n4 12\n\nSample Output 1\n\n16\n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\nSample Input 2\n\n8 20\n\nSample Output 2\n\n12\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n2\n\n1 is a divisor of 1.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 174, "cpu_time_ms": 349, "memory_kb": 25804}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s821166033", "group_id": "codeNet:p03126", "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, m = sc.nextInt\n// val b = sc.nextInt\n// val a = List.fill(n)(sc.nextInt)\n// val b = List.fill(m)(sc.nextInt)\n// val c = List.fill(n - 1)(sc.nextInt)\n// val list = List.fill(n, 2)(sc.next)\n\n val a = (1 to n).foldLeft(Seq.empty[Seq[Int]]){ case (acc, _) =>\n val k = sc.nextInt\n acc :+ List.fill(k)(sc.nextInt)\n }.flatten\n\n val ans = a.groupBy(identity).foldLeft(0){ case (acc, in) => if (in._2.size == n) acc + 1 else acc }\n\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": 1575866611, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03126.html", "problem_id": "p03126", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03126/input.txt", "sample_output_relpath": "derived/input_output/data/p03126/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03126/Scala/s821166033.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s821166033", "user_id": "u040380439"}, "prompt_components": {"gold_output": "1\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, m = sc.nextInt\n// val b = sc.nextInt\n// val a = List.fill(n)(sc.nextInt)\n// val b = List.fill(m)(sc.nextInt)\n// val c = List.fill(n - 1)(sc.nextInt)\n// val list = List.fill(n, 2)(sc.next)\n\n val a = (1 to n).foldLeft(Seq.empty[Seq[Int]]){ case (acc, _) =>\n val k = sc.nextInt\n acc :+ List.fill(k)(sc.nextInt)\n }.flatten\n\n val ans = a.groupBy(identity).foldLeft(0){ case (acc, in) => if (in._2.size == n) acc + 1 else acc }\n\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 : 200 points\n\nProblem Statement\n\nKatsusando loves omelette rice.\n\nBesides, he loves crème brûlée, tenderloin steak and so on, and believes that these foods are all loved by everyone.\n\nTo prove that hypothesis, he conducted a survey on M kinds of foods and asked N people whether they like these foods or not.\n\nThe i-th person answered that he/she only likes the A_{i1}-th, A_{i2}-th, ..., A_{iK_i}-th food.\n\nFind the number of the foods liked by all the N people.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 30\n\n1 \\leq K_i \\leq M\n\n1 \\leq A_{ij} \\leq M\n\nFor each i (1 \\leq i \\leq N), A_{i1}, A_{i2}, ..., A_{iK_i} are distinct.\n\nConstraints\n\nInput is given from Standard Input in the following format:\n\nN M\nK_1 A_{11} A_{12} ... A_{1K_1}\nK_2 A_{21} A_{22} ... A_{2K_2}\n:\nK_N A_{N1} A_{N2} ... A_{NK_N}\n\nOutput\n\nPrint the number of the foods liked by all the N people.\n\nSample Input 1\n\n3 4\n2 1 3\n3 1 2 3\n2 3 2\n\nSample Output 1\n\n1\n\nAs only the third food is liked by all the three people, 1 should be printed.\n\nSample Input 2\n\n5 5\n4 2 3 4 5\n4 1 3 4 5\n4 1 2 4 5\n4 1 2 3 5\n4 1 2 3 4\n\nSample Output 2\n\n0\n\nKatsusando's hypothesis turned out to be wrong.\n\nSample Input 3\n\n1 30\n3 5 10 30\n\nSample Output 3\n\n3", "sample_input": "3 4\n2 1 3\n3 1 2 3\n2 3 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03126", "source_text": "Score : 200 points\n\nProblem Statement\n\nKatsusando loves omelette rice.\n\nBesides, he loves crème brûlée, tenderloin steak and so on, and believes that these foods are all loved by everyone.\n\nTo prove that hypothesis, he conducted a survey on M kinds of foods and asked N people whether they like these foods or not.\n\nThe i-th person answered that he/she only likes the A_{i1}-th, A_{i2}-th, ..., A_{iK_i}-th food.\n\nFind the number of the foods liked by all the N people.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 30\n\n1 \\leq K_i \\leq M\n\n1 \\leq A_{ij} \\leq M\n\nFor each i (1 \\leq i \\leq N), A_{i1}, A_{i2}, ..., A_{iK_i} are distinct.\n\nConstraints\n\nInput is given from Standard Input in the following format:\n\nN M\nK_1 A_{11} A_{12} ... A_{1K_1}\nK_2 A_{21} A_{22} ... A_{2K_2}\n:\nK_N A_{N1} A_{N2} ... A_{NK_N}\n\nOutput\n\nPrint the number of the foods liked by all the N people.\n\nSample Input 1\n\n3 4\n2 1 3\n3 1 2 3\n2 3 2\n\nSample Output 1\n\n1\n\nAs only the third food is liked by all the three people, 1 should be printed.\n\nSample Input 2\n\n5 5\n4 2 3 4 5\n4 1 3 4 5\n4 1 2 4 5\n4 1 2 3 5\n4 1 2 3 4\n\nSample Output 2\n\n0\n\nKatsusando's hypothesis turned out to be wrong.\n\nSample Input 3\n\n1 30\n3 5 10 30\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1350, "cpu_time_ms": 430, "memory_kb": 169548}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s256797865", "group_id": "codeNet:p03126", "input_text": "object Main{\n\tdef main(A:Array[String]){\n\t\tval s = new java.util.Scanner(System.in)\n\t\tval n = s.nextInt\n\t\tval a = new Array[Int](s.nextInt)\n\t\t(1 to n).flatMap(_ => 1 to s.nextInt).foreach(_=>a(s.nextInt-1)+=1)\n\t\tprintln(a.count(i=>i==n))\n\t}\n}", "language": "Scala", "metadata": {"date": 1550377527, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03126.html", "problem_id": "p03126", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03126/input.txt", "sample_output_relpath": "derived/input_output/data/p03126/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03126/Scala/s256797865.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s256797865", "user_id": "u059234158"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main{\n\tdef main(A:Array[String]){\n\t\tval s = new java.util.Scanner(System.in)\n\t\tval n = s.nextInt\n\t\tval a = new Array[Int](s.nextInt)\n\t\t(1 to n).flatMap(_ => 1 to s.nextInt).foreach(_=>a(s.nextInt-1)+=1)\n\t\tprintln(a.count(i=>i==n))\n\t}\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nKatsusando loves omelette rice.\n\nBesides, he loves crème brûlée, tenderloin steak and so on, and believes that these foods are all loved by everyone.\n\nTo prove that hypothesis, he conducted a survey on M kinds of foods and asked N people whether they like these foods or not.\n\nThe i-th person answered that he/she only likes the A_{i1}-th, A_{i2}-th, ..., A_{iK_i}-th food.\n\nFind the number of the foods liked by all the N people.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 30\n\n1 \\leq K_i \\leq M\n\n1 \\leq A_{ij} \\leq M\n\nFor each i (1 \\leq i \\leq N), A_{i1}, A_{i2}, ..., A_{iK_i} are distinct.\n\nConstraints\n\nInput is given from Standard Input in the following format:\n\nN M\nK_1 A_{11} A_{12} ... A_{1K_1}\nK_2 A_{21} A_{22} ... A_{2K_2}\n:\nK_N A_{N1} A_{N2} ... A_{NK_N}\n\nOutput\n\nPrint the number of the foods liked by all the N people.\n\nSample Input 1\n\n3 4\n2 1 3\n3 1 2 3\n2 3 2\n\nSample Output 1\n\n1\n\nAs only the third food is liked by all the three people, 1 should be printed.\n\nSample Input 2\n\n5 5\n4 2 3 4 5\n4 1 3 4 5\n4 1 2 4 5\n4 1 2 3 5\n4 1 2 3 4\n\nSample Output 2\n\n0\n\nKatsusando's hypothesis turned out to be wrong.\n\nSample Input 3\n\n1 30\n3 5 10 30\n\nSample Output 3\n\n3", "sample_input": "3 4\n2 1 3\n3 1 2 3\n2 3 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03126", "source_text": "Score : 200 points\n\nProblem Statement\n\nKatsusando loves omelette rice.\n\nBesides, he loves crème brûlée, tenderloin steak and so on, and believes that these foods are all loved by everyone.\n\nTo prove that hypothesis, he conducted a survey on M kinds of foods and asked N people whether they like these foods or not.\n\nThe i-th person answered that he/she only likes the A_{i1}-th, A_{i2}-th, ..., A_{iK_i}-th food.\n\nFind the number of the foods liked by all the N people.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 30\n\n1 \\leq K_i \\leq M\n\n1 \\leq A_{ij} \\leq M\n\nFor each i (1 \\leq i \\leq N), A_{i1}, A_{i2}, ..., A_{iK_i} are distinct.\n\nConstraints\n\nInput is given from Standard Input in the following format:\n\nN M\nK_1 A_{11} A_{12} ... A_{1K_1}\nK_2 A_{21} A_{22} ... A_{2K_2}\n:\nK_N A_{N1} A_{N2} ... A_{NK_N}\n\nOutput\n\nPrint the number of the foods liked by all the N people.\n\nSample Input 1\n\n3 4\n2 1 3\n3 1 2 3\n2 3 2\n\nSample Output 1\n\n1\n\nAs only the third food is liked by all the three people, 1 should be printed.\n\nSample Input 2\n\n5 5\n4 2 3 4 5\n4 1 3 4 5\n4 1 2 4 5\n4 1 2 3 5\n4 1 2 3 4\n\nSample Output 2\n\n0\n\nKatsusando's hypothesis turned out to be wrong.\n\nSample Input 3\n\n1 30\n3 5 10 30\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 242, "cpu_time_ms": 364, "memory_kb": 27812}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s759467695", "group_id": "codeNet:p03126", "input_text": "import java.util.Scanner\n\nobject Main{\n val sc = new Scanner(System.in)\n def main(args: Array[String]): Unit ={\n\n val n = sc.nextInt\n val m = sc.nextInt\n\n\n val l = (1 to n).foldLeft(List.empty[List[Int]]) {(seq, i) =>\n val k = sc.nextInt\n seq :+ List.fill(k)(sc.nextInt)\n }\n\n val c = l.foldLeft((1 to m).toList)( _ intersect _)\n\n println(c.size)\n\n }\n\n}", "language": "Scala", "metadata": {"date": 1550370630, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03126.html", "problem_id": "p03126", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03126/input.txt", "sample_output_relpath": "derived/input_output/data/p03126/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03126/Scala/s759467695.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s759467695", "user_id": "u829407811"}, "prompt_components": {"gold_output": "1\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\n val n = sc.nextInt\n val m = sc.nextInt\n\n\n val l = (1 to n).foldLeft(List.empty[List[Int]]) {(seq, i) =>\n val k = sc.nextInt\n seq :+ List.fill(k)(sc.nextInt)\n }\n\n val c = l.foldLeft((1 to m).toList)( _ intersect _)\n\n println(c.size)\n\n }\n\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nKatsusando loves omelette rice.\n\nBesides, he loves crème brûlée, tenderloin steak and so on, and believes that these foods are all loved by everyone.\n\nTo prove that hypothesis, he conducted a survey on M kinds of foods and asked N people whether they like these foods or not.\n\nThe i-th person answered that he/she only likes the A_{i1}-th, A_{i2}-th, ..., A_{iK_i}-th food.\n\nFind the number of the foods liked by all the N people.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 30\n\n1 \\leq K_i \\leq M\n\n1 \\leq A_{ij} \\leq M\n\nFor each i (1 \\leq i \\leq N), A_{i1}, A_{i2}, ..., A_{iK_i} are distinct.\n\nConstraints\n\nInput is given from Standard Input in the following format:\n\nN M\nK_1 A_{11} A_{12} ... A_{1K_1}\nK_2 A_{21} A_{22} ... A_{2K_2}\n:\nK_N A_{N1} A_{N2} ... A_{NK_N}\n\nOutput\n\nPrint the number of the foods liked by all the N people.\n\nSample Input 1\n\n3 4\n2 1 3\n3 1 2 3\n2 3 2\n\nSample Output 1\n\n1\n\nAs only the third food is liked by all the three people, 1 should be printed.\n\nSample Input 2\n\n5 5\n4 2 3 4 5\n4 1 3 4 5\n4 1 2 4 5\n4 1 2 3 5\n4 1 2 3 4\n\nSample Output 2\n\n0\n\nKatsusando's hypothesis turned out to be wrong.\n\nSample Input 3\n\n1 30\n3 5 10 30\n\nSample Output 3\n\n3", "sample_input": "3 4\n2 1 3\n3 1 2 3\n2 3 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03126", "source_text": "Score : 200 points\n\nProblem Statement\n\nKatsusando loves omelette rice.\n\nBesides, he loves crème brûlée, tenderloin steak and so on, and believes that these foods are all loved by everyone.\n\nTo prove that hypothesis, he conducted a survey on M kinds of foods and asked N people whether they like these foods or not.\n\nThe i-th person answered that he/she only likes the A_{i1}-th, A_{i2}-th, ..., A_{iK_i}-th food.\n\nFind the number of the foods liked by all the N people.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 30\n\n1 \\leq K_i \\leq M\n\n1 \\leq A_{ij} \\leq M\n\nFor each i (1 \\leq i \\leq N), A_{i1}, A_{i2}, ..., A_{iK_i} are distinct.\n\nConstraints\n\nInput is given from Standard Input in the following format:\n\nN M\nK_1 A_{11} A_{12} ... A_{1K_1}\nK_2 A_{21} A_{22} ... A_{2K_2}\n:\nK_N A_{N1} A_{N2} ... A_{NK_N}\n\nOutput\n\nPrint the number of the foods liked by all the N people.\n\nSample Input 1\n\n3 4\n2 1 3\n3 1 2 3\n2 3 2\n\nSample Output 1\n\n1\n\nAs only the third food is liked by all the three people, 1 should be printed.\n\nSample Input 2\n\n5 5\n4 2 3 4 5\n4 1 3 4 5\n4 1 2 4 5\n4 1 2 3 5\n4 1 2 3 4\n\nSample Output 2\n\n0\n\nKatsusando's hypothesis turned out to be wrong.\n\nSample Input 3\n\n1 30\n3 5 10 30\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 396, "memory_kb": 27692}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s899836287", "group_id": "codeNet:p03136", "input_text": "object Main extends App {\n val in = scala.io.Source.stdin.getLines.toSeq\n val ls = in.tail.head.split(' ').map(_.toLong).toArray\n val s = ls.sorted.reverse\n val longest = s.head\n val others = s.tail.sum\n val ret = if(longest < others) \"YES\" else \"NO\"\n println(ret)\n}\n", "language": "Scala", "metadata": {"date": 1549246138, "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/s899836287.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s899836287", "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.tail.head.split(' ').map(_.toLong).toArray\n val s = ls.sorted.reverse\n val longest = s.head\n val others = s.tail.sum\n val ret = if(longest < others) \"YES\" else \"NO\"\n println(ret)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 331, "memory_kb": 27320}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s464288044", "group_id": "codeNet:p03137", "input_text": "import scala.io.StdIn._\n\nobject Main extends App {\n\n val Array(n,m) = readLine().split(\" \").map(_.toInt)\n val X = readLine().split(\" \").map(_.toLong)\n\n def solve() = {\n val sorted = X.sorted\n (0 until m-1).map { i =>\n sorted(i+1) - sorted(i)\n }.sorted(Ordering[Long].reverse).drop(n-1).sum\n }\n\n println(solve())\n\n}\n\n", "language": "Scala", "metadata": {"date": 1596169796, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/s464288044.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s464288044", "user_id": "u947008426"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main extends App {\n\n val Array(n,m) = readLine().split(\" \").map(_.toInt)\n val X = readLine().split(\" \").map(_.toLong)\n\n def solve() = {\n val sorted = X.sorted\n (0 until m-1).map { i =>\n sorted(i+1) - sorted(i)\n }.sorted(Ordering[Long].reverse).drop(n-1).sum\n }\n\n println(solve())\n\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 731, "memory_kb": 65464}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s023501133", "group_id": "codeNet:p03140", "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.nextInt\n sc.nextLine\n val ABC = Array.fill(3)(sc.nextLine)\n\n var n = 0\n for (i <- 0 until N) {\n if (ABC(0)(i) != ABC(1)(i)) {\n n += 1\n }\n if (ABC(0)(i) != ABC(2)(i) && ABC(1)(i) != ABC(2)(i)) {\n n += 1\n }\n }\n n.toString\n }\n}\n", "language": "Scala", "metadata": {"date": 1548641402, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03140.html", "problem_id": "p03140", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03140/input.txt", "sample_output_relpath": "derived/input_output/data/p03140/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03140/Scala/s023501133.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s023501133", "user_id": "u297767059"}, "prompt_components": {"gold_output": "3\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.nextInt\n sc.nextLine\n val ABC = Array.fill(3)(sc.nextLine)\n\n var n = 0\n for (i <- 0 until N) {\n if (ABC(0)(i) != ABC(1)(i)) {\n n += 1\n }\n if (ABC(0)(i) != ABC(2)(i) && ABC(1)(i) != ABC(2)(i)) {\n n += 1\n }\n }\n n.toString\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters.\n\nOur objective is to make all these three strings equal. For that, you can repeatedly perform the following operation:\n\nOperation: Choose one of the strings A, B and C, and specify an integer i between 1 and N (inclusive). Change the i-th character from the beginning of the chosen string to some other lowercase English letter.\n\nWhat is the minimum number of operations required to achieve the objective?\n\nConstraints\n\n1 \\leq N \\leq 100\n\nEach of the strings A, B and C is a string of length N.\n\nEach character in each of the strings A, B and C is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\nB\nC\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4\nwest\neast\nwait\n\nSample Output 1\n\n3\n\nIn this sample, initially A = west、B = east、C = wait. We can achieve the objective in the minimum number of operations by performing three operations as follows:\n\nChange the second character in A to a. A is now wast.\n\nChange the first character in B to w. B is now wast.\n\nChange the third character in C to s. C is now wast.\n\nSample Input 2\n\n9\ndifferent\ndifferent\ndifferent\n\nSample Output 2\n\n0\n\nIf A, B and C are already equal in the beginning, the number of operations required is 0.\n\nSample Input 3\n\n7\nzenkoku\ntouitsu\nprogram\n\nSample Output 3\n\n13", "sample_input": "4\nwest\neast\nwait\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03140", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters.\n\nOur objective is to make all these three strings equal. For that, you can repeatedly perform the following operation:\n\nOperation: Choose one of the strings A, B and C, and specify an integer i between 1 and N (inclusive). Change the i-th character from the beginning of the chosen string to some other lowercase English letter.\n\nWhat is the minimum number of operations required to achieve the objective?\n\nConstraints\n\n1 \\leq N \\leq 100\n\nEach of the strings A, B and C is a string of length N.\n\nEach character in each of the strings A, B and C is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\nB\nC\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4\nwest\neast\nwait\n\nSample Output 1\n\n3\n\nIn this sample, initially A = west、B = east、C = wait. We can achieve the objective in the minimum number of operations by performing three operations as follows:\n\nChange the second character in A to a. A is now wast.\n\nChange the first character in B to w. B is now wast.\n\nChange the third character in C to s. C is now wast.\n\nSample Input 2\n\n9\ndifferent\ndifferent\ndifferent\n\nSample Output 2\n\n0\n\nIf A, B and C are already equal in the beginning, the number of operations required is 0.\n\nSample Input 3\n\n7\nzenkoku\ntouitsu\nprogram\n\nSample Output 3\n\n13", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 557, "cpu_time_ms": 337, "memory_kb": 27220}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s397024371", "group_id": "codeNet:p03142", "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 import java.util\n val N, M = ni()\n val (from, to) = na2(N - 1 + M ,-1)\n\n // ルートはかならずtoに現れない\n val flg = Array.ofDim[Boolean](N)\n REP(from.length) { i =>\n flg(to(i)) = true\n }\n val rt = flg.indexWhere(!_)\n// debug(rt.toString)\n\n val g = packDGraph(N, from, to)\n\n // 子供へのショートカットしかないので最大距離 == 木の上での深さになる\n // DFSしないと再計算がおこる\n // (depth, parents)\n def calcMaxDepth: (Array[Int], Array[Int]) = {\n val d = Array.ofDim[Int](N)\n val p = Array.ofDim[Int](N)\n\n val stack = mutable.Stack[Int]()\n val ix = Array.ofDim[Int](N)\n\n def visit(u: Int, v: Int): Unit = {\n if (d(v) + 1 > d(u)) {\n p(u) = v\n d(u) = d(v) + 1\n stack.push(u)\n }\n }\n\n visit(rt, 0)\n debug(d)\n debug(p)\n while(stack.nonEmpty) {\n val v = stack.top\n val es = g(v)\n if (ix(v) == es.length) stack.pop()\n else {\n val u = es(ix(v))\n visit(u, v)\n ix(v) += 1\n }\n }\n\n (d, p)\n }\n\n val (d, p) = calcMaxDepth\n debug(d)\n debug(p)\n\n REP(N) { i =>\n if (i == rt) out.println(0)\n else out.println(p(i) + 1)\n }\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 /**\n * @return (depth, parent, queue)\n */\n def traceBfs(g: Array[Array[Int]], rt: Int = 0): (Array[Int], Array[Int], Array[Int]) = {\n val n = g.length\n val INF = 1e9.toInt + 10\n val q, p = Array.ofDim[Int](n)\n q(0) = rt\n p(rt) = -1\n val d = Array.fill[Int](n)(INF)\n d(rt) = 0\n var cur = 0\n var last = 1\n while (cur < last) {\n val v = q(cur)\n REP(g(v).length) { i =>\n val u = g(v)(i)\n if (d(u) == INF) {\n d(u) = d(v) + 1\n p(u) = v\n q(last) = u\n last += 1\n }\n }\n cur += 1\n }\n (d, p, q)\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}\n", "language": "Scala", "metadata": {"date": 1548647826, "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/s397024371.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s397024371", "user_id": "u460609472"}, "prompt_components": {"gold_output": "0\n1\n2\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 import java.util\n val N, M = ni()\n val (from, to) = na2(N - 1 + M ,-1)\n\n // ルートはかならずtoに現れない\n val flg = Array.ofDim[Boolean](N)\n REP(from.length) { i =>\n flg(to(i)) = true\n }\n val rt = flg.indexWhere(!_)\n// debug(rt.toString)\n\n val g = packDGraph(N, from, to)\n\n // 子供へのショートカットしかないので最大距離 == 木の上での深さになる\n // DFSしないと再計算がおこる\n // (depth, parents)\n def calcMaxDepth: (Array[Int], Array[Int]) = {\n val d = Array.ofDim[Int](N)\n val p = Array.ofDim[Int](N)\n\n val stack = mutable.Stack[Int]()\n val ix = Array.ofDim[Int](N)\n\n def visit(u: Int, v: Int): Unit = {\n if (d(v) + 1 > d(u)) {\n p(u) = v\n d(u) = d(v) + 1\n stack.push(u)\n }\n }\n\n visit(rt, 0)\n debug(d)\n debug(p)\n while(stack.nonEmpty) {\n val v = stack.top\n val es = g(v)\n if (ix(v) == es.length) stack.pop()\n else {\n val u = es(ix(v))\n visit(u, v)\n ix(v) += 1\n }\n }\n\n (d, p)\n }\n\n val (d, p) = calcMaxDepth\n debug(d)\n debug(p)\n\n REP(N) { i =>\n if (i == rt) out.println(0)\n else out.println(p(i) + 1)\n }\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 /**\n * @return (depth, parent, queue)\n */\n def traceBfs(g: Array[Array[Int]], rt: Int = 0): (Array[Int], Array[Int], Array[Int]) = {\n val n = g.length\n val INF = 1e9.toInt + 10\n val q, p = Array.ofDim[Int](n)\n q(0) = rt\n p(rt) = -1\n val d = Array.fill[Int](n)(INF)\n d(rt) = 0\n var cur = 0\n var last = 1\n while (cur < last) {\n val v = q(cur)\n REP(g(v).length) { i =>\n val u = g(v)(i)\n if (d(u) == INF) {\n d(u) = d(v) + 1\n p(u) = v\n q(last) = u\n last += 1\n }\n }\n cur += 1\n }\n (d, p, q)\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}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5029, "cpu_time_ms": 960, "memory_kb": 56460}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s805255625", "group_id": "codeNet:p03142", "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 import java.util\n val N, M = ni()\n val (from, to) = na2(N - 1 + M ,-1)\n\n // ルートはかならずtoに現れない\n val flg = Array.ofDim[Boolean](N)\n REP(from.length) { i =>\n flg(to(i)) = true\n }\n val rt = flg.indexWhere(!_)\n debug(rt.toString)\n\n val g = packDGraph(N, from, to)\n\n // 子供へのショートカットしかないので最大距離 == 木の上での深さになる\n def calcMaxDepth: Array[Int] = {\n val d = Array.ofDim[Int](N)\n val queue = new java.util.ArrayDeque[Int]()\n def visit(v: Int): Unit = {\n g(v).foreach { u =>\n if (d(v) + 1 > d(u)) {\n d(u) = d(v) + 1\n queue.add(u)\n }\n }\n }\n visit(rt)\n\n while(!queue.isEmpty) {\n val v = queue.poll()\n visit(v)\n }\n\n d\n }\n\n val d: Array[Int] = calcMaxDepth\n debug(d)\n\n case class Visit(parent: Int, v: Int)\n val queue = new util.ArrayDeque[Visit]()\n val p = Array.ofDim[Int](N)\n\n def addChildren(v: Int, parent: Int): Unit = {\n p(v) = parent\n g(v).foreach { u =>\n queue.add(Visit(v, u))\n }\n }\n\n addChildren(rt, -1)\n while(!queue.isEmpty) {\n val v = queue.poll()\n if (d(v.parent) + 1 == d(v.v)) {\n addChildren(v.v, v.parent)\n }\n }\n\n debug(p)\n\n REP(N) { i =>\n if (i == rt) out.println(0)\n else out.println(p(i) + 1)\n }\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 /**\n * @return (depth, parent, queue)\n */\n def traceBfs(g: Array[Array[Int]], rt: Int = 0): (Array[Int], Array[Int], Array[Int]) = {\n val n = g.length\n val INF = 1e9.toInt + 10\n val q, p = Array.ofDim[Int](n)\n q(0) = rt\n p(rt) = -1\n val d = Array.fill[Int](n)(INF)\n d(rt) = 0\n var cur = 0\n var last = 1\n while (cur < last) {\n val v = q(cur)\n REP(g(v).length) { i =>\n val u = g(v)(i)\n if (d(u) == INF) {\n d(u) = d(v) + 1\n p(u) = v\n q(last) = u\n last += 1\n }\n }\n cur += 1\n }\n (d, p, q)\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": 1548645496, "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/s805255625.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s805255625", "user_id": "u460609472"}, "prompt_components": {"gold_output": "0\n1\n2\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 import java.util\n val N, M = ni()\n val (from, to) = na2(N - 1 + M ,-1)\n\n // ルートはかならずtoに現れない\n val flg = Array.ofDim[Boolean](N)\n REP(from.length) { i =>\n flg(to(i)) = true\n }\n val rt = flg.indexWhere(!_)\n debug(rt.toString)\n\n val g = packDGraph(N, from, to)\n\n // 子供へのショートカットしかないので最大距離 == 木の上での深さになる\n def calcMaxDepth: Array[Int] = {\n val d = Array.ofDim[Int](N)\n val queue = new java.util.ArrayDeque[Int]()\n def visit(v: Int): Unit = {\n g(v).foreach { u =>\n if (d(v) + 1 > d(u)) {\n d(u) = d(v) + 1\n queue.add(u)\n }\n }\n }\n visit(rt)\n\n while(!queue.isEmpty) {\n val v = queue.poll()\n visit(v)\n }\n\n d\n }\n\n val d: Array[Int] = calcMaxDepth\n debug(d)\n\n case class Visit(parent: Int, v: Int)\n val queue = new util.ArrayDeque[Visit]()\n val p = Array.ofDim[Int](N)\n\n def addChildren(v: Int, parent: Int): Unit = {\n p(v) = parent\n g(v).foreach { u =>\n queue.add(Visit(v, u))\n }\n }\n\n addChildren(rt, -1)\n while(!queue.isEmpty) {\n val v = queue.poll()\n if (d(v.parent) + 1 == d(v.v)) {\n addChildren(v.v, v.parent)\n }\n }\n\n debug(p)\n\n REP(N) { i =>\n if (i == rt) out.println(0)\n else out.println(p(i) + 1)\n }\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 /**\n * @return (depth, parent, queue)\n */\n def traceBfs(g: Array[Array[Int]], rt: Int = 0): (Array[Int], Array[Int], Array[Int]) = {\n val n = g.length\n val INF = 1e9.toInt + 10\n val q, p = Array.ofDim[Int](n)\n q(0) = rt\n p(rt) = -1\n val d = Array.fill[Int](n)(INF)\n d(rt) = 0\n var cur = 0\n var last = 1\n while (cur < last) {\n val v = q(cur)\n REP(g(v).length) { i =>\n val u = g(v)(i)\n if (d(u) == INF) {\n d(u) = d(v) + 1\n p(u) = v\n q(last) = u\n last += 1\n }\n }\n cur += 1\n }\n (d, p, q)\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\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5161, "cpu_time_ms": 2111, "memory_kb": 124728}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s138703436", "group_id": "codeNet:p03147", "input_text": "import scala.util.control.Breaks\n\nobject Main extends App {\n var n = scala.io.StdIn.readInt()\n var s = scala.io.StdIn.readLine()\n var inputArray = s.split(\" \").map(_.toInt)\n var i = 0\n\n def minusWater(s: Seq[Int]): Seq[Int] = {\n var arrayIndex = Seq.empty[Int]\n val maxIndex = s.indexOf(s.max)\n val b1 = new Breaks\n b1.breakable{\n for(i<-maxIndex to n - 1) {\n if (s(i) == 0) {\n b1.break()\n } else {\n arrayIndex :+= i\n }\n }\n }\n if (maxIndex > 0) {\n val b2 = new Breaks\n b2.breakable{\n for(i<-(maxIndex-1) to 0 by -1) {\n if (s(i) == 0) {\n b2.break()\n } else {\n arrayIndex :+= i\n }\n }\n }\n }\n\n s.zipWithIndex.map{ h =>\n if (arrayIndex.find(_ == h._2).isDefined) {\n h._1 - 1\n }else {\n h._1\n }\n }\n }\n\n def judgeSeq(s: Seq[Int]): Unit = {\n i += 1\n val seqAfterWater = minusWater(s)\n if (seqAfterWater.filterNot(_ == 0).isEmpty) {\n println(i)\n } else {\n judgeSeq(seqAfterWater)\n }\n }\n judgeSeq(inputArray)\n}", "language": "Scala", "metadata": {"date": 1548118653, "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/s138703436.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s138703436", "user_id": "u105921924"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.util.control.Breaks\n\nobject Main extends App {\n var n = scala.io.StdIn.readInt()\n var s = scala.io.StdIn.readLine()\n var inputArray = s.split(\" \").map(_.toInt)\n var i = 0\n\n def minusWater(s: Seq[Int]): Seq[Int] = {\n var arrayIndex = Seq.empty[Int]\n val maxIndex = s.indexOf(s.max)\n val b1 = new Breaks\n b1.breakable{\n for(i<-maxIndex to n - 1) {\n if (s(i) == 0) {\n b1.break()\n } else {\n arrayIndex :+= i\n }\n }\n }\n if (maxIndex > 0) {\n val b2 = new Breaks\n b2.breakable{\n for(i<-(maxIndex-1) to 0 by -1) {\n if (s(i) == 0) {\n b2.break()\n } else {\n arrayIndex :+= i\n }\n }\n }\n }\n\n s.zipWithIndex.map{ h =>\n if (arrayIndex.find(_ == h._2).isDefined) {\n h._1 - 1\n }else {\n h._1\n }\n }\n }\n\n def judgeSeq(s: Seq[Int]): Unit = {\n i += 1\n val seqAfterWater = minusWater(s)\n if (seqAfterWater.filterNot(_ == 0).isEmpty) {\n println(i)\n } else {\n judgeSeq(seqAfterWater)\n }\n }\n judgeSeq(inputArray)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0.\nYou are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \\leq k \\leq N), by repeating the following \"watering\" operation:\n\nSpecify integers l and r. Increase the height of Flower x by 1 for all x such that l \\leq x \\leq r.\n\nFind the minimum number of watering operations required to satisfy the condition.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq h_i \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nh_1 h_2 h_3 ...... h_N\n\nOutput\n\nPrint the minimum number of watering operations required to satisfy the condition.\n\nSample Input 1\n\n4\n1 2 2 1\n\nSample Output 1\n\n2\n\nThe minimum number of watering operations required is 2.\nOne way to achieve it is:\n\nPerform the operation with (l,r)=(1,3).\n\nPerform the operation with (l,r)=(2,4).\n\nSample Input 2\n\n5\n3 1 2 3 1\n\nSample Output 2\n\n5\n\nSample Input 3\n\n8\n4 23 75 0 23 96 50 100\n\nSample Output 3\n\n221", "sample_input": "4\n1 2 2 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03147", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0.\nYou are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \\leq k \\leq N), by repeating the following \"watering\" operation:\n\nSpecify integers l and r. Increase the height of Flower x by 1 for all x such that l \\leq x \\leq r.\n\nFind the minimum number of watering operations required to satisfy the condition.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq h_i \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nh_1 h_2 h_3 ...... h_N\n\nOutput\n\nPrint the minimum number of watering operations required to satisfy the condition.\n\nSample Input 1\n\n4\n1 2 2 1\n\nSample Output 1\n\n2\n\nThe minimum number of watering operations required is 2.\nOne way to achieve it is:\n\nPerform the operation with (l,r)=(1,3).\n\nPerform the operation with (l,r)=(2,4).\n\nSample Input 2\n\n5\n3 1 2 3 1\n\nSample Output 2\n\n5\n\nSample Input 3\n\n8\n4 23 75 0 23 96 50 100\n\nSample Output 3\n\n221", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1117, "cpu_time_ms": 704, "memory_kb": 37628}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s248629242", "group_id": "codeNet:p03148", "input_text": "import scala.collection.mutable.Map\nimport Ordering.Long.reverse\nimport scala.collection.mutable.PriorityQueue\n\nobject Main {\n // type T = PriorityQueue[Long]\n def main(args : Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val n, k = sc.nextInt\n val sushis = List.fill(n)(sc.nextInt, sc.nextInt).sortWith(_._2 > _._2)\n var kind, ans : Long = 0\n val used = new Array[Boolean](n+1)\n var selected = new PriorityQueue[Long]\n for ((t, d) <- sushis take k) {\n ans += d\n if (used(t)) selected += d\n else {\n used(t) = true\n kind += 1\n }\n }\n val toeat_ : Map[Int, List[Long]] = Map()\n for ((t, d) <- sushis) \n if (toeat_ contains t) toeat_(t) = d :: toeat_(t)\n else toeat_(t) = List(d)\n var toeat : List[List[Long]] = toeat_.filter{case (k, _) => !used(k)}.values.toList\n toeat = toeat.map(_.sorted(reverse)).sortWith(_.head > _.head)\n var candidate : Long = kind * kind + ans\n for (xs <- toeat if selected.size > 0) {\n kind += 1\n ans += (xs.head - selected.dequeue)\n candidate = candidate max (kind * kind + ans)\n }\n println(candidate)\n }\n}\n", "language": "Scala", "metadata": {"date": 1548695143, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03148.html", "problem_id": "p03148", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03148/input.txt", "sample_output_relpath": "derived/input_output/data/p03148/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03148/Scala/s248629242.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s248629242", "user_id": "u672765904"}, "prompt_components": {"gold_output": "26\n", "input_to_evaluate": "import scala.collection.mutable.Map\nimport Ordering.Long.reverse\nimport scala.collection.mutable.PriorityQueue\n\nobject Main {\n // type T = PriorityQueue[Long]\n def main(args : Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val n, k = sc.nextInt\n val sushis = List.fill(n)(sc.nextInt, sc.nextInt).sortWith(_._2 > _._2)\n var kind, ans : Long = 0\n val used = new Array[Boolean](n+1)\n var selected = new PriorityQueue[Long]\n for ((t, d) <- sushis take k) {\n ans += d\n if (used(t)) selected += d\n else {\n used(t) = true\n kind += 1\n }\n }\n val toeat_ : Map[Int, List[Long]] = Map()\n for ((t, d) <- sushis) \n if (toeat_ contains t) toeat_(t) = d :: toeat_(t)\n else toeat_(t) = List(d)\n var toeat : List[List[Long]] = toeat_.filter{case (k, _) => !used(k)}.values.toList\n toeat = toeat.map(_.sorted(reverse)).sortWith(_.head > _.head)\n var candidate : Long = kind * kind + ans\n for (xs <- toeat if selected.size > 0) {\n kind += 1\n ans += (xs.head - selected.dequeue)\n candidate = candidate max (kind * kind + ans)\n }\n println(candidate)\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N pieces of sushi. Each piece has two parameters: \"kind of topping\" t_i and \"deliciousness\" d_i.\nYou are choosing K among these N pieces to eat.\nYour \"satisfaction\" here will be calculated as follows:\n\nThe satisfaction is the sum of the \"base total deliciousness\" and the \"variety bonus\".\n\nThe base total deliciousness is the sum of the deliciousness of the pieces you eat.\n\nThe variety bonus is x*x, where x is the number of different kinds of toppings of the pieces you eat.\n\nYou want to have as much satisfaction as possible.\nFind this maximum satisfaction.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 10^5\n\n1 \\leq t_i \\leq N\n\n1 \\leq d_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nt_1 d_1\nt_2 d_2\n.\n.\n.\nt_N d_N\n\nOutput\n\nPrint the maximum satisfaction that you can obtain.\n\nSample Input 1\n\n5 3\n1 9\n1 7\n2 6\n2 5\n3 1\n\nSample Output 1\n\n26\n\nIf you eat Sushi 1,2 and 3:\n\nThe base total deliciousness is 9+7+6=22.\n\nThe variety bonus is 2*2=4.\n\nThus, your satisfaction will be 26, which is optimal.\n\nSample Input 2\n\n7 4\n1 1\n2 1\n3 1\n4 6\n4 5\n4 5\n4 5\n\nSample Output 2\n\n25\n\nIt is optimal to eat Sushi 1,2,3 and 4.\n\nSample Input 3\n\n6 5\n5 1000000000\n2 990000000\n3 980000000\n6 970000000\n6 960000000\n4 950000000\n\nSample Output 3\n\n4900000016\n\nNote that the output may not fit into a 32-bit integer type.", "sample_input": "5 3\n1 9\n1 7\n2 6\n2 5\n3 1\n"}, "reference_outputs": ["26\n"], "source_document_id": "p03148", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N pieces of sushi. Each piece has two parameters: \"kind of topping\" t_i and \"deliciousness\" d_i.\nYou are choosing K among these N pieces to eat.\nYour \"satisfaction\" here will be calculated as follows:\n\nThe satisfaction is the sum of the \"base total deliciousness\" and the \"variety bonus\".\n\nThe base total deliciousness is the sum of the deliciousness of the pieces you eat.\n\nThe variety bonus is x*x, where x is the number of different kinds of toppings of the pieces you eat.\n\nYou want to have as much satisfaction as possible.\nFind this maximum satisfaction.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 10^5\n\n1 \\leq t_i \\leq N\n\n1 \\leq d_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nt_1 d_1\nt_2 d_2\n.\n.\n.\nt_N d_N\n\nOutput\n\nPrint the maximum satisfaction that you can obtain.\n\nSample Input 1\n\n5 3\n1 9\n1 7\n2 6\n2 5\n3 1\n\nSample Output 1\n\n26\n\nIf you eat Sushi 1,2 and 3:\n\nThe base total deliciousness is 9+7+6=22.\n\nThe variety bonus is 2*2=4.\n\nThus, your satisfaction will be 26, which is optimal.\n\nSample Input 2\n\n7 4\n1 1\n2 1\n3 1\n4 6\n4 5\n4 5\n4 5\n\nSample Output 2\n\n25\n\nIt is optimal to eat Sushi 1,2,3 and 4.\n\nSample Input 3\n\n6 5\n5 1000000000\n2 990000000\n3 980000000\n6 970000000\n6 960000000\n4 950000000\n\nSample Output 3\n\n4900000016\n\nNote that the output may not fit into a 32-bit integer type.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1299, "cpu_time_ms": 1698, "memory_kb": 86816}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s430654638", "group_id": "codeNet:p03150", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val S = sc.next()\n val splited = 1.until(\"keyence\".length).map(\"keyence\".splitAt)\n val isExists = S.startsWith(\"keyence\") || S.endsWith(\"keyence\") ||\n splited.exists { case (l, r) => S.startsWith(l) && S.endsWith(r) }\n println(if (isExists) \"YES\" else \"NO\")\n}\n", "language": "Scala", "metadata": {"date": 1594235187, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03150.html", "problem_id": "p03150", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03150/input.txt", "sample_output_relpath": "derived/input_output/data/p03150/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03150/Scala/s430654638.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s430654638", "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 val splited = 1.until(\"keyence\".length).map(\"keyence\".splitAt)\n val isExists = S.startsWith(\"keyence\") || S.endsWith(\"keyence\") ||\n splited.exists { case (l, r) => S.startsWith(l) && S.endsWith(r) }\n println(if (isExists) \"YES\" else \"NO\")\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA string is called a KEYENCE string when it can be changed to keyence by removing its contiguous substring (possibly empty) only once.\n\nGiven a string S consisting of lowercase English letters, determine if S is a KEYENCE string.\n\nConstraints\n\nThe length of S is between 7 and 100 (inclusive).\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a KEYENCE string, print YES; otherwise, print NO.\n\nSample Input 1\n\nkeyofscience\n\nSample Output 1\n\nYES\n\nkeyence is an abbreviation of key of science.\n\nSample Input 2\n\nmpyszsbznf\n\nSample Output 2\n\nNO\n\nSample Input 3\n\nashlfyha\n\nSample Output 3\n\nNO\n\nSample Input 4\n\nkeyence\n\nSample Output 4\n\nYES", "sample_input": "keyofscience\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03150", "source_text": "Score : 200 points\n\nProblem Statement\n\nA string is called a KEYENCE string when it can be changed to keyence by removing its contiguous substring (possibly empty) only once.\n\nGiven a string S consisting of lowercase English letters, determine if S is a KEYENCE string.\n\nConstraints\n\nThe length of S is between 7 and 100 (inclusive).\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a KEYENCE string, print YES; otherwise, print NO.\n\nSample Input 1\n\nkeyofscience\n\nSample Output 1\n\nYES\n\nkeyence is an abbreviation of key of science.\n\nSample Input 2\n\nmpyszsbznf\n\nSample Output 2\n\nNO\n\nSample Input 3\n\nashlfyha\n\nSample Output 3\n\nNO\n\nSample Input 4\n\nkeyence\n\nSample Output 4\n\nYES", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 338, "cpu_time_ms": 493, "memory_kb": 55440}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s775120380", "group_id": "codeNet:p03150", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val S = sc.next()\n val isExists =\n \"keyence\".inits.toList.tail.zip(\"keyence\".tails.toList.tail.reverse).map {\n case (l, r) => s\".*$l.*$r.*\"\n }.exists(S.matches)\n println(if (isExists) \"YES\" else \"NO\")\n}\n", "language": "Scala", "metadata": {"date": 1594231298, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03150.html", "problem_id": "p03150", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03150/input.txt", "sample_output_relpath": "derived/input_output/data/p03150/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03150/Scala/s775120380.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s775120380", "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 val isExists =\n \"keyence\".inits.toList.tail.zip(\"keyence\".tails.toList.tail.reverse).map {\n case (l, r) => s\".*$l.*$r.*\"\n }.exists(S.matches)\n println(if (isExists) \"YES\" else \"NO\")\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA string is called a KEYENCE string when it can be changed to keyence by removing its contiguous substring (possibly empty) only once.\n\nGiven a string S consisting of lowercase English letters, determine if S is a KEYENCE string.\n\nConstraints\n\nThe length of S is between 7 and 100 (inclusive).\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a KEYENCE string, print YES; otherwise, print NO.\n\nSample Input 1\n\nkeyofscience\n\nSample Output 1\n\nYES\n\nkeyence is an abbreviation of key of science.\n\nSample Input 2\n\nmpyszsbznf\n\nSample Output 2\n\nNO\n\nSample Input 3\n\nashlfyha\n\nSample Output 3\n\nNO\n\nSample Input 4\n\nkeyence\n\nSample Output 4\n\nYES", "sample_input": "keyofscience\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03150", "source_text": "Score : 200 points\n\nProblem Statement\n\nA string is called a KEYENCE string when it can be changed to keyence by removing its contiguous substring (possibly empty) only once.\n\nGiven a string S consisting of lowercase English letters, determine if S is a KEYENCE string.\n\nConstraints\n\nThe length of S is between 7 and 100 (inclusive).\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a KEYENCE string, print YES; otherwise, print NO.\n\nSample Input 1\n\nkeyofscience\n\nSample Output 1\n\nYES\n\nkeyence is an abbreviation of key of science.\n\nSample Input 2\n\nmpyszsbznf\n\nSample Output 2\n\nNO\n\nSample Input 3\n\nashlfyha\n\nSample Output 3\n\nNO\n\nSample Input 4\n\nkeyence\n\nSample Output 4\n\nYES", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 288, "cpu_time_ms": 497, "memory_kb": 55320}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s795011290", "group_id": "codeNet:p03151", "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 = readLineLongs(sc)(0)\n val A = readLineLongs\n val B = readLineLongs\n val AmB = A.zip(B).map { case (a, b) => a - b }\n if (AmB.sum < 0) return print(-1)\n\n val (negatives, positives) = AmB.partition(_ < 0)\n val negSorted = negatives.sorted(implicitly[Ordering[Long]].reverse)\n val posSorted = positives.filter(_ > 0).sorted\n\n def posUseNumber: Int = {\n var negIndex = 0\n var posMinUnaltered = 0\n\n while (negIndex < negSorted.length) {\n val a = negSorted(negIndex)\n\n def search: Option[Int] = {\n for {i <- posSorted.indices} if (posSorted(i) > a) return Some(i)\n None\n }\n search match {\n case Some(index) => {\n posSorted(index) -= a\n negSorted(negIndex) = 0\n\n negIndex += 1\n posMinUnaltered = Math.max(posMinUnaltered, index + 1)\n }\n case None => {\n var negToFill = negSorted.sum * (-1)\n val (usedPos, unusedPos) = posSorted.splitAt(posMinUnaltered)\n negToFill -= usedPos.sum\n val additionalUse = unusedPos.scan(0L)(_ + _).takeWhile(_ < negToFill).length\n return posMinUnaltered + additionalUse\n }\n }\n }\n posMinUnaltered\n }\n println(negSorted.length + posUseNumber)\n }\n}\n", "language": "Scala", "metadata": {"date": 1547419255, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03151.html", "problem_id": "p03151", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03151/input.txt", "sample_output_relpath": "derived/input_output/data/p03151/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03151/Scala/s795011290.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s795011290", "user_id": "u909304507"}, "prompt_components": {"gold_output": "3\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 = readLineLongs(sc)(0)\n val A = readLineLongs\n val B = readLineLongs\n val AmB = A.zip(B).map { case (a, b) => a - b }\n if (AmB.sum < 0) return print(-1)\n\n val (negatives, positives) = AmB.partition(_ < 0)\n val negSorted = negatives.sorted(implicitly[Ordering[Long]].reverse)\n val posSorted = positives.filter(_ > 0).sorted\n\n def posUseNumber: Int = {\n var negIndex = 0\n var posMinUnaltered = 0\n\n while (negIndex < negSorted.length) {\n val a = negSorted(negIndex)\n\n def search: Option[Int] = {\n for {i <- posSorted.indices} if (posSorted(i) > a) return Some(i)\n None\n }\n search match {\n case Some(index) => {\n posSorted(index) -= a\n negSorted(negIndex) = 0\n\n negIndex += 1\n posMinUnaltered = Math.max(posMinUnaltered, index + 1)\n }\n case None => {\n var negToFill = negSorted.sum * (-1)\n val (usedPos, unusedPos) = posSorted.splitAt(posMinUnaltered)\n negToFill -= usedPos.sum\n val additionalUse = unusedPos.scan(0L)(_ + _).takeWhile(_ < negToFill).length\n return posMinUnaltered + additionalUse\n }\n }\n }\n posMinUnaltered\n }\n println(negSorted.length + posUseNumber)\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nA university student, Takahashi, has to take N examinations and pass all of them.\nCurrently, his readiness for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination.\n\nTakahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness.\n\nFor Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions:\n\nThe sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.\n\nFor every i, B_i \\leq C_i holds.\n\nIf such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nA_i and B_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N}\nB_1 B_2 ... B_{N}\n\nOutput\n\nPrint the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions.\nIf such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.\n\nSample Input 1\n\n3\n2 3 5\n3 4 1\n\nSample Output 1\n\n3\n\n(A_1, A_2, A_3) = (2, 3, 5) and (B_1, B_2, B_3) = (3, 4, 1). If nothing is done, he cannot pass the first and second exams.\nThe minimum possible number of indices i such that A_i and C_i are different, 3, is achieved when:\n\n(C_1, C_2, C_3) = (3, 5, 2)\n\nSample Input 2\n\n3\n2 3 3\n2 2 1\n\nSample Output 2\n\n0\n\nIn this case, he has to do nothing in order to pass all the exams.\n\nSample Input 3\n\n3\n17 7 1\n25 6 14\n\nSample Output 3\n\n-1\n\nIn this case, no matter what is done, he cannot pass all the exams.\n\nSample Input 4\n\n12\n757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604\n74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212\n\nSample Output 4\n\n5", "sample_input": "3\n2 3 5\n3 4 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03151", "source_text": "Score : 400 points\n\nProblem Statement\n\nA university student, Takahashi, has to take N examinations and pass all of them.\nCurrently, his readiness for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination.\n\nTakahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness.\n\nFor Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions:\n\nThe sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.\n\nFor every i, B_i \\leq C_i holds.\n\nIf such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^9\n\nA_i and B_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_{N}\nB_1 B_2 ... B_{N}\n\nOutput\n\nPrint the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions.\nIf such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.\n\nSample Input 1\n\n3\n2 3 5\n3 4 1\n\nSample Output 1\n\n3\n\n(A_1, A_2, A_3) = (2, 3, 5) and (B_1, B_2, B_3) = (3, 4, 1). If nothing is done, he cannot pass the first and second exams.\nThe minimum possible number of indices i such that A_i and C_i are different, 3, is achieved when:\n\n(C_1, C_2, C_3) = (3, 5, 2)\n\nSample Input 2\n\n3\n2 3 3\n2 2 1\n\nSample Output 2\n\n0\n\nIn this case, he has to do nothing in order to pass all the exams.\n\nSample Input 3\n\n3\n17 7 1\n25 6 14\n\nSample Output 3\n\n-1\n\nIn this case, no matter what is done, he cannot pass all the exams.\n\nSample Input 4\n\n12\n757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604\n74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212\n\nSample Output 4\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2014, "cpu_time_ms": 1190, "memory_kb": 78688}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s585997484", "group_id": "codeNet:p03155", "input_text": "object Main extends App {\n val n = scala.io.StdIn.readLine.toInt\n val w = scala.io.StdIn.readLine.toInt\n val h = scala.io.StdIn.readLine.toInt\n println((n-(w-1))*(n-(h-1)))\n}", "language": "Scala", "metadata": {"date": 1547323577, "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/s585997484.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s585997484", "user_id": "u654455149"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n val n = scala.io.StdIn.readLine.toInt\n val w = scala.io.StdIn.readLine.toInt\n val h = scala.io.StdIn.readLine.toInt\n println((n-(w-1))*(n-(h-1)))\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIt has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board.\n\nThe bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangular region with H rows and W columns.\n\nHow many ways are there to choose where to put the notice so that it completely covers exactly HW squares?\n\nConstraints\n\n1 \\leq H, W \\leq N \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH\nW\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n2\n3\n\nSample Output 1\n\n2\n\nThere are two ways to put the notice, as follows:\n\n### ...\n### ###\n... ###\n\nHere, # represents a square covered by the notice, and . represents a square not covered.\n\nSample Input 2\n\n100\n1\n1\n\nSample Output 2\n\n10000\n\nSample Input 3\n\n5\n4\n2\n\nSample Output 3\n\n8", "sample_input": "3\n2\n3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03155", "source_text": "Score : 100 points\n\nProblem Statement\n\nIt has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board.\n\nThe bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangular region with H rows and W columns.\n\nHow many ways are there to choose where to put the notice so that it completely covers exactly HW squares?\n\nConstraints\n\n1 \\leq H, W \\leq N \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH\nW\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n2\n3\n\nSample Output 1\n\n2\n\nThere are two ways to put the notice, as follows:\n\n### ...\n### ###\n... ###\n\nHere, # represents a square covered by the notice, and . represents a square not covered.\n\nSample Input 2\n\n100\n1\n1\n\nSample Output 2\n\n10000\n\nSample Input 3\n\n5\n4\n2\n\nSample Output 3\n\n8", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 178, "cpu_time_ms": 322, "memory_kb": 27328}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s859450346", "group_id": "codeNet:p03156", "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, B = ni()\n val P = na(N)\n val a = P.count(_ <= A)\n val b = P.count(x => A + 1 <= x && x <= B)\n val c = N - a - b\n val ans = min(a, min(b, c))\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": 1547323369, "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/s859450346.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s859450346", "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 = ni()\n val A, B = ni()\n val P = na(N)\n val a = P.count(_ <= A)\n val b = P.count(x => A + 1 <= x && x <= B)\n val c = N - a - b\n val ans = min(a, min(b, c))\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 : 200 points\n\nProblem Statement\n\nYou have written N problems to hold programming contests.\nThe i-th problem will have a score of P_i points if used in a contest.\n\nWith these problems, you would like to hold as many contests as possible under the following condition:\n\nA contest has three problems. The first problem has a score not greater than A points, the second has a score between A + 1 and B points (inclusive), and the third has a score not less than B + 1 points.\n\nThe same problem should not be used in multiple contests.\nAt most how many contests can be held?\n\nConstraints\n\n3 \\leq N \\leq 100\n\n1 \\leq P_i \\leq 20 (1 \\leq i \\leq N)\n\n1 \\leq A < B < 20\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA B\nP_1 P_2 ... P_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n7\n5 15\n1 10 16 2 7 20 12\n\nSample Output 1\n\n2\n\nTwo contests can be held by putting the first, second, third problems and the fourth, fifth, sixth problems together.\n\nSample Input 2\n\n8\n3 8\n5 5 5 10 10 10 15 20\n\nSample Output 2\n\n0\n\nNo contest can be held, because there is no problem with a score of A = 3 or less.\n\nSample Input 3\n\n3\n5 6\n5 6 10\n\nSample Output 3\n\n1", "sample_input": "7\n5 15\n1 10 16 2 7 20 12\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03156", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have written N problems to hold programming contests.\nThe i-th problem will have a score of P_i points if used in a contest.\n\nWith these problems, you would like to hold as many contests as possible under the following condition:\n\nA contest has three problems. The first problem has a score not greater than A points, the second has a score between A + 1 and B points (inclusive), and the third has a score not less than B + 1 points.\n\nThe same problem should not be used in multiple contests.\nAt most how many contests can be held?\n\nConstraints\n\n3 \\leq N \\leq 100\n\n1 \\leq P_i \\leq 20 (1 \\leq i \\leq N)\n\n1 \\leq A < B < 20\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA B\nP_1 P_2 ... P_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n7\n5 15\n1 10 16 2 7 20 12\n\nSample Output 1\n\n2\n\nTwo contests can be held by putting the first, second, third problems and the fourth, fifth, sixth problems together.\n\nSample Input 2\n\n8\n3 8\n5 5 5 10 10 10 15 20\n\nSample Output 2\n\n0\n\nNo contest can be held, because there is no problem with a score of A = 3 or less.\n\nSample Input 3\n\n3\n5 6\n5 6 10\n\nSample Output 3\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2964, "cpu_time_ms": 323, "memory_kb": 27284}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s523992885", "group_id": "codeNet:p03162", "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\n val happy = Stream.range(0, n)\n .map(_ => (sc.nextLong(), sc.nextLong(), sc.nextLong()))\n .foldLeft(0L, 0L, 0L) {\n case ((am, bm, cm), (ai, bi, ci)) =>\n (\n math.max(bm + ai, cm + ai),\n math.max(cm + bi, am + bi),\n math.max(am + ci, bm + ci)\n )\n }\n\n println(Seq(happy._1, happy._2, happy._3).max)\n\n}\n", "language": "Scala", "metadata": {"date": 1546811680, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03162.html", "problem_id": "p03162", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03162/input.txt", "sample_output_relpath": "derived/input_output/data/p03162/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03162/Scala/s523992885.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s523992885", "user_id": "u726872801"}, "prompt_components": {"gold_output": "210\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\n val happy = Stream.range(0, n)\n .map(_ => (sc.nextLong(), sc.nextLong(), sc.nextLong()))\n .foldLeft(0L, 0L, 0L) {\n case ((am, bm, cm), (ai, bi, ci)) =>\n (\n math.max(bm + ai, cm + ai),\n math.max(cm + bi, am + bi),\n math.max(am + ci, bm + ci)\n )\n }\n\n println(Seq(happy._1, happy._2, happy._3).max)\n\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTaro's summer vacation starts tomorrow, and he has decided to make plans for it now.\n\nThe vacation consists of N days.\nFor each i (1 \\leq i \\leq N), Taro will choose one of the following activities and do it on the i-th day:\n\nA: Swim in the sea. Gain a_i points of happiness.\n\nB: Catch bugs in the mountains. Gain b_i points of happiness.\n\nC: Do homework at home. Gain c_i points of happiness.\n\nAs Taro gets bored easily, he cannot do the same activities for two or more consecutive days.\n\nFind the maximum possible total points of happiness that Taro gains.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq a_i, b_i, c_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1 c_1\na_2 b_2 c_2\n:\na_N b_N c_N\n\nOutput\n\nPrint the maximum possible total points of happiness that Taro gains.\n\nSample Input 1\n\n3\n10 40 70\n20 50 80\n30 60 90\n\nSample Output 1\n\n210\n\nIf Taro does activities in the order C, B, C, he will gain 70 + 50 + 90 = 210 points of happiness.\n\nSample Input 2\n\n1\n100 10 1\n\nSample Output 2\n\n100\n\nSample Input 3\n\n7\n6 7 8\n8 8 3\n2 5 2\n7 8 6\n4 6 8\n2 3 4\n7 5 1\n\nSample Output 3\n\n46\n\nTaro should do activities in the order C, A, B, A, C, B, A.", "sample_input": "3\n10 40 70\n20 50 80\n30 60 90\n"}, "reference_outputs": ["210\n"], "source_document_id": "p03162", "source_text": "Score : 100 points\n\nProblem Statement\n\nTaro's summer vacation starts tomorrow, and he has decided to make plans for it now.\n\nThe vacation consists of N days.\nFor each i (1 \\leq i \\leq N), Taro will choose one of the following activities and do it on the i-th day:\n\nA: Swim in the sea. Gain a_i points of happiness.\n\nB: Catch bugs in the mountains. Gain b_i points of happiness.\n\nC: Do homework at home. Gain c_i points of happiness.\n\nAs Taro gets bored easily, he cannot do the same activities for two or more consecutive days.\n\nFind the maximum possible total points of happiness that Taro gains.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq a_i, b_i, c_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1 c_1\na_2 b_2 c_2\n:\na_N b_N c_N\n\nOutput\n\nPrint the maximum possible total points of happiness that Taro gains.\n\nSample Input 1\n\n3\n10 40 70\n20 50 80\n30 60 90\n\nSample Output 1\n\n210\n\nIf Taro does activities in the order C, B, C, he will gain 70 + 50 + 90 = 210 points of happiness.\n\nSample Input 2\n\n1\n100 10 1\n\nSample Output 2\n\n100\n\nSample Input 3\n\n7\n6 7 8\n8 8 3\n2 5 2\n7 8 6\n4 6 8\n2 3 4\n7 5 1\n\nSample Output 3\n\n46\n\nTaro should do activities in the order C, A, B, A, C, B, A.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 469, "cpu_time_ms": 1199, "memory_kb": 115400}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s789406103", "group_id": "codeNet:p03186", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n\n val Array(a,b,c) = StdIn.readLine.split(\" \").map(_.toInt)\n\n val ans = if((a+b) > c) b + c\n else if(b > c) c * 2 + a\n else b * 2 + a + 1\n\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1546197621, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/s789406103.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s789406103", "user_id": "u217010036"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n\n val Array(a,b,c) = StdIn.readLine.split(\" \").map(_.toInt)\n\n val ans = if((a+b) > c) b + c\n else if(b > c) c * 2 + a\n else b * 2 + a + 1\n\n println(ans)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 337, "memory_kb": 25412}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s863389676", "group_id": "codeNet:p03192", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val N = sc.next()\n println(N.count(_ == '2'))\n}\n", "language": "Scala", "metadata": {"date": 1596199478, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03192.html", "problem_id": "p03192", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03192/input.txt", "sample_output_relpath": "derived/input_output/data/p03192/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03192/Scala/s863389676.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s863389676", "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 N = sc.next()\n println(N.count(_ == '2'))\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given an integer N that has exactly four digits in base ten.\nHow many times does 2 occur in the base-ten representation of N?\n\nConstraints\n\n1000 \\leq N \\leq 9999\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1222\n\nSample Output 1\n\n3\n\n2 occurs three times in 1222. By the way, this contest is held on December 22 (JST).\n\nSample Input 2\n\n3456\n\nSample Output 2\n\n0\n\nSample Input 3\n\n9592\n\nSample Output 3\n\n1", "sample_input": "1222\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03192", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given an integer N that has exactly four digits in base ten.\nHow many times does 2 occur in the base-ten representation of N?\n\nConstraints\n\n1000 \\leq N \\leq 9999\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1222\n\nSample Output 1\n\n3\n\n2 occurs three times in 1222. By the way, this contest is held on December 22 (JST).\n\nSample Input 2\n\n3456\n\nSample Output 2\n\n0\n\nSample Input 3\n\n9592\n\nSample Output 3\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 121, "cpu_time_ms": 498, "memory_kb": 55312}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s940495111", "group_id": "codeNet:p03200", "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 s = sc.next\n// val b = sc.nextInt\n// val a = List.fill(n)(sc.nextInt)\n// val b = List.fill(m)(sc.nextInt)\n\n val aaaa = s.zipWithIndex\n\n val ans = foldLeftWithNext(s.zipWithIndex)((0, 0)) { case ((acc, count), (sA, indexA), (sB, indexB)) =>\n if ((sA.toString + sB.toString) == \"BW\") (acc + indexB - count, count + 1)\n else (acc, count)\n } {\n case ((acc, count), (sA, indexA)) =>\n (acc, count)\n }\n println(ans._1)\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 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": 1581873915, "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/s940495111.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s940495111", "user_id": "u040380439"}, "prompt_components": {"gold_output": "2\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 s = sc.next\n// val b = sc.nextInt\n// val a = List.fill(n)(sc.nextInt)\n// val b = List.fill(m)(sc.nextInt)\n\n val aaaa = s.zipWithIndex\n\n val ans = foldLeftWithNext(s.zipWithIndex)((0, 0)) { case ((acc, count), (sA, indexA), (sB, indexB)) =>\n if ((sA.toString + sB.toString) == \"BW\") (acc + indexB - count, count + 1)\n else (acc, count)\n } {\n case ((acc, count), (sA, indexA)) =>\n (acc, count)\n }\n println(ans._1)\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 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 : 300 points\n\nProblem Statement\n\nThere are N Reversi pieces arranged in a row. (A Reversi piece is a disc with a black side and a white side.)\nThe state of each piece is represented by a string S of length N.\nIf S_i=B, the i-th piece from the left is showing black;\nIf S_i=W, the i-th piece from the left is showing white.\n\nConsider performing the following operation:\n\nChoose i (1 \\leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black.\n\nFind the maximum possible number of times this operation can be performed.\n\nConstraints\n\n1 \\leq |S| \\leq 2\\times 10^5\n\nS_i=B or W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum possible number of times the operation can be performed.\n\nSample Input 1\n\nBBW\n\nSample Output 1\n\n2\n\nThe operation can be performed twice, as follows:\n\nFlip the second and third pieces from the left.\n\nFlip the first and second pieces from the left.\n\nSample Input 2\n\nBWBWBW\n\nSample Output 2\n\n6", "sample_input": "BBW\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03200", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N Reversi pieces arranged in a row. (A Reversi piece is a disc with a black side and a white side.)\nThe state of each piece is represented by a string S of length N.\nIf S_i=B, the i-th piece from the left is showing black;\nIf S_i=W, the i-th piece from the left is showing white.\n\nConsider performing the following operation:\n\nChoose i (1 \\leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black.\n\nFind the maximum possible number of times this operation can be performed.\n\nConstraints\n\n1 \\leq |S| \\leq 2\\times 10^5\n\nS_i=B or W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum possible number of times the operation can be performed.\n\nSample Input 1\n\nBBW\n\nSample Output 1\n\n2\n\nThe operation can be performed twice, as follows:\n\nFlip the second and third pieces from the left.\n\nFlip the first and second pieces from the left.\n\nSample Input 2\n\nBWBWBW\n\nSample Output 2\n\n6", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1739, "cpu_time_ms": 1357, "memory_kb": 275536}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s757121827", "group_id": "codeNet:p03200", "input_text": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val s = in.readLine\n\n val ans = (0 until s.size)./:((0L, 0)) { case ((acc,cnt),i) =>\n if(s(i) == 'W') (acc+(i-cnt), cnt+1)\n else (acc, cnt)\n }._1\n\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1558136694, "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/s757121827.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s757121827", "user_id": "u217010036"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val s = in.readLine\n\n val ans = (0 until s.size)./:((0L, 0)) { case ((acc,cnt),i) =>\n if(s(i) == 'W') (acc+(i-cnt), cnt+1)\n else (acc, cnt)\n }._1\n\n println(ans)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N Reversi pieces arranged in a row. (A Reversi piece is a disc with a black side and a white side.)\nThe state of each piece is represented by a string S of length N.\nIf S_i=B, the i-th piece from the left is showing black;\nIf S_i=W, the i-th piece from the left is showing white.\n\nConsider performing the following operation:\n\nChoose i (1 \\leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black.\n\nFind the maximum possible number of times this operation can be performed.\n\nConstraints\n\n1 \\leq |S| \\leq 2\\times 10^5\n\nS_i=B or W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum possible number of times the operation can be performed.\n\nSample Input 1\n\nBBW\n\nSample Output 1\n\n2\n\nThe operation can be performed twice, as follows:\n\nFlip the second and third pieces from the left.\n\nFlip the first and second pieces from the left.\n\nSample Input 2\n\nBWBWBW\n\nSample Output 2\n\n6", "sample_input": "BBW\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03200", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N Reversi pieces arranged in a row. (A Reversi piece is a disc with a black side and a white side.)\nThe state of each piece is represented by a string S of length N.\nIf S_i=B, the i-th piece from the left is showing black;\nIf S_i=W, the i-th piece from the left is showing white.\n\nConsider performing the following operation:\n\nChoose i (1 \\leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black.\n\nFind the maximum possible number of times this operation can be performed.\n\nConstraints\n\n1 \\leq |S| \\leq 2\\times 10^5\n\nS_i=B or W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum possible number of times the operation can be performed.\n\nSample Input 1\n\nBBW\n\nSample Output 1\n\n2\n\nThe operation can be performed twice, as follows:\n\nFlip the second and third pieces from the left.\n\nFlip the first and second pieces from the left.\n\nSample Input 2\n\nBWBWBW\n\nSample Output 2\n\n6", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 230, "cpu_time_ms": 433, "memory_kb": 37972}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s765907240", "group_id": "codeNet:p03200", "input_text": "object Main extends App {\n val regex = \"BW\"\n val newStr = \"WB\"\n println(rep(io.StdIn.readLine()))\n \n def rep(str: String): Int = {\n if (str.indexOf(regex) == -1) {\n 0\n } else {\n rep(str.replaceFirst(regex, newStr)) + 1\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1546113390, "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/s765907240.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s765907240", "user_id": "u301082814"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n val regex = \"BW\"\n val newStr = \"WB\"\n println(rep(io.StdIn.readLine()))\n \n def rep(str: String): Int = {\n if (str.indexOf(regex) == -1) {\n 0\n } else {\n rep(str.replaceFirst(regex, newStr)) + 1\n }\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N Reversi pieces arranged in a row. (A Reversi piece is a disc with a black side and a white side.)\nThe state of each piece is represented by a string S of length N.\nIf S_i=B, the i-th piece from the left is showing black;\nIf S_i=W, the i-th piece from the left is showing white.\n\nConsider performing the following operation:\n\nChoose i (1 \\leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black.\n\nFind the maximum possible number of times this operation can be performed.\n\nConstraints\n\n1 \\leq |S| \\leq 2\\times 10^5\n\nS_i=B or W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum possible number of times the operation can be performed.\n\nSample Input 1\n\nBBW\n\nSample Output 1\n\n2\n\nThe operation can be performed twice, as follows:\n\nFlip the second and third pieces from the left.\n\nFlip the first and second pieces from the left.\n\nSample Input 2\n\nBWBWBW\n\nSample Output 2\n\n6", "sample_input": "BBW\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03200", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N Reversi pieces arranged in a row. (A Reversi piece is a disc with a black side and a white side.)\nThe state of each piece is represented by a string S of length N.\nIf S_i=B, the i-th piece from the left is showing black;\nIf S_i=W, the i-th piece from the left is showing white.\n\nConsider performing the following operation:\n\nChoose i (1 \\leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black.\n\nFind the maximum possible number of times this operation can be performed.\n\nConstraints\n\n1 \\leq |S| \\leq 2\\times 10^5\n\nS_i=B or W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum possible number of times the operation can be performed.\n\nSample Input 1\n\nBBW\n\nSample Output 1\n\n2\n\nThe operation can be performed twice, as follows:\n\nFlip the second and third pieces from the left.\n\nFlip the first and second pieces from the left.\n\nSample Input 2\n\nBWBWBW\n\nSample Output 2\n\n6", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 252, "cpu_time_ms": 1814, "memory_kb": 300788}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s122654106", "group_id": "codeNet:p03201", "input_text": "\nobject Main extends App {\n\n import scala.io.StdIn._\n import scala.math._\n\n val ballCount = readLine.trim.toInt\n val series = readLine.trim.split(' ').map{_.toLong}.sorted\n var stack: List[Ball] = List(new Ball(series.head, 1))\n for (i ← 1 until series.length){\n if (stack.head.number == series(i)){\n stack.head.count += 1\n }else {\n stack ::= new Ball(series(i), 1)\n }\n }\n val balls = stack.toArray.reverse\n val exp = Array.tabulate(33){_ ⇒ 1L}\n for (i ← 1 until exp.length){\n exp(i) = exp(i - 1) * 2\n }\n var sum: Int = 0\n for (i ← balls.indices.reverse){\n for (e ← exp){\n if (e < balls(i).number * 2 && e > balls(i).number) lowerBound(balls, e - balls(i).number) match {\n case r if balls(r).number + balls(i).number == e && balls(r).count >= 1 ⇒\n val min = math.min(balls(r).count, balls(i).count)\n sum += min\n balls(r).count -= min\n case _ ⇒\n }else if (e == balls(i).number * 2 && balls(i).count >= 2) {\n sum += balls(i).count / 2\n }\n }\n }\n\n println(sum)\n def lowerBound(balls: Array[Ball], target: Long): Int = {\n var left = 0\n var right = balls.length - 1\n while (left < right){\n val mid = (left + right) / 2\n if (balls(mid).number < target){\n left = mid + 1\n }else {// target <= balls(mid).number\n right = mid\n }\n }\n right\n }\n def upperBound(balls: Array[Ball], target: Long): Int = {\n var left = 0\n var right = balls.length - 1\n while (left < right){\n val mid = (left + right) / 2\n if (balls(mid).number <= target){\n left = mid + 1\n }else {// target < balls(mid).number\n right = mid\n }\n }\n right\n }\n\n class Ball(val number: Long, var count: Int) {\n override def toString: String = s\"Ball($number, $count)\"\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}\n/*\n\n同じ文字数であれば\n\n */", "language": "Scala", "metadata": {"date": 1544930151, "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/s122654106.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s122654106", "user_id": "u419330815"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "\nobject Main extends App {\n\n import scala.io.StdIn._\n import scala.math._\n\n val ballCount = readLine.trim.toInt\n val series = readLine.trim.split(' ').map{_.toLong}.sorted\n var stack: List[Ball] = List(new Ball(series.head, 1))\n for (i ← 1 until series.length){\n if (stack.head.number == series(i)){\n stack.head.count += 1\n }else {\n stack ::= new Ball(series(i), 1)\n }\n }\n val balls = stack.toArray.reverse\n val exp = Array.tabulate(33){_ ⇒ 1L}\n for (i ← 1 until exp.length){\n exp(i) = exp(i - 1) * 2\n }\n var sum: Int = 0\n for (i ← balls.indices.reverse){\n for (e ← exp){\n if (e < balls(i).number * 2 && e > balls(i).number) lowerBound(balls, e - balls(i).number) match {\n case r if balls(r).number + balls(i).number == e && balls(r).count >= 1 ⇒\n val min = math.min(balls(r).count, balls(i).count)\n sum += min\n balls(r).count -= min\n case _ ⇒\n }else if (e == balls(i).number * 2 && balls(i).count >= 2) {\n sum += balls(i).count / 2\n }\n }\n }\n\n println(sum)\n def lowerBound(balls: Array[Ball], target: Long): Int = {\n var left = 0\n var right = balls.length - 1\n while (left < right){\n val mid = (left + right) / 2\n if (balls(mid).number < target){\n left = mid + 1\n }else {// target <= balls(mid).number\n right = mid\n }\n }\n right\n }\n def upperBound(balls: Array[Ball], target: Long): Int = {\n var left = 0\n var right = balls.length - 1\n while (left < right){\n val mid = (left + right) / 2\n if (balls(mid).number <= target){\n left = mid + 1\n }else {// target < balls(mid).number\n right = mid\n }\n }\n right\n }\n\n class Ball(val number: Long, var count: Int) {\n override def toString: String = s\"Ball($number, $count)\"\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}\n/*\n\n同じ文字数であれば\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1096, "memory_kb": 96540}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s509266724", "group_id": "codeNet:p03208", "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 = Integer.parseInt(sc.next())\n val h = new Array[Long](N)\n for (i <- 0 until N) {\n h(i) = Integer.parseInt(sc.next())\n }\n\n println(solve(N, K, h))\n }\n\n def solve(N: Int, K: Int, h: Array[Long]): String = {\n val sortedH = h.sorted\n\n var ans = sortedH(N - 1)\n for (i <- 0 to N - K) {\n ans = Math.min(ans, sortedH(K - 1 + i) - sortedH(i))\n }\n ans.toString\n }\n}", "language": "Scala", "metadata": {"date": 1564167492, "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/s509266724.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s509266724", "user_id": "u042365947"}, "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, K = Integer.parseInt(sc.next())\n val h = new Array[Long](N)\n for (i <- 0 until N) {\n h(i) = Integer.parseInt(sc.next())\n }\n\n println(solve(N, K, h))\n }\n\n def solve(N: Int, K: Int, h: Array[Long]): String = {\n val sortedH = h.sorted\n\n var ans = sortedH(N - 1)\n for (i <- 0 to N - K) {\n ans = Math.min(ans, sortedH(K - 1 + i) - sortedH(i))\n }\n ans.toString\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 528, "cpu_time_ms": 926, "memory_kb": 55180}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s950808771", "group_id": "codeNet:p03208", "input_text": "import scala.io.StdIn.readLine\n\nobject Main extends App {\n\n val Array(n, k) = readLine.split(\" \").map(_.toInt)\n val hs: List[Int] = (0 until n).map(_ => readLine.toInt).toList\n\n val sorted = hs.sorted\n\n val min = (sorted.take(n-k+1) zip sorted.drop(k-1))\n .map({ case (a, b) => b - a})\n .min\n\n println(min)\n\n}\n", "language": "Scala", "metadata": {"date": 1555114691, "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/s950808771.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s950808771", "user_id": "u247015032"}, "prompt_components": {"gold_output": "2\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 hs: List[Int] = (0 until n).map(_ => readLine.toInt).toList\n\n val sorted = hs.sorted\n\n val min = (sorted.take(n-k+1) zip sorted.drop(k-1))\n .map({ case (a, b) => b - a})\n .min\n\n println(min)\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 779, "memory_kb": 49196}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s221396243", "group_id": "codeNet:p03210", "input_text": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val x = in.readInt\n\n val ans = if(x == 7 || x == 5 || x == 3) \"YES\" else \"No\"\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1551662579, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03210.html", "problem_id": "p03210", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03210/input.txt", "sample_output_relpath": "derived/input_output/data/p03210/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03210/Scala/s221396243.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s221396243", "user_id": "u217010036"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val x = in.readInt\n\n val ans = if(x == 7 || x == 5 || x == 3) \"YES\" else \"No\"\n println(ans)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nShichi-Go-San (literally \"Seven-Five-Three\") is a traditional event in a certain country to celebrate the growth of seven-, five- and three-year-old children.\n\nTakahashi is now X years old. Will his growth be celebrated in Shichi-Go-San this time?\n\nConstraints\n\n1 ≤ X ≤ 9\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nIf Takahashi's growth will be celebrated, print YES; if it will not, print NO.\n\nSample Input 1\n\n5\n\nSample Output 1\n\nYES\n\nThe growth of a five-year-old child will be celebrated.\n\nSample Input 2\n\n6\n\nSample Output 2\n\nNO\n\nSee you next year.", "sample_input": "5\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03210", "source_text": "Score : 100 points\n\nProblem Statement\n\nShichi-Go-San (literally \"Seven-Five-Three\") is a traditional event in a certain country to celebrate the growth of seven-, five- and three-year-old children.\n\nTakahashi is now X years old. Will his growth be celebrated in Shichi-Go-San this time?\n\nConstraints\n\n1 ≤ X ≤ 9\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nIf Takahashi's growth will be celebrated, print YES; if it will not, print NO.\n\nSample Input 1\n\n5\n\nSample Output 1\n\nYES\n\nThe growth of a five-year-old child will be celebrated.\n\nSample Input 2\n\n6\n\nSample Output 2\n\nNO\n\nSee you next year.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 154, "cpu_time_ms": 324, "memory_kb": 25284}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s218913207", "group_id": "codeNet:p03211", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val nums = scala.io.StdIn.readLine.split(\"\")\n val like_num = 753\n var min_diff = 1000000\n for(i <- 0 until nums.length - 2) {\n val num = (nums(i) + nums(i + 1) + nums(i + 2)).toInt\n val diff = Math.abs(like_num - num)\n if( min_diff > diff) {\n min_diff = diff\n }\n }\n println(min_diff)\n }\n}", "language": "Scala", "metadata": {"date": 1569346731, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03211.html", "problem_id": "p03211", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03211/input.txt", "sample_output_relpath": "derived/input_output/data/p03211/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03211/Scala/s218913207.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s218913207", "user_id": "u888177577"}, "prompt_components": {"gold_output": "34\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val nums = scala.io.StdIn.readLine.split(\"\")\n val like_num = 753\n var min_diff = 1000000\n for(i <- 0 until nums.length - 2) {\n val num = (nums(i) + nums(i + 1) + nums(i + 2)).toInt\n val diff = Math.abs(like_num - num)\n if( min_diff > diff) {\n min_diff = diff\n }\n }\n println(min_diff)\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere is a string S consisting of digits 1, 2, ..., 9.\nLunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (She cannot rearrange the digits.)\n\nThe master's favorite number is 753. The closer to this number, the better.\nWhat is the minimum possible (absolute) difference between X and 753?\n\nConstraints\n\nS is a string of length between 4 and 10 (inclusive).\n\nEach character in S is 1, 2, ..., or 9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum possible difference between X and 753.\n\nSample Input 1\n\n1234567876\n\nSample Output 1\n\n34\n\nTaking out the seventh to ninth characters results in X = 787, and the difference between this and 753 is 787 - 753 = 34. The difference cannot be made smaller, no matter where X is taken from.\n\nNote that the digits cannot be rearranged. For example, taking out 567 and rearranging it to 765 is not allowed.\n\nWe cannot take out three digits that are not consecutive from S, either. For example, taking out the seventh digit 7, the ninth digit 7 and the tenth digit 6 to obtain 776 is not allowed.\n\nSample Input 2\n\n35753\n\nSample Output 2\n\n0\n\nIf 753 itself can be taken out, the answer is 0.\n\nSample Input 3\n\n1111111111\n\nSample Output 3\n\n642\n\nNo matter where X is taken from, X = 111, with the difference 753 - 111 = 642.", "sample_input": "1234567876\n"}, "reference_outputs": ["34\n"], "source_document_id": "p03211", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere is a string S consisting of digits 1, 2, ..., 9.\nLunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (She cannot rearrange the digits.)\n\nThe master's favorite number is 753. The closer to this number, the better.\nWhat is the minimum possible (absolute) difference between X and 753?\n\nConstraints\n\nS is a string of length between 4 and 10 (inclusive).\n\nEach character in S is 1, 2, ..., or 9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum possible difference between X and 753.\n\nSample Input 1\n\n1234567876\n\nSample Output 1\n\n34\n\nTaking out the seventh to ninth characters results in X = 787, and the difference between this and 753 is 787 - 753 = 34. The difference cannot be made smaller, no matter where X is taken from.\n\nNote that the digits cannot be rearranged. For example, taking out 567 and rearranging it to 765 is not allowed.\n\nWe cannot take out three digits that are not consecutive from S, either. For example, taking out the seventh digit 7, the ninth digit 7 and the tenth digit 6 to obtain 776 is not allowed.\n\nSample Input 2\n\n35753\n\nSample Output 2\n\n0\n\nIf 753 itself can be taken out, the answer is 0.\n\nSample Input 3\n\n1111111111\n\nSample Output 3\n\n642\n\nNo matter where X is taken from, X = 111, with the difference 753 - 111 = 642.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 395, "cpu_time_ms": 340, "memory_kb": 25416}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s974406262", "group_id": "codeNet:p03211", "input_text": "object Main extends App {\n val S = io.StdIn.readLine\n\n val out =S.sliding(3).map{ss => math.abs(753 - ss.mkString.toInt)}.min\n\n println(out)\n\n}", "language": "Scala", "metadata": {"date": 1556572659, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03211.html", "problem_id": "p03211", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03211/input.txt", "sample_output_relpath": "derived/input_output/data/p03211/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03211/Scala/s974406262.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s974406262", "user_id": "u620456020"}, "prompt_components": {"gold_output": "34\n", "input_to_evaluate": "object Main extends App {\n val S = io.StdIn.readLine\n\n val out =S.sliding(3).map{ss => math.abs(753 - ss.mkString.toInt)}.min\n\n println(out)\n\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere is a string S consisting of digits 1, 2, ..., 9.\nLunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (She cannot rearrange the digits.)\n\nThe master's favorite number is 753. The closer to this number, the better.\nWhat is the minimum possible (absolute) difference between X and 753?\n\nConstraints\n\nS is a string of length between 4 and 10 (inclusive).\n\nEach character in S is 1, 2, ..., or 9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum possible difference between X and 753.\n\nSample Input 1\n\n1234567876\n\nSample Output 1\n\n34\n\nTaking out the seventh to ninth characters results in X = 787, and the difference between this and 753 is 787 - 753 = 34. The difference cannot be made smaller, no matter where X is taken from.\n\nNote that the digits cannot be rearranged. For example, taking out 567 and rearranging it to 765 is not allowed.\n\nWe cannot take out three digits that are not consecutive from S, either. For example, taking out the seventh digit 7, the ninth digit 7 and the tenth digit 6 to obtain 776 is not allowed.\n\nSample Input 2\n\n35753\n\nSample Output 2\n\n0\n\nIf 753 itself can be taken out, the answer is 0.\n\nSample Input 3\n\n1111111111\n\nSample Output 3\n\n642\n\nNo matter where X is taken from, X = 111, with the difference 753 - 111 = 642.", "sample_input": "1234567876\n"}, "reference_outputs": ["34\n"], "source_document_id": "p03211", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere is a string S consisting of digits 1, 2, ..., 9.\nLunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (She cannot rearrange the digits.)\n\nThe master's favorite number is 753. The closer to this number, the better.\nWhat is the minimum possible (absolute) difference between X and 753?\n\nConstraints\n\nS is a string of length between 4 and 10 (inclusive).\n\nEach character in S is 1, 2, ..., or 9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the minimum possible difference between X and 753.\n\nSample Input 1\n\n1234567876\n\nSample Output 1\n\n34\n\nTaking out the seventh to ninth characters results in X = 787, and the difference between this and 753 is 787 - 753 = 34. The difference cannot be made smaller, no matter where X is taken from.\n\nNote that the digits cannot be rearranged. For example, taking out 567 and rearranging it to 765 is not allowed.\n\nWe cannot take out three digits that are not consecutive from S, either. For example, taking out the seventh digit 7, the ninth digit 7 and the tenth digit 6 to obtain 776 is not allowed.\n\nSample Input 2\n\n35753\n\nSample Output 2\n\n0\n\nIf 753 itself can be taken out, the answer is 0.\n\nSample Input 3\n\n1111111111\n\nSample Output 3\n\n642\n\nNo matter where X is taken from, X = 111, with the difference 753 - 111 = 642.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 146, "cpu_time_ms": 324, "memory_kb": 25408}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s872269936", "group_id": "codeNet:p03213", "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\n def add(a: mutable.Map[Int, Int], b: mutable.Map[Int, Int]): mutable.Map[Int, Int] = {\n val res = mutable.Map[Int, Int]().withDefaultValue(0)\n res ++= a\n b.foreach { case (f, cnt) => res(f) = res(f) + cnt }\n res\n }\n\n val factors = map(N - 1, 2) { i =>\n factorize(i)\n }.foldLeft(mutable.Map[Int, Int]())(add)\n\n val C = factors.values.toArray\n var ans = 0\n\n def count1(a: Int) = {\n C.count(_ >= a - 1)\n }\n\n // a < b\n def count2(a: Int, b: Int) = {\n val cb = C.count(_ >= b - 1)\n val ca = C.count(_ >= a - 1) - cb\n\n ca * cb + (if (cb > 1) cb * (cb - 1) else 0)\n }\n\n // a < b == c\n def count3(a: Int, b: Int) = {\n val cb = C.count(_ >= b - 1)\n val ca = C.count(_ >= a - 1) - cb\n\n var res = 0\n if (cb > 1) {\n res += ca * cb * (cb - 1) / 2\n }\n if (cb > 2) {\n res += cb * (cb - 1) * (cb - 2) / 2\n }\n res\n }\n\n ans += count1(75)\n ans += count2(5, 15)\n ans += count2(3, 25)\n ans += count3(3, 5)\n\n\n out.println(ans)\n }\n\n /**\n * *注意* IntをLongにして使わないこと\n */\n def factorize(n: Int): mutable.Map[Int, Int] = {\n import scala.collection.mutable\n val res = mutable.Map[Int, Int]() withDefaultValue 0\n\n def minFactor(n0: Int, rt: Int, i: Int): Int = {\n if (i > rt) n0 // √n まで見つからなかったら n0は素数か1\n else if (n0 % i == 0) i\n else minFactor(n0, rt, i + 1)\n }\n\n def step(n0: Int): Unit = {\n minFactor(n0, math.sqrt(n0).toInt, 2) match {\n case 1 =>\n case f =>\n res(f) = res(f) + 1\n step(n0 / f)\n }\n }\n\n step(n)\n res\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": 1543806952, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03213.html", "problem_id": "p03213", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03213/input.txt", "sample_output_relpath": "derived/input_output/data/p03213/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03213/Scala/s872269936.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s872269936", "user_id": "u460609472"}, "prompt_components": {"gold_output": "0\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\n def add(a: mutable.Map[Int, Int], b: mutable.Map[Int, Int]): mutable.Map[Int, Int] = {\n val res = mutable.Map[Int, Int]().withDefaultValue(0)\n res ++= a\n b.foreach { case (f, cnt) => res(f) = res(f) + cnt }\n res\n }\n\n val factors = map(N - 1, 2) { i =>\n factorize(i)\n }.foldLeft(mutable.Map[Int, Int]())(add)\n\n val C = factors.values.toArray\n var ans = 0\n\n def count1(a: Int) = {\n C.count(_ >= a - 1)\n }\n\n // a < b\n def count2(a: Int, b: Int) = {\n val cb = C.count(_ >= b - 1)\n val ca = C.count(_ >= a - 1) - cb\n\n ca * cb + (if (cb > 1) cb * (cb - 1) else 0)\n }\n\n // a < b == c\n def count3(a: Int, b: Int) = {\n val cb = C.count(_ >= b - 1)\n val ca = C.count(_ >= a - 1) - cb\n\n var res = 0\n if (cb > 1) {\n res += ca * cb * (cb - 1) / 2\n }\n if (cb > 2) {\n res += cb * (cb - 1) * (cb - 2) / 2\n }\n res\n }\n\n ans += count1(75)\n ans += count2(5, 15)\n ans += count2(3, 25)\n ans += count3(3, 5)\n\n\n out.println(ans)\n }\n\n /**\n * *注意* IntをLongにして使わないこと\n */\n def factorize(n: Int): mutable.Map[Int, Int] = {\n import scala.collection.mutable\n val res = mutable.Map[Int, Int]() withDefaultValue 0\n\n def minFactor(n0: Int, rt: Int, i: Int): Int = {\n if (i > rt) n0 // √n まで見つからなかったら n0は素数か1\n else if (n0 % i == 0) i\n else minFactor(n0, rt, i + 1)\n }\n\n def step(n0: Int): Unit = {\n minFactor(n0, math.sqrt(n0).toInt, 2) match {\n case 1 =>\n case f =>\n res(f) = res(f) + 1\n step(n0 / f)\n }\n }\n\n step(n)\n res\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 : 400 points\n\nProblem Statement\n\nYou are given an integer N. Among the divisors of N! (= 1 \\times 2 \\times ... \\times N), how many Shichi-Go numbers (literally \"Seven-Five numbers\") are there?\n\nHere, a Shichi-Go number is a positive integer that has exactly 75 divisors.\n\nNote\n\nWhen a positive integer A divides a positive integer B, A is said to a divisor of B.\nFor example, 6 has four divisors: 1, 2, 3 and 6.\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\nPrint the number of the Shichi-Go numbers that are divisors of N!.\n\nSample Input 1\n\n9\n\nSample Output 1\n\n0\n\nThere are no Shichi-Go numbers among the divisors of 9! = 1 \\times 2 \\times ... \\times 9 = 362880.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n1\n\nThere is one Shichi-Go number among the divisors of 10! = 3628800: 32400.\n\nSample Input 3\n\n100\n\nSample Output 3\n\n543", "sample_input": "9\n"}, "reference_outputs": ["0\n"], "source_document_id": "p03213", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given an integer N. Among the divisors of N! (= 1 \\times 2 \\times ... \\times N), how many Shichi-Go numbers (literally \"Seven-Five numbers\") are there?\n\nHere, a Shichi-Go number is a positive integer that has exactly 75 divisors.\n\nNote\n\nWhen a positive integer A divides a positive integer B, A is said to a divisor of B.\nFor example, 6 has four divisors: 1, 2, 3 and 6.\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\nPrint the number of the Shichi-Go numbers that are divisors of N!.\n\nSample Input 1\n\n9\n\nSample Output 1\n\n0\n\nThere are no Shichi-Go numbers among the divisors of 9! = 1 \\times 2 \\times ... \\times 9 = 362880.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n1\n\nThere is one Shichi-Go number among the divisors of 10! = 3628800: 32400.\n\nSample Input 3\n\n100\n\nSample Output 3\n\n543", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4122, "cpu_time_ms": 347, "memory_kb": 27192}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s554637947", "group_id": "codeNet:p03216", "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 S = ns(N)\n val Q = ni()\n val K = na(Q)\n\n val cumD, cumM, cumDM = Array.ofDim[Long](N + 1)\n rep(N) { i =>\n cumD(i + 1) = cumD(i) + (if(S(i) == 'D') 1 else 0)\n cumM(i + 1) = cumM(i) + (if(S(i) == 'M') 1 else 0)\n cumDM(i + 1) = cumDM(i) + (if(S(i) == 'M') cumD(i) else 0)\n }\n\n val C = {\n var p = 0\n rep(N) { i =>\n if (S(i) == 'C') p += 1\n }\n val res = Array.ofDim[Int](p)\n rep_r(N) { i =>\n if (S(i) == 'C') {\n p -= 1\n res(p) = i\n }\n }\n res\n }\n\n K.foreach { k =>\n var ans = 0L\n rep(C.length) { i =>\n val c = C(i)\n val dm = if (c >= k) {\n val d = cumD(c - k + 1)\n val m = cumM(c + 1) - cumM(c - k + 1)\n cumDM(c + 1) - cumDM(c - k + 1) - d * m\n } else {\n cumDM(c + 1)\n }\n ans += dm\n }\n out.println(ans)\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, 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[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": 1543211587, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03216.html", "problem_id": "p03216", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03216/input.txt", "sample_output_relpath": "derived/input_output/data/p03216/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03216/Scala/s554637947.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s554637947", "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 S = ns(N)\n val Q = ni()\n val K = na(Q)\n\n val cumD, cumM, cumDM = Array.ofDim[Long](N + 1)\n rep(N) { i =>\n cumD(i + 1) = cumD(i) + (if(S(i) == 'D') 1 else 0)\n cumM(i + 1) = cumM(i) + (if(S(i) == 'M') 1 else 0)\n cumDM(i + 1) = cumDM(i) + (if(S(i) == 'M') cumD(i) else 0)\n }\n\n val C = {\n var p = 0\n rep(N) { i =>\n if (S(i) == 'C') p += 1\n }\n val res = Array.ofDim[Int](p)\n rep_r(N) { i =>\n if (S(i) == 'C') {\n p -= 1\n res(p) = i\n }\n }\n res\n }\n\n K.foreach { k =>\n var ans = 0L\n rep(C.length) { i =>\n val c = C(i)\n val dm = if (c >= k) {\n val d = cumD(c - k + 1)\n val m = cumM(c + 1) - cumM(c - k + 1)\n cumDM(c + 1) - cumDM(c - k + 1) - d * m\n } else {\n cumDM(c + 1)\n }\n ans += dm\n }\n out.println(ans)\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, 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[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 : 600 points\n\nProblem Statement\n\nIn Dwango Co., Ltd., there is a content distribution system named 'Dwango Media Cluster', and it is called 'DMC' for short.\n\nThe name 'DMC' sounds cool for Niwango-kun, so he starts to define DMC-ness of a string.\n\nGiven a string S of length N and an integer k (k \\geq 3),\nhe defines the k-DMC number of S as the number of triples (a, b, c) of integers that satisfy the following conditions:\n\n0 \\leq a < b < c \\leq N - 1\n\nS[a] = D\n\nS[b] = M\n\nS[c] = C\n\nc-a < k\n\nHere S[a] is the a-th character of the string S. Indexing is zero-based, that is, 0 \\leq a \\leq N - 1 holds.\n\nFor a string S and Q integers k_0, k_1, ..., k_{Q-1}, calculate the k_i-DMC number of S for each i (0 \\leq i \\leq Q-1).\n\nConstraints\n\n3 \\leq N \\leq 10^6\n\nS consists of uppercase English letters\n\n1 \\leq Q \\leq 75\n\n3 \\leq k_i \\leq N\n\nAll numbers given in input are integers\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\nQ\nk_{0} k_{1} ... k_{Q-1}\n\nOutput\n\nPrint Q lines.\nThe i-th line should contain the k_i-DMC number of the string S.\n\nSample Input 1\n\n18\nDWANGOMEDIACLUSTER\n1\n18\n\nSample Output 1\n\n1\n\n(a,b,c) = (0, 6, 11) satisfies the conditions.\n\nStrangely, Dwango Media Cluster does not have so much DMC-ness by his definition.\n\nSample Input 2\n\n18\nDDDDDDMMMMMCCCCCCC\n1\n18\n\nSample Output 2\n\n210\n\nThe number of triples can be calculated as 6\\times 5\\times 7.\n\nSample Input 3\n\n54\nDIALUPWIDEAREANETWORKGAMINGOPERATIONCORPORATIONLIMITED\n3\n20 30 40\n\nSample Output 3\n\n0\n1\n2\n\n(a, b, c) = (0, 23, 36), (8, 23, 36) satisfy the conditions except the last one, namely, c-a < k_i.\n\nBy the way, DWANGO is an acronym for \"Dial-up Wide Area Network Gaming Operation\".\n\nSample Output 4\n\n30\nDMCDMCDMCDMCDMCDMCDMCDMCDMCDMC\n4\n5 10 15 20\n\nSample Output 4\n\n10\n52\n110\n140", "sample_input": "18\nDWANGOMEDIACLUSTER\n1\n18\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03216", "source_text": "Score : 600 points\n\nProblem Statement\n\nIn Dwango Co., Ltd., there is a content distribution system named 'Dwango Media Cluster', and it is called 'DMC' for short.\n\nThe name 'DMC' sounds cool for Niwango-kun, so he starts to define DMC-ness of a string.\n\nGiven a string S of length N and an integer k (k \\geq 3),\nhe defines the k-DMC number of S as the number of triples (a, b, c) of integers that satisfy the following conditions:\n\n0 \\leq a < b < c \\leq N - 1\n\nS[a] = D\n\nS[b] = M\n\nS[c] = C\n\nc-a < k\n\nHere S[a] is the a-th character of the string S. Indexing is zero-based, that is, 0 \\leq a \\leq N - 1 holds.\n\nFor a string S and Q integers k_0, k_1, ..., k_{Q-1}, calculate the k_i-DMC number of S for each i (0 \\leq i \\leq Q-1).\n\nConstraints\n\n3 \\leq N \\leq 10^6\n\nS consists of uppercase English letters\n\n1 \\leq Q \\leq 75\n\n3 \\leq k_i \\leq N\n\nAll numbers given in input are integers\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\nQ\nk_{0} k_{1} ... k_{Q-1}\n\nOutput\n\nPrint Q lines.\nThe i-th line should contain the k_i-DMC number of the string S.\n\nSample Input 1\n\n18\nDWANGOMEDIACLUSTER\n1\n18\n\nSample Output 1\n\n1\n\n(a,b,c) = (0, 6, 11) satisfies the conditions.\n\nStrangely, Dwango Media Cluster does not have so much DMC-ness by his definition.\n\nSample Input 2\n\n18\nDDDDDDMMMMMCCCCCCC\n1\n18\n\nSample Output 2\n\n210\n\nThe number of triples can be calculated as 6\\times 5\\times 7.\n\nSample Input 3\n\n54\nDIALUPWIDEAREANETWORKGAMINGOPERATIONCORPORATIONLIMITED\n3\n20 30 40\n\nSample Output 3\n\n0\n1\n2\n\n(a, b, c) = (0, 23, 36), (8, 23, 36) satisfy the conditions except the last one, namely, c-a < k_i.\n\nBy the way, DWANGO is an acronym for \"Dial-up Wide Area Network Gaming Operation\".\n\nSample Output 4\n\n30\nDMCDMCDMCDMCDMCDMCDMCDMCDMCDMC\n4\n5 10 15 20\n\nSample Output 4\n\n10\n52\n110\n140", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3345, "cpu_time_ms": 897, "memory_kb": 61288}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s323435592", "group_id": "codeNet:p03220", "input_text": "object Main extends App {\n import scala.io.StdIn.{readInt, readLine}\n\n val elevationRate = 0.006\n def averageTemperature(T: Double)(elevation: Int) : Double = T - elevation * elevationRate\n\n val _ = readInt()\n val Array(t, a) = readLine().split(' ').map(_.toInt)\n val elevations = readLine().split(' ').map(_.toInt)\n\n val distancesFromA = elevations.map(averageTemperature(t)(_) - a)\n\n println(distancesFromA.zipWithIndex.minBy(_._1.abs)._2 + 1)\n}", "language": "Scala", "metadata": {"date": 1598280112, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/s323435592.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s323435592", "user_id": "u388106329"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main extends App {\n import scala.io.StdIn.{readInt, readLine}\n\n val elevationRate = 0.006\n def averageTemperature(T: Double)(elevation: Int) : Double = T - elevation * elevationRate\n\n val _ = readInt()\n val Array(t, a) = readLine().split(' ').map(_.toInt)\n val elevations = readLine().split(' ').map(_.toInt)\n\n val distancesFromA = elevations.map(averageTemperature(t)(_) - a)\n\n println(distancesFromA.zipWithIndex.minBy(_._1.abs)._2 + 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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 522, "memory_kb": 54908}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s591431286", "group_id": "codeNet:p03220", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val N, T, A = sc.nextInt()\n val Hs = List.fill(N)(sc.nextInt())\n val (_, index) :: _ = Hs.zipWithIndex.sortBy { case (h, _) => (A - T + h * 0.006).abs }\n println(index + 1)\n}\n", "language": "Scala", "metadata": {"date": 1593650163, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/s591431286.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s591431286", "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 N, T, A = sc.nextInt()\n val Hs = List.fill(N)(sc.nextInt())\n val (_, index) :: _ = Hs.zipWithIndex.sortBy { case (h, _) => (A - T + h * 0.006).abs }\n println(index + 1)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 577, "memory_kb": 56060}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s764435449", "group_id": "codeNet:p03220", "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 _ = in.readLine().toInt\n val Array(t, a) = in.readLine().split(\"\\\\s+\").map(_.toInt)\n val hs = in.readLine().split(\"\\\\s+\").map(_.toInt)\n\n val tm = t * 1000\n val am = a * 1000\n out.println(hs.map(h => Math.abs(tm - h * 6 - am)).zipWithIndex.minBy(_._1)._2 + 1)\n\n out.flush()\n }\n}\n", "language": "Scala", "metadata": {"date": 1586661334, "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/s764435449.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s764435449", "user_id": "u178269371"}, "prompt_components": {"gold_output": "1\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 _ = in.readLine().toInt\n val Array(t, a) = in.readLine().split(\"\\\\s+\").map(_.toInt)\n val hs = in.readLine().split(\"\\\\s+\").map(_.toInt)\n\n val tm = t * 1000\n val am = a * 1000\n out.println(hs.map(h => Math.abs(tm - h * 6 - am)).zipWithIndex.minBy(_._1)._2 + 1)\n\n out.flush()\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 582, "cpu_time_ms": 347, "memory_kb": 27468}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s714867589", "group_id": "codeNet:p03221", "input_text": "object Main {\n\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val N, M = sc.nextInt()\n\n case class City(i: Int, year: Int)\n val prefectures = Array.fill(N+1)(\n new scala.collection.mutable.PriorityQueue[City]()(\n Ordering.by[City, Int](c => c.year)(Ordering.Int.reverse)))\n val result = new Array[String](M)\n\n (0 until M) foreach { i =>\n val p, y = sc.nextInt()\n prefectures(p).enqueue(City(i, y))\n }\n\n val format = (n: Int) => \"%06d\".format(n)\n\n (1 to N). foreach { p =>\n val prefecture = prefectures(p)\n var i = 1\n while (prefecture.nonEmpty) {\n val city = prefecture.dequeue()\n result(city.i) = s\"${format(p)}${format(i)}\"\n i += 1\n }\n }\n\n println(result.mkString(\"\\n\"))\n\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1562382165, "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/s714867589.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s714867589", "user_id": "u891387249"}, "prompt_components": {"gold_output": "000001000002\n000002000001\n000001000001\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, M = sc.nextInt()\n\n case class City(i: Int, year: Int)\n val prefectures = Array.fill(N+1)(\n new scala.collection.mutable.PriorityQueue[City]()(\n Ordering.by[City, Int](c => c.year)(Ordering.Int.reverse)))\n val result = new Array[String](M)\n\n (0 until M) foreach { i =>\n val p, y = sc.nextInt()\n prefectures(p).enqueue(City(i, y))\n }\n\n val format = (n: Int) => \"%06d\".format(n)\n\n (1 to N). foreach { p =>\n val prefecture = prefectures(p)\n var i = 1\n while (prefecture.nonEmpty) {\n val city = prefecture.dequeue()\n result(city.i) = s\"${format(p)}${format(i)}\"\n i += 1\n }\n }\n\n println(result.mkString(\"\\n\"))\n\n }\n\n}\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "sample_input": "2 3\n1 32\n2 63\n1 12\n"}, "reference_outputs": ["000001000002\n000002000001\n000001000001\n"], "source_document_id": "p03221", "source_text": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 816, "cpu_time_ms": 2123, "memory_kb": 133460}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s522750556", "group_id": "codeNet:p03221", "input_text": "object Main extends App {\n\tcase class Town(val p: Int, val y: Long)\n\n\tval Array(n, m) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n \t\n \tval pN = new Array[Int](n)\n \tval id = new Array[Long](m)\n\n \tval towns = {for(i<-0 until m) yield{\n \t\tval Array(p, y) = scala.io.StdIn.readLine.split(\" \")\n \t\tTown(p.toInt, y.toLong)\n \t}}.zipWithIndex.sortBy(_._1.y)\n\n\n \tfor((t, i) <- towns){\n \t\tpN(t.p - 1) += 1\n \t\tid(i) = 1000000000000L + t.p*1000000L + pN(t.p - 1) \n \t}\n\n \tid.foreach{z => println(z.toString.takeRight(12))}\n} ", "language": "Scala", "metadata": {"date": 1542389627, "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/s522750556.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s522750556", "user_id": "u675876401"}, "prompt_components": {"gold_output": "000001000002\n000002000001\n000001000001\n", "input_to_evaluate": "object Main extends App {\n\tcase class Town(val p: Int, val y: Long)\n\n\tval Array(n, m) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n \t\n \tval pN = new Array[Int](n)\n \tval id = new Array[Long](m)\n\n \tval towns = {for(i<-0 until m) yield{\n \t\tval Array(p, y) = scala.io.StdIn.readLine.split(\" \")\n \t\tTown(p.toInt, y.toLong)\n \t}}.zipWithIndex.sortBy(_._1.y)\n\n\n \tfor((t, i) <- towns){\n \t\tpN(t.p - 1) += 1\n \t\tid(i) = 1000000000000L + t.p*1000000L + pN(t.p - 1) \n \t}\n\n \tid.foreach{z => println(z.toString.takeRight(12))}\n} ", "problem_context": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "sample_input": "2 3\n1 32\n2 63\n1 12\n"}, "reference_outputs": ["000001000002\n000002000001\n000001000001\n"], "source_document_id": "p03221", "source_text": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 517, "cpu_time_ms": 2025, "memory_kb": 82104}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s115726568", "group_id": "codeNet:p03221", "input_text": "object Main extends App {\n val lines = io.Source.stdin.getLines.toIndexedSeq\n //val N = lines.head.split(' ').map(_.toInt).head\n //val accs = (0 until N).toArray.map(_=>0)\n val line = lines.tail.zipWithIndex.map{ case (e, gi) =>\n val tmp = e.split(' ').map(_.toInt).toArray\n (tmp(0), (tmp(1), gi))\n }\n val maxgi=line.size\n var idMap=Map[Int, String]()\n val groupByP = line.groupBy(_._1).foreach{ case (pgr, ylist) =>\n \tylist.sortBy(_._2).zipWithIndex.foreach{ case (yi, yindex) =>\n val gi = yi._2._2\n val id = \"%06d%06d\".format(pgr, (yindex+1))\n //println(gi, id)\n idMap = idMap + (gi -> id)\n }\n }\n (0 until maxgi).foreach(i => println(idMap(i)))\n}", "language": "Scala", "metadata": {"date": 1541915861, "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/s115726568.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s115726568", "user_id": "u699236457"}, "prompt_components": {"gold_output": "000001000002\n000002000001\n000001000001\n", "input_to_evaluate": "object Main extends App {\n val lines = io.Source.stdin.getLines.toIndexedSeq\n //val N = lines.head.split(' ').map(_.toInt).head\n //val accs = (0 until N).toArray.map(_=>0)\n val line = lines.tail.zipWithIndex.map{ case (e, gi) =>\n val tmp = e.split(' ').map(_.toInt).toArray\n (tmp(0), (tmp(1), gi))\n }\n val maxgi=line.size\n var idMap=Map[Int, String]()\n val groupByP = line.groupBy(_._1).foreach{ case (pgr, ylist) =>\n \tylist.sortBy(_._2).zipWithIndex.foreach{ case (yi, yindex) =>\n val gi = yi._2._2\n val id = \"%06d%06d\".format(pgr, (yindex+1))\n //println(gi, id)\n idMap = idMap + (gi -> id)\n }\n }\n (0 until maxgi).foreach(i => println(idMap(i)))\n}", "problem_context": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "sample_input": "2 3\n1 32\n2 63\n1 12\n"}, "reference_outputs": ["000001000002\n000002000001\n000001000001\n"], "source_document_id": "p03221", "source_text": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 689, "cpu_time_ms": 2119, "memory_kb": 151084}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s638149718", "group_id": "codeNet:p03221", "input_text": "object Main extends App {\n\n val (n, m) = readLine.split(\" \").map(_.toInt) match {\n case Array(n, m) => (n, m)\n }\n\n val lines: Seq[(Int, Int)] = (1 to m)\n .map(_ =>\n readLine.split(\" \").map(_.toInt) match {\n case Array(p, y) => (p, y)\n })\n\n val map: Map[Int, Map[Int, Int]] =\n lines\n .groupBy(_._1)\n .mapValues(\n _.sortBy(_._2).zipWithIndex.map {\n case ((p, y), index) => (y, index + 1)\n }.toMap\n )\n\n def convert(p: Int, order: Int) = f\"${p}%06d${order}%06d\"\n val pw = new java.io.PrintWriter(System.out)\n lines.map { case (p, y) => convert(p, map(p)(y)) }.foreach{ res =>\n pw.println(res)\n }\n pw.flush\n}", "language": "Scala", "metadata": {"date": 1541393466, "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/s638149718.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s638149718", "user_id": "u149419355"}, "prompt_components": {"gold_output": "000001000002\n000002000001\n000001000001\n", "input_to_evaluate": "object Main extends App {\n\n val (n, m) = readLine.split(\" \").map(_.toInt) match {\n case Array(n, m) => (n, m)\n }\n\n val lines: Seq[(Int, Int)] = (1 to m)\n .map(_ =>\n readLine.split(\" \").map(_.toInt) match {\n case Array(p, y) => (p, y)\n })\n\n val map: Map[Int, Map[Int, Int]] =\n lines\n .groupBy(_._1)\n .mapValues(\n _.sortBy(_._2).zipWithIndex.map {\n case ((p, y), index) => (y, index + 1)\n }.toMap\n )\n\n def convert(p: Int, order: Int) = f\"${p}%06d${order}%06d\"\n val pw = new java.io.PrintWriter(System.out)\n lines.map { case (p, y) => convert(p, map(p)(y)) }.foreach{ res =>\n pw.println(res)\n }\n pw.flush\n}", "problem_context": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "sample_input": "2 3\n1 32\n2 63\n1 12\n"}, "reference_outputs": ["000001000002\n000002000001\n000001000001\n"], "source_document_id": "p03221", "source_text": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 679, "cpu_time_ms": 2119, "memory_kb": 154744}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s112732302", "group_id": "codeNet:p03221", "input_text": "object Main extends App {\n val (n, m) = readLine.split(\" \").map(_.toInt) match {\n case Array(n, m) => (n, m)\n }\n\n def convert(p: Int, order: Int) = f\"${p}%06d${order}%06d\"\n\n val lines: Array[Array[Int]] = (1 to m).toArray.map(id =>\n readLine.split(\" \").map(_.toInt) match { case Array(p, y) => Array(id, p, y) })\n\n def order(a1: Array[Int], a2: Array[Int]): Boolean =\n if (a1(1) == a1(1)) a1(2) < a1(2) else a1(1) < a1(1)\n\n var currentP = 0\n var currentIndex = 1\n\n def next(a: Array[Int]) = {\n if (a(1) == currentP) currentIndex = currentIndex + 1 else {\n currentIndex = 1\n currentP = a(1)\n }\n Array(a(0), a(1), currentIndex)\n }\n\n lines\n .sortWith(order)\n .map(next)\n .sortBy(_(0))\n .foreach(a => println(convert(a(1), a(2))))\n\n}", "language": "Scala", "metadata": {"date": 1541392479, "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/s112732302.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s112732302", "user_id": "u149419355"}, "prompt_components": {"gold_output": "000001000002\n000002000001\n000001000001\n", "input_to_evaluate": "object Main extends App {\n val (n, m) = readLine.split(\" \").map(_.toInt) match {\n case Array(n, m) => (n, m)\n }\n\n def convert(p: Int, order: Int) = f\"${p}%06d${order}%06d\"\n\n val lines: Array[Array[Int]] = (1 to m).toArray.map(id =>\n readLine.split(\" \").map(_.toInt) match { case Array(p, y) => Array(id, p, y) })\n\n def order(a1: Array[Int], a2: Array[Int]): Boolean =\n if (a1(1) == a1(1)) a1(2) < a1(2) else a1(1) < a1(1)\n\n var currentP = 0\n var currentIndex = 1\n\n def next(a: Array[Int]) = {\n if (a(1) == currentP) currentIndex = currentIndex + 1 else {\n currentIndex = 1\n currentP = a(1)\n }\n Array(a(0), a(1), currentIndex)\n }\n\n lines\n .sortWith(order)\n .map(next)\n .sortBy(_(0))\n .foreach(a => println(convert(a(1), a(2))))\n\n}", "problem_context": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "sample_input": "2 3\n1 32\n2 63\n1 12\n"}, "reference_outputs": ["000001000002\n000002000001\n000001000001\n"], "source_document_id": "p03221", "source_text": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 779, "cpu_time_ms": 2119, "memory_kb": 88732}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s413419475", "group_id": "codeNet:p03225", "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 H, W = in.next().toInt\n val s = new Array[String](H)\n for (i <- 0 until H) {\n s(i) = in.next()\n }\n\n //\n def manhattan(p1: (Int, Int), p2: (Int, Int)): Int = {\n val (x1, y1) = p1\n val (x2, y2) = p2\n\n (x1 - x2).abs + (y1 - y2).abs\n }\n\n var pairs: List[(Int, Int)] = Nil\n\n for(y <- 0 until H; x <- 0 until W) {\n if(s(y)(x) == '#') {\n pairs = (x+1, y+1) :: pairs\n }\n }\n\n var ans = 0\n\n val ar = pairs.toArray\n val l = ar.length\n for(i <- 0 until l-1) {\n for(k <- i+1 until l) {\n val dist = manhattan(ar(i), ar(k))\n for(m <- k+1 until l) {\n if(manhattan(ar(i), ar(m)) == dist && manhattan(ar(k), ar(m)) == dist)\n ans += 1\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": 1540693920, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03225.html", "problem_id": "p03225", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03225/input.txt", "sample_output_relpath": "derived/input_output/data/p03225/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03225/Scala/s413419475.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s413419475", "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 H, W = in.next().toInt\n val s = new Array[String](H)\n for (i <- 0 until H) {\n s(i) = in.next()\n }\n\n //\n def manhattan(p1: (Int, Int), p2: (Int, Int)): Int = {\n val (x1, y1) = p1\n val (x2, y2) = p2\n\n (x1 - x2).abs + (y1 - y2).abs\n }\n\n var pairs: List[(Int, Int)] = Nil\n\n for(y <- 0 until H; x <- 0 until W) {\n if(s(y)(x) == '#') {\n pairs = (x+1, y+1) :: pairs\n }\n }\n\n var ans = 0\n\n val ar = pairs.toArray\n val l = ar.length\n for(i <- 0 until l-1) {\n for(k <- i+1 until l) {\n val dist = manhattan(ar(i), ar(k))\n for(m <- k+1 until l) {\n if(manhattan(ar(i), ar(m)) == dist && manhattan(ar(k), ar(m)) == dist)\n ans += 1\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 : 700 points\n\nProblem Statement\n\nThere are some coins in the xy-plane.\nThe positions of the coins are represented by a grid of characters with H rows and W columns.\nIf the character at the i-th row and j-th column, s_{ij}, is #, there is one coin at point (i,j); if that character is ., there is no coin at point (i,j). There are no other coins in the xy-plane.\n\nThere is no coin at point (x,y) where 1\\leq i\\leq H,1\\leq j\\leq W does not hold.\nThere is also no coin at point (x,y) where x or y (or both) is not an integer.\nAdditionally, two or more coins never exist at the same point.\n\nFind the number of triples of different coins that satisfy the following condition:\n\nChoosing any two of the three coins would result in the same Manhattan distance between the points where they exist.\n\nHere, the Manhattan distance between points (x,y) and (x',y') is |x-x'|+|y-y'|.\nTwo triples are considered the same if the only difference between them is the order of the coins.\n\nConstraints\n\n1 \\leq H,W \\leq 300\n\ns_{ij} is # or ..\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 number of triples that satisfy the condition.\n\nSample Input 1\n\n5 4\n#.##\n.##.\n#...\n..##\n...#\n\nSample Output 1\n\n3\n\n((1,1),(1,3),(2,2)),((1,1),(2,2),(3,1)) and ((1,3),(3,1),(4,4)) satisfy the condition.\n\nSample Input 2\n\n13 27\n......#.........#.......#..\n#############...#.....###..\n..............#####...##...\n...#######......#...#######\n...#.....#.....###...#...#.\n...#######....#.#.#.#.###.#\n..............#.#.#...#.#..\n#############.#.#.#...###..\n#...........#...#...#######\n#..#######..#...#...#.....#\n#..#.....#..#...#...#.###.#\n#..#######..#...#...#.#.#.#\n#..........##...#...#.#####\n\nSample Output 2\n\n870", "sample_input": "5 4\n#.##\n.##.\n#...\n..##\n...#\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03225", "source_text": "Score : 700 points\n\nProblem Statement\n\nThere are some coins in the xy-plane.\nThe positions of the coins are represented by a grid of characters with H rows and W columns.\nIf the character at the i-th row and j-th column, s_{ij}, is #, there is one coin at point (i,j); if that character is ., there is no coin at point (i,j). There are no other coins in the xy-plane.\n\nThere is no coin at point (x,y) where 1\\leq i\\leq H,1\\leq j\\leq W does not hold.\nThere is also no coin at point (x,y) where x or y (or both) is not an integer.\nAdditionally, two or more coins never exist at the same point.\n\nFind the number of triples of different coins that satisfy the following condition:\n\nChoosing any two of the three coins would result in the same Manhattan distance between the points where they exist.\n\nHere, the Manhattan distance between points (x,y) and (x',y') is |x-x'|+|y-y'|.\nTwo triples are considered the same if the only difference between them is the order of the coins.\n\nConstraints\n\n1 \\leq H,W \\leq 300\n\ns_{ij} is # or ..\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 number of triples that satisfy the condition.\n\nSample Input 1\n\n5 4\n#.##\n.##.\n#...\n..##\n...#\n\nSample Output 1\n\n3\n\n((1,1),(1,3),(2,2)),((1,1),(2,2),(3,1)) and ((1,3),(3,1),(4,4)) satisfy the condition.\n\nSample Input 2\n\n13 27\n......#.........#.......#..\n#############...#.....###..\n..............#####...##...\n...#######......#...#######\n...#.....#.....###...#...#.\n...#######....#.#.#.#.###.#\n..............#.#.#...#.#..\n#############.#.#.#...###..\n#...........#...#...#######\n#..#######..#...#...#.....#\n#..#.....#..#...#...#.###.#\n#..#######..#...#...#.#.#.#\n#..........##...#...#.#####\n\nSample Output 2\n\n870", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 42968}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s941090861", "group_id": "codeNet:p03231", "input_text": "object Main{\n def main(args:Array[String]):Unit={\n var MN = readLine\n var S = readLine\n var T = readLine\n var res = new calculate(S,T)\n \n println(res.calculate())\n\n }\n}\n\nimport scala.collection.mutable.ArrayBuffer\n\nclass calculate(s:String,t:String){\n var lens = s.length\n var lent = t.length\n\n def calculate():Int={\n var lcm = getLCM()\n var res = lcm\n\n var record:Map[Int,String] = Map()\n\n for(i <- 0 until lens){\n var temp = i*(lcm/lens)+1\n record += (temp -> s.charAt(i).toString)\n }\n var flag = true\n for(i <- 0 until lent if flag){\n var temp = i*(lcm/lent)+1\n var tempRecord = record.getOrElse(temp,\"0\")\n if(!tempRecord.equals(\"0\") && !tempRecord.equals(t.charAt(i).toString)){\n flag = false\n res = -1\n }\n }\n res\n }\n\n\n\n def getLCM():Int={\n return lens*lent/getGCD\n }\n\n def getGCD():Int={\n var tempN = lens\n var tempM = lent\n var c = lens % lent\n while(c!=0){\n tempN = tempM\n tempM = c\n c = tempN % tempM\n }\n return tempM\n }\n}", "language": "Scala", "metadata": {"date": 1542761600, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03231.html", "problem_id": "p03231", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03231/input.txt", "sample_output_relpath": "derived/input_output/data/p03231/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03231/Scala/s941090861.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s941090861", "user_id": "u825805112"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "object Main{\n def main(args:Array[String]):Unit={\n var MN = readLine\n var S = readLine\n var T = readLine\n var res = new calculate(S,T)\n \n println(res.calculate())\n\n }\n}\n\nimport scala.collection.mutable.ArrayBuffer\n\nclass calculate(s:String,t:String){\n var lens = s.length\n var lent = t.length\n\n def calculate():Int={\n var lcm = getLCM()\n var res = lcm\n\n var record:Map[Int,String] = Map()\n\n for(i <- 0 until lens){\n var temp = i*(lcm/lens)+1\n record += (temp -> s.charAt(i).toString)\n }\n var flag = true\n for(i <- 0 until lent if flag){\n var temp = i*(lcm/lent)+1\n var tempRecord = record.getOrElse(temp,\"0\")\n if(!tempRecord.equals(\"0\") && !tempRecord.equals(t.charAt(i).toString)){\n flag = false\n res = -1\n }\n }\n res\n }\n\n\n\n def getLCM():Int={\n return lens*lent/getGCD\n }\n\n def getGCD():Int={\n var tempN = lens\n var tempM = lent\n var c = lens % lent\n while(c!=0){\n tempN = tempM\n tempM = c\n c = tempN % tempM\n }\n return tempM\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S of length N and another string T of length M.\nThese strings consist of lowercase English letters.\n\nA string X is called a good string when the following conditions are all met:\n\nLet L be the length of X. L is divisible by both N and M.\n\nConcatenating the 1-st, (\\frac{L}{N}+1)-th, (2 \\times \\frac{L}{N}+1)-th, ..., ((N-1)\\times\\frac{L}{N}+1)-th characters of X, without changing the order, results in S.\n\nConcatenating the 1-st, (\\frac{L}{M}+1)-th, (2 \\times \\frac{L}{M}+1)-th, ..., ((M-1)\\times\\frac{L}{M}+1)-th characters of X, without changing the order, results in T.\n\nDetermine if there exists a good string. If it exists, find the length of the shortest such string.\n\nConstraints\n\n1 \\leq N,M \\leq 10^5\n\nS and T consist of lowercase English letters.\n\n|S|=N\n\n|T|=M\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nS\nT\n\nOutput\n\nIf a good string does not exist, print -1; if it exists, print the length of the shortest such string.\n\nSample Input 1\n\n3 2\nacp\nae\n\nSample Output 1\n\n6\n\nFor example, the string accept is a good string.\nThere is no good string shorter than this, so the answer is 6.\n\nSample Input 2\n\n6 3\nabcdef\nabc\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n15 9\ndnsusrayukuaiia\ndujrunuma\n\nSample Output 3\n\n45", "sample_input": "3 2\nacp\nae\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03231", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S of length N and another string T of length M.\nThese strings consist of lowercase English letters.\n\nA string X is called a good string when the following conditions are all met:\n\nLet L be the length of X. L is divisible by both N and M.\n\nConcatenating the 1-st, (\\frac{L}{N}+1)-th, (2 \\times \\frac{L}{N}+1)-th, ..., ((N-1)\\times\\frac{L}{N}+1)-th characters of X, without changing the order, results in S.\n\nConcatenating the 1-st, (\\frac{L}{M}+1)-th, (2 \\times \\frac{L}{M}+1)-th, ..., ((M-1)\\times\\frac{L}{M}+1)-th characters of X, without changing the order, results in T.\n\nDetermine if there exists a good string. If it exists, find the length of the shortest such string.\n\nConstraints\n\n1 \\leq N,M \\leq 10^5\n\nS and T consist of lowercase English letters.\n\n|S|=N\n\n|T|=M\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nS\nT\n\nOutput\n\nIf a good string does not exist, print -1; if it exists, print the length of the shortest such string.\n\nSample Input 1\n\n3 2\nacp\nae\n\nSample Output 1\n\n6\n\nFor example, the string accept is a good string.\nThere is no good string shorter than this, so the answer is 6.\n\nSample Input 2\n\n6 3\nabcdef\nabc\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n15 9\ndnsusrayukuaiia\ndujrunuma\n\nSample Output 3\n\n45", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1065, "cpu_time_ms": 623, "memory_kb": 65132}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s603496158", "group_id": "codeNet:p03238", "input_text": "object Main extends App {\n val i = scala.io.StdIn.readLine().toInt\n\n if (i == 1){\n println(\"Hello World\")\n } else {\n val a = scala.io.StdIn.readLine().toInt\n val b = scala.io.StdIn.readLine().toInt\n println(a+b)\n }\n}", "language": "Scala", "metadata": {"date": 1558154297, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03238.html", "problem_id": "p03238", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03238/input.txt", "sample_output_relpath": "derived/input_output/data/p03238/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03238/Scala/s603496158.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s603496158", "user_id": "u238510421"}, "prompt_components": {"gold_output": "Hello World\n", "input_to_evaluate": "object Main extends App {\n val i = scala.io.StdIn.readLine().toInt\n\n if (i == 1){\n println(\"Hello World\")\n } else {\n val a = scala.io.StdIn.readLine().toInt\n val b = scala.io.StdIn.readLine().toInt\n println(a+b)\n }\n}", "problem_context": "Score: 100 points\n\nProblem Statement\n\nIn 2020, AtCoder Inc. with an annual sales of more than one billion yen (the currency of Japan) has started a business in programming education.\n\nOne day, there was an exam where a one-year-old child must write a program that prints Hello World, and a two-year-old child must write a program that receives integers A, B and prints A+B.\n\nTakahashi, who is taking this exam, suddenly forgets his age.\n\nHe decides to write a program that first receives his age N (1 or 2) as input, then prints Hello World if N=1, and additionally receives integers A, B and prints A+B if N=2.\n\nWrite this program for him.\n\nConstraints\n\nN is 1 or 2.\n\nA is an integer between 1 and 9 (inclusive).\n\nB is an integer between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in one of the following formats:\n\n1\n\n2\nA\nB\n\nOutput\n\nIf N=1, print Hello World; if N=2, print A+B.\n\nSample Input 1\n\n1\n\nSample Output 1\n\nHello World\n\nAs N=1, Takahashi is one year old. Thus, we should print Hello World.\n\nSample Input 2\n\n2\n3\n5\n\nSample Output 2\n\n8\n\nAs N=2, Takahashi is two years old. Thus, we should print A+B, which is 8 since A=3 and B=5.", "sample_input": "1\n"}, "reference_outputs": ["Hello World\n"], "source_document_id": "p03238", "source_text": "Score: 100 points\n\nProblem Statement\n\nIn 2020, AtCoder Inc. with an annual sales of more than one billion yen (the currency of Japan) has started a business in programming education.\n\nOne day, there was an exam where a one-year-old child must write a program that prints Hello World, and a two-year-old child must write a program that receives integers A, B and prints A+B.\n\nTakahashi, who is taking this exam, suddenly forgets his age.\n\nHe decides to write a program that first receives his age N (1 or 2) as input, then prints Hello World if N=1, and additionally receives integers A, B and prints A+B if N=2.\n\nWrite this program for him.\n\nConstraints\n\nN is 1 or 2.\n\nA is an integer between 1 and 9 (inclusive).\n\nB is an integer between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in one of the following formats:\n\n1\n\n2\nA\nB\n\nOutput\n\nIf N=1, print Hello World; if N=2, print A+B.\n\nSample Input 1\n\n1\n\nSample Output 1\n\nHello World\n\nAs N=1, Takahashi is one year old. Thus, we should print Hello World.\n\nSample Input 2\n\n2\n3\n5\n\nSample Output 2\n\n8\n\nAs N=2, Takahashi is two years old. Thus, we should print A+B, which is 8 since A=3 and B=5.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 248, "cpu_time_ms": 320, "memory_kb": 25296}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s795518475", "group_id": "codeNet:p03238", "input_text": "object Main extends App {\n\n val age = io.StdIn.readLine.toInt\n\n val out = age match {\n case 1 => \"Hello World\"\n case 2 => {\n val A = io.StdIn.readLine.toInt\n val B = io.StdIn.readLine.toInt\n (A + B).toString\n }\n }\n\n println(out)\n}\n", "language": "Scala", "metadata": {"date": 1556278827, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03238.html", "problem_id": "p03238", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03238/input.txt", "sample_output_relpath": "derived/input_output/data/p03238/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03238/Scala/s795518475.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s795518475", "user_id": "u620456020"}, "prompt_components": {"gold_output": "Hello World\n", "input_to_evaluate": "object Main extends App {\n\n val age = io.StdIn.readLine.toInt\n\n val out = age match {\n case 1 => \"Hello World\"\n case 2 => {\n val A = io.StdIn.readLine.toInt\n val B = io.StdIn.readLine.toInt\n (A + B).toString\n }\n }\n\n println(out)\n}\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nIn 2020, AtCoder Inc. with an annual sales of more than one billion yen (the currency of Japan) has started a business in programming education.\n\nOne day, there was an exam where a one-year-old child must write a program that prints Hello World, and a two-year-old child must write a program that receives integers A, B and prints A+B.\n\nTakahashi, who is taking this exam, suddenly forgets his age.\n\nHe decides to write a program that first receives his age N (1 or 2) as input, then prints Hello World if N=1, and additionally receives integers A, B and prints A+B if N=2.\n\nWrite this program for him.\n\nConstraints\n\nN is 1 or 2.\n\nA is an integer between 1 and 9 (inclusive).\n\nB is an integer between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in one of the following formats:\n\n1\n\n2\nA\nB\n\nOutput\n\nIf N=1, print Hello World; if N=2, print A+B.\n\nSample Input 1\n\n1\n\nSample Output 1\n\nHello World\n\nAs N=1, Takahashi is one year old. Thus, we should print Hello World.\n\nSample Input 2\n\n2\n3\n5\n\nSample Output 2\n\n8\n\nAs N=2, Takahashi is two years old. Thus, we should print A+B, which is 8 since A=3 and B=5.", "sample_input": "1\n"}, "reference_outputs": ["Hello World\n"], "source_document_id": "p03238", "source_text": "Score: 100 points\n\nProblem Statement\n\nIn 2020, AtCoder Inc. with an annual sales of more than one billion yen (the currency of Japan) has started a business in programming education.\n\nOne day, there was an exam where a one-year-old child must write a program that prints Hello World, and a two-year-old child must write a program that receives integers A, B and prints A+B.\n\nTakahashi, who is taking this exam, suddenly forgets his age.\n\nHe decides to write a program that first receives his age N (1 or 2) as input, then prints Hello World if N=1, and additionally receives integers A, B and prints A+B if N=2.\n\nWrite this program for him.\n\nConstraints\n\nN is 1 or 2.\n\nA is an integer between 1 and 9 (inclusive).\n\nB is an integer between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in one of the following formats:\n\n1\n\n2\nA\nB\n\nOutput\n\nIf N=1, print Hello World; if N=2, print A+B.\n\nSample Input 1\n\n1\n\nSample Output 1\n\nHello World\n\nAs N=1, Takahashi is one year old. Thus, we should print Hello World.\n\nSample Input 2\n\n2\n3\n5\n\nSample Output 2\n\n8\n\nAs N=2, Takahashi is two years old. Thus, we should print A+B, which is 8 since A=3 and B=5.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 259, "cpu_time_ms": 319, "memory_kb": 27320}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s939516140", "group_id": "codeNet:p03238", "input_text": "object Main extends App{\n val sc = new java.util.Scanner(System.in)\n val N = sc.nextInt()\n println (\n if (N==1) \"Hello World\"\n else {\n val A,B = sc.nextInt()\n A+B\n }\n )\n} ", "language": "Scala", "metadata": {"date": 1540690042, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03238.html", "problem_id": "p03238", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03238/input.txt", "sample_output_relpath": "derived/input_output/data/p03238/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03238/Scala/s939516140.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s939516140", "user_id": "u690438113"}, "prompt_components": {"gold_output": "Hello World\n", "input_to_evaluate": "object Main extends App{\n val sc = new java.util.Scanner(System.in)\n val N = sc.nextInt()\n println (\n if (N==1) \"Hello World\"\n else {\n val A,B = sc.nextInt()\n A+B\n }\n )\n} ", "problem_context": "Score: 100 points\n\nProblem Statement\n\nIn 2020, AtCoder Inc. with an annual sales of more than one billion yen (the currency of Japan) has started a business in programming education.\n\nOne day, there was an exam where a one-year-old child must write a program that prints Hello World, and a two-year-old child must write a program that receives integers A, B and prints A+B.\n\nTakahashi, who is taking this exam, suddenly forgets his age.\n\nHe decides to write a program that first receives his age N (1 or 2) as input, then prints Hello World if N=1, and additionally receives integers A, B and prints A+B if N=2.\n\nWrite this program for him.\n\nConstraints\n\nN is 1 or 2.\n\nA is an integer between 1 and 9 (inclusive).\n\nB is an integer between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in one of the following formats:\n\n1\n\n2\nA\nB\n\nOutput\n\nIf N=1, print Hello World; if N=2, print A+B.\n\nSample Input 1\n\n1\n\nSample Output 1\n\nHello World\n\nAs N=1, Takahashi is one year old. Thus, we should print Hello World.\n\nSample Input 2\n\n2\n3\n5\n\nSample Output 2\n\n8\n\nAs N=2, Takahashi is two years old. Thus, we should print A+B, which is 8 since A=3 and B=5.", "sample_input": "1\n"}, "reference_outputs": ["Hello World\n"], "source_document_id": "p03238", "source_text": "Score: 100 points\n\nProblem Statement\n\nIn 2020, AtCoder Inc. with an annual sales of more than one billion yen (the currency of Japan) has started a business in programming education.\n\nOne day, there was an exam where a one-year-old child must write a program that prints Hello World, and a two-year-old child must write a program that receives integers A, B and prints A+B.\n\nTakahashi, who is taking this exam, suddenly forgets his age.\n\nHe decides to write a program that first receives his age N (1 or 2) as input, then prints Hello World if N=1, and additionally receives integers A, B and prints A+B if N=2.\n\nWrite this program for him.\n\nConstraints\n\nN is 1 or 2.\n\nA is an integer between 1 and 9 (inclusive).\n\nB is an integer between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in one of the following formats:\n\n1\n\n2\nA\nB\n\nOutput\n\nIf N=1, print Hello World; if N=2, print A+B.\n\nSample Input 1\n\n1\n\nSample Output 1\n\nHello World\n\nAs N=1, Takahashi is one year old. Thus, we should print Hello World.\n\nSample Input 2\n\n2\n3\n5\n\nSample Output 2\n\n8\n\nAs N=2, Takahashi is two years old. Thus, we should print A+B, which is 8 since A=3 and B=5.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 196, "cpu_time_ms": 352, "memory_kb": 25904}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s336024074", "group_id": "codeNet:p03238", "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.nextInt\n\n N match {\n case 1 => \"Hello World\"\n case 2 => Array.fill(2)(sc.nextInt).sum.toString\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1538875242, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03238.html", "problem_id": "p03238", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03238/input.txt", "sample_output_relpath": "derived/input_output/data/p03238/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03238/Scala/s336024074.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s336024074", "user_id": "u297767059"}, "prompt_components": {"gold_output": "Hello World\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.nextInt\n\n N match {\n case 1 => \"Hello World\"\n case 2 => Array.fill(2)(sc.nextInt).sum.toString\n }\n }\n}\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nIn 2020, AtCoder Inc. with an annual sales of more than one billion yen (the currency of Japan) has started a business in programming education.\n\nOne day, there was an exam where a one-year-old child must write a program that prints Hello World, and a two-year-old child must write a program that receives integers A, B and prints A+B.\n\nTakahashi, who is taking this exam, suddenly forgets his age.\n\nHe decides to write a program that first receives his age N (1 or 2) as input, then prints Hello World if N=1, and additionally receives integers A, B and prints A+B if N=2.\n\nWrite this program for him.\n\nConstraints\n\nN is 1 or 2.\n\nA is an integer between 1 and 9 (inclusive).\n\nB is an integer between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in one of the following formats:\n\n1\n\n2\nA\nB\n\nOutput\n\nIf N=1, print Hello World; if N=2, print A+B.\n\nSample Input 1\n\n1\n\nSample Output 1\n\nHello World\n\nAs N=1, Takahashi is one year old. Thus, we should print Hello World.\n\nSample Input 2\n\n2\n3\n5\n\nSample Output 2\n\n8\n\nAs N=2, Takahashi is two years old. Thus, we should print A+B, which is 8 since A=3 and B=5.", "sample_input": "1\n"}, "reference_outputs": ["Hello World\n"], "source_document_id": "p03238", "source_text": "Score: 100 points\n\nProblem Statement\n\nIn 2020, AtCoder Inc. with an annual sales of more than one billion yen (the currency of Japan) has started a business in programming education.\n\nOne day, there was an exam where a one-year-old child must write a program that prints Hello World, and a two-year-old child must write a program that receives integers A, B and prints A+B.\n\nTakahashi, who is taking this exam, suddenly forgets his age.\n\nHe decides to write a program that first receives his age N (1 or 2) as input, then prints Hello World if N=1, and additionally receives integers A, B and prints A+B if N=2.\n\nWrite this program for him.\n\nConstraints\n\nN is 1 or 2.\n\nA is an integer between 1 and 9 (inclusive).\n\nB is an integer between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in one of the following formats:\n\n1\n\n2\nA\nB\n\nOutput\n\nIf N=1, print Hello World; if N=2, print A+B.\n\nSample Input 1\n\n1\n\nSample Output 1\n\nHello World\n\nAs N=1, Takahashi is one year old. Thus, we should print Hello World.\n\nSample Input 2\n\n2\n3\n5\n\nSample Output 2\n\n8\n\nAs N=2, Takahashi is two years old. Thus, we should print A+B, which is 8 since A=3 and B=5.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 399, "cpu_time_ms": 345, "memory_kb": 25544}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s857955212", "group_id": "codeNet:p03238", "input_text": "object Main {\n def main(args:Array[String]) {\n\tval age = scala.io.StdIn.readInt\n\t\n\tif(age == 1) {\n\t println(\"Hello World\")\n\t}\n\telse if(age == 2) {\n println(scala.io.StdIn.readInt + scala.io.StdIn.readInt)\n\t}\n }\n}", "language": "Scala", "metadata": {"date": 1538874214, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03238.html", "problem_id": "p03238", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03238/input.txt", "sample_output_relpath": "derived/input_output/data/p03238/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03238/Scala/s857955212.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s857955212", "user_id": "u888177577"}, "prompt_components": {"gold_output": "Hello World\n", "input_to_evaluate": "object Main {\n def main(args:Array[String]) {\n\tval age = scala.io.StdIn.readInt\n\t\n\tif(age == 1) {\n\t println(\"Hello World\")\n\t}\n\telse if(age == 2) {\n println(scala.io.StdIn.readInt + scala.io.StdIn.readInt)\n\t}\n }\n}", "problem_context": "Score: 100 points\n\nProblem Statement\n\nIn 2020, AtCoder Inc. with an annual sales of more than one billion yen (the currency of Japan) has started a business in programming education.\n\nOne day, there was an exam where a one-year-old child must write a program that prints Hello World, and a two-year-old child must write a program that receives integers A, B and prints A+B.\n\nTakahashi, who is taking this exam, suddenly forgets his age.\n\nHe decides to write a program that first receives his age N (1 or 2) as input, then prints Hello World if N=1, and additionally receives integers A, B and prints A+B if N=2.\n\nWrite this program for him.\n\nConstraints\n\nN is 1 or 2.\n\nA is an integer between 1 and 9 (inclusive).\n\nB is an integer between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in one of the following formats:\n\n1\n\n2\nA\nB\n\nOutput\n\nIf N=1, print Hello World; if N=2, print A+B.\n\nSample Input 1\n\n1\n\nSample Output 1\n\nHello World\n\nAs N=1, Takahashi is one year old. Thus, we should print Hello World.\n\nSample Input 2\n\n2\n3\n5\n\nSample Output 2\n\n8\n\nAs N=2, Takahashi is two years old. Thus, we should print A+B, which is 8 since A=3 and B=5.", "sample_input": "1\n"}, "reference_outputs": ["Hello World\n"], "source_document_id": "p03238", "source_text": "Score: 100 points\n\nProblem Statement\n\nIn 2020, AtCoder Inc. with an annual sales of more than one billion yen (the currency of Japan) has started a business in programming education.\n\nOne day, there was an exam where a one-year-old child must write a program that prints Hello World, and a two-year-old child must write a program that receives integers A, B and prints A+B.\n\nTakahashi, who is taking this exam, suddenly forgets his age.\n\nHe decides to write a program that first receives his age N (1 or 2) as input, then prints Hello World if N=1, and additionally receives integers A, B and prints A+B if N=2.\n\nWrite this program for him.\n\nConstraints\n\nN is 1 or 2.\n\nA is an integer between 1 and 9 (inclusive).\n\nB is an integer between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in one of the following formats:\n\n1\n\n2\nA\nB\n\nOutput\n\nIf N=1, print Hello World; if N=2, print A+B.\n\nSample Input 1\n\n1\n\nSample Output 1\n\nHello World\n\nAs N=1, Takahashi is one year old. Thus, we should print Hello World.\n\nSample Input 2\n\n2\n3\n5\n\nSample Output 2\n\n8\n\nAs N=2, Takahashi is two years old. Thus, we should print A+B, which is 8 since A=3 and B=5.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 220, "cpu_time_ms": 327, "memory_kb": 25412}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s941807419", "group_id": "codeNet:p03239", "input_text": "object Main extends App {\n val Array(n, t) = readLine.split(\" \").map(_.toInt)\n val cts = for (_ <- 1 to n) yield {\n val Array(c, t) = readLine.split(\" \").map(_.toInt)\n (c, t)\n }\n\n val filteredCts = cts.filter(ct => {\n val c_ = ct._1\n val t_ = ct._2\n t_ <= t\n })\n val ans =\n if (filteredCts.isEmpty) \"TLE\"\n else filteredCts.minBy(ct => ct._1)._1\n\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1572281306, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03239.html", "problem_id": "p03239", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03239/input.txt", "sample_output_relpath": "derived/input_output/data/p03239/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03239/Scala/s941807419.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s941807419", "user_id": "u049922547"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "object Main extends App {\n val Array(n, t) = readLine.split(\" \").map(_.toInt)\n val cts = for (_ <- 1 to n) yield {\n val Array(c, t) = readLine.split(\" \").map(_.toInt)\n (c, t)\n }\n\n val filteredCts = cts.filter(ct => {\n val c_ = ct._1\n val t_ = ct._2\n t_ <= t\n })\n val ans =\n if (filteredCts.isEmpty) \"TLE\"\n else filteredCts.minBy(ct => ct._1)._1\n\n println(ans)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWhen Mr. X is away from home, he has decided to use his smartwatch to search the best route to go back home, to participate in ABC.\n\nYou, the smartwatch, has found N routes to his home.\n\nIf Mr. X uses the i-th of these routes, he will get home in time t_i at cost c_i.\n\nFind the smallest cost of a route that takes not longer than time T.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq T \\leq 1000\n\n1 \\leq c_i \\leq 1000\n\n1 \\leq t_i \\leq 1000\n\nThe pairs (c_i, t_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nc_1 t_1\nc_2 t_2\n:\nc_N t_N\n\nOutput\n\nPrint the smallest cost of a route that takes not longer than time T.\n\nIf there is no route that takes not longer than time T, print TLE instead.\n\nSample Input 1\n\n3 70\n7 60\n1 80\n4 50\n\nSample Output 1\n\n4\n\nThe first route gets him home at cost 7.\n\nThe second route takes longer than time T = 70.\n\nThe third route gets him home at cost 4.\n\nThus, the cost 4 of the third route is the minimum.\n\nSample Input 2\n\n4 3\n1 1000\n2 4\n3 1000\n4 500\n\nSample Output 2\n\nTLE\n\nThere is no route that takes not longer than time T = 3.\n\nSample Input 3\n\n5 9\n25 8\n5 9\n4 10\n1000 1000\n6 1\n\nSample Output 3\n\n5", "sample_input": "3 70\n7 60\n1 80\n4 50\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03239", "source_text": "Score : 200 points\n\nProblem Statement\n\nWhen Mr. X is away from home, he has decided to use his smartwatch to search the best route to go back home, to participate in ABC.\n\nYou, the smartwatch, has found N routes to his home.\n\nIf Mr. X uses the i-th of these routes, he will get home in time t_i at cost c_i.\n\nFind the smallest cost of a route that takes not longer than time T.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq T \\leq 1000\n\n1 \\leq c_i \\leq 1000\n\n1 \\leq t_i \\leq 1000\n\nThe pairs (c_i, t_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nc_1 t_1\nc_2 t_2\n:\nc_N t_N\n\nOutput\n\nPrint the smallest cost of a route that takes not longer than time T.\n\nIf there is no route that takes not longer than time T, print TLE instead.\n\nSample Input 1\n\n3 70\n7 60\n1 80\n4 50\n\nSample Output 1\n\n4\n\nThe first route gets him home at cost 7.\n\nThe second route takes longer than time T = 70.\n\nThe third route gets him home at cost 4.\n\nThus, the cost 4 of the third route is the minimum.\n\nSample Input 2\n\n4 3\n1 1000\n2 4\n3 1000\n4 500\n\nSample Output 2\n\nTLE\n\nThere is no route that takes not longer than time T = 3.\n\nSample Input 3\n\n5 9\n25 8\n5 9\n4 10\n1000 1000\n6 1\n\nSample Output 3\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 389, "cpu_time_ms": 337, "memory_kb": 27468}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s360967698", "group_id": "codeNet:p03239", "input_text": "object Main extends App {\n val NT = io.StdIn.readLine.split(' ').map(_.toInt)\n val N = NT.head\n val T = NT.last\n val cts = (1 to N).map(i => io.StdIn.readLine.split(' ').map(_.toInt))\n\n val candidates = cts.filter(cti => cti(1) <= T)\n\n val out = if (candidates.isEmpty) \"TLE\" else candidates.map(_.head).min\n\n println(out)\n}", "language": "Scala", "metadata": {"date": 1556573632, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03239.html", "problem_id": "p03239", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03239/input.txt", "sample_output_relpath": "derived/input_output/data/p03239/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03239/Scala/s360967698.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s360967698", "user_id": "u620456020"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "object Main extends App {\n val NT = io.StdIn.readLine.split(' ').map(_.toInt)\n val N = NT.head\n val T = NT.last\n val cts = (1 to N).map(i => io.StdIn.readLine.split(' ').map(_.toInt))\n\n val candidates = cts.filter(cti => cti(1) <= T)\n\n val out = if (candidates.isEmpty) \"TLE\" else candidates.map(_.head).min\n\n println(out)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWhen Mr. X is away from home, he has decided to use his smartwatch to search the best route to go back home, to participate in ABC.\n\nYou, the smartwatch, has found N routes to his home.\n\nIf Mr. X uses the i-th of these routes, he will get home in time t_i at cost c_i.\n\nFind the smallest cost of a route that takes not longer than time T.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq T \\leq 1000\n\n1 \\leq c_i \\leq 1000\n\n1 \\leq t_i \\leq 1000\n\nThe pairs (c_i, t_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nc_1 t_1\nc_2 t_2\n:\nc_N t_N\n\nOutput\n\nPrint the smallest cost of a route that takes not longer than time T.\n\nIf there is no route that takes not longer than time T, print TLE instead.\n\nSample Input 1\n\n3 70\n7 60\n1 80\n4 50\n\nSample Output 1\n\n4\n\nThe first route gets him home at cost 7.\n\nThe second route takes longer than time T = 70.\n\nThe third route gets him home at cost 4.\n\nThus, the cost 4 of the third route is the minimum.\n\nSample Input 2\n\n4 3\n1 1000\n2 4\n3 1000\n4 500\n\nSample Output 2\n\nTLE\n\nThere is no route that takes not longer than time T = 3.\n\nSample Input 3\n\n5 9\n25 8\n5 9\n4 10\n1000 1000\n6 1\n\nSample Output 3\n\n5", "sample_input": "3 70\n7 60\n1 80\n4 50\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03239", "source_text": "Score : 200 points\n\nProblem Statement\n\nWhen Mr. X is away from home, he has decided to use his smartwatch to search the best route to go back home, to participate in ABC.\n\nYou, the smartwatch, has found N routes to his home.\n\nIf Mr. X uses the i-th of these routes, he will get home in time t_i at cost c_i.\n\nFind the smallest cost of a route that takes not longer than time T.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq T \\leq 1000\n\n1 \\leq c_i \\leq 1000\n\n1 \\leq t_i \\leq 1000\n\nThe pairs (c_i, t_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nc_1 t_1\nc_2 t_2\n:\nc_N t_N\n\nOutput\n\nPrint the smallest cost of a route that takes not longer than time T.\n\nIf there is no route that takes not longer than time T, print TLE instead.\n\nSample Input 1\n\n3 70\n7 60\n1 80\n4 50\n\nSample Output 1\n\n4\n\nThe first route gets him home at cost 7.\n\nThe second route takes longer than time T = 70.\n\nThe third route gets him home at cost 4.\n\nThus, the cost 4 of the third route is the minimum.\n\nSample Input 2\n\n4 3\n1 1000\n2 4\n3 1000\n4 500\n\nSample Output 2\n\nTLE\n\nThere is no route that takes not longer than time T = 3.\n\nSample Input 3\n\n5 9\n25 8\n5 9\n4 10\n1000 1000\n6 1\n\nSample Output 3\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 331, "cpu_time_ms": 327, "memory_kb": 27312}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s259129380", "group_id": "codeNet:p03239", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val N,T = sc.nextInt()\n val a = List.fill(N,2)(sc.nextInt()) filter (_(1)<=T)\n println(\n if(a==Nil) \"TLE\"\n else a.sortBy(_.head).head.head\n )\n}", "language": "Scala", "metadata": {"date": 1540692004, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03239.html", "problem_id": "p03239", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03239/input.txt", "sample_output_relpath": "derived/input_output/data/p03239/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03239/Scala/s259129380.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s259129380", "user_id": "u690438113"}, "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,T = sc.nextInt()\n val a = List.fill(N,2)(sc.nextInt()) filter (_(1)<=T)\n println(\n if(a==Nil) \"TLE\"\n else a.sortBy(_.head).head.head\n )\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWhen Mr. X is away from home, he has decided to use his smartwatch to search the best route to go back home, to participate in ABC.\n\nYou, the smartwatch, has found N routes to his home.\n\nIf Mr. X uses the i-th of these routes, he will get home in time t_i at cost c_i.\n\nFind the smallest cost of a route that takes not longer than time T.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq T \\leq 1000\n\n1 \\leq c_i \\leq 1000\n\n1 \\leq t_i \\leq 1000\n\nThe pairs (c_i, t_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nc_1 t_1\nc_2 t_2\n:\nc_N t_N\n\nOutput\n\nPrint the smallest cost of a route that takes not longer than time T.\n\nIf there is no route that takes not longer than time T, print TLE instead.\n\nSample Input 1\n\n3 70\n7 60\n1 80\n4 50\n\nSample Output 1\n\n4\n\nThe first route gets him home at cost 7.\n\nThe second route takes longer than time T = 70.\n\nThe third route gets him home at cost 4.\n\nThus, the cost 4 of the third route is the minimum.\n\nSample Input 2\n\n4 3\n1 1000\n2 4\n3 1000\n4 500\n\nSample Output 2\n\nTLE\n\nThere is no route that takes not longer than time T = 3.\n\nSample Input 3\n\n5 9\n25 8\n5 9\n4 10\n1000 1000\n6 1\n\nSample Output 3\n\n5", "sample_input": "3 70\n7 60\n1 80\n4 50\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03239", "source_text": "Score : 200 points\n\nProblem Statement\n\nWhen Mr. X is away from home, he has decided to use his smartwatch to search the best route to go back home, to participate in ABC.\n\nYou, the smartwatch, has found N routes to his home.\n\nIf Mr. X uses the i-th of these routes, he will get home in time t_i at cost c_i.\n\nFind the smallest cost of a route that takes not longer than time T.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq T \\leq 1000\n\n1 \\leq c_i \\leq 1000\n\n1 \\leq t_i \\leq 1000\n\nThe pairs (c_i, t_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nc_1 t_1\nc_2 t_2\n:\nc_N t_N\n\nOutput\n\nPrint the smallest cost of a route that takes not longer than time T.\n\nIf there is no route that takes not longer than time T, print TLE instead.\n\nSample Input 1\n\n3 70\n7 60\n1 80\n4 50\n\nSample Output 1\n\n4\n\nThe first route gets him home at cost 7.\n\nThe second route takes longer than time T = 70.\n\nThe third route gets him home at cost 4.\n\nThus, the cost 4 of the third route is the minimum.\n\nSample Input 2\n\n4 3\n1 1000\n2 4\n3 1000\n4 500\n\nSample Output 2\n\nTLE\n\nThere is no route that takes not longer than time T = 3.\n\nSample Input 3\n\n5 9\n25 8\n5 9\n4 10\n1000 1000\n6 1\n\nSample Output 3\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 224, "cpu_time_ms": 356, "memory_kb": 25664}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s251816257", "group_id": "codeNet:p03239", "input_text": "import scala.io.StdIn\nobject Main extends App {\n val Seq(n, t) : Seq[Int] = StdIn.readLine.split(\" \").map(_.toInt)\n val cts = Range(0, n)\n .map(_ => (StdIn.readLine.split(\" \").map(_.toInt)))\n .map(s => (s(0), s(1)))\n println(cts.sorted.find(_._2 <= t).map(_._1.toString).getOrElse(\"TLE\"))\n}\n", "language": "Scala", "metadata": {"date": 1538886828, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03239.html", "problem_id": "p03239", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03239/input.txt", "sample_output_relpath": "derived/input_output/data/p03239/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03239/Scala/s251816257.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s251816257", "user_id": "u633757735"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import scala.io.StdIn\nobject Main extends App {\n val Seq(n, t) : Seq[Int] = StdIn.readLine.split(\" \").map(_.toInt)\n val cts = Range(0, n)\n .map(_ => (StdIn.readLine.split(\" \").map(_.toInt)))\n .map(s => (s(0), s(1)))\n println(cts.sorted.find(_._2 <= t).map(_._1.toString).getOrElse(\"TLE\"))\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWhen Mr. X is away from home, he has decided to use his smartwatch to search the best route to go back home, to participate in ABC.\n\nYou, the smartwatch, has found N routes to his home.\n\nIf Mr. X uses the i-th of these routes, he will get home in time t_i at cost c_i.\n\nFind the smallest cost of a route that takes not longer than time T.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq T \\leq 1000\n\n1 \\leq c_i \\leq 1000\n\n1 \\leq t_i \\leq 1000\n\nThe pairs (c_i, t_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nc_1 t_1\nc_2 t_2\n:\nc_N t_N\n\nOutput\n\nPrint the smallest cost of a route that takes not longer than time T.\n\nIf there is no route that takes not longer than time T, print TLE instead.\n\nSample Input 1\n\n3 70\n7 60\n1 80\n4 50\n\nSample Output 1\n\n4\n\nThe first route gets him home at cost 7.\n\nThe second route takes longer than time T = 70.\n\nThe third route gets him home at cost 4.\n\nThus, the cost 4 of the third route is the minimum.\n\nSample Input 2\n\n4 3\n1 1000\n2 4\n3 1000\n4 500\n\nSample Output 2\n\nTLE\n\nThere is no route that takes not longer than time T = 3.\n\nSample Input 3\n\n5 9\n25 8\n5 9\n4 10\n1000 1000\n6 1\n\nSample Output 3\n\n5", "sample_input": "3 70\n7 60\n1 80\n4 50\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03239", "source_text": "Score : 200 points\n\nProblem Statement\n\nWhen Mr. X is away from home, he has decided to use his smartwatch to search the best route to go back home, to participate in ABC.\n\nYou, the smartwatch, has found N routes to his home.\n\nIf Mr. X uses the i-th of these routes, he will get home in time t_i at cost c_i.\n\nFind the smallest cost of a route that takes not longer than time T.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq T \\leq 1000\n\n1 \\leq c_i \\leq 1000\n\n1 \\leq t_i \\leq 1000\n\nThe pairs (c_i, t_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nc_1 t_1\nc_2 t_2\n:\nc_N t_N\n\nOutput\n\nPrint the smallest cost of a route that takes not longer than time T.\n\nIf there is no route that takes not longer than time T, print TLE instead.\n\nSample Input 1\n\n3 70\n7 60\n1 80\n4 50\n\nSample Output 1\n\n4\n\nThe first route gets him home at cost 7.\n\nThe second route takes longer than time T = 70.\n\nThe third route gets him home at cost 4.\n\nThus, the cost 4 of the third route is the minimum.\n\nSample Input 2\n\n4 3\n1 1000\n2 4\n3 1000\n4 500\n\nSample Output 2\n\nTLE\n\nThere is no route that takes not longer than time T = 3.\n\nSample Input 3\n\n5 9\n25 8\n5 9\n4 10\n1000 1000\n6 1\n\nSample Output 3\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 300, "cpu_time_ms": 328, "memory_kb": 25420}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s651322315", "group_id": "codeNet:p03241", "input_text": "object Main{\n def main(args:Array[String]):Unit={\n var nm = readLine.split(\" \").map(x => x.toInt) \n var n = nm(0)\n var m = nm(1)\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": 1543278738, "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/s651322315.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s651322315", "user_id": "u825805112"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main{\n def main(args:Array[String]):Unit={\n var nm = readLine.split(\" \").map(x => x.toInt) \n var n = nm(0)\n var m = nm(1)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1320, "memory_kb": 27884}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s602182258", "group_id": "codeNet:p03242", "input_text": "object Main extends App {\n\tval n = scala.io.StdIn.readInt\n\tprintln(1110-n)\n} ", "language": "Scala", "metadata": {"date": 1538856175, "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/s602182258.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s602182258", "user_id": "u633757735"}, "prompt_components": {"gold_output": "991\n", "input_to_evaluate": "object Main extends App {\n\tval n = scala.io.StdIn.readInt\n\tprintln(1110-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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 77, "cpu_time_ms": 323, "memory_kb": 25424}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s492739143", "group_id": "codeNet:p03242", "input_text": "import scala.io.StdIn\n\nobject Main {\n def main(args: Array[String]) = {\n StdIn.readLine()\n val a = StdIn.readLine().split(\" \").toList.map { str: String => str.toInt }\n\n def getAlternateIndex(intList: List[Int], result: List[Int] = Nil): List[Int] = intList match {\n case Nil => result.reverse\n case int :: tail => getAlternateIndex(tail.drop(1), int :: result)\n }\n\n val even = getAlternateIndex(a)\n val odd = getAlternateIndex(a.drop(1))\n\n def makeMap(key: Set[Int], value: List[Int], map: Map[Int, Int] = Map.empty[Int, Int]): Map[Int, Int] = {\n key.toList match {\n case Nil => map\n case k :: tail => makeMap(tail.toSet, value.filter { v: Int => k != v }, map + (k -> value.count { v: Int => k == v }))\n }\n }\n\n val evenMap = makeMap(even.toSet, even)\n val oddMap = makeMap(odd.toSet, odd)\n\n val evenMax = evenMap.maxBy(item => item._2)\n val oddMax = oddMap.maxBy(item => item._2)\n\n var evenMaxVal = evenMax._2\n var oddMaxVal = oddMax._2\n\n val evenMaxKey = evenMax._1\n val oddMaxKey = oddMax._1\n\n var count = even.toSet.size + odd.toSet.size match {\n case x: Int if x < 2 => 0\n case _ =>\n if (evenMaxKey == oddMaxKey) {\n {\n if (evenMaxVal < oddMaxVal) {\n var t = makeMap(even.filter { num: Int => num != oddMaxKey }.toSet, even.filter { num: Int => num != oddMaxKey })\n evenMaxVal = {\n if (t == Map.empty) {\n 0\n } else {\n t.maxBy(item => item._2)._2\n }\n }\n } else {\n var t = makeMap(odd.filter { num: Int => num != evenMaxKey }.toSet, even.filter { num: Int => num != evenMaxKey })\n evenMaxVal = {\n if (t == Map.empty) {\n 0\n } else {\n t.maxBy(item => item._2)._2\n }\n }\n }\n }\n }\n even.size - evenMaxVal + odd.size - oddMaxVal\n }\n println(count)\n }\n}\n", "language": "Scala", "metadata": {"date": 1538347217, "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/s492739143.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s492739143", "user_id": "u513475309"}, "prompt_components": {"gold_output": "991\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main {\n def main(args: Array[String]) = {\n StdIn.readLine()\n val a = StdIn.readLine().split(\" \").toList.map { str: String => str.toInt }\n\n def getAlternateIndex(intList: List[Int], result: List[Int] = Nil): List[Int] = intList match {\n case Nil => result.reverse\n case int :: tail => getAlternateIndex(tail.drop(1), int :: result)\n }\n\n val even = getAlternateIndex(a)\n val odd = getAlternateIndex(a.drop(1))\n\n def makeMap(key: Set[Int], value: List[Int], map: Map[Int, Int] = Map.empty[Int, Int]): Map[Int, Int] = {\n key.toList match {\n case Nil => map\n case k :: tail => makeMap(tail.toSet, value.filter { v: Int => k != v }, map + (k -> value.count { v: Int => k == v }))\n }\n }\n\n val evenMap = makeMap(even.toSet, even)\n val oddMap = makeMap(odd.toSet, odd)\n\n val evenMax = evenMap.maxBy(item => item._2)\n val oddMax = oddMap.maxBy(item => item._2)\n\n var evenMaxVal = evenMax._2\n var oddMaxVal = oddMax._2\n\n val evenMaxKey = evenMax._1\n val oddMaxKey = oddMax._1\n\n var count = even.toSet.size + odd.toSet.size match {\n case x: Int if x < 2 => 0\n case _ =>\n if (evenMaxKey == oddMaxKey) {\n {\n if (evenMaxVal < oddMaxVal) {\n var t = makeMap(even.filter { num: Int => num != oddMaxKey }.toSet, even.filter { num: Int => num != oddMaxKey })\n evenMaxVal = {\n if (t == Map.empty) {\n 0\n } else {\n t.maxBy(item => item._2)._2\n }\n }\n } else {\n var t = makeMap(odd.filter { num: Int => num != evenMaxKey }.toSet, even.filter { num: Int => num != evenMaxKey })\n evenMaxVal = {\n if (t == Map.empty) {\n 0\n } else {\n t.maxBy(item => item._2)._2\n }\n }\n }\n }\n }\n even.size - evenMaxVal + odd.size - oddMaxVal\n }\n println(count)\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2534, "cpu_time_ms": 329, "memory_kb": 27192}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s494620206", "group_id": "codeNet:p03242", "input_text": "object Main extends App {\n val s = new java.util.Scanner(System.in).next\n val m = Map('1' -> '9', '9' -> '1')\n println(s.map(m(_)))\n}", "language": "Scala", "metadata": {"date": 1538326297, "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/s494620206.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s494620206", "user_id": "u191819389"}, "prompt_components": {"gold_output": "991\n", "input_to_evaluate": "object Main extends App {\n val s = new java.util.Scanner(System.in).next\n val m = Map('1' -> '9', '9' -> '1')\n println(s.map(m(_)))\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 136, "cpu_time_ms": 394, "memory_kb": 25416}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s741608826", "group_id": "codeNet:p03243", "input_text": "object Main extends App{\n import scala.io.StdIn._\n import scala.math.ceil\n val n:Double = readLine().toInt\n\n println((ceil(n/111)*111).toInt)\n}", "language": "Scala", "metadata": {"date": 1559112064, "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/s741608826.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s741608826", "user_id": "u238510421"}, "prompt_components": {"gold_output": "111\n", "input_to_evaluate": "object Main extends App{\n import scala.io.StdIn._\n import scala.math.ceil\n val n:Double = readLine().toInt\n\n println((ceil(n/111)*111).toInt)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 326, "memory_kb": 25400}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s911756315", "group_id": "codeNet:p03243", "input_text": "object Main{\n\tdef main(args:Array[String]):Unit={\n var input = readLine\n var record:Map[Int,Int] = Map()\n for(i <- input){\n var tmp = i.toString.toInt\n var r = record.getOrElse(tmp,0)\n r+=1\n record+=(tmp -> r)\n }\n var keys = record.keySet.toArray.sorted.reverse\n var flag = true\n var res = \"\"\n if(keys.length==1){\n for(i <- 0 until 3) res += keys(0).toString\n flag = false\n }\n for(k <- 0 until keys.length if flag){\n if(k==0 && input.charAt(0).toString.toInt==keys(k)){\n for(i <- 0 until 3) res += keys(0).toString\n flag = false\n }\n if(keys(k)==input.charAt(0).toString.toInt){\n for(i <- 0 until 3) res += keys(k-1).toString\n flag = false\n }\n }\n println(res)\n \n }\n}", "language": "Scala", "metadata": {"date": 1543281228, "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/s911756315.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s911756315", "user_id": "u825805112"}, "prompt_components": {"gold_output": "111\n", "input_to_evaluate": "object Main{\n\tdef main(args:Array[String]):Unit={\n var input = readLine\n var record:Map[Int,Int] = Map()\n for(i <- input){\n var tmp = i.toString.toInt\n var r = record.getOrElse(tmp,0)\n r+=1\n record+=(tmp -> r)\n }\n var keys = record.keySet.toArray.sorted.reverse\n var flag = true\n var res = \"\"\n if(keys.length==1){\n for(i <- 0 until 3) res += keys(0).toString\n flag = false\n }\n for(k <- 0 until keys.length if flag){\n if(k==0 && input.charAt(0).toString.toInt==keys(k)){\n for(i <- 0 until 3) res += keys(0).toString\n flag = false\n }\n if(keys(k)==input.charAt(0).toString.toInt){\n for(i <- 0 until 3) res += keys(k-1).toString\n flag = false\n }\n }\n println(res)\n \n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 839, "cpu_time_ms": 331, "memory_kb": 25424}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s404522498", "group_id": "codeNet:p03243", "input_text": "object Main extends App{\n println(111*(new java.util.Scanner(System.in).nextInt()/111).ceil.toInt)\n}", "language": "Scala", "metadata": {"date": 1540692935, "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/s404522498.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s404522498", "user_id": "u690438113"}, "prompt_components": {"gold_output": "111\n", "input_to_evaluate": "object Main extends App{\n println(111*(new java.util.Scanner(System.in).nextInt()/111).ceil.toInt)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 101, "cpu_time_ms": 345, "memory_kb": 25536}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s911729573", "group_id": "codeNet:p03243", "input_text": "object Main extends App {\n\tval n : Int = scala.io.StdIn.readInt\n val xxx : Seq[Int] = Range(111,1110,111).toSeq\n\tprintln(xxx.find(_ > n).get)\n} \n", "language": "Scala", "metadata": {"date": 1538856610, "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/s911729573.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s911729573", "user_id": "u633757735"}, "prompt_components": {"gold_output": "111\n", "input_to_evaluate": "object Main extends App {\n\tval n : Int = scala.io.StdIn.readInt\n val xxx : Seq[Int] = Range(111,1110,111).toSeq\n\tprintln(xxx.find(_ > n).get)\n} \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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 318, "memory_kb": 27200}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s390666010", "group_id": "codeNet:p03244", "input_text": "import scala.io.{StdIn => in}\nimport scala.collection.{mutable => mu}\n\nobject Main extends App {\n import MapHelper._\n val n = in.readInt\n val seq = in.readLine.split(\" \").map(_.toInt)\n\n val map1 = mu.HashMap.empty[Int,Int]\n val map2 = mu.HashMap.empty[Int,Int]\n val set = mu.HashSet.empty[Int]\n for(i <- 0 until n) {\n set += seq(i)\n if(i % 2 == 0) map1.addOrUpdate(seq(i), 1)\n else map2.addOrUpdate(seq(i), 1)\n }\n\n val max1 = map1.values.max\n val max2 = map2.values.max\n val res1 = (n / 2) - max1\n val res2 = (n - (n / 2)) - max2\n // println(map1.mkString(\" \"))\n // println(map2.mkString(\" \"))\n // println(res1 + \" \" + res2)\n\n val ans = if(set.size == 1) n / 2 else res1 + res2\n println(ans)\n\n object MapHelper {\n implicit class AddOrUpdate[A](map:mu.HashMap[Int,Int]) {\n def addOrUpdate(key:Int, value:Int):mu.HashMap[Int,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": 1561213414, "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/s390666010.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s390666010", "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 val n = in.readInt\n val seq = in.readLine.split(\" \").map(_.toInt)\n\n val map1 = mu.HashMap.empty[Int,Int]\n val map2 = mu.HashMap.empty[Int,Int]\n val set = mu.HashSet.empty[Int]\n for(i <- 0 until n) {\n set += seq(i)\n if(i % 2 == 0) map1.addOrUpdate(seq(i), 1)\n else map2.addOrUpdate(seq(i), 1)\n }\n\n val max1 = map1.values.max\n val max2 = map2.values.max\n val res1 = (n / 2) - max1\n val res2 = (n - (n / 2)) - max2\n // println(map1.mkString(\" \"))\n // println(map2.mkString(\" \"))\n // println(res1 + \" \" + res2)\n\n val ans = if(set.size == 1) n / 2 else res1 + res2\n println(ans)\n\n object MapHelper {\n implicit class AddOrUpdate[A](map:mu.HashMap[Int,Int]) {\n def addOrUpdate(key:Int, value:Int):mu.HashMap[Int,Int] =\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\nA sequence a_1,a_2,... ,a_n is said to be /\\/\\/\\/ when the following conditions are satisfied:\n\nFor each i = 1,2,..., n-2, a_i = a_{i+2}.\n\nExactly two different numbers appear in the sequence.\n\nYou are given a sequence v_1,v_2,...,v_n whose length is even.\nWe would like to make this sequence /\\/\\/\\/ by replacing some of its elements.\nFind the minimum number of elements that needs to be replaced.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\nn is even.\n\n1 \\leq v_i \\leq 10^5\n\nv_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\nv_1 v_2 ... v_n\n\nOutput\n\nPrint the minimum number of elements that needs to be replaced.\n\nSample Input 1\n\n4\n3 1 3 2\n\nSample Output 1\n\n1\n\nThe sequence 3,1,3,2 is not /\\/\\/\\/, but we can make it /\\/\\/\\/ by replacing one of its elements: for example, replace the fourth element to make it 3,1,3,1.\n\nSample Input 2\n\n6\n105 119 105 119 105 119\n\nSample Output 2\n\n0\n\nThe sequence 105,119,105,119,105,119 is /\\/\\/\\/.\n\nSample Input 3\n\n4\n1 1 1 1\n\nSample Output 3\n\n2\n\nThe elements of the sequence 1,1,1,1 are all the same, so it is not /\\/\\/\\/.", "sample_input": "4\n3 1 3 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03244", "source_text": "Score : 300 points\n\nProblem Statement\n\nA sequence a_1,a_2,... ,a_n is said to be /\\/\\/\\/ when the following conditions are satisfied:\n\nFor each i = 1,2,..., n-2, a_i = a_{i+2}.\n\nExactly two different numbers appear in the sequence.\n\nYou are given a sequence v_1,v_2,...,v_n whose length is even.\nWe would like to make this sequence /\\/\\/\\/ by replacing some of its elements.\nFind the minimum number of elements that needs to be replaced.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\nn is even.\n\n1 \\leq v_i \\leq 10^5\n\nv_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\nv_1 v_2 ... v_n\n\nOutput\n\nPrint the minimum number of elements that needs to be replaced.\n\nSample Input 1\n\n4\n3 1 3 2\n\nSample Output 1\n\n1\n\nThe sequence 3,1,3,2 is not /\\/\\/\\/, but we can make it /\\/\\/\\/ by replacing one of its elements: for example, replace the fourth element to make it 3,1,3,1.\n\nSample Input 2\n\n6\n105 119 105 119 105 119\n\nSample Output 2\n\n0\n\nThe sequence 105,119,105,119,105,119 is /\\/\\/\\/.\n\nSample Input 3\n\n4\n1 1 1 1\n\nSample Output 3\n\n2\n\nThe elements of the sequence 1,1,1,1 are all the same, so it is not /\\/\\/\\/.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 987, "cpu_time_ms": 798, "memory_kb": 51160}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s520313766", "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 std=mysprit(n,sc).map(x=>(List(0,0)::mysort(x,Nil))).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.sorted match{\n case Nil => r\n case x::xs => {\n val n = xs.indexWhere(_!=x)\n mysort(xs.drop(n), (x :: n+1 :: 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": 1540709469, "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/s520313766.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s520313766", "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 std=mysprit(n,sc).map(x=>(List(0,0)::mysort(x,Nil))).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.sorted match{\n case Nil => r\n case x::xs => {\n val n = xs.indexWhere(_!=x)\n mysort(xs.drop(n), (x :: n+1 :: 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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 948, "cpu_time_ms": 2114, "memory_kb": 124736}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s801177770", "group_id": "codeNet:p03244", "input_text": "import scala.io.StdIn\n\nobject Main {\n def main(args: Array[String]) = {\n StdIn.readLine()\n val a = StdIn.readLine().split(\" \").toList.map { str: String => str.toInt }\n\n def getAlternateIndex(intList: List[Int], result: List[Int] = Nil): List[Int] = intList match {\n case Nil => result.reverse\n case int :: tail => getAlternateIndex(tail.drop(1), int :: result)\n }\n\n val evenA = getAlternateIndex(a)\n val oddA = getAlternateIndex(a.drop(1))\n\n println(evenA.toSet.size-1 + oddA.toSet.size-1 match {\n case x: Int if x < 0 => 0\n case x: Int if (evenA ::: oddA).toSet.size == 1 => evenA.size\n })\n }\n}\n", "language": "Scala", "metadata": {"date": 1538289552, "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/s801177770.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s801177770", "user_id": "u513475309"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main {\n def main(args: Array[String]) = {\n StdIn.readLine()\n val a = StdIn.readLine().split(\" \").toList.map { str: String => str.toInt }\n\n def getAlternateIndex(intList: List[Int], result: List[Int] = Nil): List[Int] = intList match {\n case Nil => result.reverse\n case int :: tail => getAlternateIndex(tail.drop(1), int :: result)\n }\n\n val evenA = getAlternateIndex(a)\n val oddA = getAlternateIndex(a.drop(1))\n\n println(evenA.toSet.size-1 + oddA.toSet.size-1 match {\n case x: Int if x < 0 => 0\n case x: Int if (evenA ::: oddA).toSet.size == 1 => evenA.size\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1137, "memory_kb": 100384}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s318454526", "group_id": "codeNet:p03248", "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 s = readLineStrings(sc)(0).toList.map(_ == '1').toArray\n val n = s.length\n if (!s.head || s.last) {\n println(-1)\n return\n }\n if (!(0 to (n - 2)).forall(i => s(i) == s(n - 2 - i))) {\n println(-1)\n return\n }\n var nodeIndex = 1\n while (nodeIndex < n - 1) {\n if (s(nodeIndex)) {\n println(s\"$nodeIndex ${nodeIndex + 1}\")\n nodeIndex += 1\n } else {\n var nextNodeIndex = nodeIndex\n while (!s(nextNodeIndex)) nextNodeIndex += 1\n nextNodeIndex += 1\n for (i <- nodeIndex until nextNodeIndex) {\n println(s\"$i $nextNodeIndex\")\n }\n nodeIndex = nextNodeIndex\n }\n }\n println(s\"${n - 1} $n\")\n }\n}", "language": "Scala", "metadata": {"date": 1538275786, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03248.html", "problem_id": "p03248", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03248/input.txt", "sample_output_relpath": "derived/input_output/data/p03248/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03248/Scala/s318454526.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s318454526", "user_id": "u909304507"}, "prompt_components": {"gold_output": "-1\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 s = readLineStrings(sc)(0).toList.map(_ == '1').toArray\n val n = s.length\n if (!s.head || s.last) {\n println(-1)\n return\n }\n if (!(0 to (n - 2)).forall(i => s(i) == s(n - 2 - i))) {\n println(-1)\n return\n }\n var nodeIndex = 1\n while (nodeIndex < n - 1) {\n if (s(nodeIndex)) {\n println(s\"$nodeIndex ${nodeIndex + 1}\")\n nodeIndex += 1\n } else {\n var nextNodeIndex = nodeIndex\n while (!s(nextNodeIndex)) nextNodeIndex += 1\n nextNodeIndex += 1\n for (i <- nodeIndex until nextNodeIndex) {\n println(s\"$i $nextNodeIndex\")\n }\n nodeIndex = nextNodeIndex\n }\n }\n println(s\"${n - 1} $n\")\n }\n}", "problem_context": "Score : 700 points\n\nProblem Statement\n\nYou are given a string s of length n.\nDoes a tree with n vertices that satisfies the following conditions exist?\n\nThe vertices are numbered 1,2,..., n.\n\nThe edges are numbered 1,2,..., n-1, and Edge i connects Vertex u_i and v_i.\n\nIf the i-th character in s is 1, we can have a connected component of size i by removing one edge from the tree.\n\nIf the i-th character in s is 0, we cannot have a connected component of size i by removing any one edge from the tree.\n\nIf such a tree exists, construct one such tree.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\ns is a string of length n consisting of 0 and 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nIf a tree with n vertices that satisfies the conditions does not exist, print -1.\n\nIf a tree with n vertices that satisfies the conditions exist, print n-1 lines.\nThe i-th line should contain u_i and v_i with a space in between.\nIf there are multiple trees that satisfy the conditions, any such tree will be accepted.\n\nSample Input 1\n\n1111\n\nSample Output 1\n\n-1\n\nIt is impossible to have a connected component of size n after removing one edge from a tree with n vertices.\n\nSample Input 2\n\n1110\n\nSample Output 2\n\n1 2\n2 3\n3 4\n\nIf Edge 1 or Edge 3 is removed, we will have a connected component of size 1 and another of size 3. If Edge 2 is removed, we will have two connected components, each of size 2.\n\nSample Input 3\n\n1010\n\nSample Output 3\n\n1 2\n1 3\n1 4\n\nRemoving any edge will result in a connected component of size 1 and another of size 3.", "sample_input": "1111\n"}, "reference_outputs": ["-1\n"], "source_document_id": "p03248", "source_text": "Score : 700 points\n\nProblem Statement\n\nYou are given a string s of length n.\nDoes a tree with n vertices that satisfies the following conditions exist?\n\nThe vertices are numbered 1,2,..., n.\n\nThe edges are numbered 1,2,..., n-1, and Edge i connects Vertex u_i and v_i.\n\nIf the i-th character in s is 1, we can have a connected component of size i by removing one edge from the tree.\n\nIf the i-th character in s is 0, we cannot have a connected component of size i by removing any one edge from the tree.\n\nIf such a tree exists, construct one such tree.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\ns is a string of length n consisting of 0 and 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nIf a tree with n vertices that satisfies the conditions does not exist, print -1.\n\nIf a tree with n vertices that satisfies the conditions exist, print n-1 lines.\nThe i-th line should contain u_i and v_i with a space in between.\nIf there are multiple trees that satisfy the conditions, any such tree will be accepted.\n\nSample Input 1\n\n1111\n\nSample Output 1\n\n-1\n\nIt is impossible to have a connected component of size n after removing one edge from a tree with n vertices.\n\nSample Input 2\n\n1110\n\nSample Output 2\n\n1 2\n2 3\n3 4\n\nIf Edge 1 or Edge 3 is removed, we will have a connected component of size 1 and another of size 3. If Edge 2 is removed, we will have two connected components, each of size 2.\n\nSample Input 3\n\n1010\n\nSample Output 3\n\n1 2\n1 3\n1 4\n\nRemoving any edge will result in a connected component of size 1 and another of size 3.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1406, "cpu_time_ms": 1383, "memory_kb": 47688}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s772770678", "group_id": "codeNet:p03254", "input_text": "\nobject Main extends App {\n val sc = new java.util.Scanner(System.in) \n var n = sc.nextInt()\n var x = sc.nextInt()\n sc.useDelimiter(\"\\n\")\n val a = sc.next().split(\" \").map(_.toInt).toList.sorted\n var i = 0\n var ans = 0\n for (i <- 0 until n) {\n if (a(i) <= x) {\n ans += 1\n x -= a(i)\n }\n }\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1598413452, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03254.html", "problem_id": "p03254", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03254/input.txt", "sample_output_relpath": "derived/input_output/data/p03254/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03254/Scala/s772770678.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s772770678", "user_id": "u396472025"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "\nobject Main extends App {\n val sc = new java.util.Scanner(System.in) \n var n = sc.nextInt()\n var x = sc.nextInt()\n sc.useDelimiter(\"\\n\")\n val a = sc.next().split(\" \").map(_.toInt).toList.sorted\n var i = 0\n var ans = 0\n for (i <- 0 until n) {\n if (a(i) <= x) {\n ans += 1\n x -= a(i)\n }\n }\n println(ans)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N children, numbered 1, 2, ..., N.\n\nSnuke has decided to distribute x sweets among them.\nHe needs to give out all the x sweets, but some of the children may get zero sweets.\n\nFor each i (1 \\leq i \\leq N), Child i will be happy if he/she gets exactly a_i sweets.\nSnuke is trying to maximize the number of happy children by optimally distributing the sweets.\nFind the maximum possible number of happy children.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n1 \\leq x \\leq 10^9\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN x\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum possible number of happy children.\n\nSample Input 1\n\n3 70\n20 30 10\n\nSample Output 1\n\n2\n\nOne optimal way to distribute sweets is (20, 30, 20).\n\nSample Input 2\n\n3 10\n20 30 10\n\nSample Output 2\n\n1\n\nThe optimal way to distribute sweets is (0, 0, 10).\n\nSample Input 3\n\n4 1111\n1 10 100 1000\n\nSample Output 3\n\n4\n\nThe optimal way to distribute sweets is (1, 10, 100, 1000).\n\nSample Input 4\n\n2 10\n20 20\n\nSample Output 4\n\n0\n\nNo children will be happy, no matter how the sweets are distributed.", "sample_input": "3 70\n20 30 10\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03254", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N children, numbered 1, 2, ..., N.\n\nSnuke has decided to distribute x sweets among them.\nHe needs to give out all the x sweets, but some of the children may get zero sweets.\n\nFor each i (1 \\leq i \\leq N), Child i will be happy if he/she gets exactly a_i sweets.\nSnuke is trying to maximize the number of happy children by optimally distributing the sweets.\nFind the maximum possible number of happy children.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n1 \\leq x \\leq 10^9\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN x\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum possible number of happy children.\n\nSample Input 1\n\n3 70\n20 30 10\n\nSample Output 1\n\n2\n\nOne optimal way to distribute sweets is (20, 30, 20).\n\nSample Input 2\n\n3 10\n20 30 10\n\nSample Output 2\n\n1\n\nThe optimal way to distribute sweets is (0, 0, 10).\n\nSample Input 3\n\n4 1111\n1 10 100 1000\n\nSample Output 3\n\n4\n\nThe optimal way to distribute sweets is (1, 10, 100, 1000).\n\nSample Input 4\n\n2 10\n20 20\n\nSample Output 4\n\n0\n\nNo children will be happy, no matter how the sweets are distributed.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 329, "cpu_time_ms": 505, "memory_kb": 55388}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s650136854", "group_id": "codeNet:p03254", "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, x = sc.nextInt()\n val kids = List.fill(n)(sc.nextInt()).sorted.scan(0)((a, b) => a + b)\n val a = kids.takeWhile(_ <= x).length\n// println(kids, a)\n System.err.println(\"hahaha\")\n a match {\n case 1 => println(0)\n case m if kids(m - 1) == x => println(m)\n case m if m == kids.length => println(m - 2)\n case m => println(m - 1)\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1587761417, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03254.html", "problem_id": "p03254", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03254/input.txt", "sample_output_relpath": "derived/input_output/data/p03254/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03254/Scala/s650136854.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s650136854", "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, x = sc.nextInt()\n val kids = List.fill(n)(sc.nextInt()).sorted.scan(0)((a, b) => a + b)\n val a = kids.takeWhile(_ <= x).length\n// println(kids, a)\n System.err.println(\"hahaha\")\n a match {\n case 1 => println(0)\n case m if kids(m - 1) == x => println(m)\n case m if m == kids.length => println(m - 2)\n case m => println(m - 1)\n }\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N children, numbered 1, 2, ..., N.\n\nSnuke has decided to distribute x sweets among them.\nHe needs to give out all the x sweets, but some of the children may get zero sweets.\n\nFor each i (1 \\leq i \\leq N), Child i will be happy if he/she gets exactly a_i sweets.\nSnuke is trying to maximize the number of happy children by optimally distributing the sweets.\nFind the maximum possible number of happy children.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n1 \\leq x \\leq 10^9\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN x\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum possible number of happy children.\n\nSample Input 1\n\n3 70\n20 30 10\n\nSample Output 1\n\n2\n\nOne optimal way to distribute sweets is (20, 30, 20).\n\nSample Input 2\n\n3 10\n20 30 10\n\nSample Output 2\n\n1\n\nThe optimal way to distribute sweets is (0, 0, 10).\n\nSample Input 3\n\n4 1111\n1 10 100 1000\n\nSample Output 3\n\n4\n\nThe optimal way to distribute sweets is (1, 10, 100, 1000).\n\nSample Input 4\n\n2 10\n20 20\n\nSample Output 4\n\n0\n\nNo children will be happy, no matter how the sweets are distributed.", "sample_input": "3 70\n20 30 10\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03254", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N children, numbered 1, 2, ..., N.\n\nSnuke has decided to distribute x sweets among them.\nHe needs to give out all the x sweets, but some of the children may get zero sweets.\n\nFor each i (1 \\leq i \\leq N), Child i will be happy if he/she gets exactly a_i sweets.\nSnuke is trying to maximize the number of happy children by optimally distributing the sweets.\nFind the maximum possible number of happy children.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n1 \\leq x \\leq 10^9\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN x\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum possible number of happy children.\n\nSample Input 1\n\n3 70\n20 30 10\n\nSample Output 1\n\n2\n\nOne optimal way to distribute sweets is (20, 30, 20).\n\nSample Input 2\n\n3 10\n20 30 10\n\nSample Output 2\n\n1\n\nThe optimal way to distribute sweets is (0, 0, 10).\n\nSample Input 3\n\n4 1111\n1 10 100 1000\n\nSample Output 3\n\n4\n\nThe optimal way to distribute sweets is (1, 10, 100, 1000).\n\nSample Input 4\n\n2 10\n20 20\n\nSample Output 4\n\n0\n\nNo children will be happy, no matter how the sweets are distributed.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 540, "cpu_time_ms": 349, "memory_kb": 25680}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s886969010", "group_id": "codeNet:p03254", "input_text": "object Main extends App {\n var a = readLine.split(\" \").map(_.toLong)\n var b = readLine.split(\" \").map(_.toLong).sorted\n var sum = 0L\n for(i <- 0 until a(0).toInt - 1 if(a(1) >= b(i))) {\n a(1) -= b(i)\n sum = sum + 1\n }\n if(a(1) == b(a(0).toInt - 1)) {\n sum = sum + 1\n }\n print(sum)\n}", "language": "Scala", "metadata": {"date": 1564287490, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03254.html", "problem_id": "p03254", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03254/input.txt", "sample_output_relpath": "derived/input_output/data/p03254/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03254/Scala/s886969010.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s886969010", "user_id": "u533688845"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n var a = readLine.split(\" \").map(_.toLong)\n var b = readLine.split(\" \").map(_.toLong).sorted\n var sum = 0L\n for(i <- 0 until a(0).toInt - 1 if(a(1) >= b(i))) {\n a(1) -= b(i)\n sum = sum + 1\n }\n if(a(1) == b(a(0).toInt - 1)) {\n sum = sum + 1\n }\n print(sum)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N children, numbered 1, 2, ..., N.\n\nSnuke has decided to distribute x sweets among them.\nHe needs to give out all the x sweets, but some of the children may get zero sweets.\n\nFor each i (1 \\leq i \\leq N), Child i will be happy if he/she gets exactly a_i sweets.\nSnuke is trying to maximize the number of happy children by optimally distributing the sweets.\nFind the maximum possible number of happy children.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n1 \\leq x \\leq 10^9\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN x\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum possible number of happy children.\n\nSample Input 1\n\n3 70\n20 30 10\n\nSample Output 1\n\n2\n\nOne optimal way to distribute sweets is (20, 30, 20).\n\nSample Input 2\n\n3 10\n20 30 10\n\nSample Output 2\n\n1\n\nThe optimal way to distribute sweets is (0, 0, 10).\n\nSample Input 3\n\n4 1111\n1 10 100 1000\n\nSample Output 3\n\n4\n\nThe optimal way to distribute sweets is (1, 10, 100, 1000).\n\nSample Input 4\n\n2 10\n20 20\n\nSample Output 4\n\n0\n\nNo children will be happy, no matter how the sweets are distributed.", "sample_input": "3 70\n20 30 10\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03254", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N children, numbered 1, 2, ..., N.\n\nSnuke has decided to distribute x sweets among them.\nHe needs to give out all the x sweets, but some of the children may get zero sweets.\n\nFor each i (1 \\leq i \\leq N), Child i will be happy if he/she gets exactly a_i sweets.\nSnuke is trying to maximize the number of happy children by optimally distributing the sweets.\nFind the maximum possible number of happy children.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n1 \\leq x \\leq 10^9\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN x\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum possible number of happy children.\n\nSample Input 1\n\n3 70\n20 30 10\n\nSample Output 1\n\n2\n\nOne optimal way to distribute sweets is (20, 30, 20).\n\nSample Input 2\n\n3 10\n20 30 10\n\nSample Output 2\n\n1\n\nThe optimal way to distribute sweets is (0, 0, 10).\n\nSample Input 3\n\n4 1111\n1 10 100 1000\n\nSample Output 3\n\n4\n\nThe optimal way to distribute sweets is (1, 10, 100, 1000).\n\nSample Input 4\n\n2 10\n20 20\n\nSample Output 4\n\n0\n\nNo children will be happy, no matter how the sweets are distributed.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 309, "cpu_time_ms": 326, "memory_kb": 25416}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s228835679", "group_id": "codeNet:p03263", "input_text": "object Main extends App {\n\tval Array(h, w) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\tval a = Array.ofDim[Int](h, w)\n\n\tfor(i<-0 until h){\n\t\ta(i) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\t}\n\n\tvar ans1 = List[(Int, Int, Int, Int)]()\n\tvar list = List[(Int, Int)]()\n\n\tfor(i<-0 until h){\n\t\tif(i%2 == 0){\n\t\t\tfor(j<-0 until w){\n\t\t\t\tlist = (i, j) :: list\n\t\t\t}\n\t\t}else{\n\t\t\tfor(j<-(w-1) to 0 by -1){\n\t\t\t\tlist = (i,j) :: list\n\t\t\t}\n\t\t}\n\t}\n\n\tfor(i<-0 until (h*w-1)){\n\t\tval x = list(i)._1\n\t\tval y = list(i)._2\n\n\t\tval s = list(i+1)._1\n\t\tval t = list(i+1)._2\n\n\t\tif(a(x)(y)%2 == 1){\n\t\t\ta(x)(y) -= 1\n\t\t\ta(s)(t) += 1\n\t\t\tans1 = (x,y,s,t) :: ans1\n\t\t}\n\t}\n\n\tprintln(ans1.size)\n\tfor(x <- ans1.reverse){\n\t\tmyP(x._1, x._2, x._3, x._4)\n\t}\n\n\tdef myP(x: Int, y: Int, a: Int, b: Int): Unit = {\n\t\tprintln(Array(x+1,y+1,a+1,b+1).mkString(\" \"))\n\t}\n\n\n\n}\n", "language": "Scala", "metadata": {"date": 1536601408, "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/s228835679.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s228835679", "user_id": "u675876401"}, "prompt_components": {"gold_output": "3\n2 2 2 3\n1 1 1 2\n1 3 1 2\n", "input_to_evaluate": "object Main extends App {\n\tval Array(h, w) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\tval a = Array.ofDim[Int](h, w)\n\n\tfor(i<-0 until h){\n\t\ta(i) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\t}\n\n\tvar ans1 = List[(Int, Int, Int, Int)]()\n\tvar list = List[(Int, Int)]()\n\n\tfor(i<-0 until h){\n\t\tif(i%2 == 0){\n\t\t\tfor(j<-0 until w){\n\t\t\t\tlist = (i, j) :: list\n\t\t\t}\n\t\t}else{\n\t\t\tfor(j<-(w-1) to 0 by -1){\n\t\t\t\tlist = (i,j) :: list\n\t\t\t}\n\t\t}\n\t}\n\n\tfor(i<-0 until (h*w-1)){\n\t\tval x = list(i)._1\n\t\tval y = list(i)._2\n\n\t\tval s = list(i+1)._1\n\t\tval t = list(i+1)._2\n\n\t\tif(a(x)(y)%2 == 1){\n\t\t\ta(x)(y) -= 1\n\t\t\ta(s)(t) += 1\n\t\t\tans1 = (x,y,s,t) :: ans1\n\t\t}\n\t}\n\n\tprintln(ans1.size)\n\tfor(x <- ans1.reverse){\n\t\tmyP(x._1, x._2, x._3, x._4)\n\t}\n\n\tdef myP(x: Int, y: Int, a: Int, b: Int): Unit = {\n\t\tprintln(Array(x+1,y+1,a+1,b+1).mkString(\" \"))\n\t}\n\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2113, "memory_kb": 75616}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s286264738", "group_id": "codeNet:p03263", "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 def evenResolution(row: Seq[Int]): Seq[Int] = row.scanLeft(0){ (a, carry) => (a + carry) % 2 }.drop(1).dropRight(1)\n def flattenZigzag[A]: Array[Array[A]] => scala.collection.mutable.ArraySeq[A] = { array =>\n val indexedArray = array.zipWithIndex\n val grouped = indexedArray.groupBy(_._2 % 2).mapValues(_.map(_._1))\n grouped(0).zip(grouped(1)).flatMap { case (ev, odd) => ev ++ odd }\n }\n\n val Array(h, w) = readLineInts\n val a = Array.fill(h)(readLineInts)\n val indexedCells = {\n a.zipWithIndex.map { case (row, rowIndex) =>\n row.zipWithIndex.map { case (cell, columnIndex) => (cell, (rowIndex, columnIndex)) }\n }\n }\n val zigzag = flattenZigzag(indexedCells)\n val moveFlags = evenResolution(zigzag.map(_._1))\n val moves: Seq[(Int, Int, Int, Int)] = {\n for((moveFlag, index) <- moveFlags.zipWithIndex;\n (y1, x1) <- Some(zigzag(index)._2) if moveFlag == 1;\n (y2, x2) <- Some(zigzag(index + 1)._2)) yield (y1, x1, y2, x2)\n }\n println(moves.length)\n for ((a, b, c, d) <- moves) println(s\"$a $b $c $d\")\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1536463424, "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/s286264738.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s286264738", "user_id": "u909304507"}, "prompt_components": {"gold_output": "3\n2 2 2 3\n1 1 1 2\n1 3 1 2\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 def evenResolution(row: Seq[Int]): Seq[Int] = row.scanLeft(0){ (a, carry) => (a + carry) % 2 }.drop(1).dropRight(1)\n def flattenZigzag[A]: Array[Array[A]] => scala.collection.mutable.ArraySeq[A] = { array =>\n val indexedArray = array.zipWithIndex\n val grouped = indexedArray.groupBy(_._2 % 2).mapValues(_.map(_._1))\n grouped(0).zip(grouped(1)).flatMap { case (ev, odd) => ev ++ odd }\n }\n\n val Array(h, w) = readLineInts\n val a = Array.fill(h)(readLineInts)\n val indexedCells = {\n a.zipWithIndex.map { case (row, rowIndex) =>\n row.zipWithIndex.map { case (cell, columnIndex) => (cell, (rowIndex, columnIndex)) }\n }\n }\n val zigzag = flattenZigzag(indexedCells)\n val moveFlags = evenResolution(zigzag.map(_._1))\n val moves: Seq[(Int, Int, Int, Int)] = {\n for((moveFlag, index) <- moveFlags.zipWithIndex;\n (y1, x1) <- Some(zigzag(index)._2) if moveFlag == 1;\n (y2, x2) <- Some(zigzag(index + 1)._2)) yield (y1, x1, y2, x2)\n }\n println(moves.length)\n for ((a, b, c, d) <- moves) println(s\"$a $b $c $d\")\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1791, "cpu_time_ms": 2111, "memory_kb": 128252}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s993814021", "group_id": "codeNet:p03263", "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 def adjustRow(row: Seq[Int]): Seq[Int] = row.scanLeft(0){ (a, carry) => (a + carry) % 2 }.drop(1).dropRight(1)\n\n val Array(h, w) = readLineInts\n val a = Array.fill(h)(readLineInts)\n val b = a.map(row => row.map(aij => if (aij == 0) aij else if (aij % 2 == 0) 2 else 1))\n println(b(0).toList)\n val moveResults: Seq[(Seq[Int], Int)] = b.map { row =>\n val moves = adjustRow(row)\n (moves, row.last + moves.lastOption.getOrElse(0))\n }\n val rowMoves = moveResults.map(_._1)\n val column = moveResults.map(_._2)\n val columnMoves = adjustRow(column)\n\n val rowWiseMoves = {\n for((rowMove, rowIndex) <- rowMoves.zipWithIndex;\n (moveFlag, columnIndex) <- rowMove.zipWithIndex;\n move <- Some((rowIndex + 1, columnIndex + 1, rowIndex + 1, columnIndex + 2)) if moveFlag == 1) yield move\n }\n val columnWiseMoves = {\n for ((moveFlag, rowIndex) <- columnMoves.zipWithIndex;\n move <- Some((rowIndex + 1, w, rowIndex + 2, w)) if moveFlag == 1) yield move\n }\n val moves = rowWiseMoves ++ columnWiseMoves\n\n println(moves.length)\n for ((a, b, c, d) <- moves) println(s\"$a $b $c $d\")\n }\n}\n", "language": "Scala", "metadata": {"date": 1536460571, "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/s993814021.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s993814021", "user_id": "u909304507"}, "prompt_components": {"gold_output": "3\n2 2 2 3\n1 1 1 2\n1 3 1 2\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 def adjustRow(row: Seq[Int]): Seq[Int] = row.scanLeft(0){ (a, carry) => (a + carry) % 2 }.drop(1).dropRight(1)\n\n val Array(h, w) = readLineInts\n val a = Array.fill(h)(readLineInts)\n val b = a.map(row => row.map(aij => if (aij == 0) aij else if (aij % 2 == 0) 2 else 1))\n println(b(0).toList)\n val moveResults: Seq[(Seq[Int], Int)] = b.map { row =>\n val moves = adjustRow(row)\n (moves, row.last + moves.lastOption.getOrElse(0))\n }\n val rowMoves = moveResults.map(_._1)\n val column = moveResults.map(_._2)\n val columnMoves = adjustRow(column)\n\n val rowWiseMoves = {\n for((rowMove, rowIndex) <- rowMoves.zipWithIndex;\n (moveFlag, columnIndex) <- rowMove.zipWithIndex;\n move <- Some((rowIndex + 1, columnIndex + 1, rowIndex + 1, columnIndex + 2)) if moveFlag == 1) yield move\n }\n val columnWiseMoves = {\n for ((moveFlag, rowIndex) <- columnMoves.zipWithIndex;\n move <- Some((rowIndex + 1, w, rowIndex + 2, w)) if moveFlag == 1) yield move\n }\n val moves = rowWiseMoves ++ columnWiseMoves\n\n println(moves.length)\n for ((a, b, c, d) <- moves) println(s\"$a $b $c $d\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1858, "cpu_time_ms": 1910, "memory_kb": 92008}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s079966094", "group_id": "codeNet:p03264", "input_text": "// A - Pair\n// https://abc108.contest.atcoder.jp/tasks/abc108_a\n\nimport scala.io.StdIn.readLine\n\nobject Main extends App {\n\n val k = readLine.toInt\n\n val odd = k / 2\n val even = (k + 1) / 2\n\n val c = odd * even\n\n println(c)\n\n}", "language": "Scala", "metadata": {"date": 1537779024, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03264.html", "problem_id": "p03264", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03264/input.txt", "sample_output_relpath": "derived/input_output/data/p03264/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03264/Scala/s079966094.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s079966094", "user_id": "u212517806"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "// A - Pair\n// https://abc108.contest.atcoder.jp/tasks/abc108_a\n\nimport scala.io.StdIn.readLine\n\nobject Main extends App {\n\n val k = readLine.toInt\n\n val odd = k / 2\n val even = (k + 1) / 2\n\n val c = odd * even\n\n println(c)\n\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nFind the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive). The order does not matter.\n\nConstraints\n\n2\\leq K\\leq 100\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive).\n\nSample Input 1\n\n3\n\nSample Output 1\n\n2\n\nTwo pairs can be chosen: (2,1) and (2,3).\n\nSample Input 2\n\n6\n\nSample Output 2\n\n9\n\nSample Input 3\n\n11\n\nSample Output 3\n\n30\n\nSample Input 4\n\n50\n\nSample Output 4\n\n625", "sample_input": "3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03264", "source_text": "Score : 100 points\n\nProblem Statement\n\nFind the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive). The order does not matter.\n\nConstraints\n\n2\\leq K\\leq 100\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive).\n\nSample Input 1\n\n3\n\nSample Output 1\n\n2\n\nTwo pairs can be chosen: (2,1) and (2,3).\n\nSample Input 2\n\n6\n\nSample Output 2\n\n9\n\nSample Input 3\n\n11\n\nSample Output 3\n\n30\n\nSample Input 4\n\n50\n\nSample Output 4\n\n625", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 231, "cpu_time_ms": 317, "memory_kb": 25412}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s938403987", "group_id": "codeNet:p03273", "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(h, w) = sc.nextLine.split(\" \").map(_.toInt)\n val table = List.fill(h)(sc.nextLine.toList).map(_.toList)\n table.filter(_.contains('#')).transpose.filter(_.contains('#')).transpose.map(_.mkString).foreach(println(_))\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1557143173, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03273.html", "problem_id": "p03273", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03273/input.txt", "sample_output_relpath": "derived/input_output/data/p03273/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03273/Scala/s938403987.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s938403987", "user_id": "u629133942"}, "prompt_components": {"gold_output": "###\n###\n.##\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(h, w) = sc.nextLine.split(\" \").map(_.toInt)\n val table = List.fill(h)(sc.nextLine.toList).map(_.toList)\n table.filter(_.contains('#')).transpose.filter(_.contains('#')).transpose.map(_.mkString).foreach(println(_))\n }\n\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere is a grid of squares with H horizontal rows and W vertical columns.\nThe square at the i-th row from the top and the j-th column from the left is represented as (i, j).\nEach square is black or white.\nThe color of the square is given as an H-by-W matrix (a_{i, j}).\nIf a_{i, j} is ., the square (i, j) is white; if a_{i, j} is #, the square (i, j) is black.\n\nSnuke is compressing this grid.\nHe will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:\n\nOperation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.\n\nIt can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation.\nFind the final state of the grid.\n\nConstraints\n\n1 \\leq H, W \\leq 100\n\na_{i, j} is . or #.\n\nThere is at least one black square in the whole grid.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{1, 1}...a_{1, W}\n:\na_{H, 1}...a_{H, W}\n\nOutput\n\nPrint the final state of the grid in the same format as input (without the numbers of rows and columns); see the samples for clarity.\n\nSample Input 1\n\n4 4\n##.#\n....\n##.#\n.#.#\n\nSample Output 1\n\n###\n###\n.##\n\nThe second row and the third column in the original grid will be removed.\n\nSample Input 2\n\n3 3\n#..\n.#.\n..#\n\nSample Output 2\n\n#..\n.#.\n..#\n\nAs there is no row or column that consists only of white squares, no operation will be performed.\n\nSample Input 3\n\n4 5\n.....\n.....\n..#..\n.....\n\nSample Output 3\n\n#\n\nSample Input 4\n\n7 6\n......\n....#.\n.#....\n..#...\n..#...\n......\n.#..#.\n\nSample Output 4\n\n..#\n#..\n.#.\n.#.\n#.#", "sample_input": "4 4\n##.#\n....\n##.#\n.#.#\n"}, "reference_outputs": ["###\n###\n.##\n"], "source_document_id": "p03273", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere is a grid of squares with H horizontal rows and W vertical columns.\nThe square at the i-th row from the top and the j-th column from the left is represented as (i, j).\nEach square is black or white.\nThe color of the square is given as an H-by-W matrix (a_{i, j}).\nIf a_{i, j} is ., the square (i, j) is white; if a_{i, j} is #, the square (i, j) is black.\n\nSnuke is compressing this grid.\nHe will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:\n\nOperation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.\n\nIt can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation.\nFind the final state of the grid.\n\nConstraints\n\n1 \\leq H, W \\leq 100\n\na_{i, j} is . or #.\n\nThere is at least one black square in the whole grid.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{1, 1}...a_{1, W}\n:\na_{H, 1}...a_{H, W}\n\nOutput\n\nPrint the final state of the grid in the same format as input (without the numbers of rows and columns); see the samples for clarity.\n\nSample Input 1\n\n4 4\n##.#\n....\n##.#\n.#.#\n\nSample Output 1\n\n###\n###\n.##\n\nThe second row and the third column in the original grid will be removed.\n\nSample Input 2\n\n3 3\n#..\n.#.\n..#\n\nSample Output 2\n\n#..\n.#.\n..#\n\nAs there is no row or column that consists only of white squares, no operation will be performed.\n\nSample Input 3\n\n4 5\n.....\n.....\n..#..\n.....\n\nSample Output 3\n\n#\n\nSample Input 4\n\n7 6\n......\n....#.\n.#....\n..#...\n..#...\n......\n.#..#.\n\nSample Output 4\n\n..#\n#..\n.#.\n.#.\n#.#", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 369, "cpu_time_ms": 481, "memory_kb": 30060}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s212710615", "group_id": "codeNet:p03273", "input_text": "import scala.io.StdIn._\nimport scala.math._\n\n/**\n * ABC107B\n */\nobject Main extends App {\n\n val Seq(h, w) = readLine().split(\" \").toSeq.map(_.toInt)\n val blob: Seq[String] = (0 until h).map(_ => readLine()).toIndexedSeq\n\n val calcNewRow = (b: String) => {\n (0 until w)\n .filter(colNum => blob.map(_(colNum).toString).contains(\"#\"))\n .map(v => b(v))\n .mkString(\"\")\n }\n\n val ans = blob.filter(v => v.contains(\"#\"))\n .map(calcNewRow(_))\n\n ans.foreach(println)\n\n}\n", "language": "Scala", "metadata": {"date": 1541893321, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03273.html", "problem_id": "p03273", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03273/input.txt", "sample_output_relpath": "derived/input_output/data/p03273/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03273/Scala/s212710615.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s212710615", "user_id": "u234749694"}, "prompt_components": {"gold_output": "###\n###\n.##\n", "input_to_evaluate": "import scala.io.StdIn._\nimport scala.math._\n\n/**\n * ABC107B\n */\nobject Main extends App {\n\n val Seq(h, w) = readLine().split(\" \").toSeq.map(_.toInt)\n val blob: Seq[String] = (0 until h).map(_ => readLine()).toIndexedSeq\n\n val calcNewRow = (b: String) => {\n (0 until w)\n .filter(colNum => blob.map(_(colNum).toString).contains(\"#\"))\n .map(v => b(v))\n .mkString(\"\")\n }\n\n val ans = blob.filter(v => v.contains(\"#\"))\n .map(calcNewRow(_))\n\n ans.foreach(println)\n\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere is a grid of squares with H horizontal rows and W vertical columns.\nThe square at the i-th row from the top and the j-th column from the left is represented as (i, j).\nEach square is black or white.\nThe color of the square is given as an H-by-W matrix (a_{i, j}).\nIf a_{i, j} is ., the square (i, j) is white; if a_{i, j} is #, the square (i, j) is black.\n\nSnuke is compressing this grid.\nHe will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:\n\nOperation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.\n\nIt can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation.\nFind the final state of the grid.\n\nConstraints\n\n1 \\leq H, W \\leq 100\n\na_{i, j} is . or #.\n\nThere is at least one black square in the whole grid.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{1, 1}...a_{1, W}\n:\na_{H, 1}...a_{H, W}\n\nOutput\n\nPrint the final state of the grid in the same format as input (without the numbers of rows and columns); see the samples for clarity.\n\nSample Input 1\n\n4 4\n##.#\n....\n##.#\n.#.#\n\nSample Output 1\n\n###\n###\n.##\n\nThe second row and the third column in the original grid will be removed.\n\nSample Input 2\n\n3 3\n#..\n.#.\n..#\n\nSample Output 2\n\n#..\n.#.\n..#\n\nAs there is no row or column that consists only of white squares, no operation will be performed.\n\nSample Input 3\n\n4 5\n.....\n.....\n..#..\n.....\n\nSample Output 3\n\n#\n\nSample Input 4\n\n7 6\n......\n....#.\n.#....\n..#...\n..#...\n......\n.#..#.\n\nSample Output 4\n\n..#\n#..\n.#.\n.#.\n#.#", "sample_input": "4 4\n##.#\n....\n##.#\n.#.#\n"}, "reference_outputs": ["###\n###\n.##\n"], "source_document_id": "p03273", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere is a grid of squares with H horizontal rows and W vertical columns.\nThe square at the i-th row from the top and the j-th column from the left is represented as (i, j).\nEach square is black or white.\nThe color of the square is given as an H-by-W matrix (a_{i, j}).\nIf a_{i, j} is ., the square (i, j) is white; if a_{i, j} is #, the square (i, j) is black.\n\nSnuke is compressing this grid.\nHe will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:\n\nOperation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.\n\nIt can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation.\nFind the final state of the grid.\n\nConstraints\n\n1 \\leq H, W \\leq 100\n\na_{i, j} is . or #.\n\nThere is at least one black square in the whole grid.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{1, 1}...a_{1, W}\n:\na_{H, 1}...a_{H, W}\n\nOutput\n\nPrint the final state of the grid in the same format as input (without the numbers of rows and columns); see the samples for clarity.\n\nSample Input 1\n\n4 4\n##.#\n....\n##.#\n.#.#\n\nSample Output 1\n\n###\n###\n.##\n\nThe second row and the third column in the original grid will be removed.\n\nSample Input 2\n\n3 3\n#..\n.#.\n..#\n\nSample Output 2\n\n#..\n.#.\n..#\n\nAs there is no row or column that consists only of white squares, no operation will be performed.\n\nSample Input 3\n\n4 5\n.....\n.....\n..#..\n.....\n\nSample Output 3\n\n#\n\nSample Input 4\n\n7 6\n......\n....#.\n.#....\n..#...\n..#...\n......\n.#..#.\n\nSample Output 4\n\n..#\n#..\n.#.\n.#.\n#.#", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 487, "cpu_time_ms": 670, "memory_kb": 49900}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s183272544", "group_id": "codeNet:p03273", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n StdIn.readLine\n\n Iterator.continually(StdIn.readLine)\n .takeWhile(_ != null)\n .filter(_.contains('#'))\n .map(_.toCharArray)\n .toArray\n .transpose\n .filter(_.contains('#'))\n .transpose\n .toArray\n .foreach(ch => println(ch.mkString))\n}", "language": "Scala", "metadata": {"date": 1541528310, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03273.html", "problem_id": "p03273", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03273/input.txt", "sample_output_relpath": "derived/input_output/data/p03273/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03273/Scala/s183272544.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s183272544", "user_id": "u217010036"}, "prompt_components": {"gold_output": "###\n###\n.##\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n StdIn.readLine\n\n Iterator.continually(StdIn.readLine)\n .takeWhile(_ != null)\n .filter(_.contains('#'))\n .map(_.toCharArray)\n .toArray\n .transpose\n .filter(_.contains('#'))\n .transpose\n .toArray\n .foreach(ch => println(ch.mkString))\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere is a grid of squares with H horizontal rows and W vertical columns.\nThe square at the i-th row from the top and the j-th column from the left is represented as (i, j).\nEach square is black or white.\nThe color of the square is given as an H-by-W matrix (a_{i, j}).\nIf a_{i, j} is ., the square (i, j) is white; if a_{i, j} is #, the square (i, j) is black.\n\nSnuke is compressing this grid.\nHe will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:\n\nOperation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.\n\nIt can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation.\nFind the final state of the grid.\n\nConstraints\n\n1 \\leq H, W \\leq 100\n\na_{i, j} is . or #.\n\nThere is at least one black square in the whole grid.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{1, 1}...a_{1, W}\n:\na_{H, 1}...a_{H, W}\n\nOutput\n\nPrint the final state of the grid in the same format as input (without the numbers of rows and columns); see the samples for clarity.\n\nSample Input 1\n\n4 4\n##.#\n....\n##.#\n.#.#\n\nSample Output 1\n\n###\n###\n.##\n\nThe second row and the third column in the original grid will be removed.\n\nSample Input 2\n\n3 3\n#..\n.#.\n..#\n\nSample Output 2\n\n#..\n.#.\n..#\n\nAs there is no row or column that consists only of white squares, no operation will be performed.\n\nSample Input 3\n\n4 5\n.....\n.....\n..#..\n.....\n\nSample Output 3\n\n#\n\nSample Input 4\n\n7 6\n......\n....#.\n.#....\n..#...\n..#...\n......\n.#..#.\n\nSample Output 4\n\n..#\n#..\n.#.\n.#.\n#.#", "sample_input": "4 4\n##.#\n....\n##.#\n.#.#\n"}, "reference_outputs": ["###\n###\n.##\n"], "source_document_id": "p03273", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere is a grid of squares with H horizontal rows and W vertical columns.\nThe square at the i-th row from the top and the j-th column from the left is represented as (i, j).\nEach square is black or white.\nThe color of the square is given as an H-by-W matrix (a_{i, j}).\nIf a_{i, j} is ., the square (i, j) is white; if a_{i, j} is #, the square (i, j) is black.\n\nSnuke is compressing this grid.\nHe will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:\n\nOperation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.\n\nIt can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation.\nFind the final state of the grid.\n\nConstraints\n\n1 \\leq H, W \\leq 100\n\na_{i, j} is . or #.\n\nThere is at least one black square in the whole grid.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{1, 1}...a_{1, W}\n:\na_{H, 1}...a_{H, W}\n\nOutput\n\nPrint the final state of the grid in the same format as input (without the numbers of rows and columns); see the samples for clarity.\n\nSample Input 1\n\n4 4\n##.#\n....\n##.#\n.#.#\n\nSample Output 1\n\n###\n###\n.##\n\nThe second row and the third column in the original grid will be removed.\n\nSample Input 2\n\n3 3\n#..\n.#.\n..#\n\nSample Output 2\n\n#..\n.#.\n..#\n\nAs there is no row or column that consists only of white squares, no operation will be performed.\n\nSample Input 3\n\n4 5\n.....\n.....\n..#..\n.....\n\nSample Output 3\n\n#\n\nSample Input 4\n\n7 6\n......\n....#.\n.#....\n..#...\n..#...\n......\n.#..#.\n\nSample Output 4\n\n..#\n#..\n.#.\n.#.\n#.#", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 312, "cpu_time_ms": 413, "memory_kb": 29556}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s087099327", "group_id": "codeNet:p03281", "input_text": "object Main extends App{\nprintln((1 to scala.io.StdIn.readInt by 2 filter { k =>\n (1 to k filter(k % _ == 0)).size == 8\n}).size)}", "language": "Scala", "metadata": {"date": 1561154466, "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/s087099327.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s087099327", "user_id": "u238510421"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main extends App{\nprintln((1 to scala.io.StdIn.readInt by 2 filter { k =>\n (1 to k filter(k % _ == 0)).size == 8\n}).size)}", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 347, "memory_kb": 25496}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s235871385", "group_id": "codeNet:p03282", "input_text": "object Main extends App {\n val str = io.StdIn.readLine()\n val index = io.StdIn.readInt\n\n val mrInfinity = new MrInfinity\n println(mrInfinity.superBrain(str, index))\n}\n\nclass MrInfinity {\n /**\n * 500兆回処理を繰り返してできた文字列の、左からindex番目の値を返却する。\n * @str 捜査対象の文字列(1~9の数値で構成されている)\n * @index 検査位置\n * @return 左からindex番目にある値(0からでなく、1から開始)\n */\n def superBrain(str: String, index: Long): Char = {\n // 与えられた条件から、実際に5000兆回処理する必要はない。\n // indexより左に1しかない場合には何回処理をしても1になることが明確なので1を返却する。\n // 1以外の数値の場合、2の5000兆乗が優にindexの条件である10^18を越えるため、\n // 一番最初に出てきた数字でindexまでが埋め尽くされることになる。\n // ex) \"21\"の場合、2が2の5000兆乗個/1が1個となり、indexの最大値である10^18番目は2となる。\n //\n // 従って、以下の条件で返却値を決める。\n // indexまでに1しかない場合 -> 1を返却\n // 1以外の値がある場合 -> 一番左にある1以外の値\n \n if (index == 1 || str.length == 1) str.head\n else {\n str.head match {\n case '1' => superBrain(str.tail, index - 1)\n case _ => str.head\n }\n }\n }\n \n}\n", "language": "Scala", "metadata": {"date": 1535719626, "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/s235871385.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s235871385", "user_id": "u216683960"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n val str = io.StdIn.readLine()\n val index = io.StdIn.readInt\n\n val mrInfinity = new MrInfinity\n println(mrInfinity.superBrain(str, index))\n}\n\nclass MrInfinity {\n /**\n * 500兆回処理を繰り返してできた文字列の、左からindex番目の値を返却する。\n * @str 捜査対象の文字列(1~9の数値で構成されている)\n * @index 検査位置\n * @return 左からindex番目にある値(0からでなく、1から開始)\n */\n def superBrain(str: String, index: Long): Char = {\n // 与えられた条件から、実際に5000兆回処理する必要はない。\n // indexより左に1しかない場合には何回処理をしても1になることが明確なので1を返却する。\n // 1以外の数値の場合、2の5000兆乗が優にindexの条件である10^18を越えるため、\n // 一番最初に出てきた数字でindexまでが埋め尽くされることになる。\n // ex) \"21\"の場合、2が2の5000兆乗個/1が1個となり、indexの最大値である10^18番目は2となる。\n //\n // 従って、以下の条件で返却値を決める。\n // indexまでに1しかない場合 -> 1を返却\n // 1以外の値がある場合 -> 一番左にある1以外の値\n \n if (index == 1 || str.length == 1) str.head\n else {\n str.head match {\n case '1' => superBrain(str.tail, index - 1)\n case _ => str.head\n }\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1482, "cpu_time_ms": 320, "memory_kb": 25292}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s862330522", "group_id": "codeNet:p03284", "input_text": "import scala.io.StdIn._\nobject Main extends App{\n val sc = new java.util.Scanner(System.in)\n val n,k = sc.nextInt\n if(n%k==0){\n print(0)\n }\n else{\n print(1)\n }\n}", "language": "Scala", "metadata": {"date": 1590454841, "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/s862330522.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s862330522", "user_id": "u662430503"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import scala.io.StdIn._\nobject Main extends App{\n val sc = new java.util.Scanner(System.in)\n val n,k = sc.nextInt\n if(n%k==0){\n print(0)\n }\n else{\n print(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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 348, "memory_kb": 27340}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s591679718", "group_id": "codeNet:p03284", "input_text": "object Main extends App {\n io.StdIn.readLine().split(' ').map(_.toInt).toList match {\n case n :: k :: Nil => println(if (n % k == 0) 0 else 1)\n }\n}\n", "language": "Scala", "metadata": {"date": 1540604089, "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/s591679718.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s591679718", "user_id": "u108923708"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main extends App {\n io.StdIn.readLine().split(' ').map(_.toInt).toList match {\n case n :: k :: Nil => println(if (n % k == 0) 0 else 1)\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 153, "cpu_time_ms": 324, "memory_kb": 27448}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s880696618", "group_id": "codeNet:p03285", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n val n = StdIn.readLine.toInt\n val ans = if ((n % 7) == 0 || (n % 4) == 0) \"Yes\"\n else if ((1 until n by 7).exists(i => (n - i) % 4 == 0)) \"Yes\"\n else \"No\"\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1541547083, "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/s880696618.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s880696618", "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 val ans = if ((n % 7) == 0 || (n % 4) == 0) \"Yes\"\n else if ((1 until n by 7).exists(i => (n - i) % 4 == 0)) \"Yes\"\n else \"No\"\n println(ans)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nLa Confiserie d'ABC sells cakes at 4 dollars each and doughnuts at 7 dollars each.\nDetermine if there is a way to buy some of them for exactly N dollars. You can buy two or more doughnuts and two or more cakes, and you can also choose to buy zero doughnuts or zero cakes.\n\nConstraints\n\nN is an integer between 1 and 100, inclusive.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there is a way to buy some cakes and some doughnuts for exactly N dollars, print Yes; otherwise, print No.\n\nSample Input 1\n\n11\n\nSample Output 1\n\nYes\n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\nSample Input 2\n\n40\n\nSample Output 2\n\nYes\n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\nSample Input 3\n\n3\n\nSample Output 3\n\nNo\n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than 3 dollars, so there is no such way.", "sample_input": "11\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03285", "source_text": "Score : 200 points\n\nProblem Statement\n\nLa Confiserie d'ABC sells cakes at 4 dollars each and doughnuts at 7 dollars each.\nDetermine if there is a way to buy some of them for exactly N dollars. You can buy two or more doughnuts and two or more cakes, and you can also choose to buy zero doughnuts or zero cakes.\n\nConstraints\n\nN is an integer between 1 and 100, inclusive.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there is a way to buy some cakes and some doughnuts for exactly N dollars, print Yes; otherwise, print No.\n\nSample Input 1\n\n11\n\nSample Output 1\n\nYes\n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\nSample Input 2\n\n40\n\nSample Output 2\n\nYes\n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\nSample Input 3\n\n3\n\nSample Output 3\n\nNo\n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than 3 dollars, so there is no such way.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 229, "cpu_time_ms": 324, "memory_kb": 25296}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s089232906", "group_id": "codeNet:p03285", "input_text": "import scala.io.StdIn\n\nobject Main {\n\tdef main(args: Array[String]): Unit ={\n\t\tval N = StdIn.readLine.toInt\n\n\t\tval result = (0 to N/7 ).exists{ n =>\n\t\t\t(N - 7 * n ) % 4 == 0\n\t\t}\n\t\tprintln( if (result) \"Yes\" else \"No\")\n\t}\n}\n", "language": "Scala", "metadata": {"date": 1539519224, "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/s089232906.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s089232906", "user_id": "u829407811"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main {\n\tdef main(args: Array[String]): Unit ={\n\t\tval N = StdIn.readLine.toInt\n\n\t\tval result = (0 to N/7 ).exists{ n =>\n\t\t\t(N - 7 * n ) % 4 == 0\n\t\t}\n\t\tprintln( if (result) \"Yes\" else \"No\")\n\t}\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nLa Confiserie d'ABC sells cakes at 4 dollars each and doughnuts at 7 dollars each.\nDetermine if there is a way to buy some of them for exactly N dollars. You can buy two or more doughnuts and two or more cakes, and you can also choose to buy zero doughnuts or zero cakes.\n\nConstraints\n\nN is an integer between 1 and 100, inclusive.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there is a way to buy some cakes and some doughnuts for exactly N dollars, print Yes; otherwise, print No.\n\nSample Input 1\n\n11\n\nSample Output 1\n\nYes\n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\nSample Input 2\n\n40\n\nSample Output 2\n\nYes\n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\nSample Input 3\n\n3\n\nSample Output 3\n\nNo\n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than 3 dollars, so there is no such way.", "sample_input": "11\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03285", "source_text": "Score : 200 points\n\nProblem Statement\n\nLa Confiserie d'ABC sells cakes at 4 dollars each and doughnuts at 7 dollars each.\nDetermine if there is a way to buy some of them for exactly N dollars. You can buy two or more doughnuts and two or more cakes, and you can also choose to buy zero doughnuts or zero cakes.\n\nConstraints\n\nN is an integer between 1 and 100, inclusive.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there is a way to buy some cakes and some doughnuts for exactly N dollars, print Yes; otherwise, print No.\n\nSample Input 1\n\n11\n\nSample Output 1\n\nYes\n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\nSample Input 2\n\n40\n\nSample Output 2\n\nYes\n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\nSample Input 3\n\n3\n\nSample Output 3\n\nNo\n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than 3 dollars, so there is no such way.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 223, "cpu_time_ms": 317, "memory_kb": 27180}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s067052271", "group_id": "codeNet:p03287", "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 N = sc.nextInt\n val M = sc.nextInt\n val A = Array.fill(N)(sc.nextInt)\n\n val checked = mutable.Set[Int](N)\n var ans = 0L\n for (l <- 0 until N if !checked(l)) {\n var sum = 0\n var r = 0\n for (i <- l until N) {\n if (sum == 0) {\n checked += i\n }\n sum += A(i)\n if (sum % M == 0) {\n r += 1\n ans += r\n sum = 0\n }\n }\n }\n ans.toString\n }\n}\n", "language": "Scala", "metadata": {"date": 1534041300, "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/s067052271.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s067052271", "user_id": "u297767059"}, "prompt_components": {"gold_output": "3\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 N = sc.nextInt\n val M = sc.nextInt\n val A = Array.fill(N)(sc.nextInt)\n\n val checked = mutable.Set[Int](N)\n var ans = 0L\n for (l <- 0 until N if !checked(l)) {\n var sum = 0\n var r = 0\n for (i <- l until N) {\n if (sum == 0) {\n checked += i\n }\n sum += A(i)\n if (sum % M == 0) {\n r += 1\n ans += r\n sum = 0\n }\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 699, "cpu_time_ms": 2123, "memory_kb": 106112}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s612620479", "group_id": "codeNet:p03288", "input_text": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val r = in.readInt\n\n val ans = r match {\n case r if r < 1200 => \"ABC\"\n case r if r < 2000 => \"ARC\"\n case _ => \"AGC\"\n }\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1557613679, "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/s612620479.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s612620479", "user_id": "u217010036"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val r = in.readInt\n\n val ans = r match {\n case r if r < 1200 => \"ABC\"\n case r if r < 2000 => \"ARC\"\n case _ => \"AGC\"\n }\n println(ans)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 330, "memory_kb": 27428}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s277067320", "group_id": "codeNet:p03288", "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 D, G = in.next().toInt\n val p = new Array[Int](D+1)\n val c = new Array[Int](D+1)\n\n for(i <- 1 to D) {\n val a, b = in.next().toInt\n p(i) = a; c(i) = b / 100\n }\n\n\n //\n val MAX = 100000\n val IM = Int.MaxValue\n val dp = Array.fill[Int](MAX+1)(IM)\n dp(0) = 0\n for(k <- 1 to D) {\n val np = p(k); val nc = c(k)\n\n for(i <- (1 to MAX).reverse) {\n for (j <- 1 until np) {\n val now = i - (k * j)\n if(now >= 0)\n if(dp(now) != IM) {\n dp(i) = dp(i) min (dp(now) + j)\n }\n }\n\n val clear = i - (k * np) - nc\n if(clear >= 0)\n if(dp(clear) != IM) {\n dp(i) = dp(i) min (dp(clear) + np)\n }\n }\n }\n\n var ans = IM\n for (i <- G/100 to MAX)\n ans = ans min dp(i)\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": 1551745964, "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/s277067320.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s277067320", "user_id": "u098968285"}, "prompt_components": {"gold_output": "ABC\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 D, G = in.next().toInt\n val p = new Array[Int](D+1)\n val c = new Array[Int](D+1)\n\n for(i <- 1 to D) {\n val a, b = in.next().toInt\n p(i) = a; c(i) = b / 100\n }\n\n\n //\n val MAX = 100000\n val IM = Int.MaxValue\n val dp = Array.fill[Int](MAX+1)(IM)\n dp(0) = 0\n for(k <- 1 to D) {\n val np = p(k); val nc = c(k)\n\n for(i <- (1 to MAX).reverse) {\n for (j <- 1 until np) {\n val now = i - (k * j)\n if(now >= 0)\n if(dp(now) != IM) {\n dp(i) = dp(i) min (dp(now) + j)\n }\n }\n\n val clear = i - (k * np) - nc\n if(clear >= 0)\n if(dp(clear) != IM) {\n dp(i) = dp(i) min (dp(clear) + np)\n }\n }\n }\n\n var ans = IM\n for (i <- G/100 to MAX)\n ans = ans min dp(i)\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 : 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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1341, "cpu_time_ms": 329, "memory_kb": 25416}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s372086237", "group_id": "codeNet:p03289", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n val s = StdIn.readLine.split(\" \")\n\n val res = s.filter(_.charAt(0) == 'A')\n .filter(l => l.count(_.isUpper) == 2)\n .map(_.toCharArray)\n .map(_.drop(2).init)\n .exists(l => l.count(ch => ch == 'C') == 1)\n\n println(if (res) \"AC\" else \"WA\")\n}", "language": "Scala", "metadata": {"date": 1541618829, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03289.html", "problem_id": "p03289", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03289/input.txt", "sample_output_relpath": "derived/input_output/data/p03289/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03289/Scala/s372086237.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s372086237", "user_id": "u217010036"}, "prompt_components": {"gold_output": "AC\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n val s = StdIn.readLine.split(\" \")\n\n val res = s.filter(_.charAt(0) == 'A')\n .filter(l => l.count(_.isUpper) == 2)\n .map(_.toCharArray)\n .map(_.drop(2).init)\n .exists(l => l.count(ch => ch == 'C') == 1)\n\n println(if (res) \"AC\" else \"WA\")\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S. Each character of S is uppercase or lowercase English letter.\nDetermine if S satisfies all of the following conditions:\n\nThe initial character of S is an uppercase A.\n\nThere is exactly one occurrence of C between the third character from the beginning and the second to last character (inclusive).\n\nAll letters except the A and C mentioned above are lowercase.\n\nConstraints\n\n4 ≤ |S| ≤ 10 (|S| is the length of the string S.)\n\nEach character of S is uppercase or lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S satisfies all of the conditions in the problem statement, print AC; otherwise, print WA.\n\nSample Input 1\n\nAtCoder\n\nSample Output 1\n\nAC\n\nThe first letter is A, the third letter is C and the remaining letters are all lowercase, so all the conditions are satisfied.\n\nSample Input 2\n\nACoder\n\nSample Output 2\n\nWA\n\nThe second letter should not be C.\n\nSample Input 3\n\nAcycliC\n\nSample Output 3\n\nWA\n\nThe last letter should not be C, either.\n\nSample Input 4\n\nAtCoCo\n\nSample Output 4\n\nWA\n\nThere should not be two or more occurrences of C.\n\nSample Input 5\n\nAtcoder\n\nSample Output 5\n\nWA\n\nThe number of C should not be zero, either.", "sample_input": "AtCoder\n"}, "reference_outputs": ["AC\n"], "source_document_id": "p03289", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S. Each character of S is uppercase or lowercase English letter.\nDetermine if S satisfies all of the following conditions:\n\nThe initial character of S is an uppercase A.\n\nThere is exactly one occurrence of C between the third character from the beginning and the second to last character (inclusive).\n\nAll letters except the A and C mentioned above are lowercase.\n\nConstraints\n\n4 ≤ |S| ≤ 10 (|S| is the length of the string S.)\n\nEach character of S is uppercase or lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S satisfies all of the conditions in the problem statement, print AC; otherwise, print WA.\n\nSample Input 1\n\nAtCoder\n\nSample Output 1\n\nAC\n\nThe first letter is A, the third letter is C and the remaining letters are all lowercase, so all the conditions are satisfied.\n\nSample Input 2\n\nACoder\n\nSample Output 2\n\nWA\n\nThe second letter should not be C.\n\nSample Input 3\n\nAcycliC\n\nSample Output 3\n\nWA\n\nThe last letter should not be C, either.\n\nSample Input 4\n\nAtCoCo\n\nSample Output 4\n\nWA\n\nThere should not be two or more occurrences of C.\n\nSample Input 5\n\nAtcoder\n\nSample Output 5\n\nWA\n\nThe number of C should not be zero, either.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 303, "cpu_time_ms": 358, "memory_kb": 25552}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s204067578", "group_id": "codeNet:p03289", "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 println(if (\n S.filter(c => c == 'C').size == 1\n && S.filter(c => c == 'A').size == 1\n && S.indexOf('A') == 0\n && 2 <= S.indexOf('C')\n && S.indexOf('C') < S.size - 1\n && S.filter(c => c.isLower).size + 2 == S.size\n ) (\"AC\") else (\"WA\"))\n }\n\n def recursive(A: Array[Array[Long]], pq: mutable.PriorityQueue[(Long, Int)], used: Set[Int]): Long = {\n if (pq.length == 0) (0) else {\n val now = pq.dequeue()\n (if (used.contains(now._2)) (0) else {\n for (i <- 0 until A(now._2).size) {\n if (A(now._2)(i) != -1) (pq.enqueue((A(now._2)(i), i)))\n }\n now._1\n }) + recursive(A, pq, used + now._2)\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}\n", "language": "Scala", "metadata": {"date": 1533764422, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03289.html", "problem_id": "p03289", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03289/input.txt", "sample_output_relpath": "derived/input_output/data/p03289/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03289/Scala/s204067578.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s204067578", "user_id": "u779353743"}, "prompt_components": {"gold_output": "AC\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 println(if (\n S.filter(c => c == 'C').size == 1\n && S.filter(c => c == 'A').size == 1\n && S.indexOf('A') == 0\n && 2 <= S.indexOf('C')\n && S.indexOf('C') < S.size - 1\n && S.filter(c => c.isLower).size + 2 == S.size\n ) (\"AC\") else (\"WA\"))\n }\n\n def recursive(A: Array[Array[Long]], pq: mutable.PriorityQueue[(Long, Int)], used: Set[Int]): Long = {\n if (pq.length == 0) (0) else {\n val now = pq.dequeue()\n (if (used.contains(now._2)) (0) else {\n for (i <- 0 until A(now._2).size) {\n if (A(now._2)(i) != -1) (pq.enqueue((A(now._2)(i), i)))\n }\n now._1\n }) + recursive(A, pq, used + now._2)\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}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S. Each character of S is uppercase or lowercase English letter.\nDetermine if S satisfies all of the following conditions:\n\nThe initial character of S is an uppercase A.\n\nThere is exactly one occurrence of C between the third character from the beginning and the second to last character (inclusive).\n\nAll letters except the A and C mentioned above are lowercase.\n\nConstraints\n\n4 ≤ |S| ≤ 10 (|S| is the length of the string S.)\n\nEach character of S is uppercase or lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S satisfies all of the conditions in the problem statement, print AC; otherwise, print WA.\n\nSample Input 1\n\nAtCoder\n\nSample Output 1\n\nAC\n\nThe first letter is A, the third letter is C and the remaining letters are all lowercase, so all the conditions are satisfied.\n\nSample Input 2\n\nACoder\n\nSample Output 2\n\nWA\n\nThe second letter should not be C.\n\nSample Input 3\n\nAcycliC\n\nSample Output 3\n\nWA\n\nThe last letter should not be C, either.\n\nSample Input 4\n\nAtCoCo\n\nSample Output 4\n\nWA\n\nThere should not be two or more occurrences of C.\n\nSample Input 5\n\nAtcoder\n\nSample Output 5\n\nWA\n\nThe number of C should not be zero, either.", "sample_input": "AtCoder\n"}, "reference_outputs": ["AC\n"], "source_document_id": "p03289", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S. Each character of S is uppercase or lowercase English letter.\nDetermine if S satisfies all of the following conditions:\n\nThe initial character of S is an uppercase A.\n\nThere is exactly one occurrence of C between the third character from the beginning and the second to last character (inclusive).\n\nAll letters except the A and C mentioned above are lowercase.\n\nConstraints\n\n4 ≤ |S| ≤ 10 (|S| is the length of the string S.)\n\nEach character of S is uppercase or lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S satisfies all of the conditions in the problem statement, print AC; otherwise, print WA.\n\nSample Input 1\n\nAtCoder\n\nSample Output 1\n\nAC\n\nThe first letter is A, the third letter is C and the remaining letters are all lowercase, so all the conditions are satisfied.\n\nSample Input 2\n\nACoder\n\nSample Output 2\n\nWA\n\nThe second letter should not be C.\n\nSample Input 3\n\nAcycliC\n\nSample Output 3\n\nWA\n\nThe last letter should not be C, either.\n\nSample Input 4\n\nAtCoCo\n\nSample Output 4\n\nWA\n\nThere should not be two or more occurrences of C.\n\nSample Input 5\n\nAtcoder\n\nSample Output 5\n\nWA\n\nThe number of C should not be zero, either.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6411, "cpu_time_ms": 334, "memory_kb": 25400}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s557976978", "group_id": "codeNet:p03289", "input_text": "object Main extends App {\n\tval s = scala.io.StdIn.readLine.toList.toArray\n\tval size = s.size\n \n\tval A = Array('a', 'B', 'c', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z')\n\n\tif(s(0) == 'A'){\n\t\tvar flag = false\n\t\tvar cnt = 0\n\n\t\tif(A.contains(s(1))) flag = true\n\n\t\tfor(i<-2 to size-2){\n\t\t\tif(s(i) == 'C') cnt += 1\n\t\t\tif(A.contains(s(i))) flag = true\n\t\t}\n\n\t\tif(flag) println(\"WA\")\n\t\telse if(cnt == 1) println(\"AC\")\n\t\telse println(\"WA\")\n\t}else{\n\t\tprintln(\"WA\")\n\t}\n}", "language": "Scala", "metadata": {"date": 1533681703, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03289.html", "problem_id": "p03289", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03289/input.txt", "sample_output_relpath": "derived/input_output/data/p03289/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03289/Scala/s557976978.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s557976978", "user_id": "u675876401"}, "prompt_components": {"gold_output": "AC\n", "input_to_evaluate": "object Main extends App {\n\tval s = scala.io.StdIn.readLine.toList.toArray\n\tval size = s.size\n \n\tval A = Array('a', 'B', 'c', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z')\n\n\tif(s(0) == 'A'){\n\t\tvar flag = false\n\t\tvar cnt = 0\n\n\t\tif(A.contains(s(1))) flag = true\n\n\t\tfor(i<-2 to size-2){\n\t\t\tif(s(i) == 'C') cnt += 1\n\t\t\tif(A.contains(s(i))) flag = true\n\t\t}\n\n\t\tif(flag) println(\"WA\")\n\t\telse if(cnt == 1) println(\"AC\")\n\t\telse println(\"WA\")\n\t}else{\n\t\tprintln(\"WA\")\n\t}\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S. Each character of S is uppercase or lowercase English letter.\nDetermine if S satisfies all of the following conditions:\n\nThe initial character of S is an uppercase A.\n\nThere is exactly one occurrence of C between the third character from the beginning and the second to last character (inclusive).\n\nAll letters except the A and C mentioned above are lowercase.\n\nConstraints\n\n4 ≤ |S| ≤ 10 (|S| is the length of the string S.)\n\nEach character of S is uppercase or lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S satisfies all of the conditions in the problem statement, print AC; otherwise, print WA.\n\nSample Input 1\n\nAtCoder\n\nSample Output 1\n\nAC\n\nThe first letter is A, the third letter is C and the remaining letters are all lowercase, so all the conditions are satisfied.\n\nSample Input 2\n\nACoder\n\nSample Output 2\n\nWA\n\nThe second letter should not be C.\n\nSample Input 3\n\nAcycliC\n\nSample Output 3\n\nWA\n\nThe last letter should not be C, either.\n\nSample Input 4\n\nAtCoCo\n\nSample Output 4\n\nWA\n\nThere should not be two or more occurrences of C.\n\nSample Input 5\n\nAtcoder\n\nSample Output 5\n\nWA\n\nThe number of C should not be zero, either.", "sample_input": "AtCoder\n"}, "reference_outputs": ["AC\n"], "source_document_id": "p03289", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S. Each character of S is uppercase or lowercase English letter.\nDetermine if S satisfies all of the following conditions:\n\nThe initial character of S is an uppercase A.\n\nThere is exactly one occurrence of C between the third character from the beginning and the second to last character (inclusive).\n\nAll letters except the A and C mentioned above are lowercase.\n\nConstraints\n\n4 ≤ |S| ≤ 10 (|S| is the length of the string S.)\n\nEach character of S is uppercase or lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S satisfies all of the conditions in the problem statement, print AC; otherwise, print WA.\n\nSample Input 1\n\nAtCoder\n\nSample Output 1\n\nAC\n\nThe first letter is A, the third letter is C and the remaining letters are all lowercase, so all the conditions are satisfied.\n\nSample Input 2\n\nACoder\n\nSample Output 2\n\nWA\n\nThe second letter should not be C.\n\nSample Input 3\n\nAcycliC\n\nSample Output 3\n\nWA\n\nThe last letter should not be C, either.\n\nSample Input 4\n\nAtCoCo\n\nSample Output 4\n\nWA\n\nThere should not be two or more occurrences of C.\n\nSample Input 5\n\nAtcoder\n\nSample Output 5\n\nWA\n\nThe number of C should not be zero, either.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 530, "cpu_time_ms": 327, "memory_kb": 25552}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s941116709", "group_id": "codeNet:p03290", "input_text": "object Main extends App {\n case class Problem(n: Int, ratio: Long, bonus: Long) {\n val completeScore = n * ratio + bonus\n }\n case class Result(score: Long, count: Int)\n\n val in = new java.util.Scanner(System.in)\n val D = in.nextInt\n val G = in.nextLong / 100\n\n val Ps = Array.tabulate(D){i => Problem(in.nextInt, i + 1, in.nextLong / 100)}\n val comps: IndexedSeq[Result] = (0 until (1 << D)).map {mask =>\n (0 to D).foldLeft(Result(0L, 0)) {case (r, i) =>\n if (((1 << i) & mask) == 0) r else Result(r.score + Ps(i).completeScore, r.count + Ps(i).n)\n }\n }\n\n def getAll(i: Int): Seq[Int] = {\n val targetComps: Seq[Result] = (0 until (1 << D)).flatMap {mask =>\n if (((1 << i) & mask) != 0) None else Some(comps(mask))\n }\n\n val p = Ps(i)\n val halfways: Seq[Result] = (0 to p.n).map {n =>\n if (n == p.n) Result(p.completeScore, n) else Result(n * p.ratio, n)\n }\n\n for {\n c <- targetComps\n h <- halfways\n if (c.score + h.score >= G)\n } yield c.count + h.count\n }\n\n println((0 until D).flatMap(getAll).min)\n}", "language": "Scala", "metadata": {"date": 1591986277, "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/s941116709.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s941116709", "user_id": "u132324749"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main extends App {\n case class Problem(n: Int, ratio: Long, bonus: Long) {\n val completeScore = n * ratio + bonus\n }\n case class Result(score: Long, count: Int)\n\n val in = new java.util.Scanner(System.in)\n val D = in.nextInt\n val G = in.nextLong / 100\n\n val Ps = Array.tabulate(D){i => Problem(in.nextInt, i + 1, in.nextLong / 100)}\n val comps: IndexedSeq[Result] = (0 until (1 << D)).map {mask =>\n (0 to D).foldLeft(Result(0L, 0)) {case (r, i) =>\n if (((1 << i) & mask) == 0) r else Result(r.score + Ps(i).completeScore, r.count + Ps(i).n)\n }\n }\n\n def getAll(i: Int): Seq[Int] = {\n val targetComps: Seq[Result] = (0 until (1 << D)).flatMap {mask =>\n if (((1 << i) & mask) != 0) None else Some(comps(mask))\n }\n\n val p = Ps(i)\n val halfways: Seq[Result] = (0 to p.n).map {n =>\n if (n == p.n) Result(p.completeScore, n) else Result(n * p.ratio, n)\n }\n\n for {\n c <- targetComps\n h <- halfways\n if (c.score + h.score >= G)\n } yield c.count + h.count\n }\n\n println((0 until D).flatMap(getAll).min)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nA programming competition site AtCode provides algorithmic problems.\nEach problem is allocated a score based on its difficulty.\nCurrently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points.\nThese p_1 + … + p_D problems are all of the problems available on AtCode.\n\nA user of AtCode has a value called total score.\nThe total score of a user is the sum of the following two elements:\n\nBase score: the sum of the scores of all problems solved by the user.\n\nPerfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D).\n\nTakahashi, who is the new user of AtCode, has not solved any problem.\nHis objective is to have a total score of G or more points.\nAt least how many problems does he need to solve for this objective?\n\nConstraints\n\n1 ≤ D ≤ 10\n\n1 ≤ p_i ≤ 100\n\n100 ≤ c_i ≤ 10^6\n\n100 ≤ G\n\nAll values in input are integers.\n\nc_i and G are all multiples of 100.\n\nIt is possible to have a total score of G or more points.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD G\np_1 c_1\n:\np_D c_D\n\nOutput\n\nPrint the minimum number of problems that needs to be solved in order to have a total score of G or more points. Note that this objective is always achievable (see Constraints).\n\nSample Input 1\n\n2 700\n3 500\n5 800\n\nSample Output 1\n\n3\n\nIn this case, there are three problems each with 100 points and five problems each with 200 points. The perfect bonus for solving all the 100-point problems is 500 points, and the perfect bonus for solving all the 200-point problems is 800 points. Takahashi's objective is to have a total score of 700 points or more.\n\nOne way to achieve this objective is to solve four 200-point problems and earn a base score of 800 points. However, if we solve three 100-point problems, we can earn the perfect bonus of 500 points in addition to the base score of 300 points, for a total score of 800 points, and we can achieve the objective with fewer problems.\n\nSample Input 2\n\n2 2000\n3 500\n5 800\n\nSample Output 2\n\n7\n\nThis case is similar to Sample Input 1, but the Takahashi's objective this time is 2000 points or more. In this case, we inevitably need to solve all five 200-point problems, and by solving two 100-point problems additionally we have the total score of 2000 points.\n\nSample Input 3\n\n2 400\n3 500\n5 800\n\nSample Output 3\n\n2\n\nThis case is again similar to Sample Input 1, but the Takahashi's objective this time is 400 points or more. In this case, we only need to solve two 200-point problems to achieve the objective.\n\nSample Input 4\n\n5 25000\n20 1000\n40 1000\n50 1000\n30 1000\n1 1000\n\nSample Output 4\n\n66\n\nThere is only one 500-point problem, but the perfect bonus can be earned even in such a case.", "sample_input": "2 700\n3 500\n5 800\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03290", "source_text": "Score : 300 points\n\nProblem Statement\n\nA programming competition site AtCode provides algorithmic problems.\nEach problem is allocated a score based on its difficulty.\nCurrently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points.\nThese p_1 + … + p_D problems are all of the problems available on AtCode.\n\nA user of AtCode has a value called total score.\nThe total score of a user is the sum of the following two elements:\n\nBase score: the sum of the scores of all problems solved by the user.\n\nPerfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D).\n\nTakahashi, who is the new user of AtCode, has not solved any problem.\nHis objective is to have a total score of G or more points.\nAt least how many problems does he need to solve for this objective?\n\nConstraints\n\n1 ≤ D ≤ 10\n\n1 ≤ p_i ≤ 100\n\n100 ≤ c_i ≤ 10^6\n\n100 ≤ G\n\nAll values in input are integers.\n\nc_i and G are all multiples of 100.\n\nIt is possible to have a total score of G or more points.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD G\np_1 c_1\n:\np_D c_D\n\nOutput\n\nPrint the minimum number of problems that needs to be solved in order to have a total score of G or more points. Note that this objective is always achievable (see Constraints).\n\nSample Input 1\n\n2 700\n3 500\n5 800\n\nSample Output 1\n\n3\n\nIn this case, there are three problems each with 100 points and five problems each with 200 points. The perfect bonus for solving all the 100-point problems is 500 points, and the perfect bonus for solving all the 200-point problems is 800 points. Takahashi's objective is to have a total score of 700 points or more.\n\nOne way to achieve this objective is to solve four 200-point problems and earn a base score of 800 points. However, if we solve three 100-point problems, we can earn the perfect bonus of 500 points in addition to the base score of 300 points, for a total score of 800 points, and we can achieve the objective with fewer problems.\n\nSample Input 2\n\n2 2000\n3 500\n5 800\n\nSample Output 2\n\n7\n\nThis case is similar to Sample Input 1, but the Takahashi's objective this time is 2000 points or more. In this case, we inevitably need to solve all five 200-point problems, and by solving two 100-point problems additionally we have the total score of 2000 points.\n\nSample Input 3\n\n2 400\n3 500\n5 800\n\nSample Output 3\n\n2\n\nThis case is again similar to Sample Input 1, but the Takahashi's objective this time is 400 points or more. In this case, we only need to solve two 200-point problems to achieve the objective.\n\nSample Input 4\n\n5 25000\n20 1000\n40 1000\n50 1000\n30 1000\n1 1000\n\nSample Output 4\n\n66\n\nThere is only one 500-point problem, but the perfect bonus can be earned even in such a case.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1072, "cpu_time_ms": 653, "memory_kb": 50792}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s083361671", "group_id": "codeNet:p03290", "input_text": "import scala.math.ceil\n\nobject Main {\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val d, g = sc.nextInt\n val table : List[List[Int]] = List.fill(d, 2)(sc.nextInt)\n\n val is = 0 until d\n\n var n = 0\n var gLeft = g\n var psLeft= is.map(table(_)(0))\n val cs = is.map(table(_)(1))\n while(gLeft > 0) {\n val isSufficient = is.filter(i => gLeft.toFloat / 100 / (i + 1) <= psLeft(i))\n if(isSufficient.nonEmpty) {\n n = n + ceil(gLeft.toFloat / 100 / (isSufficient.max + 1)).toInt\n gLeft = 0\n } else {\n val iMax = is.maxBy(i =>\n ((i + 1) * 100 * psLeft(i) + cs(i)).toFloat / psLeft(i)\n )\n n = n + psLeft(iMax)\n gLeft = gLeft - (iMax + 1) * psLeft(iMax) * 100 + cs(iMax)\n psLeft = psLeft.updated(iMax, 0)\n }\n }\n println(n)\n }\n}", "language": "Scala", "metadata": {"date": 1533523049, "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/s083361671.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s083361671", "user_id": "u710809824"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.math.ceil\n\nobject Main {\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val d, g = sc.nextInt\n val table : List[List[Int]] = List.fill(d, 2)(sc.nextInt)\n\n val is = 0 until d\n\n var n = 0\n var gLeft = g\n var psLeft= is.map(table(_)(0))\n val cs = is.map(table(_)(1))\n while(gLeft > 0) {\n val isSufficient = is.filter(i => gLeft.toFloat / 100 / (i + 1) <= psLeft(i))\n if(isSufficient.nonEmpty) {\n n = n + ceil(gLeft.toFloat / 100 / (isSufficient.max + 1)).toInt\n gLeft = 0\n } else {\n val iMax = is.maxBy(i =>\n ((i + 1) * 100 * psLeft(i) + cs(i)).toFloat / psLeft(i)\n )\n n = n + psLeft(iMax)\n gLeft = gLeft - (iMax + 1) * psLeft(iMax) * 100 + cs(iMax)\n psLeft = psLeft.updated(iMax, 0)\n }\n }\n println(n)\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nA programming competition site AtCode provides algorithmic problems.\nEach problem is allocated a score based on its difficulty.\nCurrently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points.\nThese p_1 + … + p_D problems are all of the problems available on AtCode.\n\nA user of AtCode has a value called total score.\nThe total score of a user is the sum of the following two elements:\n\nBase score: the sum of the scores of all problems solved by the user.\n\nPerfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D).\n\nTakahashi, who is the new user of AtCode, has not solved any problem.\nHis objective is to have a total score of G or more points.\nAt least how many problems does he need to solve for this objective?\n\nConstraints\n\n1 ≤ D ≤ 10\n\n1 ≤ p_i ≤ 100\n\n100 ≤ c_i ≤ 10^6\n\n100 ≤ G\n\nAll values in input are integers.\n\nc_i and G are all multiples of 100.\n\nIt is possible to have a total score of G or more points.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD G\np_1 c_1\n:\np_D c_D\n\nOutput\n\nPrint the minimum number of problems that needs to be solved in order to have a total score of G or more points. Note that this objective is always achievable (see Constraints).\n\nSample Input 1\n\n2 700\n3 500\n5 800\n\nSample Output 1\n\n3\n\nIn this case, there are three problems each with 100 points and five problems each with 200 points. The perfect bonus for solving all the 100-point problems is 500 points, and the perfect bonus for solving all the 200-point problems is 800 points. Takahashi's objective is to have a total score of 700 points or more.\n\nOne way to achieve this objective is to solve four 200-point problems and earn a base score of 800 points. However, if we solve three 100-point problems, we can earn the perfect bonus of 500 points in addition to the base score of 300 points, for a total score of 800 points, and we can achieve the objective with fewer problems.\n\nSample Input 2\n\n2 2000\n3 500\n5 800\n\nSample Output 2\n\n7\n\nThis case is similar to Sample Input 1, but the Takahashi's objective this time is 2000 points or more. In this case, we inevitably need to solve all five 200-point problems, and by solving two 100-point problems additionally we have the total score of 2000 points.\n\nSample Input 3\n\n2 400\n3 500\n5 800\n\nSample Output 3\n\n2\n\nThis case is again similar to Sample Input 1, but the Takahashi's objective this time is 400 points or more. In this case, we only need to solve two 200-point problems to achieve the objective.\n\nSample Input 4\n\n5 25000\n20 1000\n40 1000\n50 1000\n30 1000\n1 1000\n\nSample Output 4\n\n66\n\nThere is only one 500-point problem, but the perfect bonus can be earned even in such a case.", "sample_input": "2 700\n3 500\n5 800\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03290", "source_text": "Score : 300 points\n\nProblem Statement\n\nA programming competition site AtCode provides algorithmic problems.\nEach problem is allocated a score based on its difficulty.\nCurrently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points.\nThese p_1 + … + p_D problems are all of the problems available on AtCode.\n\nA user of AtCode has a value called total score.\nThe total score of a user is the sum of the following two elements:\n\nBase score: the sum of the scores of all problems solved by the user.\n\nPerfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D).\n\nTakahashi, who is the new user of AtCode, has not solved any problem.\nHis objective is to have a total score of G or more points.\nAt least how many problems does he need to solve for this objective?\n\nConstraints\n\n1 ≤ D ≤ 10\n\n1 ≤ p_i ≤ 100\n\n100 ≤ c_i ≤ 10^6\n\n100 ≤ G\n\nAll values in input are integers.\n\nc_i and G are all multiples of 100.\n\nIt is possible to have a total score of G or more points.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD G\np_1 c_1\n:\np_D c_D\n\nOutput\n\nPrint the minimum number of problems that needs to be solved in order to have a total score of G or more points. Note that this objective is always achievable (see Constraints).\n\nSample Input 1\n\n2 700\n3 500\n5 800\n\nSample Output 1\n\n3\n\nIn this case, there are three problems each with 100 points and five problems each with 200 points. The perfect bonus for solving all the 100-point problems is 500 points, and the perfect bonus for solving all the 200-point problems is 800 points. Takahashi's objective is to have a total score of 700 points or more.\n\nOne way to achieve this objective is to solve four 200-point problems and earn a base score of 800 points. However, if we solve three 100-point problems, we can earn the perfect bonus of 500 points in addition to the base score of 300 points, for a total score of 800 points, and we can achieve the objective with fewer problems.\n\nSample Input 2\n\n2 2000\n3 500\n5 800\n\nSample Output 2\n\n7\n\nThis case is similar to Sample Input 1, but the Takahashi's objective this time is 2000 points or more. In this case, we inevitably need to solve all five 200-point problems, and by solving two 100-point problems additionally we have the total score of 2000 points.\n\nSample Input 3\n\n2 400\n3 500\n5 800\n\nSample Output 3\n\n2\n\nThis case is again similar to Sample Input 1, but the Takahashi's objective this time is 400 points or more. In this case, we only need to solve two 200-point problems to achieve the objective.\n\nSample Input 4\n\n5 25000\n20 1000\n40 1000\n50 1000\n30 1000\n1 1000\n\nSample Output 4\n\n66\n\nThere is only one 500-point problem, but the perfect bonus can be earned even in such a case.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 860, "cpu_time_ms": 1026, "memory_kb": 114556}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s543099317", "group_id": "codeNet:p03292", "input_text": "import scala.io.StdIn._\nimport scala.math._\nobject Main extends App{\n val sc = new java.util.Scanner(System.in)\n val a,b,c = sc.nextInt\n if(a lcm(a, b)) - 1L\n val r = A.foldLeft(0L)((b, n) => b + LCM % n)\n println(r)\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1576815680, "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/s191268812.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s191268812", "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)(sc.nextLong())\n\n def gcd(a: Long, b: Long): Long =\n if (a % b == 0L) b\n else gcd(b, a % b)\n\n def lcm(a: Long, b: Long): Long =\n a * (b / gcd(a, b))\n\n val LCM = A.reduce((a, b) => lcm(a, b)) - 1L\n val r = A.foldLeft(0L)((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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 468, "memory_kb": 29576}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s240106162", "group_id": "codeNet:p03295", "input_text": "object Main extends App {\n val Array(n, m) = io.StdIn.readLine().split(' ').map(_.toInt)\n val against = (for(_ <- 0 until m) yield\n io.StdIn.readLine().split(' ').map(_.toInt) match {\n case Array(a, b) => (a-1, b-1)\n }).sortWith{case (x, y) => x._2 < y._2}\n\n var end = 0\n var count = 0\n for ((a,b) <- against) {\n if (end <= a) {\n end = b\n count += 1\n }\n }\n\n println(count)\n}", "language": "Scala", "metadata": {"date": 1576695524, "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/s240106162.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s240106162", "user_id": "u269739894"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main extends App {\n val Array(n, m) = io.StdIn.readLine().split(' ').map(_.toInt)\n val against = (for(_ <- 0 until m) yield\n io.StdIn.readLine().split(' ').map(_.toInt) match {\n case Array(a, b) => (a-1, b-1)\n }).sortWith{case (x, y) => x._2 < y._2}\n\n var end = 0\n var count = 0\n for ((a,b) <- against) {\n if (end <= a) {\n end = b\n count += 1\n }\n }\n\n println(count)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N islands lining up from west to east, connected by N-1 bridges.\n\nThe i-th bridge connects the i-th island from the west and the (i+1)-th island from the west.\n\nOne day, disputes took place between some islands, and there were M requests from the inhabitants of the islands:\n\nRequest i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible.\n\nYou decided to remove some bridges to meet all these M requests.\n\nFind the minimum number of bridges that must be removed.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq a_i < b_i \\leq N\n\nAll pairs (a_i, b_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nOutput\n\nPrint the minimum number of bridges that must be removed.\n\nSample Input 1\n\n5 2\n1 4\n2 5\n\nSample Output 1\n\n1\n\nThe requests can be met by removing the bridge connecting the second and third islands from the west.\n\nSample Input 2\n\n9 5\n1 8\n2 7\n3 5\n4 6\n7 9\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 10\n1 2\n1 3\n1 4\n1 5\n2 3\n2 4\n2 5\n3 4\n3 5\n4 5\n\nSample Output 3\n\n4", "sample_input": "5 2\n1 4\n2 5\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03295", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N islands lining up from west to east, connected by N-1 bridges.\n\nThe i-th bridge connects the i-th island from the west and the (i+1)-th island from the west.\n\nOne day, disputes took place between some islands, and there were M requests from the inhabitants of the islands:\n\nRequest i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible.\n\nYou decided to remove some bridges to meet all these M requests.\n\nFind the minimum number of bridges that must be removed.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq a_i < b_i \\leq N\n\nAll pairs (a_i, b_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nOutput\n\nPrint the minimum number of bridges that must be removed.\n\nSample Input 1\n\n5 2\n1 4\n2 5\n\nSample Output 1\n\n1\n\nThe requests can be met by removing the bridge connecting the second and third islands from the west.\n\nSample Input 2\n\n9 5\n1 8\n2 7\n3 5\n4 6\n7 9\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 10\n1 2\n1 3\n1 4\n1 5\n2 3\n2 4\n2 5\n3 4\n3 5\n4 5\n\nSample Output 3\n\n4", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 408, "cpu_time_ms": 1312, "memory_kb": 64496}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s799862575", "group_id": "codeNet:p03295", "input_text": "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\nobject Main extends App {\n def func(routes:Array[Array[Int]]):Int = {\n if (routes.isEmpty){\n 0\n } else {\n val removeBridge = routes.flatten.distinct.map(r=>{\n (r,routes.count(rr=>rr.contains(r)))\n }).maxBy(_._2)._1\n func(routes.filter(!_.contains(removeBridge)))+1\n }\n }\n\n val n = Scanner.nextInt()\n val m = Scanner.nextInt()\n val ab = Array.fill(m,2)(Scanner.nextInt())\n val routes = ab.map(abi=>{\n (abi(0) until abi(1)).toArray\n })\n println(func(routes))\n}", "language": "Scala", "metadata": {"date": 1532224839, "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/s799862575.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s799862575", "user_id": "u387147818"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "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\nobject Main extends App {\n def func(routes:Array[Array[Int]]):Int = {\n if (routes.isEmpty){\n 0\n } else {\n val removeBridge = routes.flatten.distinct.map(r=>{\n (r,routes.count(rr=>rr.contains(r)))\n }).maxBy(_._2)._1\n func(routes.filter(!_.contains(removeBridge)))+1\n }\n }\n\n val n = Scanner.nextInt()\n val m = Scanner.nextInt()\n val ab = Array.fill(m,2)(Scanner.nextInt())\n val routes = ab.map(abi=>{\n (abi(0) until abi(1)).toArray\n })\n println(func(routes))\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N islands lining up from west to east, connected by N-1 bridges.\n\nThe i-th bridge connects the i-th island from the west and the (i+1)-th island from the west.\n\nOne day, disputes took place between some islands, and there were M requests from the inhabitants of the islands:\n\nRequest i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible.\n\nYou decided to remove some bridges to meet all these M requests.\n\nFind the minimum number of bridges that must be removed.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq a_i < b_i \\leq N\n\nAll pairs (a_i, b_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nOutput\n\nPrint the minimum number of bridges that must be removed.\n\nSample Input 1\n\n5 2\n1 4\n2 5\n\nSample Output 1\n\n1\n\nThe requests can be met by removing the bridge connecting the second and third islands from the west.\n\nSample Input 2\n\n9 5\n1 8\n2 7\n3 5\n4 6\n7 9\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 10\n1 2\n1 3\n1 4\n1 5\n2 3\n2 4\n2 5\n3 4\n3 5\n4 5\n\nSample Output 3\n\n4", "sample_input": "5 2\n1 4\n2 5\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03295", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N islands lining up from west to east, connected by N-1 bridges.\n\nThe i-th bridge connects the i-th island from the west and the (i+1)-th island from the west.\n\nOne day, disputes took place between some islands, and there were M requests from the inhabitants of the islands:\n\nRequest i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible.\n\nYou decided to remove some bridges to meet all these M requests.\n\nFind the minimum number of bridges that must be removed.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq a_i < b_i \\leq N\n\nAll pairs (a_i, b_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nOutput\n\nPrint the minimum number of bridges that must be removed.\n\nSample Input 1\n\n5 2\n1 4\n2 5\n\nSample Output 1\n\n1\n\nThe requests can be met by removing the bridge connecting the second and third islands from the west.\n\nSample Input 2\n\n9 5\n1 8\n2 7\n3 5\n4 6\n7 9\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 10\n1 2\n1 3\n1 4\n1 5\n2 3\n2 4\n2 5\n3 4\n3 5\n4 5\n\nSample Output 3\n\n4", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1716, "cpu_time_ms": 2112, "memory_kb": 298192}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s405650227", "group_id": "codeNet:p03305", "input_text": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\nimport scala.collection.mutable.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, s, t = in.next().toInt\n\n val graphA = Array.fill[List[(Int, Int)]](n+1)(Nil)\n val graphB = Array.fill[List[(Int, Int)]](n+1)(Nil)\n\n for(_ <- 1 to m) {\n val u, v, a, b = in.next().toInt\n graphA(u) = (v, a) :: graphA(u)\n graphA(v) = (u, a) :: graphA(v)\n graphB(u) = (v, b) :: graphB(u)\n graphB(v) = (u, b) :: graphB(v)\n }\n\n\n // fro から to への最短距離(v は頂点数)\n def dijkstra(from: Int, to: Int, v: Int, edge: Array[List[(Int, Int)]]): Array[Long] = {\n val MAX = Long.MaxValue\n\n val dist = Array.fill(v+1)(MAX) // fro からの距離を格納する\n val check = new Array[Boolean](v+1) // すでにその頂点からを調べたかのフラグ\n\n dist(from) = 0\n\n val pq = new PriorityQueue[(Long, Int)] // (-cost, node) queue\n pq.enqueue((-0, from))\n\n // 頂点は v 個あるので、v 周する\n for(_ <- 0 until v) {\n // 調べ済みでない頂点のうち、最も近い頂点を now に入れる\n var nowNode = -1 // このターンにフォーカスするノード\n\n breakable {\n while(true) {\n nowNode = pq.dequeue._2 // 最小コストから貪欲に取っていく\n if(!check(nowNode)){ // まだチェックされていないノードだったら決定\n check(nowNode) = true\n break\n }\n }\n }\n\n // その頂点からたどり着ける頂点の情報を更新する\n for((nextNode, cost) <- edge(nowNode)) {\n val nextDist = dist(nowNode) + cost\n if(nextDist < dist(nextNode)){ // 既存の通路より近いなら更新\n dist(nextNode) = nextDist\n pq.enqueue((-nextDist, nextNode))\n }\n }\n }\n\n dist\n }\n\n val init = 1e15.toLong\n\n val dpA = dijkstra(s, t, n, graphA)\n val dpB = dijkstra(t, s, n, graphB)\n\n val ans = new Array[Long](n+1)\n ans(n) = 0L\n\n for(i <- (0 until n).reverse) {\n val now = init - (dpA(i+1) + dpB(i+1))\n ans(i) = now max ans(i+1)\n }\n\n for(i <- 0 until n) {\n pw.println(ans(i))\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\n", "language": "Scala", "metadata": {"date": 1531022378, "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/s405650227.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s405650227", "user_id": "u098968285"}, "prompt_components": {"gold_output": "999999999999998\n999999999999989\n999999999999979\n999999999999897\n", "input_to_evaluate": "import java.io._\nimport java.util.StringTokenizer\nimport scala.util.control.Breaks.{breakable,break}\nimport scala.collection.mutable.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, s, t = in.next().toInt\n\n val graphA = Array.fill[List[(Int, Int)]](n+1)(Nil)\n val graphB = Array.fill[List[(Int, Int)]](n+1)(Nil)\n\n for(_ <- 1 to m) {\n val u, v, a, b = in.next().toInt\n graphA(u) = (v, a) :: graphA(u)\n graphA(v) = (u, a) :: graphA(v)\n graphB(u) = (v, b) :: graphB(u)\n graphB(v) = (u, b) :: graphB(v)\n }\n\n\n // fro から to への最短距離(v は頂点数)\n def dijkstra(from: Int, to: Int, v: Int, edge: Array[List[(Int, Int)]]): Array[Long] = {\n val MAX = Long.MaxValue\n\n val dist = Array.fill(v+1)(MAX) // fro からの距離を格納する\n val check = new Array[Boolean](v+1) // すでにその頂点からを調べたかのフラグ\n\n dist(from) = 0\n\n val pq = new PriorityQueue[(Long, Int)] // (-cost, node) queue\n pq.enqueue((-0, from))\n\n // 頂点は v 個あるので、v 周する\n for(_ <- 0 until v) {\n // 調べ済みでない頂点のうち、最も近い頂点を now に入れる\n var nowNode = -1 // このターンにフォーカスするノード\n\n breakable {\n while(true) {\n nowNode = pq.dequeue._2 // 最小コストから貪欲に取っていく\n if(!check(nowNode)){ // まだチェックされていないノードだったら決定\n check(nowNode) = true\n break\n }\n }\n }\n\n // その頂点からたどり着ける頂点の情報を更新する\n for((nextNode, cost) <- edge(nowNode)) {\n val nextDist = dist(nowNode) + cost\n if(nextDist < dist(nextNode)){ // 既存の通路より近いなら更新\n dist(nextNode) = nextDist\n pq.enqueue((-nextDist, nextNode))\n }\n }\n }\n\n dist\n }\n\n val init = 1e15.toLong\n\n val dpA = dijkstra(s, t, n, graphA)\n val dpB = dijkstra(t, s, n, graphB)\n\n val ans = new Array[Long](n+1)\n ans(n) = 0L\n\n for(i <- (0 until n).reverse) {\n val now = init - (dpA(i+1) + dpB(i+1))\n ans(i) = now max ans(i+1)\n }\n\n for(i <- 0 until n) {\n pw.println(ans(i))\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\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2679, "cpu_time_ms": 1806, "memory_kb": 142656}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s344436705", "group_id": "codeNet:p03307", "input_text": "object Main extends App {\n val in = readLine.toInt\n println(if(in % 2 == 0) in else in * 2)\n}", "language": "Scala", "metadata": {"date": 1567987541, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03307.html", "problem_id": "p03307", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03307/input.txt", "sample_output_relpath": "derived/input_output/data/p03307/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03307/Scala/s344436705.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s344436705", "user_id": "u190068878"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "object Main extends App {\n val in = readLine.toInt\n println(if(in % 2 == 0) in else in * 2)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a positive integer N.\nFind the minimum positive integer divisible by both 2 and N.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum positive integer divisible by both 2 and N.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n6\n\n6 is divisible by both 2 and 3.\nAlso, there is no positive integer less than 6 that is divisible by both 2 and 3.\nThus, the answer is 6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\n1999999998", "sample_input": "3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03307", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a positive integer N.\nFind the minimum positive integer divisible by both 2 and N.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum positive integer divisible by both 2 and N.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n6\n\n6 is divisible by both 2 and 3.\nAlso, there is no positive integer less than 6 that is divisible by both 2 and 3.\nThus, the answer is 6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n10\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\n1999999998", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 95, "cpu_time_ms": 331, "memory_kb": 27192}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s714090078", "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 c = (0 until n).map { i =>\n a(i) - (i+1) \n }.sorted\n val b = c(n/2)\n\n val ans = a./:(0L, 1L){ (elm, ai) =>\n val (acc, idx) = elm\n (acc + (ai - (b + idx)).abs, idx + 1L)\n }._1\n\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1569120208, "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/s714090078.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s714090078", "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 c = (0 until n).map { i =>\n a(i) - (i+1) \n }.sorted\n val b = c(n/2)\n\n val ans = a./:(0L, 1L){ (elm, ai) =>\n val (acc, idx) = elm\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 892, "memory_kb": 63952}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s372053934", "group_id": "codeNet:p03309", "input_text": "object Main extends App {\n\tval n = scala.io.StdIn.readInt\n\tvar a = scala.io.StdIn.readLine.split(\" \").map(_.toLong)\n\n\tfor(i<-0 until n){\n\t\ta(i) -= i.toLong + 1L\n\t}\n\n//\tprintln(a.mkString(\" \"))\n\n\ta = a.sorted\n\n\tvar ans = 0L\n\n\tval t = n/2\n\n\tif(n%2 == 1){\n\t\tval b = a(t)\n\n\t\tfor(x<-a){\n\t\t\tans += math.abs(x - b)\n\t\t}\n\t\tprintln(ans)\n\n\t}else{\n\t\tval b1 = a(t)\n\t\tval b2 = a(t-1)\n\n\t\tvar ans1 = 0L\n\n\t\tfor(x<-a){\n\t\t\tans += math.abs(x - b1)\n\t\t\tans1 += math.abs(x - b2)\n\t\t}\n\t\tprintln(math.min(ans, ans1))\n\t}\n}\n", "language": "Scala", "metadata": {"date": 1530494287, "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/s372053934.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s372053934", "user_id": "u675876401"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n\tval n = scala.io.StdIn.readInt\n\tvar a = scala.io.StdIn.readLine.split(\" \").map(_.toLong)\n\n\tfor(i<-0 until n){\n\t\ta(i) -= i.toLong + 1L\n\t}\n\n//\tprintln(a.mkString(\" \"))\n\n\ta = a.sorted\n\n\tvar ans = 0L\n\n\tval t = n/2\n\n\tif(n%2 == 1){\n\t\tval b = a(t)\n\n\t\tfor(x<-a){\n\t\t\tans += math.abs(x - b)\n\t\t}\n\t\tprintln(ans)\n\n\t}else{\n\t\tval b1 = a(t)\n\t\tval b2 = a(t-1)\n\n\t\tvar ans1 = 0L\n\n\t\tfor(x<-a){\n\t\t\tans += math.abs(x - b1)\n\t\t\tans1 += math.abs(x - b2)\n\t\t}\n\t\tprintln(math.min(ans, ans1))\n\t}\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke has an integer sequence A of length N.\n\nHe will freely choose an integer b.\nHere, he will get sad if A_i and b+i are far from each other.\nMore specifically, the sadness of Snuke is calculated as follows:\n\nabs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))\n\nHere, abs(x) is a function that returns the absolute value of x.\n\nFind the minimum possible sadness of Snuke.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible sadness of Snuke.\n\nSample Input 1\n\n5\n2 2 3 5 5\n\nSample Output 1\n\n2\n\nIf we choose b=0, the sadness of Snuke would be abs(2-(0+1))+abs(2-(0+2))+abs(3-(0+3))+abs(5-(0+4))+abs(5-(0+5))=2.\nAny choice of b does not make the sadness of Snuke less than 2, so the answer is 2.\n\nSample Input 2\n\n9\n1 2 3 4 5 6 7 8 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n6\n6 5 4 3 2 1\n\nSample Output 3\n\n18\n\nSample Input 4\n\n7\n1 1 1 1 2 3 4\n\nSample Output 4\n\n6", "sample_input": "5\n2 2 3 5 5\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03309", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke has an integer sequence A of length N.\n\nHe will freely choose an integer b.\nHere, he will get sad if A_i and b+i are far from each other.\nMore specifically, the sadness of Snuke is calculated as follows:\n\nabs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))\n\nHere, abs(x) is a function that returns the absolute value of x.\n\nFind the minimum possible sadness of Snuke.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible sadness of Snuke.\n\nSample Input 1\n\n5\n2 2 3 5 5\n\nSample Output 1\n\n2\n\nIf we choose b=0, the sadness of Snuke would be abs(2-(0+1))+abs(2-(0+2))+abs(3-(0+3))+abs(5-(0+4))+abs(5-(0+5))=2.\nAny choice of b does not make the sadness of Snuke less than 2, so the answer is 2.\n\nSample Input 2\n\n9\n1 2 3 4 5 6 7 8 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n6\n6 5 4 3 2 1\n\nSample Output 3\n\n18\n\nSample Input 4\n\n7\n1 1 1 1 2 3 4\n\nSample Output 4\n\n6", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 496, "cpu_time_ms": 802, "memory_kb": 58844}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s141667063", "group_id": "codeNet:p03313", "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](1 << N)\n for (i <- 0 to (1 << N) - 1)\n A(i) = in.next().toInt\n\n\n //\n val dp = Array.fill[(Int, Int)](1 << N)((-1, -1))\n dp(0) = (0, 0)\n dp(1) = (0, 1)\n var ans = A(0) + A(1)\n println(ans)\n\n\n import scala.collection.mutable.PriorityQueue\n\n for (i <- 2 to (1 << N) - 1) {\n val pq = new PriorityQueue[(Int, Int)]\n pq.enqueue(A(i) -> i)\n\n for (k <- 0 to N) {\n val hoge = i & 1 << k\n if(hoge != 0) {\n val now = i ^ hoge\n val (a, b) = dp(now)\n pq.enqueue(A(a) -> a)\n pq.enqueue(A(b) -> b)\n }\n }\n\n var lst: List[Int] = Nil\n while(lst.length < 2) {\n val (_, ind) = pq.dequeue\n if(!lst.contains(ind))\n lst = ind :: lst\n }\n\n dp(i) = (lst(0), lst(1))\n ans = Math.max(ans, lst.map(ind => A(ind)).sum)\n println(ans)\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\n", "language": "Scala", "metadata": {"date": 1550633521, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03313.html", "problem_id": "p03313", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03313/input.txt", "sample_output_relpath": "derived/input_output/data/p03313/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03313/Scala/s141667063.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s141667063", "user_id": "u098968285"}, "prompt_components": {"gold_output": "3\n4\n5\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](1 << N)\n for (i <- 0 to (1 << N) - 1)\n A(i) = in.next().toInt\n\n\n //\n val dp = Array.fill[(Int, Int)](1 << N)((-1, -1))\n dp(0) = (0, 0)\n dp(1) = (0, 1)\n var ans = A(0) + A(1)\n println(ans)\n\n\n import scala.collection.mutable.PriorityQueue\n\n for (i <- 2 to (1 << N) - 1) {\n val pq = new PriorityQueue[(Int, Int)]\n pq.enqueue(A(i) -> i)\n\n for (k <- 0 to N) {\n val hoge = i & 1 << k\n if(hoge != 0) {\n val now = i ^ hoge\n val (a, b) = dp(now)\n pq.enqueue(A(a) -> a)\n pq.enqueue(A(b) -> b)\n }\n }\n\n var lst: List[Int] = Nil\n while(lst.length < 2) {\n val (_, ind) = pq.dequeue\n if(!lst.contains(ind))\n lst = ind :: lst\n }\n\n dp(i) = (lst(0), lst(1))\n ans = Math.max(ans, lst.map(ind => A(ind)).sum)\n println(ans)\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\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nThere is an integer sequence of length 2^N: A_0, A_1, ..., A_{2^N-1}. (Note that the sequence is 0-indexed.)\n\nFor every integer K satisfying 1 \\leq K \\leq 2^N-1, solve the following problem:\n\nLet i and j be integers. Find the maximum value of A_i + A_j where 0 \\leq i < j \\leq 2^N-1 and (i or j) \\leq K.\nHere, or denotes the bitwise OR.\n\nConstraints\n\n1 \\leq N \\leq 18\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_0 A_1 ... A_{2^N-1}\n\nOutput\n\nPrint 2^N-1 lines.\nIn the i-th line, print the answer of the problem above for K=i.\n\nSample Input 1\n\n2\n1 2 3 1\n\nSample Output 1\n\n3\n4\n5\n\nFor K=1, the only possible pair of i and j is (i,j)=(0,1), so the answer is A_0+A_1=1+2=3.\n\nFor K=2, the possible pairs of i and j are (i,j)=(0,1),(0,2).\nWhen (i,j)=(0,2), A_i+A_j=1+3=4. This is the maximum value, so the answer is 4.\n\nFor K=3, the possible pairs of i and j are (i,j)=(0,1),(0,2),(0,3),(1,2),(1,3),(2,3) .\nWhen (i,j)=(1,2), A_i+A_j=2+3=5. This is the maximum value, so the answer is 5.\n\nSample Input 2\n\n3\n10 71 84 33 6 47 23 25\n\nSample Output 2\n\n81\n94\n155\n155\n155\n155\n155\n\nSample Input 3\n\n4\n75 26 45 72 81 47 97 97 2 2 25 82 84 17 56 32\n\nSample Output 3\n\n101\n120\n147\n156\n156\n178\n194\n194\n194\n194\n194\n194\n194\n194\n194", "sample_input": "2\n1 2 3 1\n"}, "reference_outputs": ["3\n4\n5\n"], "source_document_id": "p03313", "source_text": "Score : 700 points\n\nProblem Statement\n\nThere is an integer sequence of length 2^N: A_0, A_1, ..., A_{2^N-1}. (Note that the sequence is 0-indexed.)\n\nFor every integer K satisfying 1 \\leq K \\leq 2^N-1, solve the following problem:\n\nLet i and j be integers. Find the maximum value of A_i + A_j where 0 \\leq i < j \\leq 2^N-1 and (i or j) \\leq K.\nHere, or denotes the bitwise OR.\n\nConstraints\n\n1 \\leq N \\leq 18\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_0 A_1 ... A_{2^N-1}\n\nOutput\n\nPrint 2^N-1 lines.\nIn the i-th line, print the answer of the problem above for K=i.\n\nSample Input 1\n\n2\n1 2 3 1\n\nSample Output 1\n\n3\n4\n5\n\nFor K=1, the only possible pair of i and j is (i,j)=(0,1), so the answer is A_0+A_1=1+2=3.\n\nFor K=2, the possible pairs of i and j are (i,j)=(0,1),(0,2).\nWhen (i,j)=(0,2), A_i+A_j=1+3=4. This is the maximum value, so the answer is 4.\n\nFor K=3, the possible pairs of i and j are (i,j)=(0,1),(0,2),(0,3),(1,2),(1,3),(2,3) .\nWhen (i,j)=(1,2), A_i+A_j=2+3=5. This is the maximum value, so the answer is 5.\n\nSample Input 2\n\n3\n10 71 84 33 6 47 23 25\n\nSample Output 2\n\n81\n94\n155\n155\n155\n155\n155\n\nSample Input 3\n\n4\n75 26 45 72 81 47 97 97 2 2 25 82 84 17 56 32\n\nSample Output 3\n\n101\n120\n147\n156\n156\n178\n194\n194\n194\n194\n194\n194\n194\n194\n194", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1428, "cpu_time_ms": 2111, "memory_kb": 134132}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s321250992", "group_id": "codeNet:p03315", "input_text": "object Main extends App {\n import scala.io.StdIn.readLine\n \n val s=readLine\n var ans=0\n for(c <- s)if(c=='+')ans+=1 else ans-=1\n println(s\"${ans}\")\n}", "language": "Scala", "metadata": {"date": 1551332877, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03315.html", "problem_id": "p03315", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03315/input.txt", "sample_output_relpath": "derived/input_output/data/p03315/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03315/Scala/s321250992.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s321250992", "user_id": "u604693716"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n import scala.io.StdIn.readLine\n \n val s=readLine\n var ans=0\n for(c <- s)if(c=='+')ans+=1 else ans-=1\n println(s\"${ans}\")\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is always an integer in Takahashi's mind.\n\nInitially, the integer in Takahashi's mind is 0. Takahashi is now going to eat four symbols, each of which is + or -. When he eats +, the integer in his mind increases by 1; when he eats -, the integer in his mind decreases by 1.\n\nThe symbols Takahashi is going to eat are given to you as a string S. The i-th character in S is the i-th symbol for him to eat.\n\nFind the integer in Takahashi's mind after he eats all the symbols.\n\nConstraints\n\nThe length of S is 4.\n\nEach character in S is + or -.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the integer in Takahashi's mind after he eats all the symbols.\n\nSample Input 1\n\n+-++\n\nSample Output 1\n\n2\n\nInitially, the integer in Takahashi's mind is 0.\n\nThe first integer for him to eat is +. After eating it, the integer in his mind becomes 1.\n\nThe second integer to eat is -. After eating it, the integer in his mind becomes 0.\n\nThe third integer to eat is +. After eating it, the integer in his mind becomes 1.\n\nThe fourth integer to eat is +. After eating it, the integer in his mind becomes 2.\n\nThus, the integer in Takahashi's mind after he eats all the symbols is 2.\n\nSample Input 2\n\n-+--\n\nSample Output 2\n\n-2\n\nSample Input 3\n\n----\n\nSample Output 3\n\n-4", "sample_input": "+-++\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03315", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is always an integer in Takahashi's mind.\n\nInitially, the integer in Takahashi's mind is 0. Takahashi is now going to eat four symbols, each of which is + or -. When he eats +, the integer in his mind increases by 1; when he eats -, the integer in his mind decreases by 1.\n\nThe symbols Takahashi is going to eat are given to you as a string S. The i-th character in S is the i-th symbol for him to eat.\n\nFind the integer in Takahashi's mind after he eats all the symbols.\n\nConstraints\n\nThe length of S is 4.\n\nEach character in S is + or -.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the integer in Takahashi's mind after he eats all the symbols.\n\nSample Input 1\n\n+-++\n\nSample Output 1\n\n2\n\nInitially, the integer in Takahashi's mind is 0.\n\nThe first integer for him to eat is +. After eating it, the integer in his mind becomes 1.\n\nThe second integer to eat is -. After eating it, the integer in his mind becomes 0.\n\nThe third integer to eat is +. After eating it, the integer in his mind becomes 1.\n\nThe fourth integer to eat is +. After eating it, the integer in his mind becomes 2.\n\nThus, the integer in Takahashi's mind after he eats all the symbols is 2.\n\nSample Input 2\n\n-+--\n\nSample Output 2\n\n-2\n\nSample Input 3\n\n----\n\nSample Output 3\n\n-4", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 155, "cpu_time_ms": 331, "memory_kb": 25416}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s527652549", "group_id": "codeNet:p03316", "input_text": "object Main extends App {\n import scala.io.StdIn\n\n val input = StdIn.readLine()\n val sum = input.split(\"\").map(_.toInt).sum\n if (input.toInt / sum == 0) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}\n", "language": "Scala", "metadata": {"date": 1599681414, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/s527652549.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s527652549", "user_id": "u388106329"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n import scala.io.StdIn\n\n val input = StdIn.readLine()\n val sum = input.split(\"\").map(_.toInt).sum\n if (input.toInt / sum == 0) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 215, "cpu_time_ms": 489, "memory_kb": 54724}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s383257771", "group_id": "codeNet:p03316", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val num = scala.io.StdIn.readInt\n val nums = num.toString.split(\"\")\n var snum = 0\n\n nums.foreach({ i =>\n snum += i.toInt\n })\n\n if(num%snum == 0) println(\"Yes\")\n else println(\"No\")\n }\n}", "language": "Scala", "metadata": {"date": 1568817676, "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/s383257771.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s383257771", "user_id": "u888177577"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val num = scala.io.StdIn.readInt\n val nums = num.toString.split(\"\")\n var snum = 0\n\n nums.foreach({ i =>\n snum += i.toInt\n })\n\n if(num%snum == 0) println(\"Yes\")\n else println(\"No\")\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 282, "cpu_time_ms": 332, "memory_kb": 25536}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s653173718", "group_id": "codeNet:p03316", "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 def solve(sc: => Scanner): Unit = {\n val N = sc.nextLong\n println(if (N % recursive(N) == 0) (\"Yes\") else (\"No\"))\n }\n\n def recursive(N: Long): Long = {\n if (N == 0) (0) else (recursive(N / 10) + N % 10)\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": 1529983175, "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/s653173718.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s653173718", "user_id": "u779353743"}, "prompt_components": {"gold_output": "Yes\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 def solve(sc: => Scanner): Unit = {\n val N = sc.nextLong\n println(if (N % recursive(N) == 0) (\"Yes\") else (\"No\"))\n }\n\n def recursive(N: Long): Long = {\n if (N == 0) (0) else (recursive(N / 10) + N % 10)\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 : 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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3648, "cpu_time_ms": 336, "memory_kb": 27724}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s523122039", "group_id": "codeNet:p03319", "input_text": "\nimport java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val (n, k) = (sc.nextInt, sc.nextInt)\n val li = (1 to n).map(_ => sc.nextInt)\n\n println(1 + (n - 2) / (k - 1))\n}\n", "language": "Scala", "metadata": {"date": 1530143439, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03319.html", "problem_id": "p03319", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03319/input.txt", "sample_output_relpath": "derived/input_output/data/p03319/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03319/Scala/s523122039.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s523122039", "user_id": "u726872801"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "\nimport java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val (n, k) = (sc.nextInt, sc.nextInt)\n val li = (1 to n).map(_ => sc.nextInt)\n\n println(1 + (n - 2) / (k - 1))\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\n\nOn this sequence, Snuke can perform the following operation:\n\nChoose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.\n\nSnuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.\nFind the minimum number of operations required.\nIt can be proved that, Under the constraints of this problem, this objective is always achievable.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 100000\n\nA_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 3\n2 3 1 4\n\nSample Output 1\n\n2\n\nOne optimal strategy is as follows:\n\nIn the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.\n\nIn the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.\n\nSample Input 2\n\n3 3\n1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n8 3\n7 3 1 8 4 6 2 5\n\nSample Output 3\n\n4", "sample_input": "4 3\n2 3 1 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03319", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\n\nOn this sequence, Snuke can perform the following operation:\n\nChoose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.\n\nSnuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.\nFind the minimum number of operations required.\nIt can be proved that, Under the constraints of this problem, this objective is always achievable.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 100000\n\nA_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 3\n2 3 1 4\n\nSample Output 1\n\n2\n\nOne optimal strategy is as follows:\n\nIn the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.\n\nIn the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.\n\nSample Input 2\n\n3 3\n1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n8 3\n7 3 1 8 4 6 2 5\n\nSample Output 3\n\n4", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 689, "memory_kb": 52640}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s452423688", "group_id": "codeNet:p03323", "input_text": "object Main extends App {\n val E869120, square1001 = io.StdIn.readLine().split(\" \")\n println(if(E869120.toString.toInt <= 8 && square1001.toString.toInt <= 8) \"Yay!\" else \":(\")\n}", "language": "Scala", "metadata": {"date": 1576074722, "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/s452423688.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s452423688", "user_id": "u093124031"}, "prompt_components": {"gold_output": "Yay!\n", "input_to_evaluate": "object Main extends App {\n val E869120, square1001 = io.StdIn.readLine().split(\" \")\n println(if(E869120.toString.toInt <= 8 && square1001.toString.toInt <= 8) \"Yay!\" else \":(\")\n}", "problem_context": "Score: 100 points\n\nProblem Statement\n\nE869120's and square1001's 16-th birthday is coming soon.\n\nTakahashi from AtCoder Kingdom gave them a round cake cut into 16 equal fan-shaped pieces.\n\nE869120 and square1001 were just about to eat A and B of those pieces, respectively,\n\nwhen they found a note attached to the cake saying that \"the same person should not take two adjacent pieces of cake\".\n\nCan both of them obey the instruction in the note and take desired numbers of pieces of cake?\n\nConstraints\n\nA and B are integers between 1 and 16 (inclusive).\n\nA+B is at most 16.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf both E869120 and square1001 can obey the instruction in the note and take desired numbers of pieces of cake, print Yay!; otherwise, print :(.\n\nSample Input 1\n\n5 4\n\nSample Output 1\n\nYay!\n\nBoth of them can take desired number of pieces as follows:\n\nSample Input 2\n\n8 8\n\nSample Output 2\n\nYay!\n\nBoth of them can take desired number of pieces as follows:\n\nSample Input 3\n\n11 4\n\nSample Output 3\n\n:(\n\nIn this case, there is no way for them to take desired number of pieces, unfortunately.", "sample_input": "5 4\n"}, "reference_outputs": ["Yay!\n"], "source_document_id": "p03323", "source_text": "Score: 100 points\n\nProblem Statement\n\nE869120's and square1001's 16-th birthday is coming soon.\n\nTakahashi from AtCoder Kingdom gave them a round cake cut into 16 equal fan-shaped pieces.\n\nE869120 and square1001 were just about to eat A and B of those pieces, respectively,\n\nwhen they found a note attached to the cake saying that \"the same person should not take two adjacent pieces of cake\".\n\nCan both of them obey the instruction in the note and take desired numbers of pieces of cake?\n\nConstraints\n\nA and B are integers between 1 and 16 (inclusive).\n\nA+B is at most 16.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf both E869120 and square1001 can obey the instruction in the note and take desired numbers of pieces of cake, print Yay!; otherwise, print :(.\n\nSample Input 1\n\n5 4\n\nSample Output 1\n\nYay!\n\nBoth of them can take desired number of pieces as follows:\n\nSample Input 2\n\n8 8\n\nSample Output 2\n\nYay!\n\nBoth of them can take desired number of pieces as follows:\n\nSample Input 3\n\n11 4\n\nSample Output 3\n\n:(\n\nIn this case, there is no way for them to take desired number of pieces, unfortunately.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 180, "cpu_time_ms": 333, "memory_kb": 27324}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s488681936", "group_id": "codeNet:p03323", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val piece_of_cakes = scala.io.StdIn.readLine.split(\" \")\n if(piece_of_cakes(0).toInt <= 8 && piece_of_cakes(1).toInt <= 8) println(\"Yay!\")\n else println(\":(\")\n }\n}", "language": "Scala", "metadata": {"date": 1568752639, "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/s488681936.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s488681936", "user_id": "u888177577"}, "prompt_components": {"gold_output": "Yay!\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val piece_of_cakes = scala.io.StdIn.readLine.split(\" \")\n if(piece_of_cakes(0).toInt <= 8 && piece_of_cakes(1).toInt <= 8) println(\"Yay!\")\n else println(\":(\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 289, "cpu_time_ms": 322, "memory_kb": 25520}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s855577785", "group_id": "codeNet:p03325", "input_text": "import java.util.Scanner\n\nimport scala.annotation.tailrec\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val n = sc.nextInt()\n val a=List.fill(n)(sc.nextInt())\n println(a.map(x=>f(x)).sum)\n }\n \n def f(n:Int):Int={\n if (n%2!=0){\n 0\n }else{\n 1+f(n/2)\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1586374377, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03325.html", "problem_id": "p03325", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03325/input.txt", "sample_output_relpath": "derived/input_output/data/p03325/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03325/Scala/s855577785.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s855577785", "user_id": "u336949031"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.annotation.tailrec\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val n = sc.nextInt()\n val a=List.fill(n)(sc.nextInt())\n println(a.map(x=>f(x)).sum)\n }\n \n def f(n:Int):Int={\n if (n%2!=0){\n 0\n }else{\n 1+f(n/2)\n }\n }\n}\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nAs AtCoder Beginner Contest 100 is taking place, the office of AtCoder, Inc. is decorated with a sequence of length N, a = {a_1, a_2, a_3, ..., a_N}.\n\nSnuke, an employee, would like to play with this sequence.\n\nSpecifically, he would like to repeat the following operation as many times as possible:\n\nFor every i satisfying 1 \\leq i \\leq N, perform one of the following: \"divide a_i by 2\" and \"multiply a_i by 3\".\nHere, choosing \"multiply a_i by 3\" for every i is not allowed, and the value of a_i after the operation must be an integer.\n\nAt most how many operations can be performed?\n\nConstraints\n\nN is an integer between 1 and 10 \\ 000 (inclusive).\n\na_i is an integer between 1 and 1 \\ 000 \\ 000 \\ 000 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 a_3 ... a_N\n\nOutput\n\nPrint the maximum number of operations that Snuke can perform.\n\nSample Input 1\n\n3\n5 2 4\n\nSample Output 1\n\n3\n\nThe sequence is initially {5, 2, 4}. Three operations can be performed as follows:\n\nFirst, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {15, 6, 2}.\n\nNext, multiply a_1 by 3, divide a_2 by 2 and multiply a_3 by 3. The sequence is now {45, 3, 6}.\n\nFinally, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {135, 9, 3}.\n\nSample Input 2\n\n4\n631 577 243 199\n\nSample Output 2\n\n0\n\nNo operation can be performed since all the elements are odd. Thus, the answer is 0.\n\nSample Input 3\n\n10\n2184 2126 1721 1800 1024 2528 3360 1945 1280 1776\n\nSample Output 3\n\n39", "sample_input": "3\n5 2 4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03325", "source_text": "Score: 300 points\n\nProblem Statement\n\nAs AtCoder Beginner Contest 100 is taking place, the office of AtCoder, Inc. is decorated with a sequence of length N, a = {a_1, a_2, a_3, ..., a_N}.\n\nSnuke, an employee, would like to play with this sequence.\n\nSpecifically, he would like to repeat the following operation as many times as possible:\n\nFor every i satisfying 1 \\leq i \\leq N, perform one of the following: \"divide a_i by 2\" and \"multiply a_i by 3\".\nHere, choosing \"multiply a_i by 3\" for every i is not allowed, and the value of a_i after the operation must be an integer.\n\nAt most how many operations can be performed?\n\nConstraints\n\nN is an integer between 1 and 10 \\ 000 (inclusive).\n\na_i is an integer between 1 and 1 \\ 000 \\ 000 \\ 000 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 a_3 ... a_N\n\nOutput\n\nPrint the maximum number of operations that Snuke can perform.\n\nSample Input 1\n\n3\n5 2 4\n\nSample Output 1\n\n3\n\nThe sequence is initially {5, 2, 4}. Three operations can be performed as follows:\n\nFirst, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {15, 6, 2}.\n\nNext, multiply a_1 by 3, divide a_2 by 2 and multiply a_3 by 3. The sequence is now {45, 3, 6}.\n\nFinally, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {135, 9, 3}.\n\nSample Input 2\n\n4\n631 577 243 199\n\nSample Output 2\n\n0\n\nNo operation can be performed since all the elements are odd. Thus, the answer is 0.\n\nSample Input 3\n\n10\n2184 2126 1721 1800 1024 2528 3360 1945 1280 1776\n\nSample Output 3\n\n39", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 337, "cpu_time_ms": 636, "memory_kb": 39508}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s893417198", "group_id": "codeNet:p03326", "input_text": "object Main extends App {\n def abs(num:Long) = {\n if (num > 0){\n num\n } else {\n -num\n }\n }\n val sc = new java.util.Scanner(System.in)\n val n,m = sc.nextInt()\n val a = Array.fill(n,3)(sc.nextLong())\n val result = a.combinations(m).map(ai=>{\n val x = abs(ai.map(_(0)).sum)\n val y = abs(ai.map(_(1)).sum)\n val z = abs(ai.map(_(2)).sum)\n x+y+z\n }).max\n println(result)\n}", "language": "Scala", "metadata": {"date": 1529199728, "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/s893417198.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s893417198", "user_id": "u387147818"}, "prompt_components": {"gold_output": "56\n", "input_to_evaluate": "object Main extends App {\n def abs(num:Long) = {\n if (num > 0){\n num\n } else {\n -num\n }\n }\n val sc = new java.util.Scanner(System.in)\n val n,m = sc.nextInt()\n val a = Array.fill(n,3)(sc.nextLong())\n val result = a.combinations(m).map(ai=>{\n val x = abs(ai.map(_(0)).sum)\n val y = abs(ai.map(_(1)).sum)\n val z = abs(ai.map(_(2)).sum)\n x+y+z\n }).max\n println(result)\n}", "problem_context": "Score: 400 points\n\nProblem Statement\n\nTakahashi became a pastry chef and opened a shop La Confiserie d'ABC to celebrate AtCoder Beginner Contest 100.\n\nThe shop sells N kinds of cakes.\n\nEach kind of cake has three parameters \"beauty\", \"tastiness\" and \"popularity\". The i-th kind of cake has the beauty of x_i, the tastiness of y_i and the popularity of z_i.\n\nThese values may be zero or negative.\n\nRingo has decided to have M pieces of cakes here. He will choose the set of cakes as follows:\n\nDo not have two or more pieces of the same kind of cake.\n\nUnder the condition above, choose the set of cakes to maximize (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity).\n\nFind the maximum possible value of (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) for the set of cakes that Ringo chooses.\n\nConstraints\n\nN is an integer between 1 and 1 \\ 000 (inclusive).\n\nM is an integer between 0 and N (inclusive).\n\nx_i, y_i, z_i \\ (1 \\leq i \\leq N) are integers between -10 \\ 000 \\ 000 \\ 000 and 10 \\ 000 \\ 000 \\ 000 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nx_1 y_1 z_1\nx_2 y_2 z_2\n: :\nx_N y_N z_N\n\nOutput\n\nPrint the maximum possible value of (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) for the set of cakes that Ringo chooses.\n\nSample Input 1\n\n5 3\n3 1 4\n1 5 9\n2 6 5\n3 5 8\n9 7 9\n\nSample Output 1\n\n56\n\nConsider having the 2-nd, 4-th and 5-th kinds of cakes. The total beauty, tastiness and popularity will be as follows:\n\nBeauty: 1 + 3 + 9 = 13\n\nTastiness: 5 + 5 + 7 = 17\n\nPopularity: 9 + 8 + 9 = 26\n\nThe value (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) here is 13 + 17 + 26 = 56. This is the maximum value.\n\nSample Input 2\n\n5 3\n1 -2 3\n-4 5 -6\n7 -8 -9\n-10 11 -12\n13 -14 15\n\nSample Output 2\n\n54\n\nConsider having the 1-st, 3-rd and 5-th kinds of cakes. The total beauty, tastiness and popularity will be as follows:\n\nBeauty: 1 + 7 + 13 = 21\n\nTastiness: (-2) + (-8) + (-14) = -24\n\nPopularity: 3 + (-9) + 15 = 9\n\nThe value (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) here is 21 + 24 + 9 = 54. This is the maximum value.\n\nSample Input 3\n\n10 5\n10 -80 21\n23 8 38\n-94 28 11\n-26 -2 18\n-69 72 79\n-26 -86 -54\n-72 -50 59\n21 65 -32\n40 -94 87\n-62 18 82\n\nSample Output 3\n\n638\n\nIf we have the 3-rd, 4-th, 5-th, 7-th and 10-th kinds of cakes, the total beauty, tastiness and popularity will be -323, 66 and 249, respectively.\n\nThe value (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) here is 323 + 66 + 249 = 638. This is the maximum value.\n\nSample Input 4\n\n3 2\n2000000000 -9000000000 4000000000\n7000000000 -5000000000 3000000000\n6000000000 -1000000000 8000000000\n\nSample Output 4\n\n30000000000\n\nThe values of the beauty, tastiness and popularity of the cakes and the value to be printed may not fit into 32-bit integers.", "sample_input": "5 3\n3 1 4\n1 5 9\n2 6 5\n3 5 8\n9 7 9\n"}, "reference_outputs": ["56\n"], "source_document_id": "p03326", "source_text": "Score: 400 points\n\nProblem Statement\n\nTakahashi became a pastry chef and opened a shop La Confiserie d'ABC to celebrate AtCoder Beginner Contest 100.\n\nThe shop sells N kinds of cakes.\n\nEach kind of cake has three parameters \"beauty\", \"tastiness\" and \"popularity\". The i-th kind of cake has the beauty of x_i, the tastiness of y_i and the popularity of z_i.\n\nThese values may be zero or negative.\n\nRingo has decided to have M pieces of cakes here. He will choose the set of cakes as follows:\n\nDo not have two or more pieces of the same kind of cake.\n\nUnder the condition above, choose the set of cakes to maximize (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity).\n\nFind the maximum possible value of (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) for the set of cakes that Ringo chooses.\n\nConstraints\n\nN is an integer between 1 and 1 \\ 000 (inclusive).\n\nM is an integer between 0 and N (inclusive).\n\nx_i, y_i, z_i \\ (1 \\leq i \\leq N) are integers between -10 \\ 000 \\ 000 \\ 000 and 10 \\ 000 \\ 000 \\ 000 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nx_1 y_1 z_1\nx_2 y_2 z_2\n: :\nx_N y_N z_N\n\nOutput\n\nPrint the maximum possible value of (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) for the set of cakes that Ringo chooses.\n\nSample Input 1\n\n5 3\n3 1 4\n1 5 9\n2 6 5\n3 5 8\n9 7 9\n\nSample Output 1\n\n56\n\nConsider having the 2-nd, 4-th and 5-th kinds of cakes. The total beauty, tastiness and popularity will be as follows:\n\nBeauty: 1 + 3 + 9 = 13\n\nTastiness: 5 + 5 + 7 = 17\n\nPopularity: 9 + 8 + 9 = 26\n\nThe value (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) here is 13 + 17 + 26 = 56. This is the maximum value.\n\nSample Input 2\n\n5 3\n1 -2 3\n-4 5 -6\n7 -8 -9\n-10 11 -12\n13 -14 15\n\nSample Output 2\n\n54\n\nConsider having the 1-st, 3-rd and 5-th kinds of cakes. The total beauty, tastiness and popularity will be as follows:\n\nBeauty: 1 + 7 + 13 = 21\n\nTastiness: (-2) + (-8) + (-14) = -24\n\nPopularity: 3 + (-9) + 15 = 9\n\nThe value (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) here is 21 + 24 + 9 = 54. This is the maximum value.\n\nSample Input 3\n\n10 5\n10 -80 21\n23 8 38\n-94 28 11\n-26 -2 18\n-69 72 79\n-26 -86 -54\n-72 -50 59\n21 65 -32\n40 -94 87\n-62 18 82\n\nSample Output 3\n\n638\n\nIf we have the 3-rd, 4-th, 5-th, 7-th and 10-th kinds of cakes, the total beauty, tastiness and popularity will be -323, 66 and 249, respectively.\n\nThe value (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) here is 323 + 66 + 249 = 638. This is the maximum value.\n\nSample Input 4\n\n3 2\n2000000000 -9000000000 4000000000\n7000000000 -5000000000 3000000000\n6000000000 -1000000000 8000000000\n\nSample Output 4\n\n30000000000\n\nThe values of the beauty, tastiness and popularity of the cakes and the value to be printed may not fit into 32-bit integers.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 405, "cpu_time_ms": 2111, "memory_kb": 123536}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s504883240", "group_id": "codeNet:p03327", "input_text": "\nobject Main extends App {\n val n = scala.io.StdIn.readLine.toInt\n if(n >= 1000){\n println(\"ABD\")\n }else{\n println(\"ABC\")\n }\n}", "language": "Scala", "metadata": {"date": 1528678969, "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/s504883240.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s504883240", "user_id": "u654455149"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "\nobject Main extends App {\n val n = scala.io.StdIn.readLine.toInt\n if(n >= 1000){\n println(\"ABD\")\n }else{\n println(\"ABC\")\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nDecades have passed since the beginning of AtCoder Beginner Contest.\n\nThe contests are labeled as ABC001, ABC002, ... from the first round, but after the 999-th round ABC999, a problem occurred: how the future rounds should be labeled?\n\nIn the end, the labels for the rounds from the 1000-th to the 1998-th are decided: ABD001, ABD002, ..., ABD999.\n\nYou are given an integer N between 1 and 1998 (inclusive). Print the first three characters of the label of the N-th round of AtCoder Beginner Contest.\n\nConstraints\n\n1 \\leq N \\leq 1998\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the first three characters of the label of the N-th round of AtCoder Beginner Contest.\n\nSample Input 1\n\n999\n\nSample Output 1\n\nABC\n\nThe 999-th round of AtCoder Beginner Contest is labeled as ABC999.\n\nSample Input 2\n\n1000\n\nSample Output 2\n\nABD\n\nThe 1000-th round of AtCoder Beginner Contest is labeled as ABD001.\n\nSample Input 3\n\n1481\n\nSample Output 3\n\nABD\n\nThe 1481-th round of AtCoder Beginner Contest is labeled as ABD482.", "sample_input": "999\n"}, "reference_outputs": ["ABC\n"], "source_document_id": "p03327", "source_text": "Score : 100 points\n\nProblem Statement\n\nDecades have passed since the beginning of AtCoder Beginner Contest.\n\nThe contests are labeled as ABC001, ABC002, ... from the first round, but after the 999-th round ABC999, a problem occurred: how the future rounds should be labeled?\n\nIn the end, the labels for the rounds from the 1000-th to the 1998-th are decided: ABD001, ABD002, ..., ABD999.\n\nYou are given an integer N between 1 and 1998 (inclusive). Print the first three characters of the label of the N-th round of AtCoder Beginner Contest.\n\nConstraints\n\n1 \\leq N \\leq 1998\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the first three characters of the label of the N-th round of AtCoder Beginner Contest.\n\nSample Input 1\n\n999\n\nSample Output 1\n\nABC\n\nThe 999-th round of AtCoder Beginner Contest is labeled as ABC999.\n\nSample Input 2\n\n1000\n\nSample Output 2\n\nABD\n\nThe 1000-th round of AtCoder Beginner Contest is labeled as ABD001.\n\nSample Input 3\n\n1481\n\nSample Output 3\n\nABD\n\nThe 1481-th round of AtCoder Beginner Contest is labeled as ABD482.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 136, "cpu_time_ms": 323, "memory_kb": 25380}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s919751596", "group_id": "codeNet:p03328", "input_text": "import scala.io.StdIn._\n\nobject Main extends App {\n val Seq(a, b) = readLine().split(\" \").map(_.toInt).toSeq\n println((1 until (b - a)).sum - a)\n}\n", "language": "Scala", "metadata": {"date": 1599870023, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/s919751596.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s919751596", "user_id": "u004161348"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main extends App {\n val Seq(a, b) = readLine().split(\" \").map(_.toInt).toSeq\n println((1 until (b - a)).sum - a)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 493, "memory_kb": 54948}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s172411408", "group_id": "codeNet:p03329", "input_text": "object Main extends App {\n import scala.math._\n \n val n = readInt\n val dp = Array.fill[Int](n+1)(Int.MaxValue)\n dp(0) = 0\n \n for (i <- 0 until n) {\n dp(i+1) = min(dp(i+1),dp(i)+1) //1円引き出す\n for (j <- 0 to ((log((n-i).toDouble)/log(6.0)).toInt)) dp(i+pow(6,j).toInt) = min(dp(i+pow(6,j).toInt),dp(i)+1) //6のべき乗円引き出す\n for (j <- 0 to ((log((n-i).toDouble)/log(9.0)).toInt)) dp(i+pow(9,j).toInt) = min(dp(i+pow(9,j).toInt),dp(i)+1) //9のべき乗円引き出す\n }\n \n println(dp(n))\n}", "language": "Scala", "metadata": {"date": 1576520569, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03329.html", "problem_id": "p03329", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03329/input.txt", "sample_output_relpath": "derived/input_output/data/p03329/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03329/Scala/s172411408.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s172411408", "user_id": "u696665136"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "object Main extends App {\n import scala.math._\n \n val n = readInt\n val dp = Array.fill[Int](n+1)(Int.MaxValue)\n dp(0) = 0\n \n for (i <- 0 until n) {\n dp(i+1) = min(dp(i+1),dp(i)+1) //1円引き出す\n for (j <- 0 to ((log((n-i).toDouble)/log(6.0)).toInt)) dp(i+pow(6,j).toInt) = min(dp(i+pow(6,j).toInt),dp(i)+1) //6のべき乗円引き出す\n for (j <- 0 to ((log((n-i).toDouble)/log(9.0)).toInt)) dp(i+pow(9,j).toInt) = min(dp(i+pow(9,j).toInt),dp(i)+1) //9のべき乗円引き出す\n }\n \n println(dp(n))\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTo make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation:\n\n1 yen (the currency of Japan)\n\n6 yen, 6^2(=36) yen, 6^3(=216) yen, ...\n\n9 yen, 9^2(=81) yen, 9^3(=729) yen, ...\n\nAt least how many operations are required to withdraw exactly N yen in total?\n\nIt is not allowed to re-deposit the money you withdrew.\n\nConstraints\n\n1 \\leq N \\leq 100000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf at least x operations are required to withdraw exactly N yen in total, print x.\n\nSample Input 1\n\n127\n\nSample Output 1\n\n4\n\nBy withdrawing 1 yen, 9 yen, 36(=6^2) yen and 81(=9^2) yen, we can withdraw 127 yen in four operations.\n\nSample Input 2\n\n3\n\nSample Output 2\n\n3\n\nBy withdrawing 1 yen three times, we can withdraw 3 yen in three operations.\n\nSample Input 3\n\n44852\n\nSample Output 3\n\n16", "sample_input": "127\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03329", "source_text": "Score : 300 points\n\nProblem Statement\n\nTo make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation:\n\n1 yen (the currency of Japan)\n\n6 yen, 6^2(=36) yen, 6^3(=216) yen, ...\n\n9 yen, 9^2(=81) yen, 9^3(=729) yen, ...\n\nAt least how many operations are required to withdraw exactly N yen in total?\n\nIt is not allowed to re-deposit the money you withdrew.\n\nConstraints\n\n1 \\leq N \\leq 100000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf at least x operations are required to withdraw exactly N yen in total, print x.\n\nSample Input 1\n\n127\n\nSample Output 1\n\n4\n\nBy withdrawing 1 yen, 9 yen, 36(=6^2) yen and 81(=9^2) yen, we can withdraw 127 yen in four operations.\n\nSample Input 2\n\n3\n\nSample Output 2\n\n3\n\nBy withdrawing 1 yen three times, we can withdraw 3 yen in three operations.\n\nSample Input 3\n\n44852\n\nSample Output 3\n\n16", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 528, "cpu_time_ms": 537, "memory_kb": 37640}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s634420893", "group_id": "codeNet:p03330", "input_text": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val Array(n, c) = in.readLine.split(\" \").map(_.toInt)\n val dcf = Iterator.continually(in.readLine)\n .take(c).map(_.split(\" \").map(_.toInt)).toArray\n val pallet = Iterator.continually(in.readLine)\n .take(n).map(_.split(\" \").map(_.toInt - 1)).toArray\n\n val table = Array.ofDim[Int](3,c)\n for {\n k <- 0 until c\n i <- 0 until n\n j <- 0 until n\n } {\n table((i+j)%3)(k) += dcf(pallet(i)(j))(k)\n }\n\n // debug(table.mkString(\" \"))\n\n def dfsEnum(d:Int, n:Int):Int = {\n // d進 n個列挙\n val enum = Array.ofDim[Int](n)\n var ret = Int.MaxValue\n \n def evalute():Unit = {\n if(enum.toSet.size == 3) {\n val res = \n enum.map(i => table(i)(enum(i))).sum\n ret = math.min(ret, res)\n // debug(enum.mkString(\" \"), \" \", res)\n }\n }\n \n def dfs(cnt:Int):Unit = {\n if(cnt == n) evalute\n else {\n for(i <- 0 until c) {\n enum(cnt) = i\n dfs(cnt+1)\n }\n }\n }\n \n dfs(0)\n ret\n }\n\n val ans = dfsEnum(c,3)\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": 1554259410, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03330.html", "problem_id": "p03330", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03330/input.txt", "sample_output_relpath": "derived/input_output/data/p03330/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03330/Scala/s634420893.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s634420893", "user_id": "u217010036"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val Array(n, c) = in.readLine.split(\" \").map(_.toInt)\n val dcf = Iterator.continually(in.readLine)\n .take(c).map(_.split(\" \").map(_.toInt)).toArray\n val pallet = Iterator.continually(in.readLine)\n .take(n).map(_.split(\" \").map(_.toInt - 1)).toArray\n\n val table = Array.ofDim[Int](3,c)\n for {\n k <- 0 until c\n i <- 0 until n\n j <- 0 until n\n } {\n table((i+j)%3)(k) += dcf(pallet(i)(j))(k)\n }\n\n // debug(table.mkString(\" \"))\n\n def dfsEnum(d:Int, n:Int):Int = {\n // d進 n個列挙\n val enum = Array.ofDim[Int](n)\n var ret = Int.MaxValue\n \n def evalute():Unit = {\n if(enum.toSet.size == 3) {\n val res = \n enum.map(i => table(i)(enum(i))).sum\n ret = math.min(ret, res)\n // debug(enum.mkString(\" \"), \" \", res)\n }\n }\n \n def dfs(cnt:Int):Unit = {\n if(cnt == n) evalute\n else {\n for(i <- 0 until c) {\n enum(cnt) = i\n dfs(cnt+1)\n }\n }\n }\n \n dfs(0)\n ret\n }\n\n val ans = dfsEnum(c,3)\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 : 400 points\n\nProblem Statement\n\nThere is a grid with N rows and N columns of squares. Let (i,j) be the square at the i-th row from the top and the j-th column from the left.\n\nThese squares have to be painted in one of the C colors from Color 1 to Color C. Initially, (i,j) is painted in Color c_{i,j}.\n\nWe say the grid is a good grid when the following condition is met for all i,j,x,y satisfying 1 \\leq i,j,x,y \\leq N:\n\nIf (i+j) \\% 3=(x+y) \\% 3, the color of (i,j) and the color of (x,y) are the same.\n\nIf (i+j) \\% 3 \\neq (x+y) \\% 3, the color of (i,j) and the color of (x,y) are different.\n\nHere, X \\% Y represents X modulo Y.\n\nWe will repaint zero or more squares so that the grid will be a good grid.\n\nFor a square, the wrongness when the color of the square is X before repainting and Y after repainting, is D_{X,Y}.\n\nFind the minimum possible sum of the wrongness of all the squares.\n\nConstraints\n\n1 \\leq N \\leq 500\n\n3 \\leq C \\leq 30\n\n1 \\leq D_{i,j} \\leq 1000 (i \\neq j),D_{i,j}=0 (i=j)\n\n1 \\leq c_{i,j} \\leq C\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN C\nD_{1,1} ... D_{1,C}\n:\nD_{C,1} ... D_{C,C}\nc_{1,1} ... c_{1,N}\n:\nc_{N,1} ... c_{N,N}\n\nOutput\n\nIf the minimum possible sum of the wrongness of all the squares is x, print x.\n\nSample Input 1\n\n2 3\n0 1 1\n1 0 1\n1 4 0\n1 2\n3 3\n\nSample Output 1\n\n3\n\nRepaint (1,1) to Color 2. The wrongness of (1,1) becomes D_{1,2}=1.\n\nRepaint (1,2) to Color 3. The wrongness of (1,2) becomes D_{2,3}=1.\n\nRepaint (2,2) to Color 1. The wrongness of (2,2) becomes D_{3,1}=1.\n\nIn this case, the sum of the wrongness of all the squares is 3.\n\nNote that D_{i,j} \\neq D_{j,i} is possible.\n\nSample Input 2\n\n4 3\n0 12 71\n81 0 53\n14 92 0\n1 1 2 1\n2 1 1 2\n2 2 1 3\n1 1 2 2\n\nSample Output 2\n\n428", "sample_input": "2 3\n0 1 1\n1 0 1\n1 4 0\n1 2\n3 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03330", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere is a grid with N rows and N columns of squares. Let (i,j) be the square at the i-th row from the top and the j-th column from the left.\n\nThese squares have to be painted in one of the C colors from Color 1 to Color C. Initially, (i,j) is painted in Color c_{i,j}.\n\nWe say the grid is a good grid when the following condition is met for all i,j,x,y satisfying 1 \\leq i,j,x,y \\leq N:\n\nIf (i+j) \\% 3=(x+y) \\% 3, the color of (i,j) and the color of (x,y) are the same.\n\nIf (i+j) \\% 3 \\neq (x+y) \\% 3, the color of (i,j) and the color of (x,y) are different.\n\nHere, X \\% Y represents X modulo Y.\n\nWe will repaint zero or more squares so that the grid will be a good grid.\n\nFor a square, the wrongness when the color of the square is X before repainting and Y after repainting, is D_{X,Y}.\n\nFind the minimum possible sum of the wrongness of all the squares.\n\nConstraints\n\n1 \\leq N \\leq 500\n\n3 \\leq C \\leq 30\n\n1 \\leq D_{i,j} \\leq 1000 (i \\neq j),D_{i,j}=0 (i=j)\n\n1 \\leq c_{i,j} \\leq C\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN C\nD_{1,1} ... D_{1,C}\n:\nD_{C,1} ... D_{C,C}\nc_{1,1} ... c_{1,N}\n:\nc_{N,1} ... c_{N,N}\n\nOutput\n\nIf the minimum possible sum of the wrongness of all the squares is x, print x.\n\nSample Input 1\n\n2 3\n0 1 1\n1 0 1\n1 4 0\n1 2\n3 3\n\nSample Output 1\n\n3\n\nRepaint (1,1) to Color 2. The wrongness of (1,1) becomes D_{1,2}=1.\n\nRepaint (1,2) to Color 3. The wrongness of (1,2) becomes D_{2,3}=1.\n\nRepaint (2,2) to Color 1. The wrongness of (2,2) becomes D_{3,1}=1.\n\nIn this case, the sum of the wrongness of all the squares is 3.\n\nNote that D_{i,j} \\neq D_{j,i} is possible.\n\nSample Input 2\n\n4 3\n0 12 71\n81 0 53\n14 92 0\n1 1 2 1\n2 1 1 2\n2 2 1 3\n1 1 2 2\n\nSample Output 2\n\n428", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1209, "cpu_time_ms": 671, "memory_kb": 44196}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s879891816", "group_id": "codeNet:p03333", "input_text": "import java.util.Comparator\n\nobject 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\n case class Seg(id: Int, l: Int, r: Int) {\n\n /**\n * @return (距離, 場所)\n */\n def move(p: Int): (Int, Int) = {\n if (l to r contains p) {\n (0, p)\n } else if (abs(p - l) > abs(p - r)) {\n (abs(p - r), r)\n } else {\n (abs(p - l), l)\n }\n }\n }\n\n def newQueue(f: Seg => Int) = new java.util.PriorityQueue[Seg](N, new Comparator[Seg] {\n override def compare(o1: Seg, o2: Seg): Int = Integer.compare(f(o1), f(o2))\n })\n\n val MAX = 1e5.toInt\n val S = Array(newQueue(MAX - _.l), newQueue(_.r))\n\n rep(N) { i =>\n val s = Seg(i, ni(), ni())\n map(2)(i => S(i).add(s))\n }\n\n var ans = 0L\n var p = 0\n val removed = mutable.Set[Int]()\n def maintain(): Unit = {\n rep(2) { i =>\n var s = S(i).peek()\n while(!S(i).isEmpty && removed.contains(s.id)) {S(i).remove(); s = S(i).peek()}\n }\n }\n\n rep(N) { _ =>\n maintain()\n val s = map(2)(i => S(i).peek()).maxBy(_.move(p)._1)\n removed += s.id\n val (len, pos) = s.move(p)\n ans += len\n p = pos\n }\n ans += abs(p)\n\n out.println(ans)\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 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": 1539205725, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03333.html", "problem_id": "p03333", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03333/input.txt", "sample_output_relpath": "derived/input_output/data/p03333/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03333/Scala/s879891816.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s879891816", "user_id": "u460609472"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import java.util.Comparator\n\nobject 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\n case class Seg(id: Int, l: Int, r: Int) {\n\n /**\n * @return (距離, 場所)\n */\n def move(p: Int): (Int, Int) = {\n if (l to r contains p) {\n (0, p)\n } else if (abs(p - l) > abs(p - r)) {\n (abs(p - r), r)\n } else {\n (abs(p - l), l)\n }\n }\n }\n\n def newQueue(f: Seg => Int) = new java.util.PriorityQueue[Seg](N, new Comparator[Seg] {\n override def compare(o1: Seg, o2: Seg): Int = Integer.compare(f(o1), f(o2))\n })\n\n val MAX = 1e5.toInt\n val S = Array(newQueue(MAX - _.l), newQueue(_.r))\n\n rep(N) { i =>\n val s = Seg(i, ni(), ni())\n map(2)(i => S(i).add(s))\n }\n\n var ans = 0L\n var p = 0\n val removed = mutable.Set[Int]()\n def maintain(): Unit = {\n rep(2) { i =>\n var s = S(i).peek()\n while(!S(i).isEmpty && removed.contains(s.id)) {S(i).remove(); s = S(i).peek()}\n }\n }\n\n rep(N) { _ =>\n maintain()\n val s = map(2)(i => S(i).peek()).maxBy(_.move(p)._1)\n removed += s.id\n val (len, pos) = s.move(p)\n ans += len\n p = pos\n }\n ans += abs(p)\n\n out.println(ans)\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 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 : 700 points\n\nProblem Statement\n\nTakahashi and Aoki will play a game with a number line and some segments.\nTakahashi is standing on the number line and he is initially at coordinate 0.\nAoki has N segments. The i-th segment is [L_i,R_i], that is, a segment consisting of points with coordinates between L_i and R_i (inclusive).\n\nThe game has N steps. The i-th step proceeds as follows:\n\nFirst, Aoki chooses a segment that is still not chosen yet from the N segments and tells it to Takahashi.\n\nThen, Takahashi walks along the number line to some point within the segment chosen by Aoki this time.\n\nAfter N steps are performed, Takahashi will return to coordinate 0 and the game ends.\n\nLet K be the total distance traveled by Takahashi throughout the game. Aoki will choose segments so that K will be as large as possible, and Takahashi walks along the line so that K will be as small as possible. What will be the value of K in the end?\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n-10^5 ≤ L_i < R_i ≤ 10^5\n\nL_i and R_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 R_1\n:\nL_N R_N\n\nOutput\n\nPrint the total distance traveled by Takahashi throughout the game when Takahashi and Aoki acts as above.\nIt is guaranteed that K is always an integer when L_i,R_i are integers.\n\nSample Input 1\n\n3\n-5 1\n3 7\n-4 -2\n\nSample Output 1\n\n10\n\nOne possible sequence of actions of Takahashi and Aoki is as follows:\n\nAoki chooses the first segment. Takahashi moves from coordinate 0 to -4, covering a distance of 4.\n\nAoki chooses the third segment. Takahashi stays at coordinate -4.\n\nAoki chooses the second segment. Takahashi moves from coordinate -4 to 3, covering a distance of 7.\n\nTakahashi moves from coordinate 3 to 0, covering a distance of 3.\n\nThe distance covered by Takahashi here is 14 (because Takahashi didn't move optimally).\nIt turns out that if both players move optimally, the distance covered by Takahashi will be 10.\n\nSample Input 2\n\n3\n1 2\n3 4\n5 6\n\nSample Output 2\n\n12\n\nSample Input 3\n\n5\n-2 0\n-2 0\n7 8\n9 10\n-2 -1\n\nSample Output 3\n\n34", "sample_input": "3\n-5 1\n3 7\n-4 -2\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03333", "source_text": "Score : 700 points\n\nProblem Statement\n\nTakahashi and Aoki will play a game with a number line and some segments.\nTakahashi is standing on the number line and he is initially at coordinate 0.\nAoki has N segments. The i-th segment is [L_i,R_i], that is, a segment consisting of points with coordinates between L_i and R_i (inclusive).\n\nThe game has N steps. The i-th step proceeds as follows:\n\nFirst, Aoki chooses a segment that is still not chosen yet from the N segments and tells it to Takahashi.\n\nThen, Takahashi walks along the number line to some point within the segment chosen by Aoki this time.\n\nAfter N steps are performed, Takahashi will return to coordinate 0 and the game ends.\n\nLet K be the total distance traveled by Takahashi throughout the game. Aoki will choose segments so that K will be as large as possible, and Takahashi walks along the line so that K will be as small as possible. What will be the value of K in the end?\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n-10^5 ≤ L_i < R_i ≤ 10^5\n\nL_i and R_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 R_1\n:\nL_N R_N\n\nOutput\n\nPrint the total distance traveled by Takahashi throughout the game when Takahashi and Aoki acts as above.\nIt is guaranteed that K is always an integer when L_i,R_i are integers.\n\nSample Input 1\n\n3\n-5 1\n3 7\n-4 -2\n\nSample Output 1\n\n10\n\nOne possible sequence of actions of Takahashi and Aoki is as follows:\n\nAoki chooses the first segment. Takahashi moves from coordinate 0 to -4, covering a distance of 4.\n\nAoki chooses the third segment. Takahashi stays at coordinate -4.\n\nAoki chooses the second segment. Takahashi moves from coordinate -4 to 3, covering a distance of 7.\n\nTakahashi moves from coordinate 3 to 0, covering a distance of 3.\n\nThe distance covered by Takahashi here is 14 (because Takahashi didn't move optimally).\nIt turns out that if both players move optimally, the distance covered by Takahashi will be 10.\n\nSample Input 2\n\n3\n1 2\n3 4\n5 6\n\nSample Output 2\n\n12\n\nSample Input 3\n\n5\n-2 0\n-2 0\n7 8\n9 10\n-2 -1\n\nSample Output 3\n\n34", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3036, "cpu_time_ms": 1338, "memory_kb": 119984}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s828856555", "group_id": "codeNet:p03338", "input_text": "import java.util.Scanner\n\nobject Main {\n val sc = new Scanner(System.in)\n def main(args: Array[String]) {\n sc.next\n val s = sc.next\n val n = s.length\n println(1.until(n).map(\n i => s.splitAt(i)\n ).map({\n case (l, r) => l.distinct.count(x => r.contains(x))\n }).max)\n }\n}\n", "language": "Scala", "metadata": {"date": 1527632975, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03338.html", "problem_id": "p03338", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03338/input.txt", "sample_output_relpath": "derived/input_output/data/p03338/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03338/Scala/s828856555.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s828856555", "user_id": "u790142428"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n val sc = new Scanner(System.in)\n def main(args: Array[String]) {\n sc.next\n val s = sc.next\n val n = s.length\n println(1.until(n).map(\n i => s.splitAt(i)\n ).map({\n case (l, r) => l.distinct.count(x => r.contains(x))\n }).max)\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of lowercase English letters.\nWe will cut this string at one position into two strings X and Y.\nHere, we would like to maximize the number of different letters contained in both X and Y.\nFind the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n|S| = N\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the largest possible number of different letters contained in both X and Y.\n\nSample Input 1\n\n6\naabbca\n\nSample Output 1\n\n2\n\nIf we cut the string between the third and fourth letters into X = aab and Y = bca, the letters contained in both X and Y are a and b.\nThere will never be three or more different letters contained in both X and Y, so the answer is 2.\n\nSample Input 2\n\n10\naaaaaaaaaa\n\nSample Output 2\n\n1\n\nHowever we divide S, only a will be contained in both X and Y.\n\nSample Input 3\n\n45\ntgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir\n\nSample Output 3\n\n9", "sample_input": "6\naabbca\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03338", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of lowercase English letters.\nWe will cut this string at one position into two strings X and Y.\nHere, we would like to maximize the number of different letters contained in both X and Y.\nFind the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n|S| = N\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the largest possible number of different letters contained in both X and Y.\n\nSample Input 1\n\n6\naabbca\n\nSample Output 1\n\n2\n\nIf we cut the string between the third and fourth letters into X = aab and Y = bca, the letters contained in both X and Y are a and b.\nThere will never be three or more different letters contained in both X and Y, so the answer is 2.\n\nSample Input 2\n\n10\naaaaaaaaaa\n\nSample Output 2\n\n1\n\nHowever we divide S, only a will be contained in both X and Y.\n\nSample Input 3\n\n45\ntgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir\n\nSample Output 3\n\n9", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 301, "cpu_time_ms": 390, "memory_kb": 27472}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s796641929", "group_id": "codeNet:p03339", "input_text": "object Main extends App {\n val n = scala.io.StdIn.readLine.toInt\n val s = scala.io.StdIn.readLine\n var arr1 = Array.fill[Int](n)(0)\n var arr2 = Array.fill[Int](n)(0)\n var cnt = n\n\n arr1(0) = 0\n\n // 0人目をリーダーに\n cnt = s.takeRight(n - 1).count(_ == 'E')\n arr2(0) = cnt\n\n (1 until n).foreach { x =>\n if (s.charAt(x - 1) == 'W') {\n arr1(x) = arr1(x - 1) + 1\n } else {\n arr1(x) = arr1(x - 1)\n }\n\n if (s.charAt(x) == 'E') {\n arr2(x) = arr2(x - 1) - 1\n } else {\n arr2(x) = arr2(x - 1)\n }\n /*\n println(\"====A\")\n\n println(cnt)\n println(arr1(x))\n println(arr2(x - 1))\n println(arr1(x) + arr2(x - 1) - 1)\n println(\"====B\")\n */\n cnt = List(cnt, arr1(x) + arr2(x)).min\n }\n\n/*\n arr1.foreach(print)\n println()\n\n arr2.foreach(print)\n println()\n */\n println(cnt)\n\n}\n", "language": "Scala", "metadata": {"date": 1527387261, "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/s796641929.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s796641929", "user_id": "u654455149"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main extends App {\n val n = scala.io.StdIn.readLine.toInt\n val s = scala.io.StdIn.readLine\n var arr1 = Array.fill[Int](n)(0)\n var arr2 = Array.fill[Int](n)(0)\n var cnt = n\n\n arr1(0) = 0\n\n // 0人目をリーダーに\n cnt = s.takeRight(n - 1).count(_ == 'E')\n arr2(0) = cnt\n\n (1 until n).foreach { x =>\n if (s.charAt(x - 1) == 'W') {\n arr1(x) = arr1(x - 1) + 1\n } else {\n arr1(x) = arr1(x - 1)\n }\n\n if (s.charAt(x) == 'E') {\n arr2(x) = arr2(x - 1) - 1\n } else {\n arr2(x) = arr2(x - 1)\n }\n /*\n println(\"====A\")\n\n println(cnt)\n println(arr1(x))\n println(arr2(x - 1))\n println(arr1(x) + arr2(x - 1) - 1)\n println(\"====B\")\n */\n cnt = List(cnt, arr1(x) + arr2(x)).min\n }\n\n/*\n arr1.foreach(print)\n println()\n\n arr2.foreach(print)\n println()\n */\n println(cnt)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 845, "cpu_time_ms": 722, "memory_kb": 49164}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s196365731", "group_id": "codeNet:p03339", "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 N = sc.nextInt\n val S = sc.next\n\n var n = 0\n val sL = 0 +: S.map {\n case 'W' => n += 1; n\n case 'E' => n\n }\n n = 0\n val sR = 0 +: S.reverse.map {\n case 'E' => n += 1; n\n case 'W' => n\n }\n val ss = for (i <- 0 until N)\n yield sL(i) + sR(N - i - 1)\n ss.min.toString\n }\n}\n", "language": "Scala", "metadata": {"date": 1527385123, "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/s196365731.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s196365731", "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 val N = sc.nextInt\n val S = sc.next\n\n var n = 0\n val sL = 0 +: S.map {\n case 'W' => n += 1; n\n case 'E' => n\n }\n n = 0\n val sR = 0 +: S.reverse.map {\n case 'E' => n += 1; n\n case 'W' => n\n }\n val ss = for (i <- 0 until N)\n yield sL(i) + sR(N - i - 1)\n ss.min.toString\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 728, "memory_kb": 55940}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s698128576", "group_id": "codeNet:p03345", "input_text": "object Main {\n import java.io.PrintStream\n\n def main(args: Array[String]): Unit = {\n val s = new Main()\n val ps = new PrintStream(Console.out)\n Console.withOut(ps) {\n s.solve()\n }\n ps.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 import scala.Console\n\n val MOD = 1000000007\n\n def solve(): Unit = {\n val A, B, C, K = nl()\n val ans = if (K % 2 == 0) A - B else B - A\n println(ans)\n }\n\n\n class InputReader(reader: BufferedReader) {\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(Console.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)(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": 1541731543, "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/s698128576.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s698128576", "user_id": "u460609472"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main {\n import java.io.PrintStream\n\n def main(args: Array[String]): Unit = {\n val s = new Main()\n val ps = new PrintStream(Console.out)\n Console.withOut(ps) {\n s.solve()\n }\n ps.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 import scala.Console\n\n val MOD = 1000000007\n\n def solve(): Unit = {\n val A, B, C, K = nl()\n val ans = if (K % 2 == 0) A - B else B - A\n println(ans)\n }\n\n\n class InputReader(reader: BufferedReader) {\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(Console.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)(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\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2480, "cpu_time_ms": 339, "memory_kb": 27432}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s948730041", "group_id": "codeNet:p03347", "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 A = Array.fill(N)(sc.nextInt)\n val B = ArrayBuffer.fill(N)(0)\n\n var ans = 0\n for (i <- (N - 1) to 0 by -1) {\n if (A(i) > i) {\n return \"-1\"\n }\n for (j <- 0 until A(i)) {\n val n = A(i) - j\n if (B(i - j) < n) {\n B(i - j) = n\n ans += 1\n } else if (B(i - j) > n) {\n return \"-1\"\n }\n\n }\n println(B)\n }\n ans.toString\n }\n}\n", "language": "Scala", "metadata": {"date": 1526869333, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03347.html", "problem_id": "p03347", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03347/input.txt", "sample_output_relpath": "derived/input_output/data/p03347/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03347/Scala/s948730041.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s948730041", "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 A = Array.fill(N)(sc.nextInt)\n val B = ArrayBuffer.fill(N)(0)\n\n var ans = 0\n for (i <- (N - 1) to 0 by -1) {\n if (A(i) > i) {\n return \"-1\"\n }\n for (j <- 0 until A(i)) {\n val n = A(i) - j\n if (B(i - j) < n) {\n B(i - j) = n\n ans += 1\n } else if (B(i - j) > n) {\n return \"-1\"\n }\n\n }\n println(B)\n }\n ans.toString\n }\n}\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nThere is a sequence X of length N, where every element is initially 0. Let X_i denote the i-th element of X.\n\nYou are given a sequence A of length N. The i-th element of A is A_i. Determine if we can make X equal to A by repeating the operation below. If we can, find the minimum number of operations required.\n\nChoose an integer i such that 1\\leq i\\leq N-1. Replace the value of X_{i+1} with the value of X_i plus 1.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq A_i \\leq 10^9(1\\leq i\\leq N)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nIf we can make X equal to A by repeating the operation, print the minimum number of operations required. If we cannot, print -1.\n\nSample Input 1\n\n4\n0\n1\n1\n2\n\nSample Output 1\n\n3\n\nWe can make X equal to A as follows:\n\nChoose i=2. X becomes (0,0,1,0).\n\nChoose i=1. X becomes (0,1,1,0).\n\nChoose i=3. X becomes (0,1,1,2).\n\nSample Input 2\n\n3\n1\n2\n1\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n9\n0\n1\n1\n0\n1\n2\n2\n1\n2\n\nSample Output 3\n\n8", "sample_input": "4\n0\n1\n1\n2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03347", "source_text": "Score : 700 points\n\nProblem Statement\n\nThere is a sequence X of length N, where every element is initially 0. Let X_i denote the i-th element of X.\n\nYou are given a sequence A of length N. The i-th element of A is A_i. Determine if we can make X equal to A by repeating the operation below. If we can, find the minimum number of operations required.\n\nChoose an integer i such that 1\\leq i\\leq N-1. Replace the value of X_{i+1} with the value of X_i plus 1.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq A_i \\leq 10^9(1\\leq i\\leq N)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nIf we can make X equal to A by repeating the operation, print the minimum number of operations required. If we cannot, print -1.\n\nSample Input 1\n\n4\n0\n1\n1\n2\n\nSample Output 1\n\n3\n\nWe can make X equal to A as follows:\n\nChoose i=2. X becomes (0,0,1,0).\n\nChoose i=1. X becomes (0,1,1,0).\n\nChoose i=3. X becomes (0,1,1,2).\n\nSample Input 2\n\n3\n1\n2\n1\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n9\n0\n1\n1\n0\n1\n2\n2\n1\n2\n\nSample Output 3\n\n8", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 708, "cpu_time_ms": 2115, "memory_kb": 224540}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s426592704", "group_id": "codeNet:p03351", "input_text": "object Main {\n\n def calc(a: Int, b: Int, c: Int, d: Int): Boolean = {\n math.abs(a - b) <= d && math.abs(b - c) <= d\n }\n\n def main(args: Array[String]): Unit = {\n val in = io.Source.fromInputStream(System.in).getLines()\n val Array(a, b, c, d) = in.next().split(' ') map (_.toInt)\n if (calc(a, b, c, d)) \"Yes\" else \"No\"\n }\n}", "language": "Scala", "metadata": {"date": 1526174040, "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/s426592704.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s426592704", "user_id": "u460609472"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main {\n\n def calc(a: Int, b: Int, c: Int, d: Int): Boolean = {\n math.abs(a - b) <= d && math.abs(b - c) <= d\n }\n\n def main(args: Array[String]): Unit = {\n val in = io.Source.fromInputStream(System.in).getLines()\n val Array(a, b, c, d) = in.next().split(' ') map (_.toInt)\n if (calc(a, b, c, d)) \"Yes\" else \"No\"\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 338, "cpu_time_ms": 324, "memory_kb": 25632}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s818522534", "group_id": "codeNet:p03352", "input_text": "object Main extends App {\n val x = io.StdIn.readInt\n\n if (x == 1) println(1)\n else {\n\n /*\n def exponentiation(base: Int): Int = {\n var tmp = base\n while (tmp < x) tmp *= base\n\n if (tmp == x) x\n else tmp/base\n }\n */\n\n def exponentiation(base: Int, acc: Int): Int =\n if (x < acc) acc/base\n else exponentiation(base, acc*base)\n\n // 1 <= 基数 <= √x\n val result = (2 to math.sqrt(x).toInt).map(exponentiation(_, 1)).max\n println(result)\n\n }\n\n}", "language": "Scala", "metadata": {"date": 1593387687, "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/s818522534.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s818522534", "user_id": "u104354966"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "object Main extends App {\n val x = io.StdIn.readInt\n\n if (x == 1) println(1)\n else {\n\n /*\n def exponentiation(base: Int): Int = {\n var tmp = base\n while (tmp < x) tmp *= base\n\n if (tmp == x) x\n else tmp/base\n }\n */\n\n def exponentiation(base: Int, acc: Int): Int =\n if (x < acc) acc/base\n else exponentiation(base, acc*base)\n\n // 1 <= 基数 <= √x\n val result = (2 to math.sqrt(x).toInt).map(exponentiation(_, 1)).max\n println(result)\n\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 479, "memory_kb": 54760}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s112715446", "group_id": "codeNet:p03352", "input_text": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val x = in.readInt\n val ans = (1 to math.sqrt(x).toInt + 1)./:(1)( (acc, i) => {\n val y = i * i\n if(y <= x) y else acc\n })\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1556066883, "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/s112715446.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s112715446", "user_id": "u217010036"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val x = in.readInt\n val ans = (1 to math.sqrt(x).toInt + 1)./:(1)( (acc, i) => {\n val y = i * i\n if(y <= x) y else acc\n })\n println(ans)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 329, "memory_kb": 27328}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s367813131", "group_id": "codeNet:p03352", "input_text": "import scala.io.StdIn\nobject Main extends App {\n val x = StdIn.readLine.toInt\n val r = math.sqrt(x).toInt\n val ans = if( r == 1) x else\n (2 to r).map { i =>\n val e = for {\n j <- (2 to r)\n e = math.pow(i,j).toInt if(e <= x)\n } yield e\n e.last\n }.max\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1541285713, "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/s367813131.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s367813131", "user_id": "u217010036"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import scala.io.StdIn\nobject Main extends App {\n val x = StdIn.readLine.toInt\n val r = math.sqrt(x).toInt\n val ans = if( r == 1) x else\n (2 to r).map { i =>\n val e = for {\n j <- (2 to r)\n e = math.pow(i,j).toInt if(e <= x)\n } yield e\n e.last\n }.max\n println(ans)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 303, "cpu_time_ms": 326, "memory_kb": 27072}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s298767297", "group_id": "codeNet:p03359", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n\n val sc = new Scanner(System.in)\n\n val month = sc.nextInt()\n val date = sc.nextInt()\n var counter = 0\n (1 to month).foreach( m =>\n (1 to date).foreach( d =>\n if (m == d) {\n counter = counter +1\n }\n )\n )\n println(counter)\n}\n", "language": "Scala", "metadata": {"date": 1526059277, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03359.html", "problem_id": "p03359", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03359/input.txt", "sample_output_relpath": "derived/input_output/data/p03359/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03359/Scala/s298767297.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s298767297", "user_id": "u726872801"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n\n val sc = new Scanner(System.in)\n\n val month = sc.nextInt()\n val date = sc.nextInt()\n var counter = 0\n (1 to month).foreach( m =>\n (1 to date).foreach( d =>\n if (m == d) {\n counter = counter +1\n }\n )\n )\n println(counter)\n}\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nIn AtCoder Kingdom, Gregorian calendar is used, and dates are written in the \"year-month-day\" order, or the \"month-day\" order without the year.\n\nFor example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.\n\nIn this country, a date is called Takahashi when the month and the day are equal as numbers. For example, 5-5 is Takahashi.\n\nHow many days from 2018-1-1 through 2018-a-b are Takahashi?\n\nConstraints\n\na is an integer between 1 and 12 (inclusive).\n\nb is an integer between 1 and 31 (inclusive).\n\n2018-a-b is a valid date in Gregorian calendar.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint the number of days from 2018-1-1 through 2018-a-b that are Takahashi.\n\nSample Input 1\n\n5 5\n\nSample Output 1\n\n5\n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\nSample Input 2\n\n2 1\n\nSample Output 2\n\n1\n\nThere is only one day that is Takahashi: 1-1.\n\nSample Input 3\n\n11 30\n\nSample Output 3\n\n11\n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7, 8-8, 9-9, 10-10 and 11-11.", "sample_input": "5 5\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03359", "source_text": "Score: 100 points\n\nProblem Statement\n\nIn AtCoder Kingdom, Gregorian calendar is used, and dates are written in the \"year-month-day\" order, or the \"month-day\" order without the year.\n\nFor example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.\n\nIn this country, a date is called Takahashi when the month and the day are equal as numbers. For example, 5-5 is Takahashi.\n\nHow many days from 2018-1-1 through 2018-a-b are Takahashi?\n\nConstraints\n\na is an integer between 1 and 12 (inclusive).\n\nb is an integer between 1 and 31 (inclusive).\n\n2018-a-b is a valid date in Gregorian calendar.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint the number of days from 2018-1-1 through 2018-a-b that are Takahashi.\n\nSample Input 1\n\n5 5\n\nSample Output 1\n\n5\n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\nSample Input 2\n\n2 1\n\nSample Output 2\n\n1\n\nThere is only one day that is Takahashi: 1-1.\n\nSample Input 3\n\n11 30\n\nSample Output 3\n\n11\n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7, 8-8, 9-9, 10-10 and 11-11.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 306, "cpu_time_ms": 330, "memory_kb": 25400}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s467135858", "group_id": "codeNet:p03371", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val A, B, C, X, Y = sc.nextLong()\n val sum = if (A + B < C * 2) {\n A * X + B * Y\n } else {\n val diff = X min Y\n diff * C * 2 +\n (A min (C * 2)) * (X - diff) +\n (B min (C * 2)) * (Y - diff)\n }\n println(sum)\n}\n", "language": "Scala", "metadata": {"date": 1593823965, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/s467135858.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s467135858", "user_id": "u737111725"}, "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.nextLong()\n val sum = if (A + B < C * 2) {\n A * X + B * Y\n } else {\n val diff = X min Y\n diff * C * 2 +\n (A min (C * 2)) * (X - diff) +\n (B min (C * 2)) * (Y - diff)\n }\n println(sum)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\n\"Pizza At\", a fast food chain, offers three kinds of pizza: \"A-pizza\", \"B-pizza\" and \"AB-pizza\". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.\n\nNakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.\n\nConstraints\n\n1 ≤ A, B, C ≤ 5000\n\n1 ≤ X, Y ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C X Y\n\nOutput\n\nPrint the minimum amount of money required to prepare X A-pizzas and Y B-pizzas.\n\nSample Input 1\n\n1500 2000 1600 3 2\n\nSample Output 1\n\n7900\n\nIt is optimal to buy four AB-pizzas and rearrange them into two A-pizzas and two B-pizzas, then buy additional one A-pizza.\n\nSample Input 2\n\n1500 2000 1900 3 2\n\nSample Output 2\n\n8500\n\nIt is optimal to directly buy three A-pizzas and two B-pizzas.\n\nSample Input 3\n\n1500 2000 500 90000 100000\n\nSample Output 3\n\n100000000\n\nIt is optimal to buy 200000 AB-pizzas and rearrange them into 100000 A-pizzas and 100000 B-pizzas. We will have 10000 more A-pizzas than necessary, but that is fine.", "sample_input": "1500 2000 1600 3 2\n"}, "reference_outputs": ["7900\n"], "source_document_id": "p03371", "source_text": "Score : 300 points\n\nProblem Statement\n\n\"Pizza At\", a fast food chain, offers three kinds of pizza: \"A-pizza\", \"B-pizza\" and \"AB-pizza\". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.\n\nNakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.\n\nConstraints\n\n1 ≤ A, B, C ≤ 5000\n\n1 ≤ X, Y ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C X Y\n\nOutput\n\nPrint the minimum amount of money required to prepare X A-pizzas and Y B-pizzas.\n\nSample Input 1\n\n1500 2000 1600 3 2\n\nSample Output 1\n\n7900\n\nIt is optimal to buy four AB-pizzas and rearrange them into two A-pizzas and two B-pizzas, then buy additional one A-pizza.\n\nSample Input 2\n\n1500 2000 1900 3 2\n\nSample Output 2\n\n8500\n\nIt is optimal to directly buy three A-pizzas and two B-pizzas.\n\nSample Input 3\n\n1500 2000 500 90000 100000\n\nSample Output 3\n\n100000000\n\nIt is optimal to buy 200000 AB-pizzas and rearrange them into 100000 A-pizzas and 100000 B-pizzas. We will have 10000 more A-pizzas than necessary, but that is fine.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 303, "cpu_time_ms": 504, "memory_kb": 55384}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s087720646", "group_id": "codeNet:p03374", "input_text": "import scala.annotation.tailrec\n\nobject Main extends App {\n val N = MyPredef2.nextInt // 寿司の数\n val C = MyPredef2.nextLong // 外周\n val inputSushi :Array[Array[Long]] = Array.fill(N, 2)(MyPredef2.nextLong) // 距離, calの配列\n\n @tailrec\n def makeSushiArray(ind :Int, sumCal: Long, maxCal: Long, sushi :Array[Array[Long]] ,res :Array[Sushi]): Array[Sushi] = {\n val target = sushi(ind)\n val tCal = sumCal + target(1) - target(0)\n var tMaxCal = maxCal\n if (maxCal < tCal) {\n tMaxCal = tCal\n }\n val tSushi = new Sushi(target(0), tMaxCal)\n\n if (ind < N - 1) {\n makeSushiArray(ind + 1, tCal + target(0), tMaxCal, sushi, res :+ tSushi)\n } else {\n res :+ tSushi\n }\n }\n val rSushi :Array[Sushi] = makeSushiArray(0, 0, 0, inputSushi, Array.empty[Sushi])\n val reverseSushi = inputSushi.reverse.map(x => Array(C - x(0), x(1)))\n val lSushi :Array[Sushi] = makeSushiArray(0,0,0,reverseSushi, Array.empty[Sushi])\n\n var rMax :Long = rSushi.maxBy(_.maxCal).maxCal\n for (i <- 0 until N - 1) {\n val tMax = rSushi(i).maxCal - rSushi(i).dist + lSushi(N - 2 - i).maxCal\n if (tMax > rMax) rMax = tMax\n }\n\n var lMax :Long = lSushi.maxBy(_.maxCal).maxCal\n for (i <- 0 until N - 1) {\n val tMax = lSushi(i).maxCal - lSushi(i).dist + rSushi(N - 2 - i).maxCal\n if (tMax > lMax) lMax = tMax\n }\n\n if (rMax > lMax) println(rMax)\n else println(lMax)\n}\n\n// 始点からの距離と、その時点での最大カロリーを持つ\ncase class Sushi(dist: Long, maxCal: Long) {}\n\nobject MyPredef2 {\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}", "language": "Scala", "metadata": {"date": 1524720028, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03374.html", "problem_id": "p03374", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03374/input.txt", "sample_output_relpath": "derived/input_output/data/p03374/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03374/Scala/s087720646.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s087720646", "user_id": "u290193605"}, "prompt_components": {"gold_output": "191\n", "input_to_evaluate": "import scala.annotation.tailrec\n\nobject Main extends App {\n val N = MyPredef2.nextInt // 寿司の数\n val C = MyPredef2.nextLong // 外周\n val inputSushi :Array[Array[Long]] = Array.fill(N, 2)(MyPredef2.nextLong) // 距離, calの配列\n\n @tailrec\n def makeSushiArray(ind :Int, sumCal: Long, maxCal: Long, sushi :Array[Array[Long]] ,res :Array[Sushi]): Array[Sushi] = {\n val target = sushi(ind)\n val tCal = sumCal + target(1) - target(0)\n var tMaxCal = maxCal\n if (maxCal < tCal) {\n tMaxCal = tCal\n }\n val tSushi = new Sushi(target(0), tMaxCal)\n\n if (ind < N - 1) {\n makeSushiArray(ind + 1, tCal + target(0), tMaxCal, sushi, res :+ tSushi)\n } else {\n res :+ tSushi\n }\n }\n val rSushi :Array[Sushi] = makeSushiArray(0, 0, 0, inputSushi, Array.empty[Sushi])\n val reverseSushi = inputSushi.reverse.map(x => Array(C - x(0), x(1)))\n val lSushi :Array[Sushi] = makeSushiArray(0,0,0,reverseSushi, Array.empty[Sushi])\n\n var rMax :Long = rSushi.maxBy(_.maxCal).maxCal\n for (i <- 0 until N - 1) {\n val tMax = rSushi(i).maxCal - rSushi(i).dist + lSushi(N - 2 - i).maxCal\n if (tMax > rMax) rMax = tMax\n }\n\n var lMax :Long = lSushi.maxBy(_.maxCal).maxCal\n for (i <- 0 until N - 1) {\n val tMax = lSushi(i).maxCal - lSushi(i).dist + rSushi(N - 2 - i).maxCal\n if (tMax > lMax) lMax = tMax\n }\n\n if (rMax > lMax) println(rMax)\n else println(lMax)\n}\n\n// 始点からの距離と、その時点での最大カロリーを持つ\ncase class Sushi(dist: Long, maxCal: Long) {}\n\nobject MyPredef2 {\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}", "problem_context": "Score : 500 points\n\nProblem Statement\n\n\"Teishi-zushi\", a Japanese restaurant, is a plain restaurant with only one round counter. The outer circumference of the counter is C meters. Customers cannot go inside the counter.\n\nNakahashi entered Teishi-zushi, and he was guided to the counter. Now, there are N pieces of sushi (vinegared rice with seafood and so on) on the counter. The distance measured clockwise from the point where Nakahashi is standing to the point where the i-th sushi is placed, is x_i meters. Also, the i-th sushi has a nutritive value of v_i kilocalories.\n\nNakahashi can freely walk around the circumference of the counter. When he reach a point where a sushi is placed, he can eat that sushi and take in its nutrition (naturally, the sushi disappears). However, while walking, he consumes 1 kilocalories per meter.\n\nWhenever he is satisfied, he can leave the restaurant from any place (he does not have to return to the initial place). On balance, at most how much nutrition can he take in before he leaves? That is, what is the maximum possible value of the total nutrition taken in minus the total energy consumed? Assume that there are no other customers, and no new sushi will be added to the counter. Also, since Nakahashi has plenty of nutrition in his body, assume that no matter how much he walks and consumes energy, he never dies from hunger.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n2 ≤ C ≤ 10^{14}\n\n1 ≤ x_1 < x_2 < ... < x_N < C\n\n1 ≤ v_i ≤ 10^9\n\nAll values in input are integers.\n\nSubscores\n\n300 points will be awarded for passing the test set satisfying N ≤ 100.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN C\nx_1 v_1\nx_2 v_2\n:\nx_N v_N\n\nOutput\n\nIf Nakahashi can take in at most c kilocalories on balance before he leaves the restaurant, print c.\n\nSample Input 1\n\n3 20\n2 80\n9 120\n16 1\n\nSample Output 1\n\n191\n\nThere are three sushi on the counter with a circumference of 20 meters. If he walks two meters clockwise from the initial place, he can eat a sushi of 80 kilocalories. If he walks seven more meters clockwise, he can eat a sushi of 120 kilocalories. If he leaves now, the total nutrition taken in is 200 kilocalories, and the total energy consumed is 9 kilocalories, thus he can take in 191 kilocalories on balance, which is the largest possible value.\n\nSample Input 2\n\n3 20\n2 80\n9 1\n16 120\n\nSample Output 2\n\n192\n\nThe second and third sushi have been swapped. Again, if he walks two meters clockwise from the initial place, he can eat a sushi of 80 kilocalories. If he walks six more meters counterclockwise this time, he can eat a sushi of 120 kilocalories. If he leaves now, the total nutrition taken in is 200 kilocalories, and the total energy consumed is 8 kilocalories, thus he can take in 192 kilocalories on balance, which is the largest possible value.\n\nSample Input 3\n\n1 100000000000000\n50000000000000 1\n\nSample Output 3\n\n0\n\nEven though the only sushi is so far that it does not fit into a 32-bit integer, its nutritive value is low, thus he should immediately leave without doing anything.\n\nSample Input 4\n\n15 10000000000\n400000000 1000000000\n800000000 1000000000\n1900000000 1000000000\n2400000000 1000000000\n2900000000 1000000000\n3300000000 1000000000\n3700000000 1000000000\n3800000000 1000000000\n4000000000 1000000000\n4100000000 1000000000\n5200000000 1000000000\n6600000000 1000000000\n8000000000 1000000000\n9300000000 1000000000\n9700000000 1000000000\n\nSample Output 4\n\n6500000000\n\nAll these sample inputs above are included in the test set for the partial score.", "sample_input": "3 20\n2 80\n9 120\n16 1\n"}, "reference_outputs": ["191\n"], "source_document_id": "p03374", "source_text": "Score : 500 points\n\nProblem Statement\n\n\"Teishi-zushi\", a Japanese restaurant, is a plain restaurant with only one round counter. The outer circumference of the counter is C meters. Customers cannot go inside the counter.\n\nNakahashi entered Teishi-zushi, and he was guided to the counter. Now, there are N pieces of sushi (vinegared rice with seafood and so on) on the counter. The distance measured clockwise from the point where Nakahashi is standing to the point where the i-th sushi is placed, is x_i meters. Also, the i-th sushi has a nutritive value of v_i kilocalories.\n\nNakahashi can freely walk around the circumference of the counter. When he reach a point where a sushi is placed, he can eat that sushi and take in its nutrition (naturally, the sushi disappears). However, while walking, he consumes 1 kilocalories per meter.\n\nWhenever he is satisfied, he can leave the restaurant from any place (he does not have to return to the initial place). On balance, at most how much nutrition can he take in before he leaves? That is, what is the maximum possible value of the total nutrition taken in minus the total energy consumed? Assume that there are no other customers, and no new sushi will be added to the counter. Also, since Nakahashi has plenty of nutrition in his body, assume that no matter how much he walks and consumes energy, he never dies from hunger.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n2 ≤ C ≤ 10^{14}\n\n1 ≤ x_1 < x_2 < ... < x_N < C\n\n1 ≤ v_i ≤ 10^9\n\nAll values in input are integers.\n\nSubscores\n\n300 points will be awarded for passing the test set satisfying N ≤ 100.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN C\nx_1 v_1\nx_2 v_2\n:\nx_N v_N\n\nOutput\n\nIf Nakahashi can take in at most c kilocalories on balance before he leaves the restaurant, print c.\n\nSample Input 1\n\n3 20\n2 80\n9 120\n16 1\n\nSample Output 1\n\n191\n\nThere are three sushi on the counter with a circumference of 20 meters. If he walks two meters clockwise from the initial place, he can eat a sushi of 80 kilocalories. If he walks seven more meters clockwise, he can eat a sushi of 120 kilocalories. If he leaves now, the total nutrition taken in is 200 kilocalories, and the total energy consumed is 9 kilocalories, thus he can take in 191 kilocalories on balance, which is the largest possible value.\n\nSample Input 2\n\n3 20\n2 80\n9 1\n16 120\n\nSample Output 2\n\n192\n\nThe second and third sushi have been swapped. Again, if he walks two meters clockwise from the initial place, he can eat a sushi of 80 kilocalories. If he walks six more meters counterclockwise this time, he can eat a sushi of 120 kilocalories. If he leaves now, the total nutrition taken in is 200 kilocalories, and the total energy consumed is 8 kilocalories, thus he can take in 192 kilocalories on balance, which is the largest possible value.\n\nSample Input 3\n\n1 100000000000000\n50000000000000 1\n\nSample Output 3\n\n0\n\nEven though the only sushi is so far that it does not fit into a 32-bit integer, its nutritive value is low, thus he should immediately leave without doing anything.\n\nSample Input 4\n\n15 10000000000\n400000000 1000000000\n800000000 1000000000\n1900000000 1000000000\n2400000000 1000000000\n2900000000 1000000000\n3300000000 1000000000\n3700000000 1000000000\n3800000000 1000000000\n4000000000 1000000000\n4100000000 1000000000\n5200000000 1000000000\n6600000000 1000000000\n8000000000 1000000000\n9300000000 1000000000\n9700000000 1000000000\n\nSample Output 4\n\n6500000000\n\nAll these sample inputs above are included in the test set for the partial score.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2924, "cpu_time_ms": 2112, "memory_kb": 122884}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s383514032", "group_id": "codeNet:p03379", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n val n = StdIn.readLine().toInt\n val a = StdIn.readLine().split(' ').map(_.toInt)\n\n val mid = (n / 2) - 1\n val r = (0 until n).map { i =>\n val t = a.slice(0, i) ++ a.slice(i+1, n)\n val s = t.sorted\n //println(s.mkString(\" \"))\n s(mid)\n }\n\n r.foreach(println)\n\n}", "language": "Scala", "metadata": {"date": 1526005499, "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/s383514032.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s383514032", "user_id": "u895032849"}, "prompt_components": {"gold_output": "4\n3\n3\n4\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n val n = StdIn.readLine().toInt\n val a = StdIn.readLine().split(' ').map(_.toInt)\n\n val mid = (n / 2) - 1\n val r = (0 until n).map { i =>\n val t = a.slice(0, i) ++ a.slice(i+1, n)\n val s = t.sorted\n //println(s.mkString(\" \"))\n s(mid)\n }\n\n r.foreach(println)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2115, "memory_kb": 135308}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s549188741", "group_id": "codeNet:p03380", "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()).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 // aj >= n となる 最小の aj を返す\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 - 1)\n }\n // aj <= n となる最大の aj を 返す\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(0, upper)\n }\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\n val left = A(lowerBounds(center, i))\n val right = A(upperBounds(center, 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, 0, 0)\n }\n\n val (n, r) = solve(N, A)\n println(s\"$n $r\")\n }\n\n}\n\n", "language": "Scala", "metadata": {"date": 1576899505, "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/s549188741.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s549188741", "user_id": "u891387249"}, "prompt_components": {"gold_output": "11 6\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()).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 // aj >= n となる 最小の aj を返す\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 - 1)\n }\n // aj <= n となる最大の aj を 返す\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(0, upper)\n }\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\n val left = A(lowerBounds(center, i))\n val right = A(upperBounds(center, 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, 0, 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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2104, "cpu_time_ms": 860, "memory_kb": 54576}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s248519931", "group_id": "codeNet:p03381", "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 xs = getArray[Int]\n\n val xsSorted = xs.sorted\n val median1 = xsSorted(n / 2 - 1)\n val median2 = xsSorted(n / 2)\n\n n.times { i =>\n out.println(\n if (xs(i) <= median1) {\n median2\n } else {\n median1\n }\n )\n }\n\n out.flush()\n }\n}", "language": "Scala", "metadata": {"date": 1593657844, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/s248519931.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s248519931", "user_id": "u178269371"}, "prompt_components": {"gold_output": "4\n3\n3\n4\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 xs = getArray[Int]\n\n val xsSorted = xs.sorted\n val median1 = xsSorted(n / 2 - 1)\n val median2 = xsSorted(n / 2)\n\n n.times { i =>\n out.println(\n if (xs(i) <= median1) {\n median2\n } else {\n median1\n }\n )\n }\n\n out.flush()\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4012, "cpu_time_ms": 930, "memory_kb": 82000}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s832549660", "group_id": "codeNet:p03385", "input_text": "import scala.io.StdIn._\nobject Main extends App{\n val sc = new java.util.Scanner(System.in)\n var s = sc.next\n if(s.contains(\"a\")&&s.contains(\"b\")&&s.contains(\"c\")){\n println(\"Yes\")\n }\n else{\n println(\"No\")\n }\n}", "language": "Scala", "metadata": {"date": 1590359242, "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/s832549660.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s832549660", "user_id": "u662430503"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.io.StdIn._\nobject Main extends App{\n val sc = new java.util.Scanner(System.in)\n var s = sc.next\n if(s.contains(\"a\")&&s.contains(\"b\")&&s.contains(\"c\")){\n println(\"Yes\")\n }\n else{\n 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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 336, "memory_kb": 25540}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s275616528", "group_id": "codeNet:p03386", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val a, b, k = sc.nextInt()\n var ans = ((a until (a + k).min(b)) ++ ((b - k + 1).max(a) to b)).distinct\n ans.foreach(println)\n}\n", "language": "Scala", "metadata": {"date": 1600701587, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/s275616528.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s275616528", "user_id": "u191819389"}, "prompt_components": {"gold_output": "3\n4\n7\n8\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 var ans = ((a until (a + k).min(b)) ++ ((b - k + 1).max(a) to b)).distinct\n ans.foreach(println)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nPrint all the integers that satisfies the following in ascending order:\n\nAmong the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.\n\nConstraints\n\n1 \\leq A \\leq B \\leq 10^9\n\n1 \\leq K \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint all the integers that satisfies the condition above in ascending order.\n\nSample Input 1\n\n3 8 2\n\nSample Output 1\n\n3\n4\n7\n8\n\n3 is the first smallest integer among the integers between 3 and 8.\n\n4 is the second smallest integer among the integers between 3 and 8.\n\n7 is the second largest integer among the integers between 3 and 8.\n\n8 is the first largest integer among the integers between 3 and 8.\n\nSample Input 2\n\n4 8 3\n\nSample Output 2\n\n4\n5\n6\n7\n8\n\nSample Input 3\n\n2 9 100\n\nSample Output 3\n\n2\n3\n4\n5\n6\n7\n8\n9", "sample_input": "3 8 2\n"}, "reference_outputs": ["3\n4\n7\n8\n"], "source_document_id": "p03386", "source_text": "Score : 200 points\n\nProblem Statement\n\nPrint all the integers that satisfies the following in ascending order:\n\nAmong the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.\n\nConstraints\n\n1 \\leq A \\leq B \\leq 10^9\n\n1 \\leq K \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint all the integers that satisfies the condition above in ascending order.\n\nSample Input 1\n\n3 8 2\n\nSample Output 1\n\n3\n4\n7\n8\n\n3 is the first smallest integer among the integers between 3 and 8.\n\n4 is the second smallest integer among the integers between 3 and 8.\n\n7 is the second largest integer among the integers between 3 and 8.\n\n8 is the first largest integer among the integers between 3 and 8.\n\nSample Input 2\n\n4 8 3\n\nSample Output 2\n\n4\n5\n6\n7\n8\n\nSample Input 3\n\n2 9 100\n\nSample Output 3\n\n2\n3\n4\n5\n6\n7\n8\n9", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 201, "cpu_time_ms": 517, "memory_kb": 55316}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s491300586", "group_id": "codeNet:p03386", "input_text": "import scala.collection.generic.CanBuild\nimport scala.io.StdIn\nimport scala.language.higherKinds\n\n// TODO: write well formed Docs!\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\nobject StdInScanner {\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 a line\n def readLine: StdInScanner[String] = StdInScanner(s => s.readLine().trim)\n // read a line as Int\n def readLnInt: StdInScanner[Int] = StdInScanner(s => s.readInt())\n // read a line as BigInt\n def readLnBigInt: StdInScanner[BigInt] = readLine.map(BigInt(_))\n\n // read tokens (separated by \"sep\") from a line, and store them in an array\n def readTokens(sep: String): StdInScanner[Array[String]] =\n readLine.map(_.split(sep).map(_.trim))\n // read tokens (separated by \"sep\") from a line, and store them in a collection (type \"C\")\n def readTokensTo[C[_]](sep: String)(implicit cb: CanBuild[String, C[String]]): StdInScanner[C[String]] =\n readTokens(sep).map(_.to[C])\n\n\n // read \"n\" lines, and store them in an array\n def readLines(n: Int): StdInScanner[Array[String]] =\n StdInScanner(s => Array.fill(n)(s.readLine().trim))\n // read \"n\" lines, and store them in a collection \"C\"\n def readLinesTo[C[_]](n: Int)(implicit cb: CanBuild[String, C[String]]): StdInScanner[C[String]] =\n readLines(n).map(_.to[C])\n\n // read \"n\" ints from lines. and store them in an array\n def readInts(n: Int): StdInScanner[Array[Int]] =\n StdInScanner(s => Array.fill(n)(s.readInt()))\n // read \"n\" ints from lines. and store them in a collection \"C\"\n def readIntsTo[C[_]](n: Int)(implicit cb: CanBuild[Int, C[Int]]): StdInScanner[C[Int]] =\n readInts(n).map(_.to[C])\n\n // read a table of \"n\" rows\n def readTable(rows: Int, sep: String = \" \"): StdInScanner[Array[Array[String]]] =\n readLines(rows).map{ lns =>\n lns.map(ln => ln.split(sep).map(tkn => tkn.trim))\n }\n\n // read a 2D int matrix of \"n\" rows, stored in an array of arrays\n def readIntMatrix(rows: Int, sep: String = \" \"): StdInScanner[Array[Array[Int]]] =\n readLines(rows).map{ lns =>\n lns.map(ln => ln.split(sep).map(tkn => tkn.toInt))\n }\n\n // read a 2D int matrix of \"n\" rows, stored in a collection of collections (\"C[C[Int]\")\n def readIntMatrixTo[C[_]](rows: Int, sep: String = \" \")(implicit cb1: CanBuild[Int, C[Int]] ,cb2: CanBuild[C[Int], C[C[Int]]]): StdInScanner[C[C[Int]]] =\n readIntMatrix(rows, sep).map { mat =>\n mat.map(row => row.to[C]).to[C]\n }\n}\n\nobject Main {\n\n import StdInScanner._\n\n def main(args: Array[String]) = {\n def abk = readTokens(\" \").map(_.map(_.toInt)).run\n val Array(a, b, k) = abk\n val s = scala.collection.mutable.TreeSet.empty[Int]\n for (i <- 0 until k) {\n if(a + i <= b) {\n s += (a + i)\n }\n if(b - i >= a) {\n s += (b - i)\n }\n }\n\n s.foreach(println)\n }\n}\n", "language": "Scala", "metadata": {"date": 1523150316, "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/s491300586.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s491300586", "user_id": "u715634684"}, "prompt_components": {"gold_output": "3\n4\n7\n8\n", "input_to_evaluate": "import scala.collection.generic.CanBuild\nimport scala.io.StdIn\nimport scala.language.higherKinds\n\n// TODO: write well formed Docs!\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\nobject StdInScanner {\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 a line\n def readLine: StdInScanner[String] = StdInScanner(s => s.readLine().trim)\n // read a line as Int\n def readLnInt: StdInScanner[Int] = StdInScanner(s => s.readInt())\n // read a line as BigInt\n def readLnBigInt: StdInScanner[BigInt] = readLine.map(BigInt(_))\n\n // read tokens (separated by \"sep\") from a line, and store them in an array\n def readTokens(sep: String): StdInScanner[Array[String]] =\n readLine.map(_.split(sep).map(_.trim))\n // read tokens (separated by \"sep\") from a line, and store them in a collection (type \"C\")\n def readTokensTo[C[_]](sep: String)(implicit cb: CanBuild[String, C[String]]): StdInScanner[C[String]] =\n readTokens(sep).map(_.to[C])\n\n\n // read \"n\" lines, and store them in an array\n def readLines(n: Int): StdInScanner[Array[String]] =\n StdInScanner(s => Array.fill(n)(s.readLine().trim))\n // read \"n\" lines, and store them in a collection \"C\"\n def readLinesTo[C[_]](n: Int)(implicit cb: CanBuild[String, C[String]]): StdInScanner[C[String]] =\n readLines(n).map(_.to[C])\n\n // read \"n\" ints from lines. and store them in an array\n def readInts(n: Int): StdInScanner[Array[Int]] =\n StdInScanner(s => Array.fill(n)(s.readInt()))\n // read \"n\" ints from lines. and store them in a collection \"C\"\n def readIntsTo[C[_]](n: Int)(implicit cb: CanBuild[Int, C[Int]]): StdInScanner[C[Int]] =\n readInts(n).map(_.to[C])\n\n // read a table of \"n\" rows\n def readTable(rows: Int, sep: String = \" \"): StdInScanner[Array[Array[String]]] =\n readLines(rows).map{ lns =>\n lns.map(ln => ln.split(sep).map(tkn => tkn.trim))\n }\n\n // read a 2D int matrix of \"n\" rows, stored in an array of arrays\n def readIntMatrix(rows: Int, sep: String = \" \"): StdInScanner[Array[Array[Int]]] =\n readLines(rows).map{ lns =>\n lns.map(ln => ln.split(sep).map(tkn => tkn.toInt))\n }\n\n // read a 2D int matrix of \"n\" rows, stored in a collection of collections (\"C[C[Int]\")\n def readIntMatrixTo[C[_]](rows: Int, sep: String = \" \")(implicit cb1: CanBuild[Int, C[Int]] ,cb2: CanBuild[C[Int], C[C[Int]]]): StdInScanner[C[C[Int]]] =\n readIntMatrix(rows, sep).map { mat =>\n mat.map(row => row.to[C]).to[C]\n }\n}\n\nobject Main {\n\n import StdInScanner._\n\n def main(args: Array[String]) = {\n def abk = readTokens(\" \").map(_.map(_.toInt)).run\n val Array(a, b, k) = abk\n val s = scala.collection.mutable.TreeSet.empty[Int]\n for (i <- 0 until k) {\n if(a + i <= b) {\n s += (a + i)\n }\n if(b - i >= a) {\n s += (b - i)\n }\n }\n\n s.foreach(println)\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nPrint all the integers that satisfies the following in ascending order:\n\nAmong the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.\n\nConstraints\n\n1 \\leq A \\leq B \\leq 10^9\n\n1 \\leq K \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint all the integers that satisfies the condition above in ascending order.\n\nSample Input 1\n\n3 8 2\n\nSample Output 1\n\n3\n4\n7\n8\n\n3 is the first smallest integer among the integers between 3 and 8.\n\n4 is the second smallest integer among the integers between 3 and 8.\n\n7 is the second largest integer among the integers between 3 and 8.\n\n8 is the first largest integer among the integers between 3 and 8.\n\nSample Input 2\n\n4 8 3\n\nSample Output 2\n\n4\n5\n6\n7\n8\n\nSample Input 3\n\n2 9 100\n\nSample Output 3\n\n2\n3\n4\n5\n6\n7\n8\n9", "sample_input": "3 8 2\n"}, "reference_outputs": ["3\n4\n7\n8\n"], "source_document_id": "p03386", "source_text": "Score : 200 points\n\nProblem Statement\n\nPrint all the integers that satisfies the following in ascending order:\n\nAmong the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.\n\nConstraints\n\n1 \\leq A \\leq B \\leq 10^9\n\n1 \\leq K \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint all the integers that satisfies the condition above in ascending order.\n\nSample Input 1\n\n3 8 2\n\nSample Output 1\n\n3\n4\n7\n8\n\n3 is the first smallest integer among the integers between 3 and 8.\n\n4 is the second smallest integer among the integers between 3 and 8.\n\n7 is the second largest integer among the integers between 3 and 8.\n\n8 is the first largest integer among the integers between 3 and 8.\n\nSample Input 2\n\n4 8 3\n\nSample Output 2\n\n4\n5\n6\n7\n8\n\nSample Input 3\n\n2 9 100\n\nSample Output 3\n\n2\n3\n4\n5\n6\n7\n8\n9", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3342, "cpu_time_ms": 342, "memory_kb": 25540}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s330228285", "group_id": "codeNet:p03400", "input_text": "\nobject Main extends App {\n val sc = new java.util.Scanner(System.in) \n val n = sc.nextInt()\n val d = sc.nextInt()\n val x = sc.nextInt() \n val ret = for (i <- 1 to n) yield {\n calc(0, sc.nextInt(), List()).length\n }\n println(ret.sum + x)\n \n def calc(i: Int, a: Int, acc: List[Int]): List[Int] = {\n if (!acc.isEmpty && d < i*a+1) {\n acc\n } else {\n calc(i+1, a, acc:+(i*a+1))\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1598417366, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03400.html", "problem_id": "p03400", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03400/input.txt", "sample_output_relpath": "derived/input_output/data/p03400/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03400/Scala/s330228285.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s330228285", "user_id": "u396472025"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "\nobject Main extends App {\n val sc = new java.util.Scanner(System.in) \n val n = sc.nextInt()\n val d = sc.nextInt()\n val x = sc.nextInt() \n val ret = for (i <- 1 to n) yield {\n calc(0, sc.nextInt(), List()).length\n }\n println(ret.sum + x)\n \n def calc(i: Int, a: Int, acc: List[Int]): List[Int] = {\n if (!acc.isEmpty && d < i*a+1) {\n acc\n } else {\n calc(i+1, a, acc:+(i*a+1))\n }\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSome number of chocolate pieces were prepared for a training camp.\nThe camp had N participants and lasted for D days.\nThe i-th participant (1 \\leq i \\leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on.\nAs a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces.\n\nFind the number of chocolate pieces prepared at the beginning of the camp.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq D \\leq 100\n\n1 \\leq X \\leq 100\n\n1 \\leq A_i \\leq 100 (1 \\leq i \\leq N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD X\nA_1\nA_2\n:\nA_N\n\nOutput\n\nFind the number of chocolate pieces prepared at the beginning of the camp.\n\nSample Input 1\n\n3\n7 1\n2\n5\n10\n\nSample Output 1\n\n8\n\nThe camp has 3 participants and lasts for 7 days.\nEach participant eats chocolate pieces as follows:\n\nThe first participant eats one chocolate piece on Day 1, 3, 5 and 7, for a total of four.\n\nThe second participant eats one chocolate piece on Day 1 and 6, for a total of two.\n\nThe third participant eats one chocolate piece only on Day 1, for a total of one.\n\nSince the number of pieces remaining at the end of the camp is one, the number of pieces prepared at the beginning of the camp is 1 + 4 + 2 + 1 = 8.\n\nSample Input 2\n\n2\n8 20\n1\n10\n\nSample Output 2\n\n29\n\nSample Input 3\n\n5\n30 44\n26\n18\n81\n18\n6\n\nSample Output 3\n\n56", "sample_input": "3\n7 1\n2\n5\n10\n"}, "reference_outputs": ["8\n"], "source_document_id": "p03400", "source_text": "Score : 200 points\n\nProblem Statement\n\nSome number of chocolate pieces were prepared for a training camp.\nThe camp had N participants and lasted for D days.\nThe i-th participant (1 \\leq i \\leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on.\nAs a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces.\n\nFind the number of chocolate pieces prepared at the beginning of the camp.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq D \\leq 100\n\n1 \\leq X \\leq 100\n\n1 \\leq A_i \\leq 100 (1 \\leq i \\leq N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD X\nA_1\nA_2\n:\nA_N\n\nOutput\n\nFind the number of chocolate pieces prepared at the beginning of the camp.\n\nSample Input 1\n\n3\n7 1\n2\n5\n10\n\nSample Output 1\n\n8\n\nThe camp has 3 participants and lasts for 7 days.\nEach participant eats chocolate pieces as follows:\n\nThe first participant eats one chocolate piece on Day 1, 3, 5 and 7, for a total of four.\n\nThe second participant eats one chocolate piece on Day 1 and 6, for a total of two.\n\nThe third participant eats one chocolate piece only on Day 1, for a total of one.\n\nSince the number of pieces remaining at the end of the camp is one, the number of pieces prepared at the beginning of the camp is 1 + 4 + 2 + 1 = 8.\n\nSample Input 2\n\n2\n8 20\n1\n10\n\nSample Output 2\n\n29\n\nSample Input 3\n\n5\n30 44\n26\n18\n81\n18\n6\n\nSample Output 3\n\n56", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 415, "cpu_time_ms": 513, "memory_kb": 55396}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s997764131", "group_id": "codeNet:p03408", "input_text": "\nobject Main extends App {\n \n val sc = new java.util.Scanner(System.in)\n val n = Array.fill(sc.nextInt())(sc.next()).groupMapReduce(identity)(_ => 1)(_ + _)\n val m = Array.fill(sc.nextInt())(sc.next()).groupMapReduce(identity)(_ => 1)(_ + _)\n val ans = n.keys.map(key => n.getOrElse(key, 0) - m.getOrElse(key, 0)).max\n println(if (ans < 0) 0 else ans)\n}\n", "language": "Scala", "metadata": {"date": 1600396098, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03408.html", "problem_id": "p03408", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03408/input.txt", "sample_output_relpath": "derived/input_output/data/p03408/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03408/Scala/s997764131.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s997764131", "user_id": "u396472025"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "\nobject Main extends App {\n \n val sc = new java.util.Scanner(System.in)\n val n = Array.fill(sc.nextInt())(sc.next()).groupMapReduce(identity)(_ => 1)(_ + _)\n val m = Array.fill(sc.nextInt())(sc.next()).groupMapReduce(identity)(_ => 1)(_ + _)\n val ans = n.keys.map(key => n.getOrElse(key, 0) - m.getOrElse(key, 0)).max\n println(if (ans < 0) 0 else ans)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has N blue cards and M red cards.\nA string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i.\n\nTakahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen.\n\nHere, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces atcoder, he will not earn money even if there are blue cards with atcoderr, atcode, btcoder, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.)\n\nAt most how much can he earn on balance?\n\nNote that the same string may be written on multiple cards.\n\nConstraints\n\nN and M are integers.\n\n1 \\leq N, M \\leq 100\n\ns_1, s_2, ..., s_N, t_1, t_2, ..., t_M are all strings of lengths between 1 and 10 (inclusive) consisting of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\nM\nt_1\nt_2\n:\nt_M\n\nOutput\n\nIf Takahashi can earn at most X yen on balance, print X.\n\nSample Input 1\n\n3\napple\norange\napple\n1\ngrape\n\nSample Output 1\n\n2\n\nHe can earn 2 yen by announcing apple.\n\nSample Input 2\n\n3\napple\norange\napple\n5\napple\napple\napple\napple\napple\n\nSample Output 2\n\n1\n\nIf he announces apple, he will lose 3 yen. If he announces orange, he can earn 1 yen.\n\nSample Input 3\n\n1\nvoldemort\n10\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\n\nSample Output 3\n\n0\n\nIf he announces voldemort, he will lose 9 yen. If he announces orange, for example, he can avoid losing a yen.\n\nSample Input 4\n\n6\nred\nred\nblue\nyellow\nyellow\nred\n5\nred\nred\nyellow\ngreen\nblue\n\nSample Output 4\n\n1", "sample_input": "3\napple\norange\napple\n1\ngrape\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03408", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has N blue cards and M red cards.\nA string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i.\n\nTakahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen.\n\nHere, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces atcoder, he will not earn money even if there are blue cards with atcoderr, atcode, btcoder, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.)\n\nAt most how much can he earn on balance?\n\nNote that the same string may be written on multiple cards.\n\nConstraints\n\nN and M are integers.\n\n1 \\leq N, M \\leq 100\n\ns_1, s_2, ..., s_N, t_1, t_2, ..., t_M are all strings of lengths between 1 and 10 (inclusive) consisting of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\nM\nt_1\nt_2\n:\nt_M\n\nOutput\n\nIf Takahashi can earn at most X yen on balance, print X.\n\nSample Input 1\n\n3\napple\norange\napple\n1\ngrape\n\nSample Output 1\n\n2\n\nHe can earn 2 yen by announcing apple.\n\nSample Input 2\n\n3\napple\norange\napple\n5\napple\napple\napple\napple\napple\n\nSample Output 2\n\n1\n\nIf he announces apple, he will lose 3 yen. If he announces orange, he can earn 1 yen.\n\nSample Input 3\n\n1\nvoldemort\n10\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\n\nSample Output 3\n\n0\n\nIf he announces voldemort, he will lose 9 yen. If he announces orange, for example, he can avoid losing a yen.\n\nSample Input 4\n\n6\nred\nred\nblue\nyellow\nyellow\nred\n5\nred\nred\nyellow\ngreen\nblue\n\nSample Output 4\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 360, "cpu_time_ms": 533, "memory_kb": 56048}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s831206872", "group_id": "codeNet:p03409", "input_text": "import scala.io.StdIn\nobject Main extends App {\n case class Point(x: Int, y: Int)\n def readPoints(n: Int): List[Point] = (0 until n).foldLeft(List.empty[Point]){\n (acc, _) =>\n val wkp = StdIn.readLine().trim.split(' ').map(_.toInt)\n Point(wkp(0), wkp(1)) :: acc\n }\n \n def comparePoint(red: Point, blue: Point): Boolean = red.x < blue.x && red.y < blue.y\n \n val pointCount = StdIn.readLine().trim.toInt\n val redPoints = readPoints(pointCount).sortBy(e => (e.x, e.y))\n val bluePoints = readPoints(pointCount).sortBy(e => (e.x, e.y))\n \n val wk = redPoints.map{ red =>\n bluePoints.map{ blue =>\n (red, blue)\n }\n }.flatten.filter(e => comparePoint(e._1, e._2)).groupBy(e => e._1).toList.sortBy(l => (l._2.size, -l._1.x, -l._1.y))\n \n //println(wk)\n val result = wk.foldLeft(0, Set.empty[Point], Set.empty[Point]){ (acc, e) =>\n var cnt = acc._1\n var checkRed = acc._2\n var checkBlue = acc._3\n e._2.foreach{ be =>\n cnt = if(checkRed.contains(e._1) || checkBlue.contains(be._2)){\n cnt\n } else {\n checkRed += e._1\n checkBlue += be._2\n cnt + 1\n }\n }\n \n (cnt, checkRed, checkBlue)\n\n }\n\n println(result._1)\n \n}\n", "language": "Scala", "metadata": {"date": 1521770059, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03409.html", "problem_id": "p03409", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03409/input.txt", "sample_output_relpath": "derived/input_output/data/p03409/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03409/Scala/s831206872.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s831206872", "user_id": "u895032849"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.io.StdIn\nobject Main extends App {\n case class Point(x: Int, y: Int)\n def readPoints(n: Int): List[Point] = (0 until n).foldLeft(List.empty[Point]){\n (acc, _) =>\n val wkp = StdIn.readLine().trim.split(' ').map(_.toInt)\n Point(wkp(0), wkp(1)) :: acc\n }\n \n def comparePoint(red: Point, blue: Point): Boolean = red.x < blue.x && red.y < blue.y\n \n val pointCount = StdIn.readLine().trim.toInt\n val redPoints = readPoints(pointCount).sortBy(e => (e.x, e.y))\n val bluePoints = readPoints(pointCount).sortBy(e => (e.x, e.y))\n \n val wk = redPoints.map{ red =>\n bluePoints.map{ blue =>\n (red, blue)\n }\n }.flatten.filter(e => comparePoint(e._1, e._2)).groupBy(e => e._1).toList.sortBy(l => (l._2.size, -l._1.x, -l._1.y))\n \n //println(wk)\n val result = wk.foldLeft(0, Set.empty[Point], Set.empty[Point]){ (acc, e) =>\n var cnt = acc._1\n var checkRed = acc._2\n var checkBlue = acc._3\n e._2.foreach{ be =>\n cnt = if(checkRed.contains(e._1) || checkBlue.contains(be._2)){\n cnt\n } else {\n checkRed += e._1\n checkBlue += be._2\n cnt + 1\n }\n }\n \n (cnt, checkRed, checkBlue)\n\n }\n\n println(result._1)\n \n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nOn a two-dimensional plane, there are N red points and N blue points.\nThe coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i).\n\nA red point and a blue point can form a friendly pair when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point.\n\nAt most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs.\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq N \\leq 100\n\n0 \\leq a_i, b_i, c_i, d_i < 2N\n\na_1, a_2, ..., a_N, c_1, c_2, ..., c_N are all different.\n\nb_1, b_2, ..., b_N, d_1, d_2, ..., d_N are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\na_2 b_2\n:\na_N b_N\nc_1 d_1\nc_2 d_2\n:\nc_N d_N\n\nOutput\n\nPrint the maximum number of friendly pairs.\n\nSample Input 1\n\n3\n2 0\n3 1\n1 3\n4 2\n0 4\n5 5\n\nSample Output 1\n\n2\n\nFor example, you can pair (2, 0) and (4, 2), then (3, 1) and (5, 5).\n\nSample Input 2\n\n3\n0 0\n1 1\n5 2\n2 3\n3 4\n4 5\n\nSample Output 2\n\n2\n\nFor example, you can pair (0, 0) and (2, 3), then (1, 1) and (3, 4).\n\nSample Input 3\n\n2\n2 2\n3 3\n0 0\n1 1\n\nSample Output 3\n\n0\n\nIt is possible that no pair can be formed.\n\nSample Input 4\n\n5\n0 0\n7 3\n2 2\n4 8\n1 6\n8 5\n6 9\n5 4\n9 1\n3 7\n\nSample Output 4\n\n5\n\nSample Input 5\n\n5\n0 0\n1 1\n5 5\n6 6\n7 7\n2 2\n3 3\n4 4\n8 8\n9 9\n\nSample Output 5\n\n4", "sample_input": "3\n2 0\n3 1\n1 3\n4 2\n0 4\n5 5\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03409", "source_text": "Score : 400 points\n\nProblem Statement\n\nOn a two-dimensional plane, there are N red points and N blue points.\nThe coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i).\n\nA red point and a blue point can form a friendly pair when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point.\n\nAt most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs.\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq N \\leq 100\n\n0 \\leq a_i, b_i, c_i, d_i < 2N\n\na_1, a_2, ..., a_N, c_1, c_2, ..., c_N are all different.\n\nb_1, b_2, ..., b_N, d_1, d_2, ..., d_N are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\na_2 b_2\n:\na_N b_N\nc_1 d_1\nc_2 d_2\n:\nc_N d_N\n\nOutput\n\nPrint the maximum number of friendly pairs.\n\nSample Input 1\n\n3\n2 0\n3 1\n1 3\n4 2\n0 4\n5 5\n\nSample Output 1\n\n2\n\nFor example, you can pair (2, 0) and (4, 2), then (3, 1) and (5, 5).\n\nSample Input 2\n\n3\n0 0\n1 1\n5 2\n2 3\n3 4\n4 5\n\nSample Output 2\n\n2\n\nFor example, you can pair (0, 0) and (2, 3), then (1, 1) and (3, 4).\n\nSample Input 3\n\n2\n2 2\n3 3\n0 0\n1 1\n\nSample Output 3\n\n0\n\nIt is possible that no pair can be formed.\n\nSample Input 4\n\n5\n0 0\n7 3\n2 2\n4 8\n1 6\n8 5\n6 9\n5 4\n9 1\n3 7\n\nSample Output 4\n\n5\n\nSample Input 5\n\n5\n0 0\n1 1\n5 5\n6 6\n7 7\n2 2\n3 3\n4 4\n8 8\n9 9\n\nSample Output 5\n\n4", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1206, "cpu_time_ms": 436, "memory_kb": 28808}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s475500428", "group_id": "codeNet:p03415", "input_text": "object Main extends App{\nval cs = for (i<-1 to 3) yield scala.io.StdIn.readLine().toList\n\nval result = for(i<-0 until 3) yield cs(i)(i)\n\nprintln(result.foldLeft(\"\")((a,b)=>a+b))\n}", "language": "Scala", "metadata": {"date": 1560409386, "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/s475500428.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s475500428", "user_id": "u238510421"}, "prompt_components": {"gold_output": "abc\n", "input_to_evaluate": "object Main extends App{\nval cs = for (i<-1 to 3) yield scala.io.StdIn.readLine().toList\n\nval result = for(i<-0 until 3) yield cs(i)(i)\n\nprintln(result.foldLeft(\"\")((a,b)=>a+b))\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have a 3×3 square grid, where each square contains a lowercase English letters.\nThe letter in the square at the i-th row from the top and j-th column from the left is c_{ij}.\n\nPrint the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.\n\nConstraints\n\nInput consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nc_{11}c_{12}c_{13}\nc_{21}c_{22}c_{23}\nc_{31}c_{32}c_{33}\n\nOutput\n\nPrint the string of length 3 that can be obtained by concatenating the letters on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.\n\nSample Input 1\n\nant\nobe\nrec\n\nSample Output 1\n\nabc\n\nThe letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid are a, b and c from top-right to bottom-left. Concatenate these letters and print abc.\n\nSample Input 2\n\nedu\ncat\nion\n\nSample Output 2\n\nean", "sample_input": "ant\nobe\nrec\n"}, "reference_outputs": ["abc\n"], "source_document_id": "p03415", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have a 3×3 square grid, where each square contains a lowercase English letters.\nThe letter in the square at the i-th row from the top and j-th column from the left is c_{ij}.\n\nPrint the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.\n\nConstraints\n\nInput consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nc_{11}c_{12}c_{13}\nc_{21}c_{22}c_{23}\nc_{31}c_{32}c_{33}\n\nOutput\n\nPrint the string of length 3 that can be obtained by concatenating the letters on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.\n\nSample Input 1\n\nant\nobe\nrec\n\nSample Output 1\n\nabc\n\nThe letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid are a, b and c from top-right to bottom-left. Concatenate these letters and print abc.\n\nSample Input 2\n\nedu\ncat\nion\n\nSample Output 2\n\nean", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 179, "cpu_time_ms": 341, "memory_kb": 25528}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s406446971", "group_id": "codeNet:p03416", "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 sc: Scanner = new Scanner(input)\n val a,b = sc.nextInt\n var sum = 0\n for (i <- a to b) {\n val is = i.toString\n if (is(0) == is(4) && is(1) == is(3)) sum += 1\n }\n sum.toString\n }\n\n val tests = List(\n \"\"\"11009 11332\"\"\".stripMargin -> \"\"\"4\"\"\",\n \"\"\"31415 92653\"\"\".stripMargin -> \"\"\"612\"\"\"\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": 1566190677, "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/s406446971.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s406446971", "user_id": "u334087399"}, "prompt_components": {"gold_output": "4\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 sc: Scanner = new Scanner(input)\n val a,b = sc.nextInt\n var sum = 0\n for (i <- a to b) {\n val is = i.toString\n if (is(0) == is(4) && is(1) == is(3)) sum += 1\n }\n sum.toString\n }\n\n val tests = List(\n \"\"\"11009 11332\"\"\".stripMargin -> \"\"\"4\"\"\",\n \"\"\"31415 92653\"\"\".stripMargin -> \"\"\"612\"\"\"\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\nFind the number of palindromic numbers among the integers between A and B (inclusive).\nHere, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward.\n\nConstraints\n\n10000 \\leq A \\leq B \\leq 99999\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the number of palindromic numbers among the integers between A and B (inclusive).\n\nSample Input 1\n\n11009 11332\n\nSample Output 1\n\n4\n\nThere are four integers that satisfy the conditions: 11011, 11111, 11211 and 11311.\n\nSample Input 2\n\n31415 92653\n\nSample Output 2\n\n612", "sample_input": "11009 11332\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03416", "source_text": "Score : 200 points\n\nProblem Statement\n\nFind the number of palindromic numbers among the integers between A and B (inclusive).\nHere, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward.\n\nConstraints\n\n10000 \\leq A \\leq B \\leq 99999\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the number of palindromic numbers among the integers between A and B (inclusive).\n\nSample Input 1\n\n11009 11332\n\nSample Output 1\n\n4\n\nThere are four integers that satisfy the conditions: 11011, 11111, 11211 and 11311.\n\nSample Input 2\n\n31415 92653\n\nSample Output 2\n\n612", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 991, "cpu_time_ms": 408, "memory_kb": 32840}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s422927476", "group_id": "codeNet:p03416", "input_text": "import scala.io.StdIn.{readLine}\n\nobject Main extends App {\n def isPalindromic(s: String): Boolean = {\n val (src, dst) = s.splitAt(s.length / 2 + 1)\n val taked = src.take(dst.length)\n taked == dst.reverse\n }\n\n def nPalindromic(input: String): Int = {\n val ints = input.split(\" \").map(_.toInt)\n nPalindromic(ints(0), ints(1))\n\n }\n\n def nPalindromic(start: Int, end: Int):Int = {\n Range(start, end).count(i => isPalindromic(i.toString))\n }\n\n println(nPalindromic(readLine()))\n}", "language": "Scala", "metadata": {"date": 1521176185, "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/s422927476.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s422927476", "user_id": "u586698246"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import scala.io.StdIn.{readLine}\n\nobject Main extends App {\n def isPalindromic(s: String): Boolean = {\n val (src, dst) = s.splitAt(s.length / 2 + 1)\n val taked = src.take(dst.length)\n taked == dst.reverse\n }\n\n def nPalindromic(input: String): Int = {\n val ints = input.split(\" \").map(_.toInt)\n nPalindromic(ints(0), ints(1))\n\n }\n\n def nPalindromic(start: Int, end: Int):Int = {\n Range(start, end).count(i => isPalindromic(i.toString))\n }\n\n println(nPalindromic(readLine()))\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nFind the number of palindromic numbers among the integers between A and B (inclusive).\nHere, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward.\n\nConstraints\n\n10000 \\leq A \\leq B \\leq 99999\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the number of palindromic numbers among the integers between A and B (inclusive).\n\nSample Input 1\n\n11009 11332\n\nSample Output 1\n\n4\n\nThere are four integers that satisfy the conditions: 11011, 11111, 11211 and 11311.\n\nSample Input 2\n\n31415 92653\n\nSample Output 2\n\n612", "sample_input": "11009 11332\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03416", "source_text": "Score : 200 points\n\nProblem Statement\n\nFind the number of palindromic numbers among the integers between A and B (inclusive).\nHere, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward.\n\nConstraints\n\n10000 \\leq A \\leq B \\leq 99999\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the number of palindromic numbers among the integers between A and B (inclusive).\n\nSample Input 1\n\n11009 11332\n\nSample Output 1\n\n4\n\nThere are four integers that satisfy the conditions: 11011, 11111, 11211 and 11311.\n\nSample Input 2\n\n31415 92653\n\nSample Output 2\n\n612", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 500, "cpu_time_ms": 581, "memory_kb": 40832}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s706434811", "group_id": "codeNet:p03417", "input_text": "\nimport scala.io.StdIn\n\nobject Main extends App {\n var a = StdIn.readLine().split(' ').map(_.toLong).sorted\n\n val n = a(0)\n val m = a(1)\n \n println(if (n == 1 && m == 1) 1 else if (n == 1 && m != 1) m - 2 else (n - 2) * (m - 2))\n\n}", "language": "Scala", "metadata": {"date": 1526096347, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03417.html", "problem_id": "p03417", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03417/input.txt", "sample_output_relpath": "derived/input_output/data/p03417/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03417/Scala/s706434811.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s706434811", "user_id": "u895032849"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "\nimport scala.io.StdIn\n\nobject Main extends App {\n var a = StdIn.readLine().split(' ').map(_.toLong).sorted\n\n val n = a(0)\n val m = a(1)\n \n println(if (n == 1 && m == 1) 1 else if (n == 1 && m != 1) m - 2 else (n - 2) * (m - 2))\n\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region.\nThe front and back sides of these cards can be distinguished, and initially every card faces up.\n\nWe will perform the following operation once for each square contains a card:\n\nFor each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square.\n\nIt can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed.\nFind the number of cards that face down after all the operations.\n\nConstraints\n\n1 \\leq N,M \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of cards that face down after all the operations.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n0\n\nWe will flip every card in any of the four operations. Thus, after all the operations, all cards face up.\n\nSample Input 2\n\n1 7\n\nSample Output 2\n\n5\n\nAfter all the operations, all cards except at both ends face down.\n\nSample Input 3\n\n314 1592\n\nSample Output 3\n\n496080", "sample_input": "2 2\n"}, "reference_outputs": ["0\n"], "source_document_id": "p03417", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region.\nThe front and back sides of these cards can be distinguished, and initially every card faces up.\n\nWe will perform the following operation once for each square contains a card:\n\nFor each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square.\n\nIt can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed.\nFind the number of cards that face down after all the operations.\n\nConstraints\n\n1 \\leq N,M \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of cards that face down after all the operations.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n0\n\nWe will flip every card in any of the four operations. Thus, after all the operations, all cards face up.\n\nSample Input 2\n\n1 7\n\nSample Output 2\n\n5\n\nAfter all the operations, all cards except at both ends face down.\n\nSample Input 3\n\n314 1592\n\nSample Output 3\n\n496080", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 322, "memory_kb": 25416}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s515684155", "group_id": "codeNet:p03417", "input_text": "object Main extends App {\n\n val In = io.StdIn.readLine()\n val A = In.split(\" \")\n\n val max:Int = A.max.toInt\n val min:Int = A.min.toInt\n\n //var arr = Array.ofDim[Int](A(0).toInt, A(1).toInt)\n\n var N = 0\n\n if (min == 1) {\n if (max == 1) {\n N = 1\n }else {\n N = max - 2\n }\n }\n\n if (min == 2) {\n N = 0\n }\n\n if (min >= 3){\n N = (A(0).toInt - 2) * (A(1).toInt - 2)\n }\n\n print(N)\n\n}\n", "language": "Scala", "metadata": {"date": 1521757452, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03417.html", "problem_id": "p03417", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03417/input.txt", "sample_output_relpath": "derived/input_output/data/p03417/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03417/Scala/s515684155.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s515684155", "user_id": "u290519059"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "object Main extends App {\n\n val In = io.StdIn.readLine()\n val A = In.split(\" \")\n\n val max:Int = A.max.toInt\n val min:Int = A.min.toInt\n\n //var arr = Array.ofDim[Int](A(0).toInt, A(1).toInt)\n\n var N = 0\n\n if (min == 1) {\n if (max == 1) {\n N = 1\n }else {\n N = max - 2\n }\n }\n\n if (min == 2) {\n N = 0\n }\n\n if (min >= 3){\n N = (A(0).toInt - 2) * (A(1).toInt - 2)\n }\n\n print(N)\n\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region.\nThe front and back sides of these cards can be distinguished, and initially every card faces up.\n\nWe will perform the following operation once for each square contains a card:\n\nFor each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square.\n\nIt can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed.\nFind the number of cards that face down after all the operations.\n\nConstraints\n\n1 \\leq N,M \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of cards that face down after all the operations.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n0\n\nWe will flip every card in any of the four operations. Thus, after all the operations, all cards face up.\n\nSample Input 2\n\n1 7\n\nSample Output 2\n\n5\n\nAfter all the operations, all cards except at both ends face down.\n\nSample Input 3\n\n314 1592\n\nSample Output 3\n\n496080", "sample_input": "2 2\n"}, "reference_outputs": ["0\n"], "source_document_id": "p03417", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region.\nThe front and back sides of these cards can be distinguished, and initially every card faces up.\n\nWe will perform the following operation once for each square contains a card:\n\nFor each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square.\n\nIt can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed.\nFind the number of cards that face down after all the operations.\n\nConstraints\n\n1 \\leq N,M \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of cards that face down after all the operations.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n0\n\nWe will flip every card in any of the four operations. Thus, after all the operations, all cards face up.\n\nSample Input 2\n\n1 7\n\nSample Output 2\n\n5\n\nAfter all the operations, all cards except at both ends face down.\n\nSample Input 3\n\n314 1592\n\nSample Output 3\n\n496080", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 415, "cpu_time_ms": 320, "memory_kb": 25520}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s995230973", "group_id": "codeNet:p03419", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val N, M = sc.nextLong()\n val reverseCount =\n (N, M) match {\n case (1, 1) => 1\n case (1, m) => m - 2\n case (n, 1) => n - 2\n case (n, m) => (n - 2) * (m - 2)\n }\n println(reverseCount)\n}\n", "language": "Scala", "metadata": {"date": 1595202405, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03419.html", "problem_id": "p03419", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03419/input.txt", "sample_output_relpath": "derived/input_output/data/p03419/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03419/Scala/s995230973.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s995230973", "user_id": "u737111725"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val N, M = sc.nextLong()\n val reverseCount =\n (N, M) match {\n case (1, 1) => 1\n case (1, m) => m - 2\n case (n, 1) => n - 2\n case (n, m) => (n - 2) * (m - 2)\n }\n println(reverseCount)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region.\nThe front and back sides of these cards can be distinguished, and initially every card faces up.\n\nWe will perform the following operation once for each square contains a card:\n\nFor each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square.\n\nIt can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed.\nFind the number of cards that face down after all the operations.\n\nConstraints\n\n1 \\leq N,M \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of cards that face down after all the operations.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n0\n\nWe will flip every card in any of the four operations. Thus, after all the operations, all cards face up.\n\nSample Input 2\n\n1 7\n\nSample Output 2\n\n5\n\nAfter all the operations, all cards except at both ends face down.\n\nSample Input 3\n\n314 1592\n\nSample Output 3\n\n496080", "sample_input": "2 2\n"}, "reference_outputs": ["0\n"], "source_document_id": "p03419", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region.\nThe front and back sides of these cards can be distinguished, and initially every card faces up.\n\nWe will perform the following operation once for each square contains a card:\n\nFor each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square.\n\nIt can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed.\nFind the number of cards that face down after all the operations.\n\nConstraints\n\n1 \\leq N,M \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of cards that face down after all the operations.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n0\n\nWe will flip every card in any of the four operations. Thus, after all the operations, all cards face up.\n\nSample Input 2\n\n1 7\n\nSample Output 2\n\n5\n\nAfter all the operations, all cards except at both ends face down.\n\nSample Input 3\n\n314 1592\n\nSample Output 3\n\n496080", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 285, "cpu_time_ms": 494, "memory_kb": 55284}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s863639720", "group_id": "codeNet:p03419", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val N, M = sc.nextInt()\n val reverseCount =\n N match {\n case 1 => M match {\n case 1 => 1\n case _ => M - 2\n }\n case _ => (N - 2) * (M - 2)\n }\n println(reverseCount)\n}\n", "language": "Scala", "metadata": {"date": 1595202088, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03419.html", "problem_id": "p03419", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03419/input.txt", "sample_output_relpath": "derived/input_output/data/p03419/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03419/Scala/s863639720.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s863639720", "user_id": "u737111725"}, "prompt_components": {"gold_output": "0\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 reverseCount =\n N match {\n case 1 => M match {\n case 1 => 1\n case _ => M - 2\n }\n case _ => (N - 2) * (M - 2)\n }\n println(reverseCount)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region.\nThe front and back sides of these cards can be distinguished, and initially every card faces up.\n\nWe will perform the following operation once for each square contains a card:\n\nFor each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square.\n\nIt can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed.\nFind the number of cards that face down after all the operations.\n\nConstraints\n\n1 \\leq N,M \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of cards that face down after all the operations.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n0\n\nWe will flip every card in any of the four operations. Thus, after all the operations, all cards face up.\n\nSample Input 2\n\n1 7\n\nSample Output 2\n\n5\n\nAfter all the operations, all cards except at both ends face down.\n\nSample Input 3\n\n314 1592\n\nSample Output 3\n\n496080", "sample_input": "2 2\n"}, "reference_outputs": ["0\n"], "source_document_id": "p03419", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region.\nThe front and back sides of these cards can be distinguished, and initially every card faces up.\n\nWe will perform the following operation once for each square contains a card:\n\nFor each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square.\n\nIt can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed.\nFind the number of cards that face down after all the operations.\n\nConstraints\n\n1 \\leq N,M \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of cards that face down after all the operations.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n0\n\nWe will flip every card in any of the four operations. Thus, after all the operations, all cards face up.\n\nSample Input 2\n\n1 7\n\nSample Output 2\n\n5\n\nAfter all the operations, all cards except at both ends face down.\n\nSample Input 3\n\n314 1592\n\nSample Output 3\n\n496080", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 275, "cpu_time_ms": 521, "memory_kb": 55308}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s151010493", "group_id": "codeNet:p03419", "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(converter)\n }\n\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 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, m) = get[Long, Long]\n\n out.println(\n if (n == 1) {\n if (m == 1) {\n 1\n } else {\n m - 2\n }\n } else {\n if (m == 1) {\n n - 2\n } else {\n (m - 2) * (n - 2)\n }\n }\n )\n\n out.flush()\n }\n}", "language": "Scala", "metadata": {"date": 1592616566, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03419.html", "problem_id": "p03419", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03419/input.txt", "sample_output_relpath": "derived/input_output/data/p03419/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03419/Scala/s151010493.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s151010493", "user_id": "u178269371"}, "prompt_components": {"gold_output": "0\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(converter)\n }\n\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 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, m) = get[Long, Long]\n\n out.println(\n if (n == 1) {\n if (m == 1) {\n 1\n } else {\n m - 2\n }\n } else {\n if (m == 1) {\n n - 2\n } else {\n (m - 2) * (n - 2)\n }\n }\n )\n\n out.flush()\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region.\nThe front and back sides of these cards can be distinguished, and initially every card faces up.\n\nWe will perform the following operation once for each square contains a card:\n\nFor each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square.\n\nIt can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed.\nFind the number of cards that face down after all the operations.\n\nConstraints\n\n1 \\leq N,M \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of cards that face down after all the operations.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n0\n\nWe will flip every card in any of the four operations. Thus, after all the operations, all cards face up.\n\nSample Input 2\n\n1 7\n\nSample Output 2\n\n5\n\nAfter all the operations, all cards except at both ends face down.\n\nSample Input 3\n\n314 1592\n\nSample Output 3\n\n496080", "sample_input": "2 2\n"}, "reference_outputs": ["0\n"], "source_document_id": "p03419", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region.\nThe front and back sides of these cards can be distinguished, and initially every card faces up.\n\nWe will perform the following operation once for each square contains a card:\n\nFor each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square.\n\nIt can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed.\nFind the number of cards that face down after all the operations.\n\nConstraints\n\n1 \\leq N,M \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of cards that face down after all the operations.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n0\n\nWe will flip every card in any of the four operations. Thus, after all the operations, all cards face up.\n\nSample Input 2\n\n1 7\n\nSample Output 2\n\n5\n\nAfter all the operations, all cards except at both ends face down.\n\nSample Input 3\n\n314 1592\n\nSample Output 3\n\n496080", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2626, "cpu_time_ms": 507, "memory_kb": 57028}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s687359516", "group_id": "codeNet:p03420", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val N, K = sc.nextLong\n\n var sum :Long = 0\n if (K == 0) {\n println(N * N)\n sys.exit\n }\n\n for (b <- K + 1 to N) {\n val x = N % b\n if (x >= K) {\n sum += (b - K) * (N / b) + x + 1 - K\n } else {\n sum += (b - K) * (N / b)\n }\n }\n\n println(sum)\n}", "language": "Scala", "metadata": {"date": 1526603065, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03420.html", "problem_id": "p03420", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03420/input.txt", "sample_output_relpath": "derived/input_output/data/p03420/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03420/Scala/s687359516.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s687359516", "user_id": "u290193605"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val N, K = sc.nextLong\n\n var sum :Long = 0\n if (K == 0) {\n println(N * N)\n sys.exit\n }\n\n for (b <- K + 1 to N) {\n val x = N % b\n if (x >= K) {\n sum += (b - K) * (N / b) + x + 1 - K\n } else {\n sum += (b - K) * (N / b)\n }\n }\n\n println(sum)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten.\nHe remembers that the remainder of a divided by b was greater than or equal to K.\nFind the number of possible pairs that he may have had.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq K \\leq N-1\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of possible pairs that he may have had.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n7\n\nThere are seven possible pairs: (2,3),(5,3),(2,4),(3,4),(2,5),(3,5) and (4,5).\n\nSample Input 2\n\n10 0\n\nSample Output 2\n\n100\n\nSample Input 3\n\n31415 9265\n\nSample Output 3\n\n287927211", "sample_input": "5 2\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03420", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten.\nHe remembers that the remainder of a divided by b was greater than or equal to K.\nFind the number of possible pairs that he may have had.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq K \\leq N-1\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of possible pairs that he may have had.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n7\n\nThere are seven possible pairs: (2,3),(5,3),(2,4),(3,4),(2,5),(3,5) and (4,5).\n\nSample Input 2\n\n10 0\n\nSample Output 2\n\n100\n\nSample Input 3\n\n31415 9265\n\nSample Output 3\n\n287927211", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 345, "cpu_time_ms": 395, "memory_kb": 32164}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s384810385", "group_id": "codeNet:p03421", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val N, A, B = sc.nextInt\n val X = N - A - B\n\n // A + B > N + 1 のとき実現不可能\n if ((A + B) > (N + 1) | N > A * B) {\n println(-1)\n sys.exit\n }\n\n // それ以外のとき、実現可能\n var arr = Array.emptyIntArray\n\n if (B != N) {\n for (i <- 1 to A) arr :+= i\n }\n\n if (A != N) {\n for (j <- N - B + 1 to N) arr +:= j\n }\n\n if (A > B) {\n for (k <- A + 1 to N - B) arr +:= k\n } else {\n for (k <- N - B to A + 1 by -1) arr +:= k\n }\n\n\n println(arr.mkString(\" \"))\n}", "language": "Scala", "metadata": {"date": 1526620301, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03421.html", "problem_id": "p03421", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03421/input.txt", "sample_output_relpath": "derived/input_output/data/p03421/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03421/Scala/s384810385.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s384810385", "user_id": "u290193605"}, "prompt_components": {"gold_output": "2 4 1 5 3\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val N, A, B = sc.nextInt\n val X = N - A - B\n\n // A + B > N + 1 のとき実現不可能\n if ((A + B) > (N + 1) | N > A * B) {\n println(-1)\n sys.exit\n }\n\n // それ以外のとき、実現可能\n var arr = Array.emptyIntArray\n\n if (B != N) {\n for (i <- 1 to A) arr :+= i\n }\n\n if (A != N) {\n for (j <- N - B + 1 to N) arr +:= j\n }\n\n if (A > B) {\n for (k <- A + 1 to N - B) arr +:= k\n } else {\n for (k <- N - B to A + 1 by -1) arr +:= k\n }\n\n\n println(arr.mkString(\" \"))\n}", "problem_context": "Score : 700 points\n\nProblem Statement\n\nDetermine if there exists a sequence obtained by permuting 1,2,...,N that satisfies the following conditions:\n\nThe length of its longest increasing subsequence is A.\n\nThe length of its longest decreasing subsequence is B.\n\nIf it exists, construct one such sequence.\n\nNotes\n\nA subsequence of a sequence P is a sequence that can be obtained by extracting some of the elements in P without changing the order.\n\nA longest increasing subsequence of a sequence P is a sequence with the maximum length among the subsequences of P that are monotonically increasing.\n\nSimilarly, a longest decreasing subsequence of a sequence P is a sequence with the maximum length among the subsequences of P that are monotonically decreasing.\n\nConstraints\n\n1 \\leq N,A,B \\leq 3\\times 10^5\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nIf there are no sequences that satisfy the conditions, print -1.\n\nOtherwise, print N integers. The i-th integer should be the i-th element of the sequence that you constructed.\n\nSample Input 1\n\n5 3 2\n\nSample Output 1\n\n2 4 1 5 3\n\nOne longest increasing subsequence of this sequence is {2,4,5}, and one longest decreasing subsequence of it is {4,3}.\n\nSample Input 2\n\n7 7 1\n\nSample Output 2\n\n1 2 3 4 5 6 7\n\nSample Input 3\n\n300000 300000 300000\n\nSample Output 3\n\n-1", "sample_input": "5 3 2\n"}, "reference_outputs": ["2 4 1 5 3\n"], "source_document_id": "p03421", "source_text": "Score : 700 points\n\nProblem Statement\n\nDetermine if there exists a sequence obtained by permuting 1,2,...,N that satisfies the following conditions:\n\nThe length of its longest increasing subsequence is A.\n\nThe length of its longest decreasing subsequence is B.\n\nIf it exists, construct one such sequence.\n\nNotes\n\nA subsequence of a sequence P is a sequence that can be obtained by extracting some of the elements in P without changing the order.\n\nA longest increasing subsequence of a sequence P is a sequence with the maximum length among the subsequences of P that are monotonically increasing.\n\nSimilarly, a longest decreasing subsequence of a sequence P is a sequence with the maximum length among the subsequences of P that are monotonically decreasing.\n\nConstraints\n\n1 \\leq N,A,B \\leq 3\\times 10^5\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nIf there are no sequences that satisfy the conditions, print -1.\n\nOtherwise, print N integers. The i-th integer should be the i-th element of the sequence that you constructed.\n\nSample Input 1\n\n5 3 2\n\nSample Output 1\n\n2 4 1 5 3\n\nOne longest increasing subsequence of this sequence is {2,4,5}, and one longest decreasing subsequence of it is {4,3}.\n\nSample Input 2\n\n7 7 1\n\nSample Output 2\n\n1 2 3 4 5 6 7\n\nSample Input 3\n\n300000 300000 300000\n\nSample Output 3\n\n-1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2111, "memory_kb": 112704}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s024816944", "group_id": "codeNet:p03424", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n val n = StdIn.readLine\n val size = StdIn.readLine.split(\" \").toList\n .distinct.size\n\n println(if (size == 3) \"Three\" else \"Four\")\n}", "language": "Scala", "metadata": {"date": 1542844031, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03424.html", "problem_id": "p03424", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03424/input.txt", "sample_output_relpath": "derived/input_output/data/p03424/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03424/Scala/s024816944.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s024816944", "user_id": "u217010036"}, "prompt_components": {"gold_output": "Four\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n val n = StdIn.readLine\n val size = StdIn.readLine.split(\" \").toList\n .distinct.size\n\n println(if (size == 3) \"Three\" else \"Four\")\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIn Japan, people make offerings called hina arare, colorful crackers, on March 3.\n\nWe have a bag that contains N hina arare. (From here, we call them arare.)\n\nIt is known that the bag either contains arare in three colors: pink, white and green, or contains arare in four colors: pink, white, green and yellow.\n\nWe have taken out the arare in the bag one by one, and the color of the i-th arare was S_i, where colors are represented as follows - pink: P, white: W, green: G, yellow: Y.\n\nIf the number of colors of the arare in the bag was three, print Three; if the number of colors was four, print Four.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nS_i is P, W, G or Y.\n\nThere always exist i, j and k such that S_i=P, S_j=W and S_k=G.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1 S_2 ... S_N\n\nOutput\n\nIf the number of colors of the arare in the bag was three, print Three; if the number of colors was four, print Four.\n\nSample Input 1\n\n6\nG W Y P Y W\n\nSample Output 1\n\nFour\n\nThe bag contained arare in four colors, so you should print Four.\n\nSample Input 2\n\n9\nG W W G P W P G G\n\nSample Output 2\n\nThree\n\nThe bag contained arare in three colors, so you should print Three.\n\nSample Input 3\n\n8\nP Y W G Y W Y Y\n\nSample Output 3\n\nFour", "sample_input": "6\nG W Y P Y W\n"}, "reference_outputs": ["Four\n"], "source_document_id": "p03424", "source_text": "Score : 200 points\n\nProblem Statement\n\nIn Japan, people make offerings called hina arare, colorful crackers, on March 3.\n\nWe have a bag that contains N hina arare. (From here, we call them arare.)\n\nIt is known that the bag either contains arare in three colors: pink, white and green, or contains arare in four colors: pink, white, green and yellow.\n\nWe have taken out the arare in the bag one by one, and the color of the i-th arare was S_i, where colors are represented as follows - pink: P, white: W, green: G, yellow: Y.\n\nIf the number of colors of the arare in the bag was three, print Three; if the number of colors was four, print Four.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nS_i is P, W, G or Y.\n\nThere always exist i, j and k such that S_i=P, S_j=W and S_k=G.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1 S_2 ... S_N\n\nOutput\n\nIf the number of colors of the arare in the bag was three, print Three; if the number of colors was four, print Four.\n\nSample Input 1\n\n6\nG W Y P Y W\n\nSample Output 1\n\nFour\n\nThe bag contained arare in four colors, so you should print Four.\n\nSample Input 2\n\n9\nG W W G P W P G G\n\nSample Output 2\n\nThree\n\nThe bag contained arare in three colors, so you should print Three.\n\nSample Input 3\n\n8\nP Y W G Y W Y Y\n\nSample Output 3\n\nFour", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 328, "memory_kb": 25492}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s250132424", "group_id": "codeNet:p03425", "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 sc.nextLine()\n val s = new Array[String](n)\n val mp = scala.collection.mutable.Map[Char, Int](\n ('M', 0), ('A', 0), ('R', 0), ('C', 0), ('H', 0))\n for (i <- 0 until n) {\n s(i) = sc.nextLine()\n val index = s(i)(0)\n if (index == 'M' || index == 'A' || index == 'R' || index == 'C' || index == 'H') {\n mp(index) += 1\n }\n }\n\n var ans = 0\n val values = mp.values.toList\n for (i <- 0 until 5; j <- i + 1 until 5; k <- j + 1 until 5) {\n ans += values(i) * values(j) * values(k)\n }\n\n println(ans)\n }\n}\n", "language": "Scala", "metadata": {"date": 1582341809, "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/s250132424.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s250132424", "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 solve(): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n sc.nextLine()\n val s = new Array[String](n)\n val mp = scala.collection.mutable.Map[Char, Int](\n ('M', 0), ('A', 0), ('R', 0), ('C', 0), ('H', 0))\n for (i <- 0 until n) {\n s(i) = sc.nextLine()\n val index = s(i)(0)\n if (index == 'M' || index == 'A' || index == 'R' || index == 'C' || index == 'H') {\n mp(index) += 1\n }\n }\n\n var ans = 0\n val values = mp.values.toList\n for (i <- 0 until 5; j <- i + 1 until 5; k <- j + 1 until 5) {\n ans += values(i) * values(j) * values(k)\n }\n\n println(ans)\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 811, "memory_kb": 107692}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s549367784", "group_id": "codeNet:p03425", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\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 + (\n members.get(l(0)).getOrElse(0) * members.get(l(1)).getOrElse(0) * members.get(l(2)).getOrElse(0))\n\n }\n\n println(result)\n\n}\n", "language": "Scala", "metadata": {"date": 1526160759, "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/s549367784.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s549367784", "user_id": "u895032849"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\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 + (\n members.get(l(0)).getOrElse(0) * members.get(l(1)).getOrElse(0) * members.get(l(2)).getOrElse(0))\n\n }\n\n println(result)\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 616, "memory_kb": 41740}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s414711717", "group_id": "codeNet:p03426", "input_text": "import java.io.{BufferedReader, IOException, InputStream, InputStreamReader}\nimport java.util.{Scanner, StringTokenizer}\n\nimport scala.util.Sorting\n\nobject Main {\n def solve(): Unit = {\n val sc = new InputReader(System.in)\n val H = sc.nextInt()\n val W = sc.nextInt()\n val D = sc.nextInt()\n val N = H * W\n val A = Array.ofDim[(Int, Int)](N + 1)\n \n for {\n h <- 1 to H\n w <- 1 to W\n } {\n val x = sc.nextInt()\n A(x) = (h, w)\n }\n\n def move(s: (Int, Int), t: (Int, Int)) = math.abs(s._1 - t._1) + math.abs(s._2 - t._2)\n\n // (1 to D-1) から xまでのコスト\n val cost = Array.ofDim[Int](N + 1)\n (1 to D) foreach { d => // 最初の地点dから\n var j = 1\n while(j * D + d <= N) {\n// (0 until (N / D) + (if(d <= N % D) 1 else 0)) foreach { j => // j回移動する\n// if (j == 0) cost(d) = 0\n// else {\n val next = d + D * j\n val prev = d + D * (j - 1)\n cost(next) = cost(prev) + move(A(prev), A(next))\n// }\n j += 1\n }\n }\n\n val Q = sc.nextInt()\n (0 until Q) foreach { _ =>\n val L = sc.nextInt()\n val R = sc.nextInt()\n println(cost(R) - cost(L))\n }\n }\n\n def main(args: Array[String]): Unit = {\n solve()\n }\n\n class InputReader(val stream: InputStream) {\n val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n 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 }\n}\n", "language": "Scala", "metadata": {"date": 1527745828, "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/s414711717.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s414711717", "user_id": "u460609472"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.io.{BufferedReader, IOException, InputStream, InputStreamReader}\nimport java.util.{Scanner, StringTokenizer}\n\nimport scala.util.Sorting\n\nobject Main {\n def solve(): Unit = {\n val sc = new InputReader(System.in)\n val H = sc.nextInt()\n val W = sc.nextInt()\n val D = sc.nextInt()\n val N = H * W\n val A = Array.ofDim[(Int, Int)](N + 1)\n \n for {\n h <- 1 to H\n w <- 1 to W\n } {\n val x = sc.nextInt()\n A(x) = (h, w)\n }\n\n def move(s: (Int, Int), t: (Int, Int)) = math.abs(s._1 - t._1) + math.abs(s._2 - t._2)\n\n // (1 to D-1) から xまでのコスト\n val cost = Array.ofDim[Int](N + 1)\n (1 to D) foreach { d => // 最初の地点dから\n var j = 1\n while(j * D + d <= N) {\n// (0 until (N / D) + (if(d <= N % D) 1 else 0)) foreach { j => // j回移動する\n// if (j == 0) cost(d) = 0\n// else {\n val next = d + D * j\n val prev = d + D * (j - 1)\n cost(next) = cost(prev) + move(A(prev), A(next))\n// }\n j += 1\n }\n }\n\n val Q = sc.nextInt()\n (0 until Q) foreach { _ =>\n val L = sc.nextInt()\n val R = sc.nextInt()\n println(cost(R) - cost(L))\n }\n }\n\n def main(args: Array[String]): Unit = {\n solve()\n }\n\n class InputReader(val stream: InputStream) {\n val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n 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 }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1657, "cpu_time_ms": 1268, "memory_kb": 51208}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s496218547", "group_id": "codeNet:p03426", "input_text": "import java.util.Scanner\nobject Main extends App {\n val scanner = new Scanner(System.in)\n val h, w, d = scanner.nextInt\n val table: Map[Int, (Int, Int)] = (for {\n y <- 0 until h\n x <- 0 until w\n } yield scanner.nextInt -> (x, y)).toMap\n\n (1 to scanner.nextInt).foreach{i =>\n val l, r = scanner.nextInt\n /*\n println(((l to r by d).sliding(2).map{l =>\n val lPos = table(l.head)\n val rPos = table(l.last)\n Math.abs(lPos._1 - rPos._1) + Math.abs(lPos._2 - rPos._2)\n }).sum)\n */\n }\n (1 to 100000).foreach{i => println(0)} // test\n}\n\n", "language": "Scala", "metadata": {"date": 1522173028, "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/s496218547.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s496218547", "user_id": "u132324749"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import java.util.Scanner\nobject Main extends App {\n val scanner = new Scanner(System.in)\n val h, w, d = scanner.nextInt\n val table: Map[Int, (Int, Int)] = (for {\n y <- 0 until h\n x <- 0 until w\n } yield scanner.nextInt -> (x, y)).toMap\n\n (1 to scanner.nextInt).foreach{i =>\n val l, r = scanner.nextInt\n /*\n println(((l to r by d).sliding(2).map{l =>\n val lPos = table(l.head)\n val rPos = table(l.last)\n Math.abs(lPos._1 - rPos._1) + Math.abs(lPos._2 - rPos._2)\n }).sum)\n */\n }\n (1 to 100000).foreach{i => println(0)} // test\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1706, "memory_kb": 128396}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s631685533", "group_id": "codeNet:p03427", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.next()\n if (n.tail.forall(_ == '9')) {\n println(n.toList.map(_.asDigit).sum)\n } else {\n println((n.head.asDigit - 1) + (9 * (n.length - 1)))\n }\n}\n", "language": "Scala", "metadata": {"date": 1600713143, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03427.html", "problem_id": "p03427", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03427/input.txt", "sample_output_relpath": "derived/input_output/data/p03427/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03427/Scala/s631685533.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s631685533", "user_id": "u396472025"}, "prompt_components": {"gold_output": "18\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.next()\n if (n.tail.forall(_ == '9')) {\n println(n.toList.map(_.asDigit).sum)\n } else {\n println((n.head.asDigit - 1) + (9 * (n.length - 1)))\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nFind the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.\n\nConstraints\n\n1\\leq N \\leq 10^{16}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.\n\nSample Input 1\n\n100\n\nSample Output 1\n\n18\n\nFor example, the sum of the digits in 99 is 18, which turns out to be the maximum value.\n\nSample Input 2\n\n9995\n\nSample Output 2\n\n35\n\nFor example, the sum of the digits in 9989 is 35, which turns out to be the maximum value.\n\nSample Input 3\n\n3141592653589793\n\nSample Output 3\n\n137", "sample_input": "100\n"}, "reference_outputs": ["18\n"], "source_document_id": "p03427", "source_text": "Score : 300 points\n\nProblem Statement\n\nFind the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.\n\nConstraints\n\n1\\leq N \\leq 10^{16}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.\n\nSample Input 1\n\n100\n\nSample Output 1\n\n18\n\nFor example, the sum of the digits in 99 is 18, which turns out to be the maximum value.\n\nSample Input 2\n\n9995\n\nSample Output 2\n\n35\n\nFor example, the sum of the digits in 9989 is 35, which turns out to be the maximum value.\n\nSample Input 3\n\n3141592653589793\n\nSample Output 3\n\n137", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 238, "cpu_time_ms": 496, "memory_kb": 55528}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s350738127", "group_id": "codeNet:p03433", "input_text": "import scala.io.StdIn._\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val t = readLine.toInt % 500\n println(if (t <= readLine.toInt) {\n \"Yes\"\n } else {\n \"No\"\n })\n }\n}", "language": "Scala", "metadata": {"date": 1520119842, "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/s350738127.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s350738127", "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]): Unit = {\n val t = readLine.toInt % 500\n println(if (t <= readLine.toInt) {\n \"Yes\"\n } else {\n \"No\"\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 334, "memory_kb": 25296}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s920339182", "group_id": "codeNet:p03434", "input_text": "object Main extends App {\n import scala.io.StdIn.readLine\n \n \tval mushi = readLine\n \tval cards = readLine.split(\" \").map(_.toInt).toList\n \n \tprintln(cards.sorted.foldLeft(0)((a,b)=> b - a ).toString) \n}", "language": "Scala", "metadata": {"date": 1594925843, "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/s920339182.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s920339182", "user_id": "u189998431"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n import scala.io.StdIn.readLine\n \n \tval mushi = readLine\n \tval cards = readLine.split(\" \").map(_.toInt).toList\n \n \tprintln(cards.sorted.foldLeft(0)((a,b)=> b - a ).toString) \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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 483, "memory_kb": 54816}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s836179043", "group_id": "codeNet:p03434", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n val n = StdIn.readLine().toInt\n val a = StdIn.readLine().split(' ').map(_.toInt).sorted(Ordering[Int].reverse).zipWithIndex\n\n //println(a.mkString(\" \"))\n println(a.foldLeft(0)((acc, p) => if(p._2 % 2 == 0) acc + p._1 else acc - p._1))\n}\n", "language": "Scala", "metadata": {"date": 1526170423, "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/s836179043.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s836179043", "user_id": "u895032849"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n val n = StdIn.readLine().toInt\n val a = StdIn.readLine().split(' ').map(_.toInt).sorted(Ordering[Int].reverse).zipWithIndex\n\n //println(a.mkString(\" \"))\n println(a.foldLeft(0)((acc, p) => if(p._2 % 2 == 0) acc + p._1 else acc - p._1))\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 323, "memory_kb": 25540}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s140599713", "group_id": "codeNet:p03435", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n import scala.io.StdIn.readLine\n val rowC1 = readLine.split(\" \").map(_.toInt)\n val rowC2 = readLine.split(\" \").map(_.toInt)\n val rowC3 = readLine.split(\" \").map(_.toInt)\n\n val maxN = 100\n\n def checkRow(row:Array[Int], a1: Int, a2: Int, a3:Int): Boolean ={\n ((row(0) - a1) == (row(1) - a2)) && ((row(1) - a2) == (row(2) - a3))\n }\n val checklist =\n for(a1 <- 0 to maxN; a2 <- 0 to maxN; a3 <- 0 to maxN) yield {\n val a = checkRow(rowC1, a1, a2, a3) && checkRow(rowC2, a1, a2, a3) && checkRow(rowC3, a1, a2, a3)\n //println(\"DEBUG\" + a)\n a\n }\n val ans = checklist.exists(x => x)\n\n println(if(ans) \"Yes\" else \"No\")\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1588515656, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03435.html", "problem_id": "p03435", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03435/input.txt", "sample_output_relpath": "derived/input_output/data/p03435/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03435/Scala/s140599713.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s140599713", "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 rowC1 = readLine.split(\" \").map(_.toInt)\n val rowC2 = readLine.split(\" \").map(_.toInt)\n val rowC3 = readLine.split(\" \").map(_.toInt)\n\n val maxN = 100\n\n def checkRow(row:Array[Int], a1: Int, a2: Int, a3:Int): Boolean ={\n ((row(0) - a1) == (row(1) - a2)) && ((row(1) - a2) == (row(2) - a3))\n }\n val checklist =\n for(a1 <- 0 to maxN; a2 <- 0 to maxN; a3 <- 0 to maxN) yield {\n val a = checkRow(rowC1, a1, a2, a3) && checkRow(rowC2, a1, a2, a3) && checkRow(rowC3, a1, a2, a3)\n //println(\"DEBUG\" + a)\n a\n }\n val ans = checklist.exists(x => x)\n\n println(if(ans) \"Yes\" else \"No\")\n }\n\n}\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nWe have a 3 \\times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left.\n\nAccording to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j.\n\nDetermine if he is correct.\n\nConstraints\n\nc_{i, j} \\ (1 \\leq i \\leq 3, 1 \\leq j \\leq 3) is an integer between 0 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nc_{1,1} c_{1,2} c_{1,3}\nc_{2,1} c_{2,2} c_{2,3}\nc_{3,1} c_{3,2} c_{3,3}\n\nOutput\n\nIf Takahashi's statement is correct, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 0 1\n2 1 2\n1 0 1\n\nSample Output 1\n\nYes\n\nTakahashi is correct, since there are possible sets of integers such as: a_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\nSample Input 2\n\n2 2 2\n2 1 2\n2 2 2\n\nSample Output 2\n\nNo\n\nTakahashi is incorrect in this case.\n\nSample Input 3\n\n0 8 8\n0 8 8\n0 8 8\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n1 8 6\n2 9 7\n0 7 7\n\nSample Output 4\n\nNo", "sample_input": "1 0 1\n2 1 2\n1 0 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03435", "source_text": "Score: 300 points\n\nProblem Statement\n\nWe have a 3 \\times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left.\n\nAccording to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j.\n\nDetermine if he is correct.\n\nConstraints\n\nc_{i, j} \\ (1 \\leq i \\leq 3, 1 \\leq j \\leq 3) is an integer between 0 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nc_{1,1} c_{1,2} c_{1,3}\nc_{2,1} c_{2,2} c_{2,3}\nc_{3,1} c_{3,2} c_{3,3}\n\nOutput\n\nIf Takahashi's statement is correct, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 0 1\n2 1 2\n1 0 1\n\nSample Output 1\n\nYes\n\nTakahashi is correct, since there are possible sets of integers such as: a_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\nSample Input 2\n\n2 2 2\n2 1 2\n2 2 2\n\nSample Output 2\n\nNo\n\nTakahashi is incorrect in this case.\n\nSample Input 3\n\n0 8 8\n0 8 8\n0 8 8\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n1 8 6\n2 9 7\n0 7 7\n\nSample Output 4\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 739, "cpu_time_ms": 727, "memory_kb": 44964}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s824848324", "group_id": "codeNet:p03435", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n val seq = Iterator.continually(StdIn.readLine)\n .takeWhile(_ != null)\n .map(_.split(\" \").map(_.toInt))\n .toArray\n\n val y = (0 until 3).map(i => seq(0)(i)).toArray\n val x = (0 until 3).map(i => seq(i)(0)-y(0)).toArray\n\n val ans = (\n for{\n i <- 0 until 3\n j <- 0 until 3\n } yield { seq(i)(j) == x(i) + y(j) }\n ).forall(_ == true)\n\n println(if(ans)\"Yes\"else\"No\")\n}", "language": "Scala", "metadata": {"date": 1544294062, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03435.html", "problem_id": "p03435", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03435/input.txt", "sample_output_relpath": "derived/input_output/data/p03435/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03435/Scala/s824848324.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s824848324", "user_id": "u217010036"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n val seq = Iterator.continually(StdIn.readLine)\n .takeWhile(_ != null)\n .map(_.split(\" \").map(_.toInt))\n .toArray\n\n val y = (0 until 3).map(i => seq(0)(i)).toArray\n val x = (0 until 3).map(i => seq(i)(0)-y(0)).toArray\n\n val ans = (\n for{\n i <- 0 until 3\n j <- 0 until 3\n } yield { seq(i)(j) == x(i) + y(j) }\n ).forall(_ == true)\n\n println(if(ans)\"Yes\"else\"No\")\n}", "problem_context": "Score: 300 points\n\nProblem Statement\n\nWe have a 3 \\times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left.\n\nAccording to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j.\n\nDetermine if he is correct.\n\nConstraints\n\nc_{i, j} \\ (1 \\leq i \\leq 3, 1 \\leq j \\leq 3) is an integer between 0 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nc_{1,1} c_{1,2} c_{1,3}\nc_{2,1} c_{2,2} c_{2,3}\nc_{3,1} c_{3,2} c_{3,3}\n\nOutput\n\nIf Takahashi's statement is correct, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 0 1\n2 1 2\n1 0 1\n\nSample Output 1\n\nYes\n\nTakahashi is correct, since there are possible sets of integers such as: a_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\nSample Input 2\n\n2 2 2\n2 1 2\n2 2 2\n\nSample Output 2\n\nNo\n\nTakahashi is incorrect in this case.\n\nSample Input 3\n\n0 8 8\n0 8 8\n0 8 8\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n1 8 6\n2 9 7\n0 7 7\n\nSample Output 4\n\nNo", "sample_input": "1 0 1\n2 1 2\n1 0 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03435", "source_text": "Score: 300 points\n\nProblem Statement\n\nWe have a 3 \\times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left.\n\nAccording to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j.\n\nDetermine if he is correct.\n\nConstraints\n\nc_{i, j} \\ (1 \\leq i \\leq 3, 1 \\leq j \\leq 3) is an integer between 0 and 100 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nc_{1,1} c_{1,2} c_{1,3}\nc_{2,1} c_{2,2} c_{2,3}\nc_{3,1} c_{3,2} c_{3,3}\n\nOutput\n\nIf Takahashi's statement is correct, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 0 1\n2 1 2\n1 0 1\n\nSample Output 1\n\nYes\n\nTakahashi is correct, since there are possible sets of integers such as: a_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\nSample Input 2\n\n2 2 2\n2 1 2\n2 2 2\n\nSample Output 2\n\nNo\n\nTakahashi is incorrect in this case.\n\nSample Input 3\n\n0 8 8\n0 8 8\n0 8 8\n\nSample Output 3\n\nYes\n\nSample Input 4\n\n1 8 6\n2 9 7\n0 7 7\n\nSample Output 4\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 442, "cpu_time_ms": 329, "memory_kb": 27200}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s674433473", "group_id": "codeNet:p03447", "input_text": "object Main {\n\tdef main(args: Array[String]) {\n\t\tval input = io.Source.stdin.getLines().mkString(\"\\n\")\n\t\tprintln(solve(input).trim)\n\t}\n\n\tdef solve(input: String): String = {\n\t\tval List(a, b, c, x) = input.split(\"\\n\").map(_.toInt).toList\n\t\tval ay = (0 to a).map(_*500)\n\t\tval by = (0 to b).map(_*100)\n\t\tval cy = (0 to c).map(_*50)\n\t\tay.flatMap(i => by.flatMap(j => cy.map(k => i+j+k))).filter(_==x).size.toString()\n\t}\n\n}", "language": "Scala", "metadata": {"date": 1581725085, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03447.html", "problem_id": "p03447", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03447/input.txt", "sample_output_relpath": "derived/input_output/data/p03447/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03447/Scala/s674433473.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s674433473", "user_id": "u828257930"}, "prompt_components": {"gold_output": "84\n", "input_to_evaluate": "object Main {\n\tdef main(args: Array[String]) {\n\t\tval input = io.Source.stdin.getLines().mkString(\"\\n\")\n\t\tprintln(solve(input).trim)\n\t}\n\n\tdef solve(input: String): String = {\n\t\tval List(a, b, c, x) = input.split(\"\\n\").map(_.toInt).toList\n\t\tval ay = (0 to a).map(_*500)\n\t\tval by = (0 to b).map(_*100)\n\t\tval cy = (0 to c).map(_*50)\n\t\tay.flatMap(i => by.flatMap(j => cy.map(k => i+j+k))).filter(_==x).size.toString()\n\t}\n\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou went shopping to buy cakes and donuts with X yen (the currency of Japan).\n\nFirst, you bought one cake for A yen at a cake shop.\nThen, you bought as many donuts as possible for B yen each, at a donut shop.\n\nHow much do you have left after shopping?\n\nConstraints\n\n1 \\leq A, B \\leq 1 000\n\nA + B \\leq X \\leq 10 000\n\nX, A and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\nA\nB\n\nOutput\n\nPrint the amount you have left after shopping.\n\nSample Input 1\n\n1234\n150\n100\n\nSample Output 1\n\n84\n\nYou have 1234 - 150 = 1084 yen left after buying a cake.\nWith this amount, you can buy 10 donuts, after which you have 84 yen left.\n\nSample Input 2\n\n1000\n108\n108\n\nSample Output 2\n\n28\n\nSample Input 3\n\n579\n123\n456\n\nSample Output 3\n\n0\n\nSample Input 4\n\n7477\n549\n593\n\nSample Output 4\n\n405", "sample_input": "1234\n150\n100\n"}, "reference_outputs": ["84\n"], "source_document_id": "p03447", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou went shopping to buy cakes and donuts with X yen (the currency of Japan).\n\nFirst, you bought one cake for A yen at a cake shop.\nThen, you bought as many donuts as possible for B yen each, at a donut shop.\n\nHow much do you have left after shopping?\n\nConstraints\n\n1 \\leq A, B \\leq 1 000\n\nA + B \\leq X \\leq 10 000\n\nX, A and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\nA\nB\n\nOutput\n\nPrint the amount you have left after shopping.\n\nSample Input 1\n\n1234\n150\n100\n\nSample Output 1\n\n84\n\nYou have 1234 - 150 = 1084 yen left after buying a cake.\nWith this amount, you can buy 10 donuts, after which you have 84 yen left.\n\nSample Input 2\n\n1000\n108\n108\n\nSample Output 2\n\n28\n\nSample Input 3\n\n579\n123\n456\n\nSample Output 3\n\n0\n\nSample Input 4\n\n7477\n549\n593\n\nSample Output 4\n\n405", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 332, "memory_kb": 27448}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s519684367", "group_id": "codeNet:p03447", "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 x: Int = sc.nextLine.toInt\n val a: Int = sc.nextLine.toInt\n val b: Int = sc.nextLine.toInt\n println((x - a) % b)\n\n }\n}\n", "language": "Scala", "metadata": {"date": 1557642693, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03447.html", "problem_id": "p03447", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03447/input.txt", "sample_output_relpath": "derived/input_output/data/p03447/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03447/Scala/s519684367.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s519684367", "user_id": "u629133942"}, "prompt_components": {"gold_output": "84\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 x: Int = sc.nextLine.toInt\n val a: Int = sc.nextLine.toInt\n val b: Int = sc.nextLine.toInt\n println((x - a) % b)\n\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou went shopping to buy cakes and donuts with X yen (the currency of Japan).\n\nFirst, you bought one cake for A yen at a cake shop.\nThen, you bought as many donuts as possible for B yen each, at a donut shop.\n\nHow much do you have left after shopping?\n\nConstraints\n\n1 \\leq A, B \\leq 1 000\n\nA + B \\leq X \\leq 10 000\n\nX, A and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\nA\nB\n\nOutput\n\nPrint the amount you have left after shopping.\n\nSample Input 1\n\n1234\n150\n100\n\nSample Output 1\n\n84\n\nYou have 1234 - 150 = 1084 yen left after buying a cake.\nWith this amount, you can buy 10 donuts, after which you have 84 yen left.\n\nSample Input 2\n\n1000\n108\n108\n\nSample Output 2\n\n28\n\nSample Input 3\n\n579\n123\n456\n\nSample Output 3\n\n0\n\nSample Input 4\n\n7477\n549\n593\n\nSample Output 4\n\n405", "sample_input": "1234\n150\n100\n"}, "reference_outputs": ["84\n"], "source_document_id": "p03447", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou went shopping to buy cakes and donuts with X yen (the currency of Japan).\n\nFirst, you bought one cake for A yen at a cake shop.\nThen, you bought as many donuts as possible for B yen each, at a donut shop.\n\nHow much do you have left after shopping?\n\nConstraints\n\n1 \\leq A, B \\leq 1 000\n\nA + B \\leq X \\leq 10 000\n\nX, A and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\nA\nB\n\nOutput\n\nPrint the amount you have left after shopping.\n\nSample Input 1\n\n1234\n150\n100\n\nSample Output 1\n\n84\n\nYou have 1234 - 150 = 1084 yen left after buying a cake.\nWith this amount, you can buy 10 donuts, after which you have 84 yen left.\n\nSample Input 2\n\n1000\n108\n108\n\nSample Output 2\n\n28\n\nSample Input 3\n\n579\n123\n456\n\nSample Output 3\n\n0\n\nSample Input 4\n\n7477\n549\n593\n\nSample Output 4\n\n405", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 343, "memory_kb": 25540}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s206356619", "group_id": "codeNet:p03449", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n import scala.io.StdIn.readLine\n val Array(datN) = readLine.split(\" \").map(_.toInt)\n val datA = for(i <- 1 to 2) yield (readLine.split(\" \").map(_.toInt))\n\n val ans = (0 until datN).map(x => datA(0).take(x + 1).sum + datA(1).takeRight(datN - x).sum).max\n println(ans)\n }\n}\n", "language": "Scala", "metadata": {"date": 1589426916, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03449.html", "problem_id": "p03449", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03449/input.txt", "sample_output_relpath": "derived/input_output/data/p03449/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03449/Scala/s206356619.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s206356619", "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 Array(datN) = readLine.split(\" \").map(_.toInt)\n val datA = for(i <- 1 to 2) yield (readLine.split(\" \").map(_.toInt))\n\n val ans = (0 until datN).map(x => datA(0).take(x + 1).sum + datA(1).takeRight(datN - x).sum).max\n println(ans)\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have a 2 \\times N grid. We will denote the square at the i-th row and j-th column (1 \\leq i \\leq 2, 1 \\leq j \\leq N) as (i, j).\n\nYou are initially in the top-left square, (1, 1).\nYou will travel to the bottom-right square, (2, N), by repeatedly moving right or down.\n\nThe square (i, j) contains A_{i, j} candies.\nYou will collect all the candies you visit during the travel.\nThe top-left and bottom-right squares also contain candies, and you will also collect them.\n\nAt most how many candies can you collect when you choose the best way to travel?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq A_{i, j} \\leq 100 (1 \\leq i \\leq 2, 1 \\leq j \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} ... A_{1, N}\nA_{2, 1} A_{2, 2} ... A_{2, N}\n\nOutput\n\nPrint the maximum number of candies that can be collected.\n\nSample Input 1\n\n5\n3 2 2 4 1\n1 2 2 2 1\n\nSample Output 1\n\n14\n\nThe number of collected candies will be maximized when you:\n\nmove right three times, then move down once, then move right once.\n\nSample Input 2\n\n4\n1 1 1 1\n1 1 1 1\n\nSample Output 2\n\n5\n\nYou will always collect the same number of candies, regardless of how you travel.\n\nSample Input 3\n\n7\n3 3 4 5 4 5 3\n5 3 4 4 2 3 2\n\nSample Output 3\n\n29\n\nSample Input 4\n\n1\n2\n3\n\nSample Output 4\n\n5", "sample_input": "5\n3 2 2 4 1\n1 2 2 2 1\n"}, "reference_outputs": ["14\n"], "source_document_id": "p03449", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have a 2 \\times N grid. We will denote the square at the i-th row and j-th column (1 \\leq i \\leq 2, 1 \\leq j \\leq N) as (i, j).\n\nYou are initially in the top-left square, (1, 1).\nYou will travel to the bottom-right square, (2, N), by repeatedly moving right or down.\n\nThe square (i, j) contains A_{i, j} candies.\nYou will collect all the candies you visit during the travel.\nThe top-left and bottom-right squares also contain candies, and you will also collect them.\n\nAt most how many candies can you collect when you choose the best way to travel?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq A_{i, j} \\leq 100 (1 \\leq i \\leq 2, 1 \\leq j \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} ... A_{1, N}\nA_{2, 1} A_{2, 2} ... A_{2, N}\n\nOutput\n\nPrint the maximum number of candies that can be collected.\n\nSample Input 1\n\n5\n3 2 2 4 1\n1 2 2 2 1\n\nSample Output 1\n\n14\n\nThe number of collected candies will be maximized when you:\n\nmove right three times, then move down once, then move right once.\n\nSample Input 2\n\n4\n1 1 1 1\n1 1 1 1\n\nSample Output 2\n\n5\n\nYou will always collect the same number of candies, regardless of how you travel.\n\nSample Input 3\n\n7\n3 3 4 5 4 5 3\n5 3 4 4 2 3 2\n\nSample Output 3\n\n29\n\nSample Input 4\n\n1\n2\n3\n\nSample Output 4\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 518, "memory_kb": 54972}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s907117686", "group_id": "codeNet:p03449", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n val n = StdIn.readLine.toInt\n val seq = Iterator.continually(StdIn.readLine)\n .take(2)\n .map(_.split(\" \").map(_.toInt))\n .toArray\n val seq1 = seq(0).scanLeft(0)( (acc, e) => acc + e).tail\n val seq2 = seq(1).scanRight(0)( (e,acc) => acc + e).init\n val ans = (0 until n).map(i => seq1(i) + seq2(i)).max\n\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1544297379, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03449.html", "problem_id": "p03449", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03449/input.txt", "sample_output_relpath": "derived/input_output/data/p03449/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03449/Scala/s907117686.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s907117686", "user_id": "u217010036"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n val n = StdIn.readLine.toInt\n val seq = Iterator.continually(StdIn.readLine)\n .take(2)\n .map(_.split(\" \").map(_.toInt))\n .toArray\n val seq1 = seq(0).scanLeft(0)( (acc, e) => acc + e).tail\n val seq2 = seq(1).scanRight(0)( (e,acc) => acc + e).init\n val ans = (0 until n).map(i => seq1(i) + seq2(i)).max\n\n println(ans)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have a 2 \\times N grid. We will denote the square at the i-th row and j-th column (1 \\leq i \\leq 2, 1 \\leq j \\leq N) as (i, j).\n\nYou are initially in the top-left square, (1, 1).\nYou will travel to the bottom-right square, (2, N), by repeatedly moving right or down.\n\nThe square (i, j) contains A_{i, j} candies.\nYou will collect all the candies you visit during the travel.\nThe top-left and bottom-right squares also contain candies, and you will also collect them.\n\nAt most how many candies can you collect when you choose the best way to travel?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq A_{i, j} \\leq 100 (1 \\leq i \\leq 2, 1 \\leq j \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} ... A_{1, N}\nA_{2, 1} A_{2, 2} ... A_{2, N}\n\nOutput\n\nPrint the maximum number of candies that can be collected.\n\nSample Input 1\n\n5\n3 2 2 4 1\n1 2 2 2 1\n\nSample Output 1\n\n14\n\nThe number of collected candies will be maximized when you:\n\nmove right three times, then move down once, then move right once.\n\nSample Input 2\n\n4\n1 1 1 1\n1 1 1 1\n\nSample Output 2\n\n5\n\nYou will always collect the same number of candies, regardless of how you travel.\n\nSample Input 3\n\n7\n3 3 4 5 4 5 3\n5 3 4 4 2 3 2\n\nSample Output 3\n\n29\n\nSample Input 4\n\n1\n2\n3\n\nSample Output 4\n\n5", "sample_input": "5\n3 2 2 4 1\n1 2 2 2 1\n"}, "reference_outputs": ["14\n"], "source_document_id": "p03449", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have a 2 \\times N grid. We will denote the square at the i-th row and j-th column (1 \\leq i \\leq 2, 1 \\leq j \\leq N) as (i, j).\n\nYou are initially in the top-left square, (1, 1).\nYou will travel to the bottom-right square, (2, N), by repeatedly moving right or down.\n\nThe square (i, j) contains A_{i, j} candies.\nYou will collect all the candies you visit during the travel.\nThe top-left and bottom-right squares also contain candies, and you will also collect them.\n\nAt most how many candies can you collect when you choose the best way to travel?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq A_{i, j} \\leq 100 (1 \\leq i \\leq 2, 1 \\leq j \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} ... A_{1, N}\nA_{2, 1} A_{2, 2} ... A_{2, N}\n\nOutput\n\nPrint the maximum number of candies that can be collected.\n\nSample Input 1\n\n5\n3 2 2 4 1\n1 2 2 2 1\n\nSample Output 1\n\n14\n\nThe number of collected candies will be maximized when you:\n\nmove right three times, then move down once, then move right once.\n\nSample Input 2\n\n4\n1 1 1 1\n1 1 1 1\n\nSample Output 2\n\n5\n\nYou will always collect the same number of candies, regardless of how you travel.\n\nSample Input 3\n\n7\n3 3 4 5 4 5 3\n5 3 4 4 2 3 2\n\nSample Output 3\n\n29\n\nSample Input 4\n\n1\n2\n3\n\nSample Output 4\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 345, "memory_kb": 25420}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s135365951", "group_id": "codeNet:p03450", "input_text": "import scala.io.{StdIn => in}\nimport scala.collection.{mutable => mu}\n\nobject Main extends App {\n val Array(n, m) = in.readLine.split(\" \").map(_.toInt)\n\n val INF = 1 << 30\n val value = Array.fill(n+1)(INF)\n case class Edge(node:Int, cost:Int)\n val graph = Array.fill(n+1)(mu.ListBuffer.empty[Edge])\n\n Iterator.continually(in.readLine)\n .take(m)\n .map(_.split(\" \").map(_.toInt))\n .foreach(e => {\n val l = e(0) - 1\n val r = e(1) - 1\n val d = e(2)\n graph(l) += new Edge(r,d)\n graph(r) += new Edge(l,-d)\n })\n\n def bfs(node:Int):Unit = {\n if(graph(node).nonEmpty) {\n graph(node).foreach( edge => {\n if(value(edge.node) == INF) {\n value(edge.node) = value(node) + edge.cost\n bfs(edge.node)\n }\n })\n }\n }\n\n (0 until n).foreach( i => {\n if(value(i) == INF) {\n value(i) = 0\n bfs(i)\n }\n })\n\n val valid =\n (0 until n).forall( i => {\n graph(i).forall( edge => {\n value(i) + edge.cost == value(edge.node)\n })\n })\n\n val ans = if(valid) \"Yes\" else \"No\"\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1554938207, "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/s135365951.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s135365951", "user_id": "u217010036"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.io.{StdIn => in}\nimport scala.collection.{mutable => mu}\n\nobject Main extends App {\n val Array(n, m) = in.readLine.split(\" \").map(_.toInt)\n\n val INF = 1 << 30\n val value = Array.fill(n+1)(INF)\n case class Edge(node:Int, cost:Int)\n val graph = Array.fill(n+1)(mu.ListBuffer.empty[Edge])\n\n Iterator.continually(in.readLine)\n .take(m)\n .map(_.split(\" \").map(_.toInt))\n .foreach(e => {\n val l = e(0) - 1\n val r = e(1) - 1\n val d = e(2)\n graph(l) += new Edge(r,d)\n graph(r) += new Edge(l,-d)\n })\n\n def bfs(node:Int):Unit = {\n if(graph(node).nonEmpty) {\n graph(node).foreach( edge => {\n if(value(edge.node) == INF) {\n value(edge.node) = value(node) + edge.cost\n bfs(edge.node)\n }\n })\n }\n }\n\n (0 until n).foreach( i => {\n if(value(i) == INF) {\n value(i) = 0\n bfs(i)\n }\n })\n\n val valid =\n (0 until n).forall( i => {\n graph(i).forall( edge => {\n value(i) + edge.cost == value(edge.node)\n })\n })\n\n val ans = if(valid) \"Yes\" else \"No\"\n println(ans)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1089, "cpu_time_ms": 1288, "memory_kb": 105844}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s792088970", "group_id": "codeNet:p03450", "input_text": "import scala.io.{StdIn => in}\nimport scala.collection.{mutable => mu}\n\nobject Main extends App {\n val Array(n, m) = in.readLine.split(\" \").map(_.toInt)\n\n val INF = 1 << 30\n val value = Array.fill(n)(INF)\n case class Edge(node:Int, cost:Int)\n val graph = Array.fill(n)(mu.ListBuffer.empty[Edge])\n\n Iterator.continually(in.readLine)\n .take(m)\n .map(_.split(\" \").map(_.toInt))\n .foreach(e => {\n val l = e(0) - 1\n val r = e(1) - 1\n val d = e(2)\n graph(l) += new Edge(r,d)\n graph(r) += new Edge(l,-d)\n })\n\n def bfs(node:Int):Unit = {\n if(graph(node).nonEmpty) {\n graph(node).foreach( edge => {\n if(value(edge.node) == INF) {\n value(edge.node) = value(node) + edge.cost\n bfs(edge.node)\n }\n })\n }\n }\n\n (0 until n).foreach( i => {\n if(value(i) == INF) {\n value(i) = 0\n bfs(i)\n }\n })\n\n val valid =\n (0 until n).forall( i => {\n graph(i).forall( edge => {\n value(i) + edge.cost == value(edge.node)\n })\n })\n\n val ans = if(valid) \"Yes\" else \"No\"\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1554937725, "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/s792088970.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s792088970", "user_id": "u217010036"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.io.{StdIn => in}\nimport scala.collection.{mutable => mu}\n\nobject Main extends App {\n val Array(n, m) = in.readLine.split(\" \").map(_.toInt)\n\n val INF = 1 << 30\n val value = Array.fill(n)(INF)\n case class Edge(node:Int, cost:Int)\n val graph = Array.fill(n)(mu.ListBuffer.empty[Edge])\n\n Iterator.continually(in.readLine)\n .take(m)\n .map(_.split(\" \").map(_.toInt))\n .foreach(e => {\n val l = e(0) - 1\n val r = e(1) - 1\n val d = e(2)\n graph(l) += new Edge(r,d)\n graph(r) += new Edge(l,-d)\n })\n\n def bfs(node:Int):Unit = {\n if(graph(node).nonEmpty) {\n graph(node).foreach( edge => {\n if(value(edge.node) == INF) {\n value(edge.node) = value(node) + edge.cost\n bfs(edge.node)\n }\n })\n }\n }\n\n (0 until n).foreach( i => {\n if(value(i) == INF) {\n value(i) = 0\n bfs(i)\n }\n })\n\n val valid =\n (0 until n).forall( i => {\n graph(i).forall( edge => {\n value(i) + edge.cost == value(edge.node)\n })\n })\n\n val ans = if(valid) \"Yes\" else \"No\"\n println(ans)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1085, "cpu_time_ms": 1315, "memory_kb": 104668}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s159616148", "group_id": "codeNet:p03456", "input_text": "object Main extends App {\n val input = readLine\n val a = input.split(\" \")(0)\n val b = input.split(\" \")(1)\n val num = (a + b).toInt\n val sqrt_double = Math.sqrt(num)\n val sqrt_int = sqrt_double.toInt\n val res = if(sqrt_int * sqrt_int - num == 0){\"Yes\"}else{\"No\"}\n println(res)\n}\n", "language": "Scala", "metadata": {"date": 1584415744, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03456.html", "problem_id": "p03456", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03456/input.txt", "sample_output_relpath": "derived/input_output/data/p03456/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03456/Scala/s159616148.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s159616148", "user_id": "u153852307"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n val input = readLine\n val a = input.split(\" \")(0)\n val b = input.split(\" \")(1)\n val num = (a + b).toInt\n val sqrt_double = Math.sqrt(num)\n val sqrt_int = sqrt_double.toInt\n val res = if(sqrt_int * sqrt_int - num == 0){\"Yes\"}else{\"No\"}\n println(res)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAtCoDeer the deer has found two positive integers, a and b.\nDetermine whether the concatenation of a and b in this order is a square number.\n\nConstraints\n\n1 ≤ a,b ≤ 100\n\na and b are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the concatenation of a and b in this order is a square number, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 21\n\nSample Output 1\n\nYes\n\nAs 121 = 11 × 11, it is a square number.\n\nSample Input 2\n\n100 100\n\nSample Output 2\n\nNo\n\n100100 is not a square number.\n\nSample Input 3\n\n12 10\n\nSample Output 3\n\nNo", "sample_input": "1 21\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03456", "source_text": "Score : 200 points\n\nProblem Statement\n\nAtCoDeer the deer has found two positive integers, a and b.\nDetermine whether the concatenation of a and b in this order is a square number.\n\nConstraints\n\n1 ≤ a,b ≤ 100\n\na and b are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the concatenation of a and b in this order is a square number, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 21\n\nSample Output 1\n\nYes\n\nAs 121 = 11 × 11, it is a square number.\n\nSample Input 2\n\n100 100\n\nSample Output 2\n\nNo\n\n100100 is not a square number.\n\nSample Input 3\n\n12 10\n\nSample Output 3\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 330, "memory_kb": 25404}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s557120192", "group_id": "codeNet:p03456", "input_text": "object Main extends App {\n\t// your code goes here\n\tval x = io.StdIn.readLine().replaceAll(\"[^0-9]+\", \"\").toLong\n val s = math.sqrt(x).round\n (x==s*s) match {\n case true => println(\"Yes\")\n case false => println(\"No\")\n }\n}", "language": "Scala", "metadata": {"date": 1521550352, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03456.html", "problem_id": "p03456", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03456/input.txt", "sample_output_relpath": "derived/input_output/data/p03456/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03456/Scala/s557120192.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s557120192", "user_id": "u055182547"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n\t// your code goes here\n\tval x = io.StdIn.readLine().replaceAll(\"[^0-9]+\", \"\").toLong\n val s = math.sqrt(x).round\n (x==s*s) match {\n case true => println(\"Yes\")\n case false => println(\"No\")\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAtCoDeer the deer has found two positive integers, a and b.\nDetermine whether the concatenation of a and b in this order is a square number.\n\nConstraints\n\n1 ≤ a,b ≤ 100\n\na and b are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the concatenation of a and b in this order is a square number, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 21\n\nSample Output 1\n\nYes\n\nAs 121 = 11 × 11, it is a square number.\n\nSample Input 2\n\n100 100\n\nSample Output 2\n\nNo\n\n100100 is not a square number.\n\nSample Input 3\n\n12 10\n\nSample Output 3\n\nNo", "sample_input": "1 21\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03456", "source_text": "Score : 200 points\n\nProblem Statement\n\nAtCoDeer the deer has found two positive integers, a and b.\nDetermine whether the concatenation of a and b in this order is a square number.\n\nConstraints\n\n1 ≤ a,b ≤ 100\n\na and b are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the concatenation of a and b in this order is a square number, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 21\n\nSample Output 1\n\nYes\n\nAs 121 = 11 × 11, it is a square number.\n\nSample Input 2\n\n100 100\n\nSample Output 2\n\nNo\n\n100100 is not a square number.\n\nSample Input 3\n\n12 10\n\nSample Output 3\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 318, "memory_kb": 27204}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s801534464", "group_id": "codeNet:p03457", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val list: Seq[Seq[Int]] = Seq(0,0,0) :: List.fill(n, 3)(sc.nextInt.toInt)\n \n val check = (term: Int, start: (Int, Int), end: (Int, Int)) => {\n val diffX = math.abs(end._1 - start._1)\n val diffY = math.abs(end._2 - start._2)\n val diff = diffX + diffY\n \n (diff <= term) && (diff % 2 == term % 2)\n }\n \n val results: Seq[Boolean] = for (index <- (1 to n)) yield {\n check(list(index)(0) - list(index - 1)(0), (list(index - 1)(1), list(index - 1)(2)), (list(index)(1), list(index)(2)))\n }\n val result = !results.contains(false)\n \n println(if (result) \"Yes\" else \"No\")\n}", "language": "Scala", "metadata": {"date": 1577950466, "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/s801534464.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s801534464", "user_id": "u715268393"}, "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 list: Seq[Seq[Int]] = Seq(0,0,0) :: List.fill(n, 3)(sc.nextInt.toInt)\n \n val check = (term: Int, start: (Int, Int), end: (Int, Int)) => {\n val diffX = math.abs(end._1 - start._1)\n val diffY = math.abs(end._2 - start._2)\n val diff = diffX + diffY\n \n (diff <= term) && (diff % 2 == term % 2)\n }\n \n val results: Seq[Boolean] = for (index <- (1 to n)) yield {\n check(list(index)(0) - list(index - 1)(0), (list(index - 1)(1), list(index - 1)(2)), (list(index)(1), list(index)(2)))\n }\n val result = !results.contains(false)\n \n println(if (result) \"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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 685, "cpu_time_ms": 2114, "memory_kb": 118536}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s437322370", "group_id": "codeNet:p03457", "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, 3)(sc.nextInt)\n \n def check(term: Int, start: (Int, Int), end: (Int, Int)): Boolean = {\n val diffX = math.abs(end._1 - start._1)\n val diffY = math.abs(end._2 - start._2)\n val diff = diffX + diffY\n \n (diff <= term) && (diff % 2 == term % 2)\n }\n \n val results: Seq[Boolean] = for (index <- (0 to list.length - 1)) yield {\n if (index == 0) check(list(index)(0), (0, 0), (list(index)(1), list(index)(2)))\n else check(list(index)(0) - list(index - 1)(0), (list(index - 1)(1), list(index - 1)(2)), (list(index)(1), list(index)(2)))\n }\n \n println(if (results.contains(false)) \"No\" else \"Yes\")\n}", "language": "Scala", "metadata": {"date": 1577948976, "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/s437322370.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s437322370", "user_id": "u715268393"}, "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 list = List.fill(n, 3)(sc.nextInt)\n \n def check(term: Int, start: (Int, Int), end: (Int, Int)): Boolean = {\n val diffX = math.abs(end._1 - start._1)\n val diffY = math.abs(end._2 - start._2)\n val diff = diffX + diffY\n \n (diff <= term) && (diff % 2 == term % 2)\n }\n \n val results: Seq[Boolean] = for (index <- (0 to list.length - 1)) yield {\n if (index == 0) check(list(index)(0), (0, 0), (list(index)(1), list(index)(2)))\n else check(list(index)(0) - list(index - 1)(0), (list(index - 1)(1), list(index - 1)(2)), (list(index)(1), list(index)(2)))\n }\n \n println(if (results.contains(false)) \"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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2115, "memory_kb": 116488}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s912457973", "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, y: Int): Boolean = {\n if (t == 0) (x == 0 && y == 0)\n else if(x == 0 && y == 0 && (t & 1) == 0) true\n else if (x < 0 || y < 0 || x > t || y > t || x + y > 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), Math.abs(x2(1) - x1(1)), Math.abs(x2(2) - x1(2)))}\n print(if(list2.forall{case (t, x, y) => f(t, x, y)}) \"Yes\" else \"No\")\n}\n\n", "language": "Scala", "metadata": {"date": 1525727079, "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/s912457973.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s912457973", "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, y: Int): Boolean = {\n if (t == 0) (x == 0 && y == 0)\n else if(x == 0 && y == 0 && (t & 1) == 0) true\n else if (x < 0 || y < 0 || x > t || y > t || x + y > 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), Math.abs(x2(1) - x1(1)), Math.abs(x2(2) - x1(2)))}\n print(if(list2.forall{case (t, x, y) => f(t, x, y)}) \"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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 743, "cpu_time_ms": 2111, "memory_kb": 63356}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s850500499", "group_id": "codeNet:p03458", "input_text": "object Main extends App {\n val Array(n, k) = io.StdIn.readLine().split(' ').map(_.toInt)\n val k2 = k * 2\n val list = collection.mutable.ListBuffer[Array[Int]]()\n var (sum, white) = (0, 0)\n (1 to n).foreach { i =>\n val temp = io.StdIn.readLine().split(' ')\n list += (\n if (temp(2) == \"B\") {\n sum = sum + 1\n Array(temp(0).toInt % k2, temp(1).toInt % k2, 1)\n }\n else {\n sum = sum - 1\n white = white + 1\n Array(temp(0).toInt % k2, temp(1).toInt % k2, -1)\n }\n )\n }\n val matrix = new Array[Array[Int]](k2)\n (0 to k2 - 1).foreach(i => matrix(i) = new Array[Int](k2))\n def inc(x: Int, y: Int, z: Int) = {\n for {\n i <- (x to k2-1)\n j <- (y to k2-1)\n } {\n matrix(i)(j) = matrix(i)(j) + z\n }\n }\n list.foreach(arr => inc(arr(0), arr(1), arr(2)))\n var max = 0\n for { \n i <- (0 to k-1)\n j <- (0 to k-1)\n } {\n val cnt = \n (matrix(i)(j)) +\n (matrix(i+k)(j+k) - matrix(i+k)(j) - matrix(i)(j+k) + matrix(i)(j)) +\n (matrix(k2-1)(j) - matrix(i+k)(j)) +\n (matrix(i)(k2-1) - matrix(i)(j+k)) +\n (matrix(k2-1)(k2-1) - matrix(k2-1)(j+k) - matrix(i+k)(k2-1) + matrix(i+k)(j+k))\n max = Math.max(Math.max(cnt, sum - cnt), max)\n }\n print(max + white)\n}\n", "language": "Scala", "metadata": {"date": 1525819595, "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/s850500499.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s850500499", "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 list = collection.mutable.ListBuffer[Array[Int]]()\n var (sum, white) = (0, 0)\n (1 to n).foreach { i =>\n val temp = io.StdIn.readLine().split(' ')\n list += (\n if (temp(2) == \"B\") {\n sum = sum + 1\n Array(temp(0).toInt % k2, temp(1).toInt % k2, 1)\n }\n else {\n sum = sum - 1\n white = white + 1\n Array(temp(0).toInt % k2, temp(1).toInt % k2, -1)\n }\n )\n }\n val matrix = new Array[Array[Int]](k2)\n (0 to k2 - 1).foreach(i => matrix(i) = new Array[Int](k2))\n def inc(x: Int, y: Int, z: Int) = {\n for {\n i <- (x to k2-1)\n j <- (y to k2-1)\n } {\n matrix(i)(j) = matrix(i)(j) + z\n }\n }\n list.foreach(arr => inc(arr(0), arr(1), arr(2)))\n var max = 0\n for { \n i <- (0 to k-1)\n j <- (0 to k-1)\n } {\n val cnt = \n (matrix(i)(j)) +\n (matrix(i+k)(j+k) - matrix(i+k)(j) - matrix(i)(j+k) + matrix(i)(j)) +\n (matrix(k2-1)(j) - matrix(i+k)(j)) +\n (matrix(i)(k2-1) - matrix(i)(j+k)) +\n (matrix(k2-1)(k2-1) - matrix(k2-1)(j+k) - matrix(i+k)(k2-1) + matrix(i+k)(j+k))\n max = Math.max(Math.max(cnt, sum - cnt), max)\n }\n print(max + white)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1265, "cpu_time_ms": 2111, "memory_kb": 116868}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s257689258", "group_id": "codeNet:p03458", "input_text": "object Main extends App {\n val Array(n, k) = io.StdIn.readLine().split(' ').map(_.toInt)\n val k2 = k * 2\n type Record = (Int, Int)\n val list = collection.mutable.ListBuffer[Record]()\n (1 to n).foreach { i =>\n val temp = io.StdIn.readLine().split(' ')\n list += (\n if (temp(2) == \"W\")\n (temp(0).toInt % k2, temp(1).toInt % k2)\n else\n (temp(0).toInt % k2, (temp(1).toInt + k) % k2)\n )\n }\n var max = 0\n (1 to k).foreach { i =>\n (1 to k).foreach { j => \n val cnt = list.count {\n t =>\n val x = (t._1 + i) % k2\n val y = (t._2 + j) % k2\n ( (x < k && y < k) || (x >= k && y >= k))\n }\n max = Math.max(Math.max(cnt, n - cnt), max)\n }\n }\n print(max)\n}\n", "language": "Scala", "metadata": {"date": 1525802595, "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/s257689258.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s257689258", "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 type Record = (Int, Int)\n val list = collection.mutable.ListBuffer[Record]()\n (1 to n).foreach { i =>\n val temp = io.StdIn.readLine().split(' ')\n list += (\n if (temp(2) == \"W\")\n (temp(0).toInt % k2, temp(1).toInt % k2)\n else\n (temp(0).toInt % k2, (temp(1).toInt + k) % k2)\n )\n }\n var max = 0\n (1 to k).foreach { i =>\n (1 to k).foreach { j => \n val cnt = list.count {\n t =>\n val x = (t._1 + i) % k2\n val y = (t._2 + j) % k2\n ( (x < k && y < k) || (x >= k && y >= k))\n }\n max = Math.max(Math.max(cnt, n - cnt), max)\n }\n }\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": "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 738, "cpu_time_ms": 2111, "memory_kb": 47908}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s099956110", "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 // ex) k = 2 \n // □ □ ■ ■\n // k □ □ ■ ■\n // ■ ■ □ □\n // 0 ■ ■ □ □\n // 0 k \n val cnt =\n (squares(k-1)(k-1)) +\n (squares(end)(end) - squares(k-1)(end) - squares(end)(k-1) + squares(k-1)(k-1))\n var max = Math.max(cnt, n - cnt)\n for {\n i <- 0 to k-1\n j <- 0 to k-1\n } {\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 max = Math.max(Math.max(cnt, n - cnt), max)\n }\n print(max)\n}\n", "language": "Scala", "metadata": {"date": 1525872036, "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/s099956110.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s099956110", "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 // ex) k = 2 \n // □ □ ■ ■\n // k □ □ ■ ■\n // ■ ■ □ □\n // 0 ■ ■ □ □\n // 0 k \n val cnt =\n (squares(k-1)(k-1)) +\n (squares(end)(end) - squares(k-1)(end) - squares(end)(k-1) + squares(k-1)(k-1))\n var max = Math.max(cnt, n - cnt)\n for {\n i <- 0 to k-1\n j <- 0 to k-1\n } {\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 max = Math.max(Math.max(cnt, n - cnt), max)\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1492, "cpu_time_ms": 981, "memory_kb": 86060}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s415693058", "group_id": "codeNet:p03469", "input_text": "object Main extends App {\n import scala.util.matching.Regex\n\n val keyValPattern: Regex = \"([0-9]+)/([0-9]+)/([0-9]+)\".r\n\n val input: String = readLine\n\n\n val patternMatch = keyValPattern.findFirstMatchIn(input)\n patternMatch match {\n case Some(m) => println(s\"2018/${m.group(2)}/${m.group(3)}\")\n case _ => println(\"error\")\n }\n}", "language": "Scala", "metadata": {"date": 1575917384, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03469.html", "problem_id": "p03469", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03469/input.txt", "sample_output_relpath": "derived/input_output/data/p03469/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03469/Scala/s415693058.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s415693058", "user_id": "u696665136"}, "prompt_components": {"gold_output": "2018/01/07\n", "input_to_evaluate": "object Main extends App {\n import scala.util.matching.Regex\n\n val keyValPattern: Regex = \"([0-9]+)/([0-9]+)/([0-9]+)\".r\n\n val input: String = readLine\n\n\n val patternMatch = keyValPattern.findFirstMatchIn(input)\n patternMatch match {\n case Some(m) => println(s\"2018/${m.group(2)}/${m.group(3)}\")\n case _ => println(\"error\")\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nOn some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in yyyy/mm/dd format. For example, January 23, 2018 should be written as 2018/01/23.\n\nAfter finishing the document, she noticed that she had mistakenly wrote 2017 at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to 2018 and prints it.\n\nConstraints\n\nS is a string of length 10.\n\nThe first eight characters in S are 2017/01/.\n\nThe last two characters in S are digits and represent an integer between 1 and 31 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nReplace the first four characters in S with 2018 and print it.\n\nSample Input 1\n\n2017/01/07\n\nSample Output 1\n\n2018/01/07\n\nSample Input 2\n\n2017/01/31\n\nSample Output 2\n\n2018/01/31", "sample_input": "2017/01/07\n"}, "reference_outputs": ["2018/01/07\n"], "source_document_id": "p03469", "source_text": "Score : 100 points\n\nProblem Statement\n\nOn some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in yyyy/mm/dd format. For example, January 23, 2018 should be written as 2018/01/23.\n\nAfter finishing the document, she noticed that she had mistakenly wrote 2017 at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to 2018 and prints it.\n\nConstraints\n\nS is a string of length 10.\n\nThe first eight characters in S are 2017/01/.\n\nThe last two characters in S are digits and represent an integer between 1 and 31 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nReplace the first four characters in S with 2018 and print it.\n\nSample Input 1\n\n2017/01/07\n\nSample Output 1\n\n2018/01/07\n\nSample Input 2\n\n2017/01/31\n\nSample Output 2\n\n2018/01/31", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 339, "cpu_time_ms": 332, "memory_kb": 25408}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s010702565", "group_id": "codeNet:p03469", "input_text": "object Main extends App {\n\tvar N = scala.io.StdIn.readLine.toArray\n\tN(3) = '8'\n\tprintln(N.mkString)\n}", "language": "Scala", "metadata": {"date": 1515441212, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03469.html", "problem_id": "p03469", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03469/input.txt", "sample_output_relpath": "derived/input_output/data/p03469/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03469/Scala/s010702565.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s010702565", "user_id": "u675876401"}, "prompt_components": {"gold_output": "2018/01/07\n", "input_to_evaluate": "object Main extends App {\n\tvar N = scala.io.StdIn.readLine.toArray\n\tN(3) = '8'\n\tprintln(N.mkString)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nOn some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in yyyy/mm/dd format. For example, January 23, 2018 should be written as 2018/01/23.\n\nAfter finishing the document, she noticed that she had mistakenly wrote 2017 at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to 2018 and prints it.\n\nConstraints\n\nS is a string of length 10.\n\nThe first eight characters in S are 2017/01/.\n\nThe last two characters in S are digits and represent an integer between 1 and 31 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nReplace the first four characters in S with 2018 and print it.\n\nSample Input 1\n\n2017/01/07\n\nSample Output 1\n\n2018/01/07\n\nSample Input 2\n\n2017/01/31\n\nSample Output 2\n\n2018/01/31", "sample_input": "2017/01/07\n"}, "reference_outputs": ["2018/01/07\n"], "source_document_id": "p03469", "source_text": "Score : 100 points\n\nProblem Statement\n\nOn some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in yyyy/mm/dd format. For example, January 23, 2018 should be written as 2018/01/23.\n\nAfter finishing the document, she noticed that she had mistakenly wrote 2017 at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to 2018 and prints it.\n\nConstraints\n\nS is a string of length 10.\n\nThe first eight characters in S are 2017/01/.\n\nThe last two characters in S are digits and represent an integer between 1 and 31 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nReplace the first four characters in S with 2018 and print it.\n\nSample Input 1\n\n2017/01/07\n\nSample Output 1\n\n2018/01/07\n\nSample Input 2\n\n2017/01/31\n\nSample Output 2\n\n2018/01/31", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 101, "cpu_time_ms": 330, "memory_kb": 27584}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s131998378", "group_id": "codeNet:p03475", "input_text": "import scala.io.StdIn._\n\nobject Main extends App {\n val n = readInt()\n val inputs = List.fill(n - 1)(readLine().split(\" \").map(_.toInt).toList)\n\n for (i <- 0 until n - 1) {\n var time = 0\n for (j <- i until n - 1) {\n val c = inputs(j).head\n val s = inputs(j)(1)\n val f = inputs(j)(2)\n if (time < s)\n time = s\n else if (time % f != 0)\n time += f - (time % f)\n time += c\n }\n println(time)\n }\n\n println(0)\n}\n", "language": "Scala", "metadata": {"date": 1514696198, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03475.html", "problem_id": "p03475", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03475/input.txt", "sample_output_relpath": "derived/input_output/data/p03475/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03475/Scala/s131998378.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s131998378", "user_id": "u478134456"}, "prompt_components": {"gold_output": "12\n11\n0\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main extends App {\n val n = readInt()\n val inputs = List.fill(n - 1)(readLine().split(\" \").map(_.toInt).toList)\n\n for (i <- 0 until n - 1) {\n var time = 0\n for (j <- i until n - 1) {\n val c = inputs(j).head\n val s = inputs(j)(1)\n val f = inputs(j)(2)\n if (time < s)\n time = s\n else if (time % f != 0)\n time += f - (time % f)\n time += c\n }\n println(time)\n }\n\n println(0)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nA railroad running from west to east in Atcoder Kingdom is now complete.\n\nThere are N stations on the railroad, numbered 1 through N from west to east.\n\nTomorrow, the opening ceremony of the railroad will take place.\n\nOn this railroad, for each integer i such that 1≤i≤N-1, there will be trains that run from Station i to Station i+1 in C_i seconds. No other trains will be operated.\n\nThe first train from Station i to Station i+1 will depart Station i S_i seconds after the ceremony begins. Thereafter, there will be a train that departs Station i every F_i seconds.\n\nHere, it is guaranteed that F_i divides S_i.\n\nThat is, for each Time t satisfying S_i≤t and t%F_i=0, there will be a train that departs Station i t seconds after the ceremony begins and arrives at Station i+1 t+C_i seconds after the ceremony begins, where A%B denotes A modulo B, and there will be no other trains.\n\nFor each i, find the earliest possible time we can reach Station N if we are at Station i when the ceremony begins, ignoring the time needed to change trains.\n\nConstraints\n\n1≤N≤500\n\n1≤C_i≤100\n\n1≤S_i≤10^5\n\n1≤F_i≤10\n\nS_i%F_i=0\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nC_1 S_1 F_1\n:\nC_{N-1} S_{N-1} F_{N-1}\n\nOutput\n\nPrint N lines. Assuming that we are at Station i (1≤i≤N) when the ceremony begins, if the earliest possible time we can reach Station N is x seconds after the ceremony begins, the i-th line should contain x.\n\nSample Input 1\n\n3\n6 5 1\n1 10 1\n\nSample Output 1\n\n12\n11\n0\n\nWe will travel from Station 1 as follows:\n\n5 seconds after the beginning: take the train to Station 2.\n\n11 seconds: arrive at Station 2.\n\n11 seconds: take the train to Station 3.\n\n12 seconds: arrive at Station 3.\n\nWe will travel from Station 2 as follows:\n\n10 seconds: take the train to Station 3.\n\n11 seconds: arrive at Station 3.\n\nNote that we should print 0 for Station 3.\n\nSample Input 2\n\n4\n12 24 6\n52 16 4\n99 2 2\n\nSample Output 2\n\n187\n167\n101\n0\n\nSample Input 3\n\n4\n12 13 1\n44 17 17\n66 4096 64\n\nSample Output 3\n\n4162\n4162\n4162\n0", "sample_input": "3\n6 5 1\n1 10 1\n"}, "reference_outputs": ["12\n11\n0\n"], "source_document_id": "p03475", "source_text": "Score : 300 points\n\nProblem Statement\n\nA railroad running from west to east in Atcoder Kingdom is now complete.\n\nThere are N stations on the railroad, numbered 1 through N from west to east.\n\nTomorrow, the opening ceremony of the railroad will take place.\n\nOn this railroad, for each integer i such that 1≤i≤N-1, there will be trains that run from Station i to Station i+1 in C_i seconds. No other trains will be operated.\n\nThe first train from Station i to Station i+1 will depart Station i S_i seconds after the ceremony begins. Thereafter, there will be a train that departs Station i every F_i seconds.\n\nHere, it is guaranteed that F_i divides S_i.\n\nThat is, for each Time t satisfying S_i≤t and t%F_i=0, there will be a train that departs Station i t seconds after the ceremony begins and arrives at Station i+1 t+C_i seconds after the ceremony begins, where A%B denotes A modulo B, and there will be no other trains.\n\nFor each i, find the earliest possible time we can reach Station N if we are at Station i when the ceremony begins, ignoring the time needed to change trains.\n\nConstraints\n\n1≤N≤500\n\n1≤C_i≤100\n\n1≤S_i≤10^5\n\n1≤F_i≤10\n\nS_i%F_i=0\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nC_1 S_1 F_1\n:\nC_{N-1} S_{N-1} F_{N-1}\n\nOutput\n\nPrint N lines. Assuming that we are at Station i (1≤i≤N) when the ceremony begins, if the earliest possible time we can reach Station N is x seconds after the ceremony begins, the i-th line should contain x.\n\nSample Input 1\n\n3\n6 5 1\n1 10 1\n\nSample Output 1\n\n12\n11\n0\n\nWe will travel from Station 1 as follows:\n\n5 seconds after the beginning: take the train to Station 2.\n\n11 seconds: arrive at Station 2.\n\n11 seconds: take the train to Station 3.\n\n12 seconds: arrive at Station 3.\n\nWe will travel from Station 2 as follows:\n\n10 seconds: take the train to Station 3.\n\n11 seconds: arrive at Station 3.\n\nNote that we should print 0 for Station 3.\n\nSample Input 2\n\n4\n12 24 6\n52 16 4\n99 2 2\n\nSample Output 2\n\n187\n167\n101\n0\n\nSample Input 3\n\n4\n12 13 1\n44 17 17\n66 4096 64\n\nSample Output 3\n\n4162\n4162\n4162\n0", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 465, "cpu_time_ms": 1053, "memory_kb": 27908}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s959015905", "group_id": "codeNet:p03479", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val in = readLine.split(\" \").map(_.toDouble)\n val X = in(0)\n val Y = in(1)\n\n val lnOf2 = scala.math.log(2)\n val log = (scala.math.log(Y / X) / lnOf2 + 1.0).floor.toInt\n\n print(log)\n }\n}", "language": "Scala", "metadata": {"date": 1514083884, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03479.html", "problem_id": "p03479", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03479/input.txt", "sample_output_relpath": "derived/input_output/data/p03479/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03479/Scala/s959015905.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s959015905", "user_id": "u173561231"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val in = readLine.split(\" \").map(_.toDouble)\n val X = in(0)\n val Y = in(1)\n\n val lnOf2 = scala.math.log(2)\n val log = (scala.math.log(Y / X) / lnOf2 + 1.0).floor.toInt\n\n print(log)\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAs a token of his gratitude, Takahashi has decided to give his mother an integer sequence.\nThe sequence A needs to satisfy the conditions below:\n\nA consists of integers between X and Y (inclusive).\n\nFor each 1\\leq i \\leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i.\n\nFind the maximum possible length of the sequence.\n\nConstraints\n\n1 \\leq X \\leq Y \\leq 10^{18}\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the maximum possible length of the sequence.\n\nSample Input 1\n\n3 20\n\nSample Output 1\n\n3\n\nThe sequence 3,6,18 satisfies the conditions.\n\nSample Input 2\n\n25 100\n\nSample Output 2\n\n3\n\nSample Input 3\n\n314159265 358979323846264338\n\nSample Output 3\n\n31", "sample_input": "3 20\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03479", "source_text": "Score : 300 points\n\nProblem Statement\n\nAs a token of his gratitude, Takahashi has decided to give his mother an integer sequence.\nThe sequence A needs to satisfy the conditions below:\n\nA consists of integers between X and Y (inclusive).\n\nFor each 1\\leq i \\leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i.\n\nFind the maximum possible length of the sequence.\n\nConstraints\n\n1 \\leq X \\leq Y \\leq 10^{18}\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the maximum possible length of the sequence.\n\nSample Input 1\n\n3 20\n\nSample Output 1\n\n3\n\nThe sequence 3,6,18 satisfies the conditions.\n\nSample Input 2\n\n25 100\n\nSample Output 2\n\n3\n\nSample Input 3\n\n314159265 358979323846264338\n\nSample Output 3\n\n31", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 261, "cpu_time_ms": 328, "memory_kb": 25664}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s840921396", "group_id": "codeNet:p03479", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val in = readLine.split(\" \").map(_.toInt)\n val X = in(0)\n val Y = in(1)\n\n val max = (Y / X).toDouble\n \n val lnOf2 = scala.math.log(2)\n val log = (scala.math.log(max) / lnOf2 + 1.0).floor.toInt\n\n print(log)\n }\n}", "language": "Scala", "metadata": {"date": 1514083304, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03479.html", "problem_id": "p03479", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03479/input.txt", "sample_output_relpath": "derived/input_output/data/p03479/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03479/Scala/s840921396.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s840921396", "user_id": "u173561231"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val in = readLine.split(\" \").map(_.toInt)\n val X = in(0)\n val Y = in(1)\n\n val max = (Y / X).toDouble\n \n val lnOf2 = scala.math.log(2)\n val log = (scala.math.log(max) / lnOf2 + 1.0).floor.toInt\n\n print(log)\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAs a token of his gratitude, Takahashi has decided to give his mother an integer sequence.\nThe sequence A needs to satisfy the conditions below:\n\nA consists of integers between X and Y (inclusive).\n\nFor each 1\\leq i \\leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i.\n\nFind the maximum possible length of the sequence.\n\nConstraints\n\n1 \\leq X \\leq Y \\leq 10^{18}\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the maximum possible length of the sequence.\n\nSample Input 1\n\n3 20\n\nSample Output 1\n\n3\n\nThe sequence 3,6,18 satisfies the conditions.\n\nSample Input 2\n\n25 100\n\nSample Output 2\n\n3\n\nSample Input 3\n\n314159265 358979323846264338\n\nSample Output 3\n\n31", "sample_input": "3 20\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03479", "source_text": "Score : 300 points\n\nProblem Statement\n\nAs a token of his gratitude, Takahashi has decided to give his mother an integer sequence.\nThe sequence A needs to satisfy the conditions below:\n\nA consists of integers between X and Y (inclusive).\n\nFor each 1\\leq i \\leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i.\n\nFind the maximum possible length of the sequence.\n\nConstraints\n\n1 \\leq X \\leq Y \\leq 10^{18}\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the maximum possible length of the sequence.\n\nSample Input 1\n\n3 20\n\nSample Output 1\n\n3\n\nThe sequence 3,6,18 satisfies the conditions.\n\nSample Input 2\n\n25 100\n\nSample Output 2\n\n3\n\nSample Input 3\n\n314159265 358979323846264338\n\nSample Output 3\n\n31", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 292, "cpu_time_ms": 322, "memory_kb": 27212}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s403191289", "group_id": "codeNet:p03485", "input_text": "\nobject Main extends App {\n\tval ab = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\n\tif(ab.sum % 2 == 1){\n\t\tprintln(ab.sum/2 + 1)\t\n\t}else{\n\t\tprintln(ab.sum/2)\n\t}\n\t \n}", "language": "Scala", "metadata": {"date": 1513477392, "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/s403191289.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s403191289", "user_id": "u675876401"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "\nobject Main extends App {\n\tval ab = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\n\tif(ab.sum % 2 == 1){\n\t\tprintln(ab.sum/2 + 1)\t\n\t}else{\n\t\tprintln(ab.sum/2)\n\t}\n\t \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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 336, "memory_kb": 25528}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s805130586", "group_id": "codeNet:p03486", "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 s: String = sc.nextLine()\n val t: String = sc.nextLine()\n\n if (s.sorted < t.sorted.reverse) println(\"Yes\")\n else println(\"No\")\n }\n}\n", "language": "Scala", "metadata": {"date": 1558264607, "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/s805130586.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s805130586", "user_id": "u629133942"}, "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: Scanner = new Scanner(System.in)\n val s: String = sc.nextLine()\n val t: String = sc.nextLine()\n\n if (s.sorted < t.sorted.reverse) println(\"Yes\")\n else println(\"No\")\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given strings s and t, consisting of lowercase English letters.\nYou will create a string s' by freely rearranging the characters in s.\nYou will also create a string t' by freely rearranging the characters in t.\nDetermine whether it is possible to satisfy s' < t' for the lexicographic order.\n\nNotes\n\nFor a string a = a_1 a_2 ... a_N of length N and a string b = b_1 b_2 ... b_M of length M, we say a < b for the lexicographic order if either one of the following two conditions holds true:\n\nN < M and a_1 = b_1, a_2 = b_2, ..., a_N = b_N.\n\nThere exists i (1 \\leq i \\leq N, M) such that a_1 = b_1, a_2 = b_2, ..., a_{i - 1} = b_{i - 1} and a_i < b_i. Here, letters are compared using alphabetical order.\n\nFor example, xy < xya and atcoder < atlas.\n\nConstraints\n\nThe lengths of s and t are between 1 and 100 (inclusive).\n\ns and t consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf it is possible to satisfy s' < t', print Yes; if it is not, print No.\n\nSample Input 1\n\nyx\naxy\n\nSample Output 1\n\nYes\n\nWe can, for example, rearrange yx into xy and axy into yxa. Then, xy < yxa.\n\nSample Input 2\n\nratcode\natlas\n\nSample Output 2\n\nYes\n\nWe can, for example, rearrange ratcode into acdeort and atlas into tslaa. Then, acdeort < tslaa.\n\nSample Input 3\n\ncd\nabc\n\nSample Output 3\n\nNo\n\nNo matter how we rearrange cd and abc, we cannot achieve our objective.\n\nSample Input 4\n\nw\nww\n\nSample Output 4\n\nYes\n\nSample Input 5\n\nzzz\nzzz\n\nSample Output 5\n\nNo", "sample_input": "yx\naxy\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03486", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given strings s and t, consisting of lowercase English letters.\nYou will create a string s' by freely rearranging the characters in s.\nYou will also create a string t' by freely rearranging the characters in t.\nDetermine whether it is possible to satisfy s' < t' for the lexicographic order.\n\nNotes\n\nFor a string a = a_1 a_2 ... a_N of length N and a string b = b_1 b_2 ... b_M of length M, we say a < b for the lexicographic order if either one of the following two conditions holds true:\n\nN < M and a_1 = b_1, a_2 = b_2, ..., a_N = b_N.\n\nThere exists i (1 \\leq i \\leq N, M) such that a_1 = b_1, a_2 = b_2, ..., a_{i - 1} = b_{i - 1} and a_i < b_i. Here, letters are compared using alphabetical order.\n\nFor example, xy < xya and atcoder < atlas.\n\nConstraints\n\nThe lengths of s and t are between 1 and 100 (inclusive).\n\ns and t consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf it is possible to satisfy s' < t', print Yes; if it is not, print No.\n\nSample Input 1\n\nyx\naxy\n\nSample Output 1\n\nYes\n\nWe can, for example, rearrange yx into xy and axy into yxa. Then, xy < yxa.\n\nSample Input 2\n\nratcode\natlas\n\nSample Output 2\n\nYes\n\nWe can, for example, rearrange ratcode into acdeort and atlas into tslaa. Then, acdeort < tslaa.\n\nSample Input 3\n\ncd\nabc\n\nSample Output 3\n\nNo\n\nNo matter how we rearrange cd and abc, we cannot achieve our objective.\n\nSample Input 4\n\nw\nww\n\nSample Output 4\n\nYes\n\nSample Input 5\n\nzzz\nzzz\n\nSample Output 5\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 277, "cpu_time_ms": 355, "memory_kb": 25552}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s498858529", "group_id": "codeNet:p03486", "input_text": "\nobject Main extends App {\n\tval s = scala.io.StdIn.readLine.toList.sorted\n\tval t = scala.io.StdIn.readLine.toList.sorted.reverse\n\n\tdef check(a: List[Char], b: List[Char]): Boolean = {\n\t\ta match {\n\t\t\tcase e::rest => if(e == b.head) check(rest, b.tail)\n\t\t\t\t\t\t\telse if( e < b.head) true\n\t\t\t\t\t\t\telse false\n\t\t\tcase Nil => b match {\n\t\t\t\tcase Nil => false\n\t\t\t\tcase _ => true \n\t\t\t}\n\t\t}\t\n\t} \n\n\tif(check(s,t)) println(\"Yes\")\n\telse println(\"No\")\n}", "language": "Scala", "metadata": {"date": 1513478297, "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/s498858529.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s498858529", "user_id": "u675876401"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "\nobject Main extends App {\n\tval s = scala.io.StdIn.readLine.toList.sorted\n\tval t = scala.io.StdIn.readLine.toList.sorted.reverse\n\n\tdef check(a: List[Char], b: List[Char]): Boolean = {\n\t\ta match {\n\t\t\tcase e::rest => if(e == b.head) check(rest, b.tail)\n\t\t\t\t\t\t\telse if( e < b.head) true\n\t\t\t\t\t\t\telse false\n\t\t\tcase Nil => b match {\n\t\t\t\tcase Nil => false\n\t\t\t\tcase _ => true \n\t\t\t}\n\t\t}\t\n\t} \n\n\tif(check(s,t)) println(\"Yes\")\n\telse println(\"No\")\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given strings s and t, consisting of lowercase English letters.\nYou will create a string s' by freely rearranging the characters in s.\nYou will also create a string t' by freely rearranging the characters in t.\nDetermine whether it is possible to satisfy s' < t' for the lexicographic order.\n\nNotes\n\nFor a string a = a_1 a_2 ... a_N of length N and a string b = b_1 b_2 ... b_M of length M, we say a < b for the lexicographic order if either one of the following two conditions holds true:\n\nN < M and a_1 = b_1, a_2 = b_2, ..., a_N = b_N.\n\nThere exists i (1 \\leq i \\leq N, M) such that a_1 = b_1, a_2 = b_2, ..., a_{i - 1} = b_{i - 1} and a_i < b_i. Here, letters are compared using alphabetical order.\n\nFor example, xy < xya and atcoder < atlas.\n\nConstraints\n\nThe lengths of s and t are between 1 and 100 (inclusive).\n\ns and t consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf it is possible to satisfy s' < t', print Yes; if it is not, print No.\n\nSample Input 1\n\nyx\naxy\n\nSample Output 1\n\nYes\n\nWe can, for example, rearrange yx into xy and axy into yxa. Then, xy < yxa.\n\nSample Input 2\n\nratcode\natlas\n\nSample Output 2\n\nYes\n\nWe can, for example, rearrange ratcode into acdeort and atlas into tslaa. Then, acdeort < tslaa.\n\nSample Input 3\n\ncd\nabc\n\nSample Output 3\n\nNo\n\nNo matter how we rearrange cd and abc, we cannot achieve our objective.\n\nSample Input 4\n\nw\nww\n\nSample Output 4\n\nYes\n\nSample Input 5\n\nzzz\nzzz\n\nSample Output 5\n\nNo", "sample_input": "yx\naxy\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03486", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given strings s and t, consisting of lowercase English letters.\nYou will create a string s' by freely rearranging the characters in s.\nYou will also create a string t' by freely rearranging the characters in t.\nDetermine whether it is possible to satisfy s' < t' for the lexicographic order.\n\nNotes\n\nFor a string a = a_1 a_2 ... a_N of length N and a string b = b_1 b_2 ... b_M of length M, we say a < b for the lexicographic order if either one of the following two conditions holds true:\n\nN < M and a_1 = b_1, a_2 = b_2, ..., a_N = b_N.\n\nThere exists i (1 \\leq i \\leq N, M) such that a_1 = b_1, a_2 = b_2, ..., a_{i - 1} = b_{i - 1} and a_i < b_i. Here, letters are compared using alphabetical order.\n\nFor example, xy < xya and atcoder < atlas.\n\nConstraints\n\nThe lengths of s and t are between 1 and 100 (inclusive).\n\ns and t consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf it is possible to satisfy s' < t', print Yes; if it is not, print No.\n\nSample Input 1\n\nyx\naxy\n\nSample Output 1\n\nYes\n\nWe can, for example, rearrange yx into xy and axy into yxa. Then, xy < yxa.\n\nSample Input 2\n\nratcode\natlas\n\nSample Output 2\n\nYes\n\nWe can, for example, rearrange ratcode into acdeort and atlas into tslaa. Then, acdeort < tslaa.\n\nSample Input 3\n\ncd\nabc\n\nSample Output 3\n\nNo\n\nNo matter how we rearrange cd and abc, we cannot achieve our objective.\n\nSample Input 4\n\nw\nww\n\nSample Output 4\n\nYes\n\nSample Input 5\n\nzzz\nzzz\n\nSample Output 5\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 438, "cpu_time_ms": 331, "memory_kb": 27328}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s282025525", "group_id": "codeNet:p03487", "input_text": "// Abx082 C\nobject Main extends App {\n val sc = new java.util.Scanner(System.in)\n\n val n = scala.io.StdIn.readLine.toInt\n val list = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n val map = list.groupBy(identity).mapValues(_.length).toMap\n var delete_count = 0\n var checked = Map[Int, Boolean]()\n\n list.foreach({e =>\n if (checked.isDefinedAt(e)) {\n } else {\n if (map(e) > e) {\n delete_count += map(e) - e\n }\n\n if (map(e) < e) {\n delete_count += map(e)\n }\n\n checked += (e -> true)\n }\n })\n println(delete_count)\n}\n", "language": "Scala", "metadata": {"date": 1585700949, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03487.html", "problem_id": "p03487", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03487/input.txt", "sample_output_relpath": "derived/input_output/data/p03487/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03487/Scala/s282025525.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s282025525", "user_id": "u393913844"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "// Abx082 C\nobject Main extends App {\n val sc = new java.util.Scanner(System.in)\n\n val n = scala.io.StdIn.readLine.toInt\n val list = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n val map = list.groupBy(identity).mapValues(_.length).toMap\n var delete_count = 0\n var checked = Map[Int, Boolean]()\n\n list.foreach({e =>\n if (checked.isDefinedAt(e)) {\n } else {\n if (map(e) > e) {\n delete_count += map(e) - e\n }\n\n if (map(e) < e) {\n delete_count += map(e)\n }\n\n checked += (e -> true)\n }\n })\n println(delete_count)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N).\nYour objective is to remove some of the elements in a so that a will be a good sequence.\n\nHere, an sequence b is a good sequence when the following condition holds true:\n\nFor each element x in b, the value x occurs exactly x times in b.\n\nFor example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not.\n\nFind the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\na_i is an integer.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nSample Input 1\n\n4\n3 3 3 3\n\nSample Output 1\n\n1\n\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2\n\n5\n2 4 1 4 2\n\nSample Output 2\n\n2\n\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3\n\n6\n1 2 2 3 3 3\n\nSample Output 3\n\n0\n\nSample Input 4\n\n1\n1000000000\n\nSample Output 4\n\n1\n\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5\n\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5\n\n5", "sample_input": "4\n3 3 3 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03487", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N).\nYour objective is to remove some of the elements in a so that a will be a good sequence.\n\nHere, an sequence b is a good sequence when the following condition holds true:\n\nFor each element x in b, the value x occurs exactly x times in b.\n\nFor example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not.\n\nFind the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\na_i is an integer.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nSample Input 1\n\n4\n3 3 3 3\n\nSample Output 1\n\n1\n\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2\n\n5\n2 4 1 4 2\n\nSample Output 2\n\n2\n\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3\n\n6\n1 2 2 3 3 3\n\nSample Output 3\n\n0\n\nSample Input 4\n\n1\n1000000000\n\nSample Output 4\n\n1\n\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5\n\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 571, "cpu_time_ms": 1230, "memory_kb": 116188}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s781571628", "group_id": "codeNet:p03487", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n\n val sc = new Scanner(System.in)\n\n val n = sc.nextInt\n val al = Seq.fill(n)(sc.nextInt)\n\n val containsCounts =\n al.foldLeft(Map.empty[Int, Int]){ case (m, e) =>\n if (m.isDefinedAt(e)) m.updated(e, m(e) + 1)\n else Map(e -> 1) ++ m\n\n // m で定義されている => mapValue\n // m で定義されていない=> mapを追加\n }\n\n// val aDistinct = al.distinct\n\n// val containsCounts =\n// aDistinct.map{ e =>\n// e -> al.count(_ == e)\n// }\n\n val res =\n containsCounts.foldLeft(0){case (acc, (e,cnt)) =>\n val added =\n if(e > cnt) cnt else cnt - e\n acc + added\n }\n\n println(res)\n}", "language": "Scala", "metadata": {"date": 1576346999, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03487.html", "problem_id": "p03487", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03487/input.txt", "sample_output_relpath": "derived/input_output/data/p03487/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03487/Scala/s781571628.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s781571628", "user_id": "u829407811"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n\n val sc = new Scanner(System.in)\n\n val n = sc.nextInt\n val al = Seq.fill(n)(sc.nextInt)\n\n val containsCounts =\n al.foldLeft(Map.empty[Int, Int]){ case (m, e) =>\n if (m.isDefinedAt(e)) m.updated(e, m(e) + 1)\n else Map(e -> 1) ++ m\n\n // m で定義されている => mapValue\n // m で定義されていない=> mapを追加\n }\n\n// val aDistinct = al.distinct\n\n// val containsCounts =\n// aDistinct.map{ e =>\n// e -> al.count(_ == e)\n// }\n\n val res =\n containsCounts.foldLeft(0){case (acc, (e,cnt)) =>\n val added =\n if(e > cnt) cnt else cnt - e\n acc + added\n }\n\n println(res)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N).\nYour objective is to remove some of the elements in a so that a will be a good sequence.\n\nHere, an sequence b is a good sequence when the following condition holds true:\n\nFor each element x in b, the value x occurs exactly x times in b.\n\nFor example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not.\n\nFind the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\na_i is an integer.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nSample Input 1\n\n4\n3 3 3 3\n\nSample Output 1\n\n1\n\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2\n\n5\n2 4 1 4 2\n\nSample Output 2\n\n2\n\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3\n\n6\n1 2 2 3 3 3\n\nSample Output 3\n\n0\n\nSample Input 4\n\n1\n1000000000\n\nSample Output 4\n\n1\n\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5\n\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5\n\n5", "sample_input": "4\n3 3 3 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03487", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N).\nYour objective is to remove some of the elements in a so that a will be a good sequence.\n\nHere, an sequence b is a good sequence when the following condition holds true:\n\nFor each element x in b, the value x occurs exactly x times in b.\n\nFor example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not.\n\nFind the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\na_i is an integer.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nSample Input 1\n\n4\n3 3 3 3\n\nSample Output 1\n\n1\n\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2\n\n5\n2 4 1 4 2\n\nSample Output 2\n\n2\n\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3\n\n6\n1 2 2 3 3 3\n\nSample Output 3\n\n0\n\nSample Input 4\n\n1\n1000000000\n\nSample Output 4\n\n1\n\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5\n\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 694, "cpu_time_ms": 2111, "memory_kb": 124864}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s856516731", "group_id": "codeNet:p03487", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n\n val n = StdIn.readLine.toInt\n val seq = StdIn.readLine.split(\" \").map(_.toInt).sorted.toBuffer\n seq ++= Array(0)\n\n\n val ans = {\n seq.foldLeft(0,0,0)((acc,e) => {\n // println(acc._1 + \" \" + acc._2 + \" \" + acc._3)\n if(acc._1 != e) {\n if(acc._1 != acc._2) {\n if(acc._2 < acc._1) (e, 1, acc._3 + acc._2)\n else (e, 1, acc._3 + acc._2 - acc._1)\n }\n else (e, 1, acc._3)\n } else {\n (e, acc._2+1, acc._3)\n }\n })._3\n }\n\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1544996383, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03487.html", "problem_id": "p03487", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03487/input.txt", "sample_output_relpath": "derived/input_output/data/p03487/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03487/Scala/s856516731.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s856516731", "user_id": "u217010036"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n\n val n = StdIn.readLine.toInt\n val seq = StdIn.readLine.split(\" \").map(_.toInt).sorted.toBuffer\n seq ++= Array(0)\n\n\n val ans = {\n seq.foldLeft(0,0,0)((acc,e) => {\n // println(acc._1 + \" \" + acc._2 + \" \" + acc._3)\n if(acc._1 != e) {\n if(acc._1 != acc._2) {\n if(acc._2 < acc._1) (e, 1, acc._3 + acc._2)\n else (e, 1, acc._3 + acc._2 - acc._1)\n }\n else (e, 1, acc._3)\n } else {\n (e, acc._2+1, acc._3)\n }\n })._3\n }\n\n println(ans)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N).\nYour objective is to remove some of the elements in a so that a will be a good sequence.\n\nHere, an sequence b is a good sequence when the following condition holds true:\n\nFor each element x in b, the value x occurs exactly x times in b.\n\nFor example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not.\n\nFind the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\na_i is an integer.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nSample Input 1\n\n4\n3 3 3 3\n\nSample Output 1\n\n1\n\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2\n\n5\n2 4 1 4 2\n\nSample Output 2\n\n2\n\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3\n\n6\n1 2 2 3 3 3\n\nSample Output 3\n\n0\n\nSample Input 4\n\n1\n1000000000\n\nSample Output 4\n\n1\n\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5\n\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5\n\n5", "sample_input": "4\n3 3 3 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03487", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N).\nYour objective is to remove some of the elements in a so that a will be a good sequence.\n\nHere, an sequence b is a good sequence when the following condition holds true:\n\nFor each element x in b, the value x occurs exactly x times in b.\n\nFor example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not.\n\nFind the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\na_i is an integer.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nSample Input 1\n\n4\n3 3 3 3\n\nSample Output 1\n\n1\n\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2\n\n5\n2 4 1 4 2\n\nSample Output 2\n\n2\n\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3\n\n6\n1 2 2 3 3 3\n\nSample Output 3\n\n0\n\nSample Input 4\n\n1\n1000000000\n\nSample Output 4\n\n1\n\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5\n\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 549, "cpu_time_ms": 768, "memory_kb": 50840}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s874060065", "group_id": "codeNet:p03487", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n val n = StdIn.readLine().toInt\n val a = StdIn.readLine().split(' ').map(_.toLong)\n \n val b = a.groupBy(f => f)\n println(b.foldLeft(0L)( (acc, e) => acc + (if(e._2.length >= e._1) e._2.length - e._1 else e._2.length)))\n \n}", "language": "Scala", "metadata": {"date": 1526845469, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03487.html", "problem_id": "p03487", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03487/input.txt", "sample_output_relpath": "derived/input_output/data/p03487/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03487/Scala/s874060065.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s874060065", "user_id": "u895032849"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n val n = StdIn.readLine().toInt\n val a = StdIn.readLine().split(' ').map(_.toLong)\n \n val b = a.groupBy(f => f)\n println(b.foldLeft(0L)( (acc, e) => acc + (if(e._2.length >= e._1) e._2.length - e._1 else e._2.length)))\n \n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N).\nYour objective is to remove some of the elements in a so that a will be a good sequence.\n\nHere, an sequence b is a good sequence when the following condition holds true:\n\nFor each element x in b, the value x occurs exactly x times in b.\n\nFor example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not.\n\nFind the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\na_i is an integer.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nSample Input 1\n\n4\n3 3 3 3\n\nSample Output 1\n\n1\n\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2\n\n5\n2 4 1 4 2\n\nSample Output 2\n\n2\n\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3\n\n6\n1 2 2 3 3 3\n\nSample Output 3\n\n0\n\nSample Input 4\n\n1\n1000000000\n\nSample Output 4\n\n1\n\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5\n\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5\n\n5", "sample_input": "4\n3 3 3 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03487", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N).\nYour objective is to remove some of the elements in a so that a will be a good sequence.\n\nHere, an sequence b is a good sequence when the following condition holds true:\n\nFor each element x in b, the value x occurs exactly x times in b.\n\nFor example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not.\n\nFind the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\na_i is an integer.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nSample Input 1\n\n4\n3 3 3 3\n\nSample Output 1\n\n1\n\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2\n\n5\n2 4 1 4 2\n\nSample Output 2\n\n2\n\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3\n\n6\n1 2 2 3 3 3\n\nSample Output 3\n\n0\n\nSample Input 4\n\n1\n1000000000\n\nSample Output 4\n\n1\n\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5\n\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 277, "cpu_time_ms": 1086, "memory_kb": 96408}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s392534321", "group_id": "codeNet:p03494", "input_text": "object Main {\n def main(args: Array[String]) {\n val sc = new java.util.Scanner(System.in);\n sc.nextLine()\n val line = sc.nextLine().split(\" \").map(_.toInt);\n println(calc(line, 0));\n }\n\n def calc(line:Array[Int], count:Int) : String = {\n if (line.count(_.toInt%2==0) == line.size) {\n calc(line.map(_.toInt/2), count+1);\n } else {\n count.toString\n }\n }\n}", "language": "Scala", "metadata": {"date": 1581902020, "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/s392534321.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s392534321", "user_id": "u822961851"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]) {\n val sc = new java.util.Scanner(System.in);\n sc.nextLine()\n val line = sc.nextLine().split(\" \").map(_.toInt);\n println(calc(line, 0));\n }\n\n def calc(line:Array[Int], count:Int) : String = {\n if (line.count(_.toInt%2==0) == line.size) {\n calc(line.map(_.toInt/2), count+1);\n } else {\n count.toString\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 391, "memory_kb": 25896}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s156737611", "group_id": "codeNet:p03498", "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)\n\n for (i <- 0 until N) {\n a(i) = in.next().toInt\n }\n\n var mx = a.max\n var mn = a.min\n\n def printer(ans: List[(Int, Int)]): Unit = {\n pw.println(ans.length)\n for (e <- ans)\n pw.println(s\"${e._1} ${e._2}\")\n pw.flush()\n }\n\n var ans: List[(Int, Int)] = List()\n\n if (Math.abs(mx) == 0 && Math.abs(mn) == 0) {\n println(0)\n }\n else if (Math.abs(mx) > Math.abs(mn)) {\n var ind = 0\n for (i <- 0 until N) {\n if(a(i) == mx)\n ind = i\n }\n\n for(i <- 1 until N) {\n while(a(i) < a(i-1)) {\n ans = (ind+1, i+1) :: ans\n a(i) += mx\n if(a(i) > mx) {\n mx = a(i)\n ind = i\n }\n }\n }\n\n printer(ans)\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": 1526944512, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03498.html", "problem_id": "p03498", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03498/input.txt", "sample_output_relpath": "derived/input_output/data/p03498/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03498/Scala/s156737611.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s156737611", "user_id": "u098968285"}, "prompt_components": {"gold_output": "2\n2 3\n3 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 N = in.next().toInt\n val a = new Array[Int](N)\n\n for (i <- 0 until N) {\n a(i) = in.next().toInt\n }\n\n var mx = a.max\n var mn = a.min\n\n def printer(ans: List[(Int, Int)]): Unit = {\n pw.println(ans.length)\n for (e <- ans)\n pw.println(s\"${e._1} ${e._2}\")\n pw.flush()\n }\n\n var ans: List[(Int, Int)] = List()\n\n if (Math.abs(mx) == 0 && Math.abs(mn) == 0) {\n println(0)\n }\n else if (Math.abs(mx) > Math.abs(mn)) {\n var ind = 0\n for (i <- 0 until N) {\n if(a(i) == mx)\n ind = i\n }\n\n for(i <- 1 until N) {\n while(a(i) < a(i-1)) {\n ans = (ind+1, i+1) :: ans\n a(i) += mx\n if(a(i) > mx) {\n mx = a(i)\n ind = i\n }\n }\n }\n\n printer(ans)\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 : 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": "p03498", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1314, "cpu_time_ms": 2115, "memory_kb": 237808}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s600097219", "group_id": "codeNet:p03501", "input_text": "import scala.math._\n\nobject Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n, a, b = 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": 1562287545, "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/s600097219.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s600097219", "user_id": "u040380439"}, "prompt_components": {"gold_output": "119\n", "input_to_evaluate": "import scala.math._\n\nobject Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n, a, b = 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\nYou are parking at a parking lot. You can choose from the following two fee plans:\n\nPlan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.\n\nPlan 2: The fee will be B yen, regardless of the duration.\n\nFind the minimum fee when you park for N hours.\n\nConstraints\n\n1≤N≤20\n\n1≤A≤100\n\n1≤B≤2000\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nWhen the minimum fee is x yen, print the value of x.\n\nSample Input 1\n\n7 17 120\n\nSample Output 1\n\n119\n\nIf you choose Plan 1, the fee will be 7×17=119 yen.\n\nIf you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\nSample Input 2\n\n5 20 100\n\nSample Output 2\n\n100\n\nThe fee might be the same in the two plans.\n\nSample Input 3\n\n6 18 100\n\nSample Output 3\n\n100", "sample_input": "7 17 120\n"}, "reference_outputs": ["119\n"], "source_document_id": "p03501", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are parking at a parking lot. You can choose from the following two fee plans:\n\nPlan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.\n\nPlan 2: The fee will be B yen, regardless of the duration.\n\nFind the minimum fee when you park for N hours.\n\nConstraints\n\n1≤N≤20\n\n1≤A≤100\n\n1≤B≤2000\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nWhen the minimum fee is x yen, print the value of x.\n\nSample Input 1\n\n7 17 120\n\nSample Output 1\n\n119\n\nIf you choose Plan 1, the fee will be 7×17=119 yen.\n\nIf you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\nSample Input 2\n\n5 20 100\n\nSample Output 2\n\n100\n\nThe fee might be the same in the two plans.\n\nSample Input 3\n\n6 18 100\n\nSample Output 3\n\n100", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 784, "cpu_time_ms": 344, "memory_kb": 27448}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s568621750", "group_id": "codeNet:p03503", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt()\n val m = 10\n val f = Array.fill(n * m)(sc.nextInt())\n val p = Array.fill(n * (m+1))(sc.nextInt())\n\n var ans = Long.MinValue\n for (s <- 1 until 1 << m) {\n var ansSub = 0L\n for (i <- 0 until n) {\n val count = (0 until m).count(j => ((s >> j) & f(i*m + j)) == 1)\n ansSub += p(i*(m+1) + count)\n }\n\n ans = ans.max(ansSub)\n }\n\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1598207685, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03503.html", "problem_id": "p03503", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03503/input.txt", "sample_output_relpath": "derived/input_output/data/p03503/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03503/Scala/s568621750.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s568621750", "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 = sc.nextInt()\n val m = 10\n val f = Array.fill(n * m)(sc.nextInt())\n val p = Array.fill(n * (m+1))(sc.nextInt())\n\n var ans = Long.MinValue\n for (s <- 1 until 1 << m) {\n var ansSub = 0L\n for (i <- 0 until n) {\n val count = (0 until m).count(j => ((s >> j) & f(i*m + j)) == 1)\n ansSub += p(i*(m+1) + count)\n }\n\n ans = ans.max(ansSub)\n }\n\n println(ans)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nJoisino is planning to open a shop in a shopping street.\n\nEach of the five weekdays is divided into two periods, the morning and the evening. For each of those ten periods, a shop must be either open during the whole period, or closed during the whole period. Naturally, a shop must be open during at least one of those periods.\n\nThere are already N stores in the street, numbered 1 through N.\n\nYou are given information of the business hours of those shops, F_{i,j,k}. If F_{i,j,k}=1, Shop i is open during Period k on Day j (this notation is explained below); if F_{i,j,k}=0, Shop i is closed during that period. Here, the days of the week are denoted as follows. Monday: Day 1, Tuesday: Day 2, Wednesday: Day 3, Thursday: Day 4, Friday: Day 5. Also, the morning is denoted as Period 1, and the afternoon is denoted as Period 2.\n\nLet c_i be the number of periods during which both Shop i and Joisino's shop are open. Then, the profit of Joisino's shop will be P_{1,c_1}+P_{2,c_2}+...+P_{N,c_N}.\n\nFind the maximum possible profit of Joisino's shop when she decides whether her shop is open during each period, making sure that it is open during at least one period.\n\nConstraints\n\n1≤N≤100\n\n0≤F_{i,j,k}≤1\n\nFor every integer i such that 1≤i≤N, there exists at least one pair (j,k) such that F_{i,j,k}=1.\n\n-10^7≤P_{i,j}≤10^7\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nF_{1,1,1} F_{1,1,2} ... F_{1,5,1} F_{1,5,2}\n:\nF_{N,1,1} F_{N,1,2} ... F_{N,5,1} F_{N,5,2}\nP_{1,0} ... P_{1,10}\n:\nP_{N,0} ... P_{N,10}\n\nOutput\n\nPrint the maximum possible profit of Joisino's shop.\n\nSample Input 1\n\n1\n1 1 0 1 0 0 0 1 0 1\n3 4 5 6 7 8 9 -2 -3 4 -2\n\nSample Output 1\n\n8\n\nIf her shop is open only during the periods when Shop 1 is opened, the profit will be 8, which is the maximum possible profit.\n\nSample Input 2\n\n2\n1 1 1 1 1 0 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1\n\nSample Output 2\n\n-2\n\nNote that a shop must be open during at least one period, and the profit may be negative.\n\nSample Input 3\n\n3\n1 1 1 1 1 1 0 0 1 1\n0 1 0 1 1 1 1 0 1 0\n1 0 1 1 0 1 0 1 0 1\n-8 6 -2 -8 -8 4 8 7 -6 2 2\n-9 2 0 1 7 -5 0 -2 -6 5 5\n6 -6 7 -9 6 -5 8 0 -9 -7 -7\n\nSample Output 3\n\n23", "sample_input": "1\n1 1 0 1 0 0 0 1 0 1\n3 4 5 6 7 8 9 -2 -3 4 -2\n"}, "reference_outputs": ["8\n"], "source_document_id": "p03503", "source_text": "Score : 300 points\n\nProblem Statement\n\nJoisino is planning to open a shop in a shopping street.\n\nEach of the five weekdays is divided into two periods, the morning and the evening. For each of those ten periods, a shop must be either open during the whole period, or closed during the whole period. Naturally, a shop must be open during at least one of those periods.\n\nThere are already N stores in the street, numbered 1 through N.\n\nYou are given information of the business hours of those shops, F_{i,j,k}. If F_{i,j,k}=1, Shop i is open during Period k on Day j (this notation is explained below); if F_{i,j,k}=0, Shop i is closed during that period. Here, the days of the week are denoted as follows. Monday: Day 1, Tuesday: Day 2, Wednesday: Day 3, Thursday: Day 4, Friday: Day 5. Also, the morning is denoted as Period 1, and the afternoon is denoted as Period 2.\n\nLet c_i be the number of periods during which both Shop i and Joisino's shop are open. Then, the profit of Joisino's shop will be P_{1,c_1}+P_{2,c_2}+...+P_{N,c_N}.\n\nFind the maximum possible profit of Joisino's shop when she decides whether her shop is open during each period, making sure that it is open during at least one period.\n\nConstraints\n\n1≤N≤100\n\n0≤F_{i,j,k}≤1\n\nFor every integer i such that 1≤i≤N, there exists at least one pair (j,k) such that F_{i,j,k}=1.\n\n-10^7≤P_{i,j}≤10^7\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nF_{1,1,1} F_{1,1,2} ... F_{1,5,1} F_{1,5,2}\n:\nF_{N,1,1} F_{N,1,2} ... F_{N,5,1} F_{N,5,2}\nP_{1,0} ... P_{1,10}\n:\nP_{N,0} ... P_{N,10}\n\nOutput\n\nPrint the maximum possible profit of Joisino's shop.\n\nSample Input 1\n\n1\n1 1 0 1 0 0 0 1 0 1\n3 4 5 6 7 8 9 -2 -3 4 -2\n\nSample Output 1\n\n8\n\nIf her shop is open only during the periods when Shop 1 is opened, the profit will be 8, which is the maximum possible profit.\n\nSample Input 2\n\n2\n1 1 1 1 1 0 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1\n\nSample Output 2\n\n-2\n\nNote that a shop must be open during at least one period, and the profit may be negative.\n\nSample Input 3\n\n3\n1 1 1 1 1 1 0 0 1 1\n0 1 0 1 1 1 1 0 1 0\n1 0 1 1 0 1 0 1 0 1\n-8 6 -2 -8 -8 4 8 7 -6 2 2\n-9 2 0 1 7 -5 0 -2 -6 5 5\n6 -6 7 -9 6 -5 8 0 -9 -7 -7\n\nSample Output 3\n\n23", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 458, "cpu_time_ms": 618, "memory_kb": 58004}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s541818516", "group_id": "codeNet:p03543", "input_text": "import scala.io.StdIn._\n \nobject Main extends App{\n val sc = new java.util.Scanner(System.in)\n val n = sc.next\n if((n(0)==n(1))&&(n(1)==n(2))||(n(1)==n(2))&&(n(2)==n(3))){\n println(\"Yes\")\n }\n else{\n println(\"No\")\n } \n}", "language": "Scala", "metadata": {"date": 1590196543, "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/s541818516.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s541818516", "user_id": "u662430503"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import scala.io.StdIn._\n \nobject Main extends App{\n val sc = new java.util.Scanner(System.in)\n val n = sc.next\n if((n(0)==n(1))&&(n(1)==n(2))||(n(1)==n(2))&&(n(2)==n(3))){\n println(\"Yes\")\n }\n else{\n 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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 360, "memory_kb": 27456}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s259890677", "group_id": "codeNet:p03545", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val x = sc.nextInt\n\n val d = x % 10\n val c = x % 100 / 10\n val b = x % 1000 / 100\n val a = x / 1000\n\n val bins = (0 until 8).map(k => zeroEmbeddingtoString(k.toBinaryString, 3))\n\n val res = bins.find { bin =>\n a + (if (bin(0) == '0') 1 else -1) * b +(if (bin(1) == '0') 1 else -1) * c +(if (bin(2) == '0') 1 else -1) * d == 7\n }.fold(\"impossible\") { bin =>\n val flg0 = if (bin(0) == '0') \"+\" else \"-\"\n val flg1 = if (bin(1) == '0') \"+\" else \"-\"\n val flg2 = if (bin(2) == '0') \"+\" else \"-\"\n s\"$a$flg0$b$flg1$c$flg2$d=7\"\n }\n\n println(res)\n\n def zeroEmbeddingtoString(str: String, index: Int): String ={\n val l = str.length\n List.fill(index - l)(\"0\").mkString + str\n }\n\n}", "language": "Scala", "metadata": {"date": 1558571350, "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/s259890677.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s259890677", "user_id": "u829407811"}, "prompt_components": {"gold_output": "1+2+2+2=7\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val x = sc.nextInt\n\n val d = x % 10\n val c = x % 100 / 10\n val b = x % 1000 / 100\n val a = x / 1000\n\n val bins = (0 until 8).map(k => zeroEmbeddingtoString(k.toBinaryString, 3))\n\n val res = bins.find { bin =>\n a + (if (bin(0) == '0') 1 else -1) * b +(if (bin(1) == '0') 1 else -1) * c +(if (bin(2) == '0') 1 else -1) * d == 7\n }.fold(\"impossible\") { bin =>\n val flg0 = if (bin(0) == '0') \"+\" else \"-\"\n val flg1 = if (bin(1) == '0') \"+\" else \"-\"\n val flg2 = if (bin(2) == '0') \"+\" else \"-\"\n s\"$a$flg0$b$flg1$c$flg2$d=7\"\n }\n\n println(res)\n\n def zeroEmbeddingtoString(str: String, index: Int): String ={\n val l = str.length\n List.fill(index - l)(\"0\").mkString + str\n }\n\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSitting in a station waiting room, Joisino is gazing at her train ticket.\n\nThe ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive).\n\nIn the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with + or - so that the formula holds.\n\nThe given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.\n\nConstraints\n\n0≤A,B,C,D≤9\n\nAll input values are integers.\n\nIt is guaranteed that there is a solution.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nABCD\n\nOutput\n\nPrint the formula you made, including the part =7.\n\nUse the signs + and -.\n\nDo not print a space between a digit and a sign.\n\nSample Input 1\n\n1222\n\nSample Output 1\n\n1+2+2+2=7\n\nThis is the only valid solution.\n\nSample Input 2\n\n0290\n\nSample Output 2\n\n0-2+9+0=7\n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\nSample Input 3\n\n3242\n\nSample Output 3\n\n3+2+4-2=7", "sample_input": "1222\n"}, "reference_outputs": ["1+2+2+2=7\n"], "source_document_id": "p03545", "source_text": "Score : 300 points\n\nProblem Statement\n\nSitting in a station waiting room, Joisino is gazing at her train ticket.\n\nThe ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive).\n\nIn the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with + or - so that the formula holds.\n\nThe given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.\n\nConstraints\n\n0≤A,B,C,D≤9\n\nAll input values are integers.\n\nIt is guaranteed that there is a solution.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nABCD\n\nOutput\n\nPrint the formula you made, including the part =7.\n\nUse the signs + and -.\n\nDo not print a space between a digit and a sign.\n\nSample Input 1\n\n1222\n\nSample Output 1\n\n1+2+2+2=7\n\nThis is the only valid solution.\n\nSample Input 2\n\n0290\n\nSample Output 2\n\n0-2+9+0=7\n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\nSample Input 3\n\n3242\n\nSample Output 3\n\n3+2+4-2=7", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 789, "cpu_time_ms": 343, "memory_kb": 27468}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s026513870", "group_id": "codeNet:p03547", "input_text": "object Main extends App {\n\tval k = scala.io.StdIn.readLine.split(\" \")\n\t\n\tdef test(x: String): Int = {\n\t\tx match {\n\t\t\tcase \"A\" => 10\n\t\t\tcase \"B\" => 11\n\t\t\tcase \"C\" => 12\n\t\t\tcase \"D\" => 13\n\t\t\tcase \"E\" => 14\n\t\t\tcase \"F\" => 15\n\t\t\tcase _ => 0\n\t\t}\n\t}\n\n\tif(test(k(0)) == test(k(1))){\n\t\tprintln(\"=\")\n\t}else if(test(k(0)) > test(k(1))){\n\t\tprintln(\">\")\n\t}else{\n\t\tprintln(\"<\")\n\t}\n\n}\n", "language": "Scala", "metadata": {"date": 1510457496, "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/s026513870.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s026513870", "user_id": "u675876401"}, "prompt_components": {"gold_output": "<\n", "input_to_evaluate": "object Main extends App {\n\tval k = scala.io.StdIn.readLine.split(\" \")\n\t\n\tdef test(x: String): Int = {\n\t\tx match {\n\t\t\tcase \"A\" => 10\n\t\t\tcase \"B\" => 11\n\t\t\tcase \"C\" => 12\n\t\t\tcase \"D\" => 13\n\t\t\tcase \"E\" => 14\n\t\t\tcase \"F\" => 15\n\t\t\tcase _ => 0\n\t\t}\n\t}\n\n\tif(test(k(0)) == test(k(1))){\n\t\tprintln(\"=\")\n\t}else if(test(k(0)) > test(k(1))){\n\t\tprintln(\">\")\n\t}else{\n\t\tprintln(\"<\")\n\t}\n\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn programming, hexadecimal notation is often used.\n\nIn hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters A, B, C, D, E and F are used to represent the values 10, 11, 12, 13, 14 and 15, respectively.\n\nIn this problem, you are given two letters X and Y. Each X and Y is A, B, C, D, E or F.\n\nWhen X and Y are seen as hexadecimal numbers, which is larger?\n\nConstraints\n\nEach X and Y is A, B, C, D, E or F.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf X is smaller, print <; if Y is smaller, print >; if they are equal, print =.\n\nSample Input 1\n\nA B\n\nSample Output 1\n\n<\n\n10 < 11.\n\nSample Input 2\n\nE C\n\nSample Output 2\n\n>\n\n14 > 12.\n\nSample Input 3\n\nF F\n\nSample Output 3\n\n=\n\n15 = 15.", "sample_input": "A B\n"}, "reference_outputs": ["<\n"], "source_document_id": "p03547", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn programming, hexadecimal notation is often used.\n\nIn hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters A, B, C, D, E and F are used to represent the values 10, 11, 12, 13, 14 and 15, respectively.\n\nIn this problem, you are given two letters X and Y. Each X and Y is A, B, C, D, E or F.\n\nWhen X and Y are seen as hexadecimal numbers, which is larger?\n\nConstraints\n\nEach X and Y is A, B, C, D, E or F.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf X is smaller, print <; if Y is smaller, print >; if they are equal, print =.\n\nSample Input 1\n\nA B\n\nSample Output 1\n\n<\n\n10 < 11.\n\nSample Input 2\n\nE C\n\nSample Output 2\n\n>\n\n14 > 12.\n\nSample Input 3\n\nF F\n\nSample Output 3\n\n=\n\n15 = 15.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 371, "cpu_time_ms": 320, "memory_kb": 27204}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s052481471", "group_id": "codeNet:p03548", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val X, Y, Z = sc.nextInt()\n println((X - Z) / (Y + Z))\n}\n", "language": "Scala", "metadata": {"date": 1599139850, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03548.html", "problem_id": "p03548", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03548/input.txt", "sample_output_relpath": "derived/input_output/data/p03548/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03548/Scala/s052481471.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s052481471", "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, Z = sc.nextInt()\n println((X - Z) / (Y + Z))\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a long seat of width X centimeters.\nThere are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters.\n\nWe would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two people, and between the end of the seat and a person.\n\nAt most how many people can sit on the seat?\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq X, Y, Z \\leq 10^5\n\nY+2Z \\leq X\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y Z\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n13 3 1\n\nSample Output 1\n\n3\n\nThere is just enough room for three, as shown below:\n\nFigure\n\nSample Input 2\n\n12 3 1\n\nSample Output 2\n\n2\n\nSample Input 3\n\n100000 1 1\n\nSample Output 3\n\n49999\n\nSample Input 4\n\n64146 123 456\n\nSample Output 4\n\n110\n\nSample Input 5\n\n64145 123 456\n\nSample Output 5\n\n109", "sample_input": "13 3 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03548", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a long seat of width X centimeters.\nThere are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters.\n\nWe would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two people, and between the end of the seat and a person.\n\nAt most how many people can sit on the seat?\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq X, Y, Z \\leq 10^5\n\nY+2Z \\leq X\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y Z\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n13 3 1\n\nSample Output 1\n\n3\n\nThere is just enough room for three, as shown below:\n\nFigure\n\nSample Input 2\n\n12 3 1\n\nSample Output 2\n\n2\n\nSample Input 3\n\n100000 1 1\n\nSample Output 3\n\n49999\n\nSample Input 4\n\n64146 123 456\n\nSample Output 4\n\n110\n\nSample Input 5\n\n64145 123 456\n\nSample Output 5\n\n109", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 501, "memory_kb": 55340}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s307937552", "group_id": "codeNet:p03548", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n val Array(x, y, z) = StdIn.readLine.split(\" \").map(_.toInt)\n val ans = (x-z) / (y+z)\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1545252494, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03548.html", "problem_id": "p03548", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03548/input.txt", "sample_output_relpath": "derived/input_output/data/p03548/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03548/Scala/s307937552.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s307937552", "user_id": "u217010036"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n val Array(x, y, z) = StdIn.readLine.split(\" \").map(_.toInt)\n val ans = (x-z) / (y+z)\n println(ans)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a long seat of width X centimeters.\nThere are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters.\n\nWe would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two people, and between the end of the seat and a person.\n\nAt most how many people can sit on the seat?\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq X, Y, Z \\leq 10^5\n\nY+2Z \\leq X\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y Z\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n13 3 1\n\nSample Output 1\n\n3\n\nThere is just enough room for three, as shown below:\n\nFigure\n\nSample Input 2\n\n12 3 1\n\nSample Output 2\n\n2\n\nSample Input 3\n\n100000 1 1\n\nSample Output 3\n\n49999\n\nSample Input 4\n\n64146 123 456\n\nSample Output 4\n\n110\n\nSample Input 5\n\n64145 123 456\n\nSample Output 5\n\n109", "sample_input": "13 3 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03548", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a long seat of width X centimeters.\nThere are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters.\n\nWe would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two people, and between the end of the seat and a person.\n\nAt most how many people can sit on the seat?\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq X, Y, Z \\leq 10^5\n\nY+2Z \\leq X\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y Z\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n13 3 1\n\nSample Output 1\n\n3\n\nThere is just enough room for three, as shown below:\n\nFigure\n\nSample Input 2\n\n12 3 1\n\nSample Output 2\n\n2\n\nSample Input 3\n\n100000 1 1\n\nSample Output 3\n\n49999\n\nSample Input 4\n\n64146 123 456\n\nSample Output 4\n\n110\n\nSample Input 5\n\n64145 123 456\n\nSample Output 5\n\n109", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 153, "cpu_time_ms": 343, "memory_kb": 27464}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s648502408", "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.last - w)\n val b = Math.abs(an.last - an(an.length - 2))\n if (a > b) a else b\n }\n\n println(ans)\n }\n}\n", "language": "Scala", "metadata": {"date": 1510461776, "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/s648502408.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s648502408", "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.last - w)\n val b = Math.abs(an.last - an(an.length - 2))\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 456, "memory_kb": 31588}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s680046304", "group_id": "codeNet:p03556", "input_text": "import scala.math.sqrt\n\nobject Main{\n def main(args: Array[String]){\n val input=io.Source.stdin.getLines().mkString(\"\\n\")\n println(solve(input).trim())\n }\n\n def solve(input:String):String={\n val n=input.toInt\n (((sqrt(n)+0.25).toInt)*((sqrt(n)+0.25).toInt)).toString\n }\n}\n", "language": "Scala", "metadata": {"date": 1571409390, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03556.html", "problem_id": "p03556", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03556/input.txt", "sample_output_relpath": "derived/input_output/data/p03556/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03556/Scala/s680046304.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s680046304", "user_id": "u394033362"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import scala.math.sqrt\n\nobject Main{\n def main(args: Array[String]){\n val input=io.Source.stdin.getLines().mkString(\"\\n\")\n println(solve(input).trim())\n }\n\n def solve(input:String):String={\n val n=input.toInt\n (((sqrt(n)+0.25).toInt)*((sqrt(n)+0.25).toInt)).toString\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nFind the largest square number not exceeding N. Here, a square number is an integer that can be represented as the square of an integer.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the largest square number not exceeding N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\n10 is not square, but 9 = 3 × 3 is. Thus, we print 9.\n\nSample Input 2\n\n81\n\nSample Output 2\n\n81\n\nSample Input 3\n\n271828182\n\nSample Output 3\n\n271821169", "sample_input": "10\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03556", "source_text": "Score : 200 points\n\nProblem Statement\n\nFind the largest square number not exceeding N. Here, a square number is an integer that can be represented as the square of an integer.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the largest square number not exceeding N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\n10 is not square, but 9 = 3 × 3 is. Thus, we print 9.\n\nSample Input 2\n\n81\n\nSample Output 2\n\n81\n\nSample Input 3\n\n271828182\n\nSample Output 3\n\n271821169", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 288, "cpu_time_ms": 322, "memory_kb": 25528}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s673351888", "group_id": "codeNet:p03556", "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 sqrtN = Math.floor(Math.sqrt(n)).toInt\n\n val res = sqrtN * sqrtN\n\n println(res)\n}", "language": "Scala", "metadata": {"date": 1557999590, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03556.html", "problem_id": "p03556", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03556/input.txt", "sample_output_relpath": "derived/input_output/data/p03556/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03556/Scala/s673351888.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s673351888", "user_id": "u829407811"}, "prompt_components": {"gold_output": "9\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 sqrtN = Math.floor(Math.sqrt(n)).toInt\n\n val res = sqrtN * sqrtN\n\n println(res)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nFind the largest square number not exceeding N. Here, a square number is an integer that can be represented as the square of an integer.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the largest square number not exceeding N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\n10 is not square, but 9 = 3 × 3 is. Thus, we print 9.\n\nSample Input 2\n\n81\n\nSample Output 2\n\n81\n\nSample Input 3\n\n271828182\n\nSample Output 3\n\n271821169", "sample_input": "10\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03556", "source_text": "Score : 200 points\n\nProblem Statement\n\nFind the largest square number not exceeding N. Here, a square number is an integer that can be represented as the square of an integer.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the largest square number not exceeding N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\n10 is not square, but 9 = 3 × 3 is. Thus, we print 9.\n\nSample Input 2\n\n81\n\nSample Output 2\n\n81\n\nSample Input 3\n\n271828182\n\nSample Output 3\n\n271821169", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 198, "cpu_time_ms": 342, "memory_kb": 25644}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s678465862", "group_id": "codeNet:p03557", "input_text": "\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 val B = Array.fill(N)(sc.nextInt())\n val C = Array.fill(N)(sc.nextInt()).sorted(Ordering.Int.reverse)\n\n // 3カテゴリーのパーツがそれぞれN個ずつあります\n // パーツのサイズ\n // 中部のパーツのサイズは、上部のパーツのサイズより真に大きく\n // 下部のパーツのサイズは、中部のパーツのサイズより真に大きくなければなりません\n // 作れる祭壇は何種類あるでしょうか/\n // ただし 2つの祭壇が異なるとは, 上部, 中部, 下部に使われるピースのうち少なくとも1つが異なる\n // 1つ決めた時の, そのパーツより大きいパーツはO(log N)で出すことができる\n // 普通にやると, O(N^2logN)とかになる, 間に合わない\n // なので, 中部を先に決めておく\n // 中部を決めた時, その時上部のパーツに使えるのは, 中部より小さいもの\n // 下部のパーツに使えるのは, 中部より大きいもの,\n // これらは それぞれ O(log N)で求めることができ, O(NlogN)で求めることができる\n\n def upperBounds(A: Array[Int], b: Int): Int = {\n def recursive(l: Int, r: Int): Int =\n if (r - l > 1) {\n val mid = l + (r - l) / 2\n if (A(mid) >= b) recursive(l, mid)\n else recursive(mid, r)\n } else l\n recursive(-1, N)\n }\n\n def lowerBounds(C: Array[Int], b: Int): Int = {\n def recursive(l: Int, r: Int): Int =\n if (r - l > 1) {\n val mid = l + (r - l) / 2\n if (C(mid) <= b) recursive(l, mid)\n else recursive(mid, r)\n } else l\n recursive(-1, N)\n }\n\n val r = (0 until N).foldLeft(0L) { case (sum, i) =>\n sum + (upperBounds(A, B(i)) + 1L) * (lowerBounds(C, B(i)) + 1L)\n }\n\n println(r)\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1594527249, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03557.html", "problem_id": "p03557", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03557/input.txt", "sample_output_relpath": "derived/input_output/data/p03557/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03557/Scala/s678465862.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s678465862", "user_id": "u891387249"}, "prompt_components": {"gold_output": "3\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 val N = sc.nextInt()\n val A = Array.fill(N)(sc.nextInt()).sorted\n val B = Array.fill(N)(sc.nextInt())\n val C = Array.fill(N)(sc.nextInt()).sorted(Ordering.Int.reverse)\n\n // 3カテゴリーのパーツがそれぞれN個ずつあります\n // パーツのサイズ\n // 中部のパーツのサイズは、上部のパーツのサイズより真に大きく\n // 下部のパーツのサイズは、中部のパーツのサイズより真に大きくなければなりません\n // 作れる祭壇は何種類あるでしょうか/\n // ただし 2つの祭壇が異なるとは, 上部, 中部, 下部に使われるピースのうち少なくとも1つが異なる\n // 1つ決めた時の, そのパーツより大きいパーツはO(log N)で出すことができる\n // 普通にやると, O(N^2logN)とかになる, 間に合わない\n // なので, 中部を先に決めておく\n // 中部を決めた時, その時上部のパーツに使えるのは, 中部より小さいもの\n // 下部のパーツに使えるのは, 中部より大きいもの,\n // これらは それぞれ O(log N)で求めることができ, O(NlogN)で求めることができる\n\n def upperBounds(A: Array[Int], b: Int): Int = {\n def recursive(l: Int, r: Int): Int =\n if (r - l > 1) {\n val mid = l + (r - l) / 2\n if (A(mid) >= b) recursive(l, mid)\n else recursive(mid, r)\n } else l\n recursive(-1, N)\n }\n\n def lowerBounds(C: Array[Int], b: Int): Int = {\n def recursive(l: Int, r: Int): Int =\n if (r - l > 1) {\n val mid = l + (r - l) / 2\n if (C(mid) <= b) recursive(l, mid)\n else recursive(mid, r)\n } else l\n recursive(-1, N)\n }\n\n val r = (0 until N).foldLeft(0L) { case (sum, i) =>\n sum + (upperBounds(A, B(i)) + 1L) * (lowerBounds(C, B(i)) + 1L)\n }\n\n println(r)\n }\n\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThe season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower.\n\nHe has N parts for each of the three categories. The size of the i-th upper part is A_i, the size of the i-th middle part is B_i, and the size of the i-th lower part is C_i.\n\nTo build an altar, the size of the middle part must be strictly greater than that of the upper part, and the size of the lower part must be strictly greater than that of the middle part. On the other hand, any three parts that satisfy these conditions can be combined to form an altar.\n\nHow many different altars can Ringo build? Here, two altars are considered different when at least one of the three parts used is different.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9(1\\leq i\\leq N)\n\n1 \\leq B_i \\leq 10^9(1\\leq i\\leq N)\n\n1 \\leq C_i \\leq 10^9(1\\leq i\\leq N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 ... A_N\nB_1 ... B_N\nC_1 ... C_N\n\nOutput\n\nPrint the number of different altars that Ringo can build.\n\nSample Input 1\n\n2\n1 5\n2 4\n3 6\n\nSample Output 1\n\n3\n\nThe following three altars can be built:\n\nUpper: 1-st part, Middle: 1-st part, Lower: 1-st part\n\nUpper: 1-st part, Middle: 1-st part, Lower: 2-nd part\n\nUpper: 1-st part, Middle: 2-nd part, Lower: 2-nd part\n\nSample Input 2\n\n3\n1 1 1\n2 2 2\n3 3 3\n\nSample Output 2\n\n27\n\nSample Input 3\n\n6\n3 14 159 2 6 53\n58 9 79 323 84 6\n2643 383 2 79 50 288\n\nSample Output 3\n\n87", "sample_input": "2\n1 5\n2 4\n3 6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03557", "source_text": "Score : 300 points\n\nProblem Statement\n\nThe season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower.\n\nHe has N parts for each of the three categories. The size of the i-th upper part is A_i, the size of the i-th middle part is B_i, and the size of the i-th lower part is C_i.\n\nTo build an altar, the size of the middle part must be strictly greater than that of the upper part, and the size of the lower part must be strictly greater than that of the middle part. On the other hand, any three parts that satisfy these conditions can be combined to form an altar.\n\nHow many different altars can Ringo build? Here, two altars are considered different when at least one of the three parts used is different.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9(1\\leq i\\leq N)\n\n1 \\leq B_i \\leq 10^9(1\\leq i\\leq N)\n\n1 \\leq C_i \\leq 10^9(1\\leq i\\leq N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 ... A_N\nB_1 ... B_N\nC_1 ... C_N\n\nOutput\n\nPrint the number of different altars that Ringo can build.\n\nSample Input 1\n\n2\n1 5\n2 4\n3 6\n\nSample Output 1\n\n3\n\nThe following three altars can be built:\n\nUpper: 1-st part, Middle: 1-st part, Lower: 1-st part\n\nUpper: 1-st part, Middle: 1-st part, Lower: 2-nd part\n\nUpper: 1-st part, Middle: 2-nd part, Lower: 2-nd part\n\nSample Input 2\n\n3\n1 1 1\n2 2 2\n3 3 3\n\nSample Output 2\n\n27\n\nSample Input 3\n\n6\n3 14 159 2 6 53\n58 9 79 323 84 6\n2643 383 2 79 50 288\n\nSample Output 3\n\n87", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2034, "cpu_time_ms": 1221, "memory_kb": 62488}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s970600490", "group_id": "codeNet:p03569", "input_text": "object Main extends App {\n val s = io.StdIn.readLine()\n val check = s.filterNot(_=='x')\n\n if(check!=check.reverse){\n println(-1)\n sys.exit()\n }\n\n var ans = 0\n var first = 0\n var latter = 0\n var i = 0\n while( i < (s.length + first + latter)/2){\n if( s(i - first) != s(-1+(-1)*i+latter+s.length) ){\n ans += 1\n if( s(i-first)=='x' ){\n latter += 1\n }else{\n first += 1\n }\n }\n i += 1\n }\n\n println(ans)\n\n}\n", "language": "Scala", "metadata": {"date": 1508736770, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03569.html", "problem_id": "p03569", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03569/input.txt", "sample_output_relpath": "derived/input_output/data/p03569/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03569/Scala/s970600490.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s970600490", "user_id": "u750673980"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n val s = io.StdIn.readLine()\n val check = s.filterNot(_=='x')\n\n if(check!=check.reverse){\n println(-1)\n sys.exit()\n }\n\n var ans = 0\n var first = 0\n var latter = 0\n var i = 0\n while( i < (s.length + first + latter)/2){\n if( s(i - first) != s(-1+(-1)*i+latter+s.length) ){\n ans += 1\n if( s(i-first)=='x' ){\n latter += 1\n }else{\n first += 1\n }\n }\n i += 1\n }\n\n println(ans)\n\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a string s consisting of lowercase English letters.\nSnuke can perform the following operation repeatedly:\n\nInsert a letter x to any position in s of his choice, including the beginning and end of s.\n\nSnuke's objective is to turn s into a palindrome.\nDetermine whether the objective is achievable. If it is achievable, find the minimum number of operations required.\n\nNotes\n\nA palindrome is a string that reads the same forward and backward.\nFor example, a, aa, abba and abcba are palindromes, while ab, abab and abcda are not.\n\nConstraints\n\n1 \\leq |s| \\leq 10^5\n\ns consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nIf the objective is achievable, print the number of operations required.\nIf it is not, print -1 instead.\n\nSample Input 1\n\nxabxa\n\nSample Output 1\n\n2\n\nOne solution is as follows (newly inserted x are shown in bold):\n\nxabxa → xaxbxa → xaxbxax\n\nSample Input 2\n\nab\n\nSample Output 2\n\n-1\n\nNo sequence of operations can turn s into a palindrome.\n\nSample Input 3\n\na\n\nSample Output 3\n\n0\n\ns is a palindrome already at the beginning.\n\nSample Input 4\n\noxxx\n\nSample Output 4\n\n3\n\nOne solution is as follows:\n\noxxx → xoxxx → xxoxxx → xxxoxxx", "sample_input": "xabxa\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03569", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a string s consisting of lowercase English letters.\nSnuke can perform the following operation repeatedly:\n\nInsert a letter x to any position in s of his choice, including the beginning and end of s.\n\nSnuke's objective is to turn s into a palindrome.\nDetermine whether the objective is achievable. If it is achievable, find the minimum number of operations required.\n\nNotes\n\nA palindrome is a string that reads the same forward and backward.\nFor example, a, aa, abba and abcba are palindromes, while ab, abab and abcda are not.\n\nConstraints\n\n1 \\leq |s| \\leq 10^5\n\ns consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nIf the objective is achievable, print the number of operations required.\nIf it is not, print -1 instead.\n\nSample Input 1\n\nxabxa\n\nSample Output 1\n\n2\n\nOne solution is as follows (newly inserted x are shown in bold):\n\nxabxa → xaxbxa → xaxbxax\n\nSample Input 2\n\nab\n\nSample Output 2\n\n-1\n\nNo sequence of operations can turn s into a palindrome.\n\nSample Input 3\n\na\n\nSample Output 3\n\n0\n\ns is a palindrome already at the beginning.\n\nSample Input 4\n\noxxx\n\nSample Output 4\n\n3\n\nOne solution is as follows:\n\noxxx → xoxxx → xxoxxx → xxxoxxx", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 459, "cpu_time_ms": 438, "memory_kb": 29312}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s249856397", "group_id": "codeNet:p03573", "input_text": "import scala.io.StdIn._\nimport scala.math._\n \nobject Main extends App{\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 if(a==b){\n println(c)\n }\n else if(a==c){\n println(b)\n }\n else{\n println(a)\n }\n}", "language": "Scala", "metadata": {"date": 1590193721, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03573.html", "problem_id": "p03573", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03573/input.txt", "sample_output_relpath": "derived/input_output/data/p03573/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03573/Scala/s249856397.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s249856397", "user_id": "u662430503"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "import scala.io.StdIn._\nimport scala.math._\n \nobject Main extends App{\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 if(a==b){\n println(c)\n }\n else if(a==c){\n println(b)\n }\n else{\n println(a)\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given three integers, A, B and C.\n\nAmong them, two are the same, but the remaining one is different from the rest.\n\nFor example, when A=5,B=7,C=5, A and C are the same, but B is different.\n\nFind the one that is different from the rest among the given three integers.\n\nConstraints\n\n-100 \\leq A,B,C \\leq 100\n\nA, B and C are integers.\n\nThe input satisfies the condition in the statement.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nAmong A, B and C, print the integer that is different from the rest.\n\nSample Input 1\n\n5 7 5\n\nSample Output 1\n\n7\n\nThis is the same case as the one in the statement.\n\nSample Input 2\n\n1 1 7\n\nSample Output 2\n\n7\n\nIn this case, C is the one we seek.\n\nSample Input 3\n\n-100 100 100\n\nSample Output 3\n\n-100", "sample_input": "5 7 5\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03573", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given three integers, A, B and C.\n\nAmong them, two are the same, but the remaining one is different from the rest.\n\nFor example, when A=5,B=7,C=5, A and C are the same, but B is different.\n\nFind the one that is different from the rest among the given three integers.\n\nConstraints\n\n-100 \\leq A,B,C \\leq 100\n\nA, B and C are integers.\n\nThe input satisfies the condition in the statement.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nAmong A, B and C, print the integer that is different from the rest.\n\nSample Input 1\n\n5 7 5\n\nSample Output 1\n\n7\n\nThis is the same case as the one in the statement.\n\nSample Input 2\n\n1 1 7\n\nSample Output 2\n\n7\n\nIn this case, C is the one we seek.\n\nSample Input 3\n\n-100 100 100\n\nSample Output 3\n\n-100", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 337, "memory_kb": 25560}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s166481943", "group_id": "codeNet:p03583", "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 // 制約から, h, n, w <= 3500を探索することになる\n val (h, n, w) = (for {\n h <- 1L to 3500L\n n <- 1L to 3500L\n top = N * h * n\n bottom = 4L * h * n - N * n - N * h\n if bottom > 0\n if top % bottom == 0\n w = top / bottom\n } yield (h, n, w)).head\n\n println(s\"$h $n $w\")\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1593573082, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03583.html", "problem_id": "p03583", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03583/input.txt", "sample_output_relpath": "derived/input_output/data/p03583/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03583/Scala/s166481943.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s166481943", "user_id": "u891387249"}, "prompt_components": {"gold_output": "1 2 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 // 制約から, h, n, w <= 3500を探索することになる\n val (h, n, w) = (for {\n h <- 1L to 3500L\n n <- 1L to 3500L\n top = N * h * n\n bottom = 4L * h * n - N * n - N * h\n if bottom > 0\n if top % bottom == 0\n w = top / bottom\n } yield (h, n, w)).head\n\n println(s\"$h $n $w\")\n }\n\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N.\n\nFind a triple of positive integers h, n and w such that 4/N = 1/h + 1/n + 1/w.\n\nIf there are multiple solutions, any of them will be accepted.\n\nConstraints\n\nIt is guaranteed that, for the given integer N, there exists a solution such that h,n,w \\leq 3500.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutputs\n\nPrint a triple of positive integers h, n and w that satisfies the condition, in the following format:\n\nh n w\n\nSample Input 1\n\n2\n\nSample Output 1\n\n1 2 2\n\n4/2 = 1/1 + 1/2 + 1/2.\n\nSample Input 2\n\n3485\n\nSample Output 2\n\n872 1012974 1539173474040\n\nIt is allowed to use an integer exceeding 3500 in a solution.\n\nSample Input 3\n\n4664\n\nSample Output 3\n\n3498 3498 3498", "sample_input": "2\n"}, "reference_outputs": ["1 2 2\n"], "source_document_id": "p03583", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N.\n\nFind a triple of positive integers h, n and w such that 4/N = 1/h + 1/n + 1/w.\n\nIf there are multiple solutions, any of them will be accepted.\n\nConstraints\n\nIt is guaranteed that, for the given integer N, there exists a solution such that h,n,w \\leq 3500.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutputs\n\nPrint a triple of positive integers h, n and w that satisfies the condition, in the following format:\n\nh n w\n\nSample Input 1\n\n2\n\nSample Output 1\n\n1 2 2\n\n4/2 = 1/1 + 1/2 + 1/2.\n\nSample Input 2\n\n3485\n\nSample Output 2\n\n872 1012974 1539173474040\n\nIt is allowed to use an integer exceeding 3500 in a solution.\n\nSample Input 3\n\n4664\n\nSample Output 3\n\n3498 3498 3498", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 464, "cpu_time_ms": 1230, "memory_kb": 62976}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s401382479", "group_id": "codeNet:p03584", "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 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 N, K = ni()\n val (a, b) = na2(N)\n val del = Array.ofDim[Boolean](N)\n var ans = 0L\n REP_r(30) { k =>\n if ((K>>k&1) == 1) {\n // 0の場合\n var sum = 0L\n REP(N) { i =>\n if (!del(i) && (a(i)>>k&1) == 0) {\n sum += b(i)\n }\n }\n ans = max(ans, sum)\n // delは変わらない\n } else {\n // 0の場合\n REP(N) { i =>\n if (!del(i) && (a(i)>>k&1) == 1) {\n del(i) = true\n }\n }\n }\n// debug(del)\n }\n\n var sum = 0L\n REP(N) { i =>\n if (!del(i)) {\n sum += b(i)\n }\n }\n ans = max(ans, sum)\n\n out.println(ans)\n }\n}", "language": "Scala", "metadata": {"date": 1575696613, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03584.html", "problem_id": "p03584", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03584/input.txt", "sample_output_relpath": "derived/input_output/data/p03584/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03584/Scala/s401382479.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s401382479", "user_id": "u460609472"}, "prompt_components": {"gold_output": "8\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 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 N, K = ni()\n val (a, b) = na2(N)\n val del = Array.ofDim[Boolean](N)\n var ans = 0L\n REP_r(30) { k =>\n if ((K>>k&1) == 1) {\n // 0の場合\n var sum = 0L\n REP(N) { i =>\n if (!del(i) && (a(i)>>k&1) == 0) {\n sum += b(i)\n }\n }\n ans = max(ans, sum)\n // delは変わらない\n } else {\n // 0の場合\n REP(N) { i =>\n if (!del(i) && (a(i)>>k&1) == 1) {\n del(i) = true\n }\n }\n }\n// debug(del)\n }\n\n var sum = 0L\n REP(N) { i =>\n if (!del(i)) {\n sum += b(i)\n }\n }\n ans = max(ans, sum)\n\n out.println(ans)\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nSeisu-ya, a store specializing in non-negative integers, sells N non-negative integers. The i-th integer is A_i and has a utility of B_i.\nThere may be multiple equal integers with different utilities.\n\nTakahashi will buy some integers in this store. He can buy a combination of integers whose bitwise OR is less than or equal to K. He wants the sum of utilities of purchased integers to be as large as possible.\n\nFind the maximum possible sum of utilities of purchased integers.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq K < 2^{30}\n\n0 \\leq A_i < 2^{30}(1\\leq i\\leq N)\n\n1 \\leq B_i \\leq 10^9(1\\leq i\\leq N)\n\nAll input values are integers.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 B_1\n:\nA_N B_N\n\nOutputs\n\nPrint the maximum possible sum of utilities of purchased integers.\n\nSample Input 1\n\n3 5\n3 3\n4 4\n2 5\n\nSample Output 1\n\n8\n\nBuy 2 and 3 to achieve the maximum possible total utility, 8.\n\nSample Input 2\n\n3 6\n3 3\n4 4\n2 5\n\nSample Output 2\n\n9\n\nBuy 2 and 4 to achieve the maximum possible total utility, 9.\n\nSample Input 3\n\n7 14\n10 5\n7 4\n11 4\n9 8\n3 6\n6 2\n8 9\n\nSample Output 3\n\n32", "sample_input": "3 5\n3 3\n4 4\n2 5\n"}, "reference_outputs": ["8\n"], "source_document_id": "p03584", "source_text": "Score : 500 points\n\nProblem Statement\n\nSeisu-ya, a store specializing in non-negative integers, sells N non-negative integers. The i-th integer is A_i and has a utility of B_i.\nThere may be multiple equal integers with different utilities.\n\nTakahashi will buy some integers in this store. He can buy a combination of integers whose bitwise OR is less than or equal to K. He wants the sum of utilities of purchased integers to be as large as possible.\n\nFind the maximum possible sum of utilities of purchased integers.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq K < 2^{30}\n\n0 \\leq A_i < 2^{30}(1\\leq i\\leq N)\n\n1 \\leq B_i \\leq 10^9(1\\leq i\\leq N)\n\nAll input values are integers.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 B_1\n:\nA_N B_N\n\nOutputs\n\nPrint the maximum possible sum of utilities of purchased integers.\n\nSample Input 1\n\n3 5\n3 3\n4 4\n2 5\n\nSample Output 1\n\n8\n\nBuy 2 and 3 to achieve the maximum possible total utility, 8.\n\nSample Input 2\n\n3 6\n3 3\n4 4\n2 5\n\nSample Output 2\n\n9\n\nBuy 2 and 4 to achieve the maximum possible total utility, 9.\n\nSample Input 3\n\n7 14\n10 5\n7 4\n11 4\n9 8\n3 6\n6 2\n8 9\n\nSample Output 3\n\n32", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4626, "cpu_time_ms": 1114, "memory_kb": 43008}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s997951600", "group_id": "codeNet:p03591", "input_text": "object Main extends App {\n\tval N = scala.io.StdIn.readLine.toList\n\n\tN match {\n\t\tcase 'Y'::'A'::'K'::'I'::rest => println(\"Yes\")\n\t\tcase _ => println(\"No\") \n\t}\n\n}", "language": "Scala", "metadata": {"date": 1506220826, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03591.html", "problem_id": "p03591", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03591/input.txt", "sample_output_relpath": "derived/input_output/data/p03591/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03591/Scala/s997951600.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s997951600", "user_id": "u675876401"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n\tval N = scala.io.StdIn.readLine.toList\n\n\tN match {\n\t\tcase 'Y'::'A'::'K'::'I'::rest => println(\"Yes\")\n\t\tcase _ => println(\"No\") \n\t}\n\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nRingo is giving a present to Snuke.\n\nRingo has found out that Snuke loves yakiniku (a Japanese term meaning grilled meat. yaki: grilled, niku: meat). He supposes that Snuke likes grilled things starting with YAKI in Japanese, and does not like other things.\n\nYou are given a string S representing the Japanese name of Ringo's present to Snuke. Determine whether S starts with YAKI.\n\nConstraints\n\n1 \\leq |S| \\leq 10\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S starts with YAKI, print Yes; otherwise, print No.\n\nSample Input 1\n\nYAKINIKU\n\nSample Output 1\n\nYes\n\nYAKINIKU starts with YAKI.\n\nSample Input 2\n\nTAKOYAKI\n\nSample Output 2\n\nNo\n\nTAKOYAKI (a Japanese snack. tako: octopus) does not start with YAKI.\n\nSample Input 3\n\nYAK\n\nSample Output 3\n\nNo", "sample_input": "YAKINIKU\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03591", "source_text": "Score : 100 points\n\nProblem Statement\n\nRingo is giving a present to Snuke.\n\nRingo has found out that Snuke loves yakiniku (a Japanese term meaning grilled meat. yaki: grilled, niku: meat). He supposes that Snuke likes grilled things starting with YAKI in Japanese, and does not like other things.\n\nYou are given a string S representing the Japanese name of Ringo's present to Snuke. Determine whether S starts with YAKI.\n\nConstraints\n\n1 \\leq |S| \\leq 10\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S starts with YAKI, print Yes; otherwise, print No.\n\nSample Input 1\n\nYAKINIKU\n\nSample Output 1\n\nYes\n\nYAKINIKU starts with YAKI.\n\nSample Input 2\n\nTAKOYAKI\n\nSample Output 2\n\nNo\n\nTAKOYAKI (a Japanese snack. tako: octopus) does not start with YAKI.\n\nSample Input 3\n\nYAK\n\nSample Output 3\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 321, "memory_kb": 25420}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s657647242", "group_id": "codeNet:p03608", "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, M, R = in.next().toInt\n val r = new Array[Int](R)\n for (i <- 0 until R) {\n r(i) = in.next().toInt\n }\n\n val d = Array.ofDim[Long](N+1, N+1) // d[a][b] は辺 e = (a, b) のコスト(存在しない場合はINF, ただし d[i][i] = 0 とする)\n val MAX = Integer.MAX_VALUE\n\n // 初期化\n for(i <- 0 to N; j <- 0 to N){\n if(i == j)\n d(i)(j) = 0\n else\n d(i)(j) = MAX\n }\n\n // input d\n for(_ <- 0 until M) {\n val a, b, c = in.next().toInt\n d(a)(b) = c\n d(b)(a) = c\n }\n\n // function\n def warshall_floyd() =\n for(k <- 1 to N; i <- 1 to N; j <- 1 to N){\n d(i)(j) = Math.min(d(i)(j), d(i)(k) + d(k)(j))\n }\n\n\n // main process\n warshall_floyd()\n\n var ans: Long = Integer.MAX_VALUE\n for(pl <- r.toList.permutations) {\n var tmp = 0L\n for(i <- 0 until pl.length - 1) {\n tmp += d(pl(i))(pl(i+1))\n }\n ans = Math.min(ans, tmp)\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": 1520296345, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03608.html", "problem_id": "p03608", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03608/input.txt", "sample_output_relpath": "derived/input_output/data/p03608/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03608/Scala/s657647242.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s657647242", "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, M, R = in.next().toInt\n val r = new Array[Int](R)\n for (i <- 0 until R) {\n r(i) = in.next().toInt\n }\n\n val d = Array.ofDim[Long](N+1, N+1) // d[a][b] は辺 e = (a, b) のコスト(存在しない場合はINF, ただし d[i][i] = 0 とする)\n val MAX = Integer.MAX_VALUE\n\n // 初期化\n for(i <- 0 to N; j <- 0 to N){\n if(i == j)\n d(i)(j) = 0\n else\n d(i)(j) = MAX\n }\n\n // input d\n for(_ <- 0 until M) {\n val a, b, c = in.next().toInt\n d(a)(b) = c\n d(b)(a) = c\n }\n\n // function\n def warshall_floyd() =\n for(k <- 1 to N; i <- 1 to N; j <- 1 to N){\n d(i)(j) = Math.min(d(i)(j), d(i)(k) + d(k)(j))\n }\n\n\n // main process\n warshall_floyd()\n\n var ans: Long = Integer.MAX_VALUE\n for(pl <- r.toList.permutations) {\n var tmp = 0L\n for(i <- 0 until pl.length - 1) {\n tmp += d(pl(i))(pl(i+1))\n }\n ans = Math.min(ans, tmp)\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 : 400 points\n\nProblem Statement\n\nThere are N towns in the State of Atcoder, connected by M bidirectional roads.\n\nThe i-th road connects Town A_i and B_i and has a length of C_i.\n\nJoisino is visiting R towns in the state, r_1,r_2,..,r_R (not necessarily in this order).\n\nShe will fly to the first town she visits, and fly back from the last town she visits, but for the rest of the trip she will have to travel by road.\n\nIf she visits the towns in the order that minimizes the distance traveled by road, what will that distance be?\n\nConstraints\n\n2≤N≤200\n\n1≤M≤N×(N-1)/2\n\n2≤R≤min(8,N) (min(8,N) is the smaller of 8 and N.)\n\nr_i≠r_j (i≠j)\n\n1≤A_i,B_i≤N, A_i≠B_i\n\n(A_i,B_i)≠(A_j,B_j),(A_i,B_i)≠(B_j,A_j) (i≠j)\n\n1≤C_i≤100000\n\nEvery town can be reached from every town by road.\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M R\nr_1 ... r_R\nA_1 B_1 C_1\n:\nA_M B_M C_M\n\nOutput\n\nPrint the distance traveled by road if Joisino visits the towns in the order that minimizes it.\n\nSample Input 1\n\n3 3 3\n1 2 3\n1 2 1\n2 3 1\n3 1 4\n\nSample Output 1\n\n2\n\nFor example, if she visits the towns in the order of 1, 2, 3, the distance traveled will be 2, which is the minimum possible.\n\nSample Input 2\n\n3 3 2\n1 3\n2 3 2\n1 3 6\n1 2 2\n\nSample Output 2\n\n4\n\nThe shortest distance between Towns 1 and 3 is 4. Thus, whether she visits Town 1 or 3 first, the distance traveled will be 4.\n\nSample Input 3\n\n4 6 3\n2 3 4\n1 2 4\n2 3 3\n4 3 1\n1 4 1\n4 2 2\n3 1 6\n\nSample Output 3\n\n3", "sample_input": "3 3 3\n1 2 3\n1 2 1\n2 3 1\n3 1 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03608", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N towns in the State of Atcoder, connected by M bidirectional roads.\n\nThe i-th road connects Town A_i and B_i and has a length of C_i.\n\nJoisino is visiting R towns in the state, r_1,r_2,..,r_R (not necessarily in this order).\n\nShe will fly to the first town she visits, and fly back from the last town she visits, but for the rest of the trip she will have to travel by road.\n\nIf she visits the towns in the order that minimizes the distance traveled by road, what will that distance be?\n\nConstraints\n\n2≤N≤200\n\n1≤M≤N×(N-1)/2\n\n2≤R≤min(8,N) (min(8,N) is the smaller of 8 and N.)\n\nr_i≠r_j (i≠j)\n\n1≤A_i,B_i≤N, A_i≠B_i\n\n(A_i,B_i)≠(A_j,B_j),(A_i,B_i)≠(B_j,A_j) (i≠j)\n\n1≤C_i≤100000\n\nEvery town can be reached from every town by road.\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M R\nr_1 ... r_R\nA_1 B_1 C_1\n:\nA_M B_M C_M\n\nOutput\n\nPrint the distance traveled by road if Joisino visits the towns in the order that minimizes it.\n\nSample Input 1\n\n3 3 3\n1 2 3\n1 2 1\n2 3 1\n3 1 4\n\nSample Output 1\n\n2\n\nFor example, if she visits the towns in the order of 1, 2, 3, the distance traveled will be 2, which is the minimum possible.\n\nSample Input 2\n\n3 3 2\n1 3\n2 3 2\n1 3 6\n1 2 2\n\nSample Output 2\n\n4\n\nThe shortest distance between Towns 1 and 3 is 4. Thus, whether she visits Town 1 or 3 first, the distance traveled will be 4.\n\nSample Input 3\n\n4 6 3\n2 3 4\n1 2 4\n2 3 3\n4 3 1\n1 4 1\n4 2 2\n3 1 6\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1482, "cpu_time_ms": 822, "memory_kb": 39472}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s081292923", "group_id": "codeNet:p03608", "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, M, R = in.next().toInt\n val r = new Array[Int](R)\n for (i <- 0 until R) {\n r(i) = in.next().toInt\n }\n\n val d = Array.ofDim[Long](N+1, N+1) // d[a][b] は辺 e = (a, b) のコスト(存在しない場合はINF, ただし d[i][i] = 0 とする)\n val MAX = 100002L\n\n // 初期化\n for(i <- 0 to N; j <- 0 to N){\n if(i == j)\n d(i)(j) = 0\n else\n d(i)(j) = MAX\n }\n\n // input d\n for(i <- 0 until M) {\n val a, b, c = in.next().toInt\n d(a)(b) = c\n d(b)(a) = c\n }\n\n // function\n def warshall_floyd() =\n for(k <- 1 to N; i <- 1 to N; j <- 1 to N){\n d(i)(j) = Math.min(d(i)(j), d(i)(k) + d(k)(j))\n }\n\n\n // main process\n warshall_floyd()\n\n var ans: Long = Integer.MAX_VALUE\n for(pl <- r.toList.permutations) {\n var tmp = 0L\n for(i <- 0 until pl.length - 1) {\n tmp += d(pl(i))(pl(i+1))\n }\n ans = Math.min(ans, tmp)\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": 1520294702, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03608.html", "problem_id": "p03608", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03608/input.txt", "sample_output_relpath": "derived/input_output/data/p03608/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03608/Scala/s081292923.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s081292923", "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, M, R = in.next().toInt\n val r = new Array[Int](R)\n for (i <- 0 until R) {\n r(i) = in.next().toInt\n }\n\n val d = Array.ofDim[Long](N+1, N+1) // d[a][b] は辺 e = (a, b) のコスト(存在しない場合はINF, ただし d[i][i] = 0 とする)\n val MAX = 100002L\n\n // 初期化\n for(i <- 0 to N; j <- 0 to N){\n if(i == j)\n d(i)(j) = 0\n else\n d(i)(j) = MAX\n }\n\n // input d\n for(i <- 0 until M) {\n val a, b, c = in.next().toInt\n d(a)(b) = c\n d(b)(a) = c\n }\n\n // function\n def warshall_floyd() =\n for(k <- 1 to N; i <- 1 to N; j <- 1 to N){\n d(i)(j) = Math.min(d(i)(j), d(i)(k) + d(k)(j))\n }\n\n\n // main process\n warshall_floyd()\n\n var ans: Long = Integer.MAX_VALUE\n for(pl <- r.toList.permutations) {\n var tmp = 0L\n for(i <- 0 until pl.length - 1) {\n tmp += d(pl(i))(pl(i+1))\n }\n ans = Math.min(ans, tmp)\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\nThere are N towns in the State of Atcoder, connected by M bidirectional roads.\n\nThe i-th road connects Town A_i and B_i and has a length of C_i.\n\nJoisino is visiting R towns in the state, r_1,r_2,..,r_R (not necessarily in this order).\n\nShe will fly to the first town she visits, and fly back from the last town she visits, but for the rest of the trip she will have to travel by road.\n\nIf she visits the towns in the order that minimizes the distance traveled by road, what will that distance be?\n\nConstraints\n\n2≤N≤200\n\n1≤M≤N×(N-1)/2\n\n2≤R≤min(8,N) (min(8,N) is the smaller of 8 and N.)\n\nr_i≠r_j (i≠j)\n\n1≤A_i,B_i≤N, A_i≠B_i\n\n(A_i,B_i)≠(A_j,B_j),(A_i,B_i)≠(B_j,A_j) (i≠j)\n\n1≤C_i≤100000\n\nEvery town can be reached from every town by road.\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M R\nr_1 ... r_R\nA_1 B_1 C_1\n:\nA_M B_M C_M\n\nOutput\n\nPrint the distance traveled by road if Joisino visits the towns in the order that minimizes it.\n\nSample Input 1\n\n3 3 3\n1 2 3\n1 2 1\n2 3 1\n3 1 4\n\nSample Output 1\n\n2\n\nFor example, if she visits the towns in the order of 1, 2, 3, the distance traveled will be 2, which is the minimum possible.\n\nSample Input 2\n\n3 3 2\n1 3\n2 3 2\n1 3 6\n1 2 2\n\nSample Output 2\n\n4\n\nThe shortest distance between Towns 1 and 3 is 4. Thus, whether she visits Town 1 or 3 first, the distance traveled will be 4.\n\nSample Input 3\n\n4 6 3\n2 3 4\n1 2 4\n2 3 3\n4 3 1\n1 4 1\n4 2 2\n3 1 6\n\nSample Output 3\n\n3", "sample_input": "3 3 3\n1 2 3\n1 2 1\n2 3 1\n3 1 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03608", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N towns in the State of Atcoder, connected by M bidirectional roads.\n\nThe i-th road connects Town A_i and B_i and has a length of C_i.\n\nJoisino is visiting R towns in the state, r_1,r_2,..,r_R (not necessarily in this order).\n\nShe will fly to the first town she visits, and fly back from the last town she visits, but for the rest of the trip she will have to travel by road.\n\nIf she visits the towns in the order that minimizes the distance traveled by road, what will that distance be?\n\nConstraints\n\n2≤N≤200\n\n1≤M≤N×(N-1)/2\n\n2≤R≤min(8,N) (min(8,N) is the smaller of 8 and N.)\n\nr_i≠r_j (i≠j)\n\n1≤A_i,B_i≤N, A_i≠B_i\n\n(A_i,B_i)≠(A_j,B_j),(A_i,B_i)≠(B_j,A_j) (i≠j)\n\n1≤C_i≤100000\n\nEvery town can be reached from every town by road.\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M R\nr_1 ... r_R\nA_1 B_1 C_1\n:\nA_M B_M C_M\n\nOutput\n\nPrint the distance traveled by road if Joisino visits the towns in the order that minimizes it.\n\nSample Input 1\n\n3 3 3\n1 2 3\n1 2 1\n2 3 1\n3 1 4\n\nSample Output 1\n\n2\n\nFor example, if she visits the towns in the order of 1, 2, 3, the distance traveled will be 2, which is the minimum possible.\n\nSample Input 2\n\n3 3 2\n1 3\n2 3 2\n1 3 6\n1 2 2\n\nSample Output 2\n\n4\n\nThe shortest distance between Towns 1 and 3 is 4. Thus, whether she visits Town 1 or 3 first, the distance traveled will be 4.\n\nSample Input 3\n\n4 6 3\n2 3 4\n1 2 4\n2 3 3\n4 3 1\n1 4 1\n4 2 2\n3 1 6\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1471, "cpu_time_ms": 858, "memory_kb": 39972}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s207244696", "group_id": "codeNet:p03610", "input_text": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val out = new java.io.PrintWriter(System.out)\n\n val s = in.readLine.toCharArray()\n for(i <- 0 until s.size by 2) {\n out.print(s(i))\n }\n\n out.println\n out.flush\n}", "language": "Scala", "metadata": {"date": 1577054838, "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/s207244696.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s207244696", "user_id": "u217010036"}, "prompt_components": {"gold_output": "acdr\n", "input_to_evaluate": "import scala.io.{StdIn => in}\n\nobject Main extends App {\n val out = new java.io.PrintWriter(System.out)\n\n val s = in.readLine.toCharArray()\n for(i <- 0 until s.size by 2) {\n out.print(s(i))\n }\n\n out.println\n out.flush\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.\n\nConstraints\n\nEach character in s is a lowercase English letter.\n\n1≤|s|≤10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the string obtained by concatenating all the characters in the odd-numbered positions.\n\nSample Input 1\n\natcoder\n\nSample Output 1\n\nacdr\n\nExtract the first character a, the third character c, the fifth character d and the seventh character r to obtain acdr.\n\nSample Input 2\n\naaaa\n\nSample Output 2\n\naa\n\nSample Input 3\n\nz\n\nSample Output 3\n\nz\n\nSample Input 4\n\nfukuokayamaguchi\n\nSample Output 4\n\nfkoaaauh", "sample_input": "atcoder\n"}, "reference_outputs": ["acdr\n"], "source_document_id": "p03610", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.\n\nConstraints\n\nEach character in s is a lowercase English letter.\n\n1≤|s|≤10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the string obtained by concatenating all the characters in the odd-numbered positions.\n\nSample Input 1\n\natcoder\n\nSample Output 1\n\nacdr\n\nExtract the first character a, the third character c, the fifth character d and the seventh character r to obtain acdr.\n\nSample Input 2\n\naaaa\n\nSample Output 2\n\naa\n\nSample Input 3\n\nz\n\nSample Output 3\n\nz\n\nSample Input 4\n\nfukuokayamaguchi\n\nSample Output 4\n\nfkoaaauh", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 228, "cpu_time_ms": 374, "memory_kb": 29304}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s259430649", "group_id": "codeNet:p03610", "input_text": "object Main extends App {\n val s = readLine.toList\n println((0 to s.length-1).toList.filter{_ % 2 == 0}.map{i => s(i)}.mkString(\"\"))\n}", "language": "Scala", "metadata": {"date": 1575930551, "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/s259430649.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s259430649", "user_id": "u696665136"}, "prompt_components": {"gold_output": "acdr\n", "input_to_evaluate": "object Main extends App {\n val s = readLine.toList\n println((0 to s.length-1).toList.filter{_ % 2 == 0}.map{i => s(i)}.mkString(\"\"))\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.\n\nConstraints\n\nEach character in s is a lowercase English letter.\n\n1≤|s|≤10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the string obtained by concatenating all the characters in the odd-numbered positions.\n\nSample Input 1\n\natcoder\n\nSample Output 1\n\nacdr\n\nExtract the first character a, the third character c, the fifth character d and the seventh character r to obtain acdr.\n\nSample Input 2\n\naaaa\n\nSample Output 2\n\naa\n\nSample Input 3\n\nz\n\nSample Output 3\n\nz\n\nSample Input 4\n\nfukuokayamaguchi\n\nSample Output 4\n\nfkoaaauh", "sample_input": "atcoder\n"}, "reference_outputs": ["acdr\n"], "source_document_id": "p03610", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.\n\nConstraints\n\nEach character in s is a lowercase English letter.\n\n1≤|s|≤10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the string obtained by concatenating all the characters in the odd-numbered positions.\n\nSample Input 1\n\natcoder\n\nSample Output 1\n\nacdr\n\nExtract the first character a, the third character c, the fifth character d and the seventh character r to obtain acdr.\n\nSample Input 2\n\naaaa\n\nSample Output 2\n\naa\n\nSample Input 3\n\nz\n\nSample Output 3\n\nz\n\nSample Input 4\n\nfukuokayamaguchi\n\nSample Output 4\n\nfkoaaauh", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 136, "cpu_time_ms": 2111, "memory_kb": 41844}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s574959287", "group_id": "codeNet:p03610", "input_text": "object Main extends App {\n val s = readLine.toList\n println(s.zipWithIndex.map{case (x,i) => if (i%2==0) x else \"\"}.mkString(\"\"))\n}", "language": "Scala", "metadata": {"date": 1575928687, "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/s574959287.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s574959287", "user_id": "u696665136"}, "prompt_components": {"gold_output": "acdr\n", "input_to_evaluate": "object Main extends App {\n val s = readLine.toList\n println(s.zipWithIndex.map{case (x,i) => if (i%2==0) x else \"\"}.mkString(\"\"))\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.\n\nConstraints\n\nEach character in s is a lowercase English letter.\n\n1≤|s|≤10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the string obtained by concatenating all the characters in the odd-numbered positions.\n\nSample Input 1\n\natcoder\n\nSample Output 1\n\nacdr\n\nExtract the first character a, the third character c, the fifth character d and the seventh character r to obtain acdr.\n\nSample Input 2\n\naaaa\n\nSample Output 2\n\naa\n\nSample Input 3\n\nz\n\nSample Output 3\n\nz\n\nSample Input 4\n\nfukuokayamaguchi\n\nSample Output 4\n\nfkoaaauh", "sample_input": "atcoder\n"}, "reference_outputs": ["acdr\n"], "source_document_id": "p03610", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.\n\nConstraints\n\nEach character in s is a lowercase English letter.\n\n1≤|s|≤10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the string obtained by concatenating all the characters in the odd-numbered positions.\n\nSample Input 1\n\natcoder\n\nSample Output 1\n\nacdr\n\nExtract the first character a, the third character c, the fifth character d and the seventh character r to obtain acdr.\n\nSample Input 2\n\naaaa\n\nSample Output 2\n\naa\n\nSample Input 3\n\nz\n\nSample Output 3\n\nz\n\nSample Input 4\n\nfukuokayamaguchi\n\nSample Output 4\n\nfkoaaauh", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 133, "cpu_time_ms": 558, "memory_kb": 41988}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s976344561", "group_id": "codeNet:p03614", "input_text": "import java.util.Scanner\n\nobject Main {\n\n def solve() = {\n val sc = new Scanner(System.in)\n val N = sc.nextInt()\n var ans = 0\n var prev = false\n (1 to N) foreach { i =>\n val p = sc.nextInt()\n if (prev) {\n ans += 1\n prev = false\n } else {\n prev = p == i\n }\n }\n if (prev) ans += 1\n println(ans)\n }\n\n def main(args: Array[String]): Unit = {\n solve()\n }\n}\n", "language": "Scala", "metadata": {"date": 1527885244, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03614.html", "problem_id": "p03614", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03614/input.txt", "sample_output_relpath": "derived/input_output/data/p03614/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03614/Scala/s976344561.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s976344561", "user_id": "u460609472"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n\n def solve() = {\n val sc = new Scanner(System.in)\n val N = sc.nextInt()\n var ans = 0\n var prev = false\n (1 to N) foreach { i =>\n val p = sc.nextInt()\n if (prev) {\n ans += 1\n prev = false\n } else {\n prev = p == i\n }\n }\n if (prev) ans += 1\n println(ans)\n }\n\n def main(args: Array[String]): Unit = {\n solve()\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N.\nYou can perform the following operation any number of times (possibly zero):\n\nOperation: Swap two adjacent elements in the permutation.\n\nYou want to have p_i ≠ i for all 1≤i≤N.\nFind the minimum required number of operations to achieve this.\n\nConstraints\n\n2≤N≤10^5\n\np_1,p_2,..,p_N is a permutation of 1,2,..,N.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\np_1 p_2 .. p_N\n\nOutput\n\nPrint the minimum required number of operations\n\nSample Input 1\n\n5\n1 4 3 5 2\n\nSample Output 1\n\n2\n\nSwap 1 and 4, then swap 1 and 3. p is now 4,3,1,5,2 and satisfies the condition.\nThis is the minimum possible number, so the answer is 2.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n1\n\nSwapping 1 and 2 satisfies the condition.\n\nSample Input 3\n\n2\n2 1\n\nSample Output 3\n\n0\n\nThe condition is already satisfied initially.\n\nSample Input 4\n\n9\n1 2 4 9 5 8 7 3 6\n\nSample Output 4\n\n3", "sample_input": "5\n1 4 3 5 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03614", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N.\nYou can perform the following operation any number of times (possibly zero):\n\nOperation: Swap two adjacent elements in the permutation.\n\nYou want to have p_i ≠ i for all 1≤i≤N.\nFind the minimum required number of operations to achieve this.\n\nConstraints\n\n2≤N≤10^5\n\np_1,p_2,..,p_N is a permutation of 1,2,..,N.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\np_1 p_2 .. p_N\n\nOutput\n\nPrint the minimum required number of operations\n\nSample Input 1\n\n5\n1 4 3 5 2\n\nSample Output 1\n\n2\n\nSwap 1 and 4, then swap 1 and 3. p is now 4,3,1,5,2 and satisfies the condition.\nThis is the minimum possible number, so the answer is 2.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n1\n\nSwapping 1 and 2 satisfies the condition.\n\nSample Input 3\n\n2\n2 1\n\nSample Output 3\n\n0\n\nThe condition is already satisfied initially.\n\nSample Input 4\n\n9\n1 2 4 9 5 8 7 3 6\n\nSample Output 4\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 424, "cpu_time_ms": 665, "memory_kb": 51916}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s200460098", "group_id": "codeNet:p03618", "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 as = get[String]\n\n val map = as.map(_ - 'a').foldLeft(Array.ofDim[Long]('z' - 'a' + 1)) {\n case (acc, c) =>\n acc(c) += 1\n acc\n }\n\n def nc2(n: Long): Long = {\n n * (n - 1) / 2L\n }\n\n out.println(\n map.foldLeft(nc2(as.length) + 1) {\n case (acc, count) => acc - nc2(count)\n }\n )\n\n out.flush()\n }\n}", "language": "Scala", "metadata": {"date": 1597496103, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03618.html", "problem_id": "p03618", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03618/input.txt", "sample_output_relpath": "derived/input_output/data/p03618/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03618/Scala/s200460098.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s200460098", "user_id": "u178269371"}, "prompt_components": {"gold_output": "5\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 as = get[String]\n\n val map = as.map(_ - 'a').foldLeft(Array.ofDim[Long]('z' - 'a' + 1)) {\n case (acc, c) =>\n acc(c) += 1\n acc\n }\n\n def nc2(n: Long): Long = {\n n * (n - 1) / 2L\n }\n\n out.println(\n map.foldLeft(nc2(as.length) + 1) {\n case (acc, count) => acc - nc2(count)\n }\n )\n\n out.flush()\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou have a string A = A_1 A_2 ... A_n consisting of lowercase English letters.\n\nYou can choose any two indices i and j such that 1 \\leq i \\leq j \\leq n and reverse substring A_i A_{i+1} ... A_j.\n\nYou can perform this operation at most once.\n\nHow many different strings can you obtain?\n\nConstraints\n\n1 \\leq |A| \\leq 200,000\n\nA consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\n\nOutput\n\nPrint the number of different strings you can obtain by reversing any substring in A at most once.\n\nSample Input 1\n\naatt\n\nSample Output 1\n\n5\n\nYou can obtain aatt (don't do anything), atat (reverse A[2..3]), atta (reverse A[2..4]), ttaa (reverse A[1..4]) and taat (reverse A[1..3]).\n\nSample Input 2\n\nxxxxxxxxxx\n\nSample Output 2\n\n1\n\nWhatever substring you reverse, you'll always get xxxxxxxxxx.\n\nSample Input 3\n\nabracadabra\n\nSample Output 3\n\n44", "sample_input": "aatt\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03618", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou have a string A = A_1 A_2 ... A_n consisting of lowercase English letters.\n\nYou can choose any two indices i and j such that 1 \\leq i \\leq j \\leq n and reverse substring A_i A_{i+1} ... A_j.\n\nYou can perform this operation at most once.\n\nHow many different strings can you obtain?\n\nConstraints\n\n1 \\leq |A| \\leq 200,000\n\nA consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\n\nOutput\n\nPrint the number of different strings you can obtain by reversing any substring in A at most once.\n\nSample Input 1\n\naatt\n\nSample Output 1\n\n5\n\nYou can obtain aatt (don't do anything), atat (reverse A[2..3]), atta (reverse A[2..4]), ttaa (reverse A[1..4]) and taat (reverse A[1..3]).\n\nSample Input 2\n\nxxxxxxxxxx\n\nSample Output 2\n\n1\n\nWhatever substring you reverse, you'll always get xxxxxxxxxx.\n\nSample Input 3\n\nabracadabra\n\nSample Output 3\n\n44", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4207, "cpu_time_ms": 562, "memory_kb": 59976}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s984510155", "group_id": "codeNet:p03625", "input_text": "import java.util.Scanner\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val Arr = Array.fill[Int](sc.nextInt)(sc.nextInt).groupBy(a => a).filter(A => A._2.length >= 2).foldLeft[(Int, Int)]((0, 0))((A, B) => (\n if (B._2.length >= 4) ((math.max(A._1, B._1), math.max(A._2, B._1))) else (if (A._1 < A._2) ((math.max(A._1, B._1), A._2)) else ((A._1, math.max(A._2, B._1))))\n ))\n println(Arr._1 * Arr._2)\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": 1504415734, "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/s984510155.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s984510155", "user_id": "u779353743"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def solve(sc: => Scanner): Unit = {\n val Arr = Array.fill[Int](sc.nextInt)(sc.nextInt).groupBy(a => a).filter(A => A._2.length >= 2).foldLeft[(Int, Int)]((0, 0))((A, B) => (\n if (B._2.length >= 4) ((math.max(A._1, B._1), math.max(A._2, B._1))) else (if (A._1 < A._2) ((math.max(A._1, B._1), A._2)) else ((A._1, math.max(A._2, B._1))))\n ))\n println(Arr._1 * Arr._2)\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\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1350, "memory_kb": 104484}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s469767483", "group_id": "codeNet:p03625", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n val ls = List.fill(n)(sc.nextInt).sorted(Ordering[Int].reverse)\n\n def recur(ls: List[Int], a: Int, b: Int): Int = ls match {\n case x :: y :: rest if x == y =>\n if (a == -1) recur(rest, x, b)\n else a * x\n case _ :: rest =>\n recur(rest, a, b)\n case _ => 0\n }\n println(recur(ls, -1, -1))\n}", "language": "Scala", "metadata": {"date": 1503279955, "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/s469767483.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s469767483", "user_id": "u810300246"}, "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 ls = List.fill(n)(sc.nextInt).sorted(Ordering[Int].reverse)\n\n def recur(ls: List[Int], a: Int, b: Int): Int = ls match {\n case x :: y :: rest if x == y =>\n if (a == -1) recur(rest, x, b)\n else a * x\n case _ :: rest =>\n recur(rest, a, b)\n case _ => 0\n }\n println(recur(ls, -1, -1))\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 942, "memory_kb": 54772}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s631052397", "group_id": "codeNet:p03627", "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 al = Vector.fill(n)(sc.nextInt)\n\n val cnt = al.zipWithIndex.groupBy(_._1)\n val cnt2 = cnt.filter(_._2.size >= 2)\n val cnt4 = cnt2.filter(_._2.size >= 4)\n val over2 = cnt2.keySet\n val over4 = cnt4.keySet\n\n val bl = (over2 ++ over4).toSeq.sortWith(_ > _)\n\n val res =\n if(bl.length <= 1) 0L\n else bl.head.toLong * bl.tail.head.toLong\n\n println(res)\n}", "language": "Scala", "metadata": {"date": 1557595324, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03627.html", "problem_id": "p03627", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03627/input.txt", "sample_output_relpath": "derived/input_output/data/p03627/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03627/Scala/s631052397.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s631052397", "user_id": "u829407811"}, "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\n val n = sc.nextInt\n val al = Vector.fill(n)(sc.nextInt)\n\n val cnt = al.zipWithIndex.groupBy(_._1)\n val cnt2 = cnt.filter(_._2.size >= 2)\n val cnt4 = cnt2.filter(_._2.size >= 4)\n val over2 = cnt2.keySet\n val over4 = cnt4.keySet\n\n val bl = (over2 ++ over4).toSeq.sortWith(_ > _)\n\n val res =\n if(bl.length <= 1) 0L\n else bl.head.toLong * bl.tail.head.toLong\n\n println(res)\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": "p03627", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have N sticks with negligible thickness.\nThe length of the i-th stick is A_i.\n\nSnuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides.\nFind the maximum possible area of the rectangle.\n\nConstraints\n\n4 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nA_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible area of the rectangle.\nIf no rectangle can be formed, print 0.\n\nSample Input 1\n\n6\n3 1 2 4 2 1\n\nSample Output 1\n\n2\n\n1 \\times 2 rectangle can be formed.\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\n0\n\nNo rectangle can be formed.\n\nSample Input 3\n\n10\n3 3 3 3 4 4 4 5 5 5\n\nSample Output 3\n\n20", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 480, "cpu_time_ms": 1751, "memory_kb": 122644}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s959413612", "group_id": "codeNet:p03632", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val a, b, c, d = sc.nextInt\n\n val res = (0 to 100).foldLeft(0) { (acc, n) =>\n if (a <= n && n < b && c <= n && n < d) acc+1 else acc\n }\n println(res)\n}", "language": "Scala", "metadata": {"date": 1502600976, "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/s959413612.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s959413612", "user_id": "u810300246"}, "prompt_components": {"gold_output": "50\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val a, b, c, d = sc.nextInt\n\n val res = (0 to 100).foldLeft(0) { (acc, n) =>\n if (a <= n && n < b && c <= n && n < d) acc+1 else acc\n }\n println(res)\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 x\n case (x,y) if x < y => gcd(y, x)\n case (x,y) => gcd(y, x % y)\n }\n }\n\n\n}", "language": "Scala", "metadata": {"date": 1557442475, "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/s911006527.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s911006527", "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 n = sc.nextInt\n val tl = List.fill(n)(sc.nextLong)\n\n val res = tl.tail.foldLeft(tl.head)(lcm)\n\n println(res)\n\n\n\n def lcm(a: Long, b: Long): Long ={\n ( a / gcd(a,b)) * b\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\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.\n\nInitially, the hand of every clock stands still, pointing directly upward.\n\nNow, Dolphin starts all the clocks simultaneously.\n\nIn how many seconds will the hand of every clock point directly upward again?\n\nConstraints\n\n1≤N≤100\n\n1≤T_i≤10^{18}\n\nAll input values are integers.\n\nThe correct answer is at most 10^{18} seconds.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nT_1\n:\nT_N\n\nOutput\n\nPrint the number of seconds after which the hand of every clock point directly upward again.\n\nSample Input 1\n\n2\n2\n3\n\nSample Output 1\n\n6\n\nWe have two clocks. The time when the hand of each clock points upward is as follows:\n\nClock 1: 2, 4, 6, ... seconds after the beginning\n\nClock 2: 3, 6, 9, ... seconds after the beginning\n\nTherefore, it takes 6 seconds until the hands of both clocks point directly upward.\n\nSample Input 2\n\n5\n2\n5\n10\n1000000000000000000\n1000000000000000000\n\nSample Output 2\n\n1000000000000000000", "sample_input": "2\n2\n3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03633", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.\n\nInitially, the hand of every clock stands still, pointing directly upward.\n\nNow, Dolphin starts all the clocks simultaneously.\n\nIn how many seconds will the hand of every clock point directly upward again?\n\nConstraints\n\n1≤N≤100\n\n1≤T_i≤10^{18}\n\nAll input values are integers.\n\nThe correct answer is at most 10^{18} seconds.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nT_1\n:\nT_N\n\nOutput\n\nPrint the number of seconds after which the hand of every clock point directly upward again.\n\nSample Input 1\n\n2\n2\n3\n\nSample Output 1\n\n6\n\nWe have two clocks. The time when the hand of each clock points upward is as follows:\n\nClock 1: 2, 4, 6, ... seconds after the beginning\n\nClock 2: 3, 6, 9, ... seconds after the beginning\n\nTherefore, it takes 6 seconds until the hands of both clocks point directly upward.\n\nSample Input 2\n\n5\n2\n5\n10\n1000000000000000000\n1000000000000000000\n\nSample Output 2\n\n1000000000000000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 457, "cpu_time_ms": 355, "memory_kb": 27448}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s546715540", "group_id": "codeNet:p03637", "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 ans = if (multipleOf4.length < a.length / 2) \"No\" else \"Yes\"\n\n println(ans)\n }\n}", "language": "Scala", "metadata": {"date": 1510880722, "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/s546715540.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s546715540", "user_id": "u592088571"}, "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 a = List.fill(n)(sc.nextInt)\n\n val multipleOf4 = a.filter( _ % 4 == 0)\n val ans = if (multipleOf4.length < a.length / 2) \"No\" else \"Yes\"\n\n println(ans)\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 785, "memory_kb": 58300}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s124920203", "group_id": "codeNet:p03643", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n val n = StdIn.readInt\n val ans = \"ABC\" + n\n\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1546903777, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03643.html", "problem_id": "p03643", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03643/input.txt", "sample_output_relpath": "derived/input_output/data/p03643/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03643/Scala/s124920203.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s124920203", "user_id": "u217010036"}, "prompt_components": {"gold_output": "ABC100\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n val n = StdIn.readInt\n val ans = \"ABC\" + n\n\n println(ans)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThis contest, AtCoder Beginner Contest, is abbreviated as ABC.\n\nWhen we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC.\n\nWhat is the abbreviation for the N-th round of ABC? Write a program to output the answer.\n\nConstraints\n\n100 ≤ N ≤ 999\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the abbreviation for the N-th round of ABC.\n\nSample Input 1\n\n100\n\nSample Output 1\n\nABC100\n\nThe 100th round of ABC is ABC100.\n\nSample Input 2\n\n425\n\nSample Output 2\n\nABC425\n\nSample Input 3\n\n999\n\nSample Output 3\n\nABC999", "sample_input": "100\n"}, "reference_outputs": ["ABC100\n"], "source_document_id": "p03643", "source_text": "Score : 100 points\n\nProblem Statement\n\nThis contest, AtCoder Beginner Contest, is abbreviated as ABC.\n\nWhen we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC.\n\nWhat is the abbreviation for the N-th round of ABC? Write a program to output the answer.\n\nConstraints\n\n100 ≤ N ≤ 999\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the abbreviation for the N-th round of ABC.\n\nSample Input 1\n\n100\n\nSample Output 1\n\nABC100\n\nThe 100th round of ABC is ABC100.\n\nSample Input 2\n\n425\n\nSample Output 2\n\nABC425\n\nSample Input 3\n\n999\n\nSample Output 3\n\nABC999", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 112, "cpu_time_ms": 337, "memory_kb": 25400}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s413726577", "group_id": "codeNet:p03644", "input_text": "import scala.io.StdIn\nobject Main extends App {\n def breakNumber(number: Int): Int = {\n var count = 0\n var n = number\n while (n > 1) {\n n /= 2\n count += 1\n }\n count\n }\n val N = StdIn.readLine().toInt\n var maxCount = Int.MinValue\n var answer = 0\n for (i <- 1 to N) {\n val count = breakNumber(i)\n if (count > maxCount) {\n maxCount = count\n answer = i\n }\n }\n println(answer)\n}\n", "language": "Scala", "metadata": {"date": 1565972471, "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/s413726577.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s413726577", "user_id": "u407005073"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "import scala.io.StdIn\nobject Main extends App {\n def breakNumber(number: Int): Int = {\n var count = 0\n var n = number\n while (n > 1) {\n n /= 2\n count += 1\n }\n count\n }\n val N = StdIn.readLine().toInt\n var maxCount = Int.MinValue\n var answer = 0\n for (i <- 1 to N) {\n val count = breakNumber(i)\n if (count > maxCount) {\n maxCount = count\n answer = i\n }\n }\n println(answer)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 426, "cpu_time_ms": 329, "memory_kb": 27340}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s156856583", "group_id": "codeNet:p03644", "input_text": "object Main extends App {\n var a = readInt\n def b(c:Int,d:Int):Int ={\n\tif(c*2<=d) {\n b(c*2,d)\n } else {\n return c\n }\n }\n print(b(1,a))\n}", "language": "Scala", "metadata": {"date": 1562119671, "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/s156856583.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s156856583", "user_id": "u533688845"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "object Main extends App {\n var a = readInt\n def b(c:Int,d:Int):Int ={\n\tif(c*2<=d) {\n b(c*2,d)\n } else {\n return c\n }\n }\n print(b(1,a))\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 322, "memory_kb": 25524}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s084161172", "group_id": "codeNet:p03644", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt\n\n val ls = (1 to 100).map { i =>\n if (i % 2 != 0) 0 else {\n var j = i\n var c = 0\n while(j % 2 == 0) {\n j /= 2\n c += 1\n }\n c\n }\n }\n val lss = ls.take(n)\n val max = lss.max\n println(lss.indexWhere(_ == max) + 1)\n}", "language": "Scala", "metadata": {"date": 1501377940, "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/s084161172.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s084161172", "user_id": "u810300246"}, "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\n val ls = (1 to 100).map { i =>\n if (i % 2 != 0) 0 else {\n var j = i\n var c = 0\n while(j % 2 == 0) {\n j /= 2\n c += 1\n }\n c\n }\n }\n val lss = ls.take(n)\n val max = lss.max\n println(lss.indexWhere(_ == max) + 1)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 351, "memory_kb": 26048}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s877227820", "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 a = Iterator.continually(StdIn.readLine)\n .take(m)\n .map(_.split(\" \").map(_.toInt))\n .toArray\n\n val graph = Array.fill(n+1)(ListBuffer.empty[Int])\n a.foreach(e => {\n graph(e(0)) += e(1)\n })\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": 1546637394, "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/s877227820.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s877227820", "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 a = Iterator.continually(StdIn.readLine)\n .take(m)\n .map(_.split(\" \").map(_.toInt))\n .toArray\n\n val graph = Array.fill(n+1)(ListBuffer.empty[Int])\n a.foreach(e => {\n graph(e(0)) += e(1)\n })\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1237, "memory_kb": 99752}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s462981808", "group_id": "codeNet:p03648", "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}\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 K = sc.nextLong()\n\n def a(N: Int, applyCnt: Long): Long = {\n N - 1 + applyCnt * N - K + applyCnt\n }\n\n val A_MAX = 100000000L * 100000000 + 1000\n def validate(a: Long): Boolean = 0 <= a && a <= A_MAX\n\n def ok(N: Int): Boolean = {\n val a0 = a(N, K / N)\n val a1 = a(N, K / N + 1)\n if (K % N == 0) validate(a0)\n else validate(a0) && validate(a1)\n }\n\n val N = ((2 to 50) find ok).get\n val cnt1 = (K % N).toInt\n val cnt0 = N - cnt1\n val a0 = a(N, K / N)\n val a1 = a(N, K / N + 1)\n\n out.println(N)\n out.println((map(cnt0)(_ => a0) ++ map(cnt1)(_ => a1)).mkString(\" \"))\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 = {\n (0 until n) foreach f\n }\n\n private def map[@specialized(Int, Long) A](n: Int)(f: Int => A): Seq[A] = {\n (0 until n) map f\n }\n}\n", "language": "Scala", "metadata": {"date": 1529378071, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03648.html", "problem_id": "p03648", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03648/input.txt", "sample_output_relpath": "derived/input_output/data/p03648/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03648/Scala/s462981808.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s462981808", "user_id": "u460609472"}, "prompt_components": {"gold_output": "4\n3 3 3 3\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}\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 K = sc.nextLong()\n\n def a(N: Int, applyCnt: Long): Long = {\n N - 1 + applyCnt * N - K + applyCnt\n }\n\n val A_MAX = 100000000L * 100000000 + 1000\n def validate(a: Long): Boolean = 0 <= a && a <= A_MAX\n\n def ok(N: Int): Boolean = {\n val a0 = a(N, K / N)\n val a1 = a(N, K / N + 1)\n if (K % N == 0) validate(a0)\n else validate(a0) && validate(a1)\n }\n\n val N = ((2 to 50) find ok).get\n val cnt1 = (K % N).toInt\n val cnt0 = N - cnt1\n val a0 = a(N, K / N)\n val a1 = a(N, K / N + 1)\n\n out.println(N)\n out.println((map(cnt0)(_ => a0) ++ map(cnt1)(_ => a1)).mkString(\" \"))\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 = {\n (0 until n) foreach f\n }\n\n private def map[@specialized(Int, Long) A](n: Int)(f: Int => A): Seq[A] = {\n (0 until n) map f\n }\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence becomes N-1 or smaller.\n\nDetermine the largest element in the sequence (if there is more than one, choose one). Decrease the value of this element by N, and increase each of the other elements by 1.\n\nIt can be proved that the largest element in the sequence becomes N-1 or smaller after a finite number of operations.\n\nYou are given an integer K. Find an integer sequence a_i such that the number of times we will perform the above operation is exactly K. It can be shown that there is always such a sequence under the constraints on input and output in this problem.\n\nConstraints\n\n0 ≤ K ≤ 50 \\times 10^{16}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint a solution in the following format:\n\nN\na_1 a_2 ... a_N\n\nHere, 2 ≤ N ≤ 50 and 0 ≤ a_i ≤ 10^{16} + 1000 must hold.\n\nSample Input 1\n\n0\n\nSample Output 1\n\n4\n3 3 3 3\n\nSample Input 2\n\n1\n\nSample Output 2\n\n3\n1 0 3\n\nSample Input 3\n\n2\n\nSample Output 3\n\n2\n2 2\n\nThe operation will be performed twice: [2, 2] -> [0, 3] -> [1, 1].\n\nSample Input 4\n\n3\n\nSample Output 4\n\n7\n27 0 0 0 0 0 0\n\nSample Input 5\n\n1234567894848\n\nSample Output 5\n\n10\n1000 193 256 777 0 1 1192 1234567891011 48 425", "sample_input": "0\n"}, "reference_outputs": ["4\n3 3 3 3\n"], "source_document_id": "p03648", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence becomes N-1 or smaller.\n\nDetermine the largest element in the sequence (if there is more than one, choose one). Decrease the value of this element by N, and increase each of the other elements by 1.\n\nIt can be proved that the largest element in the sequence becomes N-1 or smaller after a finite number of operations.\n\nYou are given an integer K. Find an integer sequence a_i such that the number of times we will perform the above operation is exactly K. It can be shown that there is always such a sequence under the constraints on input and output in this problem.\n\nConstraints\n\n0 ≤ K ≤ 50 \\times 10^{16}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint a solution in the following format:\n\nN\na_1 a_2 ... a_N\n\nHere, 2 ≤ N ≤ 50 and 0 ≤ a_i ≤ 10^{16} + 1000 must hold.\n\nSample Input 1\n\n0\n\nSample Output 1\n\n4\n3 3 3 3\n\nSample Input 2\n\n1\n\nSample Output 2\n\n3\n1 0 3\n\nSample Input 3\n\n2\n\nSample Output 3\n\n2\n2 2\n\nThe operation will be performed twice: [2, 2] -> [0, 3] -> [1, 1].\n\nSample Input 4\n\n3\n\nSample Output 4\n\n7\n27 0 0 0 0 0 0\n\nSample Input 5\n\n1234567894848\n\nSample Output 5\n\n10\n1000 193 256 777 0 1 1192 1234567891011 48 425", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1779, "cpu_time_ms": 331, "memory_kb": 25540}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s015209671", "group_id": "codeNet:p03652", "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) {\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 N, M = ni()\n val g = nm(N, M)\n\n def test(x: Int): Boolean = {\n debug(s\"test($x)\")\n val ix = Array.ofDim[Int](N)\n val disable = Array.ofDim[Boolean](M + 1)\n val count = Array.ofDim[Int](M + 1)\n REP(N) { i =>\n count(g(i)(0)) += 1\n }\n def step(): Boolean = {\n var mxCnt = 0\n var mxNum = 0\n REP(N) { i =>\n while(disable(g(i)(ix(i)))) {\n ix(i) += 1\n count(g(i)(ix(i))) += 1\n }\n// debug(count)\n if (count(g(i)(ix(i))) > mxCnt) {\n mxCnt = count(g(i)(ix(i)))\n mxNum = g(i)(ix(i))\n debug(s\"change mxCnt:$mxCnt mxNum:$mxNum\")\n }\n }\n debug(s\"step mxCnt:$mxCnt mxNum:$mxNum\")\n disable(mxNum) = true // 次のstepに備えて\n mxCnt <= x\n }\n\n REP(N) { _ =>\n if (step()) return true\n }\n false\n }\n\n val ans = findMin(test, 1, N)\n out.println(ans)\n }\n\n def findMin(f: Int => Boolean, min: Int, max: Int): Int = {\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": 1561501013, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03652.html", "problem_id": "p03652", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03652/input.txt", "sample_output_relpath": "derived/input_output/data/p03652/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03652/Scala/s015209671.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s015209671", "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) {\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 N, M = ni()\n val g = nm(N, M)\n\n def test(x: Int): Boolean = {\n debug(s\"test($x)\")\n val ix = Array.ofDim[Int](N)\n val disable = Array.ofDim[Boolean](M + 1)\n val count = Array.ofDim[Int](M + 1)\n REP(N) { i =>\n count(g(i)(0)) += 1\n }\n def step(): Boolean = {\n var mxCnt = 0\n var mxNum = 0\n REP(N) { i =>\n while(disable(g(i)(ix(i)))) {\n ix(i) += 1\n count(g(i)(ix(i))) += 1\n }\n// debug(count)\n if (count(g(i)(ix(i))) > mxCnt) {\n mxCnt = count(g(i)(ix(i)))\n mxNum = g(i)(ix(i))\n debug(s\"change mxCnt:$mxCnt mxNum:$mxNum\")\n }\n }\n debug(s\"step mxCnt:$mxCnt mxNum:$mxNum\")\n disable(mxNum) = true // 次のstepに備えて\n mxCnt <= x\n }\n\n REP(N) { _ =>\n if (step()) return true\n }\n false\n }\n\n val ans = findMin(test, 1, N)\n out.println(ans)\n }\n\n def findMin(f: Int => Boolean, min: Int, max: Int): Int = {\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 : 700 points\n\nProblem Statement\n\nTakahashi is hosting an sports meet.\nThere are N people who will participate. These people are conveniently numbered 1 through N.\nAlso, there are M options of sports for this event. These sports are numbered 1 through M.\nAmong these options, Takahashi will select one or more sports (possibly all) to be played in the event.\n\nTakahashi knows that Person i's j-th favorite sport is Sport A_{ij}.\nEach person will only participate in his/her most favorite sport among the ones that are actually played in the event, and will not participate in the other sports.\n\nTakahashi is worried that one of the sports will attract too many people.\nTherefore, he would like to carefully select sports to be played so that the number of the participants in the sport with the largest number of participants is minimized.\nFind the minimum possible number of the participants in the sport with the largest number of participants.\n\nConstraints\n\n1 \\leq N \\leq 300\n\n1 \\leq M \\leq 300\n\nA_{i1} , A_{i2} , ... , A_{iM} is a permutation of the integers from 1 to M.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_{11} A_{12} ... A_{1M}\nA_{21} A_{22} ... A_{2M}\n:\nA_{N1} A_{N2} ... A_{NM}\n\nOutput\n\nPrint the minimum possible number of the participants in the sport with the largest number of participants.\n\nSample Input 1\n\n4 5\n5 1 3 4 2\n2 5 3 1 4\n2 3 1 4 5\n2 5 4 3 1\n\nSample Output 1\n\n2\n\nAssume that Sports 1, 3 and 4 are selected to be played. In this case, Person 1 will participate in Sport 1, Person 2 in Sport 3, Person 3 in Sport 3 and Person 4 in Sport 4.\nHere, the sport with the largest number of participants is Sport 3, with two participants.\nThere is no way to reduce the number of participants in the sport with the largest number of participants to 1. Therefore, the answer is 2.\n\nSample Input 2\n\n3 3\n2 1 3\n2 1 3\n2 1 3\n\nSample Output 2\n\n3\n\nSince all the people have the same taste in sports, there will be a sport with three participants, no matter what sports are selected.\nTherefore, the answer is 3.", "sample_input": "4 5\n5 1 3 4 2\n2 5 3 1 4\n2 3 1 4 5\n2 5 4 3 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03652", "source_text": "Score : 700 points\n\nProblem Statement\n\nTakahashi is hosting an sports meet.\nThere are N people who will participate. These people are conveniently numbered 1 through N.\nAlso, there are M options of sports for this event. These sports are numbered 1 through M.\nAmong these options, Takahashi will select one or more sports (possibly all) to be played in the event.\n\nTakahashi knows that Person i's j-th favorite sport is Sport A_{ij}.\nEach person will only participate in his/her most favorite sport among the ones that are actually played in the event, and will not participate in the other sports.\n\nTakahashi is worried that one of the sports will attract too many people.\nTherefore, he would like to carefully select sports to be played so that the number of the participants in the sport with the largest number of participants is minimized.\nFind the minimum possible number of the participants in the sport with the largest number of participants.\n\nConstraints\n\n1 \\leq N \\leq 300\n\n1 \\leq M \\leq 300\n\nA_{i1} , A_{i2} , ... , A_{iM} is a permutation of the integers from 1 to M.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_{11} A_{12} ... A_{1M}\nA_{21} A_{22} ... A_{2M}\n:\nA_{N1} A_{N2} ... A_{NM}\n\nOutput\n\nPrint the minimum possible number of the participants in the sport with the largest number of participants.\n\nSample Input 1\n\n4 5\n5 1 3 4 2\n2 5 3 1 4\n2 3 1 4 5\n2 5 4 3 1\n\nSample Output 1\n\n2\n\nAssume that Sports 1, 3 and 4 are selected to be played. In this case, Person 1 will participate in Sport 1, Person 2 in Sport 3, Person 3 in Sport 3 and Person 4 in Sport 4.\nHere, the sport with the largest number of participants is Sport 3, with two participants.\nThere is no way to reduce the number of participants in the sport with the largest number of participants to 1. Therefore, the answer is 2.\n\nSample Input 2\n\n3 3\n2 1 3\n2 1 3\n2 1 3\n\nSample Output 2\n\n3\n\nSince all the people have the same taste in sports, there will be a sport with three participants, no matter what sports are selected.\nTherefore, the answer is 3.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4787, "cpu_time_ms": 560, "memory_kb": 38444}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s968090145", "group_id": "codeNet:p03657", "input_text": "object Main {\n\n\tdef main(arg:Array[String]) = {\n\t\tvar list = scala.io.StdIn.readLine().split(\" \").map(_.toInt);\n\t\tif(List(list(0), list(1), list(0) + list(1)).exists(_ % 3 == 0)) println(\"Possible\");\n\t\telse println(\"Impossible\");\n\t}\n\n}\n", "language": "Scala", "metadata": {"date": 1524281714, "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/s968090145.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s968090145", "user_id": "u029876051"}, "prompt_components": {"gold_output": "Possible\n", "input_to_evaluate": "object Main {\n\n\tdef main(arg:Array[String]) = {\n\t\tvar list = scala.io.StdIn.readLine().split(\" \").map(_.toInt);\n\t\tif(List(list(0), list(1), list(0) + list(1)).exists(_ % 3 == 0)) println(\"Possible\");\n\t\telse println(\"Impossible\");\n\t}\n\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 327, "memory_kb": 25412}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s635320741", "group_id": "codeNet:p03659", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n val n = StdIn.readInt\n val a = StdIn.readLine.split(\" \").map(_.toInt)\n val sum = a.sum\n val initial = (math.abs(a.head-(sum-a.head)),a.head)\n\n val ans = a.tail.init./:(initial)((acc,i) => {\n val xy = math.min(math.abs((acc._2+i)-(sum-(acc._2+i))), acc._1)\n (xy, acc._2 + i)\n })._1\n\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1546722353, "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/s635320741.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s635320741", "user_id": "u217010036"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n val n = StdIn.readInt\n val a = StdIn.readLine.split(\" \").map(_.toInt)\n val sum = a.sum\n val initial = (math.abs(a.head-(sum-a.head)),a.head)\n\n val ans = a.tail.init./:(initial)((acc,i) => {\n val xy = math.min(math.abs((acc._2+i)-(sum-(acc._2+i))), acc._1)\n (xy, acc._2 + i)\n })._1\n\n println(ans)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 366, "cpu_time_ms": 623, "memory_kb": 57080}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s317579208", "group_id": "codeNet:p03659", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n val n = readLine()\n val a = readLine().split(\" \").toList.map(_.toInt)\n val total = a.sum\n def searchMin(intList: List[Int], min: Int = (a.head - a.drop(1).sum).abs): Int = {\n intList match {\n case int :: tail if tail == Nil => min\n case int :: tail =>\n val diff = (int - tail.sum).abs\n searchMin(tail, if (diff < min) diff else min)\n }\n }\n println(searchMin(a))\n }\n}\n", "language": "Scala", "metadata": {"date": 1544031201, "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/s317579208.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s317579208", "user_id": "u513475309"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n val n = readLine()\n val a = readLine().split(\" \").toList.map(_.toInt)\n val total = a.sum\n def searchMin(intList: List[Int], min: Int = (a.head - a.drop(1).sum).abs): Int = {\n intList match {\n case int :: tail if tail == Nil => min\n case int :: tail =>\n val diff = (int - tail.sum).abs\n searchMin(tail, if (diff < min) diff else min)\n }\n }\n println(searchMin(a))\n }\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": "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 485, "cpu_time_ms": 2111, "memory_kb": 145448}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s669656353", "group_id": "codeNet:p03660", "input_text": "import java.util.Scanner\nimport Math.max\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val fene = \"Fennec\"\n val snuke = \"Snuke\"\n\n val N = sc.nextInt()\n val edges = Array.fill[List[Int]](N+1)(Nil)\n for (_ <- 1 to N-1) {\n val a, b = sc.nextInt()\n edges(a) = b :: edges(a)\n edges(b) = a :: edges(b)\n }\n\n\n // fenec\n val stack = new scala.collection.mutable.Stack[(Int, Int)]\n val dp = new Array[Boolean](N+1)\n dp(1) = true\n\n var feneMax = 0\n \n for(e <- edges(1)) {\n stack.push((e, 1))\n dp(e) = true\n }\n\n while(!stack.isEmpty) {\n val (node, score) = stack.pop\n\n node match {\n case N =>\n if((score-1) % 2 == 1) feneMax = max(feneMax, score-1)\n case _ =>\n feneMax = max(feneMax, score)\n var flag = true\n for(e <- edges(node)) {\n if(!dp(e)) {\n flag = false\n stack.push((e, score+1))\n dp(e) = true\n }\n }\n if(flag) feneMax = max(feneMax, score)\n }\n }\n\n\n // snuke\n for(i <- 1 to N)\n dp(i) = false\n dp(N) = true\n\n var snukeMax = 0\n \n for(e <- edges(N)) {\n stack.push((e, 1))\n dp(e) = true\n }\n\n while(!stack.isEmpty) {\n val (node, score) = stack.pop\n\n node match {\n case 1 =>\n if((score-1) % 2 == 1) snukeMax = max(snukeMax, score-1)\n case _ =>\n snukeMax = max(snukeMax, score)\n var flag = true\n for(e <- edges(node)) {\n if(!dp(e)) {\n flag = false\n stack.push((e, score+1))\n dp(e) = true\n }\n }\n if(flag) snukeMax = max(snukeMax, score)\n }\n }\n\n if(feneMax > snukeMax)\n println(fene)\n else\n println(snuke)\n}\n", "language": "Scala", "metadata": {"date": 1511827487, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03660.html", "problem_id": "p03660", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03660/input.txt", "sample_output_relpath": "derived/input_output/data/p03660/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03660/Scala/s669656353.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s669656353", "user_id": "u098968285"}, "prompt_components": {"gold_output": "Fennec\n", "input_to_evaluate": "import java.util.Scanner\nimport Math.max\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val fene = \"Fennec\"\n val snuke = \"Snuke\"\n\n val N = sc.nextInt()\n val edges = Array.fill[List[Int]](N+1)(Nil)\n for (_ <- 1 to N-1) {\n val a, b = sc.nextInt()\n edges(a) = b :: edges(a)\n edges(b) = a :: edges(b)\n }\n\n\n // fenec\n val stack = new scala.collection.mutable.Stack[(Int, Int)]\n val dp = new Array[Boolean](N+1)\n dp(1) = true\n\n var feneMax = 0\n \n for(e <- edges(1)) {\n stack.push((e, 1))\n dp(e) = true\n }\n\n while(!stack.isEmpty) {\n val (node, score) = stack.pop\n\n node match {\n case N =>\n if((score-1) % 2 == 1) feneMax = max(feneMax, score-1)\n case _ =>\n feneMax = max(feneMax, score)\n var flag = true\n for(e <- edges(node)) {\n if(!dp(e)) {\n flag = false\n stack.push((e, score+1))\n dp(e) = true\n }\n }\n if(flag) feneMax = max(feneMax, score)\n }\n }\n\n\n // snuke\n for(i <- 1 to N)\n dp(i) = false\n dp(N) = true\n\n var snukeMax = 0\n \n for(e <- edges(N)) {\n stack.push((e, 1))\n dp(e) = true\n }\n\n while(!stack.isEmpty) {\n val (node, score) = stack.pop\n\n node match {\n case 1 =>\n if((score-1) % 2 == 1) snukeMax = max(snukeMax, score-1)\n case _ =>\n snukeMax = max(snukeMax, score)\n var flag = true\n for(e <- edges(node)) {\n if(!dp(e)) {\n flag = false\n stack.push((e, score+1))\n dp(e) = true\n }\n }\n if(flag) snukeMax = max(snukeMax, score)\n }\n }\n\n if(feneMax > snukeMax)\n println(fene)\n else\n println(snuke)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nFennec and Snuke are playing a board game.\n\nOn the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree.\n\nInitially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored.\nFennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell.\nMore specifically, each player performs the following action in her/his turn:\n\nFennec: selects an uncolored cell that is adjacent to a black cell, and paints it black.\n\nSnuke: selects an uncolored cell that is adjacent to a white cell, and paints it white.\n\nA player loses when she/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq a_i, b_i \\leq N\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\n:\na_{N-1} b_{N-1}\n\nOutput\n\nIf Fennec wins, print Fennec; if Snuke wins, print Snuke.\n\nSample Input 1\n\n7\n3 6\n1 2\n3 1\n7 4\n5 7\n1 4\n\nSample Output 1\n\nFennec\n\nFor example, if Fennec first paints Cell 2 black, she will win regardless of Snuke's moves.\n\nSample Input 2\n\n4\n1 4\n4 2\n2 3\n\nSample Output 2\n\nSnuke", "sample_input": "7\n3 6\n1 2\n3 1\n7 4\n5 7\n1 4\n"}, "reference_outputs": ["Fennec\n"], "source_document_id": "p03660", "source_text": "Score : 400 points\n\nProblem Statement\n\nFennec and Snuke are playing a board game.\n\nOn the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree.\n\nInitially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored.\nFennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell.\nMore specifically, each player performs the following action in her/his turn:\n\nFennec: selects an uncolored cell that is adjacent to a black cell, and paints it black.\n\nSnuke: selects an uncolored cell that is adjacent to a white cell, and paints it white.\n\nA player loses when she/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq a_i, b_i \\leq N\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\n:\na_{N-1} b_{N-1}\n\nOutput\n\nIf Fennec wins, print Fennec; if Snuke wins, print Snuke.\n\nSample Input 1\n\n7\n3 6\n1 2\n3 1\n7 4\n5 7\n1 4\n\nSample Output 1\n\nFennec\n\nFor example, if Fennec first paints Cell 2 black, she will win regardless of Snuke's moves.\n\nSample Input 2\n\n4\n1 4\n4 2\n2 3\n\nSample Output 2\n\nSnuke", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1691, "cpu_time_ms": 958, "memory_kb": 80608}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s192072143", "group_id": "codeNet:p03662", "input_text": "import java.io.{BufferedReader, IOException, InputStream, InputStreamReader}\nimport java.util.StringTokenizer\n\nimport scala.collection.mutable\nimport scala.util.Sorting\n\nobject Main {\n def solve(): Unit = {\n val sc = new InputReader(System.in)\n val N = sc.nextInt()\n val e = Array.ofDim[mutable.Set[Int]](N + 1)\n (0 until N - 1) foreach { _ =>\n val u = sc.nextInt()\n val v = sc.nextInt()\n if (e(u) == null) e(u) = mutable.Set.empty\n if (e(v) == null) e(v) = mutable.Set.empty\n e(u) += v\n e(v) += u\n }\n\n def findPath(s: Int, t: Int): Seq[Int] = {\n val INF = N + 10\n val d = Array.fill(N + 1)(INF)\n val q = mutable.PriorityQueue.empty[(Int, Int)](Ordering.by((_: (Int, Int))._1)) // (cost, 頂点)\n val prev = Array.fill(N + 1)(-1)\n\n d(s) = 0\n q.enqueue((0, s))\n\n while(q.nonEmpty) {\n val (cost, v) = q.dequeue()\n if (cost <= d(v)) {\n e(v).foreach { u =>\n if (d(u) > d(v) + 1) {\n d(u) = d(v) + 1\n prev(u) = v\n q.enqueue((d(u), u))\n }\n }\n }\n }\n\n def traceback(v: Int, end: Int, path: List[Int]): List[Int] = v match {\n case `end` => v :: path\n case _ => traceback(prev(v), end, v :: path)\n }\n\n traceback(t, s, Nil)\n }\n\n def delEdge(u: Int, v: Int): Unit = {\n e(u) -= v\n e(v) -= u\n }\n\n val oneToN = findPath(1, N)\n oneToN zip oneToN.drop(1) foreach {\n case (u, v) => delEdge(u, v)\n }\n\n val uf = new UnionFind(N + 1)\n e.indices foreach { v =>\n if (e(v) != null )\n e(v).foreach { u =>\n uf.unite(v, u)\n }\n }\n\n def countConnected(v: Int): Int = {\n val r = uf.find(v)\n ((1 to N) count (v => uf.find(v) == r)) - 1\n }\n\n val c1 = countConnected(1)\n val cN = countConnected(N)\n\n val len = oneToN.length - 2\n val winner = if (c1 + (len & 1) > cN) \"Fennec\"\n else \"Snuke\"\n\n println(winner)\n }\n\n def main(args: Array[String]): Unit = {\n solve()\n }\n\n class InputReader(val stream: InputStream) {\n val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n 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 nextChar(): Char = next.charAt(0)\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": 1527916938, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03662.html", "problem_id": "p03662", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03662/input.txt", "sample_output_relpath": "derived/input_output/data/p03662/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03662/Scala/s192072143.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s192072143", "user_id": "u460609472"}, "prompt_components": {"gold_output": "Fennec\n", "input_to_evaluate": "import java.io.{BufferedReader, IOException, InputStream, InputStreamReader}\nimport java.util.StringTokenizer\n\nimport scala.collection.mutable\nimport scala.util.Sorting\n\nobject Main {\n def solve(): Unit = {\n val sc = new InputReader(System.in)\n val N = sc.nextInt()\n val e = Array.ofDim[mutable.Set[Int]](N + 1)\n (0 until N - 1) foreach { _ =>\n val u = sc.nextInt()\n val v = sc.nextInt()\n if (e(u) == null) e(u) = mutable.Set.empty\n if (e(v) == null) e(v) = mutable.Set.empty\n e(u) += v\n e(v) += u\n }\n\n def findPath(s: Int, t: Int): Seq[Int] = {\n val INF = N + 10\n val d = Array.fill(N + 1)(INF)\n val q = mutable.PriorityQueue.empty[(Int, Int)](Ordering.by((_: (Int, Int))._1)) // (cost, 頂点)\n val prev = Array.fill(N + 1)(-1)\n\n d(s) = 0\n q.enqueue((0, s))\n\n while(q.nonEmpty) {\n val (cost, v) = q.dequeue()\n if (cost <= d(v)) {\n e(v).foreach { u =>\n if (d(u) > d(v) + 1) {\n d(u) = d(v) + 1\n prev(u) = v\n q.enqueue((d(u), u))\n }\n }\n }\n }\n\n def traceback(v: Int, end: Int, path: List[Int]): List[Int] = v match {\n case `end` => v :: path\n case _ => traceback(prev(v), end, v :: path)\n }\n\n traceback(t, s, Nil)\n }\n\n def delEdge(u: Int, v: Int): Unit = {\n e(u) -= v\n e(v) -= u\n }\n\n val oneToN = findPath(1, N)\n oneToN zip oneToN.drop(1) foreach {\n case (u, v) => delEdge(u, v)\n }\n\n val uf = new UnionFind(N + 1)\n e.indices foreach { v =>\n if (e(v) != null )\n e(v).foreach { u =>\n uf.unite(v, u)\n }\n }\n\n def countConnected(v: Int): Int = {\n val r = uf.find(v)\n ((1 to N) count (v => uf.find(v) == r)) - 1\n }\n\n val c1 = countConnected(1)\n val cN = countConnected(N)\n\n val len = oneToN.length - 2\n val winner = if (c1 + (len & 1) > cN) \"Fennec\"\n else \"Snuke\"\n\n println(winner)\n }\n\n def main(args: Array[String]): Unit = {\n solve()\n }\n\n class InputReader(val stream: InputStream) {\n val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n 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 nextChar(): Char = next.charAt(0)\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\nFennec and Snuke are playing a board game.\n\nOn the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree.\n\nInitially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored.\nFennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell.\nMore specifically, each player performs the following action in her/his turn:\n\nFennec: selects an uncolored cell that is adjacent to a black cell, and paints it black.\n\nSnuke: selects an uncolored cell that is adjacent to a white cell, and paints it white.\n\nA player loses when she/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq a_i, b_i \\leq N\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\n:\na_{N-1} b_{N-1}\n\nOutput\n\nIf Fennec wins, print Fennec; if Snuke wins, print Snuke.\n\nSample Input 1\n\n7\n3 6\n1 2\n3 1\n7 4\n5 7\n1 4\n\nSample Output 1\n\nFennec\n\nFor example, if Fennec first paints Cell 2 black, she will win regardless of Snuke's moves.\n\nSample Input 2\n\n4\n1 4\n4 2\n2 3\n\nSample Output 2\n\nSnuke", "sample_input": "7\n3 6\n1 2\n3 1\n7 4\n5 7\n1 4\n"}, "reference_outputs": ["Fennec\n"], "source_document_id": "p03662", "source_text": "Score : 400 points\n\nProblem Statement\n\nFennec and Snuke are playing a board game.\n\nOn the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree.\n\nInitially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored.\nFennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell.\nMore specifically, each player performs the following action in her/his turn:\n\nFennec: selects an uncolored cell that is adjacent to a black cell, and paints it black.\n\nSnuke: selects an uncolored cell that is adjacent to a white cell, and paints it white.\n\nA player loses when she/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq a_i, b_i \\leq N\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\n:\na_{N-1} b_{N-1}\n\nOutput\n\nIf Fennec wins, print Fennec; if Snuke wins, print Snuke.\n\nSample Input 1\n\n7\n3 6\n1 2\n3 1\n7 4\n5 7\n1 4\n\nSample Output 1\n\nFennec\n\nFor example, if Fennec first paints Cell 2 black, she will win regardless of Snuke's moves.\n\nSample Input 2\n\n4\n1 4\n4 2\n2 3\n\nSample Output 2\n\nSnuke", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3016, "cpu_time_ms": 1347, "memory_kb": 104952}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s661823697", "group_id": "codeNet:p03672", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n\n val q = StdIn.readLine()\n \n def solve(s: String): Int = {\n val (s1, s2) = s.splitAt(s.length/2)\n if(s1 == s2) s.length\n else solve(s.tail)\n } \n \n println(solve(q.reverse.tail))\n \n}\n", "language": "Scala", "metadata": {"date": 1534937286, "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/s661823697.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s661823697", "user_id": "u895032849"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n\n val q = StdIn.readLine()\n \n def solve(s: String): Int = {\n val (s1, s2) = s.splitAt(s.length/2)\n if(s1 == s2) s.length\n else solve(s.tail)\n } \n \n println(solve(q.reverse.tail))\n \n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 248, "cpu_time_ms": 329, "memory_kb": 27204}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s525166497", "group_id": "codeNet:p03679", "input_text": "\nobject Main {\n def main(args: Array[String]) {\n val sc = new java.util.Scanner(System.in)\n val x, a, b = sc.nextInt\n\n val text =\n if (a < b) \"delicious\"\n else if (a + x > b) \"safe\"\n else \"dangerous\"\n\n println(text)\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1509593909, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03679.html", "problem_id": "p03679", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03679/input.txt", "sample_output_relpath": "derived/input_output/data/p03679/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03679/Scala/s525166497.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s525166497", "user_id": "u592088571"}, "prompt_components": {"gold_output": "safe\n", "input_to_evaluate": "\nobject Main {\n def main(args: Array[String]) {\n val sc = new java.util.Scanner(System.in)\n val x, a, b = sc.nextInt\n\n val text =\n if (a < b) \"delicious\"\n else if (a + x > b) \"safe\"\n else \"dangerous\"\n\n println(text)\n }\n}\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi has a strong stomach. He never gets a stomachache from eating something whose \"best-by\" date is at most X days earlier.\nHe gets a stomachache if the \"best-by\" date of the food is X+1 or more days earlier, though.\n\nOther than that, he finds the food delicious if he eats it not later than the \"best-by\" date. Otherwise, he does not find it delicious.\n\nTakahashi bought some food A days before the \"best-by\" date, and ate it B days after he bought it.\n\nWrite a program that outputs delicious if he found it delicious, safe if he did not found it delicious but did not get a stomachache either, and dangerous if he got a stomachache.\n\nConstraints\n\n1 ≤ X,A,B ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX A B\n\nOutput\n\nPrint delicious if Takahashi found the food delicious; print safe if he neither found it delicious nor got a stomachache; print dangerous if he got a stomachache.\n\nSample Input 1\n\n4 3 6\n\nSample Output 1\n\nsafe\n\nHe ate the food three days after the \"best-by\" date. It was not delicious or harmful for him.\n\nSample Input 2\n\n6 5 1\n\nSample Output 2\n\ndelicious\n\nHe ate the food by the \"best-by\" date. It was delicious for him.\n\nSample Input 3\n\n3 7 12\n\nSample Output 3\n\ndangerous\n\nHe ate the food five days after the \"best-by\" date. It was harmful for him.", "sample_input": "4 3 6\n"}, "reference_outputs": ["safe\n"], "source_document_id": "p03679", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi has a strong stomach. He never gets a stomachache from eating something whose \"best-by\" date is at most X days earlier.\nHe gets a stomachache if the \"best-by\" date of the food is X+1 or more days earlier, though.\n\nOther than that, he finds the food delicious if he eats it not later than the \"best-by\" date. Otherwise, he does not find it delicious.\n\nTakahashi bought some food A days before the \"best-by\" date, and ate it B days after he bought it.\n\nWrite a program that outputs delicious if he found it delicious, safe if he did not found it delicious but did not get a stomachache either, and dangerous if he got a stomachache.\n\nConstraints\n\n1 ≤ X,A,B ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX A B\n\nOutput\n\nPrint delicious if Takahashi found the food delicious; print safe if he neither found it delicious nor got a stomachache; print dangerous if he got a stomachache.\n\nSample Input 1\n\n4 3 6\n\nSample Output 1\n\nsafe\n\nHe ate the food three days after the \"best-by\" date. It was not delicious or harmful for him.\n\nSample Input 2\n\n6 5 1\n\nSample Output 2\n\ndelicious\n\nHe ate the food by the \"best-by\" date. It was delicious for him.\n\nSample Input 3\n\n3 7 12\n\nSample Output 3\n\ndangerous\n\nHe ate the food five days after the \"best-by\" date. It was harmful for him.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 253, "cpu_time_ms": 341, "memory_kb": 25412}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s065578055", "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 val num = list.scan(1)((a, _) => list(a - 1)).find(_ == 2).fold(-1)(_ + 1)\n \n println(num)\n}", "language": "Scala", "metadata": {"date": 1578293712, "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/s065578055.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s065578055", "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 val num = list.scan(1)((a, _) => list(a - 1)).find(_ == 2).fold(-1)(_ + 1)\n \n println(num)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi wants to gain muscle, and decides to work out at AtCoder Gym.\n\nThe exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up.\nThese buttons are numbered 1 through N.\nWhen Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i.\nWhen Button i is not lighten up, nothing will happen by pressing it.\n\nInitially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up.\n\nDetermine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1\na_2\n:\na_N\n\nOutput\n\nPrint -1 if it is impossible to lighten up Button 2.\nOtherwise, print the minimum number of times we need to press buttons in order to lighten up Button 2.\n\nSample Input 1\n\n3\n3\n1\n2\n\nSample Output 1\n\n2\n\nPress Button 1, then Button 3.\n\nSample Input 2\n\n4\n3\n4\n1\n2\n\nSample Output 2\n\n-1\n\nPressing Button 1 lightens up Button 3, and vice versa, so Button 2 will never be lighten up.\n\nSample Input 3\n\n5\n3\n3\n4\n2\n4\n\nSample Output 3\n\n3", "sample_input": "3\n3\n1\n2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03680", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi wants to gain muscle, and decides to work out at AtCoder Gym.\n\nThe exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up.\nThese buttons are numbered 1 through N.\nWhen Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i.\nWhen Button i is not lighten up, nothing will happen by pressing it.\n\nInitially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up.\n\nDetermine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1\na_2\n:\na_N\n\nOutput\n\nPrint -1 if it is impossible to lighten up Button 2.\nOtherwise, print the minimum number of times we need to press buttons in order to lighten up Button 2.\n\nSample Input 1\n\n3\n3\n1\n2\n\nSample Output 1\n\n2\n\nPress Button 1, then Button 3.\n\nSample Input 2\n\n4\n3\n4\n1\n2\n\nSample Output 2\n\n-1\n\nPressing Button 1 lightens up Button 3, and vice versa, so Button 2 will never be lighten up.\n\nSample Input 3\n\n5\n3\n3\n4\n2\n4\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 228, "cpu_time_ms": 2115, "memory_kb": 54944}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s045162917", "group_id": "codeNet:p03680", "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.next.toInt\n val bottons = List.fill(n)(sc.nextInt)\n val indexBottonMap = bottons.zipWithIndex.map(item => (item._2, item._1)).toMap\n\n def go(n: Int, k: Int, acc: Int): Int = {\n if (n == -1) -1\n else if (k == 2) acc\n else {\n go(n - 1, indexBottonMap(k - 1), acc + 1)\n }\n }\n\n println(go(n, 1, 0))\n }\n}\n", "language": "Scala", "metadata": {"date": 1558346549, "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/s045162917.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s045162917", "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 n = sc.next.toInt\n val bottons = List.fill(n)(sc.nextInt)\n val indexBottonMap = bottons.zipWithIndex.map(item => (item._2, item._1)).toMap\n\n def go(n: Int, k: Int, acc: Int): Int = {\n if (n == -1) -1\n else if (k == 2) acc\n else {\n go(n - 1, indexBottonMap(k - 1), acc + 1)\n }\n }\n\n println(go(n, 1, 0))\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi wants to gain muscle, and decides to work out at AtCoder Gym.\n\nThe exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up.\nThese buttons are numbered 1 through N.\nWhen Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i.\nWhen Button i is not lighten up, nothing will happen by pressing it.\n\nInitially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up.\n\nDetermine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1\na_2\n:\na_N\n\nOutput\n\nPrint -1 if it is impossible to lighten up Button 2.\nOtherwise, print the minimum number of times we need to press buttons in order to lighten up Button 2.\n\nSample Input 1\n\n3\n3\n1\n2\n\nSample Output 1\n\n2\n\nPress Button 1, then Button 3.\n\nSample Input 2\n\n4\n3\n4\n1\n2\n\nSample Output 2\n\n-1\n\nPressing Button 1 lightens up Button 3, and vice versa, so Button 2 will never be lighten up.\n\nSample Input 3\n\n5\n3\n3\n4\n2\n4\n\nSample Output 3\n\n3", "sample_input": "3\n3\n1\n2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03680", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi wants to gain muscle, and decides to work out at AtCoder Gym.\n\nThe exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up.\nThese buttons are numbered 1 through N.\nWhen Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i.\nWhen Button i is not lighten up, nothing will happen by pressing it.\n\nInitially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up.\n\nDetermine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1\na_2\n:\na_N\n\nOutput\n\nPrint -1 if it is impossible to lighten up Button 2.\nOtherwise, print the minimum number of times we need to press buttons in order to lighten up Button 2.\n\nSample Input 1\n\n3\n3\n1\n2\n\nSample Output 1\n\n2\n\nPress Button 1, then Button 3.\n\nSample Input 2\n\n4\n3\n4\n1\n2\n\nSample Output 2\n\n-1\n\nPressing Button 1 lightens up Button 3, and vice versa, so Button 2 will never be lighten up.\n\nSample Input 3\n\n5\n3\n3\n4\n2\n4\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 476, "cpu_time_ms": 1046, "memory_kb": 89964}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s673093197", "group_id": "codeNet:p03680", "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 al = Vector.fill(n)(sc.nextInt)\n\n val m = ((1 to n).toVector zip al).toMap\n\n def loop(list: Vector[Int],num: Int):Vector[Int] ={\n val next = m(num)\n next match{\n case 1 => list\n case 2 => list :+ 2\n case _ => loop(list :+ num, next)\n }\n }\n\n val temp = loop(Vector.empty[Int], 1)\n val res = if(temp.contains(2)) temp.length else -1\n\n println(res)\n}\n", "language": "Scala", "metadata": {"date": 1557155063, "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/s673093197.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s673093197", "user_id": "u829407811"}, "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\n val n = sc.nextInt\n val al = Vector.fill(n)(sc.nextInt)\n\n val m = ((1 to n).toVector zip al).toMap\n\n def loop(list: Vector[Int],num: Int):Vector[Int] ={\n val next = m(num)\n next match{\n case 1 => list\n case 2 => list :+ 2\n case _ => loop(list :+ num, next)\n }\n }\n\n val temp = loop(Vector.empty[Int], 1)\n val res = if(temp.contains(2)) temp.length else -1\n\n println(res)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi wants to gain muscle, and decides to work out at AtCoder Gym.\n\nThe exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up.\nThese buttons are numbered 1 through N.\nWhen Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i.\nWhen Button i is not lighten up, nothing will happen by pressing it.\n\nInitially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up.\n\nDetermine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1\na_2\n:\na_N\n\nOutput\n\nPrint -1 if it is impossible to lighten up Button 2.\nOtherwise, print the minimum number of times we need to press buttons in order to lighten up Button 2.\n\nSample Input 1\n\n3\n3\n1\n2\n\nSample Output 1\n\n2\n\nPress Button 1, then Button 3.\n\nSample Input 2\n\n4\n3\n4\n1\n2\n\nSample Output 2\n\n-1\n\nPressing Button 1 lightens up Button 3, and vice versa, so Button 2 will never be lighten up.\n\nSample Input 3\n\n5\n3\n3\n4\n2\n4\n\nSample Output 3\n\n3", "sample_input": "3\n3\n1\n2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03680", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi wants to gain muscle, and decides to work out at AtCoder Gym.\n\nThe exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up.\nThese buttons are numbered 1 through N.\nWhen Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i.\nWhen Button i is not lighten up, nothing will happen by pressing it.\n\nInitially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up.\n\nDetermine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1\na_2\n:\na_N\n\nOutput\n\nPrint -1 if it is impossible to lighten up Button 2.\nOtherwise, print the minimum number of times we need to press buttons in order to lighten up Button 2.\n\nSample Input 1\n\n3\n3\n1\n2\n\nSample Output 1\n\n2\n\nPress Button 1, then Button 3.\n\nSample Input 2\n\n4\n3\n4\n1\n2\n\nSample Output 2\n\n-1\n\nPressing Button 1 lightens up Button 3, and vice versa, so Button 2 will never be lighten up.\n\nSample Input 3\n\n5\n3\n3\n4\n2\n4\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 492, "cpu_time_ms": 2103, "memory_kb": 167792}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s310384411", "group_id": "codeNet:p03680", "input_text": "import io.StdIn.readInt\nimport annotation.tailrec\nimport collection.mutable.ListBuffer\nimport collection.Searching._\n\nobject Main extends App {\n val n = readInt\n val as = Seq.fill(n)(readInt)\n val vs = ListBuffer.empty[Int]\n\n println(solve(0, 0, as, vs))\n\n @tailrec def solve(pos: Int, res: Int, as: Seq[Int], vs: ListBuffer[Int]): Int = {\n if (pos == 1) res\n else vs.search(pos) match {\n case Found(_) => -1\n case InsertionPoint(i) => {\n vs.insert(i, pos)\n solve(as(pos) - 1, res + 1, as, vs)\n }\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1498358289, "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/s310384411.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s310384411", "user_id": "u158295568"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import io.StdIn.readInt\nimport annotation.tailrec\nimport collection.mutable.ListBuffer\nimport collection.Searching._\n\nobject Main extends App {\n val n = readInt\n val as = Seq.fill(n)(readInt)\n val vs = ListBuffer.empty[Int]\n\n println(solve(0, 0, as, vs))\n\n @tailrec def solve(pos: Int, res: Int, as: Seq[Int], vs: ListBuffer[Int]): Int = {\n if (pos == 1) res\n else vs.search(pos) match {\n case Found(_) => -1\n case InsertionPoint(i) => {\n vs.insert(i, pos)\n solve(as(pos) - 1, res + 1, as, vs)\n }\n }\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi wants to gain muscle, and decides to work out at AtCoder Gym.\n\nThe exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up.\nThese buttons are numbered 1 through N.\nWhen Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i.\nWhen Button i is not lighten up, nothing will happen by pressing it.\n\nInitially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up.\n\nDetermine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1\na_2\n:\na_N\n\nOutput\n\nPrint -1 if it is impossible to lighten up Button 2.\nOtherwise, print the minimum number of times we need to press buttons in order to lighten up Button 2.\n\nSample Input 1\n\n3\n3\n1\n2\n\nSample Output 1\n\n2\n\nPress Button 1, then Button 3.\n\nSample Input 2\n\n4\n3\n4\n1\n2\n\nSample Output 2\n\n-1\n\nPressing Button 1 lightens up Button 3, and vice versa, so Button 2 will never be lighten up.\n\nSample Input 3\n\n5\n3\n3\n4\n2\n4\n\nSample Output 3\n\n3", "sample_input": "3\n3\n1\n2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03680", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi wants to gain muscle, and decides to work out at AtCoder Gym.\n\nThe exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up.\nThese buttons are numbered 1 through N.\nWhen Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i.\nWhen Button i is not lighten up, nothing will happen by pressing it.\n\nInitially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up.\n\nDetermine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1\na_2\n:\na_N\n\nOutput\n\nPrint -1 if it is impossible to lighten up Button 2.\nOtherwise, print the minimum number of times we need to press buttons in order to lighten up Button 2.\n\nSample Input 1\n\n3\n3\n1\n2\n\nSample Output 1\n\n2\n\nPress Button 1, then Button 3.\n\nSample Input 2\n\n4\n3\n4\n1\n2\n\nSample Output 2\n\n-1\n\nPressing Button 1 lightens up Button 3, and vice versa, so Button 2 will never be lighten up.\n\nSample Input 3\n\n5\n3\n3\n4\n2\n4\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 549, "cpu_time_ms": 2111, "memory_kb": 40192}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s618134095", "group_id": "codeNet:p03681", "input_text": "import scala.io.StdIn._\n\nobject Main {\n def main(args: Array[String]): Unit = {\n solve\n }\n\n def solve(): Unit = {\n val input = readLine().split(\" \")\n val n = input(0).toInt\n val m = input(1).toInt\n val mod = 1000000007\n\n if (math.abs(n - m) > 1) {\n println(0)\n } else {\n if (math.abs(n - m) == 0) {\n println(modfactrial(n, mod) * modfactrial(m, mod) % mod * 2 % mod)\n } else {\n println(modfactrial(n, mod) * modfactrial(m, mod) % mod)\n }\n }\n }\n\n def modfactrial(n: Int, mod: Long): Long = {\n var result = 1L\n for (i <- 1 to n) {\n result = (result * i.toLong) % mod\n }\n\n return result;\n }\n}\n", "language": "Scala", "metadata": {"date": 1583682620, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03681.html", "problem_id": "p03681", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03681/input.txt", "sample_output_relpath": "derived/input_output/data/p03681/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03681/Scala/s618134095.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s618134095", "user_id": "u433254839"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "import scala.io.StdIn._\n\nobject Main {\n def main(args: Array[String]): Unit = {\n solve\n }\n\n def solve(): Unit = {\n val input = readLine().split(\" \")\n val n = input(0).toInt\n val m = input(1).toInt\n val mod = 1000000007\n\n if (math.abs(n - m) > 1) {\n println(0)\n } else {\n if (math.abs(n - m) == 0) {\n println(modfactrial(n, mod) * modfactrial(m, mod) % mod * 2 % mod)\n } else {\n println(modfactrial(n, mod) * modfactrial(m, mod) % mod)\n }\n }\n }\n\n def modfactrial(n: Int, mod: Long): Long = {\n var result = 1L\n for (i <- 1 to n) {\n result = (result * i.toLong) % mod\n }\n\n return result;\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke has N dogs and M monkeys. He wants them to line up in a row.\n\nAs a Japanese saying goes, these dogs and monkeys are on bad terms. (\"ken'en no naka\", literally \"the relationship of dogs and monkeys\", means a relationship of mutual hatred.) Snuke is trying to reconsile them, by arranging the animals so that there are neither two adjacent dogs nor two adjacent monkeys.\n\nHow many such arrangements there are? Find the count modulo 10^9+7 (since animals cannot understand numbers larger than that).\nHere, dogs and monkeys are both distinguishable. Also, two arrangements that result from reversing each other are distinguished.\n\nConstraints\n\n1 ≤ N,M ≤ 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of possible arrangements, modulo 10^9+7.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n8\n\nWe will denote the dogs by A and B, and the monkeys by C and D. There are eight possible arrangements: ACBD, ADBC, BCAD, BDAC, CADB, CBDA, DACB and DBCA.\n\nSample Input 2\n\n3 2\n\nSample Output 2\n\n12\n\nSample Input 3\n\n1 8\n\nSample Output 3\n\n0\n\nSample Input 4\n\n100000 100000\n\nSample Output 4\n\n530123477", "sample_input": "2 2\n"}, "reference_outputs": ["8\n"], "source_document_id": "p03681", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke has N dogs and M monkeys. He wants them to line up in a row.\n\nAs a Japanese saying goes, these dogs and monkeys are on bad terms. (\"ken'en no naka\", literally \"the relationship of dogs and monkeys\", means a relationship of mutual hatred.) Snuke is trying to reconsile them, by arranging the animals so that there are neither two adjacent dogs nor two adjacent monkeys.\n\nHow many such arrangements there are? Find the count modulo 10^9+7 (since animals cannot understand numbers larger than that).\nHere, dogs and monkeys are both distinguishable. Also, two arrangements that result from reversing each other are distinguished.\n\nConstraints\n\n1 ≤ N,M ≤ 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of possible arrangements, modulo 10^9+7.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n8\n\nWe will denote the dogs by A and B, and the monkeys by C and D. There are eight possible arrangements: ACBD, ADBC, BCAD, BDAC, CADB, CBDA, DACB and DBCA.\n\nSample Input 2\n\n3 2\n\nSample Output 2\n\n12\n\nSample Input 3\n\n1 8\n\nSample Output 3\n\n0\n\nSample Input 4\n\n100000 100000\n\nSample Output 4\n\n530123477", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 671, "cpu_time_ms": 342, "memory_kb": 27080}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s384619233", "group_id": "codeNet:p03688", "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) {\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 N = ni()\n val A = na(N)\n\n val mx = A.max\n val ms = A.min\n\n // 2以上ずれてるとおかしい\n val ok = mx - ms <= 1 && {\n if (mx == ms) {\n val g = mx\n // 全員違う色\n N - 1 == g || {\n // 全員他の人と同じ色\n N / 2 >= g\n }\n } else {\n val g = mx\n val cntSolo = A.count(_ == ms)\n val cntGrouped = N - cntSolo\n\n g > cntSolo && cntGrouped / 2 >= g - cntSolo\n }\n }\n\n if (ok) out.println(\"Yes\")\n else out.println(\"No\")\n }\n}", "language": "Scala", "metadata": {"date": 1561498645, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03688.html", "problem_id": "p03688", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03688/input.txt", "sample_output_relpath": "derived/input_output/data/p03688/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03688/Scala/s384619233.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s384619233", "user_id": "u460609472"}, "prompt_components": {"gold_output": "Yes\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) {\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 N = ni()\n val A = na(N)\n\n val mx = A.max\n val ms = A.min\n\n // 2以上ずれてるとおかしい\n val ok = mx - ms <= 1 && {\n if (mx == ms) {\n val g = mx\n // 全員違う色\n N - 1 == g || {\n // 全員他の人と同じ色\n N / 2 >= g\n }\n } else {\n val g = mx\n val cntSolo = A.count(_ == ms)\n val cntGrouped = N - cntSolo\n\n g > cntSolo && cntGrouped / 2 >= g - cntSolo\n }\n }\n\n if (ok) out.println(\"Yes\")\n else out.println(\"No\")\n }\n}", "problem_context": "Score : 700 points\n\nProblem Statement\n\nThere are N cats.\nWe number them from 1 through N.\n\nEach of the cats wears a hat.\nCat i says: \"there are exactly a_i different colors among the N - 1 hats worn by the cats except me.\"\n\nDetermine whether there exists a sequence of colors of the hats that is consistent with the remarks of the cats.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint Yes if there exists a sequence of colors of the hats that is consistent with the remarks of the cats; print No otherwise.\n\nSample Input 1\n\n3\n1 2 2\n\nSample Output 1\n\nYes\n\nFor example, if cat 1, 2 and 3 wears red, blue and blue hats, respectively, it is consistent with the remarks of the cats.\n\nSample Input 2\n\n3\n1 1 2\n\nSample Output 2\n\nNo\n\nFrom the remark of cat 1, we can see that cat 2 and 3 wear hats of the same color.\nAlso, from the remark of cat 2, we can see that cat 1 and 3 wear hats of the same color.\nTherefore, cat 1 and 2 wear hats of the same color, which contradicts the remark of cat 3.\n\nSample Input 3\n\n5\n4 3 4 3 4\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n3\n2 2 2\n\nSample Output 4\n\nYes\n\nSample Input 5\n\n4\n2 2 2 2\n\nSample Output 5\n\nYes\n\nSample Input 6\n\n5\n3 3 3 3 3\n\nSample Output 6\n\nNo", "sample_input": "3\n1 2 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03688", "source_text": "Score : 700 points\n\nProblem Statement\n\nThere are N cats.\nWe number them from 1 through N.\n\nEach of the cats wears a hat.\nCat i says: \"there are exactly a_i different colors among the N - 1 hats worn by the cats except me.\"\n\nDetermine whether there exists a sequence of colors of the hats that is consistent with the remarks of the cats.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint Yes if there exists a sequence of colors of the hats that is consistent with the remarks of the cats; print No otherwise.\n\nSample Input 1\n\n3\n1 2 2\n\nSample Output 1\n\nYes\n\nFor example, if cat 1, 2 and 3 wears red, blue and blue hats, respectively, it is consistent with the remarks of the cats.\n\nSample Input 2\n\n3\n1 1 2\n\nSample Output 2\n\nNo\n\nFrom the remark of cat 1, we can see that cat 2 and 3 wear hats of the same color.\nAlso, from the remark of cat 2, we can see that cat 1 and 3 wear hats of the same color.\nTherefore, cat 1 and 2 wear hats of the same color, which contradicts the remark of cat 3.\n\nSample Input 3\n\n5\n4 3 4 3 4\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n3\n2 2 2\n\nSample Output 4\n\nYes\n\nSample Input 5\n\n4\n2 2 2 2\n\nSample Output 5\n\nYes\n\nSample Input 6\n\n5\n3 3 3 3 3\n\nSample Output 6\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4160, "cpu_time_ms": 564, "memory_kb": 40476}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s060525963", "group_id": "codeNet:p03693", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n// val l = List.fill(3)(sc.nextInt)\n val r, g, b = sc.next\n\n val ans = if ((r + g + b).toInt % 4 == 0) \"YES\" else \"NO\"\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1562522758, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03693.html", "problem_id": "p03693", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03693/input.txt", "sample_output_relpath": "derived/input_output/data/p03693/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03693/Scala/s060525963.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s060525963", "user_id": "u040380439"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n// val l = List.fill(3)(sc.nextInt)\n val r, g, b = sc.next\n\n val ans = if ((r + g + b).toInt % 4 == 0) \"YES\" else \"NO\"\n println(ans)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAtCoDeer has three cards, one red, one green and one blue.\n\nAn integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.\n\nWe will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.\n\nIs this integer a multiple of 4?\n\nConstraints\n\n1 ≤ r, g, b ≤ 9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr g b\n\nOutput\n\nIf the three-digit integer is a multiple of 4, print YES (case-sensitive); otherwise, print NO.\n\nSample Input 1\n\n4 3 2\n\nSample Output 1\n\nYES\n\n432 is a multiple of 4, and thus YES should be printed.\n\nSample Input 2\n\n2 3 4\n\nSample Output 2\n\nNO\n\n234 is not a multiple of 4, and thus NO should be printed.", "sample_input": "4 3 2\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03693", "source_text": "Score : 100 points\n\nProblem Statement\n\nAtCoDeer has three cards, one red, one green and one blue.\n\nAn integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.\n\nWe will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.\n\nIs this integer a multiple of 4?\n\nConstraints\n\n1 ≤ r, g, b ≤ 9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr g b\n\nOutput\n\nIf the three-digit integer is a multiple of 4, print YES (case-sensitive); otherwise, print NO.\n\nSample Input 1\n\n4 3 2\n\nSample Output 1\n\nYES\n\n432 is a multiple of 4, and thus YES should be printed.\n\nSample Input 2\n\n2 3 4\n\nSample Output 2\n\nNO\n\n234 is not a multiple of 4, and thus NO should be printed.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 364, "memory_kb": 27164}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s988405618", "group_id": "codeNet:p03693", "input_text": "object Main extends App {\n val x = scala.io.StdIn.readLine().split(\" \").mkString(\"\").toInt\n val ret = if (x%4==0) \"YES\" else \"NO\"\n println(ret)\n}\n", "language": "Scala", "metadata": {"date": 1497142980, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03693.html", "problem_id": "p03693", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03693/input.txt", "sample_output_relpath": "derived/input_output/data/p03693/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03693/Scala/s988405618.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s988405618", "user_id": "u893154287"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "object Main extends App {\n val x = scala.io.StdIn.readLine().split(\" \").mkString(\"\").toInt\n val ret = if (x%4==0) \"YES\" else \"NO\"\n println(ret)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAtCoDeer has three cards, one red, one green and one blue.\n\nAn integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.\n\nWe will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.\n\nIs this integer a multiple of 4?\n\nConstraints\n\n1 ≤ r, g, b ≤ 9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr g b\n\nOutput\n\nIf the three-digit integer is a multiple of 4, print YES (case-sensitive); otherwise, print NO.\n\nSample Input 1\n\n4 3 2\n\nSample Output 1\n\nYES\n\n432 is a multiple of 4, and thus YES should be printed.\n\nSample Input 2\n\n2 3 4\n\nSample Output 2\n\nNO\n\n234 is not a multiple of 4, and thus NO should be printed.", "sample_input": "4 3 2\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03693", "source_text": "Score : 100 points\n\nProblem Statement\n\nAtCoDeer has three cards, one red, one green and one blue.\n\nAn integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.\n\nWe will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.\n\nIs this integer a multiple of 4?\n\nConstraints\n\n1 ≤ r, g, b ≤ 9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr g b\n\nOutput\n\nIf the three-digit integer is a multiple of 4, print YES (case-sensitive); otherwise, print NO.\n\nSample Input 1\n\n4 3 2\n\nSample Output 1\n\nYES\n\n432 is a multiple of 4, and thus YES should be printed.\n\nSample Input 2\n\n2 3 4\n\nSample Output 2\n\nNO\n\n234 is not a multiple of 4, and thus NO should be printed.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 416, "memory_kb": 27040}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s037402210", "group_id": "codeNet:p03695", "input_text": "object Main {\n\n def main(args: Array[String]): Unit = {\n import scala.io.StdIn._\n var over3200 = 0\n\n val GRAY = 0\n val BROWN = 1\n val GREEN = 2\n val WATER = 3\n val BLUE = 4\n val YELLOW = 5\n val ORANGE = 6\n val RED = 7\n val OVERED = 8\n val visited = new Array[Boolean](8)\n\n def rateToColor(rate: Int): Int =\n if (rate <= 399) GRAY\n else if (rate <= 799) BROWN\n else if (rate <= 1199) GREEN\n else if (rate <= 1599) WATER\n else if (rate <= 1999) BLUE\n else if (rate <= 2399) YELLOW\n else if (rate <= 2799) ORANGE\n else if (rate <= 3199) RED\n else OVERED\n\n val N = readLine().toInt\n val a = readLine().split(\" \").map(_.toInt)\n (0 until N).foreach { i =>\n val color = rateToColor(a(i))\n if (color == OVERED)\n over3200 += 1\n else {\n visited(color) = true\n }\n }\n\n var colors = (0 until 8) count visited\n val max = colors + Math.min(8 - colors, over3200)\n val min = if (colors == 0) 1 else colors\n println(s\"$min $max\")\n }\n\n}", "language": "Scala", "metadata": {"date": 1558215561, "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/s037402210.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s037402210", "user_id": "u891387249"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "object Main {\n\n def main(args: Array[String]): Unit = {\n import scala.io.StdIn._\n var over3200 = 0\n\n val GRAY = 0\n val BROWN = 1\n val GREEN = 2\n val WATER = 3\n val BLUE = 4\n val YELLOW = 5\n val ORANGE = 6\n val RED = 7\n val OVERED = 8\n val visited = new Array[Boolean](8)\n\n def rateToColor(rate: Int): Int =\n if (rate <= 399) GRAY\n else if (rate <= 799) BROWN\n else if (rate <= 1199) GREEN\n else if (rate <= 1599) WATER\n else if (rate <= 1999) BLUE\n else if (rate <= 2399) YELLOW\n else if (rate <= 2799) ORANGE\n else if (rate <= 3199) RED\n else OVERED\n\n val N = readLine().toInt\n val a = readLine().split(\" \").map(_.toInt)\n (0 until N).foreach { i =>\n val color = rateToColor(a(i))\n if (color == OVERED)\n over3200 += 1\n else {\n visited(color) = true\n }\n }\n\n var colors = (0 until 8) count visited\n val max = colors + Math.min(8 - colors, over3200)\n val min = if (colors == 0) 1 else colors\n println(s\"$min $max\")\n }\n\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn AtCoder, a person who has participated in a contest receives a color, which corresponds to the person's rating as follows:\n\nRating 1-399 : gray\n\nRating 400-799 : brown\n\nRating 800-1199 : green\n\nRating 1200-1599 : cyan\n\nRating 1600-1999 : blue\n\nRating 2000-2399 : yellow\n\nRating 2400-2799 : orange\n\nRating 2800-3199 : red\n\nOther than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not.\n\nCurrently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i.\n\nFind the minimum and maximum possible numbers of different colors of the users.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ a_i ≤ 4800\n\na_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum possible number of different colors of the users, and the maximum possible number of different colors, with a space in between.\n\nSample Input 1\n\n4\n2100 2500 2700 2700\n\nSample Output 1\n\n2 2\n\nThe user with rating 2100 is \"yellow\", and the others are \"orange\". There are two different colors.\n\nSample Input 2\n\n5\n1100 1900 2800 3200 3200\n\nSample Output 2\n\n3 5\n\nThe user with rating 1100 is \"green\", the user with rating 1900 is blue and the user with rating 2800 is \"red\".\n\nIf the fourth user picks \"red\", and the fifth user picks \"blue\", there are three different colors. This is one possible scenario for the minimum number of colors.\n\nIf the fourth user picks \"purple\", and the fifth user picks \"black\", there are five different colors. This is one possible scenario for the maximum number of colors.\n\nSample Input 3\n\n20\n800 810 820 830 840 850 860 870 880 890 900 910 920 930 940 950 960 970 980 990\n\nSample Output 3\n\n1 1\n\nAll the users are \"green\", and thus there is one color.", "sample_input": "4\n2100 2500 2700 2700\n"}, "reference_outputs": ["2 2\n"], "source_document_id": "p03695", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn AtCoder, a person who has participated in a contest receives a color, which corresponds to the person's rating as follows:\n\nRating 1-399 : gray\n\nRating 400-799 : brown\n\nRating 800-1199 : green\n\nRating 1200-1599 : cyan\n\nRating 1600-1999 : blue\n\nRating 2000-2399 : yellow\n\nRating 2400-2799 : orange\n\nRating 2800-3199 : red\n\nOther than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not.\n\nCurrently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i.\n\nFind the minimum and maximum possible numbers of different colors of the users.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ a_i ≤ 4800\n\na_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum possible number of different colors of the users, and the maximum possible number of different colors, with a space in between.\n\nSample Input 1\n\n4\n2100 2500 2700 2700\n\nSample Output 1\n\n2 2\n\nThe user with rating 2100 is \"yellow\", and the others are \"orange\". There are two different colors.\n\nSample Input 2\n\n5\n1100 1900 2800 3200 3200\n\nSample Output 2\n\n3 5\n\nThe user with rating 1100 is \"green\", the user with rating 1900 is blue and the user with rating 2800 is \"red\".\n\nIf the fourth user picks \"red\", and the fifth user picks \"blue\", there are three different colors. This is one possible scenario for the minimum number of colors.\n\nIf the fourth user picks \"purple\", and the fifth user picks \"black\", there are five different colors. This is one possible scenario for the maximum number of colors.\n\nSample Input 3\n\n20\n800 810 820 830 840 850 860 870 880 890 900 910 920 930 940 950 960 970 980 990\n\nSample Output 3\n\n1 1\n\nAll the users are \"green\", and thus there is one color.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1061, "cpu_time_ms": 320, "memory_kb": 25424}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s615097385", "group_id": "codeNet:p03695", "input_text": "\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt()\n val an = List.fill(n)(sc.nextInt())\n\n val colors = Array.fill(9)(0)\n val indexes = an.map( a => getIndex(a))\n indexes.foreach( index =>\n colors(index) = colors(index) + 1\n )\n\n val coders = colors.splitAt(8)\n val topCoders: Int = coders._2(0)\n val lowCoders = coders._1.filter(_ > 0).length\n\n printf(\"%d %d\\n\",\n lowCoders,\n if(lowCoders + topCoders <= 8) lowCoders + topCoders\n else 8\n )\n }\n\n /*\n レート 1-399:灰色\n レート 400-799:茶色\n レート 800-1199:緑色\n レート 1200-1599:水色\n レート 1600-1999:青色\n レート 2000-2399:黄色\n レート 2400-2799:橙色\n レート 2800-3199:赤色\n */\n def getIndex(rate: Int): Int = {\n val i = if (rate < 400) 0\n else if (rate < 800) 1\n else if (rate < 1200) 2\n else if (rate < 1600) 3\n else if (rate < 2000) 4\n else if (rate < 2400) 5\n else if (rate < 2800) 6\n else if (rate < 3200) 7\n else 8\n\n return i;\n }\n}", "language": "Scala", "metadata": {"date": 1512861003, "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/s615097385.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s615097385", "user_id": "u592088571"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new java.util.Scanner(System.in)\n val n = sc.nextInt()\n val an = List.fill(n)(sc.nextInt())\n\n val colors = Array.fill(9)(0)\n val indexes = an.map( a => getIndex(a))\n indexes.foreach( index =>\n colors(index) = colors(index) + 1\n )\n\n val coders = colors.splitAt(8)\n val topCoders: Int = coders._2(0)\n val lowCoders = coders._1.filter(_ > 0).length\n\n printf(\"%d %d\\n\",\n lowCoders,\n if(lowCoders + topCoders <= 8) lowCoders + topCoders\n else 8\n )\n }\n\n /*\n レート 1-399:灰色\n レート 400-799:茶色\n レート 800-1199:緑色\n レート 1200-1599:水色\n レート 1600-1999:青色\n レート 2000-2399:黄色\n レート 2400-2799:橙色\n レート 2800-3199:赤色\n */\n def getIndex(rate: Int): Int = {\n val i = if (rate < 400) 0\n else if (rate < 800) 1\n else if (rate < 1200) 2\n else if (rate < 1600) 3\n else if (rate < 2000) 4\n else if (rate < 2400) 5\n else if (rate < 2800) 6\n else if (rate < 3200) 7\n else 8\n\n return i;\n }\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn AtCoder, a person who has participated in a contest receives a color, which corresponds to the person's rating as follows:\n\nRating 1-399 : gray\n\nRating 400-799 : brown\n\nRating 800-1199 : green\n\nRating 1200-1599 : cyan\n\nRating 1600-1999 : blue\n\nRating 2000-2399 : yellow\n\nRating 2400-2799 : orange\n\nRating 2800-3199 : red\n\nOther than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not.\n\nCurrently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i.\n\nFind the minimum and maximum possible numbers of different colors of the users.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ a_i ≤ 4800\n\na_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum possible number of different colors of the users, and the maximum possible number of different colors, with a space in between.\n\nSample Input 1\n\n4\n2100 2500 2700 2700\n\nSample Output 1\n\n2 2\n\nThe user with rating 2100 is \"yellow\", and the others are \"orange\". There are two different colors.\n\nSample Input 2\n\n5\n1100 1900 2800 3200 3200\n\nSample Output 2\n\n3 5\n\nThe user with rating 1100 is \"green\", the user with rating 1900 is blue and the user with rating 2800 is \"red\".\n\nIf the fourth user picks \"red\", and the fifth user picks \"blue\", there are three different colors. This is one possible scenario for the minimum number of colors.\n\nIf the fourth user picks \"purple\", and the fifth user picks \"black\", there are five different colors. This is one possible scenario for the maximum number of colors.\n\nSample Input 3\n\n20\n800 810 820 830 840 850 860 870 880 890 900 910 920 930 940 950 960 970 980 990\n\nSample Output 3\n\n1 1\n\nAll the users are \"green\", and thus there is one color.", "sample_input": "4\n2100 2500 2700 2700\n"}, "reference_outputs": ["2 2\n"], "source_document_id": "p03695", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn AtCoder, a person who has participated in a contest receives a color, which corresponds to the person's rating as follows:\n\nRating 1-399 : gray\n\nRating 400-799 : brown\n\nRating 800-1199 : green\n\nRating 1200-1599 : cyan\n\nRating 1600-1999 : blue\n\nRating 2000-2399 : yellow\n\nRating 2400-2799 : orange\n\nRating 2800-3199 : red\n\nOther than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not.\n\nCurrently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i.\n\nFind the minimum and maximum possible numbers of different colors of the users.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ a_i ≤ 4800\n\na_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum possible number of different colors of the users, and the maximum possible number of different colors, with a space in between.\n\nSample Input 1\n\n4\n2100 2500 2700 2700\n\nSample Output 1\n\n2 2\n\nThe user with rating 2100 is \"yellow\", and the others are \"orange\". There are two different colors.\n\nSample Input 2\n\n5\n1100 1900 2800 3200 3200\n\nSample Output 2\n\n3 5\n\nThe user with rating 1100 is \"green\", the user with rating 1900 is blue and the user with rating 2800 is \"red\".\n\nIf the fourth user picks \"red\", and the fifth user picks \"blue\", there are three different colors. This is one possible scenario for the minimum number of colors.\n\nIf the fourth user picks \"purple\", and the fifth user picks \"black\", there are five different colors. This is one possible scenario for the maximum number of colors.\n\nSample Input 3\n\n20\n800 810 820 830 840 850 860 870 880 890 900 910 920 930 940 950 960 970 980 990\n\nSample Output 3\n\n1 1\n\nAll the users are \"green\", and thus there is one color.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1114, "cpu_time_ms": 346, "memory_kb": 27332}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s865462693", "group_id": "codeNet:p03695", "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 t = Range(0, n).map(_ => sc.nextInt())\n .sortBy(x => x)\n .map(i => math.min(i/400, 8))\n .groupBy(x => x)\n .toStream\n .sortBy(t => t._1)\n .foldLeft((0, 0)) {\n case ((minV, maxV), (id, seq)) => id match {\n case 8 => (math.max(minV, 1), maxV + seq.size)\n case _ => (minV + 1, maxV + 1)\n }\n }\n\n println(s\"${t._1} ${t._2}\")\n}\n", "language": "Scala", "metadata": {"date": 1499127741, "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/s865462693.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s865462693", "user_id": "u726872801"}, "prompt_components": {"gold_output": "2 2\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 t = Range(0, n).map(_ => sc.nextInt())\n .sortBy(x => x)\n .map(i => math.min(i/400, 8))\n .groupBy(x => x)\n .toStream\n .sortBy(t => t._1)\n .foldLeft((0, 0)) {\n case ((minV, maxV), (id, seq)) => id match {\n case 8 => (math.max(minV, 1), maxV + seq.size)\n case _ => (minV + 1, maxV + 1)\n }\n }\n\n println(s\"${t._1} ${t._2}\")\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn AtCoder, a person who has participated in a contest receives a color, which corresponds to the person's rating as follows:\n\nRating 1-399 : gray\n\nRating 400-799 : brown\n\nRating 800-1199 : green\n\nRating 1200-1599 : cyan\n\nRating 1600-1999 : blue\n\nRating 2000-2399 : yellow\n\nRating 2400-2799 : orange\n\nRating 2800-3199 : red\n\nOther than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not.\n\nCurrently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i.\n\nFind the minimum and maximum possible numbers of different colors of the users.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ a_i ≤ 4800\n\na_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum possible number of different colors of the users, and the maximum possible number of different colors, with a space in between.\n\nSample Input 1\n\n4\n2100 2500 2700 2700\n\nSample Output 1\n\n2 2\n\nThe user with rating 2100 is \"yellow\", and the others are \"orange\". There are two different colors.\n\nSample Input 2\n\n5\n1100 1900 2800 3200 3200\n\nSample Output 2\n\n3 5\n\nThe user with rating 1100 is \"green\", the user with rating 1900 is blue and the user with rating 2800 is \"red\".\n\nIf the fourth user picks \"red\", and the fifth user picks \"blue\", there are three different colors. This is one possible scenario for the minimum number of colors.\n\nIf the fourth user picks \"purple\", and the fifth user picks \"black\", there are five different colors. This is one possible scenario for the maximum number of colors.\n\nSample Input 3\n\n20\n800 810 820 830 840 850 860 870 880 890 900 910 920 930 940 950 960 970 980 990\n\nSample Output 3\n\n1 1\n\nAll the users are \"green\", and thus there is one color.", "sample_input": "4\n2100 2500 2700 2700\n"}, "reference_outputs": ["2 2\n"], "source_document_id": "p03695", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn AtCoder, a person who has participated in a contest receives a color, which corresponds to the person's rating as follows:\n\nRating 1-399 : gray\n\nRating 400-799 : brown\n\nRating 800-1199 : green\n\nRating 1200-1599 : cyan\n\nRating 1600-1999 : blue\n\nRating 2000-2399 : yellow\n\nRating 2400-2799 : orange\n\nRating 2800-3199 : red\n\nOther than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not.\n\nCurrently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i.\n\nFind the minimum and maximum possible numbers of different colors of the users.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ a_i ≤ 4800\n\na_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum possible number of different colors of the users, and the maximum possible number of different colors, with a space in between.\n\nSample Input 1\n\n4\n2100 2500 2700 2700\n\nSample Output 1\n\n2 2\n\nThe user with rating 2100 is \"yellow\", and the others are \"orange\". There are two different colors.\n\nSample Input 2\n\n5\n1100 1900 2800 3200 3200\n\nSample Output 2\n\n3 5\n\nThe user with rating 1100 is \"green\", the user with rating 1900 is blue and the user with rating 2800 is \"red\".\n\nIf the fourth user picks \"red\", and the fifth user picks \"blue\", there are three different colors. This is one possible scenario for the minimum number of colors.\n\nIf the fourth user picks \"purple\", and the fifth user picks \"black\", there are five different colors. This is one possible scenario for the maximum number of colors.\n\nSample Input 3\n\n20\n800 810 820 830 840 850 860 870 880 890 900 910 920 930 940 950 960 970 980 990\n\nSample Output 3\n\n1 1\n\nAll the users are \"green\", and thus there is one color.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 484, "cpu_time_ms": 361, "memory_kb": 27072}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s275374855", "group_id": "codeNet:p03695", "input_text": "object Main extends App {\n scala.io.StdIn.readLine()\n val ary = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n val comp = Array(\n (x:Int) => 1 <= x && x <= 399,\n (x:Int) => 400 <= x && x <= 799,\n (x:Int) => 800 <= x && x <= 1199,\n (x:Int) => 1200 <= x && x <= 1599,\n (x:Int) => 1600 <= x && x <= 1999,\n (x:Int) => 2000 <= x && x <= 2399,\n (x:Int) => 2400 <= x && x <= 2799,\n (x:Int) => 2800 <= x && x <= 3199\n )\n def cnt(ary: Array[Int], f: Array[(Int) => Boolean]): Array[Int] = {\n for (func <- f) yield ary.count(func(_))\n }\n val ret = cnt(ary, comp).count(_>0)\n val min = if (ret==0) 1 else ret\n val max = math.min(ret+ary.count(_>=3200),8)\n println(min+\" \"+max)\n}\n", "language": "Scala", "metadata": {"date": 1497144707, "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/s275374855.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s275374855", "user_id": "u893154287"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "object Main extends App {\n scala.io.StdIn.readLine()\n val ary = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n val comp = Array(\n (x:Int) => 1 <= x && x <= 399,\n (x:Int) => 400 <= x && x <= 799,\n (x:Int) => 800 <= x && x <= 1199,\n (x:Int) => 1200 <= x && x <= 1599,\n (x:Int) => 1600 <= x && x <= 1999,\n (x:Int) => 2000 <= x && x <= 2399,\n (x:Int) => 2400 <= x && x <= 2799,\n (x:Int) => 2800 <= x && x <= 3199\n )\n def cnt(ary: Array[Int], f: Array[(Int) => Boolean]): Array[Int] = {\n for (func <- f) yield ary.count(func(_))\n }\n val ret = cnt(ary, comp).count(_>0)\n val min = if (ret==0) 1 else ret\n val max = math.min(ret+ary.count(_>=3200),8)\n println(min+\" \"+max)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn AtCoder, a person who has participated in a contest receives a color, which corresponds to the person's rating as follows:\n\nRating 1-399 : gray\n\nRating 400-799 : brown\n\nRating 800-1199 : green\n\nRating 1200-1599 : cyan\n\nRating 1600-1999 : blue\n\nRating 2000-2399 : yellow\n\nRating 2400-2799 : orange\n\nRating 2800-3199 : red\n\nOther than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not.\n\nCurrently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i.\n\nFind the minimum and maximum possible numbers of different colors of the users.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ a_i ≤ 4800\n\na_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum possible number of different colors of the users, and the maximum possible number of different colors, with a space in between.\n\nSample Input 1\n\n4\n2100 2500 2700 2700\n\nSample Output 1\n\n2 2\n\nThe user with rating 2100 is \"yellow\", and the others are \"orange\". There are two different colors.\n\nSample Input 2\n\n5\n1100 1900 2800 3200 3200\n\nSample Output 2\n\n3 5\n\nThe user with rating 1100 is \"green\", the user with rating 1900 is blue and the user with rating 2800 is \"red\".\n\nIf the fourth user picks \"red\", and the fifth user picks \"blue\", there are three different colors. This is one possible scenario for the minimum number of colors.\n\nIf the fourth user picks \"purple\", and the fifth user picks \"black\", there are five different colors. This is one possible scenario for the maximum number of colors.\n\nSample Input 3\n\n20\n800 810 820 830 840 850 860 870 880 890 900 910 920 930 940 950 960 970 980 990\n\nSample Output 3\n\n1 1\n\nAll the users are \"green\", and thus there is one color.", "sample_input": "4\n2100 2500 2700 2700\n"}, "reference_outputs": ["2 2\n"], "source_document_id": "p03695", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn AtCoder, a person who has participated in a contest receives a color, which corresponds to the person's rating as follows:\n\nRating 1-399 : gray\n\nRating 400-799 : brown\n\nRating 800-1199 : green\n\nRating 1200-1599 : cyan\n\nRating 1600-1999 : blue\n\nRating 2000-2399 : yellow\n\nRating 2400-2799 : orange\n\nRating 2800-3199 : red\n\nOther than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not.\n\nCurrently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i.\n\nFind the minimum and maximum possible numbers of different colors of the users.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ a_i ≤ 4800\n\na_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum possible number of different colors of the users, and the maximum possible number of different colors, with a space in between.\n\nSample Input 1\n\n4\n2100 2500 2700 2700\n\nSample Output 1\n\n2 2\n\nThe user with rating 2100 is \"yellow\", and the others are \"orange\". There are two different colors.\n\nSample Input 2\n\n5\n1100 1900 2800 3200 3200\n\nSample Output 2\n\n3 5\n\nThe user with rating 1100 is \"green\", the user with rating 1900 is blue and the user with rating 2800 is \"red\".\n\nIf the fourth user picks \"red\", and the fifth user picks \"blue\", there are three different colors. This is one possible scenario for the minimum number of colors.\n\nIf the fourth user picks \"purple\", and the fifth user picks \"black\", there are five different colors. This is one possible scenario for the maximum number of colors.\n\nSample Input 3\n\n20\n800 810 820 830 840 850 860 870 880 890 900 910 920 930 940 950 960 970 980 990\n\nSample Output 3\n\n1 1\n\nAll the users are \"green\", and thus there is one color.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 769, "cpu_time_ms": 342, "memory_kb": 25416}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s791642546", "group_id": "codeNet:p03697", "input_text": "object Main extends App {\n val res = io.StdIn.readLine.split(\" \").map(_.toInt).sum\n val ans = if(res < 10) res.toString else \"error\"\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1546963792, "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/s791642546.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s791642546", "user_id": "u217010036"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "object Main extends App {\n val res = io.StdIn.readLine.split(\" \").map(_.toInt).sum\n val ans = if(res < 10) res.toString else \"error\"\n println(ans)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 151, "cpu_time_ms": 343, "memory_kb": 25540}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s999591337", "group_id": "codeNet:p03697", "input_text": "import scala.io.Source\n\nobject Main {\n\n def main(args: Array[String]) {\n val lines = Source.stdin.getLines.toSeq\n val n = lines.head.split(\" \")(0).toLong\n val a = lines.head.split(\" \")(1).toLong\n val b = lines.head.split(\" \")(2).toLong\n val hs = lines.tail.map(_.toLong)\n var min_count = a * n\n\n def burn(xs: Seq[Long], count: Long) {\n if (min_count < count) {\n\n } else if (xs.isEmpty) {\n min_count = count\n } else {\n val ys = xs.zipWithIndex\n for ((x, i) <- ys) {\n burn(ys.map {\n case (x2, i2) if i == i2 => x2 - a\n case (x2, i2) => x2 - b\n }.filter(_ > 0), count + 1)\n }\n }\n }\n\n burn(hs, 0)\n println(min_count)\n }\n}\n", "language": "Scala", "metadata": {"date": 1497635817, "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/s999591337.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s999591337", "user_id": "u771641306"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import scala.io.Source\n\nobject Main {\n\n def main(args: Array[String]) {\n val lines = Source.stdin.getLines.toSeq\n val n = lines.head.split(\" \")(0).toLong\n val a = lines.head.split(\" \")(1).toLong\n val b = lines.head.split(\" \")(2).toLong\n val hs = lines.tail.map(_.toLong)\n var min_count = a * n\n\n def burn(xs: Seq[Long], count: Long) {\n if (min_count < count) {\n\n } else if (xs.isEmpty) {\n min_count = count\n } else {\n val ys = xs.zipWithIndex\n for ((x, i) <- ys) {\n burn(ys.map {\n case (x2, i2) if i == i2 => x2 - a\n case (x2, i2) => x2 - b\n }.filter(_ > 0), count + 1)\n }\n }\n }\n\n burn(hs, 0)\n println(min_count)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 738, "cpu_time_ms": 327, "memory_kb": 25512}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s876428371", "group_id": "codeNet:p03698", "input_text": "\nimport java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val str = sc.next()\n\n if (str.toStream.toSet.size == str.size) {\n println(\"yes\")\n } else {\n println(\"no\")\n }\n}\n", "language": "Scala", "metadata": {"date": 1499729897, "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/s876428371.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s876428371", "user_id": "u726872801"}, "prompt_components": {"gold_output": "yes\n", "input_to_evaluate": "\nimport java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val str = sc.next()\n\n if (str.toStream.toSet.size == str.size) {\n println(\"yes\")\n } else {\n println(\"no\")\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.\n\nConstraints\n\n2 ≤ |S| ≤ 26, where |S| denotes the length of S.\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf all the characters in S are different, print yes (case-sensitive); otherwise, print no.\n\nSample Input 1\n\nuncopyrightable\n\nSample Output 1\n\nyes\n\nSample Input 2\n\ndifferent\n\nSample Output 2\n\nno\n\nSample Input 3\n\nno\n\nSample Output 3\n\nyes", "sample_input": "uncopyrightable\n"}, "reference_outputs": ["yes\n"], "source_document_id": "p03698", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.\n\nConstraints\n\n2 ≤ |S| ≤ 26, where |S| denotes the length of S.\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf all the characters in S are different, print yes (case-sensitive); otherwise, print no.\n\nSample Input 1\n\nuncopyrightable\n\nSample Output 1\n\nyes\n\nSample Input 2\n\ndifferent\n\nSample Output 2\n\nno\n\nSample Input 3\n\nno\n\nSample Output 3\n\nyes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 210, "cpu_time_ms": 337, "memory_kb": 27336}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s130658248", "group_id": "codeNet:p03700", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val N = sc.nextInt(); val A = sc.nextInt(); val B = sc.nextInt()\n val h = new Array[Int](N)\n for(i <- 0 until N)\n h(i) = sc.nextInt()\n\n val enes = h.sorted\n\n def check(n: Int): Boolean = {\n val tmp = enes.foldRight(0)((x, y) =>\n if(x - B*N <= 0) 0 + y else ((x - B*N) / (A-B)) + ((x - B*N) % (A-B)) + y)\n tmp <= n\n }\n\n // 条件を満たす最小の値を返す\n def binarySearch(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 => binarySearch(min, mid)\n case false => binarySearch(mid, max)\n }\n }\n }\n\n val ans = binarySearch(1, 1e9.toInt)\n println(ans)\n}\n", "language": "Scala", "metadata": {"date": 1508195098, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03700.html", "problem_id": "p03700", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03700/input.txt", "sample_output_relpath": "derived/input_output/data/p03700/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03700/Scala/s130658248.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s130658248", "user_id": "u098968285"}, "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\n val N = sc.nextInt(); val A = sc.nextInt(); val B = sc.nextInt()\n val h = new Array[Int](N)\n for(i <- 0 until N)\n h(i) = sc.nextInt()\n\n val enes = h.sorted\n\n def check(n: Int): Boolean = {\n val tmp = enes.foldRight(0)((x, y) =>\n if(x - B*N <= 0) 0 + y else ((x - B*N) / (A-B)) + ((x - B*N) % (A-B)) + y)\n tmp <= n\n }\n\n // 条件を満たす最小の値を返す\n def binarySearch(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 => binarySearch(min, mid)\n case false => binarySearch(mid, max)\n }\n }\n }\n\n val ans = binarySearch(1, 1e9.toInt)\n println(ans)\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called health, and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below.\n\nFortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows:\n\nSelect an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds.\n\nAt least how many explosions do you need to cause in order to vanish all the monsters?\n\nConstraints\n\nAll input values are integers.\n\n1 ≤ N ≤ 10^5\n\n1 ≤ B < A ≤ 10^9\n\n1 ≤ h_i ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum number of explosions that needs to be caused in order to vanish all the monsters.\n\nSample Input 1\n\n4 5 3\n8\n7\n4\n2\n\nSample Output 1\n\n2\n\nYou can vanish all the monsters in two explosion, as follows:\n\nFirst, cause an explosion centered at the monster with 8 health. The healths of the four monsters become 3, 4, 1 and -1, respectively, and the last monster vanishes.\n\nSecond, cause an explosion centered at the monster with 4 health remaining. The healths of the three remaining monsters become 0, -1 and -2, respectively, and all the monsters are now vanished.\n\nSample Input 2\n\n2 10 4\n20\n20\n\nSample Output 2\n\n4\n\nYou need to cause two explosions centered at each monster, for a total of four.\n\nSample Input 3\n\n5 2 1\n900000000\n900000000\n1000000000\n1000000000\n1000000000\n\nSample Output 3\n\n800000000", "sample_input": "4 5 3\n8\n7\n4\n2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03700", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called health, and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below.\n\nFortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows:\n\nSelect an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds.\n\nAt least how many explosions do you need to cause in order to vanish all the monsters?\n\nConstraints\n\nAll input values are integers.\n\n1 ≤ N ≤ 10^5\n\n1 ≤ B < A ≤ 10^9\n\n1 ≤ h_i ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum number of explosions that needs to be caused in order to vanish all the monsters.\n\nSample Input 1\n\n4 5 3\n8\n7\n4\n2\n\nSample Output 1\n\n2\n\nYou can vanish all the monsters in two explosion, as follows:\n\nFirst, cause an explosion centered at the monster with 8 health. The healths of the four monsters become 3, 4, 1 and -1, respectively, and the last monster vanishes.\n\nSecond, cause an explosion centered at the monster with 4 health remaining. The healths of the three remaining monsters become 0, -1 and -2, respectively, and all the monsters are now vanished.\n\nSample Input 2\n\n2 10 4\n20\n20\n\nSample Output 2\n\n4\n\nYou need to cause two explosions centered at each monster, for a total of four.\n\nSample Input 3\n\n5 2 1\n900000000\n900000000\n1000000000\n1000000000\n1000000000\n\nSample Output 3\n\n800000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 904, "cpu_time_ms": 1003, "memory_kb": 74596}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s540369316", "group_id": "codeNet:p03700", "input_text": "\nimport java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val n, a, b = sc.nextInt()\n val ar = Range(0, n).map(_ => sc.nextLong()).sorted.toArray\n\n println(solve)\n\n def solve(): Long = {\n var l = 1L\n var r = 1000L * 1000L * 1000L\n while (l < r) {\n val c = (l + r) / 2\n if (ok(c)) r = c\n else l = c + 1\n }\n return l\n }\n\n def ok(cnt: Long): Boolean = {\n ar.foldLeft(0L) {\n case (sum, h) => {\n if (cnt * b > h) {\n sum\n } else {\n sum + ((h - cnt * b - 1) / (a - b)) + 1\n }\n }\n } <= cnt\n }\n}\n", "language": "Scala", "metadata": {"date": 1499736026, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03700.html", "problem_id": "p03700", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03700/input.txt", "sample_output_relpath": "derived/input_output/data/p03700/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03700/Scala/s540369316.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s540369316", "user_id": "u726872801"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "\nimport java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val n, a, b = sc.nextInt()\n val ar = Range(0, n).map(_ => sc.nextLong()).sorted.toArray\n\n println(solve)\n\n def solve(): Long = {\n var l = 1L\n var r = 1000L * 1000L * 1000L\n while (l < r) {\n val c = (l + r) / 2\n if (ok(c)) r = c\n else l = c + 1\n }\n return l\n }\n\n def ok(cnt: Long): Boolean = {\n ar.foldLeft(0L) {\n case (sum, h) => {\n if (cnt * b > h) {\n sum\n } else {\n sum + ((h - cnt * b - 1) / (a - b)) + 1\n }\n }\n } <= cnt\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called health, and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below.\n\nFortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows:\n\nSelect an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds.\n\nAt least how many explosions do you need to cause in order to vanish all the monsters?\n\nConstraints\n\nAll input values are integers.\n\n1 ≤ N ≤ 10^5\n\n1 ≤ B < A ≤ 10^9\n\n1 ≤ h_i ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum number of explosions that needs to be caused in order to vanish all the monsters.\n\nSample Input 1\n\n4 5 3\n8\n7\n4\n2\n\nSample Output 1\n\n2\n\nYou can vanish all the monsters in two explosion, as follows:\n\nFirst, cause an explosion centered at the monster with 8 health. The healths of the four monsters become 3, 4, 1 and -1, respectively, and the last monster vanishes.\n\nSecond, cause an explosion centered at the monster with 4 health remaining. The healths of the three remaining monsters become 0, -1 and -2, respectively, and all the monsters are now vanished.\n\nSample Input 2\n\n2 10 4\n20\n20\n\nSample Output 2\n\n4\n\nYou need to cause two explosions centered at each monster, for a total of four.\n\nSample Input 3\n\n5 2 1\n900000000\n900000000\n1000000000\n1000000000\n1000000000\n\nSample Output 3\n\n800000000", "sample_input": "4 5 3\n8\n7\n4\n2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03700", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called health, and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below.\n\nFortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows:\n\nSelect an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds.\n\nAt least how many explosions do you need to cause in order to vanish all the monsters?\n\nConstraints\n\nAll input values are integers.\n\n1 ≤ N ≤ 10^5\n\n1 ≤ B < A ≤ 10^9\n\n1 ≤ h_i ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum number of explosions that needs to be caused in order to vanish all the monsters.\n\nSample Input 1\n\n4 5 3\n8\n7\n4\n2\n\nSample Output 1\n\n2\n\nYou can vanish all the monsters in two explosion, as follows:\n\nFirst, cause an explosion centered at the monster with 8 health. The healths of the four monsters become 3, 4, 1 and -1, respectively, and the last monster vanishes.\n\nSecond, cause an explosion centered at the monster with 4 health remaining. The healths of the three remaining monsters become 0, -1 and -2, respectively, and all the monsters are now vanished.\n\nSample Input 2\n\n2 10 4\n20\n20\n\nSample Output 2\n\n4\n\nYou need to cause two explosions centered at each monster, for a total of four.\n\nSample Input 3\n\n5 2 1\n900000000\n900000000\n1000000000\n1000000000\n1000000000\n\nSample Output 3\n\n800000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 610, "cpu_time_ms": 998, "memory_kb": 107860}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s860933294", "group_id": "codeNet:p03700", "input_text": "\nimport java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val n, a, b = sc.nextInt()\n val ar = Range(0, n).map(_ => sc.nextLong()).sorted.toArray\n\n println(solve)\n\n def solve(): Long = {\n var l = 0L\n var r = 1000L * 1000L * 1000L\n while (l != r - 1) {\n val c = (l + r) / 2\n if (ok(c)) r = c\n else l = c\n }\n return r\n }\n\n def ok(cnt: Long): Boolean = {\n ar.foldLeft(0L) {\n case (sum, h) => {\n if (cnt * b > h) {\n sum\n } else {\n sum + ((h - cnt * b - 1) / (a - b)) + 1\n }\n }\n } <= cnt\n }\n}\n", "language": "Scala", "metadata": {"date": 1499735522, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03700.html", "problem_id": "p03700", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03700/input.txt", "sample_output_relpath": "derived/input_output/data/p03700/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03700/Scala/s860933294.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s860933294", "user_id": "u726872801"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "\nimport java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val n, a, b = sc.nextInt()\n val ar = Range(0, n).map(_ => sc.nextLong()).sorted.toArray\n\n println(solve)\n\n def solve(): Long = {\n var l = 0L\n var r = 1000L * 1000L * 1000L\n while (l != r - 1) {\n val c = (l + r) / 2\n if (ok(c)) r = c\n else l = c\n }\n return r\n }\n\n def ok(cnt: Long): Boolean = {\n ar.foldLeft(0L) {\n case (sum, h) => {\n if (cnt * b > h) {\n sum\n } else {\n sum + ((h - cnt * b - 1) / (a - b)) + 1\n }\n }\n } <= cnt\n }\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called health, and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below.\n\nFortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows:\n\nSelect an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds.\n\nAt least how many explosions do you need to cause in order to vanish all the monsters?\n\nConstraints\n\nAll input values are integers.\n\n1 ≤ N ≤ 10^5\n\n1 ≤ B < A ≤ 10^9\n\n1 ≤ h_i ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum number of explosions that needs to be caused in order to vanish all the monsters.\n\nSample Input 1\n\n4 5 3\n8\n7\n4\n2\n\nSample Output 1\n\n2\n\nYou can vanish all the monsters in two explosion, as follows:\n\nFirst, cause an explosion centered at the monster with 8 health. The healths of the four monsters become 3, 4, 1 and -1, respectively, and the last monster vanishes.\n\nSecond, cause an explosion centered at the monster with 4 health remaining. The healths of the three remaining monsters become 0, -1 and -2, respectively, and all the monsters are now vanished.\n\nSample Input 2\n\n2 10 4\n20\n20\n\nSample Output 2\n\n4\n\nYou need to cause two explosions centered at each monster, for a total of four.\n\nSample Input 3\n\n5 2 1\n900000000\n900000000\n1000000000\n1000000000\n1000000000\n\nSample Output 3\n\n800000000", "sample_input": "4 5 3\n8\n7\n4\n2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03700", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called health, and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below.\n\nFortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows:\n\nSelect an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds.\n\nAt least how many explosions do you need to cause in order to vanish all the monsters?\n\nConstraints\n\nAll input values are integers.\n\n1 ≤ N ≤ 10^5\n\n1 ≤ B < A ≤ 10^9\n\n1 ≤ h_i ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum number of explosions that needs to be caused in order to vanish all the monsters.\n\nSample Input 1\n\n4 5 3\n8\n7\n4\n2\n\nSample Output 1\n\n2\n\nYou can vanish all the monsters in two explosion, as follows:\n\nFirst, cause an explosion centered at the monster with 8 health. The healths of the four monsters become 3, 4, 1 and -1, respectively, and the last monster vanishes.\n\nSecond, cause an explosion centered at the monster with 4 health remaining. The healths of the three remaining monsters become 0, -1 and -2, respectively, and all the monsters are now vanished.\n\nSample Input 2\n\n2 10 4\n20\n20\n\nSample Output 2\n\n4\n\nYou need to cause two explosions centered at each monster, for a total of four.\n\nSample Input 3\n\n5 2 1\n900000000\n900000000\n1000000000\n1000000000\n1000000000\n\nSample Output 3\n\n800000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 611, "cpu_time_ms": 1014, "memory_kb": 106740}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s148865602", "group_id": "codeNet:p03700", "input_text": "import scala.io.Source\n\nobject Main {\n\n def main(args: Array[String]) {\n val lines = Source.stdin.getLines.toSeq\n val arr = lines.head.split(\" \")\n val n = arr(0).toLong\n val a = arr(1).toLong\n val b = arr(2).toLong\n val hs = lines.tail.map(_.toLong)\n\n def isSat(xs: Seq[Long], count: Long): Boolean =\n if (count < 0) false\n else xs match {\n case Nil => true\n case x +: rest => isSat(rest, count - ((x - 1) / (a - b) + 1))\n }\n\n def minimize(lower: Long, upper: Long): Long =\n if (lower >= upper) upper\n else {\n val k = (lower + upper) / 2\n val hs2 = hs.map(_ - b * k).filter(_ > 0)\n if (isSat(hs2, k)) minimize(lower, k)\n else minimize(k + 1, upper)\n }\n\n val lowerBound = hs.max / a\n val upperBound = hs.max / b\n println(minimize(lowerBound, upperBound))\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1498068640, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03700.html", "problem_id": "p03700", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03700/input.txt", "sample_output_relpath": "derived/input_output/data/p03700/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03700/Scala/s148865602.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s148865602", "user_id": "u771641306"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.io.Source\n\nobject Main {\n\n def main(args: Array[String]) {\n val lines = Source.stdin.getLines.toSeq\n val arr = lines.head.split(\" \")\n val n = arr(0).toLong\n val a = arr(1).toLong\n val b = arr(2).toLong\n val hs = lines.tail.map(_.toLong)\n\n def isSat(xs: Seq[Long], count: Long): Boolean =\n if (count < 0) false\n else xs match {\n case Nil => true\n case x +: rest => isSat(rest, count - ((x - 1) / (a - b) + 1))\n }\n\n def minimize(lower: Long, upper: Long): Long =\n if (lower >= upper) upper\n else {\n val k = (lower + upper) / 2\n val hs2 = hs.map(_ - b * k).filter(_ > 0)\n if (isSat(hs2, k)) minimize(lower, k)\n else minimize(k + 1, upper)\n }\n\n val lowerBound = hs.max / a\n val upperBound = hs.max / b\n println(minimize(lowerBound, upperBound))\n }\n\n}\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called health, and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below.\n\nFortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows:\n\nSelect an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds.\n\nAt least how many explosions do you need to cause in order to vanish all the monsters?\n\nConstraints\n\nAll input values are integers.\n\n1 ≤ N ≤ 10^5\n\n1 ≤ B < A ≤ 10^9\n\n1 ≤ h_i ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum number of explosions that needs to be caused in order to vanish all the monsters.\n\nSample Input 1\n\n4 5 3\n8\n7\n4\n2\n\nSample Output 1\n\n2\n\nYou can vanish all the monsters in two explosion, as follows:\n\nFirst, cause an explosion centered at the monster with 8 health. The healths of the four monsters become 3, 4, 1 and -1, respectively, and the last monster vanishes.\n\nSecond, cause an explosion centered at the monster with 4 health remaining. The healths of the three remaining monsters become 0, -1 and -2, respectively, and all the monsters are now vanished.\n\nSample Input 2\n\n2 10 4\n20\n20\n\nSample Output 2\n\n4\n\nYou need to cause two explosions centered at each monster, for a total of four.\n\nSample Input 3\n\n5 2 1\n900000000\n900000000\n1000000000\n1000000000\n1000000000\n\nSample Output 3\n\n800000000", "sample_input": "4 5 3\n8\n7\n4\n2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03700", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called health, and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below.\n\nFortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows:\n\nSelect an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds.\n\nAt least how many explosions do you need to cause in order to vanish all the monsters?\n\nConstraints\n\nAll input values are integers.\n\n1 ≤ N ≤ 10^5\n\n1 ≤ B < A ≤ 10^9\n\n1 ≤ h_i ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum number of explosions that needs to be caused in order to vanish all the monsters.\n\nSample Input 1\n\n4 5 3\n8\n7\n4\n2\n\nSample Output 1\n\n2\n\nYou can vanish all the monsters in two explosion, as follows:\n\nFirst, cause an explosion centered at the monster with 8 health. The healths of the four monsters become 3, 4, 1 and -1, respectively, and the last monster vanishes.\n\nSecond, cause an explosion centered at the monster with 4 health remaining. The healths of the three remaining monsters become 0, -1 and -2, respectively, and all the monsters are now vanished.\n\nSample Input 2\n\n2 10 4\n20\n20\n\nSample Output 2\n\n4\n\nYou need to cause two explosions centered at each monster, for a total of four.\n\nSample Input 3\n\n5 2 1\n900000000\n900000000\n1000000000\n1000000000\n1000000000\n\nSample Output 3\n\n800000000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 867, "cpu_time_ms": 1441, "memory_kb": 148188}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s515061842", "group_id": "codeNet:p03712", "input_text": "\nobject Main extends App {\n \n val sc = new java.util.Scanner(System.in)\n val h, w = sc.nextInt()\n val a = Array.fill(h)(sc.next().toList)\n \n println(\"#\" * (w+2))\n for (i <- a){\n print(\"#\")\n for (j <- i) {\n print(j)\n }\n println(\"#\")\n }\n println(\"#\" * (w+2))\n}", "language": "Scala", "metadata": {"date": 1599265916, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03712.html", "problem_id": "p03712", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03712/input.txt", "sample_output_relpath": "derived/input_output/data/p03712/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03712/Scala/s515061842.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s515061842", "user_id": "u396472025"}, "prompt_components": {"gold_output": "#####\n#abc#\n#arc#\n#####\n", "input_to_evaluate": "\nobject Main extends App {\n \n val sc = new java.util.Scanner(System.in)\n val h, w = sc.nextInt()\n val a = Array.fill(h)(sc.next().toList)\n \n println(\"#\" * (w+2))\n for (i <- a){\n print(\"#\")\n for (j <- i) {\n print(j)\n }\n println(\"#\")\n }\n println(\"#\" * (w+2))\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a image with a height of H pixels and a width of W pixels.\nEach pixel is represented by a lowercase English letter.\nThe pixel at the i-th row from the top and j-th column from the left is a_{ij}.\n\nPut a box around this image and output the result. The box should consist of # and have a thickness of 1.\n\nConstraints\n\n1 ≤ H, W ≤ 100\n\na_{ij} is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{11} ... a_{1W}\n:\na_{H1} ... a_{HW}\n\nOutput\n\nPrint the image surrounded by a box that consists of # and has a thickness of 1.\n\nSample Input 1\n\n2 3\nabc\narc\n\nSample Output 1\n\n#####\n#abc#\n#arc#\n#####\n\nSample Input 2\n\n1 1\nz\n\nSample Output 2\n\n###\n#z#\n###", "sample_input": "2 3\nabc\narc\n"}, "reference_outputs": ["#####\n#abc#\n#arc#\n#####\n"], "source_document_id": "p03712", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a image with a height of H pixels and a width of W pixels.\nEach pixel is represented by a lowercase English letter.\nThe pixel at the i-th row from the top and j-th column from the left is a_{ij}.\n\nPut a box around this image and output the result. The box should consist of # and have a thickness of 1.\n\nConstraints\n\n1 ≤ H, W ≤ 100\n\na_{ij} is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{11} ... a_{1W}\n:\na_{H1} ... a_{HW}\n\nOutput\n\nPrint the image surrounded by a box that consists of # and has a thickness of 1.\n\nSample Input 1\n\n2 3\nabc\narc\n\nSample Output 1\n\n#####\n#abc#\n#arc#\n#####\n\nSample Input 2\n\n1 1\nz\n\nSample Output 2\n\n###\n#z#\n###", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 284, "cpu_time_ms": 582, "memory_kb": 56444}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s195233295", "group_id": "codeNet:p03713", "input_text": "import scala.io.StdIn\nimport scala.collection.mutable.ListBuffer\n\nobject Main extends App {\n val Array(h, w) = StdIn.readLine.split(\" \").map(_.toLong)\n\n val res1 = {\n val list = ListBuffer.empty[Long]\n val m = h / 2L\n val res = (1L until w/2)./:(Long.MaxValue, Long.MaxValue)((min, i) => {\n val a =( h * i ) \n list += a\n list += ( m * (w-i) )\n list += ( (h-m) * (w-i) )\n val r1 = list.max - list.min\n list.clear\n val k = (w-i) / 2L\n list += a\n list += ( k * h )\n list += ( (w-i-k) * h )\n val r2 = list.max - list.min\n list.clear\n ( math.min(min._2, r1), math.min(min._2, r2) )\n })\n math.min(res._1, res._2)\n }\n\n val res2 = {\n val list = ListBuffer.empty[Long]\n val m = w / 2L\n val res = (1L until h/2)./:(Long.MaxValue, Long.MaxValue)((min, i) => {\n val a = w * i\n list += a\n list += ( m * (h-i) )\n list += ( (w-m) * (h-i))\n val r1 = list.max - list.min\n list.clear\n val k = (h-i) / 2L\n list += a\n list += ( k * w )\n list += ( (h-i-k) * w )\n val r2 = list.max - list.min\n list.clear\n ( math.min(min._1, r1), math.min(min._2, r2) )\n })\n math.min(res._1, res._2)\n }\n\n val ans = math.min(res1, res2)\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1547150445, "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/s195233295.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s195233295", "user_id": "u217010036"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "import scala.io.StdIn\nimport scala.collection.mutable.ListBuffer\n\nobject Main extends App {\n val Array(h, w) = StdIn.readLine.split(\" \").map(_.toLong)\n\n val res1 = {\n val list = ListBuffer.empty[Long]\n val m = h / 2L\n val res = (1L until w/2)./:(Long.MaxValue, Long.MaxValue)((min, i) => {\n val a =( h * i ) \n list += a\n list += ( m * (w-i) )\n list += ( (h-m) * (w-i) )\n val r1 = list.max - list.min\n list.clear\n val k = (w-i) / 2L\n list += a\n list += ( k * h )\n list += ( (w-i-k) * h )\n val r2 = list.max - list.min\n list.clear\n ( math.min(min._2, r1), math.min(min._2, r2) )\n })\n math.min(res._1, res._2)\n }\n\n val res2 = {\n val list = ListBuffer.empty[Long]\n val m = w / 2L\n val res = (1L until h/2)./:(Long.MaxValue, Long.MaxValue)((min, i) => {\n val a = w * i\n list += a\n list += ( m * (h-i) )\n list += ( (w-m) * (h-i))\n val r1 = list.max - list.min\n list.clear\n val k = (h-i) / 2L\n list += a\n list += ( k * w )\n list += ( (h-i-k) * w )\n val r2 = list.max - list.min\n list.clear\n ( math.min(min._1, r1), math.min(min._2, r2) )\n })\n math.min(res._1, res._2)\n }\n\n val ans = math.min(res1, res2)\n println(ans)\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere is a bar of chocolate with a height of H blocks and a width of W blocks.\nSnuke is dividing this bar into exactly three pieces.\nHe can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle.\n\nSnuke is trying to divide the bar as evenly as possible.\nMore specifically, he is trying to minimize S_{max} - S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece.\nFind the minimum possible value of S_{max} - S_{min}.\n\nConstraints\n\n2 ≤ H, W ≤ 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\n\nOutput\n\nPrint the minimum possible value of S_{max} - S_{min}.\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n0\n\nIn the division below, S_{max} - S_{min} = 5 - 5 = 0.\n\nSample Input 2\n\n4 5\n\nSample Output 2\n\n2\n\nIn the division below, S_{max} - S_{min} = 8 - 6 = 2.\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\n4\n\nIn the division below, S_{max} - S_{min} = 10 - 6 = 4.\n\nSample Input 4\n\n100000 2\n\nSample Output 4\n\n1\n\nSample Input 5\n\n100000 100000\n\nSample Output 5\n\n50000", "sample_input": "3 5\n"}, "reference_outputs": ["0\n"], "source_document_id": "p03713", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere is a bar of chocolate with a height of H blocks and a width of W blocks.\nSnuke is dividing this bar into exactly three pieces.\nHe can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle.\n\nSnuke is trying to divide the bar as evenly as possible.\nMore specifically, he is trying to minimize S_{max} - S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece.\nFind the minimum possible value of S_{max} - S_{min}.\n\nConstraints\n\n2 ≤ H, W ≤ 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\n\nOutput\n\nPrint the minimum possible value of S_{max} - S_{min}.\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n0\n\nIn the division below, S_{max} - S_{min} = 5 - 5 = 0.\n\nSample Input 2\n\n4 5\n\nSample Output 2\n\n2\n\nIn the division below, S_{max} - S_{min} = 8 - 6 = 2.\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\n4\n\nIn the division below, S_{max} - S_{min} = 10 - 6 = 4.\n\nSample Input 4\n\n100000 2\n\nSample Output 4\n\n1\n\nSample Input 5\n\n100000 100000\n\nSample Output 5\n\n50000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1279, "cpu_time_ms": 898, "memory_kb": 51196}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s504019186", "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 val h=Math.min(H,W)\n val w=Math.max(H,W)\n \n if(H%3==1&&W%3==1)???\n \n val res = if(h%3==0||w%3==0){\n 0\n }else{\n var res = h\n \n val X = Math.max(w/3,0)\n val _X = Math.min(w,X+1)\n (X to _X).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 val Y = Math.max(h/3,0)\n val _Y = Math.min(h,Y+1)\n (Y to _Y).foreach(y => {\n val hy = h-y\n val w0 = w/2\n val w1 = w-w/2\n val can = Seq(y*h,hy*w0,hy*w1)\n res = Math.min(res,can.max-can.min)\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": 1495341663, "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/s504019186.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s504019186", "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 val h=Math.min(H,W)\n val w=Math.max(H,W)\n \n if(H%3==1&&W%3==1)???\n \n val res = if(h%3==0||w%3==0){\n 0\n }else{\n var res = h\n \n val X = Math.max(w/3,0)\n val _X = Math.min(w,X+1)\n (X to _X).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 val Y = Math.max(h/3,0)\n val _Y = Math.min(h,Y+1)\n (Y to _Y).foreach(y => {\n val hy = h-y\n val w0 = w/2\n val w1 = w-w/2\n val can = Seq(y*h,hy*w0,hy*w1)\n res = Math.min(res,can.max-can.min)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2577, "cpu_time_ms": 328, "memory_kb": 27296}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s999509071", "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 val h=Math.min(H,W)\n val w=Math.max(H,W)\n \n if(H<10000&&W<10000)???\n \n val res = if(h%3==0||w%3==0){\n 0\n }else{\n var res = h\n \n val X = Math.max(w/3,0)\n val _X = Math.min(w,X+1)\n (X to _X).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 val Y = Math.max(h/3,0)\n val _Y = Math.min(h,Y+1)\n (Y to _Y).foreach(y => {\n val hy = h-y\n val w0 = w/2\n val w1 = w-w/2\n val can = Seq(y*h,hy*w0,hy*w1)\n res = Math.min(res,can.max-can.min)\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": 1495341470, "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/s999509071.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s999509071", "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 val h=Math.min(H,W)\n val w=Math.max(H,W)\n \n if(H<10000&&W<10000)???\n \n val res = if(h%3==0||w%3==0){\n 0\n }else{\n var res = h\n \n val X = Math.max(w/3,0)\n val _X = Math.min(w,X+1)\n (X to _X).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 val Y = Math.max(h/3,0)\n val _Y = Math.min(h,Y+1)\n (Y to _Y).foreach(y => {\n val hy = h-y\n val w0 = w/2\n val w1 = w-w/2\n val can = Seq(y*h,hy*w0,hy*w1)\n res = Math.min(res,can.max-can.min)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2579, "cpu_time_ms": 329, "memory_kb": 27200}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s189003455", "group_id": "codeNet:p03719", "input_text": "object Main extends App {\n val scan = new java.util.Scanner(System.in)\n val ns: Array[Long] = Array.fill(1e5.toInt + 100)(0l)\n val n, k = scan.next().toInt\n for (_ <- 1 to n) yield ns(scan.next().toInt) += scan.next().toInt\n val acc = ns.scanLeft(0l)((s, n) => s + n).drop(1)\n println((0 to ns.length).zip(acc).dropWhile(_._2 < k).head._1)\n}", "language": "Scala", "metadata": {"date": 1525804539, "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/s189003455.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s189003455", "user_id": "u219949952"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App {\n val scan = new java.util.Scanner(System.in)\n val ns: Array[Long] = Array.fill(1e5.toInt + 100)(0l)\n val n, k = scan.next().toInt\n for (_ <- 1 to n) yield ns(scan.next().toInt) += scan.next().toInt\n val acc = ns.scanLeft(0l)((s, n) => s + n).drop(1)\n println((0 to ns.length).zip(acc).dropWhile(_._2 < k).head._1)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given three integers A, B and C.\nDetermine whether C is not less than A and not greater than B.\n\nConstraints\n\n-100≤A,B,C≤100\n\nA, B and C are all integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf the condition is satisfied, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 3 2\n\nSample Output 1\n\nYes\n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should be Yes.\n\nSample Input 2\n\n6 5 4\n\nSample Output 2\n\nNo\n\nC=4 is less than A=6, and thus the output should be No.\n\nSample Input 3\n\n2 2 2\n\nSample Output 3\n\nYes", "sample_input": "1 3 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03719", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given three integers A, B and C.\nDetermine whether C is not less than A and not greater than B.\n\nConstraints\n\n-100≤A,B,C≤100\n\nA, B and C are all integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf the condition is satisfied, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 3 2\n\nSample Output 1\n\nYes\n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should be Yes.\n\nSample Input 2\n\n6 5 4\n\nSample Output 2\n\nNo\n\nC=4 is less than A=6, and thus the output should be No.\n\nSample Input 3\n\n2 2 2\n\nSample Output 3\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 347, "cpu_time_ms": 483, "memory_kb": 41624}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s748548248", "group_id": "codeNet:p03719", "input_text": "import io.StdIn.readLine\nobject Main extends App {\n val Array(a, b, c) = readLine.split(\" \").map(_.toInt)\n println(if (a <= c && c <= b) \"Yes\" else \"No\")\n}", "language": "Scala", "metadata": {"date": 1494724050, "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/s748548248.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s748548248", "user_id": "u158295568"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "import io.StdIn.readLine\nobject Main extends App {\n val Array(a, b, c) = readLine.split(\" \").map(_.toInt)\n println(if (a <= c && c <= b) \"Yes\" else \"No\")\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given three integers A, B and C.\nDetermine whether C is not less than A and not greater than B.\n\nConstraints\n\n-100≤A,B,C≤100\n\nA, B and C are all integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf the condition is satisfied, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 3 2\n\nSample Output 1\n\nYes\n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should be Yes.\n\nSample Input 2\n\n6 5 4\n\nSample Output 2\n\nNo\n\nC=4 is less than A=6, and thus the output should be No.\n\nSample Input 3\n\n2 2 2\n\nSample Output 3\n\nYes", "sample_input": "1 3 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03719", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given three integers A, B and C.\nDetermine whether C is not less than A and not greater than B.\n\nConstraints\n\n-100≤A,B,C≤100\n\nA, B and C are all integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf the condition is satisfied, print Yes; otherwise, print No.\n\nSample Input 1\n\n1 3 2\n\nSample Output 1\n\nYes\n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should be Yes.\n\nSample Input 2\n\n6 5 4\n\nSample Output 2\n\nNo\n\nC=4 is less than A=6, and thus the output should be No.\n\nSample Input 3\n\n2 2 2\n\nSample Output 3\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 157, "cpu_time_ms": 321, "memory_kb": 25528}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s734833127", "group_id": "codeNet:p03720", "input_text": "\nobject Main extends App {\n \n val sc = new java.util.Scanner(System.in)\n val n, m = sc.nextInt()\n val r = Array.fill(m*2)(sc.nextInt())\n val ret = r.groupMapReduce(identity)(_ => 1)(_ + _)\n (1 to n).foreach(i => if (ret.contains(i)) println(ret(i)) else println(0))\n}", "language": "Scala", "metadata": {"date": 1599353103, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03720.html", "problem_id": "p03720", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03720/input.txt", "sample_output_relpath": "derived/input_output/data/p03720/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03720/Scala/s734833127.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s734833127", "user_id": "u396472025"}, "prompt_components": {"gold_output": "2\n2\n1\n1\n", "input_to_evaluate": "\nobject Main extends App {\n \n val sc = new java.util.Scanner(System.in)\n val n, m = sc.nextInt()\n val r = Array.fill(m*2)(sc.nextInt())\n val ret = r.groupMapReduce(identity)(_ => 1)(_ + _)\n (1 to n).foreach(i => if (ret.contains(i)) println(ret(i)) else println(0))\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N cities and M roads.\nThe i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally.\nThere may be more than one road that connects the same pair of two cities.\nFor each city, how many roads are connected to the city?\n\nConstraints\n\n2≤N,M≤50\n\n1≤a_i,b_i≤N\n\na_i ≠ b_i\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\n:\na_M b_M\n\nOutput\n\nPrint the answer in N lines.\nIn the i-th line (1≤i≤N), print the number of roads connected to city i.\n\nSample Input 1\n\n4 3\n1 2\n2 3\n1 4\n\nSample Output 1\n\n2\n2\n1\n1\n\nCity 1 is connected to the 1-st and 3-rd roads.\n\nCity 2 is connected to the 1-st and 2-nd roads.\n\nCity 3 is connected to the 2-nd road.\n\nCity 4 is connected to the 3-rd road.\n\nSample Input 2\n\n2 5\n1 2\n2 1\n1 2\n2 1\n1 2\n\nSample Output 2\n\n5\n5\n\nSample Input 3\n\n8 8\n1 2\n3 4\n1 5\n2 8\n3 7\n5 2\n4 1\n6 8\n\nSample Output 3\n\n3\n3\n2\n2\n2\n1\n1\n2", "sample_input": "4 3\n1 2\n2 3\n1 4\n"}, "reference_outputs": ["2\n2\n1\n1\n"], "source_document_id": "p03720", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N cities and M roads.\nThe i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally.\nThere may be more than one road that connects the same pair of two cities.\nFor each city, how many roads are connected to the city?\n\nConstraints\n\n2≤N,M≤50\n\n1≤a_i,b_i≤N\n\na_i ≠ b_i\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\n:\na_M b_M\n\nOutput\n\nPrint the answer in N lines.\nIn the i-th line (1≤i≤N), print the number of roads connected to city i.\n\nSample Input 1\n\n4 3\n1 2\n2 3\n1 4\n\nSample Output 1\n\n2\n2\n1\n1\n\nCity 1 is connected to the 1-st and 3-rd roads.\n\nCity 2 is connected to the 1-st and 2-nd roads.\n\nCity 3 is connected to the 2-nd road.\n\nCity 4 is connected to the 3-rd road.\n\nSample Input 2\n\n2 5\n1 2\n2 1\n1 2\n2 1\n1 2\n\nSample Output 2\n\n5\n5\n\nSample Input 3\n\n8 8\n1 2\n3 4\n1 5\n2 8\n3 7\n5 2\n4 1\n6 8\n\nSample Output 3\n\n3\n3\n2\n2\n2\n1\n1\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 273, "cpu_time_ms": 502, "memory_kb": 55500}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s269855895", "group_id": "codeNet:p03720", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n, m = sc.nextInt()\n val e = List.fill(2 * m)(sc.nextInt())\n val count = e.groupBy(identity).view.mapValues(_.length)\n for (i <- 1 to n) {\n println(count.getOrElse(i, 0))\n }\n}\n", "language": "Scala", "metadata": {"date": 1595690290, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03720.html", "problem_id": "p03720", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03720/input.txt", "sample_output_relpath": "derived/input_output/data/p03720/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03720/Scala/s269855895.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s269855895", "user_id": "u191819389"}, "prompt_components": {"gold_output": "2\n2\n1\n1\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 e = List.fill(2 * m)(sc.nextInt())\n val count = e.groupBy(identity).view.mapValues(_.length)\n for (i <- 1 to n) {\n println(count.getOrElse(i, 0))\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N cities and M roads.\nThe i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally.\nThere may be more than one road that connects the same pair of two cities.\nFor each city, how many roads are connected to the city?\n\nConstraints\n\n2≤N,M≤50\n\n1≤a_i,b_i≤N\n\na_i ≠ b_i\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\n:\na_M b_M\n\nOutput\n\nPrint the answer in N lines.\nIn the i-th line (1≤i≤N), print the number of roads connected to city i.\n\nSample Input 1\n\n4 3\n1 2\n2 3\n1 4\n\nSample Output 1\n\n2\n2\n1\n1\n\nCity 1 is connected to the 1-st and 3-rd roads.\n\nCity 2 is connected to the 1-st and 2-nd roads.\n\nCity 3 is connected to the 2-nd road.\n\nCity 4 is connected to the 3-rd road.\n\nSample Input 2\n\n2 5\n1 2\n2 1\n1 2\n2 1\n1 2\n\nSample Output 2\n\n5\n5\n\nSample Input 3\n\n8 8\n1 2\n3 4\n1 5\n2 8\n3 7\n5 2\n4 1\n6 8\n\nSample Output 3\n\n3\n3\n2\n2\n2\n1\n1\n2", "sample_input": "4 3\n1 2\n2 3\n1 4\n"}, "reference_outputs": ["2\n2\n1\n1\n"], "source_document_id": "p03720", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N cities and M roads.\nThe i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally.\nThere may be more than one road that connects the same pair of two cities.\nFor each city, how many roads are connected to the city?\n\nConstraints\n\n2≤N,M≤50\n\n1≤a_i,b_i≤N\n\na_i ≠ b_i\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\n:\na_M b_M\n\nOutput\n\nPrint the answer in N lines.\nIn the i-th line (1≤i≤N), print the number of roads connected to city i.\n\nSample Input 1\n\n4 3\n1 2\n2 3\n1 4\n\nSample Output 1\n\n2\n2\n1\n1\n\nCity 1 is connected to the 1-st and 3-rd roads.\n\nCity 2 is connected to the 1-st and 2-nd roads.\n\nCity 3 is connected to the 2-nd road.\n\nCity 4 is connected to the 3-rd road.\n\nSample Input 2\n\n2 5\n1 2\n2 1\n1 2\n2 1\n1 2\n\nSample Output 2\n\n5\n5\n\nSample Input 3\n\n8 8\n1 2\n3 4\n1 5\n2 8\n3 7\n5 2\n4 1\n6 8\n\nSample Output 3\n\n3\n3\n2\n2\n2\n1\n1\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 259, "cpu_time_ms": 505, "memory_kb": 55592}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s708285747", "group_id": "codeNet:p03720", "input_text": "object Main extends App {\n\tval Array(n, m) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\tval a = new Array[Int](n)\n\n\tfor(i<-0 until m){\n\t\tval Array(tp1, tp2) = scala.io.StdIn.readLine.split(\" \").map(_.toInt - 1)\n\t\ta(tp1) += 1\n\t\ta(tp2) += 1\n\t}\n\n\ta.foreach(println)\n}\n", "language": "Scala", "metadata": {"date": 1555540105, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03720.html", "problem_id": "p03720", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03720/input.txt", "sample_output_relpath": "derived/input_output/data/p03720/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03720/Scala/s708285747.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s708285747", "user_id": "u675876401"}, "prompt_components": {"gold_output": "2\n2\n1\n1\n", "input_to_evaluate": "object Main extends App {\n\tval Array(n, m) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\tval a = new Array[Int](n)\n\n\tfor(i<-0 until m){\n\t\tval Array(tp1, tp2) = scala.io.StdIn.readLine.split(\" \").map(_.toInt - 1)\n\t\ta(tp1) += 1\n\t\ta(tp2) += 1\n\t}\n\n\ta.foreach(println)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N cities and M roads.\nThe i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally.\nThere may be more than one road that connects the same pair of two cities.\nFor each city, how many roads are connected to the city?\n\nConstraints\n\n2≤N,M≤50\n\n1≤a_i,b_i≤N\n\na_i ≠ b_i\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\n:\na_M b_M\n\nOutput\n\nPrint the answer in N lines.\nIn the i-th line (1≤i≤N), print the number of roads connected to city i.\n\nSample Input 1\n\n4 3\n1 2\n2 3\n1 4\n\nSample Output 1\n\n2\n2\n1\n1\n\nCity 1 is connected to the 1-st and 3-rd roads.\n\nCity 2 is connected to the 1-st and 2-nd roads.\n\nCity 3 is connected to the 2-nd road.\n\nCity 4 is connected to the 3-rd road.\n\nSample Input 2\n\n2 5\n1 2\n2 1\n1 2\n2 1\n1 2\n\nSample Output 2\n\n5\n5\n\nSample Input 3\n\n8 8\n1 2\n3 4\n1 5\n2 8\n3 7\n5 2\n4 1\n6 8\n\nSample Output 3\n\n3\n3\n2\n2\n2\n1\n1\n2", "sample_input": "4 3\n1 2\n2 3\n1 4\n"}, "reference_outputs": ["2\n2\n1\n1\n"], "source_document_id": "p03720", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N cities and M roads.\nThe i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally.\nThere may be more than one road that connects the same pair of two cities.\nFor each city, how many roads are connected to the city?\n\nConstraints\n\n2≤N,M≤50\n\n1≤a_i,b_i≤N\n\na_i ≠ b_i\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\n:\na_M b_M\n\nOutput\n\nPrint the answer in N lines.\nIn the i-th line (1≤i≤N), print the number of roads connected to city i.\n\nSample Input 1\n\n4 3\n1 2\n2 3\n1 4\n\nSample Output 1\n\n2\n2\n1\n1\n\nCity 1 is connected to the 1-st and 3-rd roads.\n\nCity 2 is connected to the 1-st and 2-nd roads.\n\nCity 3 is connected to the 2-nd road.\n\nCity 4 is connected to the 3-rd road.\n\nSample Input 2\n\n2 5\n1 2\n2 1\n1 2\n2 1\n1 2\n\nSample Output 2\n\n5\n5\n\nSample Input 3\n\n8 8\n1 2\n3 4\n1 5\n2 8\n3 7\n5 2\n4 1\n6 8\n\nSample Output 3\n\n3\n3\n2\n2\n2\n1\n1\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 272, "cpu_time_ms": 331, "memory_kb": 25428}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s401753259", "group_id": "codeNet:p03720", "input_text": "import io.StdIn.readLine\nobject Main extends App {\n val Array(n, m) = readLine.split(\" \").map(_.toInt)\n val (as, bs) = List.fill(m)(readLine.split(\" \").map(_.toInt) match {\n case Array(a, b) => (a, b)\n }).unzip\n val rs = (as ++ bs).groupBy(identity)\n for (i <- 1 to n) println(rs(i).size)\n}\n", "language": "Scala", "metadata": {"date": 1494724797, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03720.html", "problem_id": "p03720", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03720/input.txt", "sample_output_relpath": "derived/input_output/data/p03720/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03720/Scala/s401753259.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s401753259", "user_id": "u158295568"}, "prompt_components": {"gold_output": "2\n2\n1\n1\n", "input_to_evaluate": "import io.StdIn.readLine\nobject Main extends App {\n val Array(n, m) = readLine.split(\" \").map(_.toInt)\n val (as, bs) = List.fill(m)(readLine.split(\" \").map(_.toInt) match {\n case Array(a, b) => (a, b)\n }).unzip\n val rs = (as ++ bs).groupBy(identity)\n for (i <- 1 to n) println(rs(i).size)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N cities and M roads.\nThe i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally.\nThere may be more than one road that connects the same pair of two cities.\nFor each city, how many roads are connected to the city?\n\nConstraints\n\n2≤N,M≤50\n\n1≤a_i,b_i≤N\n\na_i ≠ b_i\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\n:\na_M b_M\n\nOutput\n\nPrint the answer in N lines.\nIn the i-th line (1≤i≤N), print the number of roads connected to city i.\n\nSample Input 1\n\n4 3\n1 2\n2 3\n1 4\n\nSample Output 1\n\n2\n2\n1\n1\n\nCity 1 is connected to the 1-st and 3-rd roads.\n\nCity 2 is connected to the 1-st and 2-nd roads.\n\nCity 3 is connected to the 2-nd road.\n\nCity 4 is connected to the 3-rd road.\n\nSample Input 2\n\n2 5\n1 2\n2 1\n1 2\n2 1\n1 2\n\nSample Output 2\n\n5\n5\n\nSample Input 3\n\n8 8\n1 2\n3 4\n1 5\n2 8\n3 7\n5 2\n4 1\n6 8\n\nSample Output 3\n\n3\n3\n2\n2\n2\n1\n1\n2", "sample_input": "4 3\n1 2\n2 3\n1 4\n"}, "reference_outputs": ["2\n2\n1\n1\n"], "source_document_id": "p03720", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N cities and M roads.\nThe i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally.\nThere may be more than one road that connects the same pair of two cities.\nFor each city, how many roads are connected to the city?\n\nConstraints\n\n2≤N,M≤50\n\n1≤a_i,b_i≤N\n\na_i ≠ b_i\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\n:\na_M b_M\n\nOutput\n\nPrint the answer in N lines.\nIn the i-th line (1≤i≤N), print the number of roads connected to city i.\n\nSample Input 1\n\n4 3\n1 2\n2 3\n1 4\n\nSample Output 1\n\n2\n2\n1\n1\n\nCity 1 is connected to the 1-st and 3-rd roads.\n\nCity 2 is connected to the 1-st and 2-nd roads.\n\nCity 3 is connected to the 2-nd road.\n\nCity 4 is connected to the 3-rd road.\n\nSample Input 2\n\n2 5\n1 2\n2 1\n1 2\n2 1\n1 2\n\nSample Output 2\n\n5\n5\n\nSample Input 3\n\n8 8\n1 2\n3 4\n1 5\n2 8\n3 7\n5 2\n4 1\n6 8\n\nSample Output 3\n\n3\n3\n2\n2\n2\n1\n1\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 299, "cpu_time_ms": 340, "memory_kb": 25496}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s205205116", "group_id": "codeNet:p03721", "input_text": "object Main {\n\n def main(args: Array[String]): Unit = {\n import scala.io.StdIn._\n val inputs = readLine().split(\" \").map(_.toLong)\n val N = inputs(0).toInt\n val K = inputs(1)\n val arr = new Array[Long](100001)\n\n (0 until N).map(_ => {\n val Array(a, b) = readLine().split(\" \").map(_.toInt)\n (a, b)\n }).foreach { case (a, b) =>\n arr(a) += b\n }\n\n var c = 0L\n (1 to 100000).foreach { i =>\n c += arr(i)\n if (c >= K) {\n println(i)\n return\n }\n }\n\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1558214045, "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/s205205116.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s205205116", "user_id": "u891387249"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main {\n\n def main(args: Array[String]): Unit = {\n import scala.io.StdIn._\n val inputs = readLine().split(\" \").map(_.toLong)\n val N = inputs(0).toInt\n val K = inputs(1)\n val arr = new Array[Long](100001)\n\n (0 until N).map(_ => {\n val Array(a, b) = readLine().split(\" \").map(_.toInt)\n (a, b)\n }).foreach { case (a, b) =>\n arr(a) += b\n }\n\n var c = 0L\n (1 to 100000).foreach { i =>\n c += arr(i)\n if (c >= K) {\n println(i)\n return\n }\n }\n\n }\n\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is an empty array.\nThe following N operations will be performed to insert integers into the array.\nIn the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array.\nFind the K-th smallest integer in the array after the N operations.\nFor example, the 4-th smallest integer in the array \\{1,2,2,3,3,3\\} is 3.\n\nConstraints\n\n1≤N≤10^5\n\n1≤a_i,b_i≤10^5\n\n1≤K≤b_1…+…b_n\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 b_1\n:\na_N b_N\n\nOutput\n\nPrint the K-th smallest integer in the array after the N operations.\n\nSample Input 1\n\n3 4\n1 1\n2 2\n3 3\n\nSample Output 1\n\n3\n\nThe resulting array is the same as the one in the problem statement.\n\nSample Input 2\n\n10 500000\n1 100000\n1 100000\n1 100000\n1 100000\n1 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n\nSample Output 2\n\n1", "sample_input": "3 4\n1 1\n2 2\n3 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03721", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is an empty array.\nThe following N operations will be performed to insert integers into the array.\nIn the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array.\nFind the K-th smallest integer in the array after the N operations.\nFor example, the 4-th smallest integer in the array \\{1,2,2,3,3,3\\} is 3.\n\nConstraints\n\n1≤N≤10^5\n\n1≤a_i,b_i≤10^5\n\n1≤K≤b_1…+…b_n\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 b_1\n:\na_N b_N\n\nOutput\n\nPrint the K-th smallest integer in the array after the N operations.\n\nSample Input 1\n\n3 4\n1 1\n2 2\n3 3\n\nSample Output 1\n\n3\n\nThe resulting array is the same as the one in the problem statement.\n\nSample Input 2\n\n10 500000\n1 100000\n1 100000\n1 100000\n1 100000\n1 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n\nSample Output 2\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 525, "cpu_time_ms": 858, "memory_kb": 57784}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s347424450", "group_id": "codeNet:p03721", "input_text": "object Main extends App {\n val N = Scanner.nextInt\n val K = Scanner.nextLong\n val A = (0 until N).map(i => (Scanner.nextInt, Scanner.nextLong)).sortBy(t => t._1)\n def go(list: Seq[(Int, Long)], acc: Long = 0): Int = list match {\n case head +: tail =>\n if (acc + head._2 >= K) head._1\n else go(tail, acc + head._2)\n }\n println(go(A))\n}\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 @inline private def hasNextByte: Boolean = if (ptr >= len) {\n ptr = 0\n len = System.in.read(buf)\n len > 0\n } else {\n true\n }\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) {\n val res = buf(ptr)\n ptr += 1\n res\n } else {\n -1\n }\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)\n b = readByte\n }\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\n var b = readByte\n if (b == '-') {\n minus = true\n b = readByte\n }\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\n else n\n go(b)\n }\n def nextDouble: Double = next.toDouble\n}", "language": "Scala", "metadata": {"date": 1494726703, "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/s347424450.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s347424450", "user_id": "u989222035"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main extends App {\n val N = Scanner.nextInt\n val K = Scanner.nextLong\n val A = (0 until N).map(i => (Scanner.nextInt, Scanner.nextLong)).sortBy(t => t._1)\n def go(list: Seq[(Int, Long)], acc: Long = 0): Int = list match {\n case head +: tail =>\n if (acc + head._2 >= K) head._1\n else go(tail, acc + head._2)\n }\n println(go(A))\n}\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 @inline private def hasNextByte: Boolean = if (ptr >= len) {\n ptr = 0\n len = System.in.read(buf)\n len > 0\n } else {\n true\n }\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) {\n val res = buf(ptr)\n ptr += 1\n res\n } else {\n -1\n }\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)\n b = readByte\n }\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\n var b = readByte\n if (b == '-') {\n minus = true\n b = readByte\n }\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\n else n\n go(b)\n }\n def nextDouble: Double = next.toDouble\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is an empty array.\nThe following N operations will be performed to insert integers into the array.\nIn the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array.\nFind the K-th smallest integer in the array after the N operations.\nFor example, the 4-th smallest integer in the array \\{1,2,2,3,3,3\\} is 3.\n\nConstraints\n\n1≤N≤10^5\n\n1≤a_i,b_i≤10^5\n\n1≤K≤b_1…+…b_n\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 b_1\n:\na_N b_N\n\nOutput\n\nPrint the K-th smallest integer in the array after the N operations.\n\nSample Input 1\n\n3 4\n1 1\n2 2\n3 3\n\nSample Output 1\n\n3\n\nThe resulting array is the same as the one in the problem statement.\n\nSample Input 2\n\n10 500000\n1 100000\n1 100000\n1 100000\n1 100000\n1 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n\nSample Output 2\n\n1", "sample_input": "3 4\n1 1\n2 2\n3 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03721", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is an empty array.\nThe following N operations will be performed to insert integers into the array.\nIn the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array.\nFind the K-th smallest integer in the array after the N operations.\nFor example, the 4-th smallest integer in the array \\{1,2,2,3,3,3\\} is 3.\n\nConstraints\n\n1≤N≤10^5\n\n1≤a_i,b_i≤10^5\n\n1≤K≤b_1…+…b_n\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 b_1\n:\na_N b_N\n\nOutput\n\nPrint the K-th smallest integer in the array after the N operations.\n\nSample Input 1\n\n3 4\n1 1\n2 2\n3 3\n\nSample Output 1\n\n3\n\nThe resulting array is the same as the one in the problem statement.\n\nSample Input 2\n\n10 500000\n1 100000\n1 100000\n1 100000\n1 100000\n1 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n\nSample Output 2\n\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1624, "cpu_time_ms": 859, "memory_kb": 72244}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s427504091", "group_id": "codeNet:p03722", "input_text": "\nimport collection.mutable.ArrayBuffer\nimport scala.reflect.ClassTag\nimport scala.language.implicitConversions\n\ntrait Graph { \n case class Edge[T:Numeric](from : Int, to : Int, cost : T)\n\n class Edges[T:Numeric](val data : ArrayBuffer[Edge[T]]) {\n def size = data.size\n }\n object Edges {\n def apply[T:Numeric](xs : Edge[T]*) = new Edges(ArrayBuffer(xs:_*))\n implicit def toUnderLying[T](x:Edges[T]) = x.data\n }\n\n class WeightedGraph[T:Numeric](val size : Int, val data : Array[Edges[T]]) {\n def this(size : Int) = this(size, Array.fill(size)(Edges()))\n }\n object WeightedGraph {\n // def apply[T:Numeric](size : Int) = new WeightedGraph[T](size)\n implicit def toUnderLying[T](x:WeightedGraph[T]) = x.data\n }\n\n class UnWeightedGraph[T:Numeric](val size : Int, val data: Array[ArrayBuffer[T]]) {\n def this(size : Int) = this(size, Array.fill(size)(ArrayBuffer[T]()))\n }\n object UnWeightedGraph {\n // def apply[T:Numeric](size : Int) = new UnWeightedGraph[T](size)\n implicit def toUnderLying[T](x:UnWeightedGraph[T]) = x.data\n }\n \n class Matrix[T:Numeric:ClassTag](val row : Int, val col : Int, val data : Array[Array[T]]) {\n def this(row : Int, col : Int) = this(row, col, Array.fill(row, col)(implicitly[Numeric[T]].zero))\n def this(size : Int) = this(size, size)\n }\n object Matrix {\n implicit def toUnderLying[T](x:Matrix[T]) = x.data\n }\n}\n\n// object BellmanFord extends Graph {\n// import Edges._\n\n// // return ArrayBuffer() when find a negative cycle\n// def bellmanFord[T:ClassTag](edges : Edges[T], V : Int, s : Int, INF : T)(implicit num : Numeric[T]) : Array[T] = {\n// val dist = Array.fill[T](V)(INF)\n// dist(s) = num.zero\n// for (i <- 1 to V) {\n// for (e <- edges) {\n// if(dist(e.from) != INF \n// && num.lt(num.plus(dist(e.from), e.cost), dist(e.to))) {\n// dist(e.to) = num.plus(dist(e.from), e.cost)\n// if (i == V && e.to == V-1) return Array.empty\n// }\n// }\n// }\n// dist\n// }\n// }\n\nobject BellmanFord extends Graph {\n import Edges._\n\n // return ArrayBuffer() when find a negative cycle\n def bellmanFord(edges : ArrayBuffer[(Int, Int, Long)], V : Int, s : Int, INF : Long) : Array[Long] = {\n val dist = Array.fill(V)(INF)\n dist(s) = 0L\n for (i <- 1 to V) {\n for ((from, to, cost) <- edges) {\n if(dist(from) != INF \n && (dist(from) + cost) < dist(to)) {\n dist(to) = (dist(from) + cost)\n if (i == V && to == V-1) return Array.empty\n }\n }\n }\n dist\n }\n}\n\nimport BellmanFord._\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 edges = ArrayBuffer[(Int, Int, Long)]()\n for (_ <- 1 to M) {\n val s, t = sc.nextInt\n val c : Long = sc.nextLong\n edges += ((s-1, t-1, -c))\n }\n // println(edges.toList)\n val res = bellmanFord(edges, N, 0, Long.MaxValue)\n // println(res.toList)\n if (res.isEmpty) println(\"inf\")\n else {\n println(-res(N-1))\n }\n }\n}", "language": "Scala", "metadata": {"date": 1550766181, "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/s427504091.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s427504091", "user_id": "u672765904"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "\nimport collection.mutable.ArrayBuffer\nimport scala.reflect.ClassTag\nimport scala.language.implicitConversions\n\ntrait Graph { \n case class Edge[T:Numeric](from : Int, to : Int, cost : T)\n\n class Edges[T:Numeric](val data : ArrayBuffer[Edge[T]]) {\n def size = data.size\n }\n object Edges {\n def apply[T:Numeric](xs : Edge[T]*) = new Edges(ArrayBuffer(xs:_*))\n implicit def toUnderLying[T](x:Edges[T]) = x.data\n }\n\n class WeightedGraph[T:Numeric](val size : Int, val data : Array[Edges[T]]) {\n def this(size : Int) = this(size, Array.fill(size)(Edges()))\n }\n object WeightedGraph {\n // def apply[T:Numeric](size : Int) = new WeightedGraph[T](size)\n implicit def toUnderLying[T](x:WeightedGraph[T]) = x.data\n }\n\n class UnWeightedGraph[T:Numeric](val size : Int, val data: Array[ArrayBuffer[T]]) {\n def this(size : Int) = this(size, Array.fill(size)(ArrayBuffer[T]()))\n }\n object UnWeightedGraph {\n // def apply[T:Numeric](size : Int) = new UnWeightedGraph[T](size)\n implicit def toUnderLying[T](x:UnWeightedGraph[T]) = x.data\n }\n \n class Matrix[T:Numeric:ClassTag](val row : Int, val col : Int, val data : Array[Array[T]]) {\n def this(row : Int, col : Int) = this(row, col, Array.fill(row, col)(implicitly[Numeric[T]].zero))\n def this(size : Int) = this(size, size)\n }\n object Matrix {\n implicit def toUnderLying[T](x:Matrix[T]) = x.data\n }\n}\n\n// object BellmanFord extends Graph {\n// import Edges._\n\n// // return ArrayBuffer() when find a negative cycle\n// def bellmanFord[T:ClassTag](edges : Edges[T], V : Int, s : Int, INF : T)(implicit num : Numeric[T]) : Array[T] = {\n// val dist = Array.fill[T](V)(INF)\n// dist(s) = num.zero\n// for (i <- 1 to V) {\n// for (e <- edges) {\n// if(dist(e.from) != INF \n// && num.lt(num.plus(dist(e.from), e.cost), dist(e.to))) {\n// dist(e.to) = num.plus(dist(e.from), e.cost)\n// if (i == V && e.to == V-1) return Array.empty\n// }\n// }\n// }\n// dist\n// }\n// }\n\nobject BellmanFord extends Graph {\n import Edges._\n\n // return ArrayBuffer() when find a negative cycle\n def bellmanFord(edges : ArrayBuffer[(Int, Int, Long)], V : Int, s : Int, INF : Long) : Array[Long] = {\n val dist = Array.fill(V)(INF)\n dist(s) = 0L\n for (i <- 1 to V) {\n for ((from, to, cost) <- edges) {\n if(dist(from) != INF \n && (dist(from) + cost) < dist(to)) {\n dist(to) = (dist(from) + cost)\n if (i == V && to == V-1) return Array.empty\n }\n }\n }\n dist\n }\n}\n\nimport BellmanFord._\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 edges = ArrayBuffer[(Int, Int, Long)]()\n for (_ <- 1 to M) {\n val s, t = sc.nextInt\n val c : Long = sc.nextLong\n edges += ((s-1, t-1, -c))\n }\n // println(edges.toList)\n val res = bellmanFord(edges, N, 0, Long.MaxValue)\n // println(res.toList)\n if (res.isEmpty) println(\"inf\")\n else {\n println(-res(N-1))\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 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,c = s.nextInt\n if (c == 0) \"YES\"\n else {\n def modByB(n: Int): Stream[Int] = ((a * n) % b) #:: modByB(n + 1)\n if (modByB(1).take(b-1).contains(c)) \"YES\"\n else \"NO\"\n }\n }\n\n val tests = List(\n \"\"\"7 5 1\"\"\" -> \"\"\"YES\"\"\",\n \"\"\"2 2 1\"\"\" -> \"\"\"NO\"\"\",\n \"\"\"1 100 97\"\"\" -> \"\"\"YES\"\"\",\n \"\"\"40 98 58\"\"\" -> \"\"\"YES\"\"\",\n \"\"\"77 42 36\"\"\" -> \"\"\"NO\"\"\"\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": 1561522707, "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/s614359869.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s614359869", "user_id": "u334087399"}, "prompt_components": {"gold_output": "YES\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,c = s.nextInt\n if (c == 0) \"YES\"\n else {\n def modByB(n: Int): Stream[Int] = ((a * n) % b) #:: modByB(n + 1)\n if (modByB(1).take(b-1).contains(c)) \"YES\"\n else \"NO\"\n }\n }\n\n val tests = List(\n \"\"\"7 5 1\"\"\" -> \"\"\"YES\"\"\",\n \"\"\"2 2 1\"\"\" -> \"\"\"NO\"\"\",\n \"\"\"1 100 97\"\"\" -> \"\"\"YES\"\"\",\n \"\"\"40 98 58\"\"\" -> \"\"\"YES\"\"\",\n \"\"\"77 42 36\"\"\" -> \"\"\"NO\"\"\"\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\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1088, "cpu_time_ms": 355, "memory_kb": 25672}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s281995860", "group_id": "codeNet:p03731", "input_text": "import scala.io.StdIn\nimport java.io.{BufferedReader,InputStreamReader}\n\nobject Main extends App {\n val in = new BufferedReader(new InputStreamReader(System.in))\n val Array(n, t) = in.readLine.split(\" \").map(_.toInt)\n val a = in.readLine.split(\" \")\n\n val ans = a.tail./:(t.toLong,0)((acc,e) => {\n val ti = e.toInt\n val dur = ti - acc._2\n if(dur < t) (ti + t, ti)\n else (acc._1 + t, ti)\n })._1\n\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1547260537, "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/s281995860.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s281995860", "user_id": "u217010036"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "import scala.io.StdIn\nimport java.io.{BufferedReader,InputStreamReader}\n\nobject Main extends App {\n val in = new BufferedReader(new InputStreamReader(System.in))\n val Array(n, t) = in.readLine.split(\" \").map(_.toInt)\n val a = in.readLine.split(\" \")\n\n val ans = a.tail./:(t.toLong,0)((acc,e) => {\n val ti = e.toInt\n val dur = ti - acc._2\n if(dur < t) (ti + t, ti)\n else (acc._1 + t, ti)\n })._1\n\n println(ans)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn a public bath, there is a shower which emits water for T seconds when the switch is pushed.\n\nIf the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds.\nNote that it does not mean that the shower emits water for T additional seconds.\n\nN people will push the switch while passing by the shower.\nThe i-th person will push the switch t_i seconds after the first person pushes it.\n\nHow long will the shower emit water in total?\n\nConstraints\n\n1 ≤ N ≤ 200,000\n\n1 ≤ T ≤ 10^9\n\n0 = t_1 < t_2 < t_3 < , ..., < t_{N-1} < t_N ≤ 10^9\n\nT and each t_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nt_1 t_2 ... t_N\n\nOutput\n\nAssume that the shower will emit water for a total of X seconds. Print X.\n\nSample Input 1\n\n2 4\n0 3\n\nSample Output 1\n\n7\n\nThree seconds after the first person pushes the water, the switch is pushed again and the shower emits water for four more seconds, for a total of seven seconds.\n\nSample Input 2\n\n2 4\n0 5\n\nSample Output 2\n\n8\n\nOne second after the shower stops emission of water triggered by the first person, the switch is pushed again.\n\nSample Input 3\n\n4 1000000000\n0 1000 1000000 1000000000\n\nSample Output 3\n\n2000000000\n\nSample Input 4\n\n1 1\n0\n\nSample Output 4\n\n1\n\nSample Input 5\n\n9 10\n0 3 5 7 100 110 200 300 311\n\nSample Output 5\n\n67", "sample_input": "2 4\n0 3\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03731", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn a public bath, there is a shower which emits water for T seconds when the switch is pushed.\n\nIf the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds.\nNote that it does not mean that the shower emits water for T additional seconds.\n\nN people will push the switch while passing by the shower.\nThe i-th person will push the switch t_i seconds after the first person pushes it.\n\nHow long will the shower emit water in total?\n\nConstraints\n\n1 ≤ N ≤ 200,000\n\n1 ≤ T ≤ 10^9\n\n0 = t_1 < t_2 < t_3 < , ..., < t_{N-1} < t_N ≤ 10^9\n\nT and each t_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nt_1 t_2 ... t_N\n\nOutput\n\nAssume that the shower will emit water for a total of X seconds. Print X.\n\nSample Input 1\n\n2 4\n0 3\n\nSample Output 1\n\n7\n\nThree seconds after the first person pushes the water, the switch is pushed again and the shower emits water for four more seconds, for a total of seven seconds.\n\nSample Input 2\n\n2 4\n0 5\n\nSample Output 2\n\n8\n\nOne second after the shower stops emission of water triggered by the first person, the switch is pushed again.\n\nSample Input 3\n\n4 1000000000\n0 1000 1000000 1000000000\n\nSample Output 3\n\n2000000000\n\nSample Input 4\n\n1 1\n0\n\nSample Output 4\n\n1\n\nSample Input 5\n\n9 10\n0 3 5 7 100 110 200 300 311\n\nSample Output 5\n\n67", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 427, "cpu_time_ms": 675, "memory_kb": 77280}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s332221110", "group_id": "codeNet:p03731", "input_text": "import scala.io.StdIn\nimport java.io.{BufferedReader,InputStreamReader}\n\nobject Main extends App {\n val in = new BufferedReader(new InputStreamReader(System.in))\n val Array(n, t) = in.readLine.split(\" \").map(_.toInt)\n val a = in.readLine.split(\" \")\n\n val ans = a.tail./:(t,0)((acc,e) => {\n val ti = e.toInt\n val dur = ti - acc._2\n if(dur < t) (ti + t, ti)\n else (acc._1 + t, ti)\n })._1\n\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1547260470, "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/s332221110.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s332221110", "user_id": "u217010036"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "import scala.io.StdIn\nimport java.io.{BufferedReader,InputStreamReader}\n\nobject Main extends App {\n val in = new BufferedReader(new InputStreamReader(System.in))\n val Array(n, t) = in.readLine.split(\" \").map(_.toInt)\n val a = in.readLine.split(\" \")\n\n val ans = a.tail./:(t,0)((acc,e) => {\n val ti = e.toInt\n val dur = ti - acc._2\n if(dur < t) (ti + t, ti)\n else (acc._1 + t, ti)\n })._1\n\n println(ans)\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn a public bath, there is a shower which emits water for T seconds when the switch is pushed.\n\nIf the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds.\nNote that it does not mean that the shower emits water for T additional seconds.\n\nN people will push the switch while passing by the shower.\nThe i-th person will push the switch t_i seconds after the first person pushes it.\n\nHow long will the shower emit water in total?\n\nConstraints\n\n1 ≤ N ≤ 200,000\n\n1 ≤ T ≤ 10^9\n\n0 = t_1 < t_2 < t_3 < , ..., < t_{N-1} < t_N ≤ 10^9\n\nT and each t_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nt_1 t_2 ... t_N\n\nOutput\n\nAssume that the shower will emit water for a total of X seconds. Print X.\n\nSample Input 1\n\n2 4\n0 3\n\nSample Output 1\n\n7\n\nThree seconds after the first person pushes the water, the switch is pushed again and the shower emits water for four more seconds, for a total of seven seconds.\n\nSample Input 2\n\n2 4\n0 5\n\nSample Output 2\n\n8\n\nOne second after the shower stops emission of water triggered by the first person, the switch is pushed again.\n\nSample Input 3\n\n4 1000000000\n0 1000 1000000 1000000000\n\nSample Output 3\n\n2000000000\n\nSample Input 4\n\n1 1\n0\n\nSample Output 4\n\n1\n\nSample Input 5\n\n9 10\n0 3 5 7 100 110 200 300 311\n\nSample Output 5\n\n67", "sample_input": "2 4\n0 3\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03731", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn a public bath, there is a shower which emits water for T seconds when the switch is pushed.\n\nIf the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds.\nNote that it does not mean that the shower emits water for T additional seconds.\n\nN people will push the switch while passing by the shower.\nThe i-th person will push the switch t_i seconds after the first person pushes it.\n\nHow long will the shower emit water in total?\n\nConstraints\n\n1 ≤ N ≤ 200,000\n\n1 ≤ T ≤ 10^9\n\n0 = t_1 < t_2 < t_3 < , ..., < t_{N-1} < t_N ≤ 10^9\n\nT and each t_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nt_1 t_2 ... t_N\n\nOutput\n\nAssume that the shower will emit water for a total of X seconds. Print X.\n\nSample Input 1\n\n2 4\n0 3\n\nSample Output 1\n\n7\n\nThree seconds after the first person pushes the water, the switch is pushed again and the shower emits water for four more seconds, for a total of seven seconds.\n\nSample Input 2\n\n2 4\n0 5\n\nSample Output 2\n\n8\n\nOne second after the shower stops emission of water triggered by the first person, the switch is pushed again.\n\nSample Input 3\n\n4 1000000000\n0 1000 1000000 1000000000\n\nSample Output 3\n\n2000000000\n\nSample Input 4\n\n1 1\n0\n\nSample Output 4\n\n1\n\nSample Input 5\n\n9 10\n0 3 5 7 100 110 200 300 311\n\nSample Output 5\n\n67", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 420, "cpu_time_ms": 687, "memory_kb": 77440}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s777028068", "group_id": "codeNet:p03737", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val s1, s2, s3 = sc.next().toUpperCase\n println(s\"${s1.head}${s2.head}${s3.head}\")\n}", "language": "Scala", "metadata": {"date": 1595602248, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/s777028068.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s777028068", "user_id": "u191819389"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val s1, s2, s3 = sc.next().toUpperCase\n println(s\"${s1.head}${s2.head}${s3.head}\")\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 491, "memory_kb": 55272}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s360408304", "group_id": "codeNet:p03738", "input_text": "import java.util.Scanner\n\nimport scala.collection.immutable.Range.BigInt\n\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val a, b = sc.nextBigInteger()\n \n val ans = if (a.compareTo(b)==1) \"GRATER\" else if (a.equals(b)) \"EQUAL\" else \"LESS\"\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}\n", "language": "Scala", "metadata": {"date": 1586802936, "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/s360408304.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s360408304", "user_id": "u336949031"}, "prompt_components": {"gold_output": "GREATER\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.collection.immutable.Range.BigInt\n\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val sc = new Scanner(System.in)\n val a, b = sc.nextBigInteger()\n \n val ans = if (a.compareTo(b)==1) \"GRATER\" else if (a.equals(b)) \"EQUAL\" else \"LESS\"\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}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given two positive integers A and B. Compare the magnitudes of these numbers.\n\nConstraints\n\n1 ≤ A, B ≤ 10^{100}\n\nNeither A nor B begins with a 0.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\n\nOutput\n\nPrint GREATER if A>B, LESS if A24, print GREATER.\n\nSample Input 2\n\n850\n3777\n\nSample Output 2\n\nLESS\n\nSample Input 3\n\n9720246\n22516266\n\nSample Output 3\n\nLESS\n\nSample Input 4\n\n123456789012345678901234567890\n234567890123456789012345678901\n\nSample Output 4\n\nLESS", "sample_input": "36\n24\n"}, "reference_outputs": ["GREATER\n"], "source_document_id": "p03738", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given two positive integers A and B. Compare the magnitudes of these numbers.\n\nConstraints\n\n1 ≤ A, B ≤ 10^{100}\n\nNeither A nor B begins with a 0.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\n\nOutput\n\nPrint GREATER if A>B, LESS if A24, print GREATER.\n\nSample Input 2\n\n850\n3777\n\nSample Output 2\n\nLESS\n\nSample Input 3\n\n9720246\n22516266\n\nSample Output 3\n\nLESS\n\nSample Input 4\n\n123456789012345678901234567890\n234567890123456789012345678901\n\nSample Output 4\n\nLESS", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 451, "cpu_time_ms": 341, "memory_kb": 27328}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s723740476", "group_id": "codeNet:p03760", "input_text": "\nobject Main extends App {\n\tvar odd = io.StdIn.readLine.toList\n//\tprintln(odd)\n\tvar even = io.StdIn.readLine.toList\n//\tprintln(even)\n\n\tval z = math.max(odd.size, even.size)\n\n\tvar list: List[Char] = List()\n\n\tfor(i <- 0 until z){\n\t\tlist = list :+ odd.head\n\t\tlist = list :+ even.head\n\t\todd = odd.drop(1)\n\t\teven = even.drop(1)\n\t}\n\n\tprintln(list.mkString)\n\n\n}", "language": "Scala", "metadata": {"date": 1493394804, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03760.html", "problem_id": "p03760", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03760/input.txt", "sample_output_relpath": "derived/input_output/data/p03760/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03760/Scala/s723740476.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s723740476", "user_id": "u675876401"}, "prompt_components": {"gold_output": "xaybzc\n", "input_to_evaluate": "\nobject Main extends App {\n\tvar odd = io.StdIn.readLine.toList\n//\tprintln(odd)\n\tvar even = io.StdIn.readLine.toList\n//\tprintln(even)\n\n\tval z = math.max(odd.size, even.size)\n\n\tvar list: List[Char] = List()\n\n\tfor(i <- 0 until z){\n\t\tlist = list :+ odd.head\n\t\tlist = list :+ even.head\n\t\todd = odd.drop(1)\n\t\teven = even.drop(1)\n\t}\n\n\tprintln(list.mkString)\n\n\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSnuke signed up for a new website which holds programming competitions.\nHe worried that he might forget his password, and he took notes of it.\nSince directly recording his password would cause him trouble if stolen,\nhe took two notes: one contains the characters at the odd-numbered positions, and the other contains the characters at the even-numbered positions.\n\nYou are given two strings O and E. O contains the characters at the odd-numbered positions retaining their relative order, and E contains the characters at the even-numbered positions retaining their relative order.\nRestore the original password.\n\nConstraints\n\nO and E consists of lowercase English letters (a - z).\n\n1 \\leq |O|,|E| \\leq 50\n\n|O| - |E| is either 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nO\nE\n\nOutput\n\nPrint the original password.\n\nSample Input 1\n\nxyz\nabc\n\nSample Output 1\n\nxaybzc\n\nThe original password is xaybzc. Extracting the characters at the odd-numbered positions results in xyz, and extracting the characters at the even-numbered positions results in abc.\n\nSample Input 2\n\natcoderbeginnercontest\natcoderregularcontest\n\nSample Output 2\n\naattccooddeerrbreeggiunlnaerrccoonntteesstt", "sample_input": "xyz\nabc\n"}, "reference_outputs": ["xaybzc\n"], "source_document_id": "p03760", "source_text": "Score : 200 points\n\nProblem Statement\n\nSnuke signed up for a new website which holds programming competitions.\nHe worried that he might forget his password, and he took notes of it.\nSince directly recording his password would cause him trouble if stolen,\nhe took two notes: one contains the characters at the odd-numbered positions, and the other contains the characters at the even-numbered positions.\n\nYou are given two strings O and E. O contains the characters at the odd-numbered positions retaining their relative order, and E contains the characters at the even-numbered positions retaining their relative order.\nRestore the original password.\n\nConstraints\n\nO and E consists of lowercase English letters (a - z).\n\n1 \\leq |O|,|E| \\leq 50\n\n|O| - |E| is either 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nO\nE\n\nOutput\n\nPrint the original password.\n\nSample Input 1\n\nxyz\nabc\n\nSample Output 1\n\nxaybzc\n\nThe original password is xaybzc. Extracting the characters at the odd-numbered positions results in xyz, and extracting the characters at the even-numbered positions results in abc.\n\nSample Input 2\n\natcoderbeginnercontest\natcoderregularcontest\n\nSample Output 2\n\naattccooddeerrbreeggiunlnaerrccoonntteesstt", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 354, "cpu_time_ms": 348, "memory_kb": 25380}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s437250192", "group_id": "codeNet:p03767", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n import scala.io.StdIn.readLine\n val datN = readLine.split(\" \").map(_.toInt).head\n val datA = readLine.split(\" \").map(_.toLong).toList\n\n val ans = datA.sorted.reverse.slice(0, datN * 2).zipWithIndex.filter(_._2 % 2 == 1).map(_._1).sum\n\n println(ans)\n }\n}\n", "language": "Scala", "metadata": {"date": 1588359883, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "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/s437250192.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s437250192", "user_id": "u014716041"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n import scala.io.StdIn.readLine\n val datN = readLine.split(\" \").map(_.toInt).head\n val datA = readLine.split(\" \").map(_.toLong).toList\n\n val ans = datA.sorted.reverse.slice(0, datN * 2).zipWithIndex.filter(_._2 % 2 == 1).map(_._1).sum\n\n println(ans)\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are 3N participants in AtCoder Group Contest.\nThe strength of the i-th participant is represented by an integer a_i.\nThey will form N teams, each consisting of three participants.\nNo participant may belong to multiple teams.\n\nThe strength of a team is defined as the second largest strength among its members.\nFor example, a team of participants of strength 1, 5, 2 has a strength 2, and a team of three participants of strength 3, 2, 3 has a strength 3.\n\nFind the maximum possible sum of the strengths of N teams.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ 10^{9}\n\na_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_{3N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2\n5 2 8 5 1 5\n\nSample Output 1\n\n10\n\nThe following is one formation of teams that maximizes the sum of the strengths of teams:\n\nTeam 1: consists of the first, fourth and fifth participants.\n\nTeam 2: consists of the second, third and sixth participants.\n\nSample Input 2\n\n10\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n\nSample Output 2\n\n10000000000\n\nThe sum of the strengths can be quite large.", "sample_input": "2\n5 2 8 5 1 5\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03767", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are 3N participants in AtCoder Group Contest.\nThe strength of the i-th participant is represented by an integer a_i.\nThey will form N teams, each consisting of three participants.\nNo participant may belong to multiple teams.\n\nThe strength of a team is defined as the second largest strength among its members.\nFor example, a team of participants of strength 1, 5, 2 has a strength 2, and a team of three participants of strength 3, 2, 3 has a strength 3.\n\nFind the maximum possible sum of the strengths of N teams.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ 10^{9}\n\na_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_{3N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2\n5 2 8 5 1 5\n\nSample Output 1\n\n10\n\nThe following is one formation of teams that maximizes the sum of the strengths of teams:\n\nTeam 1: consists of the first, fourth and fifth participants.\n\nTeam 2: consists of the second, third and sixth participants.\n\nSample Input 2\n\n10\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n\nSample Output 2\n\n10000000000\n\nThe sum of the strengths can be quite large.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 327, "cpu_time_ms": 1372, "memory_kb": 113120}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s298718962", "group_id": "codeNet:p03774", "input_text": "import io.StdIn._\nobject Main extends App {\n val Array(n, m) = readLine.split(\" \").map(_.toInt)\n val abs = for(count <- 1 to n) yield readLine.split(\" \").map(_.toLong)\n val cds = for(count <- 1 to m) yield readLine.split(\" \").map(_.toLong)\n\n for(ab <- abs) {\n val manhattans = cds.map(cd => (ab.head - cd.head).abs + (ab.last - cd.last).abs)\n val min = manhattans.min\n val index = manhattans.indexOf(min)\n println(index+1)\n }\n}", "language": "Scala", "metadata": {"date": 1591854574, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03774.html", "problem_id": "p03774", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03774/input.txt", "sample_output_relpath": "derived/input_output/data/p03774/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03774/Scala/s298718962.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s298718962", "user_id": "u104354966"}, "prompt_components": {"gold_output": "2\n1\n", "input_to_evaluate": "import io.StdIn._\nobject Main extends App {\n val Array(n, m) = readLine.split(\" \").map(_.toInt)\n val abs = for(count <- 1 to n) yield readLine.split(\" \").map(_.toLong)\n val cds = for(count <- 1 to m) yield readLine.split(\" \").map(_.toLong)\n\n for(ab <- abs) {\n val manhattans = cds.map(cd => (ab.head - cd.head).abs + (ab.last - cd.last).abs)\n val min = manhattans.min\n val index = manhattans.indexOf(min)\n println(index+1)\n }\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N students and M checkpoints on the xy-plane.\n\nThe coordinates of the i-th student (1 \\leq i \\leq N) is (a_i,b_i), and the coordinates of the checkpoint numbered j (1 \\leq j \\leq M) is (c_j,d_j).\n\nWhen the teacher gives a signal, each student has to go to the nearest checkpoint measured in Manhattan distance.\n\nThe Manhattan distance between two points (x_1,y_1) and (x_2,y_2) is |x_1-x_2|+|y_1-y_2|.\n\nHere, |x| denotes the absolute value of x.\n\nIf there are multiple nearest checkpoints for a student, he/she will select the checkpoint with the smallest index.\n\nWhich checkpoint will each student go to?\n\nConstraints\n\n1 \\leq N,M \\leq 50\n\n-10^8 \\leq a_i,b_i,c_j,d_j \\leq 10^8\n\nAll input values are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\na_1 b_1\n:\na_N b_N\nc_1 d_1\n:\nc_M d_M\n\nOutput\n\nPrint N lines.\n\nThe i-th line (1 \\leq i \\leq N) should contain the index of the checkpoint for the i-th student to go.\n\nSample Input 1\n\n2 2\n2 0\n0 0\n-1 0\n1 0\n\nSample Output 1\n\n2\n1\n\nThe Manhattan distance between the first student and each checkpoint is:\n\nFor checkpoint 1: |2-(-1)|+|0-0|=3\n\nFor checkpoint 2: |2-1|+|0-0|=1\n\nThe nearest checkpoint is checkpoint 2. Thus, the first line in the output should contain 2.\n\nThe Manhattan distance between the second student and each checkpoint is:\n\nFor checkpoint 1: |0-(-1)|+|0-0|=1\n\nFor checkpoint 2: |0-1|+|0-0|=1\n\nWhen there are multiple nearest checkpoints, the student will go to the checkpoint with the smallest index. Thus, the second line in the output should contain 1.\n\nSample Input 2\n\n3 4\n10 10\n-10 -10\n3 3\n1 2\n2 3\n3 5\n3 5\n\nSample Output 2\n\n3\n1\n2\n\nThere can be multiple checkpoints at the same coordinates.\n\nSample Input 3\n\n5 5\n-100000000 -100000000\n-100000000 100000000\n100000000 -100000000\n100000000 100000000\n0 0\n0 0\n100000000 100000000\n100000000 -100000000\n-100000000 100000000\n-100000000 -100000000\n\nSample Output 3\n\n5\n4\n3\n2\n1", "sample_input": "2 2\n2 0\n0 0\n-1 0\n1 0\n"}, "reference_outputs": ["2\n1\n"], "source_document_id": "p03774", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N students and M checkpoints on the xy-plane.\n\nThe coordinates of the i-th student (1 \\leq i \\leq N) is (a_i,b_i), and the coordinates of the checkpoint numbered j (1 \\leq j \\leq M) is (c_j,d_j).\n\nWhen the teacher gives a signal, each student has to go to the nearest checkpoint measured in Manhattan distance.\n\nThe Manhattan distance between two points (x_1,y_1) and (x_2,y_2) is |x_1-x_2|+|y_1-y_2|.\n\nHere, |x| denotes the absolute value of x.\n\nIf there are multiple nearest checkpoints for a student, he/she will select the checkpoint with the smallest index.\n\nWhich checkpoint will each student go to?\n\nConstraints\n\n1 \\leq N,M \\leq 50\n\n-10^8 \\leq a_i,b_i,c_j,d_j \\leq 10^8\n\nAll input values are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\na_1 b_1\n:\na_N b_N\nc_1 d_1\n:\nc_M d_M\n\nOutput\n\nPrint N lines.\n\nThe i-th line (1 \\leq i \\leq N) should contain the index of the checkpoint for the i-th student to go.\n\nSample Input 1\n\n2 2\n2 0\n0 0\n-1 0\n1 0\n\nSample Output 1\n\n2\n1\n\nThe Manhattan distance between the first student and each checkpoint is:\n\nFor checkpoint 1: |2-(-1)|+|0-0|=3\n\nFor checkpoint 2: |2-1|+|0-0|=1\n\nThe nearest checkpoint is checkpoint 2. Thus, the first line in the output should contain 2.\n\nThe Manhattan distance between the second student and each checkpoint is:\n\nFor checkpoint 1: |0-(-1)|+|0-0|=1\n\nFor checkpoint 2: |0-1|+|0-0|=1\n\nWhen there are multiple nearest checkpoints, the student will go to the checkpoint with the smallest index. Thus, the second line in the output should contain 1.\n\nSample Input 2\n\n3 4\n10 10\n-10 -10\n3 3\n1 2\n2 3\n3 5\n3 5\n\nSample Output 2\n\n3\n1\n2\n\nThere can be multiple checkpoints at the same coordinates.\n\nSample Input 3\n\n5 5\n-100000000 -100000000\n-100000000 100000000\n100000000 -100000000\n100000000 100000000\n0 0\n0 0\n100000000 100000000\n100000000 -100000000\n-100000000 100000000\n-100000000 -100000000\n\nSample Output 3\n\n5\n4\n3\n2\n1", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 470, "cpu_time_ms": 366, "memory_kb": 27440}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s763480631", "group_id": "codeNet:p03775", "input_text": "object Main extends App {\n val n = scala.io.StdIn.readLong()\n var a = 0L\n for (i <- 1 to Math.sqrt(n).toInt) {\n if (n % i == 0) {\n a = i\n }\n }\n\n println((n / a).toString.length)\n}\n", "language": "Scala", "metadata": {"date": 1586222257, "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/s763480631.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s763480631", "user_id": "u393913844"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main extends App {\n val n = scala.io.StdIn.readLong()\n var a = 0L\n for (i <- 1 to Math.sqrt(n).toInt) {\n if (n % i == 0) {\n a = i\n }\n }\n\n println((n / a).toString.length)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N.\n\nFor two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.\n\nFor example, F(3,11) = 2 since 3 has one digit and 11 has two digits.\n\nFind the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \\times B.\n\nConstraints\n\n1 \\leq N \\leq 10^{10}\n\nN is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \\times B.\n\nSample Input 1\n\n10000\n\nSample Output 1\n\n3\n\nF(A,B) has a minimum value of 3 at (A,B)=(100,100).\n\nSample Input 2\n\n1000003\n\nSample Output 2\n\n7\n\nThere are two pairs (A,B) that satisfy the condition: (1,1000003) and (1000003,1). For these pairs, F(1,1000003)=F(1000003,1)=7.\n\nSample Input 3\n\n9876543210\n\nSample Output 3\n\n6", "sample_input": "10000\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03775", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N.\n\nFor two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.\n\nFor example, F(3,11) = 2 since 3 has one digit and 11 has two digits.\n\nFind the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \\times B.\n\nConstraints\n\n1 \\leq N \\leq 10^{10}\n\nN is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum value of F(A,B) as (A,B) ranges over all pairs of positive integers such that N = A \\times B.\n\nSample Input 1\n\n10000\n\nSample Output 1\n\n3\n\nF(A,B) has a minimum value of 3 at (A,B)=(100,100).\n\nSample Input 2\n\n1000003\n\nSample Output 2\n\n7\n\nThere are two pairs (A,B) that satisfy the condition: (1,1000003) and (1000003,1). For these pairs, F(1,1000003)=F(1000003,1)=7.\n\nSample Input 3\n\n9876543210\n\nSample Output 3\n\n6", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 196, "cpu_time_ms": 329, "memory_kb": 27200}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s202529643", "group_id": "codeNet:p03776", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n, a, b = sc.nextInt()\n val v = Array.fill(n)(sc.nextLong()).sorted\n val max = v.takeRight(a).sum.toDouble / a\n val x = v(n-a)\n val m = v.count(_ == x)\n val k = v.takeRight(a).count(_ == x)\n\n def initCombTable(n: Int): Array[Array[Long]] = {\n val comb = Array.tabulate(n+1)(i => Array.fill(i+1)(1L))\n for {\n i <- 1 to n\n j <- 1 until i\n } {\n comb(i)(j) = comb(i-1)(j-1) + comb(i-1)(j)\n }\n comb\n }\n\n val comb = initCombTable(m)\n\n val ans = if (v.takeRight(a).distinct.length == 1) {\n (k to k + (b - a).min(m - k)).map(comb(m)(_)).sum\n } else {\n comb(m)(k)\n }\n\n println(f\"$max%f\")\n println(ans)\n}\n", "language": "Scala", "metadata": {"date": 1595557888, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/s202529643.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s202529643", "user_id": "u191819389"}, "prompt_components": {"gold_output": "4.500000\n1\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val n, a, b = sc.nextInt()\n val v = Array.fill(n)(sc.nextLong()).sorted\n val max = v.takeRight(a).sum.toDouble / a\n val x = v(n-a)\n val m = v.count(_ == x)\n val k = v.takeRight(a).count(_ == x)\n\n def initCombTable(n: Int): Array[Array[Long]] = {\n val comb = Array.tabulate(n+1)(i => Array.fill(i+1)(1L))\n for {\n i <- 1 to n\n j <- 1 until i\n } {\n comb(i)(j) = comb(i-1)(j-1) + comb(i-1)(j)\n }\n comb\n }\n\n val comb = initCombTable(m)\n\n val ans = if (v.takeRight(a).distinct.length == 1) {\n (k to k + (b - a).min(m - k)).map(comb(m)(_)).sum\n } else {\n comb(m)(k)\n }\n\n println(f\"$max%f\")\n println(ans)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 720, "cpu_time_ms": 514, "memory_kb": 55888}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s071985718", "group_id": "codeNet:p03777", "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 = (a,b) match{\n case (\"H\",\"H\") => \"H\"\n case (\"H\",\"D\") => \"D\"\n case (\"D\",\"H\") => \"D\"\n case (\"D\",\"D\") => \"H\"\n }\n\n println(res)\n}", "language": "Scala", "metadata": {"date": 1556279719, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03777.html", "problem_id": "p03777", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03777/input.txt", "sample_output_relpath": "derived/input_output/data/p03777/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03777/Scala/s071985718.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s071985718", "user_id": "u829407811"}, "prompt_components": {"gold_output": "H\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 = (a,b) match{\n case (\"H\",\"H\") => \"H\"\n case (\"H\",\"D\") => \"D\"\n case (\"D\",\"H\") => \"D\"\n case (\"D\",\"D\") => \"H\"\n }\n\n println(res)\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTwo deer, AtCoDeer and TopCoDeer, are playing a game called Honest or Dishonest.\nIn this game, an honest player always tells the truth, and an dishonest player always tell lies.\nYou are given two characters a and b as the input. Each of them is either H or D, and carries the following information:\n\nIf a=H, AtCoDeer is honest; if a=D, AtCoDeer is dishonest.\nIf b=H, AtCoDeer is saying that TopCoDeer is honest; if b=D, AtCoDeer is saying that TopCoDeer is dishonest.\n\nGiven this information, determine whether TopCoDeer is honest.\n\nConstraints\n\na=H or a=D.\n\nb=H or b=D.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf TopCoDeer is honest, print H. If he is dishonest, print D.\n\nSample Input 1\n\nH H\n\nSample Output 1\n\nH\n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\nSample Input 2\n\nD H\n\nSample Output 2\n\nD\n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says, TopCoDeer is dishonest.\n\nSample Input 3\n\nD D\n\nSample Output 3\n\nH", "sample_input": "H H\n"}, "reference_outputs": ["H\n"], "source_document_id": "p03777", "source_text": "Score : 100 points\n\nProblem Statement\n\nTwo deer, AtCoDeer and TopCoDeer, are playing a game called Honest or Dishonest.\nIn this game, an honest player always tells the truth, and an dishonest player always tell lies.\nYou are given two characters a and b as the input. Each of them is either H or D, and carries the following information:\n\nIf a=H, AtCoDeer is honest; if a=D, AtCoDeer is dishonest.\nIf b=H, AtCoDeer is saying that TopCoDeer is honest; if b=D, AtCoDeer is saying that TopCoDeer is dishonest.\n\nGiven this information, determine whether TopCoDeer is honest.\n\nConstraints\n\na=H or a=D.\n\nb=H or b=D.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf TopCoDeer is honest, print H. If he is dishonest, print D.\n\nSample Input 1\n\nH H\n\nSample Output 1\n\nH\n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\nSample Input 2\n\nD H\n\nSample Output 2\n\nD\n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says, TopCoDeer is dishonest.\n\nSample Input 3\n\nD D\n\nSample Output 3\n\nH", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 275, "cpu_time_ms": 364, "memory_kb": 27984}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s422460279", "group_id": "codeNet:p03779", "input_text": "import scala.io.StdIn._\nobject Main extends App {\n val x = readLong\n println(binSearch(500000000, 1, 1000000000))\n\n @scala.annotation.tailrec\n def binSearch(n: Long, l: Long, r: Long): Long = {\n val (min, max) = range(n)\n if (min < x && x <= max) n\n else if (x <= min) binSearch((l + n) / 2, l, n)\n else binSearch((r + n) / 2, n, r)\n }\n\n def range(n: Long): (Long, Long) = {\n val sum = n * (n + 1) / 2\n (sum - n, sum)\n }\n}\n", "language": "Scala", "metadata": {"date": 1490363760, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03779.html", "problem_id": "p03779", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03779/input.txt", "sample_output_relpath": "derived/input_output/data/p03779/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03779/Scala/s422460279.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s422460279", "user_id": "u132324749"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import scala.io.StdIn._\nobject Main extends App {\n val x = readLong\n println(binSearch(500000000, 1, 1000000000))\n\n @scala.annotation.tailrec\n def binSearch(n: Long, l: Long, r: Long): Long = {\n val (min, max) = range(n)\n if (min < x && x <= max) n\n else if (x <= min) binSearch((l + n) / 2, l, n)\n else binSearch((r + n) / 2, n, r)\n }\n\n def range(n: Long): (Long, Long) = {\n val sum = n * (n + 1) / 2\n (sum - n, sum)\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0.\nDuring the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right.\nThat is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i.\nThe kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible.\nFind the earliest possible time to reach coordinate X.\n\nConstraints\n\nX is an integer.\n\n1≤X≤10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the earliest possible time for the kangaroo to reach coordinate X.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n3\n\nThe kangaroo can reach his nest at time 3 by jumping to the right three times, which is the earliest possible time.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n2\n\nHe can reach his nest at time 2 by staying at his position during the first second, and jumping to the right at the next second.\n\nSample Input 3\n\n11\n\nSample Output 3\n\n5", "sample_input": "6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03779", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0.\nDuring the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right.\nThat is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i.\nThe kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible.\nFind the earliest possible time to reach coordinate X.\n\nConstraints\n\nX is an integer.\n\n1≤X≤10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the earliest possible time for the kangaroo to reach coordinate X.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n3\n\nThe kangaroo can reach his nest at time 3 by jumping to the right three times, which is the earliest possible time.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n2\n\nHe can reach his nest at time 2 by staying at his position during the first second, and jumping to the right at the next second.\n\nSample Input 3\n\n11\n\nSample Output 3\n\n5", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 448, "cpu_time_ms": 320, "memory_kb": 25408}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s363294198", "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 val t_list = t.toList\n \n var ans = 0\n var i = 0\n \n while (i < n) {\n ans += 1\n val c_th_id = t(Array(n-1,i+c-1).min)\n val num_within_k = t_list.drop(i).takeWhile{_ <= t(i)+k}.length\n \n if(c <= num_within_k) i += c else i += num_within_k\n }\n \n println(ans)\n}", "language": "Scala", "metadata": {"date": 1577120719, "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/s363294198.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s363294198", "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 val t_list = t.toList\n \n var ans = 0\n var i = 0\n \n while (i < n) {\n ans += 1\n val c_th_id = t(Array(n-1,i+c-1).min)\n val num_within_k = t_list.drop(i).takeWhile{_ <= t(i)+k}.length\n \n if(c <= num_within_k) i += c else i += num_within_k\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 413, "cpu_time_ms": 2111, "memory_kb": 86200}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s607256774", "group_id": "codeNet:p03795", "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 n = sc.nextInt\n// val list = List.fill(3)(sc.next)\n\n val paid = n * 800\n val received = n / 15 * 200\n val ans = paid - received\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": 1562690293, "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/s607256774.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s607256774", "user_id": "u040380439"}, "prompt_components": {"gold_output": "15800\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 n = sc.nextInt\n// val list = List.fill(3)(sc.next)\n\n val paid = n * 800\n val received = n / 15 * 200\n val ans = paid - received\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\nSnuke has a favorite restaurant.\n\nThe price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer.\n\nSo far, Snuke has ordered N meals at the restaurant.\nLet the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen.\nFind x-y.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n20\n\nSample Output 1\n\n15800\n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen. Thus, the answer is 15800.\n\nSample Input 2\n\n60\n\nSample Output 2\n\n47200\n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800 yen.", "sample_input": "20\n"}, "reference_outputs": ["15800\n"], "source_document_id": "p03795", "source_text": "Score : 100 points\n\nProblem Statement\n\nSnuke has a favorite restaurant.\n\nThe price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer.\n\nSo far, Snuke has ordered N meals at the restaurant.\nLet the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen.\nFind x-y.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n20\n\nSample Output 1\n\n15800\n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen. Thus, the answer is 15800.\n\nSample Input 2\n\n60\n\nSample Output 2\n\n47200\n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800 yen.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1014, "cpu_time_ms": 350, "memory_kb": 25428}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s118489910", "group_id": "codeNet:p03808", "input_text": "object Main {\n\n import scala.math._\n\n def main(args: Array[String]) {\n\n val sc = new java.util.Scanner(System.in)\n\n val n = sc.nextInt()\n val arr = Array.fill(n)(sc.nextInt())\n\n if (check(arr)) println(\"YES\")\n else println(\"NO\")\n\n }\n def check(arr: Array[Int]): Boolean = {\n val n = arr.length\n def f(arr: Array[Int]): Boolean = {\n def calc(idx: Int, max_idx: Int): Int = {\n if (idx-max_idx > 0 ) arr(idx) - (idx - max_idx)\n else arr(idx)-(n + idx - max_idx)\n }\n def is_all_0(arr: Array[Int]): Boolean = {\n if (arr.filter(_ != 0).isEmpty) true\n else false\n }\n def exist_not_positive(arr: Array[Int]): Boolean = {\n if (arr.filter(_ < 1).length > 0) true\n else false\n }\n val max_idx = (0 until n).toList.maxBy(arr(_))\n val new_arr = (0 until n).toArray.map(calc(_, max_idx))\n\n if (is_all_0(new_arr)) true\n else if (exist_not_positive(new_arr)) false\n else f(new_arr)\n }\n f(arr)\n }\n}", "language": "Scala", "metadata": {"date": 1486262497, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03808.html", "problem_id": "p03808", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03808/input.txt", "sample_output_relpath": "derived/input_output/data/p03808/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03808/Scala/s118489910.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s118489910", "user_id": "u313766957"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "object Main {\n\n import scala.math._\n\n def main(args: Array[String]) {\n\n val sc = new java.util.Scanner(System.in)\n\n val n = sc.nextInt()\n val arr = Array.fill(n)(sc.nextInt())\n\n if (check(arr)) println(\"YES\")\n else println(\"NO\")\n\n }\n def check(arr: Array[Int]): Boolean = {\n val n = arr.length\n def f(arr: Array[Int]): Boolean = {\n def calc(idx: Int, max_idx: Int): Int = {\n if (idx-max_idx > 0 ) arr(idx) - (idx - max_idx)\n else arr(idx)-(n + idx - max_idx)\n }\n def is_all_0(arr: Array[Int]): Boolean = {\n if (arr.filter(_ != 0).isEmpty) true\n else false\n }\n def exist_not_positive(arr: Array[Int]): Boolean = {\n if (arr.filter(_ < 1).length > 0) true\n else false\n }\n val max_idx = (0 until n).toList.maxBy(arr(_))\n val new_arr = (0 until n).toArray.map(calc(_, max_idx))\n\n if (is_all_0(new_arr)) true\n else if (exist_not_positive(new_arr)) false\n else f(new_arr)\n }\n f(arr)\n }\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N boxes arranged in a circle. The i-th box contains A_i stones.\n\nDetermine whether it is possible to remove all the stones from the boxes by repeatedly performing the following operation:\n\nSelect one box. Let the box be the i-th box. Then, for each j from 1 through N, remove exactly j stones from the (i+j)-th box. Here, the (N+k)-th box is identified with the k-th box.\n\nNote that the operation cannot be performed if there is a box that does not contain enough number of stones to be removed.\n\nConstraints\n\n1 ≦ N ≦ 10^5\n\n1 ≦ A_i ≦ 10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 A_2 … A_N\n\nOutput\n\nIf it is possible to remove all the stones from the boxes, print YES. Otherwise, print NO.\n\nSample Input 1\n\n5\n4 5 1 2 3\n\nSample Output 1\n\nYES\n\nAll the stones can be removed in one operation by selecting the second box.\n\nSample Input 2\n\n5\n6 9 12 10 8\n\nSample Output 2\n\nYES\n\nSample Input 3\n\n4\n1 2 3 1\n\nSample Output 3\n\nNO", "sample_input": "5\n4 5 1 2 3\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03808", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N boxes arranged in a circle. The i-th box contains A_i stones.\n\nDetermine whether it is possible to remove all the stones from the boxes by repeatedly performing the following operation:\n\nSelect one box. Let the box be the i-th box. Then, for each j from 1 through N, remove exactly j stones from the (i+j)-th box. Here, the (N+k)-th box is identified with the k-th box.\n\nNote that the operation cannot be performed if there is a box that does not contain enough number of stones to be removed.\n\nConstraints\n\n1 ≦ N ≦ 10^5\n\n1 ≦ A_i ≦ 10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 A_2 … A_N\n\nOutput\n\nIf it is possible to remove all the stones from the boxes, print YES. Otherwise, print NO.\n\nSample Input 1\n\n5\n4 5 1 2 3\n\nSample Output 1\n\nYES\n\nAll the stones can be removed in one operation by selecting the second box.\n\nSample Input 2\n\n5\n6 9 12 10 8\n\nSample Output 2\n\nYES\n\nSample Input 3\n\n4\n1 2 3 1\n\nSample Output 3\n\nNO", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1009, "cpu_time_ms": 2102, "memory_kb": 122120}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s241391524", "group_id": "codeNet:p03813", "input_text": "object Main {\n\n val scanner = new java.util.Scanner(System.in)\n\n def main(args: Array[String]): Unit = {\n val target = scanner.nextInt()\n if (target < 1200) {\n println(\"ARC\")\n } else {\n println(\"ABC\")\n }\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1487038367, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03813.html", "problem_id": "p03813", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03813/input.txt", "sample_output_relpath": "derived/input_output/data/p03813/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03813/Scala/s241391524.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s241391524", "user_id": "u736419992"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "object Main {\n\n val scanner = new java.util.Scanner(System.in)\n\n def main(args: Array[String]): Unit = {\n val target = scanner.nextInt()\n if (target < 1200) {\n println(\"ARC\")\n } else {\n println(\"ABC\")\n }\n }\n\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSmeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise.\n\nYou are given Smeke's current rating, x. Print ABC if Smeke will participate in ABC, and print ARC otherwise.\n\nConstraints\n\n1 ≦ x ≦ 3{,}000\n\nx is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nx\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1000\n\nSample Output 1\n\nABC\n\nSmeke's current rating is less than 1200, thus the output should be ABC.\n\nSample Input 2\n\n2000\n\nSample Output 2\n\nARC\n\nSmeke's current rating is not less than 1200, thus the output should be ARC.", "sample_input": "1000\n"}, "reference_outputs": ["ABC\n"], "source_document_id": "p03813", "source_text": "Score : 100 points\n\nProblem Statement\n\nSmeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise.\n\nYou are given Smeke's current rating, x. Print ABC if Smeke will participate in ABC, and print ARC otherwise.\n\nConstraints\n\n1 ≦ x ≦ 3{,}000\n\nx is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nx\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1000\n\nSample Output 1\n\nABC\n\nSmeke's current rating is less than 1200, thus the output should be ABC.\n\nSample Input 2\n\n2000\n\nSample Output 2\n\nARC\n\nSmeke's current rating is not less than 1200, thus the output should be ARC.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 235, "cpu_time_ms": 438, "memory_kb": 22072}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s814211373", "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 @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, m = ni()\n val (l, r) = na2(n)\n\n val ans = Array.ofDim[Int](m + 2)\n val rt = math.sqrt(m).toInt\n debug(s\"rt:$rt\")\n REP(rt, 1) { d =>\n REP(n) { i =>\n val j = (l(i)-1) / d * d\n if (j + d <= r(i)) {\n ans(d) += 1\n ans(d + 1) -= 1\n }\n }\n }\n\n REP(n) { i =>\n REP(rt + 1, 1) { x =>\n var r0 = 0\n val l1 = (l(i) + x - 1) / x\n val r1 = r(i) / x\n val l2 = max(rt + 1, max(r0, l1)) // rtまで計算ずみ\n debug(s\"i:$i x:$x l1:$l1 r1:$r1 l2:$l2\")\n if (l2 <= r1) {\n ans(l2) += 1\n ans(r1 + 1) -= 1\n }\n r0 = r1 + 1\n }\n }\n\n REP(m) { i =>\n ans(i + 1) += ans(i)\n }\n\n debug(ans)\n\n REP(m, 1) { d =>\n out.println(ans(d))\n }\n }\n}", "language": "Scala", "metadata": {"date": 1568775767, "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/s814211373.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s814211373", "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 @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, m = ni()\n val (l, r) = na2(n)\n\n val ans = Array.ofDim[Int](m + 2)\n val rt = math.sqrt(m).toInt\n debug(s\"rt:$rt\")\n REP(rt, 1) { d =>\n REP(n) { i =>\n val j = (l(i)-1) / d * d\n if (j + d <= r(i)) {\n ans(d) += 1\n ans(d + 1) -= 1\n }\n }\n }\n\n REP(n) { i =>\n REP(rt + 1, 1) { x =>\n var r0 = 0\n val l1 = (l(i) + x - 1) / x\n val r1 = r(i) / x\n val l2 = max(rt + 1, max(r0, l1)) // rtまで計算ずみ\n debug(s\"i:$i x:$x l1:$l1 r1:$r1 l2:$l2\")\n if (l2 <= r1) {\n ans(l2) += 1\n ans(r1 + 1) -= 1\n }\n r0 = r1 + 1\n }\n }\n\n REP(m) { i =>\n ans(i + 1) += ans(i)\n }\n\n debug(ans)\n\n REP(m, 1) { d =>\n out.println(ans(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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4676, "cpu_time_ms": 2111, "memory_kb": 58000}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s347111059", "group_id": "codeNet:p03819", "input_text": "class FenwickTree(val n:Int, init:Int) {\n val dat = new Array[Int](n+1)\n for (i <- 1 to n) add(i, init)\n\n def this(n:Int) {\n this(n, 0)\n }\n\n def add(_idx:Int, value:Int) {\n var idx = _idx+1\n while(idx <= n) {\n dat(idx) += value\n idx += idx & -idx\n }\n }\n\n def query(_l:Int, _r:Int):Int = {\n var ans = 0\n var r = _r+1\n var l = _l+1\n while(r > 0) {\n ans += dat(r)\n r -= r & -r\n }\n while(l > 0) {\n ans -= dat(l)\n l -= l & -l\n }\n return ans\n }\n}\n\nobject Main {\n def main(args: Array[String]) {\n val Array(n,m) = scala.io.StdIn.readLine().split(' ').map(_.toInt)\n val intervals = for(i <- Range(0,n).toArray) yield {\n val Array(l,r) = scala.io.StdIn.readLine().split(' ').map(_.toInt)\n Array((r-l+1), l, r)\n }\n var sortedInt = intervals.sortBy(_.apply(0))\n val ft = new FenwickTree(m+1)\n\n for(d <- 1 to m) {\n var count = 0\n val (before, after) = sortedInt.span(_.apply(0) < d)\n for (int <- before) {\n ft.add(int(1), 1)\n ft.add(int(2)+1, -1)\n }\n for(i <- Range(0, m+1, d)) count += ft.query(-1, i)\n count += after.length\n sortedInt = after\n println(count)\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1486932567, "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/s347111059.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s347111059", "user_id": "u551313534"}, "prompt_components": {"gold_output": "3\n2\n2\n", "input_to_evaluate": "class FenwickTree(val n:Int, init:Int) {\n val dat = new Array[Int](n+1)\n for (i <- 1 to n) add(i, init)\n\n def this(n:Int) {\n this(n, 0)\n }\n\n def add(_idx:Int, value:Int) {\n var idx = _idx+1\n while(idx <= n) {\n dat(idx) += value\n idx += idx & -idx\n }\n }\n\n def query(_l:Int, _r:Int):Int = {\n var ans = 0\n var r = _r+1\n var l = _l+1\n while(r > 0) {\n ans += dat(r)\n r -= r & -r\n }\n while(l > 0) {\n ans -= dat(l)\n l -= l & -l\n }\n return ans\n }\n}\n\nobject Main {\n def main(args: Array[String]) {\n val Array(n,m) = scala.io.StdIn.readLine().split(' ').map(_.toInt)\n val intervals = for(i <- Range(0,n).toArray) yield {\n val Array(l,r) = scala.io.StdIn.readLine().split(' ').map(_.toInt)\n Array((r-l+1), l, r)\n }\n var sortedInt = intervals.sortBy(_.apply(0))\n val ft = new FenwickTree(m+1)\n\n for(d <- 1 to m) {\n var count = 0\n val (before, after) = sortedInt.span(_.apply(0) < d)\n for (int <- before) {\n ft.add(int(1), 1)\n ft.add(int(2)+1, -1)\n }\n for(i <- Range(0, m+1, d)) count += ft.query(-1, i)\n count += after.length\n sortedInt = after\n println(count)\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1218, "cpu_time_ms": 2103, "memory_kb": 137752}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s568536637", "group_id": "codeNet:p03831", "input_text": "import scala.io.StdIn.readLine\n\n/**\n * Created by sonetsuyoshi on 2015/12/16.\n */\nobject Main extends App {\n val arg = readLine.split(\" \").map(_.toInt)\n val N = arg.apply(0)\n val A = arg.apply(1)\n val B = arg.apply(2)\n\n val x = readLine.split(\" \").map(_.toLong)\n\n val ans: Long = 1.until(N).foldLeft(0.toLong)((s, i) => s + math.min((x(i) - x (i - 1)) * A, B)\n )\n\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1485063633, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03831.html", "problem_id": "p03831", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03831/input.txt", "sample_output_relpath": "derived/input_output/data/p03831/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03831/Scala/s568536637.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s568536637", "user_id": "u185193776"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "import scala.io.StdIn.readLine\n\n/**\n * Created by sonetsuyoshi on 2015/12/16.\n */\nobject Main extends App {\n val arg = readLine.split(\" \").map(_.toInt)\n val N = arg.apply(0)\n val A = arg.apply(1)\n val B = arg.apply(2)\n\n val x = readLine.split(\" \").map(_.toLong)\n\n val ans: Long = 1.until(N).foldLeft(0.toLong)((s, i) => s + math.min((x(i) - x (i - 1)) * A, B)\n )\n\n println(ans)\n}", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N towns on a line running east-west.\nThe towns are numbered 1 through N, in order from west to east.\nEach point on the line has a one-dimensional coordinate, and a point that is farther east has a greater coordinate value.\nThe coordinate of town i is X_i.\n\nYou are now at town 1, and you want to visit all the other towns.\nYou have two ways to travel:\n\nWalk on the line.\nYour fatigue level increases by A each time you travel a distance of 1, regardless of direction.\n\nTeleport to any location of your choice.\nYour fatigue level increases by B, regardless of the distance covered.\n\nFind the minimum possible total increase of your fatigue level when you visit all the towns in these two ways.\n\nConstraints\n\nAll input values are integers.\n\n2≤N≤10^5\n\n1≤X_i≤10^9\n\nFor all i(1≤i≤N-1), X_i in}\n\nobject Main extends App {\n println(in.readLine.replace(\",\",\" \"))\n}", "language": "Scala", "metadata": {"date": 1548118938, "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/s688668507.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s688668507", "user_id": "u217010036"}, "prompt_components": {"gold_output": "happy newyear enjoy\n", "input_to_evaluate": "import scala.io.{ StdIn => in}\n\nobject Main extends App {\n println(in.readLine.replace(\",\",\" \"))\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 99, "cpu_time_ms": 339, "memory_kb": 25408}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s194364943", "group_id": "codeNet:p03836", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val sx, sy, tx, ty = sc.nextInt()\n val dx = tx - sx\n val dy = ty - sy\n val ans = s\"${\"R\" * dx}${\"U\" * dy}${\"L\" * dx}${\"D\" * (dy+1)}${\"R\" * (dx+1)}${\"U\" * (dy+1)}LU${\"L\" * (dx + 1)}${\"D\" * (dy+1)}R\"\n println(ans)\n}\n", "language": "Scala", "metadata": {"date": 1595121786, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03836.html", "problem_id": "p03836", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03836/input.txt", "sample_output_relpath": "derived/input_output/data/p03836/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03836/Scala/s194364943.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s194364943", "user_id": "u191819389"}, "prompt_components": {"gold_output": "UURDDLLUUURRDRDDDLLU\n", "input_to_evaluate": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val sx, sy, tx, ty = sc.nextInt()\n val dx = tx - sx\n val dy = ty - sy\n val ans = s\"${\"R\" * dx}${\"U\" * dy}${\"L\" * dx}${\"D\" * (dy+1)}${\"R\" * (dx+1)}${\"U\" * (dy+1)}LU${\"L\" * (dx + 1)}${\"D\" * (dy+1)}R\"\n println(ans)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nDolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up.\n\nCurrently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1.\n\nHere, both the x- and y-coordinates before and after each movement must be integers.\n\nHe will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy).\n\nHere, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty).\n\nUnder this condition, find a shortest path for him.\n\nConstraints\n\n-1000 ≤ sx < tx ≤ 1000\n\n-1000 ≤ sy < ty ≤ 1000\n\nsx,sy,tx and ty are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nsx sy tx ty\n\nOutput\n\nPrint a string S that represents a shortest path for Dolphin.\n\nThe i-th character in S should correspond to his i-th movement.\n\nThe directions of the movements should be indicated by the following characters:\n\nU: Up\n\nD: Down\n\nL: Left\n\nR: Right\n\nIf there exist multiple shortest paths under the condition, print any of them.\n\nSample Input 1\n\n0 0 1 2\n\nSample Output 1\n\nUURDDLLUUURRDRDDDLLU\n\nOne possible shortest path is:\n\nGoing from (sx,sy) to (tx,ty) for the first time: (0,0) → (0,1) → (0,2) → (1,2)\n\nGoing from (tx,ty) to (sx,sy) for the first time: (1,2) → (1,1) → (1,0) → (0,0)\n\nGoing from (sx,sy) to (tx,ty) for the second time: (0,0) → (-1,0) → (-1,1) → (-1,2) → (-1,3) → (0,3) → (1,3) → (1,2)\n\nGoing from (tx,ty) to (sx,sy) for the second time: (1,2) → (2,2) → (2,1) → (2,0) → (2,-1) → (1,-1) → (0,-1) → (0,0)\n\nSample Input 2\n\n-2 -2 1 1\n\nSample Output 2\n\nUURRURRDDDLLDLLULUUURRURRDDDLLDL", "sample_input": "0 0 1 2\n"}, "reference_outputs": ["UURDDLLUUURRDRDDDLLU\n"], "source_document_id": "p03836", "source_text": "Score : 300 points\n\nProblem Statement\n\nDolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up.\n\nCurrently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1.\n\nHere, both the x- and y-coordinates before and after each movement must be integers.\n\nHe will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy).\n\nHere, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty).\n\nUnder this condition, find a shortest path for him.\n\nConstraints\n\n-1000 ≤ sx < tx ≤ 1000\n\n-1000 ≤ sy < ty ≤ 1000\n\nsx,sy,tx and ty are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nsx sy tx ty\n\nOutput\n\nPrint a string S that represents a shortest path for Dolphin.\n\nThe i-th character in S should correspond to his i-th movement.\n\nThe directions of the movements should be indicated by the following characters:\n\nU: Up\n\nD: Down\n\nL: Left\n\nR: Right\n\nIf there exist multiple shortest paths under the condition, print any of them.\n\nSample Input 1\n\n0 0 1 2\n\nSample Output 1\n\nUURDDLLUUURRDRDDDLLU\n\nOne possible shortest path is:\n\nGoing from (sx,sy) to (tx,ty) for the first time: (0,0) → (0,1) → (0,2) → (1,2)\n\nGoing from (tx,ty) to (sx,sy) for the first time: (1,2) → (1,1) → (1,0) → (0,0)\n\nGoing from (sx,sy) to (tx,ty) for the second time: (0,0) → (-1,0) → (-1,1) → (-1,2) → (-1,3) → (0,3) → (1,3) → (1,2)\n\nGoing from (tx,ty) to (sx,sy) for the second time: (1,2) → (2,2) → (2,1) → (2,0) → (2,-1) → (1,-1) → (0,-1) → (0,0)\n\nSample Input 2\n\n-2 -2 1 1\n\nSample Output 2\n\nUURRURRDDDLLDLLULUUURRURRDDDLLDL", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 290, "cpu_time_ms": 504, "memory_kb": 55420}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s220680942", "group_id": "codeNet:p03836", "input_text": "object Main extends App {\n val Array(sx, sy, tx, ty) = scala.io.StdIn.readLine.split(' ').map(_.toInt)\n\n val path1 = \"U\" * (ty - sy) + \"R\" * (tx - sx)\n val path2 = \"R\" * (tx - sx) + \"U\" * (ty - sy)\n val path3 = \"D\" + \"R\" * (tx - sx + 1) + \"U\" * (ty - sy + 1) + \"L\"\n val path4 = \"L\" + \"U\" * (ty - sy + 1) + \"R\" * (tx - sx + 1) + \"D\"\n\n println(Array(path1, path2, path3, path4).mkString)\n}\n", "language": "Scala", "metadata": {"date": 1586394062, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03836.html", "problem_id": "p03836", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03836/input.txt", "sample_output_relpath": "derived/input_output/data/p03836/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03836/Scala/s220680942.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s220680942", "user_id": "u393913844"}, "prompt_components": {"gold_output": "UURDDLLUUURRDRDDDLLU\n", "input_to_evaluate": "object Main extends App {\n val Array(sx, sy, tx, ty) = scala.io.StdIn.readLine.split(' ').map(_.toInt)\n\n val path1 = \"U\" * (ty - sy) + \"R\" * (tx - sx)\n val path2 = \"R\" * (tx - sx) + \"U\" * (ty - sy)\n val path3 = \"D\" + \"R\" * (tx - sx + 1) + \"U\" * (ty - sy + 1) + \"L\"\n val path4 = \"L\" + \"U\" * (ty - sy + 1) + \"R\" * (tx - sx + 1) + \"D\"\n\n println(Array(path1, path2, path3, path4).mkString)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nDolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up.\n\nCurrently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1.\n\nHere, both the x- and y-coordinates before and after each movement must be integers.\n\nHe will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy).\n\nHere, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty).\n\nUnder this condition, find a shortest path for him.\n\nConstraints\n\n-1000 ≤ sx < tx ≤ 1000\n\n-1000 ≤ sy < ty ≤ 1000\n\nsx,sy,tx and ty are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nsx sy tx ty\n\nOutput\n\nPrint a string S that represents a shortest path for Dolphin.\n\nThe i-th character in S should correspond to his i-th movement.\n\nThe directions of the movements should be indicated by the following characters:\n\nU: Up\n\nD: Down\n\nL: Left\n\nR: Right\n\nIf there exist multiple shortest paths under the condition, print any of them.\n\nSample Input 1\n\n0 0 1 2\n\nSample Output 1\n\nUURDDLLUUURRDRDDDLLU\n\nOne possible shortest path is:\n\nGoing from (sx,sy) to (tx,ty) for the first time: (0,0) → (0,1) → (0,2) → (1,2)\n\nGoing from (tx,ty) to (sx,sy) for the first time: (1,2) → (1,1) → (1,0) → (0,0)\n\nGoing from (sx,sy) to (tx,ty) for the second time: (0,0) → (-1,0) → (-1,1) → (-1,2) → (-1,3) → (0,3) → (1,3) → (1,2)\n\nGoing from (tx,ty) to (sx,sy) for the second time: (1,2) → (2,2) → (2,1) → (2,0) → (2,-1) → (1,-1) → (0,-1) → (0,0)\n\nSample Input 2\n\n-2 -2 1 1\n\nSample Output 2\n\nUURRURRDDDLLDLLULUUURRURRDDDLLDL", "sample_input": "0 0 1 2\n"}, "reference_outputs": ["UURDDLLUUURRDRDDDLLU\n"], "source_document_id": "p03836", "source_text": "Score : 300 points\n\nProblem Statement\n\nDolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up.\n\nCurrently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1.\n\nHere, both the x- and y-coordinates before and after each movement must be integers.\n\nHe will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy).\n\nHere, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty).\n\nUnder this condition, find a shortest path for him.\n\nConstraints\n\n-1000 ≤ sx < tx ≤ 1000\n\n-1000 ≤ sy < ty ≤ 1000\n\nsx,sy,tx and ty are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nsx sy tx ty\n\nOutput\n\nPrint a string S that represents a shortest path for Dolphin.\n\nThe i-th character in S should correspond to his i-th movement.\n\nThe directions of the movements should be indicated by the following characters:\n\nU: Up\n\nD: Down\n\nL: Left\n\nR: Right\n\nIf there exist multiple shortest paths under the condition, print any of them.\n\nSample Input 1\n\n0 0 1 2\n\nSample Output 1\n\nUURDDLLUUURRDRDDDLLU\n\nOne possible shortest path is:\n\nGoing from (sx,sy) to (tx,ty) for the first time: (0,0) → (0,1) → (0,2) → (1,2)\n\nGoing from (tx,ty) to (sx,sy) for the first time: (1,2) → (1,1) → (1,0) → (0,0)\n\nGoing from (sx,sy) to (tx,ty) for the second time: (0,0) → (-1,0) → (-1,1) → (-1,2) → (-1,3) → (0,3) → (1,3) → (1,2)\n\nGoing from (tx,ty) to (sx,sy) for the second time: (1,2) → (2,2) → (2,1) → (2,0) → (2,-1) → (1,-1) → (0,-1) → (0,0)\n\nSample Input 2\n\n-2 -2 1 1\n\nSample Output 2\n\nUURRURRDDDLLDLLULUUURRURRDDDLLDL", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 394, "cpu_time_ms": 357, "memory_kb": 27324}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s692238875", "group_id": "codeNet:p03836", "input_text": "import java.util.Scanner\n\nobject Main extends App{\n val sc = new Scanner(System.in)\n\n val sx = sc.nextInt()\n val sy = sc.nextInt()\n val tx = sc.nextInt()\n val ty = sc.nextInt()\n\n var ans = \"\"\n for(i <- sx to tx-1)\n ans += \"R\"\n for(i <- sy to ty-1)\n ans += \"U\"\n for(i <- sx to tx-1)\n ans += \"L\"\n for(i <- sy to ty-1)\n ans += \"D\"\n\n ans += \"D\"\n for(i <- sx to tx)\n ans += \"R\"\n for(i <- sy to ty)\n ans += \"U\"\n ans += \"L\"\n\n ans += \"U\"\n for(i <- sx to tx)\n ans += \"L\"\n for(i <- sy to ty)\n ans += \"U\"\n ans += \"R\"\n\n println(ans)\n}\n", "language": "Scala", "metadata": {"date": 1497324375, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03836.html", "problem_id": "p03836", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03836/input.txt", "sample_output_relpath": "derived/input_output/data/p03836/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03836/Scala/s692238875.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s692238875", "user_id": "u098968285"}, "prompt_components": {"gold_output": "UURDDLLUUURRDRDDDLLU\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main extends App{\n val sc = new Scanner(System.in)\n\n val sx = sc.nextInt()\n val sy = sc.nextInt()\n val tx = sc.nextInt()\n val ty = sc.nextInt()\n\n var ans = \"\"\n for(i <- sx to tx-1)\n ans += \"R\"\n for(i <- sy to ty-1)\n ans += \"U\"\n for(i <- sx to tx-1)\n ans += \"L\"\n for(i <- sy to ty-1)\n ans += \"D\"\n\n ans += \"D\"\n for(i <- sx to tx)\n ans += \"R\"\n for(i <- sy to ty)\n ans += \"U\"\n ans += \"L\"\n\n ans += \"U\"\n for(i <- sx to tx)\n ans += \"L\"\n for(i <- sy to ty)\n ans += \"U\"\n ans += \"R\"\n\n println(ans)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nDolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up.\n\nCurrently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1.\n\nHere, both the x- and y-coordinates before and after each movement must be integers.\n\nHe will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy).\n\nHere, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty).\n\nUnder this condition, find a shortest path for him.\n\nConstraints\n\n-1000 ≤ sx < tx ≤ 1000\n\n-1000 ≤ sy < ty ≤ 1000\n\nsx,sy,tx and ty are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nsx sy tx ty\n\nOutput\n\nPrint a string S that represents a shortest path for Dolphin.\n\nThe i-th character in S should correspond to his i-th movement.\n\nThe directions of the movements should be indicated by the following characters:\n\nU: Up\n\nD: Down\n\nL: Left\n\nR: Right\n\nIf there exist multiple shortest paths under the condition, print any of them.\n\nSample Input 1\n\n0 0 1 2\n\nSample Output 1\n\nUURDDLLUUURRDRDDDLLU\n\nOne possible shortest path is:\n\nGoing from (sx,sy) to (tx,ty) for the first time: (0,0) → (0,1) → (0,2) → (1,2)\n\nGoing from (tx,ty) to (sx,sy) for the first time: (1,2) → (1,1) → (1,0) → (0,0)\n\nGoing from (sx,sy) to (tx,ty) for the second time: (0,0) → (-1,0) → (-1,1) → (-1,2) → (-1,3) → (0,3) → (1,3) → (1,2)\n\nGoing from (tx,ty) to (sx,sy) for the second time: (1,2) → (2,2) → (2,1) → (2,0) → (2,-1) → (1,-1) → (0,-1) → (0,0)\n\nSample Input 2\n\n-2 -2 1 1\n\nSample Output 2\n\nUURRURRDDDLLDLLULUUURRURRDDDLLDL", "sample_input": "0 0 1 2\n"}, "reference_outputs": ["UURDDLLUUURRDRDDDLLU\n"], "source_document_id": "p03836", "source_text": "Score : 300 points\n\nProblem Statement\n\nDolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up.\n\nCurrently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1.\n\nHere, both the x- and y-coordinates before and after each movement must be integers.\n\nHe will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy).\n\nHere, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty).\n\nUnder this condition, find a shortest path for him.\n\nConstraints\n\n-1000 ≤ sx < tx ≤ 1000\n\n-1000 ≤ sy < ty ≤ 1000\n\nsx,sy,tx and ty are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nsx sy tx ty\n\nOutput\n\nPrint a string S that represents a shortest path for Dolphin.\n\nThe i-th character in S should correspond to his i-th movement.\n\nThe directions of the movements should be indicated by the following characters:\n\nU: Up\n\nD: Down\n\nL: Left\n\nR: Right\n\nIf there exist multiple shortest paths under the condition, print any of them.\n\nSample Input 1\n\n0 0 1 2\n\nSample Output 1\n\nUURDDLLUUURRDRDDDLLU\n\nOne possible shortest path is:\n\nGoing from (sx,sy) to (tx,ty) for the first time: (0,0) → (0,1) → (0,2) → (1,2)\n\nGoing from (tx,ty) to (sx,sy) for the first time: (1,2) → (1,1) → (1,0) → (0,0)\n\nGoing from (sx,sy) to (tx,ty) for the second time: (0,0) → (-1,0) → (-1,1) → (-1,2) → (-1,3) → (0,3) → (1,3) → (1,2)\n\nGoing from (tx,ty) to (sx,sy) for the second time: (1,2) → (2,2) → (2,1) → (2,0) → (2,-1) → (1,-1) → (0,-1) → (0,0)\n\nSample Input 2\n\n-2 -2 1 1\n\nSample Output 2\n\nUURRURRDDDLLDLLULUUURRURRDDDLLDL", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 566, "cpu_time_ms": 601, "memory_kb": 112932}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s956962538", "group_id": "codeNet:p03838", "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 x, y = sc.nextInt()\n\n def sign(a: Int) = a >= 0\n\n val ans = if (x < y && sign(x) == sign(y)) y - x\n else if (x < 0 && y == 0) -x\n else if (x > 0 && y == 0) x + 1\n else if (sign(x) != sign(y)) abs(abs(y) - abs(x)) + 1\n else abs(abs(y) - abs(x)) + 2\n\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)(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": 1533423331, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03838.html", "problem_id": "p03838", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03838/input.txt", "sample_output_relpath": "derived/input_output/data/p03838/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03838/Scala/s956962538.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s956962538", "user_id": "u460609472"}, "prompt_components": {"gold_output": "10\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 x, y = sc.nextInt()\n\n def sign(a: Int) = a >= 0\n\n val ans = if (x < y && sign(x) == sign(y)) y - x\n else if (x < 0 && y == 0) -x\n else if (x > 0 && y == 0) x + 1\n else if (sign(x) != sign(y)) abs(abs(y) - abs(x)) + 1\n else abs(abs(y) - abs(x)) + 2\n\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)(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 : 300 points\n\nProblem Statement\n\nSnuke has a calculator. It has a display and two buttons.\n\nInitially, the display shows an integer x.\nSnuke wants to change this value into another integer y, by pressing the following two buttons some number of times in arbitrary order:\n\nButton A: When pressed, the value on the display is incremented by 1.\n\nButton B: When pressed, the sign of the value on the display is reversed.\n\nFind the minimum number of times Snuke needs to press the buttons to achieve his objective.\nIt can be shown that the objective is always achievable regardless of the values of the integers x and y.\n\nConstraints\n\nx and y are integers.\n\n|x|, |y| ≤ 10^9\n\nx and y are different.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nx y\n\nOutput\n\nPrint the minimum number of times Snuke needs to press the buttons to achieve his objective.\n\nSample Input 1\n\n10 20\n\nSample Output 1\n\n10\n\nPress button A ten times.\n\nSample Input 2\n\n10 -10\n\nSample Output 2\n\n1\n\nPress button B once.\n\nSample Input 3\n\n-10 -20\n\nSample Output 3\n\n12\n\nPress the buttons as follows:\n\nPress button B once.\n\nPress button A ten times.\n\nPress button B once.", "sample_input": "10 20\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03838", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke has a calculator. It has a display and two buttons.\n\nInitially, the display shows an integer x.\nSnuke wants to change this value into another integer y, by pressing the following two buttons some number of times in arbitrary order:\n\nButton A: When pressed, the value on the display is incremented by 1.\n\nButton B: When pressed, the sign of the value on the display is reversed.\n\nFind the minimum number of times Snuke needs to press the buttons to achieve his objective.\nIt can be shown that the objective is always achievable regardless of the values of the integers x and y.\n\nConstraints\n\nx and y are integers.\n\n|x|, |y| ≤ 10^9\n\nx and y are different.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nx y\n\nOutput\n\nPrint the minimum number of times Snuke needs to press the buttons to achieve his objective.\n\nSample Input 1\n\n10 20\n\nSample Output 1\n\n10\n\nPress button A ten times.\n\nSample Input 2\n\n10 -10\n\nSample Output 2\n\n1\n\nPress button B once.\n\nSample Input 3\n\n-10 -20\n\nSample Output 3\n\n12\n\nPress the buttons as follows:\n\nPress button B once.\n\nPress button A ten times.\n\nPress button B once.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3023, "cpu_time_ms": 330, "memory_kb": 26696}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s018279722", "group_id": "codeNet:p03838", "input_text": "import io.StdIn.readLine\n\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val Array(x, y) = readLine().split(' ' ).map(_.toInt)\n val xa = Math.abs(x)\n val ya = Math.abs(y)\n\n if (xa == ya) {\n if (x == y) println(0)\n else println(1)\n } else if (xa > ya) {\n if (x > 0 && y > 0) println(2 + xa - ya)\n else if (x > 0 && y <= 0) println(1 + xa - ya)\n else if (x < 0 && y > 0) println(1 + xa - ya)\n else println(xa - ya)\n } else {\n if (x == 0 && y > 0) println(y)\n else if (x == 0 && y < 0) println(y + 1)\n else if (x > 0 && y > 0) println(ya - xa)\n else if (x > 0 && y < 0) println(1 + ya - xa)\n else if (x < 0 && y > 0) println(1 + ya - xa)\n else println(2 + ya - xa)\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1482720830, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03838.html", "problem_id": "p03838", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03838/input.txt", "sample_output_relpath": "derived/input_output/data/p03838/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03838/Scala/s018279722.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s018279722", "user_id": "u382513779"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import io.StdIn.readLine\n\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val Array(x, y) = readLine().split(' ' ).map(_.toInt)\n val xa = Math.abs(x)\n val ya = Math.abs(y)\n\n if (xa == ya) {\n if (x == y) println(0)\n else println(1)\n } else if (xa > ya) {\n if (x > 0 && y > 0) println(2 + xa - ya)\n else if (x > 0 && y <= 0) println(1 + xa - ya)\n else if (x < 0 && y > 0) println(1 + xa - ya)\n else println(xa - ya)\n } else {\n if (x == 0 && y > 0) println(y)\n else if (x == 0 && y < 0) println(y + 1)\n else if (x > 0 && y > 0) println(ya - xa)\n else if (x > 0 && y < 0) println(1 + ya - xa)\n else if (x < 0 && y > 0) println(1 + ya - xa)\n else println(2 + ya - xa)\n }\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke has a calculator. It has a display and two buttons.\n\nInitially, the display shows an integer x.\nSnuke wants to change this value into another integer y, by pressing the following two buttons some number of times in arbitrary order:\n\nButton A: When pressed, the value on the display is incremented by 1.\n\nButton B: When pressed, the sign of the value on the display is reversed.\n\nFind the minimum number of times Snuke needs to press the buttons to achieve his objective.\nIt can be shown that the objective is always achievable regardless of the values of the integers x and y.\n\nConstraints\n\nx and y are integers.\n\n|x|, |y| ≤ 10^9\n\nx and y are different.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nx y\n\nOutput\n\nPrint the minimum number of times Snuke needs to press the buttons to achieve his objective.\n\nSample Input 1\n\n10 20\n\nSample Output 1\n\n10\n\nPress button A ten times.\n\nSample Input 2\n\n10 -10\n\nSample Output 2\n\n1\n\nPress button B once.\n\nSample Input 3\n\n-10 -20\n\nSample Output 3\n\n12\n\nPress the buttons as follows:\n\nPress button B once.\n\nPress button A ten times.\n\nPress button B once.", "sample_input": "10 20\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03838", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke has a calculator. It has a display and two buttons.\n\nInitially, the display shows an integer x.\nSnuke wants to change this value into another integer y, by pressing the following two buttons some number of times in arbitrary order:\n\nButton A: When pressed, the value on the display is incremented by 1.\n\nButton B: When pressed, the sign of the value on the display is reversed.\n\nFind the minimum number of times Snuke needs to press the buttons to achieve his objective.\nIt can be shown that the objective is always achievable regardless of the values of the integers x and y.\n\nConstraints\n\nx and y are integers.\n\n|x|, |y| ≤ 10^9\n\nx and y are different.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nx y\n\nOutput\n\nPrint the minimum number of times Snuke needs to press the buttons to achieve his objective.\n\nSample Input 1\n\n10 20\n\nSample Output 1\n\n10\n\nPress button A ten times.\n\nSample Input 2\n\n10 -10\n\nSample Output 2\n\n1\n\nPress button B once.\n\nSample Input 3\n\n-10 -20\n\nSample Output 3\n\n12\n\nPress the buttons as follows:\n\nPress button B once.\n\nPress button A ten times.\n\nPress button B once.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 778, "cpu_time_ms": 471, "memory_kb": 21696}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s382416593", "group_id": "codeNet:p03840", "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 A0, A1, A2, A3, A4, A5, A6 = sc.nextInt()\n\n val ans = A0 / 2 * 2 + A1 + min(A3, A4) * 2\n\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)(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": 1533418639, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03840.html", "problem_id": "p03840", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03840/input.txt", "sample_output_relpath": "derived/input_output/data/p03840/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03840/Scala/s382416593.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s382416593", "user_id": "u460609472"}, "prompt_components": {"gold_output": "3\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 A0, A1, A2, A3, A4, A5, A6 = sc.nextInt()\n\n val ans = A0 / 2 * 2 + A1 + min(A3, A4) * 2\n\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)(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 : 600 points\n\nProblem Statement\n\nA tetromino is a figure formed by joining four squares edge to edge.\nWe will refer to the following seven kinds of tetromino as I-, O-, T-, J-, L-, S- and Z-tetrominos, respectively:\n\nSnuke has many tetrominos. The number of I-, O-, T-, J-, L-, S- and Z-tetrominos in his possession are a_I, a_O, a_T, a_J, a_L, a_S and a_Z, respectively.\nSnuke will join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide.\nHere, the following rules must be followed:\n\nWhen placing each tetromino, rotation is allowed, but reflection is not.\n\nEach square in the rectangle must be covered by exactly one tetromino.\n\nNo part of each tetromino may be outside the rectangle.\n\nSnuke wants to form as large a rectangle as possible.\nFind the maximum possible value of K.\n\nConstraints\n\n0≤a_I,a_O,a_T,a_J,a_L,a_S,a_Z≤10^9\n\na_I+a_O+a_T+a_J+a_L+a_S+a_Z≥1\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na_I a_O a_T a_J a_L a_S a_Z\n\nOutput\n\nPrint the maximum possible value of K. If no rectangle can be formed, print 0.\n\nSample Input 1\n\n2 1 1 0 0 0 0\n\nSample Output 1\n\n3\n\nOne possible way to form the largest rectangle is shown in the following figure:\n\nSample Input 2\n\n0 0 10 0 0 0 0\n\nSample Output 2\n\n0\n\nNo rectangle can be formed.", "sample_input": "2 1 1 0 0 0 0\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03840", "source_text": "Score : 600 points\n\nProblem Statement\n\nA tetromino is a figure formed by joining four squares edge to edge.\nWe will refer to the following seven kinds of tetromino as I-, O-, T-, J-, L-, S- and Z-tetrominos, respectively:\n\nSnuke has many tetrominos. The number of I-, O-, T-, J-, L-, S- and Z-tetrominos in his possession are a_I, a_O, a_T, a_J, a_L, a_S and a_Z, respectively.\nSnuke will join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide.\nHere, the following rules must be followed:\n\nWhen placing each tetromino, rotation is allowed, but reflection is not.\n\nEach square in the rectangle must be covered by exactly one tetromino.\n\nNo part of each tetromino may be outside the rectangle.\n\nSnuke wants to form as large a rectangle as possible.\nFind the maximum possible value of K.\n\nConstraints\n\n0≤a_I,a_O,a_T,a_J,a_L,a_S,a_Z≤10^9\n\na_I+a_O+a_T+a_J+a_L+a_S+a_Z≥1\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na_I a_O a_T a_J a_L a_S a_Z\n\nOutput\n\nPrint the maximum possible value of K. If no rectangle can be formed, print 0.\n\nSample Input 1\n\n2 1 1 0 0 0 0\n\nSample Output 1\n\n3\n\nOne possible way to form the largest rectangle is shown in the following figure:\n\nSample Input 2\n\n0 0 10 0 0 0 0\n\nSample Output 2\n\n0\n\nNo rectangle can be formed.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2848, "cpu_time_ms": 321, "memory_kb": 27208}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s544985905", "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]): Long = {\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).toLong + 7.toLong\n def ans(n: Int, acm: Long): Long =\n if (n < N / 2) ans(n + 1, acm << 1 % INF)\n else acm\n\n def find(i: Int): Long =\n if (i < N) {\n C(A(i)) -= 1\n find(i + 1)\n } else {\n if (C.forall(_ == 0)) ans(0, 1)\n else 0\n }\n\n find(0)\n }\n\n println(solve(N, A))\n }\n\n}\n", "language": "Scala", "metadata": {"date": 1576877762, "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/s544985905.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s544985905", "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]): Long = {\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).toLong + 7.toLong\n def ans(n: Int, acm: Long): Long =\n if (n < N / 2) ans(n + 1, acm << 1 % INF)\n else acm\n\n def find(i: Int): Long =\n if (i < N) {\n C(A(i)) -= 1\n find(i + 1)\n } else {\n if (C.forall(_ == 0)) ans(0, 1)\n else 0\n }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 714, "memory_kb": 52124}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s955418742", "group_id": "codeNet:p03852", "input_text": "import java.util.Scanner\n\nobject Main {\n def main(args:Array[String]): Unit = {\n val vowels = Array(\"a\", \"i\", \"u\", \"e\", \"o\")\n val sc = new Scanner(System.in)\n\n if (vowels.contains(sc.nextLine())) {\n println(\"vowel\")\n } else {\n println(\"consonant\")\n }\n }\n}", "language": "Scala", "metadata": {"date": 1581992589, "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/s955418742.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s955418742", "user_id": "u276115223"}, "prompt_components": {"gold_output": "vowel\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def main(args:Array[String]): Unit = {\n val vowels = Array(\"a\", \"i\", \"u\", \"e\", \"o\")\n val sc = new Scanner(System.in)\n\n if (vowels.contains(sc.nextLine())) {\n println(\"vowel\")\n } else {\n println(\"consonant\")\n }\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: a, e, i, o and u.\n\nConstraints\n\nc is a lowercase English letter.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nc\n\nOutput\n\nIf c is a vowel, print vowel. Otherwise, print consonant.\n\nSample Input 1\n\na\n\nSample Output 1\n\nvowel\n\nSince a is a vowel, print vowel.\n\nSample Input 2\n\nz\n\nSample Output 2\n\nconsonant\n\nSample Input 3\n\ns\n\nSample Output 3\n\nconsonant", "sample_input": "a\n"}, "reference_outputs": ["vowel\n"], "source_document_id": "p03852", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: a, e, i, o and u.\n\nConstraints\n\nc is a lowercase English letter.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nc\n\nOutput\n\nIf c is a vowel, print vowel. Otherwise, print consonant.\n\nSample Input 1\n\na\n\nSample Output 1\n\nvowel\n\nSince a is a vowel, print vowel.\n\nSample Input 2\n\nz\n\nSample Output 2\n\nconsonant\n\nSample Input 3\n\ns\n\nSample Output 3\n\nconsonant", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 282, "cpu_time_ms": 333, "memory_kb": 25528}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s973696523", "group_id": "codeNet:p03853", "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(h, w) = sc.nextLine.split(\" \").map(_.toInt)\n val rectangle = List.fill(h)(sc.nextLine)\n (1 to 2 * h).map{\n ind => rectangle((ind - 1)/2)\n }.foreach(println)\n }\n}\n", "language": "Scala", "metadata": {"date": 1558657826, "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/s973696523.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s973696523", "user_id": "u629133942"}, "prompt_components": {"gold_output": "*.\n*.\n.*\n.*\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(h, w) = sc.nextLine.split(\" \").map(_.toInt)\n val rectangle = List.fill(h)(sc.nextLine)\n (1 to 2 * h).map{\n ind => rectangle((ind - 1)/2)\n }.foreach(println)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 395, "memory_kb": 27456}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s318657601", "group_id": "codeNet:p03857", "input_text": "import java.io.{BufferedReader, IOException, 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 def solve(): Unit = {\n val sc = new InputReader(System.in)\n val N = sc.nextInt()\n val K = sc.nextInt()\n val L = sc.nextInt()\n\n var i = 0\n val uf_road = new UnionFind(N + 1)\n i = 0\n while (i < K) {\n// (0 until K) foreach { _ =>\n uf_road.unite(sc.nextInt(), sc.nextInt())\n i += 1\n }\n\n val uf_rail = new UnionFind(N + 1)\n i = 0\n while (i < L) {\n// (0 until L) foreach { _ =>\n uf_rail.unite(sc.nextInt(), sc.nextInt())\n i += 1\n }\n\n val group = new java.util.HashMap[(Int, Int), Int](N) // key => group\n i = 1\n while (i <= N) {\n// (1 to N) foreach { i =>\n val k = (uf_road.find(i), uf_rail.find(i))\n group.put(k, i)\n i += 1\n }\n val i2g = Array.ofDim[Int](N + 1) // i => group\n i = 1\n while (i <= N) {\n// (1 to N) foreach { i =>\n val k = (uf_road.find(i), uf_rail.find(i))\n i2g(i) = group.get(k)\n i += 1\n }\n val count = Array.ofDim[Int](N + 1) // group => count\n i = 1\n while (i <= N) {\n// (1 to N) foreach { i =>\n count(i2g(i)) += 1\n i += 1\n }\n i = 1\n while (i <= N) {\n// (1 to N) foreach { i =>\n if (i > 1) print(\" \")\n print(count(i2g(i)))\n i += 1\n }\n\n// val count = mutable.Map[(Int, Int), Int]()\n// var i = 1\n// while(i <= N) {\n// val k = key(i)\n// if (!(count contains k)) count(k) = 0\n// count(k) = count(k) + 1\n// i += 1\n// }\n//\n// i = 1\n// while(i <= N) {\n// if (i > 1) print(\" \")\n// print(count(key(i)))\n// i += 1\n// }\n// println()\n// val count = ((1 to N) map key).groupBy(identity).mapValues(_.size)\n// val ans = ((1 to N) map (key _).andThen (count(_))).mkString(\" \")\n// println(ans)\n }\n\n def main(args: Array[String]): Unit = {\n solve()\n }\n\n\n\n class InputReader(val stream: InputStream) {\n val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n 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 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": 1528265748, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03857.html", "problem_id": "p03857", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03857/input.txt", "sample_output_relpath": "derived/input_output/data/p03857/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03857/Scala/s318657601.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s318657601", "user_id": "u460609472"}, "prompt_components": {"gold_output": "1 2 2 1\n", "input_to_evaluate": "import java.io.{BufferedReader, IOException, 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 def solve(): Unit = {\n val sc = new InputReader(System.in)\n val N = sc.nextInt()\n val K = sc.nextInt()\n val L = sc.nextInt()\n\n var i = 0\n val uf_road = new UnionFind(N + 1)\n i = 0\n while (i < K) {\n// (0 until K) foreach { _ =>\n uf_road.unite(sc.nextInt(), sc.nextInt())\n i += 1\n }\n\n val uf_rail = new UnionFind(N + 1)\n i = 0\n while (i < L) {\n// (0 until L) foreach { _ =>\n uf_rail.unite(sc.nextInt(), sc.nextInt())\n i += 1\n }\n\n val group = new java.util.HashMap[(Int, Int), Int](N) // key => group\n i = 1\n while (i <= N) {\n// (1 to N) foreach { i =>\n val k = (uf_road.find(i), uf_rail.find(i))\n group.put(k, i)\n i += 1\n }\n val i2g = Array.ofDim[Int](N + 1) // i => group\n i = 1\n while (i <= N) {\n// (1 to N) foreach { i =>\n val k = (uf_road.find(i), uf_rail.find(i))\n i2g(i) = group.get(k)\n i += 1\n }\n val count = Array.ofDim[Int](N + 1) // group => count\n i = 1\n while (i <= N) {\n// (1 to N) foreach { i =>\n count(i2g(i)) += 1\n i += 1\n }\n i = 1\n while (i <= N) {\n// (1 to N) foreach { i =>\n if (i > 1) print(\" \")\n print(count(i2g(i)))\n i += 1\n }\n\n// val count = mutable.Map[(Int, Int), Int]()\n// var i = 1\n// while(i <= N) {\n// val k = key(i)\n// if (!(count contains k)) count(k) = 0\n// count(k) = count(k) + 1\n// i += 1\n// }\n//\n// i = 1\n// while(i <= N) {\n// if (i > 1) print(\" \")\n// print(count(key(i)))\n// i += 1\n// }\n// println()\n// val count = ((1 to N) map key).groupBy(identity).mapValues(_.size)\n// val ans = ((1 to N) map (key _).andThen (count(_))).mkString(\" \")\n// println(ans)\n }\n\n def main(args: Array[String]): Unit = {\n solve()\n }\n\n\n\n class InputReader(val stream: InputStream) {\n val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n 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 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 cities. There are also K roads and L railways, extending between the cities.\nThe i-th road bidirectionally connects the p_i-th and q_i-th cities, and the i-th railway bidirectionally connects the r_i-th and s_i-th cities.\nNo two roads connect the same pair of cities. Similarly, no two railways connect the same pair of cities.\n\nWe will say city A and B are connected by roads if city B is reachable from city A by traversing some number of roads. Here, any city is considered to be connected to itself by roads.\nWe will also define connectivity by railways similarly.\n\nFor each city, find the number of the cities connected to that city by both roads and railways.\n\nConstraints\n\n2 ≦ N ≦ 2*10^5\n\n1 ≦ K, L≦ 10^5\n\n1 ≦ p_i, q_i, r_i, s_i ≦ N\n\np_i < q_i\n\nr_i < s_i\n\nWhen i ≠ j, (p_i, q_i) ≠ (p_j, q_j)\n\nWhen i ≠ j, (r_i, s_i) ≠ (r_j, s_j)\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K L\np_1 q_1\n:\np_K q_K\nr_1 s_1\n:\nr_L s_L\n\nOutput\n\nPrint N integers. The i-th of them should represent the number of the cities connected to the i-th city by both roads and railways.\n\nSample Input 1\n\n4 3 1\n1 2\n2 3\n3 4\n2 3\n\nSample Output 1\n\n1 2 2 1\n\nAll the four cities are connected to each other by roads.\n\nBy railways, only the second and third cities are connected. Thus, the answers for the cities are 1, 2, 2 and 1, respectively.\n\nSample Input 2\n\n4 2 2\n1 2\n2 3\n1 4\n2 3\n\nSample Output 2\n\n1 2 2 1\n\nSample Input 3\n\n7 4 4\n1 2\n2 3\n2 5\n6 7\n3 5\n4 5\n3 4\n6 7\n\nSample Output 3\n\n1 1 2 1 2 2 2", "sample_input": "4 3 1\n1 2\n2 3\n3 4\n2 3\n"}, "reference_outputs": ["1 2 2 1\n"], "source_document_id": "p03857", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N cities. There are also K roads and L railways, extending between the cities.\nThe i-th road bidirectionally connects the p_i-th and q_i-th cities, and the i-th railway bidirectionally connects the r_i-th and s_i-th cities.\nNo two roads connect the same pair of cities. Similarly, no two railways connect the same pair of cities.\n\nWe will say city A and B are connected by roads if city B is reachable from city A by traversing some number of roads. Here, any city is considered to be connected to itself by roads.\nWe will also define connectivity by railways similarly.\n\nFor each city, find the number of the cities connected to that city by both roads and railways.\n\nConstraints\n\n2 ≦ N ≦ 2*10^5\n\n1 ≦ K, L≦ 10^5\n\n1 ≦ p_i, q_i, r_i, s_i ≦ N\n\np_i < q_i\n\nr_i < s_i\n\nWhen i ≠ j, (p_i, q_i) ≠ (p_j, q_j)\n\nWhen i ≠ j, (r_i, s_i) ≠ (r_j, s_j)\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K L\np_1 q_1\n:\np_K q_K\nr_1 s_1\n:\nr_L s_L\n\nOutput\n\nPrint N integers. The i-th of them should represent the number of the cities connected to the i-th city by both roads and railways.\n\nSample Input 1\n\n4 3 1\n1 2\n2 3\n3 4\n2 3\n\nSample Output 1\n\n1 2 2 1\n\nAll the four cities are connected to each other by roads.\n\nBy railways, only the second and third cities are connected. Thus, the answers for the cities are 1, 2, 2 and 1, respectively.\n\nSample Input 2\n\n4 2 2\n1 2\n2 3\n1 4\n2 3\n\nSample Output 2\n\n1 2 2 1\n\nSample Input 3\n\n7 4 4\n1 2\n2 3\n2 5\n6 7\n3 5\n4 5\n3 4\n6 7\n\nSample Output 3\n\n1 1 2 1 2 2 2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3054, "cpu_time_ms": 2111, "memory_kb": 97688}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s591983603", "group_id": "codeNet:p03857", "input_text": "import java.io.{BufferedReader, IOException, InputStream, InputStreamReader}\nimport java.util.StringTokenizer\nimport java.util.concurrent.atomic.AtomicInteger\n\nimport scala.collection.mutable\nimport scala.util.Sorting\nimport math.{abs, max, min}\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n def solve(): Unit = {\n val sc = new InputReader(System.in)\n val N = sc.nextInt()\n val K = sc.nextInt()\n val L = sc.nextInt()\n\n val uf_road = new UnionFind(N + 1)\n (0 until K) foreach { _ =>\n uf_road.unite(sc.nextInt(), sc.nextInt())\n }\n\n val uf_rail = new UnionFind(N + 1)\n (0 until L) foreach { _ =>\n uf_rail.unite(sc.nextInt(), sc.nextInt())\n }\n\n def key(i: Int) = (uf_road.find(i), uf_rail.find(i))\n\n val count = mutable.Map[(Int, Int), Int]()\n var i = 1\n while(i <= N) {\n val k = key(i)\n if (!(count contains k)) count(k) = 0\n count(k) = count(k) + 1\n i += 1\n }\n\n i = 1\n while(i <= N) {\n if (i > 1) print(\" \")\n print(count(key(i)))\n i += 1\n }\n println()\n// val count = ((1 to N) map key).groupBy(identity).mapValues(_.size)\n// val ans = ((1 to N) map (key _).andThen (count(_))).mkString(\" \")\n// println(ans)\n }\n\n def main(args: Array[String]): Unit = {\n solve()\n }\n\n\n\n class InputReader(val stream: InputStream) {\n val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n 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 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": 1528263369, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03857.html", "problem_id": "p03857", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03857/input.txt", "sample_output_relpath": "derived/input_output/data/p03857/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03857/Scala/s591983603.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s591983603", "user_id": "u460609472"}, "prompt_components": {"gold_output": "1 2 2 1\n", "input_to_evaluate": "import java.io.{BufferedReader, IOException, InputStream, InputStreamReader}\nimport java.util.StringTokenizer\nimport java.util.concurrent.atomic.AtomicInteger\n\nimport scala.collection.mutable\nimport scala.util.Sorting\nimport math.{abs, max, min}\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n def solve(): Unit = {\n val sc = new InputReader(System.in)\n val N = sc.nextInt()\n val K = sc.nextInt()\n val L = sc.nextInt()\n\n val uf_road = new UnionFind(N + 1)\n (0 until K) foreach { _ =>\n uf_road.unite(sc.nextInt(), sc.nextInt())\n }\n\n val uf_rail = new UnionFind(N + 1)\n (0 until L) foreach { _ =>\n uf_rail.unite(sc.nextInt(), sc.nextInt())\n }\n\n def key(i: Int) = (uf_road.find(i), uf_rail.find(i))\n\n val count = mutable.Map[(Int, Int), Int]()\n var i = 1\n while(i <= N) {\n val k = key(i)\n if (!(count contains k)) count(k) = 0\n count(k) = count(k) + 1\n i += 1\n }\n\n i = 1\n while(i <= N) {\n if (i > 1) print(\" \")\n print(count(key(i)))\n i += 1\n }\n println()\n// val count = ((1 to N) map key).groupBy(identity).mapValues(_.size)\n// val ans = ((1 to N) map (key _).andThen (count(_))).mkString(\" \")\n// println(ans)\n }\n\n def main(args: Array[String]): Unit = {\n solve()\n }\n\n\n\n class InputReader(val stream: InputStream) {\n val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n 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 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 cities. There are also K roads and L railways, extending between the cities.\nThe i-th road bidirectionally connects the p_i-th and q_i-th cities, and the i-th railway bidirectionally connects the r_i-th and s_i-th cities.\nNo two roads connect the same pair of cities. Similarly, no two railways connect the same pair of cities.\n\nWe will say city A and B are connected by roads if city B is reachable from city A by traversing some number of roads. Here, any city is considered to be connected to itself by roads.\nWe will also define connectivity by railways similarly.\n\nFor each city, find the number of the cities connected to that city by both roads and railways.\n\nConstraints\n\n2 ≦ N ≦ 2*10^5\n\n1 ≦ K, L≦ 10^5\n\n1 ≦ p_i, q_i, r_i, s_i ≦ N\n\np_i < q_i\n\nr_i < s_i\n\nWhen i ≠ j, (p_i, q_i) ≠ (p_j, q_j)\n\nWhen i ≠ j, (r_i, s_i) ≠ (r_j, s_j)\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K L\np_1 q_1\n:\np_K q_K\nr_1 s_1\n:\nr_L s_L\n\nOutput\n\nPrint N integers. The i-th of them should represent the number of the cities connected to the i-th city by both roads and railways.\n\nSample Input 1\n\n4 3 1\n1 2\n2 3\n3 4\n2 3\n\nSample Output 1\n\n1 2 2 1\n\nAll the four cities are connected to each other by roads.\n\nBy railways, only the second and third cities are connected. Thus, the answers for the cities are 1, 2, 2 and 1, respectively.\n\nSample Input 2\n\n4 2 2\n1 2\n2 3\n1 4\n2 3\n\nSample Output 2\n\n1 2 2 1\n\nSample Input 3\n\n7 4 4\n1 2\n2 3\n2 5\n6 7\n3 5\n4 5\n3 4\n6 7\n\nSample Output 3\n\n1 1 2 1 2 2 2", "sample_input": "4 3 1\n1 2\n2 3\n3 4\n2 3\n"}, "reference_outputs": ["1 2 2 1\n"], "source_document_id": "p03857", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N cities. There are also K roads and L railways, extending between the cities.\nThe i-th road bidirectionally connects the p_i-th and q_i-th cities, and the i-th railway bidirectionally connects the r_i-th and s_i-th cities.\nNo two roads connect the same pair of cities. Similarly, no two railways connect the same pair of cities.\n\nWe will say city A and B are connected by roads if city B is reachable from city A by traversing some number of roads. Here, any city is considered to be connected to itself by roads.\nWe will also define connectivity by railways similarly.\n\nFor each city, find the number of the cities connected to that city by both roads and railways.\n\nConstraints\n\n2 ≦ N ≦ 2*10^5\n\n1 ≦ K, L≦ 10^5\n\n1 ≦ p_i, q_i, r_i, s_i ≦ N\n\np_i < q_i\n\nr_i < s_i\n\nWhen i ≠ j, (p_i, q_i) ≠ (p_j, q_j)\n\nWhen i ≠ j, (r_i, s_i) ≠ (r_j, s_j)\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K L\np_1 q_1\n:\np_K q_K\nr_1 s_1\n:\nr_L s_L\n\nOutput\n\nPrint N integers. The i-th of them should represent the number of the cities connected to the i-th city by both roads and railways.\n\nSample Input 1\n\n4 3 1\n1 2\n2 3\n3 4\n2 3\n\nSample Output 1\n\n1 2 2 1\n\nAll the four cities are connected to each other by roads.\n\nBy railways, only the second and third cities are connected. Thus, the answers for the cities are 1, 2, 2 and 1, respectively.\n\nSample Input 2\n\n4 2 2\n1 2\n2 3\n1 4\n2 3\n\nSample Output 2\n\n1 2 2 1\n\nSample Input 3\n\n7 4 4\n1 2\n2 3\n2 5\n6 7\n3 5\n4 5\n3 4\n6 7\n\nSample Output 3\n\n1 1 2 1 2 2 2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2292, "cpu_time_ms": 2045, "memory_kb": 88160}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s362914110", "group_id": "codeNet:p03857", "input_text": "import java.io.{BufferedReader, IOException, InputStream, InputStreamReader}\nimport java.util.StringTokenizer\nimport java.util.concurrent.atomic.AtomicInteger\n\nimport scala.collection.mutable\nimport scala.util.Sorting\nimport math.{abs, max, min}\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n def solve(): Unit = {\n val sc = new InputReader(System.in)\n val N = sc.nextInt()\n val K = sc.nextInt()\n val L = sc.nextInt()\n\n val uf_road = new UnionFind(N + 1)\n (0 until K) foreach { _ =>\n uf_road.unite(sc.nextInt(), sc.nextInt())\n }\n\n val uf_rail = new UnionFind(N + 1)\n (0 until L) foreach { _ =>\n uf_rail.unite(sc.nextInt(), sc.nextInt())\n }\n\n def key(i: Int) = (uf_road.find(i), uf_rail.find(i))\n\n val count = mutable.Map[(Int, Int), AtomicInteger]()\n (1 to N) map { i =>\n val k = key(i)\n if (!(count contains k)) count(k) = new AtomicInteger\n count(k).addAndGet(1)\n }\n\n (1 to N) foreach { i =>\n if (i > 1) print(\" \")\n print(count(key(i)).get)\n }\n println()\n// val count = ((1 to N) map key).groupBy(identity).mapValues(_.size)\n// val ans = ((1 to N) map (key _).andThen (count(_))).mkString(\" \")\n// println(ans)\n }\n\n def main(args: Array[String]): Unit = {\n solve()\n }\n\n\n\n class InputReader(val stream: InputStream) {\n val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n 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 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": 1528262948, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03857.html", "problem_id": "p03857", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03857/input.txt", "sample_output_relpath": "derived/input_output/data/p03857/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03857/Scala/s362914110.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s362914110", "user_id": "u460609472"}, "prompt_components": {"gold_output": "1 2 2 1\n", "input_to_evaluate": "import java.io.{BufferedReader, IOException, InputStream, InputStreamReader}\nimport java.util.StringTokenizer\nimport java.util.concurrent.atomic.AtomicInteger\n\nimport scala.collection.mutable\nimport scala.util.Sorting\nimport math.{abs, max, min}\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n def solve(): Unit = {\n val sc = new InputReader(System.in)\n val N = sc.nextInt()\n val K = sc.nextInt()\n val L = sc.nextInt()\n\n val uf_road = new UnionFind(N + 1)\n (0 until K) foreach { _ =>\n uf_road.unite(sc.nextInt(), sc.nextInt())\n }\n\n val uf_rail = new UnionFind(N + 1)\n (0 until L) foreach { _ =>\n uf_rail.unite(sc.nextInt(), sc.nextInt())\n }\n\n def key(i: Int) = (uf_road.find(i), uf_rail.find(i))\n\n val count = mutable.Map[(Int, Int), AtomicInteger]()\n (1 to N) map { i =>\n val k = key(i)\n if (!(count contains k)) count(k) = new AtomicInteger\n count(k).addAndGet(1)\n }\n\n (1 to N) foreach { i =>\n if (i > 1) print(\" \")\n print(count(key(i)).get)\n }\n println()\n// val count = ((1 to N) map key).groupBy(identity).mapValues(_.size)\n// val ans = ((1 to N) map (key _).andThen (count(_))).mkString(\" \")\n// println(ans)\n }\n\n def main(args: Array[String]): Unit = {\n solve()\n }\n\n\n\n class InputReader(val stream: InputStream) {\n val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n 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 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 cities. There are also K roads and L railways, extending between the cities.\nThe i-th road bidirectionally connects the p_i-th and q_i-th cities, and the i-th railway bidirectionally connects the r_i-th and s_i-th cities.\nNo two roads connect the same pair of cities. Similarly, no two railways connect the same pair of cities.\n\nWe will say city A and B are connected by roads if city B is reachable from city A by traversing some number of roads. Here, any city is considered to be connected to itself by roads.\nWe will also define connectivity by railways similarly.\n\nFor each city, find the number of the cities connected to that city by both roads and railways.\n\nConstraints\n\n2 ≦ N ≦ 2*10^5\n\n1 ≦ K, L≦ 10^5\n\n1 ≦ p_i, q_i, r_i, s_i ≦ N\n\np_i < q_i\n\nr_i < s_i\n\nWhen i ≠ j, (p_i, q_i) ≠ (p_j, q_j)\n\nWhen i ≠ j, (r_i, s_i) ≠ (r_j, s_j)\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K L\np_1 q_1\n:\np_K q_K\nr_1 s_1\n:\nr_L s_L\n\nOutput\n\nPrint N integers. The i-th of them should represent the number of the cities connected to the i-th city by both roads and railways.\n\nSample Input 1\n\n4 3 1\n1 2\n2 3\n3 4\n2 3\n\nSample Output 1\n\n1 2 2 1\n\nAll the four cities are connected to each other by roads.\n\nBy railways, only the second and third cities are connected. Thus, the answers for the cities are 1, 2, 2 and 1, respectively.\n\nSample Input 2\n\n4 2 2\n1 2\n2 3\n1 4\n2 3\n\nSample Output 2\n\n1 2 2 1\n\nSample Input 3\n\n7 4 4\n1 2\n2 3\n2 5\n6 7\n3 5\n4 5\n3 4\n6 7\n\nSample Output 3\n\n1 1 2 1 2 2 2", "sample_input": "4 3 1\n1 2\n2 3\n3 4\n2 3\n"}, "reference_outputs": ["1 2 2 1\n"], "source_document_id": "p03857", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N cities. There are also K roads and L railways, extending between the cities.\nThe i-th road bidirectionally connects the p_i-th and q_i-th cities, and the i-th railway bidirectionally connects the r_i-th and s_i-th cities.\nNo two roads connect the same pair of cities. Similarly, no two railways connect the same pair of cities.\n\nWe will say city A and B are connected by roads if city B is reachable from city A by traversing some number of roads. Here, any city is considered to be connected to itself by roads.\nWe will also define connectivity by railways similarly.\n\nFor each city, find the number of the cities connected to that city by both roads and railways.\n\nConstraints\n\n2 ≦ N ≦ 2*10^5\n\n1 ≦ K, L≦ 10^5\n\n1 ≦ p_i, q_i, r_i, s_i ≦ N\n\np_i < q_i\n\nr_i < s_i\n\nWhen i ≠ j, (p_i, q_i) ≠ (p_j, q_j)\n\nWhen i ≠ j, (r_i, s_i) ≠ (r_j, s_j)\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K L\np_1 q_1\n:\np_K q_K\nr_1 s_1\n:\nr_L s_L\n\nOutput\n\nPrint N integers. The i-th of them should represent the number of the cities connected to the i-th city by both roads and railways.\n\nSample Input 1\n\n4 3 1\n1 2\n2 3\n3 4\n2 3\n\nSample Output 1\n\n1 2 2 1\n\nAll the four cities are connected to each other by roads.\n\nBy railways, only the second and third cities are connected. Thus, the answers for the cities are 1, 2, 2 and 1, respectively.\n\nSample Input 2\n\n4 2 2\n1 2\n2 3\n1 4\n2 3\n\nSample Output 2\n\n1 2 2 1\n\nSample Input 3\n\n7 4 4\n1 2\n2 3\n2 5\n6 7\n3 5\n4 5\n3 4\n6 7\n\nSample Output 3\n\n1 1 2 1 2 2 2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2282, "cpu_time_ms": 2111, "memory_kb": 97204}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s380050933", "group_id": "codeNet:p03861", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n import scala.io.StdIn.readLine\n val Array(datA, datB, datX) = readLine.split(\" \").map(_.toLong)\n val ans = (datB / datX) - ((datA - 1) / datX)\n println(ans)\n }\n}\n", "language": "Scala", "metadata": {"date": 1589071580, "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/s380050933.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s380050933", "user_id": "u014716041"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n import scala.io.StdIn.readLine\n val Array(datA, datB, datX) = readLine.split(\" \").map(_.toLong)\n val ans = (datB / datX) - ((datA - 1) / datX)\n println(ans)\n }\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given nonnegative integers a and b (a ≤ b), and a positive integer x.\nAmong the integers between a and b, inclusive, how many are divisible by x?\n\nConstraints\n\n0 ≤ a ≤ b ≤ 10^{18}\n\n1 ≤ x ≤ 10^{18}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b x\n\nOutput\n\nPrint the number of the integers between a and b, inclusive, that are divisible by x.\n\nSample Input 1\n\n4 8 2\n\nSample Output 1\n\n3\n\nThere are three integers between 4 and 8, inclusive, that are divisible by 2: 4, 6 and 8.\n\nSample Input 2\n\n0 5 1\n\nSample Output 2\n\n6\n\nThere are six integers between 0 and 5, inclusive, that are divisible by 1: 0, 1, 2, 3, 4 and 5.\n\nSample Input 3\n\n9 9 2\n\nSample Output 3\n\n0\n\nThere are no integer between 9 and 9, inclusive, that is divisible by 2.\n\nSample Input 4\n\n1 1000000000000000000 3\n\nSample Output 4\n\n333333333333333333\n\nWatch out for integer overflows.", "sample_input": "4 8 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03861", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given nonnegative integers a and b (a ≤ b), and a positive integer x.\nAmong the integers between a and b, inclusive, how many are divisible by x?\n\nConstraints\n\n0 ≤ a ≤ b ≤ 10^{18}\n\n1 ≤ x ≤ 10^{18}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b x\n\nOutput\n\nPrint the number of the integers between a and b, inclusive, that are divisible by x.\n\nSample Input 1\n\n4 8 2\n\nSample Output 1\n\n3\n\nThere are three integers between 4 and 8, inclusive, that are divisible by 2: 4, 6 and 8.\n\nSample Input 2\n\n0 5 1\n\nSample Output 2\n\n6\n\nThere are six integers between 0 and 5, inclusive, that are divisible by 1: 0, 1, 2, 3, 4 and 5.\n\nSample Input 3\n\n9 9 2\n\nSample Output 3\n\n0\n\nThere are no integer between 9 and 9, inclusive, that is divisible by 2.\n\nSample Input 4\n\n1 1000000000000000000 3\n\nSample Output 4\n\n333333333333333333\n\nWatch out for integer overflows.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 232, "cpu_time_ms": 336, "memory_kb": 25544}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s200711995", "group_id": "codeNet:p03861", "input_text": "import io.{StdIn => in}\n\nobject Main extends App {\n val Array(a, b, x) = in.readLine.split(\" \").map(_.toLong)\n val ans = (b / x) - ((a-1) / x)\n println(ans)\n}", "language": "Scala", "metadata": {"date": 1548371614, "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/s200711995.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s200711995", "user_id": "u217010036"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "import io.{StdIn => in}\n\nobject Main extends App {\n val Array(a, b, x) = in.readLine.split(\" \").map(_.toLong)\n val ans = (b / x) - ((a-1) / x)\n println(ans)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given nonnegative integers a and b (a ≤ b), and a positive integer x.\nAmong the integers between a and b, inclusive, how many are divisible by x?\n\nConstraints\n\n0 ≤ a ≤ b ≤ 10^{18}\n\n1 ≤ x ≤ 10^{18}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b x\n\nOutput\n\nPrint the number of the integers between a and b, inclusive, that are divisible by x.\n\nSample Input 1\n\n4 8 2\n\nSample Output 1\n\n3\n\nThere are three integers between 4 and 8, inclusive, that are divisible by 2: 4, 6 and 8.\n\nSample Input 2\n\n0 5 1\n\nSample Output 2\n\n6\n\nThere are six integers between 0 and 5, inclusive, that are divisible by 1: 0, 1, 2, 3, 4 and 5.\n\nSample Input 3\n\n9 9 2\n\nSample Output 3\n\n0\n\nThere are no integer between 9 and 9, inclusive, that is divisible by 2.\n\nSample Input 4\n\n1 1000000000000000000 3\n\nSample Output 4\n\n333333333333333333\n\nWatch out for integer overflows.", "sample_input": "4 8 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03861", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given nonnegative integers a and b (a ≤ b), and a positive integer x.\nAmong the integers between a and b, inclusive, how many are divisible by x?\n\nConstraints\n\n0 ≤ a ≤ b ≤ 10^{18}\n\n1 ≤ x ≤ 10^{18}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b x\n\nOutput\n\nPrint the number of the integers between a and b, inclusive, that are divisible by x.\n\nSample Input 1\n\n4 8 2\n\nSample Output 1\n\n3\n\nThere are three integers between 4 and 8, inclusive, that are divisible by 2: 4, 6 and 8.\n\nSample Input 2\n\n0 5 1\n\nSample Output 2\n\n6\n\nThere are six integers between 0 and 5, inclusive, that are divisible by 1: 0, 1, 2, 3, 4 and 5.\n\nSample Input 3\n\n9 9 2\n\nSample Output 3\n\n0\n\nThere are no integer between 9 and 9, inclusive, that is divisible by 2.\n\nSample Input 4\n\n1 1000000000000000000 3\n\nSample Output 4\n\n333333333333333333\n\nWatch out for integer overflows.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 161, "cpu_time_ms": 342, "memory_kb": 25548}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s200502213", "group_id": "codeNet:p03921", "input_text": "\nimport scala.collection.mutable\nimport scala.collection.mutable.ArrayBuffer\n\n/**\n * Created by sonetsuyoshi on 2015/12/16.\n */\ncase class Person(id: Int, langs: Seq[Int])\n\nobject Main extends App {\n val params = readLine.split(\" \").map(_.toInt)\n val N = params(0)\n val M = params(1)\n\n val langs: Array[mutable.MutableList[Person]] = Array.fill(M)(mutable.MutableList[Person]())\n val ps = 0.until(N).map(x => {\n val p = Person(x, readLine.split(\" \").drop(1).map(_.toInt - 1))\n p.langs.foreach(l => langs(l).+=(p))\n p\n })\n val p0 = ps(0)\n\n val unvisitedPersons = Array.fill(N)(true)\n val unvisitedLangs = Array.fill(M)(true)\n\n val visitingPersons = mutable.Stack[Person]()\n val visitingLangs = mutable.Stack[Int]()\n\n visitingPersons.push(p0)\n\n while(visitingPersons.size > 0) {\n val p = visitingPersons.pop()\n p.langs.filter(l => unvisitedLangs(l)).foreach(l => {\n unvisitedLangs(l) = false\n val pps = langs(l)\n pps.filter(pp => unvisitedPersons(pp.id)).foreach(pp => {\n unvisitedPersons(pp.id) = false\n visitingPersons.push(pp)\n })\n })\n }\n if(unvisitedPersons.forall(_ == false)) {\n println(\"YES\")\n } else {\n println(\"NO\")\n }\n}", "language": "Scala", "metadata": {"date": 1480201916, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03921.html", "problem_id": "p03921", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03921/input.txt", "sample_output_relpath": "derived/input_output/data/p03921/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03921/Scala/s200502213.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s200502213", "user_id": "u185193776"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "\nimport scala.collection.mutable\nimport scala.collection.mutable.ArrayBuffer\n\n/**\n * Created by sonetsuyoshi on 2015/12/16.\n */\ncase class Person(id: Int, langs: Seq[Int])\n\nobject Main extends App {\n val params = readLine.split(\" \").map(_.toInt)\n val N = params(0)\n val M = params(1)\n\n val langs: Array[mutable.MutableList[Person]] = Array.fill(M)(mutable.MutableList[Person]())\n val ps = 0.until(N).map(x => {\n val p = Person(x, readLine.split(\" \").drop(1).map(_.toInt - 1))\n p.langs.foreach(l => langs(l).+=(p))\n p\n })\n val p0 = ps(0)\n\n val unvisitedPersons = Array.fill(N)(true)\n val unvisitedLangs = Array.fill(M)(true)\n\n val visitingPersons = mutable.Stack[Person]()\n val visitingLangs = mutable.Stack[Int]()\n\n visitingPersons.push(p0)\n\n while(visitingPersons.size > 0) {\n val p = visitingPersons.pop()\n p.langs.filter(l => unvisitedLangs(l)).foreach(l => {\n unvisitedLangs(l) = false\n val pps = langs(l)\n pps.filter(pp => unvisitedPersons(pp.id)).foreach(pp => {\n unvisitedPersons(pp.id) = false\n visitingPersons.push(pp)\n })\n })\n }\n if(unvisitedPersons.forall(_ == false)) {\n println(\"YES\")\n } else {\n println(\"NO\")\n }\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nOn a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M.\n\nFor CODE FESTIVAL 20XX held on this planet, N participants gathered from all over the planet.\n\nThe i-th (1≦i≦N) participant can speak K_i languages numbered L_{i,1}, L_{i,2}, ..., L_{i,{}K_i}.\n\nTwo participants A and B can communicate with each other if and only if one of the following conditions is satisfied:\n\nThere exists a language that both A and B can speak.\n\nThere exists a participant X that both A and B can communicate with.\n\nDetermine whether all N participants can communicate with all other participants.\n\nConstraints\n\n2≦N≦10^5\n\n1≦M≦10^5\n\n1≦K_i≦M\n\n(The sum of all K_i)≦10^5\n\n1≦L_{i,j}≦M\n\nL_{i,1}, L_{i,2}, ..., L_{i,{}K_i} are pairwise distinct.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying the following: N≦1000, M≦1000 and (The sum of all K_i)≦1000.\n\nAdditional 200 points will be awarded for passing the test set without additional constraints.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nK_1 L_{1,1} L_{1,2} ... L_{1,{}K_1}\nK_2 L_{2,1} L_{2,2} ... L_{2,{}K_2}\n:\nK_N L_{N,1} L_{N,2} ... L_{N,{}K_N}\n\nOutput\n\nIf all N participants can communicate with all other participants, print YES. Otherwise, print NO.\n\nSample Input 1\n\n4 6\n3 1 2 3\n2 4 2\n2 4 6\n1 6\n\nSample Output 1\n\nYES\n\nAny two participants can communicate with each other, as follows:\n\nParticipants 1 and 2: both can speak language 2.\n\nParticipants 2 and 3: both can speak language 4.\n\nParticipants 1 and 3: both can communicate with participant 2.\n\nParticipants 3 and 4: both can speak language 6.\n\nParticipants 2 and 4: both can communicate with participant 3.\n\nParticipants 1 and 4: both can communicate with participant 2.\n\nNote that there can be languages spoken by no participant.\n\nSample Input 2\n\n4 4\n2 1 2\n2 1 2\n1 3\n2 4 3\n\nSample Output 2\n\nNO\n\nFor example, participants 1 and 3 cannot communicate with each other.", "sample_input": "4 6\n3 1 2 3\n2 4 2\n2 4 6\n1 6\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03921", "source_text": "Score : 400 points\n\nProblem Statement\n\nOn a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M.\n\nFor CODE FESTIVAL 20XX held on this planet, N participants gathered from all over the planet.\n\nThe i-th (1≦i≦N) participant can speak K_i languages numbered L_{i,1}, L_{i,2}, ..., L_{i,{}K_i}.\n\nTwo participants A and B can communicate with each other if and only if one of the following conditions is satisfied:\n\nThere exists a language that both A and B can speak.\n\nThere exists a participant X that both A and B can communicate with.\n\nDetermine whether all N participants can communicate with all other participants.\n\nConstraints\n\n2≦N≦10^5\n\n1≦M≦10^5\n\n1≦K_i≦M\n\n(The sum of all K_i)≦10^5\n\n1≦L_{i,j}≦M\n\nL_{i,1}, L_{i,2}, ..., L_{i,{}K_i} are pairwise distinct.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying the following: N≦1000, M≦1000 and (The sum of all K_i)≦1000.\n\nAdditional 200 points will be awarded for passing the test set without additional constraints.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nK_1 L_{1,1} L_{1,2} ... L_{1,{}K_1}\nK_2 L_{2,1} L_{2,2} ... L_{2,{}K_2}\n:\nK_N L_{N,1} L_{N,2} ... L_{N,{}K_N}\n\nOutput\n\nIf all N participants can communicate with all other participants, print YES. Otherwise, print NO.\n\nSample Input 1\n\n4 6\n3 1 2 3\n2 4 2\n2 4 6\n1 6\n\nSample Output 1\n\nYES\n\nAny two participants can communicate with each other, as follows:\n\nParticipants 1 and 2: both can speak language 2.\n\nParticipants 2 and 3: both can speak language 4.\n\nParticipants 1 and 3: both can communicate with participant 2.\n\nParticipants 3 and 4: both can speak language 6.\n\nParticipants 2 and 4: both can communicate with participant 3.\n\nParticipants 1 and 4: both can communicate with participant 2.\n\nNote that there can be languages spoken by no participant.\n\nSample Input 2\n\n4 4\n2 1 2\n2 1 2\n1 3\n2 4 3\n\nSample Output 2\n\nNO\n\nFor example, participants 1 and 3 cannot communicate with each other.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1202, "cpu_time_ms": 2102, "memory_kb": 85880}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s338764653", "group_id": "codeNet:p03922", "input_text": "\nimport java.util.Scanner\n\nimport scala.collection.mutable\n\n/**\n * Created by sonetsuyoshi on 2015/12/16.\n */\nobject Main extends App {\n val sc = new Scanner(System.in)\n val N = sc.nextInt\n val M = sc.nextInt\n\n val valCountMap = mutable.Map[Int, Int]().withDefaultValue(0)\n val modValMap = Array.fill(M)(mutable.Set[Int]())\n val modCountMap = Array.fill(M)(0)\n\n for(i <- 0 until N) {\n val n = sc.nextInt\n val m = n % M\n valCountMap.+=((n, valCountMap(n) + 1))\n modValMap(m).+=(n)\n modCountMap(m) += 1\n }\n\n var count = modCountMap(0) / 2\n for(i <- 1 to ((M - 1) / 2)) {\n val j = M - i\n val (sId, lId) = if(modCountMap(i) < modCountMap(j)) {\n (i, j)\n } else {\n (j, i)\n }\n\n val countDif = modCountMap(lId) - modCountMap(sId)\n val maxPairNum = countDif / 2\n\n val pairNum = modValMap(lId).foldLeft(0){case(s, x) => s + valCountMap(x) / 2}\n\n count += modCountMap(sId) + math.min(maxPairNum, pairNum)\n }\n\n if(M % 2 == 0) count += modCountMap(M / 2) / 2\n\n println(count)\n}", "language": "Scala", "metadata": {"date": 1480277484, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03922.html", "problem_id": "p03922", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03922/input.txt", "sample_output_relpath": "derived/input_output/data/p03922/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03922/Scala/s338764653.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s338764653", "user_id": "u185193776"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "\nimport java.util.Scanner\n\nimport scala.collection.mutable\n\n/**\n * Created by sonetsuyoshi on 2015/12/16.\n */\nobject Main extends App {\n val sc = new Scanner(System.in)\n val N = sc.nextInt\n val M = sc.nextInt\n\n val valCountMap = mutable.Map[Int, Int]().withDefaultValue(0)\n val modValMap = Array.fill(M)(mutable.Set[Int]())\n val modCountMap = Array.fill(M)(0)\n\n for(i <- 0 until N) {\n val n = sc.nextInt\n val m = n % M\n valCountMap.+=((n, valCountMap(n) + 1))\n modValMap(m).+=(n)\n modCountMap(m) += 1\n }\n\n var count = modCountMap(0) / 2\n for(i <- 1 to ((M - 1) / 2)) {\n val j = M - i\n val (sId, lId) = if(modCountMap(i) < modCountMap(j)) {\n (i, j)\n } else {\n (j, i)\n }\n\n val countDif = modCountMap(lId) - modCountMap(sId)\n val maxPairNum = countDif / 2\n\n val pairNum = modValMap(lId).foldLeft(0){case(s, x) => s + valCountMap(x) / 2}\n\n count += modCountMap(sId) + math.min(maxPairNum, pairNum)\n }\n\n if(M % 2 == 0) count += modCountMap(M / 2) / 2\n\n println(count)\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": "p03922", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1396, "memory_kb": 81720}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s329476678", "group_id": "codeNet:p03922", "input_text": "\nimport java.util.Scanner\n\nimport scala.collection.mutable\n\n/**\n * Created by sonetsuyoshi on 2015/12/16.\n */\nobject Main extends App {\n val sc = new Scanner(System.in)\n val N = sc.nextInt\n val M = sc.nextInt\n\n val valCountMap = mutable.Map[Int, Int]().withDefaultValue(0)\n val modValMap = Array.fill(M)(mutable.Set[Int]())\n val modCountMap = Array.fill(M)(0)\n\n for(i <- 0 until N) {\n val n = sc.nextInt\n val m = n % M\n valCountMap.+=((n, valCountMap(n) + 1))\n modValMap(m).+=(n)\n modCountMap(m) += 1\n }\n\n var count = modCountMap(0) / 2\n for(i <- 1 to ((M - 1) / 2)) {\n val j = M - i\n val (sId, lId) = if(modCountMap(i) < modCountMap(j)) {\n (i, j)\n } else {\n (j, i)\n }\n\n val countDif = modCountMap(lId) - modCountMap(sId)\n val maxPairNum = countDif / 2\n\n val pairNum = modValMap(lId).foldLeft(0){case(s, x) => s + valCountMap(x) / 2}\n \n count += modCountMap(sId) + math.min(maxPairNum, pairNum)\n }\n\n count += modCountMap(M / 2) / 2\n\n println(count)\n}", "language": "Scala", "metadata": {"date": 1480277167, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03922.html", "problem_id": "p03922", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03922/input.txt", "sample_output_relpath": "derived/input_output/data/p03922/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03922/Scala/s329476678.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s329476678", "user_id": "u185193776"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "\nimport java.util.Scanner\n\nimport scala.collection.mutable\n\n/**\n * Created by sonetsuyoshi on 2015/12/16.\n */\nobject Main extends App {\n val sc = new Scanner(System.in)\n val N = sc.nextInt\n val M = sc.nextInt\n\n val valCountMap = mutable.Map[Int, Int]().withDefaultValue(0)\n val modValMap = Array.fill(M)(mutable.Set[Int]())\n val modCountMap = Array.fill(M)(0)\n\n for(i <- 0 until N) {\n val n = sc.nextInt\n val m = n % M\n valCountMap.+=((n, valCountMap(n) + 1))\n modValMap(m).+=(n)\n modCountMap(m) += 1\n }\n\n var count = modCountMap(0) / 2\n for(i <- 1 to ((M - 1) / 2)) {\n val j = M - i\n val (sId, lId) = if(modCountMap(i) < modCountMap(j)) {\n (i, j)\n } else {\n (j, i)\n }\n\n val countDif = modCountMap(lId) - modCountMap(sId)\n val maxPairNum = countDif / 2\n\n val pairNum = modValMap(lId).foldLeft(0){case(s, x) => s + valCountMap(x) / 2}\n \n count += modCountMap(sId) + math.min(maxPairNum, pairNum)\n }\n\n count += modCountMap(M / 2) / 2\n\n println(count)\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": "p03922", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1015, "cpu_time_ms": 1402, "memory_kb": 80544}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s926197083", "group_id": "codeNet:p03943", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val x = Array.fill(3)(sc.nextInt()).sorted\n if (x(0) + x(1) == x(2)) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}\n", "language": "Scala", "metadata": {"date": 1594578772, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "problem_description_relpath": "problem_descriptions/p03943.html", "problem_id": "p03943", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03943/input.txt", "sample_output_relpath": "derived/input_output/data/p03943/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03943/Scala/s926197083.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s926197083", "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 x = Array.fill(3)(sc.nextInt()).sorted\n if (x(0) + x(1) == x(2)) {\n println(\"Yes\")\n } else {\n println(\"No\")\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTwo students of AtCoder Kindergarten are fighting over candy packs.\n\nThere are three candy packs, each of which contains a, b, and c candies, respectively.\n\nTeacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible.\n\nNote that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.\n\nConstraints\n\n1 ≦ a, b, c ≦ 100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nIf it is possible to distribute the packs so that each student gets the same number of candies, print Yes. Otherwise, print No.\n\nSample Input 1\n\n10 30 20\n\nSample Output 1\n\nYes\n\nGive the pack with 30 candies to one student, and give the two packs with 10 and 20 candies to the other. Then, each gets 30 candies.\n\nSample Input 2\n\n30 30 100\n\nSample Output 2\n\nNo\n\nIn this case, the student who gets the pack with 100 candies always has more candies than the other.\n\nNote that every pack must be given to one of them.\n\nSample Input 3\n\n56 25 31\n\nSample Output 3\n\nYes", "sample_input": "10 30 20\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03943", "source_text": "Score : 100 points\n\nProblem Statement\n\nTwo students of AtCoder Kindergarten are fighting over candy packs.\n\nThere are three candy packs, each of which contains a, b, and c candies, respectively.\n\nTeacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible.\n\nNote that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.\n\nConstraints\n\n1 ≦ a, b, c ≦ 100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nIf it is possible to distribute the packs so that each student gets the same number of candies, print Yes. Otherwise, print No.\n\nSample Input 1\n\n10 30 20\n\nSample Output 1\n\nYes\n\nGive the pack with 30 candies to one student, and give the two packs with 10 and 20 candies to the other. Then, each gets 30 candies.\n\nSample Input 2\n\n30 30 100\n\nSample Output 2\n\nNo\n\nIn this case, the student who gets the pack with 100 candies always has more candies than the other.\n\nNote that every pack must be given to one of them.\n\nSample Input 3\n\n56 25 31\n\nSample Output 3\n\nYes", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 198, "cpu_time_ms": 514, "memory_kb": 55608}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s151727466", "group_id": "codeNet:p03944", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n\n case class Point(index: Int, x: Int, y: Int, pattern: Int)\n\n case class Rect(xs: Int, xe: Int, ys: Int, ye: Int)\n\n val Array(w, h, n) = StdIn.readLine().split(\" \").map(_.toInt)\n val points = (0 until n).map { i =>\n val a = StdIn.readLine().split(\" \").map(_.toInt)\n Point(i, a(0), a(1), a(2))\n }\n\n val r = points.foldLeft(Rect(0, w, 0, h)) { (acc, p) =>\n p.pattern match {\n case 1 => Rect(if (acc.xs < p.x) p.x else acc.xs, acc.xe, acc.ys, acc.ye) // < Xi\n case 2 => Rect(acc.xs, if (acc.xe > p.x) p.x else acc.xe, acc.ys, acc.ye) // > Xi\n case 3 => Rect(acc.xs, acc.xe, if (acc.ys < p.y) p.y else acc.ys , acc.ye) // < Yi\n case 4 => Rect(acc.xs, acc.xe, acc.ys, if (acc.ye > p.y) p.y else acc.ye) // > Yi\n }\n }\n // println(r)\n // println(r.xe - r.xs , r.ye - r.ys)\n println(if(r.xe < r.xs || r.ye < r.ys) 0 else (r.xe - r.xs) * (r.ye - r.ys))\n}\n", "language": "Scala", "metadata": {"date": 1536083706, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03944.html", "problem_id": "p03944", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03944/input.txt", "sample_output_relpath": "derived/input_output/data/p03944/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03944/Scala/s151727466.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s151727466", "user_id": "u895032849"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n\n case class Point(index: Int, x: Int, y: Int, pattern: Int)\n\n case class Rect(xs: Int, xe: Int, ys: Int, ye: Int)\n\n val Array(w, h, n) = StdIn.readLine().split(\" \").map(_.toInt)\n val points = (0 until n).map { i =>\n val a = StdIn.readLine().split(\" \").map(_.toInt)\n Point(i, a(0), a(1), a(2))\n }\n\n val r = points.foldLeft(Rect(0, w, 0, h)) { (acc, p) =>\n p.pattern match {\n case 1 => Rect(if (acc.xs < p.x) p.x else acc.xs, acc.xe, acc.ys, acc.ye) // < Xi\n case 2 => Rect(acc.xs, if (acc.xe > p.x) p.x else acc.xe, acc.ys, acc.ye) // > Xi\n case 3 => Rect(acc.xs, acc.xe, if (acc.ys < p.y) p.y else acc.ys , acc.ye) // < Yi\n case 4 => Rect(acc.xs, acc.xe, acc.ys, if (acc.ye > p.y) p.y else acc.ye) // > Yi\n }\n }\n // println(r)\n // println(r.xe - r.xs , r.ye - r.ys)\n println(if(r.xe < r.xs || r.ye < r.ys) 0 else (r.xe - r.xs) * (r.ye - r.ys))\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.\n\nSnuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i).\n\nThen, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows:\n\nIf a_i = 1, he painted the region satisfying x < x_i within the rectangle.\n\nIf a_i = 2, he painted the region satisfying x > x_i within the rectangle.\n\nIf a_i = 3, he painted the region satisfying y < y_i within the rectangle.\n\nIf a_i = 4, he painted the region satisfying y > y_i within the rectangle.\n\nFind the area of the white region within the rectangle after he finished painting.\n\nConstraints\n\n1 ≦ W, H ≦ 100\n\n1 ≦ N ≦ 100\n\n0 ≦ x_i ≦ W (1 ≦ i ≦ N)\n\n0 ≦ y_i ≦ H (1 ≦ i ≦ N)\n\nW, H (21:32, added), x_i and y_i are integers.\n\na_i (1 ≦ i ≦ N) is 1, 2, 3 or 4.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nW H N\nx_1 y_1 a_1\nx_2 y_2 a_2\n:\nx_N y_N a_N\n\nOutput\n\nPrint the area of the white region within the rectangle after Snuke finished painting.\n\nSample Input 1\n\n5 4 2\n2 1 1\n3 3 4\n\nSample Output 1\n\n9\n\nThe figure below shows the rectangle before Snuke starts painting.\n\nFirst, as (x_1, y_1) = (2, 1) and a_1 = 1, he paints the region satisfying x < 2 within the rectangle:\n\nThen, as (x_2, y_2) = (3, 3) and a_2 = 4, he paints the region satisfying y > 3 within the rectangle:\n\nNow, the area of the white region within the rectangle is 9.\n\nSample Input 2\n\n5 4 3\n2 1 1\n3 3 4\n1 4 2\n\nSample Output 2\n\n0\n\nIt is possible that the whole region within the rectangle is painted black.\n\nSample Input 3\n\n10 10 5\n1 6 1\n4 1 3\n6 9 4\n9 4 2\n3 1 3\n\nSample Output 3\n\n64", "sample_input": "5 4 2\n2 1 1\n3 3 4\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03944", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.\n\nSnuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i).\n\nThen, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows:\n\nIf a_i = 1, he painted the region satisfying x < x_i within the rectangle.\n\nIf a_i = 2, he painted the region satisfying x > x_i within the rectangle.\n\nIf a_i = 3, he painted the region satisfying y < y_i within the rectangle.\n\nIf a_i = 4, he painted the region satisfying y > y_i within the rectangle.\n\nFind the area of the white region within the rectangle after he finished painting.\n\nConstraints\n\n1 ≦ W, H ≦ 100\n\n1 ≦ N ≦ 100\n\n0 ≦ x_i ≦ W (1 ≦ i ≦ N)\n\n0 ≦ y_i ≦ H (1 ≦ i ≦ N)\n\nW, H (21:32, added), x_i and y_i are integers.\n\na_i (1 ≦ i ≦ N) is 1, 2, 3 or 4.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nW H N\nx_1 y_1 a_1\nx_2 y_2 a_2\n:\nx_N y_N a_N\n\nOutput\n\nPrint the area of the white region within the rectangle after Snuke finished painting.\n\nSample Input 1\n\n5 4 2\n2 1 1\n3 3 4\n\nSample Output 1\n\n9\n\nThe figure below shows the rectangle before Snuke starts painting.\n\nFirst, as (x_1, y_1) = (2, 1) and a_1 = 1, he paints the region satisfying x < 2 within the rectangle:\n\nThen, as (x_2, y_2) = (3, 3) and a_2 = 4, he paints the region satisfying y > 3 within the rectangle:\n\nNow, the area of the white region within the rectangle is 9.\n\nSample Input 2\n\n5 4 3\n2 1 1\n3 3 4\n1 4 2\n\nSample Output 2\n\n0\n\nIt is possible that the whole region within the rectangle is painted black.\n\nSample Input 3\n\n10 10 5\n1 6 1\n4 1 3\n6 9 4\n9 4 2\n3 1 3\n\nSample Output 3\n\n64", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 938, "cpu_time_ms": 333, "memory_kb": 27164}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s080678952", "group_id": "codeNet:p03946", "input_text": "import scala.io.StdIn._\nobject Main extends App {\n @scala.annotation.tailrec\n def next(diff: Int, maxValue: Int, num: Int, as: Seq[Int]): Int = {\n as match {\n case Nil => num\n case _ => \n val targetValue = as.head\n val newDiff = maxValue - targetValue\n if (newDiff > diff) next(newDiff, maxValue, 1, as.tail) // must be (targetValue < maxValue)\n else if (newDiff == diff) next(diff, targetValue, num + 1, as.tail) // must be (targetValue > maxValue)\n else next(diff, targetValue max maxValue, num, as.tail)\n }\n }\n\n /*\n val n = readLine.split(\" \").head map {_.toInt}\n */\n import java.io._\n val br = new BufferedReader(new InputStreamReader(System.in));\n val n = br.readLine.split(\" \").head map {_.toInt}\n val as = (readLine.split(\" \") map {_.toInt}).toSeq.reverse\n\n println(next(0, as.head, 0, as.tail))\n}", "language": "Scala", "metadata": {"date": 1479336201, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03946.html", "problem_id": "p03946", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03946/input.txt", "sample_output_relpath": "derived/input_output/data/p03946/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03946/Scala/s080678952.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s080678952", "user_id": "u132324749"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "import scala.io.StdIn._\nobject Main extends App {\n @scala.annotation.tailrec\n def next(diff: Int, maxValue: Int, num: Int, as: Seq[Int]): Int = {\n as match {\n case Nil => num\n case _ => \n val targetValue = as.head\n val newDiff = maxValue - targetValue\n if (newDiff > diff) next(newDiff, maxValue, 1, as.tail) // must be (targetValue < maxValue)\n else if (newDiff == diff) next(diff, targetValue, num + 1, as.tail) // must be (targetValue > maxValue)\n else next(diff, targetValue max maxValue, num, as.tail)\n }\n }\n\n /*\n val n = readLine.split(\" \").head map {_.toInt}\n */\n import java.io._\n val br = new BufferedReader(new InputStreamReader(System.in));\n val n = br.readLine.split(\" \").head map {_.toInt}\n val as = (readLine.split(\" \") map {_.toInt}).toSeq.reverse\n\n println(next(0, as.head, 0, as.tail))\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N towns located in a line, conveniently numbered 1 through N. Takahashi the merchant is going on a travel from town 1 to town N, buying and selling apples.\n\nTakahashi will begin the travel at town 1, with no apple in his possession. The actions that can be performed during the travel are as follows:\n\nMove: When at town i (i < N), move to town i + 1.\n\nMerchandise: Buy or sell an arbitrary number of apples at the current town. Here, it is assumed that one apple can always be bought and sold for A_i yen (the currency of Japan) at town i (1 ≦ i ≦ N), where A_i are distinct integers. Also, you can assume that he has an infinite supply of money.\n\nFor some reason, there is a constraint on merchandising apple during the travel: the sum of the number of apples bought and the number of apples sold during the whole travel, must be at most T. (Note that a single apple can be counted in both.)\n\nDuring the travel, Takahashi will perform actions so that the profit of the travel is maximized. Here, the profit of the travel is the amount of money that is gained by selling apples, minus the amount of money that is spent on buying apples. Note that we are not interested in apples in his possession at the end of the travel.\n\nAoki, a business rival of Takahashi, wants to trouble Takahashi by manipulating the market price of apples. Prior to the beginning of Takahashi's travel, Aoki can change A_i into another arbitrary non-negative integer A_i' for any town i, any number of times. The cost of performing this operation is |A_i - A_i'|. After performing this operation, different towns may have equal values of A_i.\n\nAoki's objective is to decrease Takahashi's expected profit by at least 1 yen. Find the minimum total cost to achieve it. You may assume that Takahashi's expected profit is initially at least 1 yen.\n\nConstraints\n\n1 ≦ N ≦ 10^5\n\n1 ≦ A_i ≦ 10^9 (1 ≦ i ≦ N)\n\nA_i are distinct.\n\n2 ≦ T ≦ 10^9\n\nIn the initial state, Takahashi's expected profit is at least 1 yen.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN T\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum total cost to decrease Takahashi's expected profit by at least 1 yen.\n\nSample Input 1\n\n3 2\n100 50 200\n\nSample Output 1\n\n1\n\nIn the initial state, Takahashi can achieve the maximum profit of 150 yen as follows:\n\nMove from town 1 to town 2.\n\nBuy one apple for 50 yen at town 2.\n\nMove from town 2 to town 3.\n\nSell one apple for 200 yen at town 3.\n\nIf, for example, Aoki changes the price of an apple at town 2 from 50 yen to 51 yen, Takahashi will not be able to achieve the profit of 150 yen. The cost of performing this operation is 1, thus the answer is 1.\n\nThere are other ways to decrease Takahashi's expected profit, such as changing the price of an apple at town 3 from 200 yen to 199 yen.\n\nSample Input 2\n\n5 8\n50 30 40 10 20\n\nSample Output 2\n\n2\n\nSample Input 3\n\n10 100\n7 10 4 5 9 3 6 8 2 1\n\nSample Output 3\n\n2", "sample_input": "3 2\n100 50 200\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03946", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N towns located in a line, conveniently numbered 1 through N. Takahashi the merchant is going on a travel from town 1 to town N, buying and selling apples.\n\nTakahashi will begin the travel at town 1, with no apple in his possession. The actions that can be performed during the travel are as follows:\n\nMove: When at town i (i < N), move to town i + 1.\n\nMerchandise: Buy or sell an arbitrary number of apples at the current town. Here, it is assumed that one apple can always be bought and sold for A_i yen (the currency of Japan) at town i (1 ≦ i ≦ N), where A_i are distinct integers. Also, you can assume that he has an infinite supply of money.\n\nFor some reason, there is a constraint on merchandising apple during the travel: the sum of the number of apples bought and the number of apples sold during the whole travel, must be at most T. (Note that a single apple can be counted in both.)\n\nDuring the travel, Takahashi will perform actions so that the profit of the travel is maximized. Here, the profit of the travel is the amount of money that is gained by selling apples, minus the amount of money that is spent on buying apples. Note that we are not interested in apples in his possession at the end of the travel.\n\nAoki, a business rival of Takahashi, wants to trouble Takahashi by manipulating the market price of apples. Prior to the beginning of Takahashi's travel, Aoki can change A_i into another arbitrary non-negative integer A_i' for any town i, any number of times. The cost of performing this operation is |A_i - A_i'|. After performing this operation, different towns may have equal values of A_i.\n\nAoki's objective is to decrease Takahashi's expected profit by at least 1 yen. Find the minimum total cost to achieve it. You may assume that Takahashi's expected profit is initially at least 1 yen.\n\nConstraints\n\n1 ≦ N ≦ 10^5\n\n1 ≦ A_i ≦ 10^9 (1 ≦ i ≦ N)\n\nA_i are distinct.\n\n2 ≦ T ≦ 10^9\n\nIn the initial state, Takahashi's expected profit is at least 1 yen.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN T\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum total cost to decrease Takahashi's expected profit by at least 1 yen.\n\nSample Input 1\n\n3 2\n100 50 200\n\nSample Output 1\n\n1\n\nIn the initial state, Takahashi can achieve the maximum profit of 150 yen as follows:\n\nMove from town 1 to town 2.\n\nBuy one apple for 50 yen at town 2.\n\nMove from town 2 to town 3.\n\nSell one apple for 200 yen at town 3.\n\nIf, for example, Aoki changes the price of an apple at town 2 from 50 yen to 51 yen, Takahashi will not be able to achieve the profit of 150 yen. The cost of performing this operation is 1, thus the answer is 1.\n\nThere are other ways to decrease Takahashi's expected profit, such as changing the price of an apple at town 3 from 200 yen to 199 yen.\n\nSample Input 2\n\n5 8\n50 30 40 10 20\n\nSample Output 2\n\n2\n\nSample Input 3\n\n10 100\n7 10 4 5 9 3 6 8 2 1\n\nSample Output 3\n\n2", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 866, "cpu_time_ms": 2102, "memory_kb": 110692}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s303328695", "group_id": "codeNet:p03957", "input_text": "object Main extends App{\n // Here your code !\n val scanner = new java.util.Scanner(System.in)\n println(cf(scanner.next))\n \n def cf(ins:String):String = ins match {\n case ins:String if ins.indexOf(\"C\") < ins.lastIndexOf(\"F\") => \"Yes\"\n case _ => \"No\"\n }\n}", "language": "Scala", "metadata": {"date": 1481214202, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03957.html", "problem_id": "p03957", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03957/input.txt", "sample_output_relpath": "derived/input_output/data/p03957/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03957/Scala/s303328695.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s303328695", "user_id": "u010863732"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "object Main extends App{\n // Here your code !\n val scanner = new java.util.Scanner(System.in)\n println(cf(scanner.next))\n \n def cf(ins:String):String = ins match {\n case ins:String if ins.indexOf(\"C\") < ins.lastIndexOf(\"F\") => \"Yes\"\n case _ => \"No\"\n }\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThis contest is CODEFESTIVAL, which can be shortened to the string CF by deleting some characters.\n\nMr. Takahashi, full of curiosity, wondered if he could obtain CF from other strings in the same way.\n\nYou are given a string s consisting of uppercase English letters.\nDetermine whether the string CF can be obtained from the string s by deleting some characters.\n\nConstraints\n\n2 ≤ |s| ≤ 100\n\nAll characters in s are uppercase English letters (A-Z).\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint Yes if the string CF can be obtained from the string s by deleting some characters.\nOtherwise print No.\n\nSample Input 1\n\nCODEFESTIVAL\n\nSample Output 1\n\nYes\n\nCF is obtained by deleting characters other than the first character C and the fifth character F.\n\nSample Input 2\n\nFESTIVALCODE\n\nSample Output 2\n\nNo\n\nFC can be obtained but CF cannot be obtained because you cannot change the order of the characters.\n\nSample Input 3\n\nCF\n\nSample Output 3\n\nYes\n\nIt is also possible not to delete any characters.\n\nSample Input 4\n\nFCF\n\nSample Output 4\n\nYes\n\nCF is obtained by deleting the first character.", "sample_input": "CODEFESTIVAL\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03957", "source_text": "Score : 100 points\n\nProblem Statement\n\nThis contest is CODEFESTIVAL, which can be shortened to the string CF by deleting some characters.\n\nMr. Takahashi, full of curiosity, wondered if he could obtain CF from other strings in the same way.\n\nYou are given a string s consisting of uppercase English letters.\nDetermine whether the string CF can be obtained from the string s by deleting some characters.\n\nConstraints\n\n2 ≤ |s| ≤ 100\n\nAll characters in s are uppercase English letters (A-Z).\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint Yes if the string CF can be obtained from the string s by deleting some characters.\nOtherwise print No.\n\nSample Input 1\n\nCODEFESTIVAL\n\nSample Output 1\n\nYes\n\nCF is obtained by deleting characters other than the first character C and the fifth character F.\n\nSample Input 2\n\nFESTIVALCODE\n\nSample Output 2\n\nNo\n\nFC can be obtained but CF cannot be obtained because you cannot change the order of the characters.\n\nSample Input 3\n\nCF\n\nSample Output 3\n\nYes\n\nIt is also possible not to delete any characters.\n\nSample Input 4\n\nFCF\n\nSample Output 4\n\nYes\n\nCF is obtained by deleting the first character.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 293, "cpu_time_ms": 431, "memory_kb": 22212}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s805910774", "group_id": "codeNet:p03959", "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 val T, A = map(N)(_ => sc.nextInt())\n sealed trait Fact\n case class Just(a: Int) extends Fact\n case class LE(a: Int) extends Fact\n\n def judge(fa: Fact, fb: Fact): Int = (fa, fb) match {\n case (Just(a), Just(b)) if a == b => 1\n case (Just(a), LE(b)) if a <= b => 1\n case (LE(a), Just(b)) if a >= b => 1\n case (LE(a), LE(b)) => min(a, b)\n case _ => 0\n }\n\n val factT, factA = Array.ofDim[Fact](N)\n var max = 0\n rep(N){ i =>\n if (T(i) > max) {\n factT(i) = Just(T(i))\n max = T(i)\n } else {\n factT(i) = LE(max)\n }\n }\n\n max = 0\n rep_r(N){ i =>\n if (A(i) > max) {\n factA(i) = Just(A(i))\n max = A(i)\n } else {\n factA(i) = LE(max)\n }\n }\n\n var ans = 1L\n rep(N){ i =>\n ans = ans * judge(factT(i), factA(i)) % MOD\n }\n\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 = 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": 1532303522, "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/s805910774.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s805910774", "user_id": "u460609472"}, "prompt_components": {"gold_output": "4\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 val T, A = map(N)(_ => sc.nextInt())\n sealed trait Fact\n case class Just(a: Int) extends Fact\n case class LE(a: Int) extends Fact\n\n def judge(fa: Fact, fb: Fact): Int = (fa, fb) match {\n case (Just(a), Just(b)) if a == b => 1\n case (Just(a), LE(b)) if a <= b => 1\n case (LE(a), Just(b)) if a >= b => 1\n case (LE(a), LE(b)) => min(a, b)\n case _ => 0\n }\n\n val factT, factA = Array.ofDim[Fact](N)\n var max = 0\n rep(N){ i =>\n if (T(i) > max) {\n factT(i) = Just(T(i))\n max = T(i)\n } else {\n factT(i) = LE(max)\n }\n }\n\n max = 0\n rep_r(N){ i =>\n if (A(i) > max) {\n factA(i) = Just(A(i))\n max = A(i)\n } else {\n factA(i) = LE(max)\n }\n }\n\n var ans = 1L\n rep(N){ i =>\n ans = ans * judge(factT(i), factA(i)) % MOD\n }\n\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 = 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\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3632, "cpu_time_ms": 753, "memory_kb": 57688}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s222024612", "group_id": "codeNet:p03959", "input_text": "object Main {\n def main(args: Array[String]): Unit = {\n var n = io.StdIn.readLine().toInt\n val t = io.StdIn.readLine().split(' ').map(_.toLong)\n val a = io.StdIn.readLine().split(' ').map(_.toLong)\n\n val h = scala.collection.mutable.ListBuffer.empty[Long]\n\n if (t(0) > a(0)) {\n println(0)\n return\n } else {\n if (n > 1 && a(0) > a(1) && t(0) != a(0)) {\n println(0)\n return\n } else {\n h += t(0)\n }\n }\n\n for (i <- 1 to (n - 2)) {\n val ht = if (t(i - 1) < t(i)) t(i) else 0\n val ha = if (a(i) > a(i + 1)) a(i) else 0\n if (ht == 0) {\n h += ha\n } else if (ha == 0) {\n h += ht\n } else if (ht == ha) {\n h += ha\n } else {\n println(0)\n return\n }\n }\n\n if (t(n - 1) < a(n - 1)) {\n println(0)\n return\n } else {\n if (n > 1 && t(n - 2) < t(n - 1) && t(n - 1) != a(n - 1)) {\n println(0)\n return\n } else {\n h += a(n - 1)\n }\n }\n\n val candidate = scala.collection.mutable.ListBuffer.empty[(Long, Int)]\n var j = 0\n while (j < n) {\n if (h(j) > 0) {\n j += 1\n } else {\n var k = j\n while (h(k) == 0) {\n k += 1\n }\n candidate += Tuple2(Math.min(h(j - 1), h(k)), k - j)\n j = k\n }\n }\n\n val p = Math.pow(10, 9).toLong + 7\n\n val res = candidate.foldLeft(1L) { (acc, pair) =>\n (acc * Math.pow(pair._1 % p, pair._2).toLong % p) % p\n }\n\n println(res)\n }\n\n}\n\n", "language": "Scala", "metadata": {"date": 1477277037, "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/s222024612.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s222024612", "user_id": "u382513779"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]): Unit = {\n var n = io.StdIn.readLine().toInt\n val t = io.StdIn.readLine().split(' ').map(_.toLong)\n val a = io.StdIn.readLine().split(' ').map(_.toLong)\n\n val h = scala.collection.mutable.ListBuffer.empty[Long]\n\n if (t(0) > a(0)) {\n println(0)\n return\n } else {\n if (n > 1 && a(0) > a(1) && t(0) != a(0)) {\n println(0)\n return\n } else {\n h += t(0)\n }\n }\n\n for (i <- 1 to (n - 2)) {\n val ht = if (t(i - 1) < t(i)) t(i) else 0\n val ha = if (a(i) > a(i + 1)) a(i) else 0\n if (ht == 0) {\n h += ha\n } else if (ha == 0) {\n h += ht\n } else if (ht == ha) {\n h += ha\n } else {\n println(0)\n return\n }\n }\n\n if (t(n - 1) < a(n - 1)) {\n println(0)\n return\n } else {\n if (n > 1 && t(n - 2) < t(n - 1) && t(n - 1) != a(n - 1)) {\n println(0)\n return\n } else {\n h += a(n - 1)\n }\n }\n\n val candidate = scala.collection.mutable.ListBuffer.empty[(Long, Int)]\n var j = 0\n while (j < n) {\n if (h(j) > 0) {\n j += 1\n } else {\n var k = j\n while (h(k) == 0) {\n k += 1\n }\n candidate += Tuple2(Math.min(h(j - 1), h(k)), k - j)\n j = k\n }\n }\n\n val p = Math.pow(10, 9).toLong + 7\n\n val res = candidate.foldLeft(1L) { (acc, pair) =>\n (acc * Math.pow(pair._1 % p, pair._2).toLong % p) % p\n }\n\n println(res)\n }\n\n}\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1520, "cpu_time_ms": 2102, "memory_kb": 65088}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s548795922", "group_id": "codeNet:p03962", "input_text": "object Main extends App {\n val c = io.StdIn.readLine.split(\" \").distinct\n println(c.length)\n}\n", "language": "Scala", "metadata": {"date": 1498105172, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03962.html", "problem_id": "p03962", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03962/input.txt", "sample_output_relpath": "derived/input_output/data/p03962/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03962/Scala/s548795922.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s548795922", "user_id": "u893154287"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "object Main extends App {\n val c = io.StdIn.readLine.split(\" \").distinct\n println(c.length)\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAtCoDeer the deer recently bought three paint cans.\nThe color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c.\nHere, the color of each paint can is represented by an integer between 1 and 100, inclusive.\n\nSince he is forgetful, he might have bought more than one paint can in the same color.\nCount the number of different kinds of colors of these paint cans and tell him.\n\nConstraints\n\n1≦a,b,c≦100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nPrint the number of different kinds of colors of the paint cans.\n\nSample Input 1\n\n3 1 4\n\nSample Output 1\n\n3\n\nThree different colors: 1, 3, and 4.\n\nSample Input 2\n\n3 3 33\n\nSample Output 2\n\n2\n\nTwo different colors: 3 and 33.", "sample_input": "3 1 4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03962", "source_text": "Score : 100 points\n\nProblem Statement\n\nAtCoDeer the deer recently bought three paint cans.\nThe color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c.\nHere, the color of each paint can is represented by an integer between 1 and 100, inclusive.\n\nSince he is forgetful, he might have bought more than one paint can in the same color.\nCount the number of different kinds of colors of these paint cans and tell him.\n\nConstraints\n\n1≦a,b,c≦100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nPrint the number of different kinds of colors of the paint cans.\n\nSample Input 1\n\n3 1 4\n\nSample Output 1\n\n3\n\nThree different colors: 1, 3, and 4.\n\nSample Input 2\n\n3 3 33\n\nSample Output 2\n\n2\n\nTwo different colors: 3 and 33.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 100, "cpu_time_ms": 323, "memory_kb": 27192}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s775269268", "group_id": "codeNet:p03963", "input_text": "object Main extends App {\n val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList\n val n = inputs(0).toInt\n val k = inputs(1).toInt\n\n println(solve(n, k))\n\n def solve(n: Int, k: Int): Int = {\n (1 until n).foldLeft(k){ (acc, _) => acc * (k - 1) }\n }\n}", "language": "Scala", "metadata": {"date": 1592083287, "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/s775269268.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s775269268", "user_id": "u631102131"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList\n val n = inputs(0).toInt\n val k = inputs(1).toInt\n\n println(solve(n, k))\n\n def solve(n: Int, k: Int): Int = {\n (1 until n).foldLeft(k){ (acc, _) => acc * (k - 1) }\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 336, "memory_kb": 25500}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s975811837", "group_id": "codeNet:p03963", "input_text": "import scala.math.pow\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val List(n, k) = io.StdIn.readLine.split(' ').toList.map(c => c.toInt)\n val answer = k * pow((k - 1), (n - 1)).toLong\n\n println(answer)\n }\n}\n", "language": "Scala", "metadata": {"date": 1476849431, "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/s975811837.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s975811837", "user_id": "u794141067"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import scala.math.pow\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val List(n, k) = io.StdIn.readLine.split(' ').toList.map(c => c.toInt)\n val answer = k * pow((k - 1), (n - 1)).toLong\n\n println(answer)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 441, "memory_kb": 21552}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s176359403", "group_id": "codeNet:p03966", "input_text": "import io.StdIn.readLine\n\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val n = readLine().toInt\n\n var t, a = 1.0\n\n for (i <- 1 to n) {\n val Array(ti, ai) = readLine().split(' ').map(_.toDouble)\n val times = Math.max(Math.ceil(t / ti).toInt, Math.ceil(a / ai).toInt)\n t = ti * times\n a = ai * times\n }\n\n println((t + a).toInt)\n }\n}\n", "language": "Scala", "metadata": {"date": 1476580396, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03966.html", "problem_id": "p03966", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03966/input.txt", "sample_output_relpath": "derived/input_output/data/p03966/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03966/Scala/s176359403.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s176359403", "user_id": "u382513779"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "import io.StdIn.readLine\n\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val n = readLine().toInt\n\n var t, a = 1.0\n\n for (i <- 1 to n) {\n val Array(ti, ai) = readLine().split(' ').map(_.toDouble)\n val times = Math.max(Math.ceil(t / ti).toInt, Math.ceil(a / ai).toInt)\n t = ti * times\n a = ai * times\n }\n\n println((t + a).toInt)\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is seeing a quick report of election results on TV.\nTwo candidates are standing for the election: Takahashi and Aoki.\nThe report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes.\nAtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i.\nIt is known that each candidate had at least one vote when he checked the report for the first time.\n\nFind the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time.\nIt can be assumed that the number of votes obtained by each candidate never decreases.\n\nConstraints\n\n1≦N≦1000\n\n1≦T_i,A_i≦1000 (1≦i≦N)\n\nT_i and A_i (1≦i≦N) are coprime.\n\nIt is guaranteed that the correct answer is at most 10^{18}.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nT_1 A_1\nT_2 A_2\n:\nT_N A_N\n\nOutput\n\nPrint the minimum possible total number of votes obtained by Takahashi and Aoki when AtCoDeer checked the report for the N-th time.\n\nSample Input 1\n\n3\n2 3\n1 1\n3 2\n\nSample Output 1\n\n10\n\nWhen the numbers of votes obtained by the two candidates change as 2,3 → 3,3 → 6,4, the total number of votes at the end is 10, which is the minimum possible number.\n\nSample Input 2\n\n4\n1 1\n1 1\n1 5\n1 100\n\nSample Output 2\n\n101\n\nIt is possible that neither candidate obtained a vote between the moment when he checked the report, and the moment when he checked it for the next time.\n\nSample Input 3\n\n5\n3 10\n48 17\n31 199\n231 23\n3 2\n\nSample Output 3\n\n6930", "sample_input": "3\n2 3\n1 1\n3 2\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03966", "source_text": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is seeing a quick report of election results on TV.\nTwo candidates are standing for the election: Takahashi and Aoki.\nThe report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes.\nAtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i.\nIt is known that each candidate had at least one vote when he checked the report for the first time.\n\nFind the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time.\nIt can be assumed that the number of votes obtained by each candidate never decreases.\n\nConstraints\n\n1≦N≦1000\n\n1≦T_i,A_i≦1000 (1≦i≦N)\n\nT_i and A_i (1≦i≦N) are coprime.\n\nIt is guaranteed that the correct answer is at most 10^{18}.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nT_1 A_1\nT_2 A_2\n:\nT_N A_N\n\nOutput\n\nPrint the minimum possible total number of votes obtained by Takahashi and Aoki when AtCoDeer checked the report for the N-th time.\n\nSample Input 1\n\n3\n2 3\n1 1\n3 2\n\nSample Output 1\n\n10\n\nWhen the numbers of votes obtained by the two candidates change as 2,3 → 3,3 → 6,4, the total number of votes at the end is 10, which is the minimum possible number.\n\nSample Input 2\n\n4\n1 1\n1 1\n1 5\n1 100\n\nSample Output 2\n\n101\n\nIt is possible that neither candidate obtained a vote between the moment when he checked the report, and the moment when he checked it for the next time.\n\nSample Input 3\n\n5\n3 10\n48 17\n31 199\n231 23\n3 2\n\nSample Output 3\n\n6930", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 380, "cpu_time_ms": 495, "memory_kb": 22944}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s123063256", "group_id": "codeNet:p03971", "input_text": "object Main extends App {\n @scala.annotation.tailrec\n def loop(chars: List[Char], a: Int, b: Int, result: Vector[String]): Vector[String] = chars match {\n case List() => result\n case x::xs => x match {\n case 'a' if 0 < a =>\n loop(xs, a - 1, b, result :+ \"Yes\")\n case 'a' if 0 < b =>\n loop(xs, 0, b - 1, result :+ \"Yes\")\n case 'b' if 0 < b =>\n loop(xs, a, b - 1, result :+ \"Yes\")\n case _ =>\n loop(xs, a, b, result :+ \"No\")\n }\n }\n val sc = new java.util.Scanner(System.in)\n val _, a, b = sc.nextInt()\n val s = sc.next().toCharArray.toList\n loop(s, a, b, Vector.empty).foreach(println)\n}", "language": "Scala", "metadata": {"date": 1589940131, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03971.html", "problem_id": "p03971", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03971/input.txt", "sample_output_relpath": "derived/input_output/data/p03971/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03971/Scala/s123063256.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s123063256", "user_id": "u737111725"}, "prompt_components": {"gold_output": "Yes\nYes\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo\n", "input_to_evaluate": "object Main extends App {\n @scala.annotation.tailrec\n def loop(chars: List[Char], a: Int, b: Int, result: Vector[String]): Vector[String] = chars match {\n case List() => result\n case x::xs => x match {\n case 'a' if 0 < a =>\n loop(xs, a - 1, b, result :+ \"Yes\")\n case 'a' if 0 < b =>\n loop(xs, 0, b - 1, result :+ \"Yes\")\n case 'b' if 0 < b =>\n loop(xs, a, b - 1, result :+ \"Yes\")\n case _ =>\n loop(xs, a, b, result :+ \"No\")\n }\n }\n val sc = new java.util.Scanner(System.in)\n val _, a, b = sc.nextInt()\n val s = sc.next().toCharArray.toList\n loop(s, a, b, Vector.empty).foreach(println)\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these.\n\nOnly Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests.\n\nA Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.\n\nAn overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.\n\nA string S is assigned indicating attributes of all participants. If the i-th character of string S is a, this means the participant ranked i-th in the Qualification contests is a Japanese student; b means the participant ranked i-th is an overseas student; and c means the participant ranked i-th is neither of these.\n\nWrite a program that outputs for all the participants in descending rank either Yes if they passed the Qualification contests or No if they did not pass.\n\nConstraints\n\n1≦N,A,B≦100000\n\nA+B≦N\n\nS is N characters long.\n\nS consists only of the letters a, b and c.\n\nInput\n\nInputs are provided from Standard Input in the following form.\n\nN A B\nS\n\nOutput\n\nOutput N lines. On the i-th line, output Yes if the i-th participant passed the Qualification contests or No if that participant did not pass.\n\nSample Input 1\n\n10 2 3\nabccabaabb\n\nSample Output 1\n\nYes\nYes\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo\n\nThe first, second, fifth, sixth, and seventh participants pass the Qualification contests.\n\nSample Input 2\n\n12 5 2\ncabbabaacaba\n\nSample Output 2\n\nNo\nYes\nYes\nYes\nYes\nNo\nYes\nYes\nNo\nYes\nNo\nNo\n\nThe sixth participant is third among overseas students and thus does not pass the Qualification contests.\n\nSample Input 3\n\n5 2 2\nccccc\n\nSample Output 3\n\nNo\nNo\nNo\nNo\nNo", "sample_input": "10 2 3\nabccabaabb\n"}, "reference_outputs": ["Yes\nYes\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo\n"], "source_document_id": "p03971", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these.\n\nOnly Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests.\n\nA Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.\n\nAn overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.\n\nA string S is assigned indicating attributes of all participants. If the i-th character of string S is a, this means the participant ranked i-th in the Qualification contests is a Japanese student; b means the participant ranked i-th is an overseas student; and c means the participant ranked i-th is neither of these.\n\nWrite a program that outputs for all the participants in descending rank either Yes if they passed the Qualification contests or No if they did not pass.\n\nConstraints\n\n1≦N,A,B≦100000\n\nA+B≦N\n\nS is N characters long.\n\nS consists only of the letters a, b and c.\n\nInput\n\nInputs are provided from Standard Input in the following form.\n\nN A B\nS\n\nOutput\n\nOutput N lines. On the i-th line, output Yes if the i-th participant passed the Qualification contests or No if that participant did not pass.\n\nSample Input 1\n\n10 2 3\nabccabaabb\n\nSample Output 1\n\nYes\nYes\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo\n\nThe first, second, fifth, sixth, and seventh participants pass the Qualification contests.\n\nSample Input 2\n\n12 5 2\ncabbabaacaba\n\nSample Output 2\n\nNo\nYes\nYes\nYes\nYes\nNo\nYes\nYes\nNo\nYes\nNo\nNo\n\nThe sixth participant is third among overseas students and thus does not pass the Qualification contests.\n\nSample Input 3\n\n5 2 2\nccccc\n\nSample Output 3\n\nNo\nNo\nNo\nNo\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 648, "cpu_time_ms": 1297, "memory_kb": 51968}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s034346377", "group_id": "codeNet:p03993", "input_text": "import java.util.Scanner\n\nobject Main {\n\tdef main(args: Array[String]) {\n\t\tval sc = new Scanner(System.in)\n\t\tval N = sc.nextInt()\n\t\tval a = List.fill(N)(sc.nextInt)\n\n\t\tval result = a.zipWithIndex.count( t => a(t._1 - 1) == (t._2 + 1)) / 2\n\n\t\tprintln(result)\n\t}\n}", "language": "Scala", "metadata": {"date": 1474767393, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p03993.html", "problem_id": "p03993", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p03993/input.txt", "sample_output_relpath": "derived/input_output/data/p03993/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03993/Scala/s034346377.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s034346377", "user_id": "u794141067"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n\tdef main(args: Array[String]) {\n\t\tval sc = new Scanner(System.in)\n\t\tval N = sc.nextInt()\n\t\tval a = List.fill(N)(sc.nextInt)\n\n\t\tval result = a.zipWithIndex.count( t => a(t._1 - 1) == (t._2 + 1)) / 2\n\n\t\tprintln(result)\n\t}\n}", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N rabbits, numbered 1 through N.\n\nThe i-th (1≤i≤N) rabbit likes rabbit a_i.\nNote that no rabbit can like itself, that is, a_i≠i.\n\nFor a pair of rabbits i and j (i<j), we call the pair (i,j) a friendly pair if the following condition is met.\n\nRabbit i likes rabbit j and rabbit j likes rabbit i.\n\nCalculate the number of the friendly pairs.\n\nConstraints\n\n2≤N≤10^5\n\n1≤a_i≤N\n\na_i≠i\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of the friendly pairs.\n\nSample Input 1\n\n4\n2 1 4 3\n\nSample Output 1\n\n2\n\nThere are two friendly pairs: (1,2) and (3,4).\n\nSample Input 2\n\n3\n2 3 1\n\nSample Output 2\n\n0\n\nThere are no friendly pairs.\n\nSample Input 3\n\n5\n5 5 5 5 1\n\nSample Output 3\n\n1\n\nThere is one friendly pair: (1,5).", "sample_input": "4\n2 1 4 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03993", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N rabbits, numbered 1 through N.\n\nThe i-th (1≤i≤N) rabbit likes rabbit a_i.\nNote that no rabbit can like itself, that is, a_i≠i.\n\nFor a pair of rabbits i and j (i<j), we call the pair (i,j) a friendly pair if the following condition is met.\n\nRabbit i likes rabbit j and rabbit j likes rabbit i.\n\nCalculate the number of the friendly pairs.\n\nConstraints\n\n2≤N≤10^5\n\n1≤a_i≤N\n\na_i≠i\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of the friendly pairs.\n\nSample Input 1\n\n4\n2 1 4 3\n\nSample Output 1\n\n2\n\nThere are two friendly pairs: (1,2) and (3,4).\n\nSample Input 2\n\n3\n2 3 1\n\nSample Output 2\n\n0\n\nThere are no friendly pairs.\n\nSample Input 3\n\n5\n5 5 5 5 1\n\nSample Output 3\n\n1\n\nThere is one friendly pair: (1,5).", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 262, "cpu_time_ms": 2102, "memory_kb": 54568}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s513096986", "group_id": "codeNet:p03994", "input_text": "import java.io.{BufferedOutputStream, BufferedReader, FileOutputStream, InputStreamReader, PrintWriter}\nimport java.lang\n\nimport scala.annotation.tailrec\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 alphaNum = 'z' - 'a' + 1\n\n val s = get[String]\n var k = get[Int]\n\n def step1(s: String): Array[Char] = {\n val cs = s.toCharArray\n\n for (index <- cs.indices) {\n val remain = ('a' + alphaNum - cs(index)) % alphaNum\n if (remain <= k) {\n cs(index) = 'a'\n k -= remain\n }\n }\n\n cs\n }\n\n def step2(cs: Array[Char]): Array[Char] = {\n cs(cs.length - 1) = ((cs.last - 'a' + k % alphaNum) % alphaNum + 'a').toChar\n cs\n }\n\n out.println(step2(step1(s)))\n\n out.flush()\n log(\"=== end\")\n debug {\n debugOut.flush()\n }\n }\n}", "language": "Scala", "metadata": {"date": 1599954756, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/s513096986.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s513096986", "user_id": "u178269371"}, "prompt_components": {"gold_output": "aya\n", "input_to_evaluate": "import java.io.{BufferedOutputStream, BufferedReader, FileOutputStream, InputStreamReader, PrintWriter}\nimport java.lang\n\nimport scala.annotation.tailrec\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 alphaNum = 'z' - 'a' + 1\n\n val s = get[String]\n var k = get[Int]\n\n def step1(s: String): Array[Char] = {\n val cs = s.toCharArray\n\n for (index <- cs.indices) {\n val remain = ('a' + alphaNum - cs(index)) % alphaNum\n if (remain <= k) {\n cs(index) = 'a'\n k -= remain\n }\n }\n\n cs\n }\n\n def step2(cs: Array[Char]): Array[Char] = {\n cs(cs.length - 1) = ((cs.last - 'a' + k % alphaNum) % alphaNum + 'a').toChar\n cs\n }\n\n out.println(step2(step1(s)))\n\n out.flush()\n log(\"=== end\")\n debug {\n debugOut.flush()\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4836, "cpu_time_ms": 525, "memory_kb": 57228}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s223736607", "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 - 2)) 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 = {\n val c = str.last + (k % 26)\n if (c > 'z') c - 25\n else c\n }\n\n val ans = newStr.mkString + lastChar.toChar\n println(ans)\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1474774035, "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/s223736607.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s223736607", "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 - 2)) 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 = {\n val c = str.last + (k % 26)\n if (c > 'z') c - 25\n else c\n }\n\n val ans = newStr.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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 581, "memory_kb": 32108}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s379692934", "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 - 2)) 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 = {\n val c = str.last + k % 26\n if (c > 'z') c - 26\n else c\n }\n\n val ans = newStr.mkString + lastChar.toChar\n println(ans)\n }\n}\n\n", "language": "Scala", "metadata": {"date": 1474773508, "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/s379692934.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s379692934", "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 - 2)) 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 = {\n val c = str.last + k % 26\n if (c > 'z') c - 26\n else c\n }\n\n val ans = newStr.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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 595, "memory_kb": 32048}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s212007001", "group_id": "codeNet:p03998", "input_text": "object Main extends App {\n val sc = new java.util.Scanner(System.in)\n val a, b, c = sc.next()\n\n def solve(a: String, b: String, c: String, turn: Char): String = {\n turn match {\n case 'a' =>\n if (a.isEmpty) {\n \"A\"\n } else {\n solve(a.tail, b, c, a.head)\n }\n case 'b' =>\n if (b.isEmpty) {\n \"B\"\n } else {\n solve(a, b.tail, c, b.head)\n }\n case 'c' =>\n if (c.isEmpty) {\n \"C\"\n } else {\n solve(a, b, c.tail, c.head)\n }\n }\n }\n\n println(solve(a, b, c, 'a'))\n}\n", "language": "Scala", "metadata": {"date": 1594566090, "filename_ext": "scala", "original_language": "Scala (2.13.1)", "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/s212007001.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s212007001", "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 a, b, c = sc.next()\n\n def solve(a: String, b: String, c: String, turn: Char): String = {\n turn match {\n case 'a' =>\n if (a.isEmpty) {\n \"A\"\n } else {\n solve(a.tail, b, c, a.head)\n }\n case 'b' =>\n if (b.isEmpty) {\n \"B\"\n } else {\n solve(a, b.tail, c, b.head)\n }\n case 'c' =>\n if (c.isEmpty) {\n \"C\"\n } else {\n solve(a, b, c.tail, c.head)\n }\n }\n }\n\n println(solve(a, b, c, 'a'))\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 593, "cpu_time_ms": 488, "memory_kb": 55384}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s529622558", "group_id": "codeNet:p04001", "input_text": "import scala.io.StdIn\n\nobject Main extends App {\n val s = StdIn.readLine()\n\n def solve(s: String): Long = {\n var ret :Long = s.toLong\n\n (1 to s.length - 1).foreach {i =>\n\n (1 to s.length - 1).combinations(i).foreach {j =>\n\n if (j.isEmpty)\n ret += s.toInt\n\n (0 to j.length).foreach { k =>\n if (k == 0) {\n ret = ret + s.substring(0, j(k)).toInt\n } else if (k == j.length) {\n ret = ret + s.substring(j(k - 1)).toInt\n } else {\n ret = ret + s.substring(j(k - 1), j(k)).toInt\n }\n }\n }\n }\n ret\n }\n\n println(solve(s))\n}\n \n\n", "language": "Scala", "metadata": {"date": 1560346765, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p04001.html", "problem_id": "p04001", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04001/input.txt", "sample_output_relpath": "derived/input_output/data/p04001/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04001/Scala/s529622558.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s529622558", "user_id": "u258933429"}, "prompt_components": {"gold_output": "176\n", "input_to_evaluate": "import scala.io.StdIn\n\nobject Main extends App {\n val s = StdIn.readLine()\n\n def solve(s: String): Long = {\n var ret :Long = s.toLong\n\n (1 to s.length - 1).foreach {i =>\n\n (1 to s.length - 1).combinations(i).foreach {j =>\n\n if (j.isEmpty)\n ret += s.toInt\n\n (0 to j.length).foreach { k =>\n if (k == 0) {\n ret = ret + s.substring(0, j(k)).toInt\n } else if (k == j.length) {\n ret = ret + s.substring(j(k - 1)).toInt\n } else {\n ret = ret + s.substring(j(k - 1), j(k)).toInt\n }\n }\n }\n }\n ret\n }\n\n println(solve(s))\n}\n \n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S consisting of digits between 1 and 9, inclusive.\nYou can insert the letter + into some of the positions (possibly none) between two letters in this string.\nHere, + must not occur consecutively after insertion.\n\nAll strings that can be obtained in this way can be evaluated as formulas.\n\nEvaluate all possible formulas, and print the sum of the results.\n\nConstraints\n\n1 \\leq |S| \\leq 10\n\nAll letters in S are digits between 1 and 9, inclusive.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the sum of the evaluated value over all possible formulas.\n\nSample Input 1\n\n125\n\nSample Output 1\n\n176\n\nThere are 4 formulas that can be obtained: 125, 1+25, 12+5 and 1+2+5. When each formula is evaluated,\n\n125\n\n1+25=26\n\n12+5=17\n\n1+2+5=8\n\nThus, the sum is 125+26+17+8=176.\n\nSample Input 2\n\n9999999999\n\nSample Output 2\n\n12656242944", "sample_input": "125\n"}, "reference_outputs": ["176\n"], "source_document_id": "p04001", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S consisting of digits between 1 and 9, inclusive.\nYou can insert the letter + into some of the positions (possibly none) between two letters in this string.\nHere, + must not occur consecutively after insertion.\n\nAll strings that can be obtained in this way can be evaluated as formulas.\n\nEvaluate all possible formulas, and print the sum of the results.\n\nConstraints\n\n1 \\leq |S| \\leq 10\n\nAll letters in S are digits between 1 and 9, inclusive.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the sum of the evaluated value over all possible formulas.\n\nSample Input 1\n\n125\n\nSample Output 1\n\n176\n\nThere are 4 formulas that can be obtained: 125, 1+25, 12+5 and 1+2+5. When each formula is evaluated,\n\n125\n\n1+25=26\n\n12+5=17\n\n1+2+5=8\n\nThus, the sum is 125+26+17+8=176.\n\nSample Input 2\n\n9999999999\n\nSample Output 2\n\n12656242944", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 643, "cpu_time_ms": 390, "memory_kb": 25536}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s963169817", "group_id": "codeNet:p04011", "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 k = sc.nextInt();\n val x = sc.nextInt();\n val y = sc.nextInt();\n\n if(n <= k) {\n println(n * x);\n }\n else {\n println(k * x + (n - k) * y);\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1472434772, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p04011.html", "problem_id": "p04011", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04011/input.txt", "sample_output_relpath": "derived/input_output/data/p04011/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04011/Scala/s963169817.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s963169817", "user_id": "u751758346"}, "prompt_components": {"gold_output": "48000\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 k = sc.nextInt();\n val x = sc.nextInt();\n val y = sc.nextInt();\n\n if(n <= k) {\n println(n * x);\n }\n else {\n println(k * x + (n - k) * y);\n }\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a hotel with the following accommodation fee:\n\nX yen (the currency of Japan) per night, for the first K nights\n\nY yen per night, for the (K+1)-th and subsequent nights\n\nTak is staying at this hotel for N consecutive nights.\nFind his total accommodation fee.\n\nConstraints\n\n1 \\leq N, K \\leq 10000\n\n1 \\leq Y < X \\leq 10000\n\nN,\\,K,\\,X,\\,Y are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nK\nX\nY\n\nOutput\n\nPrint Tak's total accommodation fee.\n\nSample Input 1\n\n5\n3\n10000\n9000\n\nSample Output 1\n\n48000\n\nThe accommodation fee is as follows:\n\n10000 yen for the 1-st night\n\n10000 yen for the 2-nd night\n\n10000 yen for the 3-rd night\n\n9000 yen for the 4-th night\n\n9000 yen for the 5-th night\n\nThus, the total is 48000 yen.\n\nSample Input 2\n\n2\n3\n10000\n9000\n\nSample Output 2\n\n20000", "sample_input": "5\n3\n10000\n9000\n"}, "reference_outputs": ["48000\n"], "source_document_id": "p04011", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a hotel with the following accommodation fee:\n\nX yen (the currency of Japan) per night, for the first K nights\n\nY yen per night, for the (K+1)-th and subsequent nights\n\nTak is staying at this hotel for N consecutive nights.\nFind his total accommodation fee.\n\nConstraints\n\n1 \\leq N, K \\leq 10000\n\n1 \\leq Y < X \\leq 10000\n\nN,\\,K,\\,X,\\,Y are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nK\nX\nY\n\nOutput\n\nPrint Tak's total accommodation fee.\n\nSample Input 1\n\n5\n3\n10000\n9000\n\nSample Output 1\n\n48000\n\nThe accommodation fee is as follows:\n\n10000 yen for the 1-st night\n\n10000 yen for the 2-nd night\n\n10000 yen for the 3-rd night\n\n9000 yen for the 4-th night\n\n9000 yen for the 5-th night\n\nThus, the total is 48000 yen.\n\nSample Input 2\n\n2\n3\n10000\n9000\n\nSample Output 2\n\n20000", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 310, "cpu_time_ms": 858, "memory_kb": 22336}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s408168563", "group_id": "codeNet:p04012", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val w = sc.next.split(\"(?<=.)\")\n\n val ac = new Array[Int](26)\n val alphabets = \"abcdefghijklmnopqrstuvwxyz\"\n\n val tArr =\n w.foldLeft(ac){case (arr, c) =>\n val i = alphabets.indexOf(c)\n val x = arr(i)\n arr.update(i, x + 1)\n arr\n }\n\n val res = if(tArr.forall(_ % 2 == 0)) \"Yes\" else \"No\"\n\n println(res)\n}\n", "language": "Scala", "metadata": {"date": 1555259679, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p04012.html", "problem_id": "p04012", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04012/input.txt", "sample_output_relpath": "derived/input_output/data/p04012/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04012/Scala/s408168563.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s408168563", "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 val w = sc.next.split(\"(?<=.)\")\n\n val ac = new Array[Int](26)\n val alphabets = \"abcdefghijklmnopqrstuvwxyz\"\n\n val tArr =\n w.foldLeft(ac){case (arr, c) =>\n val i = alphabets.indexOf(c)\n val x = arr(i)\n arr.update(i, x + 1)\n arr\n }\n\n val res = if(tArr.forall(_ % 2 == 0)) \"Yes\" else \"No\"\n\n println(res)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nLet w be a string consisting of lowercase letters.\nWe will call w beautiful if the following condition is satisfied:\n\nEach lowercase letter of the English alphabet occurs even number of times in w.\n\nYou are given the string w. Determine if w is beautiful.\n\nConstraints\n\n1 \\leq |w| \\leq 100\n\nw consists of lowercase letters (a-z).\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nw\n\nOutput\n\nPrint Yes if w is beautiful. Print No otherwise.\n\nSample Input 1\n\nabaccaba\n\nSample Output 1\n\nYes\n\na occurs four times, b occurs twice, c occurs twice and the other letters occur zero times.\n\nSample Input 2\n\nhthth\n\nSample Output 2\n\nNo", "sample_input": "abaccaba\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p04012", "source_text": "Score : 200 points\n\nProblem Statement\n\nLet w be a string consisting of lowercase letters.\nWe will call w beautiful if the following condition is satisfied:\n\nEach lowercase letter of the English alphabet occurs even number of times in w.\n\nYou are given the string w. Determine if w is beautiful.\n\nConstraints\n\n1 \\leq |w| \\leq 100\n\nw consists of lowercase letters (a-z).\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nw\n\nOutput\n\nPrint Yes if w is beautiful. Print No otherwise.\n\nSample Input 1\n\nabaccaba\n\nSample Output 1\n\nYes\n\na occurs four times, b occurs twice, c occurs twice and the other letters occur zero times.\n\nSample Input 2\n\nhthth\n\nSample Output 2\n\nNo", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 423, "cpu_time_ms": 355, "memory_kb": 27316}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s831427797", "group_id": "codeNet:p04013", "input_text": "import scala.io.Source\n\nobject Main extends App {\n val xs = Source.stdin.getLines()\n val Array(n, a) = xs.next().split(' ').map(_.toInt)\n val ds = xs.next().split(' ').map(_.toInt)\n \n println(solve(n, a, ds))\n \n def solve(n: Int, a: Int, ds: Seq[Int]): String = {\n var c = 0\n \n powerset(ds).foreach { dss =>\n val avg = if (dss.length > 0) {\n if (dss.sum % dss.length == 0) {\n dss.sum / dss.length\n } else {\n -1\n }\n } else {\n -1\n }\n c = c + (if (avg == a) 1 else 0)\n }\n \n c.toString\n }\n \n def powerset[T](xss: Seq[T]): Seq[Seq[T]] = {\n xss match {\n case Nil =>\n Seq(Seq.empty[T])\n case x +: xs =>\n val qs = powerset(xs)\n val rs = for (ps <- qs) yield x +: ps\n rs ++: qs\n }\n }\n}\n", "language": "Scala", "metadata": {"date": 1555074875, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p04013.html", "problem_id": "p04013", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04013/input.txt", "sample_output_relpath": "derived/input_output/data/p04013/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04013/Scala/s831427797.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s831427797", "user_id": "u182281714"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "import scala.io.Source\n\nobject Main extends App {\n val xs = Source.stdin.getLines()\n val Array(n, a) = xs.next().split(' ').map(_.toInt)\n val ds = xs.next().split(' ').map(_.toInt)\n \n println(solve(n, a, ds))\n \n def solve(n: Int, a: Int, ds: Seq[Int]): String = {\n var c = 0\n \n powerset(ds).foreach { dss =>\n val avg = if (dss.length > 0) {\n if (dss.sum % dss.length == 0) {\n dss.sum / dss.length\n } else {\n -1\n }\n } else {\n -1\n }\n c = c + (if (avg == a) 1 else 0)\n }\n \n c.toString\n }\n \n def powerset[T](xss: Seq[T]): Seq[Seq[T]] = {\n xss match {\n case Nil =>\n Seq(Seq.empty[T])\n case x +: xs =>\n val qs = powerset(xs)\n val rs = for (ps <- qs) yield x +: ps\n rs ++: qs\n }\n }\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": "p04013", "source_text": "Score : 300 points\n\nProblem Statement\n\nTak has N cards. On the i-th (1 \\leq i \\leq N) card is written an integer x_i.\nHe is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A.\nIn how many ways can he make his selection?\n\nConstraints\n\n1 \\leq N \\leq 50\n\n1 \\leq A \\leq 50\n\n1 \\leq x_i \\leq 50\n\nN,\\,A,\\,x_i are integers.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying 1 \\leq N \\leq 16.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN A\nx_1 x_2 ... x_N\n\nOutput\n\nPrint the number of ways to select cards such that the average of the written integers is exactly A.\n\nSample Input 1\n\n4 8\n7 9 8 9\n\nSample Output 1\n\n5\n\nThe following are the 5 ways to select cards such that the average is 8:\n\nSelect the 3-rd card.\n\nSelect the 1-st and 2-nd cards.\n\nSelect the 1-st and 4-th cards.\n\nSelect the 1-st, 2-nd and 3-rd cards.\n\nSelect the 1-st, 3-rd and 4-th cards.\n\nSample Input 2\n\n3 8\n6 6 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n8 5\n3 6 2 8 7 6 5 9\n\nSample Output 3\n\n19\n\nSample Input 4\n\n33 3\n3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3\n\nSample Output 4\n\n8589934591\n\nThe answer may not fit into a 32-bit integer.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 990, "cpu_time_ms": 2119, "memory_kb": 246540}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s624864656", "group_id": "codeNet:p04013", "input_text": "object Main {\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val n, a = sc.nextInt\n val x = List.fill(n)(sc.nextInt)\n\n val nx = (a :: x).max * n\n\n val dp = collection.mutable.ArrayBuffer.fill(n + 1, n + 1, nx + 1)(-1L)\n def dpFunc(j: Int, k: Int, s: Int): Long = {\n \tif (dp(j)(k)(s) >= 0) return dp(j)(k)(s)\n\n \tval ret = if (j == 0 && k == 0 && s == 0) 1L\n \t\telse if (j > 0 && s < x(j - 1)) dpFunc(j - 1, k, s)\n \t\telse if (j > 0 && k > 0 && s >= x(j - 1)) dpFunc(j - 1, k, s) + dpFunc(j - 1, k - 1, s - x(j - 1))\n \t\telse 0L\n \tdp(j)(k)(s) = ret\n \tret\n }\n\n val ans = (1 to n).map(k => dpFunc(n, k, k * a)).sum\n\n println(ans)\n\n }\n}", "language": "Scala", "metadata": {"date": 1473444695, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p04013.html", "problem_id": "p04013", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04013/input.txt", "sample_output_relpath": "derived/input_output/data/p04013/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04013/Scala/s624864656.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s624864656", "user_id": "u172469353"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "object Main {\n def main(args:Array[String]) = {\n val sc = new java.util.Scanner(System.in)\n val n, a = sc.nextInt\n val x = List.fill(n)(sc.nextInt)\n\n val nx = (a :: x).max * n\n\n val dp = collection.mutable.ArrayBuffer.fill(n + 1, n + 1, nx + 1)(-1L)\n def dpFunc(j: Int, k: Int, s: Int): Long = {\n \tif (dp(j)(k)(s) >= 0) return dp(j)(k)(s)\n\n \tval ret = if (j == 0 && k == 0 && s == 0) 1L\n \t\telse if (j > 0 && s < x(j - 1)) dpFunc(j - 1, k, s)\n \t\telse if (j > 0 && k > 0 && s >= x(j - 1)) dpFunc(j - 1, k, s) + dpFunc(j - 1, k - 1, s - x(j - 1))\n \t\telse 0L\n \tdp(j)(k)(s) = ret\n \tret\n }\n\n val ans = (1 to n).map(k => dpFunc(n, k, k * a)).sum\n\n println(ans)\n\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": "p04013", "source_text": "Score : 300 points\n\nProblem Statement\n\nTak has N cards. On the i-th (1 \\leq i \\leq N) card is written an integer x_i.\nHe is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A.\nIn how many ways can he make his selection?\n\nConstraints\n\n1 \\leq N \\leq 50\n\n1 \\leq A \\leq 50\n\n1 \\leq x_i \\leq 50\n\nN,\\,A,\\,x_i are integers.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying 1 \\leq N \\leq 16.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN A\nx_1 x_2 ... x_N\n\nOutput\n\nPrint the number of ways to select cards such that the average of the written integers is exactly A.\n\nSample Input 1\n\n4 8\n7 9 8 9\n\nSample Output 1\n\n5\n\nThe following are the 5 ways to select cards such that the average is 8:\n\nSelect the 3-rd card.\n\nSelect the 1-st and 2-nd cards.\n\nSelect the 1-st and 4-th cards.\n\nSelect the 1-st, 2-nd and 3-rd cards.\n\nSelect the 1-st, 3-rd and 4-th cards.\n\nSample Input 2\n\n3 8\n6 6 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n8 5\n3 6 2 8 7 6 5 9\n\nSample Output 3\n\n19\n\nSample Input 4\n\n33 3\n3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3\n\nSample Output 4\n\n8589934591\n\nThe answer may not fit into a 32-bit integer.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 709, "cpu_time_ms": 1417, "memory_kb": 64048}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s237721443", "group_id": "codeNet:p04015", "input_text": "import java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val n = sc.nextInt\n\n val a = sc.nextInt\n val xs = Vector.fill(n)(sc.nextDouble)\n\n val ints = for (i <- 1 to n) yield (0 until n).combinations(i)\n\n val dA = a.toDouble\n var ans = 0L\n for {\n p <- ints.flatten\n } yield {\n val ave = p.map(xs(_)).sum / p.length\n if (ave == dA) {\n ans = ans + 1L\n }\n }\n\n println(ans)\n}\n", "language": "Scala", "metadata": {"date": 1493074979, "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/s237721443.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s237721443", "user_id": "u220774651"}, "prompt_components": {"gold_output": "5\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\n val a = sc.nextInt\n val xs = Vector.fill(n)(sc.nextDouble)\n\n val ints = for (i <- 1 to n) yield (0 until n).combinations(i)\n\n val dA = a.toDouble\n var ans = 0L\n for {\n p <- ints.flatten\n } yield {\n val ave = p.map(xs(_)).sum / p.length\n if (ave == dA) {\n ans = ans + 1L\n }\n }\n\n println(ans)\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTak has N cards. On the i-th (1 \\leq i \\leq N) card is written an integer x_i.\nHe is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A.\nIn how many ways can he make his selection?\n\nConstraints\n\n1 \\leq N \\leq 50\n\n1 \\leq A \\leq 50\n\n1 \\leq x_i \\leq 50\n\nN,\\,A,\\,x_i are integers.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying 1 \\leq N \\leq 16.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN A\nx_1 x_2 ... x_N\n\nOutput\n\nPrint the number of ways to select cards such that the average of the written integers is exactly A.\n\nSample Input 1\n\n4 8\n7 9 8 9\n\nSample Output 1\n\n5\n\nThe following are the 5 ways to select cards such that the average is 8:\n\nSelect the 3-rd card.\n\nSelect the 1-st and 2-nd cards.\n\nSelect the 1-st and 4-th cards.\n\nSelect the 1-st, 2-nd and 3-rd cards.\n\nSelect the 1-st, 3-rd and 4-th cards.\n\nSample Input 2\n\n3 8\n6 6 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n8 5\n3 6 2 8 7 6 5 9\n\nSample Output 3\n\n19\n\nSample Input 4\n\n33 3\n3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3\n\nSample Output 4\n\n8589934591\n\nThe answer may not fit into a 32-bit integer.", "sample_input": "4 8\n7 9 8 9\n"}, "reference_outputs": ["5\n"], "source_document_id": "p04015", "source_text": "Score : 300 points\n\nProblem Statement\n\nTak has N cards. On the i-th (1 \\leq i \\leq N) card is written an integer x_i.\nHe is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A.\nIn how many ways can he make his selection?\n\nConstraints\n\n1 \\leq N \\leq 50\n\n1 \\leq A \\leq 50\n\n1 \\leq x_i \\leq 50\n\nN,\\,A,\\,x_i are integers.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying 1 \\leq N \\leq 16.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN A\nx_1 x_2 ... x_N\n\nOutput\n\nPrint the number of ways to select cards such that the average of the written integers is exactly A.\n\nSample Input 1\n\n4 8\n7 9 8 9\n\nSample Output 1\n\n5\n\nThe following are the 5 ways to select cards such that the average is 8:\n\nSelect the 3-rd card.\n\nSelect the 1-st and 2-nd cards.\n\nSelect the 1-st and 4-th cards.\n\nSelect the 1-st, 2-nd and 3-rd cards.\n\nSelect the 1-st, 3-rd and 4-th cards.\n\nSample Input 2\n\n3 8\n6 6 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n8 5\n3 6 2 8 7 6 5 9\n\nSample Output 3\n\n19\n\nSample Input 4\n\n33 3\n3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3\n\nSample Output 4\n\n8589934591\n\nThe answer may not fit into a 32-bit integer.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 428, "cpu_time_ms": 2119, "memory_kb": 302748}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s450262199", "group_id": "codeNet:p04016", "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, S = sc.nextLong()\n\n def test(b: Long, n: Long, s: Long): Boolean = {\n if (n == 0) {\n s == 0\n } else {\n val c = n % b\n test(b, n / b, s - c)\n }\n }\n\n def toRt: Option[Int] = {\n (2 to math.sqrt(N).toInt) find { b =>\n test(b, N, S)\n }\n }\n\n def afterRt: Option[Long] = {\n val rt = math.sqrt(N).toLong\n (rt to 1) find { c =>\n if ((N - S) % c != 0) false\n else {\n val b = (N - S) / c + 1\n val c0 = S - c\n 0 < c0 && c0 * c0 < N && rt < b\n }\n }\n }\n\n val ans = if (S == 1) N else toRt orElse afterRt getOrElse -1\n out.println(ans)\n }\n\n def main(args: Array[String]): Unit = {\n solve()\n out.flush()\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)(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": 1533354684, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p04016.html", "problem_id": "p04016", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04016/input.txt", "sample_output_relpath": "derived/input_output/data/p04016/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04016/Scala/s450262199.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s450262199", "user_id": "u460609472"}, "prompt_components": {"gold_output": "10\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, S = sc.nextLong()\n\n def test(b: Long, n: Long, s: Long): Boolean = {\n if (n == 0) {\n s == 0\n } else {\n val c = n % b\n test(b, n / b, s - c)\n }\n }\n\n def toRt: Option[Int] = {\n (2 to math.sqrt(N).toInt) find { b =>\n test(b, N, S)\n }\n }\n\n def afterRt: Option[Long] = {\n val rt = math.sqrt(N).toLong\n (rt to 1) find { c =>\n if ((N - S) % c != 0) false\n else {\n val b = (N - S) / c + 1\n val c0 = S - c\n 0 < c0 && c0 * c0 < N && rt < b\n }\n }\n }\n\n val ans = if (S == 1) N else toRt orElse afterRt getOrElse -1\n out.println(ans)\n }\n\n def main(args: Array[String]): Unit = {\n solve()\n out.flush()\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)(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 : 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": "p04016", "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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3398, "cpu_time_ms": 396, "memory_kb": 27944}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s048104535", "group_id": "codeNet:p04026", "input_text": "import java.io.{BufferedReader, IOException, InputStream, InputStreamReader}\nimport java.util.StringTokenizer\n\nimport scala.collection.mutable\nimport scala.util.Sorting\nimport math.{min, max, abs}\n\nobject Main {\n def solve(): Unit = {\n val sc = new InputReader(System.in)\n val S = sc.next\n\n def two = (S zip S.drop(1)).zipWithIndex find { case ((c1, c2), _) => c1 == c2 }\n def three = (S zip S.drop(1) zip S.drop(2)).zipWithIndex find { case (((c1, c2), c3), _) => c1 == c2 || c1 == c3 || c2 == c3}\n\n val ans = (two map { case (_, i) =>\n s\"${i + 1} ${i + 2}\"\n }) orElse (three map { case (_, i) =>\n s\"${i + 1} ${i + 3}\"\n }) getOrElse \"-1 -1\"\n\n println(ans)\n }\n\n def main(args: Array[String]): Unit = {\n solve()\n }\n\n\n\n class InputReader(val stream: InputStream) {\n val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n 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": 1528180235, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p04026.html", "problem_id": "p04026", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04026/input.txt", "sample_output_relpath": "derived/input_output/data/p04026/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04026/Scala/s048104535.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s048104535", "user_id": "u460609472"}, "prompt_components": {"gold_output": "2 5\n", "input_to_evaluate": "import java.io.{BufferedReader, IOException, InputStream, InputStreamReader}\nimport java.util.StringTokenizer\n\nimport scala.collection.mutable\nimport scala.util.Sorting\nimport math.{min, max, abs}\n\nobject Main {\n def solve(): Unit = {\n val sc = new InputReader(System.in)\n val S = sc.next\n\n def two = (S zip S.drop(1)).zipWithIndex find { case ((c1, c2), _) => c1 == c2 }\n def three = (S zip S.drop(1) zip S.drop(2)).zipWithIndex find { case (((c1, c2), c3), _) => c1 == c2 || c1 == c3 || c2 == c3}\n\n val ans = (two map { case (_, i) =>\n s\"${i + 1} ${i + 2}\"\n }) orElse (three map { case (_, i) =>\n s\"${i + 1} ${i + 3}\"\n }) getOrElse \"-1 -1\"\n\n println(ans)\n }\n\n def main(args: Array[String]): Unit = {\n solve()\n }\n\n\n\n class InputReader(val stream: InputStream) {\n val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n 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\nGiven a string t, we will call it unbalanced if and only if the length of t is at least 2, and more than half of the letters in t are the same. For example, both voodoo and melee are unbalanced, while neither noon nor a is.\n\nYou are given a string s consisting of lowercase letters. Determine if there exists a (contiguous) substring of s that is unbalanced. If the answer is positive, show a position where such a substring occurs in s.\n\nConstraints\n\n2 ≦ |s| ≦ 10^5\n\ns consists of lowercase letters.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying 2 ≦ N ≦ 100.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nIf there exists no unbalanced substring of s, print -1 -1.\n\nIf there exists an unbalanced substring of s, let one such substring be s_a s_{a+1} ... s_{b} (1 ≦ a < b ≦ |s|), and print a b. If there exists more than one such substring, any of them will be accepted.\n\nSample Input 1\n\nneeded\n\nSample Output 1\n\n2 5\n\nThe string s_2 s_3 s_4 s_5 = eede is unbalanced. There are also other unbalanced substrings. For example, the output 2 6 will also be accepted.\n\nSample Input 2\n\natcoder\n\nSample Output 2\n\n-1 -1\n\nThe string atcoder contains no unbalanced substring.", "sample_input": "needed\n"}, "reference_outputs": ["2 5\n"], "source_document_id": "p04026", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven a string t, we will call it unbalanced if and only if the length of t is at least 2, and more than half of the letters in t are the same. For example, both voodoo and melee are unbalanced, while neither noon nor a is.\n\nYou are given a string s consisting of lowercase letters. Determine if there exists a (contiguous) substring of s that is unbalanced. If the answer is positive, show a position where such a substring occurs in s.\n\nConstraints\n\n2 ≦ |s| ≦ 10^5\n\ns consists of lowercase letters.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying 2 ≦ N ≦ 100.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nIf there exists no unbalanced substring of s, print -1 -1.\n\nIf there exists an unbalanced substring of s, let one such substring be s_a s_{a+1} ... s_{b} (1 ≦ a < b ≦ |s|), and print a b. If there exists more than one such substring, any of them will be accepted.\n\nSample Input 1\n\nneeded\n\nSample Output 1\n\n2 5\n\nThe string s_2 s_3 s_4 s_5 = eede is unbalanced. There are also other unbalanced substrings. For example, the output 2 6 will also be accepted.\n\nSample Input 2\n\natcoder\n\nSample Output 2\n\n-1 -1\n\nThe string atcoder contains no unbalanced substring.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1221, "cpu_time_ms": 729, "memory_kb": 64276}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s525787920", "group_id": "codeNet:p04026", "input_text": "object Main {\n def main(args: Array[String]) {\n val sc = new java.util.Scanner(System.in)\n val s = sc.next\n val unb = findUnbalance(s)\n println(unb(0) + \" \" + unb(1))\n }\n def findUnbalance(s: String) = {\n if (s.length < 2) {\n Array(-1, -1) \n } else if (s.length == 2) {\n if (s(0) == s(1)) Array(0, 1) else Array(-1, -1)\n } else {\n \n val N = s.length\n var unb = Array(-1, -1)\n for (i <- 0 until N-2) {\n val s1 = s(i)\n val s2 = s(i+1)\n val s3 = s(i+2)\n if (s1 == s2) unb = Array(i+1, i+2)\n if (s2 == s3) unb = Array(i+2, i+3)\n if (s1 == s3) unb = Array(i+1, i+3)\n }\n val u = unb\n u\n }\n }\n\n}", "language": "Scala", "metadata": {"date": 1471140017, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p04026.html", "problem_id": "p04026", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04026/input.txt", "sample_output_relpath": "derived/input_output/data/p04026/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04026/Scala/s525787920.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s525787920", "user_id": "u529914106"}, "prompt_components": {"gold_output": "2 5\n", "input_to_evaluate": "object Main {\n def main(args: Array[String]) {\n val sc = new java.util.Scanner(System.in)\n val s = sc.next\n val unb = findUnbalance(s)\n println(unb(0) + \" \" + unb(1))\n }\n def findUnbalance(s: String) = {\n if (s.length < 2) {\n Array(-1, -1) \n } else if (s.length == 2) {\n if (s(0) == s(1)) Array(0, 1) else Array(-1, -1)\n } else {\n \n val N = s.length\n var unb = Array(-1, -1)\n for (i <- 0 until N-2) {\n val s1 = s(i)\n val s2 = s(i+1)\n val s3 = s(i+2)\n if (s1 == s2) unb = Array(i+1, i+2)\n if (s2 == s3) unb = Array(i+2, i+3)\n if (s1 == s3) unb = Array(i+1, i+3)\n }\n val u = unb\n u\n }\n }\n\n}", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven a string t, we will call it unbalanced if and only if the length of t is at least 2, and more than half of the letters in t are the same. For example, both voodoo and melee are unbalanced, while neither noon nor a is.\n\nYou are given a string s consisting of lowercase letters. Determine if there exists a (contiguous) substring of s that is unbalanced. If the answer is positive, show a position where such a substring occurs in s.\n\nConstraints\n\n2 ≦ |s| ≦ 10^5\n\ns consists of lowercase letters.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying 2 ≦ N ≦ 100.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nIf there exists no unbalanced substring of s, print -1 -1.\n\nIf there exists an unbalanced substring of s, let one such substring be s_a s_{a+1} ... s_{b} (1 ≦ a < b ≦ |s|), and print a b. If there exists more than one such substring, any of them will be accepted.\n\nSample Input 1\n\nneeded\n\nSample Output 1\n\n2 5\n\nThe string s_2 s_3 s_4 s_5 = eede is unbalanced. There are also other unbalanced substrings. For example, the output 2 6 will also be accepted.\n\nSample Input 2\n\natcoder\n\nSample Output 2\n\n-1 -1\n\nThe string atcoder contains no unbalanced substring.", "sample_input": "needed\n"}, "reference_outputs": ["2 5\n"], "source_document_id": "p04026", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven a string t, we will call it unbalanced if and only if the length of t is at least 2, and more than half of the letters in t are the same. For example, both voodoo and melee are unbalanced, while neither noon nor a is.\n\nYou are given a string s consisting of lowercase letters. Determine if there exists a (contiguous) substring of s that is unbalanced. If the answer is positive, show a position where such a substring occurs in s.\n\nConstraints\n\n2 ≦ |s| ≦ 10^5\n\ns consists of lowercase letters.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying 2 ≦ N ≦ 100.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nIf there exists no unbalanced substring of s, print -1 -1.\n\nIf there exists an unbalanced substring of s, let one such substring be s_a s_{a+1} ... s_{b} (1 ≦ a < b ≦ |s|), and print a b. If there exists more than one such substring, any of them will be accepted.\n\nSample Input 1\n\nneeded\n\nSample Output 1\n\n2 5\n\nThe string s_2 s_3 s_4 s_5 = eede is unbalanced. There are also other unbalanced substrings. For example, the output 2 6 will also be accepted.\n\nSample Input 2\n\natcoder\n\nSample Output 2\n\n-1 -1\n\nThe string atcoder contains no unbalanced substring.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 678, "cpu_time_ms": 841, "memory_kb": 25004}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s908607733", "group_id": "codeNet:p04029", "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).sum)\n}\n", "language": "Scala", "metadata": {"date": 1596339437, "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/s908607733.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s908607733", "user_id": "u737111725"}, "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 println(1.to(N).sum)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 497, "memory_kb": 55440}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s915391786", "group_id": "codeNet:p04030", "input_text": "\nimport java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val s = sc.next\n val cs: Seq[Char] = s.toCharArray.toList\n\n def solve(cs: Seq[Char], acc: String): String = cs match {\n case x +: xs =>\n x match {\n case 'B' => if (acc.isEmpty) solve(xs, \"\") else solve(xs, acc.substring(0, acc.length - 1))\n case z => solve(xs, acc + z)\n }\n case _ => acc\n }\n\n val ans = solve(cs, \"\")\n\n println(ans)\n}\n", "language": "Scala", "metadata": {"date": 1492468448, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p04030.html", "problem_id": "p04030", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04030/input.txt", "sample_output_relpath": "derived/input_output/data/p04030/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04030/Scala/s915391786.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s915391786", "user_id": "u220774651"}, "prompt_components": {"gold_output": "00\n", "input_to_evaluate": "\nimport java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n val s = sc.next\n val cs: Seq[Char] = s.toCharArray.toList\n\n def solve(cs: Seq[Char], acc: String): String = cs match {\n case x +: xs =>\n x match {\n case 'B' => if (acc.isEmpty) solve(xs, \"\") else solve(xs, acc.substring(0, acc.length - 1))\n case z => solve(xs, acc + z)\n }\n case _ => acc\n }\n\n val ans = solve(cs, \"\")\n\n println(ans)\n}\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the 0 key, the 1 key and the backspace key.\n\nTo begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string:\n\nThe 0 key: a letter 0 will be inserted to the right of the string.\n\nThe 1 key: a letter 1 will be inserted to the right of the string.\n\nThe backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.\n\nSig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter 0 stands for the 0 key, the letter 1 stands for the 1 key and the letter B stands for the backspace key. What string is displayed in the editor now?\n\nConstraints\n\n1 ≦ |s| ≦ 10 (|s| denotes the length of s)\n\ns consists of the letters 0, 1 and B.\n\nThe correct answer is not an empty string.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the string displayed in the editor in the end.\n\nSample Input 1\n\n01B0\n\nSample Output 1\n\n00\n\nEach time the key is pressed, the string in the editor will change as follows: 0, 01, 0, 00.\n\nSample Input 2\n\n0BB1\n\nSample Output 2\n\n1\n\nEach time the key is pressed, the string in the editor will change as follows: 0, (empty), (empty), 1.", "sample_input": "01B0\n"}, "reference_outputs": ["00\n"], "source_document_id": "p04030", "source_text": "Score : 200 points\n\nProblem Statement\n\nSig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the 0 key, the 1 key and the backspace key.\n\nTo begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string:\n\nThe 0 key: a letter 0 will be inserted to the right of the string.\n\nThe 1 key: a letter 1 will be inserted to the right of the string.\n\nThe backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.\n\nSig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter 0 stands for the 0 key, the letter 1 stands for the 1 key and the letter B stands for the backspace key. What string is displayed in the editor now?\n\nConstraints\n\n1 ≦ |s| ≦ 10 (|s| denotes the length of s)\n\ns consists of the letters 0, 1 and B.\n\nThe correct answer is not an empty string.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the string displayed in the editor in the end.\n\nSample Input 1\n\n01B0\n\nSample Output 1\n\n00\n\nEach time the key is pressed, the string in the editor will change as follows: 0, 01, 0, 00.\n\nSample Input 2\n\n0BB1\n\nSample Output 2\n\n1\n\nEach time the key is pressed, the string in the editor will change as follows: 0, (empty), (empty), 1.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 458, "cpu_time_ms": 333, "memory_kb": 25500}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s114825271", "group_id": "codeNet:p04033", "input_text": "import java.util.Scanner\n\nimport scala.annotation.tailrec\n\nobject Util {\n @tailrec\n def loop(start: Int, end: Int)(f: Int => Unit) {\n if (start < end) {\n f(start)\n loop(start + 1, end)(f)\n }\n }\n}\n\nobject Main {\n def main(args: Array[String]): Unit = {\n //nextLineとnextを同時に使ったら死ぬ\n val sc = new Scanner(System.in)\n val a, b = sc.nextLong()\n if (a * b <= 0) {\n println(\"Zero\")\n } else if (a + b > 0) {\n println(\"Positive\")\n } else {\n if ((b - a) % 2 == 0) {\n println(\"Negative\")\n } else {\n println(\"Positive\")\n }\n }\n\n }\n}\n", "language": "Scala", "metadata": {"date": 1587775905, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p04033.html", "problem_id": "p04033", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04033/input.txt", "sample_output_relpath": "derived/input_output/data/p04033/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04033/Scala/s114825271.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s114825271", "user_id": "u336949031"}, "prompt_components": {"gold_output": "Positive\n", "input_to_evaluate": "import java.util.Scanner\n\nimport scala.annotation.tailrec\n\nobject Util {\n @tailrec\n def loop(start: Int, end: Int)(f: Int => Unit) {\n if (start < end) {\n f(start)\n loop(start + 1, end)(f)\n }\n }\n}\n\nobject Main {\n def main(args: Array[String]): Unit = {\n //nextLineとnextを同時に使ったら死ぬ\n val sc = new Scanner(System.in)\n val a, b = sc.nextLong()\n if (a * b <= 0) {\n println(\"Zero\")\n } else if (a + b > 0) {\n println(\"Positive\")\n } else {\n if ((b - a) % 2 == 0) {\n println(\"Negative\")\n } else {\n println(\"Positive\")\n }\n }\n\n }\n}\n", "problem_context": "Problem Statement\n\nYou are given two integers a and b (a≤b). Determine if the product of the integers a, a+1, …, b is positive, negative or zero.\n\nConstraints\n\na and b are integers.\n\n-10^9≤a≤b≤10^9\n\nPartial Score\n\nIn test cases worth 100 points, -10≤a≤b≤10.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the product is positive, print Positive. If it is negative, print Negative. If it is zero, print Zero.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\nPositive\n\n1×2×3=6 is positive.\n\nSample Input 2\n\n-3 -1\n\nSample Output 2\n\nNegative\n\n(-3)×(-2)×(-1)=-6 is negative.\n\nSample Input 3\n\n-1 1\n\nSample Output 3\n\nZero\n\n(-1)×0×1=0.", "sample_input": "1 3\n"}, "reference_outputs": ["Positive\n"], "source_document_id": "p04033", "source_text": "Problem Statement\n\nYou are given two integers a and b (a≤b). Determine if the product of the integers a, a+1, …, b is positive, negative or zero.\n\nConstraints\n\na and b are integers.\n\n-10^9≤a≤b≤10^9\n\nPartial Score\n\nIn test cases worth 100 points, -10≤a≤b≤10.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the product is positive, print Positive. If it is negative, print Negative. If it is zero, print Zero.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\nPositive\n\n1×2×3=6 is positive.\n\nSample Input 2\n\n-3 -1\n\nSample Output 2\n\nNegative\n\n(-3)×(-2)×(-1)=-6 is negative.\n\nSample Input 3\n\n-1 1\n\nSample Output 3\n\nZero\n\n(-1)×0×1=0.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 622, "cpu_time_ms": 357, "memory_kb": 25804}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s901428390", "group_id": "codeNet:p04033", "input_text": "object Main extends App {\n\tval Array(a, b) = scala.io.StdIn.readLine.split(\" \").map(_.toLong)\n\n\tif(a > 0L){\n\t\tprintln(\"Positive\")\n\t}else if(a<=0L && b>=0L){\n\t\tprintln(\"Zero\")\n\t}else{\n\n\t\tif(b-a+1L % 2L == 0L){\n\t\t\tprintln(\"Positive\")\n\t\t}else{\n\t\t\tprintln(\"Negative\")\n\t\t}\n\t}\n\t\n}", "language": "Scala", "metadata": {"date": 1527648569, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p04033.html", "problem_id": "p04033", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04033/input.txt", "sample_output_relpath": "derived/input_output/data/p04033/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04033/Scala/s901428390.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s901428390", "user_id": "u675876401"}, "prompt_components": {"gold_output": "Positive\n", "input_to_evaluate": "object Main extends App {\n\tval Array(a, b) = scala.io.StdIn.readLine.split(\" \").map(_.toLong)\n\n\tif(a > 0L){\n\t\tprintln(\"Positive\")\n\t}else if(a<=0L && b>=0L){\n\t\tprintln(\"Zero\")\n\t}else{\n\n\t\tif(b-a+1L % 2L == 0L){\n\t\t\tprintln(\"Positive\")\n\t\t}else{\n\t\t\tprintln(\"Negative\")\n\t\t}\n\t}\n\t\n}", "problem_context": "Problem Statement\n\nYou are given two integers a and b (a≤b). Determine if the product of the integers a, a+1, …, b is positive, negative or zero.\n\nConstraints\n\na and b are integers.\n\n-10^9≤a≤b≤10^9\n\nPartial Score\n\nIn test cases worth 100 points, -10≤a≤b≤10.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the product is positive, print Positive. If it is negative, print Negative. If it is zero, print Zero.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\nPositive\n\n1×2×3=6 is positive.\n\nSample Input 2\n\n-3 -1\n\nSample Output 2\n\nNegative\n\n(-3)×(-2)×(-1)=-6 is negative.\n\nSample Input 3\n\n-1 1\n\nSample Output 3\n\nZero\n\n(-1)×0×1=0.", "sample_input": "1 3\n"}, "reference_outputs": ["Positive\n"], "source_document_id": "p04033", "source_text": "Problem Statement\n\nYou are given two integers a and b (a≤b). Determine if the product of the integers a, a+1, …, b is positive, negative or zero.\n\nConstraints\n\na and b are integers.\n\n-10^9≤a≤b≤10^9\n\nPartial Score\n\nIn test cases worth 100 points, -10≤a≤b≤10.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b\n\nOutput\n\nIf the product is positive, print Positive. If it is negative, print Negative. If it is zero, print Zero.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\nPositive\n\n1×2×3=6 is positive.\n\nSample Input 2\n\n-3 -1\n\nSample Output 2\n\nNegative\n\n(-3)×(-2)×(-1)=-6 is negative.\n\nSample Input 3\n\n-1 1\n\nSample Output 3\n\nZero\n\n(-1)×0×1=0.", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 274, "cpu_time_ms": 323, "memory_kb": 27184}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s520779185", "group_id": "codeNet:p04034", "input_text": "object Main extends App {\n\n import scala.io.StdIn.readLine\n val Array(n, m) = readLine().trim.split(\" \").map(_.toInt)\n val arr = Array.fill(n)((1, 0))\n arr(0) = (0, 1)\n (0 until m).foreach { i =>\n val Array(a, b) = readLine().trim.split(\" \").map(_.toInt)\n val x = a - 1\n val y = b - 1\n if (0 < arr(x)._2) {\n arr(y) = (0, arr(y)._1 + arr(y)._2 + 1)\n arr(x) = (arr(x)._1, arr(x)._2 - 1)\n } else {\n if (0 < arr(y)._2) {\n arr(y) = (0, arr(y)._1 + arr(y)._2 + 1)\n arr(x) = (arr(x)._1 - 1, arr(x)._2)\n } else {\n arr(y) = (arr(y)._1 + 1, arr(y)._2)\n arr(x) = (arr(x)._1 - 1, arr(x)._2)\n }\n }\n }\n\n println(arr.count(t => t._2 > 0))\n\n}\n", "language": "Scala", "metadata": {"date": 1470017092, "filename_ext": "scala", "original_language": "Scala (2.11.7)", "problem_description_relpath": "problem_descriptions/p04034.html", "problem_id": "p04034", "resource_group": "medium_resource", "sample_input_relpath": "derived/input_output/data/p04034/input.txt", "sample_output_relpath": "derived/input_output/data/p04034/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04034/Scala/s520779185.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s520779185", "user_id": "u392294962"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "object Main extends App {\n\n import scala.io.StdIn.readLine\n val Array(n, m) = readLine().trim.split(\" \").map(_.toInt)\n val arr = Array.fill(n)((1, 0))\n arr(0) = (0, 1)\n (0 until m).foreach { i =>\n val Array(a, b) = readLine().trim.split(\" \").map(_.toInt)\n val x = a - 1\n val y = b - 1\n if (0 < arr(x)._2) {\n arr(y) = (0, arr(y)._1 + arr(y)._2 + 1)\n arr(x) = (arr(x)._1, arr(x)._2 - 1)\n } else {\n if (0 < arr(y)._2) {\n arr(y) = (0, arr(y)._1 + arr(y)._2 + 1)\n arr(x) = (arr(x)._1 - 1, arr(x)._2)\n } else {\n arr(y) = (arr(y)._1 + 1, arr(y)._2)\n arr(x) = (arr(x)._1 - 1, arr(x)._2)\n }\n }\n }\n\n println(arr.count(t => t._2 > 0))\n\n}\n", "problem_context": "Problem Statement\n\nWe have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.\n\nSnuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.\n\nFind the number of boxes that may contain the red ball after all operations are performed.\n\nConstraints\n\n2≤N≤10^5\n\n1≤M≤10^5\n\n1≤x_i,y_i≤N\n\nx_i≠y_i\n\nJust before the i-th operation is performed, box x_i contains at least 1 ball.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nx_1 y_1\n:\nx_M y_M\n\nOutput\n\nPrint the number of boxes that may contain the red ball after all operations are performed.\n\nSample Input 1\n\n3 2\n1 2\n2 3\n\nSample Output 1\n\n2\n\nJust after the first operation, box 1 is empty, box 2 contains one red ball and one white ball, and box 3 contains one white ball.\n\nNow, consider the second operation. If Snuke picks the red ball from box 2, the red ball will go into box 3. If he picks the white ball instead, the red ball will stay in box 2.\nThus, the number of boxes that may contain the red ball after all operations, is 2.\n\nSample Input 2\n\n3 3\n1 2\n2 3\n2 3\n\nSample Output 2\n\n1\n\nAll balls will go into box 3.\n\nSample Input 3\n\n4 4\n1 2\n2 3\n4 1\n3 4\n\nSample Output 3\n\n3", "sample_input": "3 2\n1 2\n2 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p04034", "source_text": "Problem Statement\n\nWe have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.\n\nSnuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.\n\nFind the number of boxes that may contain the red ball after all operations are performed.\n\nConstraints\n\n2≤N≤10^5\n\n1≤M≤10^5\n\n1≤x_i,y_i≤N\n\nx_i≠y_i\n\nJust before the i-th operation is performed, box x_i contains at least 1 ball.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nx_1 y_1\n:\nx_M y_M\n\nOutput\n\nPrint the number of boxes that may contain the red ball after all operations are performed.\n\nSample Input 1\n\n3 2\n1 2\n2 3\n\nSample Output 1\n\n2\n\nJust after the first operation, box 1 is empty, box 2 contains one red ball and one white ball, and box 3 contains one white ball.\n\nNow, consider the second operation. If Snuke picks the red ball from box 2, the red ball will go into box 3. If he picks the white ball instead, the red ball will stay in box 2.\nThus, the number of boxes that may contain the red ball after all operations, is 2.\n\nSample Input 2\n\n3 3\n1 2\n2 3\n2 3\n\nSample Output 2\n\n1\n\nAll balls will go into box 3.\n\nSample Input 3\n\n4 4\n1 2\n2 3\n4 1\n3 4\n\nSample Output 3\n\n3", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 706, "cpu_time_ms": 1673, "memory_kb": 41008}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s018705841", "group_id": "codeNet:p04043", "input_text": "object Main extends App {\n val n = readLine.split(' ').map(_.toInt).sorted.toList\n n match {\n case List(5,5,7) => println(\"YES\")\n case _ => println(\"NO\")\n }\n}", "language": "Scala", "metadata": {"date": 1589563799, "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/s018705841.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s018705841", "user_id": "u534504077"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "object Main extends App {\n val n = readLine.split(' ').map(_.toInt).sorted.toList\n n match {\n case List(5,5,7) => println(\"YES\")\n case _ => 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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 172, "cpu_time_ms": 326, "memory_kb": 25552}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s172054052", "group_id": "codeNet:p04043", "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 = 1000\n var flag = false\n\n for (i <- 0 to 9) {\n if (xss.contains(i)) {\n ten = ten.filter {\n _ != i\n }\n }\n }\n\n if(ten.contains(fee / 1000)){\n for(i <- 0 to 9){\n if(flag == false) {\n if (ten.contains((fee % 1000) / 100 + i)) {\n for (j <- 0 to 9) {\n if (ten.contains((fee % 100) / 10 + j)) {\n for (k <- 0 to 9) {\n if (ten.contains((fee % 10) + k)) {\n flag = true\n cash = (fee / 1000) * 1000 + (fee % 1000 / 100 + i) * 100 + (fee % 100 / 10 + j) * 10 + (fee % 10 + k)\n }\n }\n }\n }\n }\n }\n }\n }else {\n cash = (fee / 1000 + 1) * 1000 + ten.head * 111\n }\n\n print(cash)\n\n}", "language": "Scala", "metadata": {"date": 1585270070, "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/s172054052.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s172054052", "user_id": "u547865903"}, "prompt_components": {"gold_output": "YES\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 = 1000\n var flag = false\n\n for (i <- 0 to 9) {\n if (xss.contains(i)) {\n ten = ten.filter {\n _ != i\n }\n }\n }\n\n if(ten.contains(fee / 1000)){\n for(i <- 0 to 9){\n if(flag == false) {\n if (ten.contains((fee % 1000) / 100 + i)) {\n for (j <- 0 to 9) {\n if (ten.contains((fee % 100) / 10 + j)) {\n for (k <- 0 to 9) {\n if (ten.contains((fee % 10) + k)) {\n flag = true\n cash = (fee / 1000) * 1000 + (fee % 1000 / 100 + i) * 100 + (fee % 100 / 10 + j) * 10 + (fee % 10 + k)\n }\n }\n }\n }\n }\n }\n }\n }else {\n cash = (fee / 1000 + 1) * 1000 + ten.head * 111\n }\n\n print(cash)\n\n}", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIroha loves Haiku. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.\n\nTo create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.\n\nConstraints\n\n1≦A,B,C≦10\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf it is possible to construct a Haiku by using each of the phrases once, print YES (case-sensitive). Otherwise, print NO.\n\nSample Input 1\n\n5 5 7\n\nSample Output 1\n\nYES\n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\nSample Input 2\n\n7 7 5\n\nSample Output 2\n\nNO", "sample_input": "5 5 7\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p04043", "source_text": "Score : 100 points\n\nProblem Statement\n\nIroha loves Haiku. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.\n\nTo create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.\n\nConstraints\n\n1≦A,B,C≦10\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf it is possible to construct a Haiku by using each of the phrases once, print YES (case-sensitive). Otherwise, print NO.\n\nSample Input 1\n\n5 5 7\n\nSample Output 1\n\nYES\n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\nSample Input 2\n\n7 7 5\n\nSample Output 2\n\nNO", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 993, "cpu_time_ms": 345, "memory_kb": 25552}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s026938721", "group_id": "codeNet:p04043", "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 if (sc.nextLine.split(\" \").map(_.toInt).sorted sameElements Array(5, 5, 7)) println(\"YES\")\n else println(\"NO\")\n }\n}\n", "language": "Scala", "metadata": {"date": 1557790438, "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/s026938721.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s026938721", "user_id": "u629133942"}, "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: Scanner = new Scanner(System.in)\n if (sc.nextLine.split(\" \").map(_.toInt).sorted sameElements Array(5, 5, 7)) println(\"YES\")\n else println(\"NO\")\n }\n}\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIroha loves Haiku. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.\n\nTo create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.\n\nConstraints\n\n1≦A,B,C≦10\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf it is possible to construct a Haiku by using each of the phrases once, print YES (case-sensitive). Otherwise, print NO.\n\nSample Input 1\n\n5 5 7\n\nSample Output 1\n\nYES\n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\nSample Input 2\n\n7 7 5\n\nSample Output 2\n\nNO", "sample_input": "5 5 7\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p04043", "source_text": "Score : 100 points\n\nProblem Statement\n\nIroha loves Haiku. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.\n\nTo create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.\n\nConstraints\n\n1≦A,B,C≦10\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf it is possible to construct a Haiku by using each of the phrases once, print YES (case-sensitive). Otherwise, print NO.\n\nSample Input 1\n\n5 5 7\n\nSample Output 1\n\nYES\n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\nSample Input 2\n\n7 7 5\n\nSample Output 2\n\nNO", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 251, "cpu_time_ms": 342, "memory_kb": 27192}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s535745859", "group_id": "codeNet:p04045", "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 def readLines(n: Int) = Array.fill(n)(readLine)\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 def ** (exp: Int): Int = scala.math.pow(i, exp).intValue\n }\n\n implicit class LongImplicits(val i: Long) {\n def isEven = i % 2 == 0\n def isOdd = !isEven\n\n def ** (exp: Long): Long = scala.math.pow(i, exp).longValue\n }\n\n def mycomb[T](n: Int, l: List[T]): List[List[T]] =\n n match {\n case 0 => List(List())\n case _ => for(el <- l;\n sl <- mycomb(n-1, l dropWhile { _ != el } ))\n yield el :: sl\n }\n \n def comb[T](n: Int, l: List[T]): List[List[T]] = mycomb(n, l.distinct)\n}\n\nobject Main extends App {\n import Helpers._\n\n val Array(n, k) = readIntLine\n val ds = readLine.split(\" \")\n\n val u = n to 100000000\n val x = u.dropWhile(_.toString.split(\"\").exists(ds.contains))\n\n println(x.head)\n}\n\n", "language": "Scala", "metadata": {"date": 1589122888, "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/s535745859.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s535745859", "user_id": "u174523836"}, "prompt_components": {"gold_output": "2000\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 def readLines(n: Int) = Array.fill(n)(readLine)\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 def ** (exp: Int): Int = scala.math.pow(i, exp).intValue\n }\n\n implicit class LongImplicits(val i: Long) {\n def isEven = i % 2 == 0\n def isOdd = !isEven\n\n def ** (exp: Long): Long = scala.math.pow(i, exp).longValue\n }\n\n def mycomb[T](n: Int, l: List[T]): List[List[T]] =\n n match {\n case 0 => List(List())\n case _ => for(el <- l;\n sl <- mycomb(n-1, l dropWhile { _ != el } ))\n yield el :: sl\n }\n \n def comb[T](n: Int, l: List[T]): List[List[T]] = mycomb(n, l.distinct)\n}\n\nobject Main extends App {\n import Helpers._\n\n val Array(n, k) = readIntLine\n val ds = readLine.split(\" \")\n\n val u = n to 100000000\n val x = u.dropWhile(_.toString.split(\"\").exists(ds.contains))\n\n println(x.head)\n}\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.\n\nShe is shopping, and now paying at the cashier.\nHer total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).\n\nHowever, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.\n\nFind the amount of money that she will hand to the cashier.\n\nConstraints\n\n1 ≦ N < 10000\n\n1 ≦ K < 10\n\n0 ≦ D_1 < D_2 < … < D_K≦9\n\n\\{D_1,D_2,...,D_K\\} ≠ \\{1,2,3,4,5,6,7,8,9\\}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\nD_1 D_2 … D_K\n\nOutput\n\nPrint the amount of money that Iroha will hand to the cashier.\n\nSample Input 1\n\n1000 8\n1 3 4 5 6 7 8 9\n\nSample Output 1\n\n2000\n\nShe dislikes all digits except 0 and 2.\n\nThe smallest integer equal to or greater than N=1000 whose decimal notation contains only 0 and 2, is 2000.\n\nSample Input 2\n\n9999 1\n0\n\nSample Output 2\n\n9999", "sample_input": "1000 8\n1 3 4 5 6 7 8 9\n"}, "reference_outputs": ["2000\n"], "source_document_id": "p04045", "source_text": "Score : 300 points\n\nProblem Statement\n\nIroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.\n\nShe is shopping, and now paying at the cashier.\nHer total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).\n\nHowever, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.\n\nFind the amount of money that she will hand to the cashier.\n\nConstraints\n\n1 ≦ N < 10000\n\n1 ≦ K < 10\n\n0 ≦ D_1 < D_2 < … < D_K≦9\n\n\\{D_1,D_2,...,D_K\\} ≠ \\{1,2,3,4,5,6,7,8,9\\}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\nD_1 D_2 … D_K\n\nOutput\n\nPrint the amount of money that Iroha will hand to the cashier.\n\nSample Input 1\n\n1000 8\n1 3 4 5 6 7 8 9\n\nSample Output 1\n\n2000\n\nShe dislikes all digits except 0 and 2.\n\nThe smallest integer equal to or greater than N=1000 whose decimal notation contains only 0 and 2, is 2000.\n\nSample Input 2\n\n9999 1\n0\n\nSample Output 2\n\n9999", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1152, "cpu_time_ms": 707, "memory_kb": 55480}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s526063600", "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 = 1000\n var flag = false\n\n for (i <- 0 to 9) {\n if (xss.contains(i)) {\n ten = ten.filter {\n _ != i\n }\n }\n }\n\n\n for(i <- fee to 10000){\n if(!flag) {\n if ((ten.contains(i / 1000) || fee / 1000 == 0) &&\n (ten.contains(i % 1000 / 100) || (fee / 1000 == 0 && fee % 1000 / 100 == 0)) &&\n (ten.contains(i % 100 / 10) || (fee / 1000 == 0 && fee % 1000 / 100 == 0 && fee % 100 / 10 == 0)) &&\n (ten.contains(i % 10))) {\n flag = true\n cash = i\n }\n }\n }\n\n if(!flag) cash = ten.head * 11111\n\n print(cash)\n\n}", "language": "Scala", "metadata": {"date": 1585275224, "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/s526063600.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s526063600", "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 = 1000\n var flag = false\n\n for (i <- 0 to 9) {\n if (xss.contains(i)) {\n ten = ten.filter {\n _ != i\n }\n }\n }\n\n\n for(i <- fee to 10000){\n if(!flag) {\n if ((ten.contains(i / 1000) || fee / 1000 == 0) &&\n (ten.contains(i % 1000 / 100) || (fee / 1000 == 0 && fee % 1000 / 100 == 0)) &&\n (ten.contains(i % 100 / 10) || (fee / 1000 == 0 && fee % 1000 / 100 == 0 && fee % 100 / 10 == 0)) &&\n (ten.contains(i % 10))) {\n flag = true\n cash = i\n }\n }\n }\n\n if(!flag) cash = ten.head * 11111\n\n print(cash)\n\n}", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.\n\nShe is shopping, and now paying at the cashier.\nHer total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).\n\nHowever, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.\n\nFind the amount of money that she will hand to the cashier.\n\nConstraints\n\n1 ≦ N < 10000\n\n1 ≦ K < 10\n\n0 ≦ D_1 < D_2 < … < D_K≦9\n\n\\{D_1,D_2,...,D_K\\} ≠ \\{1,2,3,4,5,6,7,8,9\\}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\nD_1 D_2 … D_K\n\nOutput\n\nPrint the amount of money that Iroha will hand to the cashier.\n\nSample Input 1\n\n1000 8\n1 3 4 5 6 7 8 9\n\nSample Output 1\n\n2000\n\nShe dislikes all digits except 0 and 2.\n\nThe smallest integer equal to or greater than N=1000 whose decimal notation contains only 0 and 2, is 2000.\n\nSample Input 2\n\n9999 1\n0\n\nSample Output 2\n\n9999", "sample_input": "1000 8\n1 3 4 5 6 7 8 9\n"}, "reference_outputs": ["2000\n"], "source_document_id": "p04045", "source_text": "Score : 300 points\n\nProblem Statement\n\nIroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.\n\nShe is shopping, and now paying at the cashier.\nHer total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).\n\nHowever, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.\n\nFind the amount of money that she will hand to the cashier.\n\nConstraints\n\n1 ≦ N < 10000\n\n1 ≦ K < 10\n\n0 ≦ D_1 < D_2 < … < D_K≦9\n\n\\{D_1,D_2,...,D_K\\} ≠ \\{1,2,3,4,5,6,7,8,9\\}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\nD_1 D_2 … D_K\n\nOutput\n\nPrint the amount of money that Iroha will hand to the cashier.\n\nSample Input 1\n\n1000 8\n1 3 4 5 6 7 8 9\n\nSample Output 1\n\n2000\n\nShe dislikes all digits except 0 and 2.\n\nThe smallest integer equal to or greater than N=1000 whose decimal notation contains only 0 and 2, is 2000.\n\nSample Input 2\n\n9999 1\n0\n\nSample Output 2\n\n9999", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 813, "cpu_time_ms": 352, "memory_kb": 27320}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s195735487", "group_id": "codeNet:p04045", "input_text": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val scanner = new Scanner(System.in)\n val n: Int = scanner.nextInt\n val k: Int = scanner.nextInt\n val hates: List[Int] = List.fill(k)(scanner.nextInt)\n\n println(calc(n, hates))\n }\n\n def calc( n: Int, hates: List[Int]): Int ={\n (n to (10*n)).find(p => p >= n && !isIncludingHateNum(p, hates)).get\n }\n\n def isIncludingHateNum(payment: Int, hates: List[Int]): Boolean ={\n val pays:List[Int] = (payment.toString.grouped(1)).toList.map(_.toInt)\n pays.exists(hates.contains(_))\n }\n}\n", "language": "Scala", "metadata": {"date": 1538065946, "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/s195735487.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s195735487", "user_id": "u817196359"}, "prompt_components": {"gold_output": "2000\n", "input_to_evaluate": "import java.util.Scanner\n\nobject Main {\n def main(args: Array[String]): Unit = {\n val scanner = new Scanner(System.in)\n val n: Int = scanner.nextInt\n val k: Int = scanner.nextInt\n val hates: List[Int] = List.fill(k)(scanner.nextInt)\n\n println(calc(n, hates))\n }\n\n def calc( n: Int, hates: List[Int]): Int ={\n (n to (10*n)).find(p => p >= n && !isIncludingHateNum(p, hates)).get\n }\n\n def isIncludingHateNum(payment: Int, hates: List[Int]): Boolean ={\n val pays:List[Int] = (payment.toString.grouped(1)).toList.map(_.toInt)\n pays.exists(hates.contains(_))\n }\n}\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.\n\nShe is shopping, and now paying at the cashier.\nHer total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).\n\nHowever, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.\n\nFind the amount of money that she will hand to the cashier.\n\nConstraints\n\n1 ≦ N < 10000\n\n1 ≦ K < 10\n\n0 ≦ D_1 < D_2 < … < D_K≦9\n\n\\{D_1,D_2,...,D_K\\} ≠ \\{1,2,3,4,5,6,7,8,9\\}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\nD_1 D_2 … D_K\n\nOutput\n\nPrint the amount of money that Iroha will hand to the cashier.\n\nSample Input 1\n\n1000 8\n1 3 4 5 6 7 8 9\n\nSample Output 1\n\n2000\n\nShe dislikes all digits except 0 and 2.\n\nThe smallest integer equal to or greater than N=1000 whose decimal notation contains only 0 and 2, is 2000.\n\nSample Input 2\n\n9999 1\n0\n\nSample Output 2\n\n9999", "sample_input": "1000 8\n1 3 4 5 6 7 8 9\n"}, "reference_outputs": ["2000\n"], "source_document_id": "p04045", "source_text": "Score : 300 points\n\nProblem Statement\n\nIroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.\n\nShe is shopping, and now paying at the cashier.\nHer total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).\n\nHowever, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.\n\nFind the amount of money that she will hand to the cashier.\n\nConstraints\n\n1 ≦ N < 10000\n\n1 ≦ K < 10\n\n0 ≦ D_1 < D_2 < … < D_K≦9\n\n\\{D_1,D_2,...,D_K\\} ≠ \\{1,2,3,4,5,6,7,8,9\\}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\nD_1 D_2 … D_K\n\nOutput\n\nPrint the amount of money that Iroha will hand to the cashier.\n\nSample Input 1\n\n1000 8\n1 3 4 5 6 7 8 9\n\nSample Output 1\n\n2000\n\nShe dislikes all digits except 0 and 2.\n\nThe smallest integer equal to or greater than N=1000 whose decimal notation contains only 0 and 2, is 2000.\n\nSample Input 2\n\n9999 1\n0\n\nSample Output 2\n\n9999", "split": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 627, "cpu_time_ms": 1250, "memory_kb": 105520}, "variant": "medium_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:Scala:s627236125", "group_id": "codeNet:p04048", "input_text": "\nimport java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val n, x = sc.nextLong\n\n println(n * 2 + x)\n}\n", "language": "Scala", "metadata": {"date": 1551404236, "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/s627236125.scala", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s627236125", "user_id": "u726872801"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "\nimport java.util.Scanner\n\nobject Main extends App {\n val sc = new Scanner(System.in)\n\n val n, x = sc.nextLong\n\n println(n * 2 + x)\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": "validation", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 350, "memory_kb": 27332}, "variant": "medium_resource"}